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
41 ;; Site dependent variables. These variables should be defined in
44 (defvar gnus-default-nntp-server nil
45 "Specify a default NNTP server.
46 This variable should be defined in paths.el, and should never be set
48 If you want to change servers, you should use `gnus-select-method'.
49 See the documentation to that variable.")
51 (defconst gnus-backup-default-subscribed-newsgroups
52 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
53 "Default default new newsgroups the first time Gnus is run.
54 Should be set in paths.el, and shouldn't be touched by the user.")
56 (defvar gnus-local-domain nil
57 "Local domain name without a host name.
58 The DOMAINNAME environment variable is used instead if it is defined.
59 If the `system-name' function returns the full Internet name, there is
60 no need to set this variable.")
62 (defvar gnus-local-organization nil
63 "String with a description of what organization (if any) the user belongs to.
64 The ORGANIZATION environment variable is used instead if it is defined.
65 If this variable contains a function, this function will be called
66 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.")
494 (defvar gnus-group-always-list-unread gnus-level-subscribed
495 "*Always list groups less than this variable with unread articles.
496 If nil, use parameter to specify.")
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-move-group nil)
1118 (defvar gnus-newsgroup-dependencies nil)
1119 (defvar gnus-newsgroup-threads nil)
1120 (defvar gnus-newsgroup-async nil)
1121 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1123 (defvar gnus-newsgroup-adaptive nil)
1125 (defconst gnus-group-line-format-alist
1126 (list (list ?M 'marked ?c)
1127 (list ?S 'subscribed ?c)
1129 (list ?N 'number ?s)
1130 (list ?I 'number-of-dormant ?d)
1131 (list ?T 'number-of-ticked ?d)
1132 (list ?R 'number-of-read ?s)
1133 (list ?t 'number-total ?d)
1134 (list ?y 'number-of-unread-unticked ?s)
1135 (list ?i 'number-of-ticked-and-dormant ?d)
1137 (list ?G 'qualified-group ?s)
1138 (list ?D 'newsgroup-description ?s)
1139 (list ?o 'moderated ?c)
1140 (list ?O 'moderated-string ?s)
1141 (list ?s 'news-server ?s)
1142 (list ?n 'news-method ?s)
1143 (list ?z 'news-method-string ?s)
1144 (list ?u 'user-defined ?s)))
1146 (defconst gnus-summary-line-format-alist
1147 (list (list ?N 'number ?d)
1148 (list ?S 'subject ?s)
1149 (list ?s 'subject-or-nil ?s)
1151 (list ?A 'address ?s)
1153 (list ?x (macroexpand '(header-xref header)) ?s)
1154 (list ?D (macroexpand '(header-date header)) ?s)
1155 (list ?d '(gnus-dd-mmm (header-date header)) ?s)
1156 (list ?M (macroexpand '(header-id header)) ?s)
1157 (list ?r (macroexpand '(header-references header)) ?s)
1158 (list ?c '(or (header-chars header) 0) ?d)
1160 (list ?I 'indentation ?s)
1161 (list ?T '(if (= level 0) "" (make-string (frame-width) ? )) ?s)
1162 (list ?R 'replied ?c)
1163 (list ?\[ 'opening-bracket ?c)
1164 (list ?\] 'closing-bracket ?c)
1165 (list ?\> '(make-string level ? ) ?s)
1166 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1168 (list ?z 'score-char ?c)
1169 (list ?U 'unread ?c)
1170 (list ?t '(gnus-summary-number-of-articles-in-thread
1171 (or gnus-tmp-adopt-thread
1172 (if (boundp 'thread) (symbol-value 'thread)
1175 (list ?e '(gnus-summary-number-of-articles-in-thread
1176 (or gnus-tmp-adopt-thread
1177 (if (boundp 'thread) (symbol-value 'thread)
1180 (list ?u 'user-defined ?s))
1181 "An alist of format specifications that can appear in summary lines,
1182 and what variables they correspond with, along with the type of the
1183 variable (string, integer, character, etc).")
1185 (defconst gnus-summary-dummy-line-format-alist
1186 (list (list ?S 'subject ?s)
1187 (list ?N 'number ?d)
1188 (list ?u 'user-defined ?s)))
1190 (defconst gnus-summary-mode-line-format-alist
1191 (list (list ?G 'group-name ?s)
1192 (list ?g '(gnus-short-group-name group-name) ?s)
1193 (list ?A 'article-number ?d)
1194 (list ?Z 'unread-and-unselected ?s)
1195 (list ?V 'gnus-version ?s)
1196 (list ?U 'unread ?d)
1197 (list ?S 'subject ?s)
1198 (list ?e 'unselected ?d)
1199 (list ?u 'user-defined ?s)
1200 (list ?s '(gnus-current-score-file-nondirectory) ?s)))
1202 (defconst gnus-group-mode-line-format-alist
1203 (list (list ?S 'news-server ?s)
1204 (list ?M 'news-method ?s)
1205 (list ?u 'user-defined ?s)))
1207 (defvar gnus-have-read-active-file nil)
1209 (defconst gnus-maintainer "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls & Boys)"
1210 "The mail address of the Gnus maintainer.")
1212 (defconst gnus-version "(ding) Gnus v0.71"
1213 "Version number for this version of Gnus.")
1215 (defvar gnus-info-nodes
1216 '((gnus-group-mode "(gnus)The Group Buffer")
1217 (gnus-summary-mode "(gnus)The Summary Buffer")
1218 (gnus-article-mode "(gnus)The Article Buffer"))
1219 "Assoc list of major modes and related Info nodes.")
1221 (defvar gnus-documentation-group-file "~/dgnus/lisp/doc.txt"
1222 "The location of the (ding) Gnus documentation group.")
1224 (defvar gnus-group-buffer "*Group*")
1225 (defvar gnus-summary-buffer "*Summary*")
1226 (defvar gnus-article-buffer "*Article*")
1227 (defvar gnus-server-buffer "*Server*")
1229 (defvar gnus-work-buffer " *gnus work*")
1231 (defvar gnus-buffer-list nil
1232 "Gnus buffers that should be killed on exit.")
1234 (defvar gnus-server-alist nil
1235 "List of available servers.")
1237 (defvar gnus-variable-list
1238 '(gnus-newsrc-options gnus-newsrc-options-n
1239 gnus-newsrc-last-checked-date
1240 gnus-newsrc-alist gnus-server-alist
1241 gnus-killed-list gnus-zombie-list)
1242 "Gnus variables saved in the quick startup file.")
1244 (defvar gnus-overload-functions
1245 '((news-inews gnus-inews-news "rnewspost")
1246 (caesar-region gnus-caesar-region "rnews"))
1247 "Functions overloaded by gnus.
1248 It is a list of `(original overload &optional file)'.")
1250 (defvar gnus-newsrc-options nil
1251 "Options line in the .newsrc file.")
1253 (defvar gnus-newsrc-options-n nil
1254 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1256 (defvar gnus-newsrc-last-checked-date nil
1257 "Date Gnus last asked server for new newsgroups.")
1259 (defvar gnus-newsrc-alist nil
1260 "Assoc list of read articles.
1261 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1263 (defvar gnus-newsrc-hashtb nil
1264 "Hashtable of gnus-newsrc-alist.")
1266 (defvar gnus-killed-list nil
1267 "List of killed newsgroups.")
1269 (defvar gnus-killed-hashtb nil
1270 "Hash table equivalent of gnus-killed-list.")
1272 (defvar gnus-zombie-list nil
1273 "List of almost dead newsgroups.")
1275 (defvar gnus-description-hashtb nil
1276 "Descriptions of newsgroups.")
1278 (defvar gnus-list-of-killed-groups nil
1279 "List of newsgroups that have recently been killed by the user.")
1281 (defvar gnus-active-hashtb nil
1282 "Hashtable of active articles.")
1284 (defvar gnus-moderated-list nil
1285 "List of moderated newsgroups.")
1287 (defvar gnus-group-marked nil)
1289 (defvar gnus-current-startup-file nil
1290 "Startup file for the current host.")
1292 (defvar gnus-last-search-regexp nil
1293 "Default regexp for article search command.")
1295 (defvar gnus-last-shell-command nil
1296 "Default shell command on article.")
1298 (defvar gnus-current-select-method nil
1299 "The current method for selecting a newsgroup.")
1301 (defvar gnus-have-all-newsgroups nil)
1303 (defvar gnus-article-internal-prepare-hook nil)
1305 (defvar gnus-newsgroup-name nil)
1306 (defvar gnus-newsgroup-begin nil)
1307 (defvar gnus-newsgroup-end nil)
1308 (defvar gnus-newsgroup-last-rmail nil)
1309 (defvar gnus-newsgroup-last-mail nil)
1310 (defvar gnus-newsgroup-last-folder nil)
1311 (defvar gnus-newsgroup-last-file nil)
1312 (defvar gnus-newsgroup-auto-expire nil)
1313 (defvar gnus-newsgroup-active nil)
1315 (defvar gnus-newsgroup-unreads nil
1316 "List of unread articles in the current newsgroup.")
1318 (defvar gnus-newsgroup-unselected nil
1319 "List of unselected unread articles in the current newsgroup.")
1321 (defvar gnus-newsgroup-marked nil
1322 "List of ticked articles in the current newsgroup (a subset of unread art).")
1324 (defvar gnus-newsgroup-killed nil
1325 "List of ranges of articles that have been through the scoring process.")
1327 (defvar gnus-newsgroup-kill-headers nil)
1329 (defvar gnus-newsgroup-replied nil
1330 "List of articles that have been replied to in the current newsgroup.")
1332 (defvar gnus-newsgroup-expirable nil
1333 "List of articles in the current newsgroup that can be expired.")
1335 (defvar gnus-newsgroup-processable nil
1336 "List of articles in the current newsgroup that can be processed.")
1338 (defvar gnus-newsgroup-bookmarks nil
1339 "List of articles in the current newsgroup that have bookmarks.")
1341 (defvar gnus-newsgroup-dormant nil
1342 "List of dormant articles in the current newsgroup.")
1344 (defvar gnus-newsgroup-scored nil
1345 "List of scored articles in the current newsgroup.")
1347 (defvar gnus-newsgroup-headers nil
1348 "List of article headers in the current newsgroup.")
1349 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1351 (defvar gnus-newsgroup-ancient nil
1352 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1354 (defvar gnus-current-article nil)
1355 (defvar gnus-article-current nil)
1356 (defvar gnus-current-headers nil)
1357 (defvar gnus-have-all-headers nil)
1358 (defvar gnus-last-article nil)
1359 (defvar gnus-newsgroup-history nil)
1360 (defvar gnus-current-kill-article nil)
1362 ;; Save window configuration.
1363 (defvar gnus-prev-winconf nil)
1366 (defvar gnus-summary-line-format-spec nil)
1367 (defvar gnus-summary-dummy-line-format-spec nil)
1368 (defvar gnus-group-line-format-spec nil)
1369 (defvar gnus-summary-mode-line-format-spec nil)
1370 (defvar gnus-article-mode-line-format-spec nil)
1371 (defvar gnus-group-mode-line-format-spec nil)
1372 (defvar gnus-summary-mark-positions nil)
1374 (defvar gnus-summary-expunge-below nil)
1375 (defvar gnus-reffed-article-number nil)
1377 (defvar rmail-default-file (expand-file-name "~/XMBOX"))
1378 (defvar rmail-default-rmail-file (expand-file-name "~/XNEWS"))
1380 (defconst gnus-summary-local-variables
1381 '(gnus-newsgroup-name
1382 gnus-newsgroup-begin gnus-newsgroup-end
1383 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1384 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1385 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1386 gnus-newsgroup-unselected gnus-newsgroup-marked
1387 gnus-newsgroup-replied gnus-newsgroup-expirable
1388 gnus-newsgroup-processable gnus-newsgroup-killed
1389 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1390 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1391 gnus-current-article gnus-current-headers gnus-have-all-headers
1392 gnus-last-article gnus-article-internal-prepare-hook
1393 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1394 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1395 gnus-newsgroup-threads gnus-newsgroup-async
1396 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1397 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1398 gnus-newsgroup-history gnus-newsgroup-ancient
1399 gnus-newsgroup-adaptive)
1400 "Variables that are buffer-local to the summary buffers.")
1402 (defconst gnus-bug-message
1403 "Sending a bug report to the Gnus Towers.
1404 ========================================
1406 The buffer below is a mail buffer. When you press `C-c C-c', it will
1407 be sent to the Gnus Bug Exterminators.
1409 At the bottom of the buffer you'll see lots of variable settings.
1410 Please do not delete those. They will tell the Bug People what your
1411 environment is, so that it will be easier to locate the bugs.
1413 If you have found a bug that makes Emacs go \"beep\", set
1414 debug-on-error to t (`M-ESC (setq debug-on-error t)') and include the
1415 backtrace in your bug report.
1417 Please describe the bug in annoying, painstaking detail.
1419 Thank you for your help in stamping out bugs.
1422 ;;; End of variables.
1424 ;; Define some autoload functions Gnus might use.
1428 (autoload 'metamail-buffer "metamail")
1429 (autoload 'Info-goto-node "info")
1430 (autoload 'hexl-hex-string-to-integer "hexl")
1432 (autoload 'pp-to-string "pp")
1433 (autoload 'pp-eval-expression "pp")
1434 (autoload 'mail-extract-address-components "mail-extr")
1436 (autoload 'nnmail-split-fancy "nnmail")
1439 (autoload 'timezone-make-date-arpa-standard "timezone")
1440 (autoload 'timezone-fix-time "timezone")
1441 (autoload 'timezone-make-sortable-date "timezone")
1442 (autoload 'timezone-make-time-string "timezone")
1445 (autoload 'mail-position-on-field "sendmail")
1446 (autoload 'mail-setup "sendmail")
1447 (autoload 'rmail-output "rmailout")
1448 (autoload 'news-mail-other-window "rnewspost")
1449 (autoload 'news-reply-yank-original "rnewspost")
1450 (autoload 'news-caesar-buffer-body "rnewspost")
1451 (autoload 'rmail-insert-rmail-file-header "rmail")
1452 (autoload 'rmail-count-new-messages "rmail")
1453 (autoload 'rmail-show-message "rmail")
1456 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1457 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1458 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1459 (autoload 'gnus-summary-save-in-folder "gnus-mh")
1460 (autoload 'gnus-Folder-save-name "gnus-mh")
1461 (autoload 'gnus-folder-save-name "gnus-mh")
1464 (autoload 'gnus-group-make-menu-bar "gnus-vis")
1465 (autoload 'gnus-summary-make-menu-bar "gnus-vis")
1466 (autoload 'gnus-server-make-menu-bar "gnus-vis")
1467 (autoload 'gnus-article-make-menu-bar "gnus-vis")
1468 (autoload 'gnus-browse-make-menu-bar "gnus-vis")
1469 (autoload 'gnus-highlight-selected-summary "gnus-vis")
1470 (autoload 'gnus-summary-highlight-line "gnus-vis")
1471 (autoload 'gnus-carpal-setup-buffer "gnus-vis")
1474 (autoload 'gnus-article-push-button "gnus-vis" nil t)
1475 (autoload 'gnus-article-press-button "gnus-vis" nil t)
1476 (autoload 'gnus-article-highlight "gnus-vis" nil t)
1477 (autoload 'gnus-article-hide "gnus-vis" nil t)
1478 (autoload 'gnus-article-hide-signature "gnus-vis" nil t)
1479 (autoload 'gnus-article-highlight-headers "gnus-vis" nil t)
1480 (autoload 'gnus-article-highlight-signature "gnus-vis" nil t)
1481 (autoload 'gnus-article-add-buttons "gnus-vis" nil t)
1482 (autoload 'gnus-article-next-button "gnus-vis" nil t)
1483 (autoload 'gnus-article-add-button "gnus-vis")
1486 (autoload 'gnus-article-highlight-citation "gnus-cite" nil t)
1487 (autoload 'gnus-article-hide-citation-maybe "gnus-cite" nil t)
1488 (autoload 'gnus-article-hide-citation "gnus-cite" nil t)
1491 (autoload 'gnus-kill "gnus-kill")
1492 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1493 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1494 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1495 (autoload 'gnus-execute "gnus-kill")
1496 (autoload 'gnus-expunge "gnus-kill")
1499 (autoload 'gnus-cache-possibly-enter-article "gnus-cache")
1500 (autoload 'gnus-cache-save-buffers "gnus-cache")
1501 (autoload 'gnus-cache-possibly-remove-article "gnus-cache")
1502 (autoload 'gnus-cache-request-article "gnus-cache")
1503 (autoload 'gnus-cache-retrieve-headers "gnus-cache")
1504 (autoload 'gnus-cache-possibly-alter-active "gnus-cache")
1505 (autoload 'gnus-jog-cache "gnus-cache" nil t)
1508 (autoload 'gnus-summary-increase-score "gnus-score" nil t)
1509 (autoload 'gnus-summary-lower-score "gnus-score" nil t)
1510 (autoload 'gnus-summary-score-map "gnus-score" nil nil 'keymap)
1511 (autoload 'gnus-score-save "gnus-score")
1512 (autoload 'gnus-score-headers "gnus-score")
1513 (autoload 'gnus-current-score-file-nondirectory "gnus-score")
1514 (autoload 'gnus-score-adaptive "gnus-score")
1515 (autoload 'gnus-score-remove-lines-adaptive "gnus-score")
1516 (autoload 'gnus-possibly-score-headers "gnus-score")
1519 (autoload 'gnus-uu-extract-map "gnus-uu" nil nil 'keymap)
1520 (autoload 'gnus-uu-mark-map "gnus-uu" nil nil 'keymap)
1521 (autoload 'gnus-uu-digest-mail-forward "gnus-uu" nil t)
1522 (autoload 'gnus-uu-digest-post-forward "gnus-uu" nil t)
1523 (autoload 'gnus-uu-mark-series "gnus-uu" nil t)
1524 (autoload 'gnus-uu-mark-region "gnus-uu" nil t)
1525 (autoload 'gnus-uu-mark-by-regexp "gnus-uu" nil t)
1526 (autoload 'gnus-uu-mark-all "gnus-uu" nil t)
1527 (autoload 'gnus-uu-mark-sparse "gnus-uu" nil t)
1528 (autoload 'gnus-uu-mark-thread "gnus-uu" nil t)
1529 (autoload 'gnus-uu-decode-uu "gnus-uu" nil t)
1530 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu" nil t)
1531 (autoload 'gnus-uu-decode-unshar "gnus-uu" nil t)
1532 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu" nil t)
1533 (autoload 'gnus-uu-decode-save "gnus-uu" nil t)
1534 (autoload 'gnus-uu-decode-binhex "gnus-uu" nil t)
1537 (autoload 'gnus-summary-send-map "gnus-msg" nil nil 'keymap)
1538 (autoload 'gnus-group-post-news "gnus-msg" nil t)
1539 (autoload 'gnus-summary-post-news "gnus-msg" nil t)
1540 (autoload 'gnus-summary-followup "gnus-msg" nil t)
1541 (autoload 'gnus-summary-followup-with-original "gnus-msg" nil t)
1542 (autoload 'gnus-summary-followup-and-reply "gnus-msg" nil t)
1543 (autoload 'gnus-summary-followup-and-reply-with-original "gnus-msg" nil t)
1544 (autoload 'gnus-summary-cancel-article "gnus-msg" nil t)
1545 (autoload 'gnus-summary-supersede-article "gnus-msg" nil t)
1546 (autoload 'gnus-post-news "gnus-msg" nil t)
1547 (autoload 'gnus-inews-news "gnus-msg" nil t)
1548 (autoload 'gnus-cancel-news "gnus-msg" nil t)
1549 (autoload 'gnus-summary-reply "gnus-msg" nil t)
1550 (autoload 'gnus-summary-reply-with-original "gnus-msg" nil t)
1551 (autoload 'gnus-summary-mail-forward "gnus-msg" nil t)
1552 (autoload 'gnus-summary-mail-other-window "gnus-msg" nil t)
1553 (autoload 'gnus-mail-reply-using-mail "gnus-msg")
1554 (autoload 'gnus-mail-yank-original "gnus-msg")
1555 (autoload 'gnus-mail-send-and-exit "gnus-msg")
1556 (autoload 'gnus-mail-forward-using-mail "gnus-msg")
1557 (autoload 'gnus-mail-other-window-using-mail "gnus-msg")
1558 (autoload 'gnus-article-mail-with-original "gnus-msg")
1559 (autoload 'gnus-article-mail "gnus-msg")
1562 (autoload 'gnus-summary-save-in-vm "gnus-vm" nil t)
1563 (autoload 'gnus-mail-forward-using-vm "gnus-vm")
1564 (autoload 'gnus-mail-reply-using-vm "gnus-vm")
1565 (autoload 'gnus-mail-other-window-using-vm "gnus-vm" nil t)
1566 (autoload 'gnus-yank-article "gnus-vm" nil t)
1572 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1573 ;; If you want the cursor to go somewhere else, set these two
1574 ;; functions in some startup hook to whatever you want.
1575 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon)
1576 (defalias 'gnus-group-position-cursor 'gnus-goto-colon)
1578 ;;; Various macros and substs.
1580 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1581 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1582 (` (let ((GnusStartBufferWindow (selected-window)))
1585 (pop-to-buffer (, buffer))
1587 (select-window GnusStartBufferWindow)))))
1589 (defmacro gnus-gethash (string hashtable)
1590 "Get hash value of STRING in HASHTABLE."
1591 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1592 ;;(` (abbrev-expansion (, string) (, hashtable)))
1593 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1595 (defmacro gnus-sethash (string value hashtable)
1596 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1597 ;; We cannot use define-abbrev since it only accepts string as value.
1598 ;; (set (intern string hashtable) value))
1599 (` (set (intern (, string) (, hashtable)) (, value))))
1601 (defsubst gnus-buffer-substring (beg end)
1602 (buffer-substring (match-beginning beg) (match-end end)))
1604 (defsubst gnus-simplify-subject-re (subject)
1605 "Remove \"Re:\" from subject lines."
1606 (let ((case-fold-search t))
1607 (if (string-match "^re: *" subject)
1608 (substring subject (match-end 0))
1611 (defsubst gnus-goto-char (point)
1612 (and point (goto-char point)))
1614 (defmacro gnus-buffer-exists-p (buffer)
1616 (funcall (if (stringp (, buffer)) 'get-buffer 'buffer-name)
1619 (defmacro gnus-kill-buffer (buffer)
1620 (` (if (gnus-buffer-exists-p (, buffer))
1621 (kill-buffer (, buffer)))))
1623 (defsubst gnus-point-at-bol ()
1624 "Return point at the beginning of line."
1631 (defsubst gnus-point-at-eol ()
1632 "Return point at the beginning of line."
1641 ;;; Gnus Utility Functions
1644 (defun gnus-extract-address-components (from)
1646 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1647 (setq address (substring from (match-beginning 0) (match-end 0))))
1649 (string-match (concat "<" (regexp-quote address) ">") from)
1650 (setq name (substring from 0 (1- (match-beginning 0)))))
1652 (and (string-match "(.+)" from)
1653 (setq name (substring from (1+ (match-beginning 0))
1654 (1- (match-end 0))))))
1655 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1656 (list (or name from) (or address from))))
1658 (defun gnus-fetch-field (field)
1659 "Return the value of the header FIELD of current article."
1662 (let ((case-fold-search t))
1663 (gnus-narrow-to-headers)
1664 (mail-fetch-field field)))))
1666 (defun gnus-goto-colon ()
1668 (search-forward ":" (gnus-point-at-eol) t))
1670 (defun gnus-narrow-to-headers ()
1673 (goto-char (point-min))
1674 (if (search-forward "\n\n")
1675 (narrow-to-region 1 (1- (point))))))
1677 (defun gnus-update-format-specifications ()
1678 (gnus-make-thread-indent-array)
1679 (setq gnus-summary-line-format-spec
1681 gnus-summary-line-format gnus-summary-line-format-alist))
1682 (gnus-update-summary-mark-positions)
1683 (setq gnus-summary-dummy-line-format-spec
1684 (gnus-parse-format gnus-summary-dummy-line-format
1685 gnus-summary-dummy-line-format-alist))
1686 (setq gnus-group-line-format-spec
1688 gnus-group-line-format
1689 gnus-group-line-format-alist))
1690 (if (and (string-match "%D" gnus-group-line-format)
1691 (not gnus-description-hashtb)
1692 gnus-read-active-file)
1693 (gnus-read-descriptions-file))
1694 (setq gnus-summary-mode-line-format-spec
1695 (gnus-parse-format gnus-summary-mode-line-format
1696 gnus-summary-mode-line-format-alist))
1697 (setq gnus-article-mode-line-format-spec
1698 (gnus-parse-format gnus-article-mode-line-format
1699 gnus-summary-mode-line-format-alist))
1700 (setq gnus-group-mode-line-format-spec
1701 (gnus-parse-format gnus-group-mode-line-format
1702 gnus-group-mode-line-format-alist)))
1704 (defun gnus-update-summary-mark-positions ()
1706 (let ((gnus-replied-mark 129)
1707 (gnus-score-below-mark 130)
1708 (gnus-score-over-mark 130)
1711 (gnus-set-work-buffer)
1712 (gnus-summary-insert-line
1713 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1714 (goto-char (point-min))
1715 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1717 (goto-char (point-min))
1718 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1719 (- (point) 2))) pos))
1720 (goto-char (point-min))
1721 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1722 (- (point) 2))) pos))
1723 (setq gnus-summary-mark-positions pos))))
1725 (defun gnus-format-max-width (form length)
1726 (let* ((val (eval form))
1727 (valstr (if (numberp val) (int-to-string val) val)))
1728 (if (> (length valstr) length)
1729 (substring valstr 0 length)
1732 (defun gnus-set-mouse-face (string)
1733 ;; Set mouse face property on STRING.
1734 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string)
1737 (defun gnus-parse-format (format spec-alist)
1738 ;; This function parses the FORMAT string with the help of the
1739 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1740 ;; string. If the FORMAT string contains the specifiers %( and %)
1741 ;; the text between them will have the mouse-face text property.
1742 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1743 (if (and gnus-visual gnus-mouse-face)
1744 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1745 (button (substring format (match-beginning 2) (match-end 2)))
1746 (post (substring format (match-beginning 3) (match-end 3))))
1748 (gnus-parse-simple-format pre spec-alist)
1749 (list 'gnus-set-mouse-face
1750 (gnus-parse-simple-format button spec-alist))
1751 (gnus-parse-simple-format post spec-alist)))
1752 (gnus-parse-simple-format
1753 (concat (substring format (match-beginning 1) (match-end 1))
1754 (substring format (match-beginning 2) (match-end 2))
1755 (substring format (match-beginning 3) (match-end 3)))
1757 (gnus-parse-simple-format format spec-alist)))
1759 (defun gnus-parse-simple-format (format spec-alist)
1760 ;; This function parses the FORMAT string with the help of the
1761 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1762 ;; string. The list will consist of the symbol `format', a format
1763 ;; specification string, and a list of forms depending on the
1766 spec flist fstring b newspec max-width elem beg)
1768 (gnus-set-work-buffer)
1770 (goto-char (point-min))
1771 (while (re-search-forward "%[-0-9]*\\(,[0-9]*\\)*\\(.\\)\\(.\\)?" nil t)
1772 (setq spec (string-to-char (buffer-substring (match-beginning 2)
1774 ;; First check if there are any specs that look anything like
1775 ;; "%12,12A", ie. with a "max width specification". These have
1776 ;; to be treated specially.
1777 (if (setq beg (match-beginning 1))
1780 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
1782 (setq beg (match-beginning 2)))
1783 ;; Find the specification from `spec-alist'.
1784 (if (not (setq elem (cdr (assq spec spec-alist))))
1785 (setq elem '("*" ?s)))
1786 ;; Treat user defined format specifiers specially
1787 (and (eq (car elem) 'user-defined)
1790 (list (intern (concat "gnus-user-format-function-"
1796 (delete-region (match-beginning 3) (match-end 3)))
1797 (if (not (zerop max-width))
1798 (let ((el (car elem)))
1799 (cond ((= (car (cdr elem)) ?c)
1800 (setq el (list 'char-to-string el)))
1801 ((= (car (cdr elem)) ?d)
1802 (numberp el) (setq el (list 'int-to-string el))))
1803 (setq flist (cons (list 'gnus-format-max-width el max-width)
1806 (setq flist (cons (car elem) flist))
1807 (setq newspec (car (cdr elem))))
1808 ;; Remove the old specification (and possibly a ",12" string).
1809 (delete-region beg (match-end 2))
1810 ;; Insert the new specification.
1813 (setq fstring (buffer-substring 1 (point-max))))
1814 (cons 'format (cons fstring (nreverse flist)))))
1816 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
1817 (defun gnus-read-init-file ()
1819 (or (and (file-exists-p gnus-init-file)
1820 ;; Don't try to load a directory.
1821 (not (file-directory-p gnus-init-file)))
1822 (file-exists-p (concat gnus-init-file ".el"))
1823 (file-exists-p (concat gnus-init-file ".elc")))
1824 (load gnus-init-file nil t)))
1826 (defun gnus-set-work-buffer ()
1827 (if (get-buffer gnus-work-buffer)
1829 (set-buffer gnus-work-buffer)
1831 (set-buffer (get-buffer-create gnus-work-buffer))
1832 (buffer-disable-undo (current-buffer))
1833 (gnus-add-current-to-buffer-list)))
1835 ;; Article file names when saving.
1837 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
1838 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1839 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
1840 Otherwise, it is like ~/News/news/group/num."
1843 (concat (if (gnus-use-long-file-name 'not-save)
1844 (gnus-capitalize-newsgroup newsgroup)
1845 (gnus-newsgroup-directory-form newsgroup))
1846 "/" (int-to-string (header-number headers)))
1847 (or gnus-article-save-directory "~/News"))))
1849 (string-equal (file-name-directory default)
1850 (file-name-directory last-file))
1851 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1853 (or last-file default))))
1855 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
1856 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1857 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group/num.
1858 Otherwise, it is like ~/News/news/group/num."
1861 (concat (if (gnus-use-long-file-name 'not-save)
1863 (gnus-newsgroup-directory-form newsgroup))
1864 "/" (int-to-string (header-number headers)))
1865 (or gnus-article-save-directory "~/News"))))
1867 (string-equal (file-name-directory default)
1868 (file-name-directory last-file))
1869 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1871 (or last-file default))))
1873 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
1874 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1875 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group.
1876 Otherwise, it is like ~/News/news/group/news."
1879 (if (gnus-use-long-file-name 'not-save)
1880 (gnus-capitalize-newsgroup newsgroup)
1881 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1882 (or gnus-article-save-directory "~/News"))))
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)
1892 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1893 (or gnus-article-save-directory "~/News"))))
1895 ;; For subscribing new newsgroup
1897 (defun gnus-subscribe-hierarchical-interactive (groups)
1898 (let ((groups (sort groups 'string<))
1899 prefixes prefix start rest ans group starts)
1901 (setq prefixes (list "^"))
1902 (while (and groups prefixes)
1903 (while (not (string-match (car prefixes) (car groups)))
1904 (setq prefixes (cdr prefixes)))
1905 (setq prefix (car prefixes))
1906 (setq start (1- (length prefix)))
1907 (if (and (string-match "[^\\.]\\." (car groups) start)
1910 (concat "^" (substring (car groups) 0 (match-end 0))))
1911 (string-match prefix (car (cdr groups))))
1913 (setq prefixes (cons prefix prefixes))
1914 (message "Descend hierarchy %s? ([y]nsq): "
1915 (substring prefix 1 (1- (length prefix))))
1916 (setq ans (read-char))
1919 (string-match prefix
1920 (setq group (car groups))))
1921 (setq gnus-killed-list
1922 (cons group gnus-killed-list))
1923 (gnus-sethash group group gnus-killed-hashtb)
1924 (setq groups (cdr groups)))
1925 (setq starts (cdr starts)))
1928 (string-match prefix
1929 (setq group (car groups))))
1930 (gnus-sethash group group gnus-killed-hashtb)
1931 (gnus-subscribe-alphabetically (car groups))
1932 (setq groups (cdr groups)))
1933 (setq starts (cdr starts)))
1936 (setq group (car groups))
1937 (setq gnus-killed-list (cons group gnus-killed-list))
1938 (gnus-sethash group group gnus-killed-hashtb)
1939 (setq groups (cdr groups))))
1941 (message "Subscribe %s? ([n]yq)" (car groups))
1942 (setq ans (read-char))
1943 (setq group (car groups))
1945 (gnus-subscribe-alphabetically (car groups))
1946 (gnus-sethash group group gnus-killed-hashtb))
1949 (setq group (car groups))
1950 (setq gnus-killed-list (cons group gnus-killed-list))
1951 (gnus-sethash group group gnus-killed-hashtb)
1952 (setq groups (cdr groups))))
1954 (setq gnus-killed-list (cons group gnus-killed-list))
1955 (gnus-sethash group group gnus-killed-hashtb)))
1956 (setq groups (cdr groups)))))))
1958 (defun gnus-subscribe-randomly (newsgroup)
1959 "Subscribe new NEWSGROUP by making it the first newsgroup."
1960 (gnus-subscribe-newsgroup newsgroup))
1962 (defun gnus-subscribe-alphabetically (newgroup)
1963 "Subscribe new NEWSGROUP and insert it in alphabetical order."
1964 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
1965 (let ((groups (cdr gnus-newsrc-alist))
1967 (while (and (not before) groups)
1968 (if (string< newgroup (car (car groups)))
1969 (setq before (car (car groups)))
1970 (setq groups (cdr groups))))
1971 (gnus-subscribe-newsgroup newgroup before)))
1973 (defun gnus-subscribe-hierarchically (newgroup)
1974 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
1975 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
1977 (set-buffer (find-file-noselect gnus-current-startup-file))
1978 (let ((groupkey newgroup)
1980 (while (and (not before) groupkey)
1981 (goto-char (point-min))
1983 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
1984 (while (and (re-search-forward groupkey-re nil t)
1986 (setq before (buffer-substring
1987 (match-beginning 1) (match-end 1)))
1988 (string< before newgroup)))))
1989 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
1991 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
1992 (substring groupkey (match-beginning 1) (match-end 1)))))
1993 (gnus-subscribe-newsgroup newgroup before))))
1995 (defun gnus-subscribe-interactively (newsgroup)
1996 "Subscribe new NEWSGROUP interactively.
1997 It is inserted in hierarchical newsgroup order if subscribed. If not,
1999 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
2000 (gnus-subscribe-hierarchically newsgroup)
2001 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
2003 (defun gnus-subscribe-zombies (newsgroup)
2004 "Make new NEWSGROUP a zombie group."
2005 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
2007 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2008 "Subscribe new NEWSGROUP.
2009 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2010 the first newsgroup."
2011 ;; We subscribe the group by changing its level to `subscribed'.
2012 (gnus-group-change-level
2013 newsgroup gnus-level-default-subscribed
2014 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2015 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2019 (defun gnus-newsgroup-directory-form (newsgroup)
2020 "Make hierarchical directory name from NEWSGROUP name."
2021 (let ((newsgroup (substring newsgroup 0)) ;Copy string.
2022 (len (length newsgroup))
2024 ;; If this is a foreign group, we don't want to translate the
2026 (if (setq idx (string-match ":" newsgroup))
2027 (aset newsgroup idx ?/)
2029 ;; Replace all occurrences of `.' with `/'.
2031 (if (= (aref newsgroup idx) ?.)
2032 (aset newsgroup idx ?/))
2033 (setq idx (1+ idx)))
2036 (defun gnus-make-directory (dir)
2037 "Make DIRECTORY recursively."
2038 (let* ((dir (expand-file-name dir default-directory))
2040 (if (string-match "/$" dir)
2041 (setq dir (substring dir 0 (match-beginning 0))))
2042 (while (not (file-exists-p dir))
2043 (setq dirs (cons dir dirs))
2044 (string-match "/[^/]+$" dir)
2045 (setq dir (substring dir 0 (match-beginning 0))))
2047 (make-directory (car dirs))
2048 (setq dirs (cdr dirs)))))
2050 (defun gnus-capitalize-newsgroup (newsgroup)
2051 "Capitalize NEWSGROUP name."
2052 (and (not (zerop (length newsgroup)))
2053 (concat (char-to-string (upcase (aref newsgroup 0)))
2054 (substring newsgroup 1))))
2058 (defun gnus-simplify-subject (subject &optional re-only)
2059 "Remove `Re:' and words in parentheses.
2060 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2061 (let ((case-fold-search t)) ;Ignore case.
2062 ;; Remove `Re:' and `Re^N:'.
2063 (if (string-match "^re:[ \t]*" subject)
2064 (setq subject (substring subject (match-end 0))))
2065 ;; Remove words in parentheses from end.
2067 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2068 (setq subject (substring subject 0 (match-beginning 0)))))
2069 ;; Return subject string.
2072 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2074 (defun gnus-simplify-subject-fuzzy (subject)
2075 (let ((case-fold-search t))
2077 (gnus-set-work-buffer)
2079 (gnus-simplify-buffer-fuzzy)
2082 (defun gnus-simplify-buffer-fuzzy ()
2083 (goto-char (point-min))
2084 (while (re-search-forward "^[ \t]*re:[ \t]*" nil t)
2085 (replace-match "" t t))
2086 (goto-char (point-min))
2087 (while (re-search-forward "[ \t\n]*([^()]*)[ \t\n]*$" nil t)
2088 (replace-match "" t t))
2089 (goto-char (point-min))
2090 (while (re-search-forward "[ \t]+" nil t)
2091 (replace-match " " t t))
2092 (goto-char (point-min))
2093 (while (re-search-forward "[ \t]+$" nil t)
2094 (replace-match "" t t))
2095 (goto-char (point-min))
2096 (while (re-search-forward "^[ \t]+" nil t)
2097 (replace-match "" t t)))
2099 ;; Add the current buffer to the list of buffers to be killed on exit.
2100 (defun gnus-add-current-to-buffer-list ()
2101 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list)))
2103 (defun gnus-string> (s1 s2)
2104 (not (or (string< s1 s2)
2107 ;; Functions accessing headers.
2108 ;; Functions are more convenient than macros in some cases.
2110 (defun gnus-header-number (header)
2111 (header-number header))
2113 (defun gnus-header-subject (header)
2114 (header-subject header))
2116 (defun gnus-header-from (header)
2117 (header-from header))
2119 (defun gnus-header-xref (header)
2120 (header-xref header))
2122 (defun gnus-header-lines (header)
2123 (header-lines header))
2125 (defun gnus-header-date (header)
2126 (header-date header))
2128 (defun gnus-header-id (header)
2131 (defun gnus-header-references (header)
2132 (header-references header))
2134 ;;; General various misc type functions.
2136 (defun gnus-clear-system ()
2137 "Clear all variables and buffers."
2138 ;; Clear Gnus variables.
2139 (let ((variables gnus-variable-list))
2141 (set (car variables) nil)
2142 (setq variables (cdr variables))))
2143 ;; Clear other internal variables.
2144 (setq gnus-list-of-killed-groups nil
2145 gnus-have-read-active-file nil
2146 gnus-newsrc-alist nil
2147 gnus-newsrc-hashtb nil
2148 gnus-killed-list nil
2149 gnus-zombie-list nil
2150 gnus-killed-hashtb nil
2151 gnus-active-hashtb nil
2152 gnus-moderated-list nil
2153 gnus-description-hashtb nil
2154 gnus-newsgroup-headers nil
2155 gnus-newsgroup-headers-hashtb-by-number nil
2156 gnus-newsgroup-name nil
2157 gnus-server-alist nil
2158 gnus-current-select-method nil)
2159 ;; Reset any score variables.
2160 (and (boundp 'gnus-score-cache)
2161 (set 'gnus-score-cache nil))
2162 (and (boundp 'gnus-internal-global-score-files)
2163 (set 'gnus-internal-global-score-files nil))
2164 ;; Kill the startup file.
2165 (and gnus-current-startup-file
2166 (get-file-buffer gnus-current-startup-file)
2167 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2168 ;; Save any cache buffers.
2169 (and gnus-use-cache (gnus-cache-save-buffers))
2170 ;; Clear the dribble buffer.
2171 (gnus-dribble-clear)
2172 ;; Kill global KILL file buffer.
2173 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2174 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2175 (gnus-kill-buffer nntp-server-buffer)
2176 ;; Kill Gnus buffers.
2177 (while gnus-buffer-list
2178 (gnus-kill-buffer (car gnus-buffer-list))
2179 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2181 (defun gnus-windows-old-to-new (setting)
2182 (if (symbolp setting)
2184 (cond ((eq setting 'SelectArticle)
2186 ((eq setting 'SelectSubject)
2188 ((eq setting 'SelectNewsgroup)
2191 (if (or (listp setting)
2192 (not (and gnus-window-configuration
2193 (memq setting '(group summary article)))))
2195 (let* ((setting (if (eq setting 'group)
2196 (if (assq 'newsgroup gnus-window-configuration)
2198 'newsgroups) setting))
2199 (elem (car (cdr (assq setting gnus-window-configuration))))
2200 (total (apply '+ elem))
2201 (types '(group summary article))
2202 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
2207 (or (zerop (nth i elem))
2209 (setq perc (/ (* 1.0 (nth 0 elem)) total))
2210 (setq out (cons (if (eq pbuf (nth i types))
2211 (vector (nth i types) perc 'point)
2212 (vector (nth i types) perc))
2215 (list (nreverse out)))))
2217 (defun gnus-configure-windows (setting)
2218 (setq setting (gnus-windows-old-to-new setting))
2219 (let ((r (if (symbolp setting)
2220 (cdr (assq setting gnus-buffer-configuration))
2222 (in-buf (current-buffer))
2223 rule val window w height hor ohor heights sub jump-buffer
2225 (or r (error "No such setting: %s" setting))
2227 ;; Either remove all windows or just remove all Gnus windows.
2228 (if gnus-use-full-window
2229 (delete-other-windows)
2230 (gnus-remove-some-windows)
2231 (switch-to-buffer nntp-server-buffer))
2237 ;; We have to do the (possible) horizontal splitting before the
2239 (if (and (listp (car hor))
2240 (eq (car (car hor)) 'horizontal))
2242 (split-window nil (floor (* (frame-width) (nth 1 (car hor)))) t)
2243 (setq hor (cdr hor))))
2245 ;; Go through the rules and eval the elements that are to be
2248 (if (setq val (if (vectorp (car hor)) (car hor) (eval (car hor))))
2250 ;; Expand short buffer name.
2251 (setq w (aref val 0))
2252 (and (setq w (cdr (assq w gnus-window-to-buffer)))
2254 (setq val (apply 'vector (mapcar (lambda (v) v) val)))
2256 (setq ohor (cons val ohor))))
2257 (setq hor (cdr hor)))
2258 (setq rule (cons (nreverse ohor) rule))
2260 (setq rule (nreverse rule))
2262 ;; We tally the window sizes.
2263 (setq total (window-height))
2265 (setq hor (car rule))
2266 (if (and (listp (car hor)) (eq (car (car hor)) 'horizontal))
2267 (setq hor (cdr hor)))
2270 (setq rel (aref (car hor) 1)
2272 (cond ((and (floatp rel) (= 1.0 rel))
2277 (max (floor (* total rel)) 4)))
2279 sub (+ sub (if (numberp (car heights)) (car heights) 0))
2281 (setq heights (nreverse heights)
2284 ;; We then go through these heighs and create windows for them.
2286 (setq height (car heights)
2287 heights (cdr heights))
2289 (setq height (- total sub)))
2291 (split-window nil height))
2292 (setq to-buf (aref (car hor) 0))
2297 (symbol-value (aref (car hor) 0)))
2299 (aref (car hor) 0))))
2300 (and (> (length (car hor)) 2)
2301 (eq (aref (car hor) 2) 'point)
2302 (setq jump-buffer (current-buffer)))
2304 (setq hor (cdr hor)))
2306 (setq rule (cdr rule)))
2308 ;; Finally, we pop to the buffer that's supposed to have point.
2309 (pop-to-buffer jump-buffer)
2312 (defun gnus-remove-some-windows ()
2313 (let ((buffers gnus-window-to-buffer)
2317 (setq buf (cdr (car buffers)))
2319 (setq buf (and (boundp buf) (symbol-value buf))))
2321 (get-buffer-window buf)
2326 (switch-to-buffer nntp-server-buffer)
2328 (delete-window (get-buffer-window buf)))))
2329 (setq buffers (cdr buffers)))
2330 (set-buffer nntp-server-buffer)))
2332 (defun gnus-version ()
2333 "Version numbers of this version of Gnus."
2335 (let ((methods gnus-valid-select-methods)
2338 ;; Go through all the legal select methods and add their version
2339 ;; numbers to the total version string. Only the backends that are
2340 ;; currently in use will have their message numbers taken into
2343 (setq meth (intern (concat (car (car methods)) "-version")))
2345 (stringp (symbol-value meth))
2346 (setq mess (concat mess "; " (symbol-value meth))))
2347 (setq methods (cdr methods)))
2348 (gnus-message 2 mess)))
2350 (defun gnus-info-find-node ()
2351 "Find Info documentation of Gnus."
2353 ;; Enlarge info window if needed.
2354 (let ((mode major-mode))
2355 (gnus-configure-windows 'info)
2356 (Info-goto-node (car (cdr (assq mode gnus-info-nodes))))))
2359 "Send a bug report to the Gnus maintainers."
2361 (let ((winconf (current-window-configuration)))
2362 (delete-other-windows)
2363 (switch-to-buffer "*Gnus Bug Help*")
2365 (insert gnus-bug-message)
2366 (goto-char (point-min))
2367 (pop-to-buffer "*Gnus Bug*")
2370 (mail-setup gnus-maintainer "[Gnus Bug Report] " nil nil nil nil)
2371 (make-local-variable 'gnus-prev-winconf)
2372 (setq gnus-prev-winconf winconf)
2373 (goto-char (point-min))
2374 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
2376 (insert (format "%s\n%s\n\n\n\n\n" (gnus-version) (emacs-version)))
2379 (goto-char (- b 3)))
2382 (defun gnus-debug ()
2383 "Attemps to go through the Gnus source file and report what variables have been changed.
2384 The source file has to be in the Emacs load path."
2386 (let ((files '("gnus.el" "gnus-msg.el" "gnus-score.el"))
2387 file dirs expr olist)
2389 (set-buffer (get-buffer-create " *gnus bug info*"))
2390 (buffer-disable-undo (current-buffer))
2391 (message "Please wait while we snoop your variables...")
2395 (setq dirs load-path)
2397 (if (not (file-exists-p
2398 (setq file (concat (file-name-as-directory
2399 (car dirs)) (car files)))))
2400 (setq dirs (cdr dirs))
2402 (insert-file-contents file)
2403 (goto-char (point-min))
2404 (or (re-search-forward "^;;* Internal variables" nil t)
2405 (error "Malformed sources in file %s" file))
2406 (narrow-to-region (point-min) (point))
2407 (goto-char (point-min))
2408 (while (setq expr (condition-case ()
2409 (read (current-buffer)) (error nil)))
2410 (and (eq (car expr) 'defvar)
2411 (stringp (nth 3 expr))
2412 (or (not (boundp (nth 1 expr)))
2413 (not (equal (eval (nth 2 expr))
2414 (symbol-value (nth 1 expr)))))
2415 (setq olist (cons (nth 1 expr) olist))))))
2416 (setq files (cdr files)))
2417 (kill-buffer (current-buffer)))
2418 (insert "------------------- Environment follows -------------------\n\n")
2420 (if (boundp (car olist))
2421 (insert "(setq " (symbol-name (car olist)) " '"
2422 (prin1-to-string (symbol-value (car olist))) ")\n")
2423 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
2424 (setq olist (cdr olist)))
2427 (defun gnus-overload-functions (&optional overloads)
2428 "Overload functions specified by optional argument OVERLOADS.
2429 If nothing is specified, use the variable gnus-overload-functions."
2431 (overloads (or overloads gnus-overload-functions)))
2433 (setq defs (car overloads))
2434 (setq overloads (cdr overloads))
2435 ;; Load file before overloading function if necessary. Make
2436 ;; sure we cannot use `require' always.
2437 (and (not (fboundp (car defs)))
2438 (car (cdr (cdr defs)))
2439 (load (car (cdr (cdr defs))) nil 'nomessage))
2440 (fset (car defs) (car (cdr defs))))))
2442 (defun gnus-replace-chars-in-string (string from to)
2443 "Replace characters in STRING from FROM to TO."
2444 (let ((string (substring string 0)) ;Copy string.
2445 (len (length string))
2447 ;; Replace all occurrences of FROM with TO.
2449 (if (= (aref string idx) from)
2450 (aset string idx to))
2451 (setq idx (1+ idx)))
2454 (defun gnus-days-between (date1 date2)
2455 ;; Return the number of days between date1 and date2.
2456 (- (gnus-day-number date1) (gnus-day-number date2)))
2458 (defun gnus-day-number (date)
2459 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2460 (timezone-parse-date date))))
2461 (timezone-absolute-from-gregorian
2462 (nth 1 dat) (nth 2 dat) (car dat))))
2464 ;; Returns a floating point number that says how many seconds have
2465 ;; lapsed between Jan 1 12:00:00 1970 and DATE.
2466 (defun gnus-seconds-since-epoch (date)
2467 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2468 (timezone-parse-date date)))
2469 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
2470 (timezone-parse-time
2471 (aref (timezone-parse-date date) 3))))
2472 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2473 (timezone-parse-date "Jan 1 12:00:00 1970")))
2474 (tday (- (timezone-absolute-from-gregorian
2475 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
2476 (timezone-absolute-from-gregorian
2477 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
2479 (* (nth 1 ttime) 60)
2480 (* 1.0 (nth 0 ttime) 60 60)
2481 (* 1.0 tday 60 60 24))))
2483 (defun gnus-file-newer-than (file date)
2484 (let ((fdate (nth 5 (file-attributes file))))
2485 (or (> (car fdate) (car date))
2486 (and (= (car fdate) (car date))
2487 (> (nth 1 fdate) (nth 1 date))))))
2489 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2491 (defun gnus-y-or-n-p (prompt)
2496 (defun gnus-yes-or-no-p (prompt)
2498 (yes-or-no-p prompt)
2501 ;; Check whether to use long file names.
2502 (defun gnus-use-long-file-name (symbol)
2503 ;; The variable has to be set...
2504 (and gnus-use-long-file-name
2505 ;; If it isn't a list, then we return t.
2506 (or (not (listp gnus-use-long-file-name))
2507 ;; If it is a list, and the list contains `symbol', we
2509 (not (memq symbol gnus-use-long-file-name)))))
2511 ;; I suspect there's a better way, but I haven't taken the time to do
2512 ;; it yet. -erik selberg@cs.washington.edu
2513 (defun gnus-dd-mmm (messy-date)
2514 "Return a string like DD-MMM from a big messy string"
2515 (let ((datevec (timezone-parse-date messy-date)))
2517 (or (aref datevec 2) "??")
2520 (nth (1- (string-to-number (aref datevec 1)))
2521 timezone-months-assoc))
2524 ;; Make a hash table (default and minimum size is 255).
2525 ;; Optional argument HASHSIZE specifies the table size.
2526 (defun gnus-make-hashtable (&optional hashsize)
2527 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
2529 ;; Make a number that is suitable for hashing; bigger than MIN and one
2531 (defun gnus-create-hash-size (min)
2537 ;; Delete the current line (and the next N lines.);
2538 (defun gnus-delete-line (&optional n)
2540 (delete-region (progn (beginning-of-line) (point))
2541 (progn (forward-line n) (point)))))
2543 ;; Show message if message has a lower level than `gnus-verbose'.
2544 ;; Guide-line for numbers:
2545 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
2546 ;; for things that take a long time, 7 - not very important messages
2547 ;; on stuff, 9 - messages inside loops.
2548 (defun gnus-message (level &rest args)
2549 (if (<= level gnus-verbose)
2550 (apply 'message args)
2551 ;; We have to do this format thingie here even if the result isn't
2552 ;; shown - the return value has to be the same as the return value
2554 (apply 'format args)))
2556 ;;; List and range functions
2558 (defun gnus-last-element (list)
2559 "Return last element of LIST."
2561 (setq list (cdr list)))
2564 (defun gnus-copy-sequence (list)
2565 "Do a complete, total copy of a list."
2566 (if (and (consp list) (not (consp (cdr list))))
2567 (cons (car list) (cdr list))
2568 (mapcar (lambda (elem) (if (consp elem)
2569 (if (consp (cdr elem))
2570 (gnus-copy-sequence elem)
2571 (cons (car elem) (cdr elem)))
2575 (defun gnus-set-difference (list1 list2)
2576 "Return a list of elements of LIST1 that do not appear in LIST2."
2577 (let ((list1 (copy-sequence list1)))
2579 (setq list1 (delq (car list2) list1))
2580 (setq list2 (cdr list2)))
2583 (defun gnus-sorted-complement (list1 list2)
2584 "Return a list of elements of LIST1 that do not appear in LIST2.
2585 Both lists have to be sorted over <."
2587 (if (or (null list1) (null list2))
2589 (while (and list1 list2)
2590 (cond ((= (car list1) (car list2))
2591 (setq list1 (cdr list1)
2593 ((< (car list1) (car list2))
2594 (setq out (cons (car list1) out))
2595 (setq list1 (cdr list1)))
2597 (setq out (cons (car list2) out))
2598 (setq list2 (cdr list2)))))
2599 (nconc (nreverse out) (or list1 list2)))))
2601 (defun gnus-intersection (list1 list2)
2604 (if (memq (car list2) list1)
2605 (setq result (cons (car list2) result)))
2606 (setq list2 (cdr list2)))
2609 (defun gnus-sorted-intersection (list1 list2)
2610 ;; LIST1 and LIST2 have to be sorted over <.
2612 (while (and list1 list2)
2613 (cond ((= (car list1) (car list2))
2614 (setq out (cons (car list1) out)
2617 ((< (car list1) (car list2))
2618 (setq list1 (cdr list1)))
2620 (setq list2 (cdr list2)))))
2623 (defun gnus-set-sorted-intersection (list1 list2)
2624 ;; LIST1 and LIST2 have to be sorted over <.
2625 ;; This function modifies LIST1.
2626 (let* ((top (cons nil list1))
2628 (while (and list1 list2)
2629 (cond ((= (car list1) (car list2))
2633 ((< (car list1) (car list2))
2634 (setcdr prev (cdr list1))
2635 (setq list1 (cdr list1)))
2637 (setq list2 (cdr list2)))))
2641 (defun gnus-compress-sequence (numbers &optional always-list)
2642 "Convert list of numbers to a list of ranges or a single range.
2643 If ALWAYS-LIST is non-nil, this function will always release a list of
2645 (let* ((first (car numbers))
2646 (last (car numbers))
2650 (if (not (listp (cdr numbers)))
2653 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2654 ((= (1+ last) (car numbers)) ;Still in sequence
2655 (setq last (car numbers)))
2656 (t ;End of one sequence
2658 (cons (if (= first last) first
2659 (cons first last)) result))
2660 (setq first (car numbers))
2661 (setq last (car numbers))))
2662 (setq numbers (cdr numbers)))
2663 (if (and (not always-list) (null result))
2664 (if (= first last) (list first) (cons first last))
2665 (nreverse (cons (if (= first last) first (cons first last))
2668 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2669 (defun gnus-uncompress-range (ranges)
2670 "Expand a list of ranges into a list of numbers.
2671 RANGES is either a single range on the form `(num . num)' or a list of
2673 (let (first last result)
2677 ((not (listp (cdr ranges)))
2678 (setq first (car ranges))
2679 (setq last (cdr ranges))
2680 (while (<= first last)
2681 (setq result (cons first result))
2682 (setq first (1+ first)))
2686 (if (atom (car ranges))
2687 (if (numberp (car ranges))
2688 (setq result (cons (car ranges) result)))
2689 (setq first (car (car ranges)))
2690 (setq last (cdr (car ranges)))
2691 (while (<= first last)
2692 (setq result (cons first result))
2693 (setq first (1+ first))))
2694 (setq ranges (cdr ranges)))
2695 (nreverse result)))))
2697 (defun gnus-add-to-range (ranges list)
2698 "Return a list of ranges that has all articles from both RANGES and LIST.
2699 Note: LIST has to be sorted over `<'."
2701 (gnus-compress-sequence list t)
2702 (setq list (copy-sequence list))
2703 (or (listp (cdr ranges))
2704 (setq ranges (list ranges)))
2706 ilist lowest highest temp)
2707 (while (and ranges list)
2709 (setq lowest (or (and (atom (car ranges)) (car ranges))
2710 (car (car ranges))))
2711 (while (and list (cdr list) (< (car (cdr list)) lowest))
2712 (setq list (cdr list)))
2713 (if (< (car ilist) lowest)
2716 (setq list (cdr list))
2718 (setq out (nconc (gnus-compress-sequence ilist t) out))))
2719 (setq highest (or (and (atom (car ranges)) (car ranges))
2720 (cdr (car ranges))))
2721 (while (and list (<= (car list) highest))
2722 (setq list (cdr list)))
2723 (setq ranges (cdr ranges)))
2725 (setq out (nconc (gnus-compress-sequence list t) out)))
2726 (setq out (sort out (lambda (r1 r2)
2727 (< (or (and (atom r1) r1) (car r1))
2728 (or (and (atom r2) r2) (car r2))))))
2731 (if (atom (car ranges))
2733 (if (atom (car (cdr ranges)))
2734 (if (= (1+ (car ranges)) (car (cdr ranges)))
2736 (setcar ranges (cons (car ranges)
2737 (car (cdr ranges))))
2738 (setcdr ranges (cdr (cdr ranges)))))
2739 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
2741 (setcar (car (cdr ranges)) (car ranges))
2742 (setcar ranges (car (cdr ranges)))
2743 (setcdr ranges (cdr (cdr ranges)))))))
2745 (if (atom (car (cdr ranges)))
2746 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
2748 (setcdr (car ranges) (car (cdr ranges)))
2749 (setcdr ranges (cdr (cdr ranges)))))
2750 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
2752 (setcdr (car ranges) (cdr (car (cdr ranges))))
2753 (setcdr ranges (cdr (cdr ranges))))))))
2754 (setq ranges (cdr ranges)))
2757 (defun gnus-remove-from-range (ranges list)
2758 "Return a list of ranges that has all articles from LIST removed from RANGES.
2759 Note: LIST has to be sorted over `<'."
2760 ;; !!! This function shouldn't look like this, but I've got a headache.
2761 (gnus-compress-sequence
2762 (gnus-sorted-complement
2763 (gnus-uncompress-range ranges) list)))
2765 (defun gnus-member-of-range (number ranges)
2766 (if (not (listp (cdr ranges)))
2767 (and (>= number (car ranges))
2768 (<= number (cdr ranges)))
2771 (if (numberp (car ranges))
2772 (>= number (car ranges))
2773 (>= number (car (car ranges))))
2775 (if (if (numberp (car ranges))
2776 (= number (car ranges))
2777 (and (>= number (car (car ranges)))
2778 (<= number (cdr (car ranges)))))
2779 (setq not-stop nil))
2780 (setq ranges (cdr ranges)))
2788 (defvar gnus-group-mode-map nil)
2789 (defvar gnus-group-group-map nil)
2790 (defvar gnus-group-mark-map nil)
2791 (defvar gnus-group-list-map nil)
2792 (defvar gnus-group-sub-map nil)
2793 (put 'gnus-group-mode 'mode-class 'special)
2795 (if gnus-group-mode-map
2797 (setq gnus-group-mode-map (make-keymap))
2798 (suppress-keymap gnus-group-mode-map)
2799 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
2800 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
2801 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
2802 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
2803 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
2804 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
2805 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
2806 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
2807 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
2808 (define-key gnus-group-mode-map "\M-n" 'gnus-group-next-unread-group-same-level)
2809 (define-key gnus-group-mode-map "\M-p" 'gnus-group-prev-unread-group-same-level)
2810 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
2811 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
2812 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
2813 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
2814 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
2815 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
2816 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
2817 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
2818 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
2819 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
2820 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
2821 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
2822 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
2823 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
2824 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
2825 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
2826 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
2827 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
2828 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
2829 (define-key gnus-group-mode-map "\C-c\M-C-a" 'gnus-group-description-apropos)
2830 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
2831 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
2832 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
2833 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
2834 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
2835 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
2836 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
2837 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
2838 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
2839 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
2840 (define-key gnus-group-mode-map "V" 'gnus-version)
2841 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
2842 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
2843 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
2844 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
2845 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
2846 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
2847 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
2848 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
2849 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group-method)
2850 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
2851 (define-key gnus-group-mode-map gnus-mouse-2 'gnus-mouse-pick-group)
2852 (define-key gnus-group-mode-map "<" 'beginning-of-buffer)
2853 (define-key gnus-group-mode-map ">" 'end-of-buffer)
2854 (define-key gnus-group-mode-map "\C-c\C-b" 'gnus-bug)
2856 (define-key gnus-group-mode-map "#" 'gnus-group-mark-group)
2857 (define-key gnus-group-mode-map "\M-#" 'gnus-group-unmark-group)
2858 (define-prefix-command 'gnus-group-mark-map)
2859 (define-key gnus-group-mode-map "M" 'gnus-group-mark-map)
2860 (define-key gnus-group-mark-map "m" 'gnus-group-mark-group)
2861 (define-key gnus-group-mark-map "u" 'gnus-group-unmark-group)
2862 (define-key gnus-group-mark-map "w" 'gnus-group-mark-region)
2864 (define-prefix-command 'gnus-group-group-map)
2865 (define-key gnus-group-mode-map "G" 'gnus-group-group-map)
2866 (define-key gnus-group-group-map "d" 'gnus-group-make-directory-group)
2867 (define-key gnus-group-group-map "h" 'gnus-group-make-help-group)
2868 (define-key gnus-group-group-map "a" 'gnus-group-make-archive-group)
2869 (define-key gnus-group-group-map "k" 'gnus-group-make-kiboze-group)
2870 (define-key gnus-group-group-map "m" 'gnus-group-make-group)
2871 (define-key gnus-group-group-map "E" 'gnus-group-edit-group)
2872 (define-key gnus-group-group-map "e" 'gnus-group-edit-group-method)
2873 (define-key gnus-group-group-map "p" 'gnus-group-edit-group-parameters)
2874 (define-key gnus-group-group-map "v" 'gnus-group-add-to-virtual)
2876 (define-prefix-command 'gnus-group-list-map)
2877 (define-key gnus-group-mode-map "A" 'gnus-group-list-map)
2878 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
2879 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
2880 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
2881 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
2882 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
2883 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
2884 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
2885 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
2887 (define-prefix-command 'gnus-group-sub-map)
2888 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
2889 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
2890 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
2891 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
2892 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
2893 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
2894 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
2895 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
2897 (defun gnus-group-mode ()
2898 "Major mode for reading news.
2900 All normal editing commands are switched off.
2901 \\<gnus-group-mode-map>
2902 The group buffer lists (some of) the groups available. For instance,
2903 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
2904 lists all zombie groups.
2906 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
2907 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
2909 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
2911 The following commands are available:
2913 \\{gnus-group-mode-map}"
2915 (if gnus-visual (gnus-group-make-menu-bar))
2916 (kill-all-local-variables)
2917 (setq mode-line-modified "-- ")
2918 (make-local-variable 'mode-line-format)
2919 (setq mode-line-format (copy-sequence mode-line-format))
2920 (and (equal (nth 3 mode-line-format) " ")
2921 (setcar (nthcdr 3 mode-line-format) ""))
2922 (setq major-mode 'gnus-group-mode)
2923 (setq mode-name "Group")
2924 (gnus-group-set-mode-line)
2925 (setq mode-line-process nil)
2926 (use-local-map gnus-group-mode-map)
2927 (buffer-disable-undo (current-buffer))
2928 (setq truncate-lines t)
2929 (setq buffer-read-only t)
2930 (run-hooks 'gnus-group-mode-hook))
2932 (defun gnus-mouse-pick-group (e)
2935 (gnus-group-read-group nil))
2938 (defun gnus-no-server (&optional arg)
2940 If ARG is a positive number, Gnus will use that as the
2941 startup level. If ARG is nil, Gnus will be started at level 2.
2942 If ARG is non-nil and not a positive number, Gnus will
2943 prompt the user for the name of an NNTP server to use.
2944 As opposed to `gnus', this command will not connect to the local server."
2946 (gnus (or arg (1- gnus-level-default-subscribed)) t))
2948 (defalias '\(ding\) 'gnus)
2951 (defun gnus (&optional arg dont-connect)
2953 If ARG is non-nil and a positive number, Gnus will use that as the
2954 startup level. If ARG is non-nil and not a positive number, Gnus will
2955 prompt the user for the name of an NNTP server to use."
2957 (if (get-buffer gnus-group-buffer)
2959 (switch-to-buffer gnus-group-buffer)
2960 (gnus-group-get-new-news))
2962 (gnus-read-init-file)
2963 (let ((level (and arg (numberp arg) (> arg 0) arg))
2967 (gnus-group-setup-buffer)
2970 (gnus-start-news-server (and arg (not level))))))
2971 (if (and (not dont-connect)
2974 (run-hooks 'gnus-startup-hook)
2975 ;; NNTP server is successfully open.
2976 (gnus-update-format-specifications)
2977 (let ((buffer-read-only nil))
2979 (if (not gnus-inhibit-startup-message)
2981 (gnus-group-startup-message)
2983 (gnus-setup-news nil level)
2984 (and gnus-use-dribble-file (gnus-dribble-open))
2985 (gnus-group-list-groups level)
2986 (gnus-configure-windows 'group))))))
2988 (defun gnus-group-startup-message (&optional x y)
2989 "Insert startup message in current buffer."
2990 ;; Insert the message.
3007 ;; And then hack it.
3008 ;; 18 is the longest line.
3009 (indent-rigidly (point-min) (point-max)
3010 (/ (max (- (window-width) (or x 28)) 0) 2))
3011 (goto-char (point-min))
3012 ;; +4 is fuzzy factor.
3013 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2)))
3015 (defun gnus-group-setup-buffer ()
3016 (or (get-buffer gnus-group-buffer)
3018 (switch-to-buffer gnus-group-buffer)
3019 (gnus-add-current-to-buffer-list)
3021 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
3023 (defun gnus-group-list-groups (level &optional unread)
3024 "List newsgroups with level LEVEL or lower that have unread alticles.
3025 Default is all subscribed groups.
3026 If argument UNREAD is non-nil, groups with no unread articles are also listed."
3027 (interactive (list (and current-prefix-arg
3028 (prefix-numeric-value current-prefix-arg))))
3029 (setq level (or level gnus-group-default-list-level gnus-level-subscribed))
3030 (gnus-group-setup-buffer) ;May call from out of group buffer
3031 (let ((case-fold-search nil)
3032 (group (gnus-group-group-name)))
3033 (funcall gnus-group-prepare-function level unread nil)
3034 (if (zerop (buffer-size))
3035 (gnus-message 5 gnus-no-groups-message)
3036 (goto-char (point-min))
3038 ;; Go to the first group with unread articles.
3039 (gnus-group-search-forward nil nil nil t)
3040 ;; Find the right group to put point on. If the current group
3041 ;; has disapeared in the new listing, try to find the next
3042 ;; one. If no next one can be found, just leave point at the
3043 ;; first newsgroup in the buffer.
3044 (if (not (gnus-goto-char
3045 (text-property-any (point-min) (point-max)
3046 'gnus-group (intern group))))
3047 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
3049 (not (gnus-goto-char
3051 (point-min) (point-max) 'gnus-group
3052 (intern (car (car newsrc)))))))
3053 (setq newsrc (cdr newsrc)))
3054 (or newsrc (progn (goto-char (point-max))
3055 (forward-line -1))))))
3056 ;; Adjust cursor point.
3057 (gnus-group-position-cursor))))
3059 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
3060 "List all newsgroups with unread articles of level LEVEL or lower.
3061 If ALL is non-nil, list groups that have no unread articles.
3062 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3063 If REGEXP, only list groups matching REGEXP."
3064 (set-buffer gnus-group-buffer)
3065 (let ((buffer-read-only nil)
3066 (newsrc (cdr gnus-newsrc-alist))
3067 (lowest (or lowest 1))
3068 info clevel unread group)
3070 (if (< lowest gnus-level-zombie)
3071 ;; List living groups.
3073 (setq info (car newsrc)
3076 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3077 (and unread ; This group might be bogus
3079 (string-match regexp group))
3080 (<= (setq clevel (car (cdr info))) level)
3082 (or all ; We list all groups?
3083 (eq unread t) ; We list unactivated groups
3084 (> unread 0) ; We list groups with unread articles
3085 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
3086 (gnus-group-insert-group-line
3087 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
3089 ;; List dead groups.
3090 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3091 (gnus-group-prepare-flat-list-dead
3092 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3093 gnus-level-zombie ?Z
3095 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3096 (gnus-group-prepare-flat-list-dead
3097 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3098 gnus-level-killed ?K regexp))
3100 (gnus-group-set-mode-line)
3101 (setq gnus-have-all-newsgroups all)
3102 (run-hooks 'gnus-group-prepare-hook)))
3104 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
3105 ;; List zombies and killed lists somehwat faster, which was
3106 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3107 ;; this by ignoring the group format specification altogether.
3110 (setq group (car groups)
3111 groups (cdr groups))
3112 (if (or (not regexp)
3113 (string-match regexp group))
3116 (insert (format " %c *: %s\n" mark group))
3117 (add-text-properties
3119 (list 'gnus-group (intern group)
3121 'gnus-level level)))))))
3123 (defun gnus-group-real-name (group)
3124 "Find the real name of a foreign newsgroup."
3125 (if (string-match "^[^:]+:" group)
3126 (substring group (match-end 0))
3129 (defun gnus-group-prefixed-name (group method)
3130 "Return the whole name from GROUP and METHOD."
3131 (and (stringp method) (setq method (gnus-server-to-method method)))
3132 (concat (format "%s" (car method))
3134 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3135 (not (string= (nth 1 method) "")))
3136 (concat "+" (nth 1 method)))
3139 (defun gnus-group-real-prefix (group)
3140 "Return the prefix of the current group name."
3141 (if (string-match "^[^:]+:" group)
3142 (substring group 0 (match-end 0))
3145 (defun gnus-group-method-name (group)
3146 "Return the method used for selecting GROUP."
3147 (let ((prefix (gnus-group-real-prefix group)))
3148 (if (equal prefix "")
3150 (if (string-match "^[^\\+]+\\+" prefix)
3151 (list (intern (substring prefix 0 (1- (match-end 0))))
3152 (substring prefix (match-end 0) (1- (length prefix))))
3153 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3155 (defun gnus-group-foreign-p (group)
3156 "Return nil if GROUP is native, non-nil if it is foreign."
3157 (string-match ":" group))
3159 (defun gnus-group-set-info (info &optional method-only-group part)
3160 (let* ((entry (gnus-gethash
3161 (or method-only-group (car info)) gnus-newsrc-hashtb))
3163 (info (if method-only-group (nth 2 entry) info)))
3164 (if (not method-only-group)
3167 (error "Trying to change non-existant group %s" method-only-group))
3168 ;; We have recevied parts of the actual group info - either the
3169 ;; select method or the group parameters. We first check
3170 ;; whether we have to extend the info, and if so, do that.
3171 (let ((len (length info))
3172 (total (if (eq part 'method) 5 6)))
3174 (setcdr (nthcdr (1- len) info)
3175 (make-list (- total len) nil)))
3176 ;; Then we enter the new info.
3177 (setcar (nthcdr (1- total) info) part-info)))
3178 ;; We uncompress some lists of marked articles.
3180 (if (not (setq marked (nth 3 info)))
3183 (or (eq 'score (car (car marked)))
3184 (eq 'bookmark (car (car marked)))
3185 (eq 'killed (car (car marked)))
3186 (setcdr (car marked)
3187 (gnus-uncompress-range (cdr (car marked)))))
3188 (setq marked (cdr marked)))))
3191 ;; This is a new group, so we just create it.
3193 (set-buffer gnus-group-buffer)
3195 ;; It's a foreign group...
3196 (gnus-group-make-group
3197 (gnus-group-real-name (car info))
3198 (prin1-to-string (car (nth 4 info)))
3199 (nth 1 (nth 4 info)))
3200 ;; It's a native group.
3201 (gnus-group-make-group
3203 (prin1-to-string (car gnus-select-method))
3204 (nth 1 gnus-select-method)))
3205 (gnus-message 6 "Note: New group created")
3207 (gnus-gethash (gnus-group-prefixed-name
3208 (gnus-group-real-name (car info))
3209 (or (nth 4 info) gnus-select-method))
3210 gnus-newsrc-hashtb))))
3211 ;; Whether it was a new group or not, we now have the entry, so we
3212 ;; can do the update.
3215 (setcar (nthcdr 2 entry) info)
3216 (if (and (not (eq (car entry) t))
3217 (gnus-gethash (car info) gnus-active-hashtb))
3218 (let ((marked (nth 3 info)))
3220 (max 0 (- (length (gnus-list-of-unread-articles
3222 (length (cdr (assq 'tick marked)))
3223 (length (cdr (assq 'dormant marked)))))))))
3224 (error "No such group: %s" (car info)))))
3226 (defun gnus-group-set-method-info (group select-method)
3227 (gnus-group-set-info select-method group 'method))
3229 (defun gnus-group-set-params-info (group params)
3230 (gnus-group-set-info params group 'params))
3232 (defun gnus-group-update-group-line ()
3233 "This function updates the current line in the newsgroup buffer and
3234 moves the point to the colon."
3235 (let* ((buffer-read-only nil)
3236 (group (gnus-group-group-name))
3237 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3240 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3243 (delete-region (point) (progn (forward-line 1) (point)))
3244 (gnus-group-insert-group-line-info group)
3246 (gnus-group-position-cursor)))
3248 (defun gnus-group-insert-group-line-info (group)
3249 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3253 (setq info (nth 2 entry))
3254 (gnus-group-insert-group-line
3255 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3256 (setq active (gnus-gethash group gnus-active-hashtb))
3257 (gnus-group-insert-group-line
3258 nil group (if (member group gnus-zombie-list) gnus-level-zombie
3260 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3262 (defun gnus-group-insert-group-line (gformat group level marked number method)
3263 (let* ((gformat (or gformat gnus-group-line-format-spec))
3264 (active (gnus-gethash group gnus-active-hashtb))
3265 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3266 (number-of-dormant (length (cdr (assq 'dormant marked))))
3267 (number-of-ticked (length (cdr (assq 'tick marked))))
3268 (number-of-ticked-and-dormant
3269 (+ number-of-ticked number-of-dormant))
3270 (number-of-unread-unticked
3271 (if (numberp number) (int-to-string (max 0 number))
3274 (if (numberp number)
3275 (max 0 (- number-total number))
3277 (subscribed (cond ((<= level gnus-level-subscribed) ? )
3278 ((<= level gnus-level-unsubscribed) ?U)
3279 ((= level gnus-level-zombie) ?Z)
3281 (qualified-group (gnus-group-real-name group))
3282 (newsgroup-description
3283 (if gnus-description-hashtb
3284 (or (gnus-gethash group gnus-description-hashtb) "")
3286 (moderated (if (member group gnus-moderated-list) ?m ? ))
3287 (moderated-string (if (eq moderated ?m) "(m)" ""))
3288 (method (gnus-server-get-method group method))
3289 (news-server (or (car (cdr method)) ""))
3290 (news-method (or (car method) ""))
3292 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3296 (> number-of-ticked 0))
3298 (number (if (eq number t) "*" (+ number number-of-dormant
3300 (buffer-read-only nil)
3305 (insert (eval gformat))
3307 (add-text-properties
3308 b (1+ b) (list 'gnus-group (intern group)
3309 'gnus-unread (if (numberp number)
3310 (string-to-int number-of-unread-unticked)
3313 'gnus-level level))))
3315 (defun gnus-group-update-group (group &optional visible-only)
3316 "Update newsgroup info of GROUP.
3317 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3319 (set-buffer gnus-group-buffer)
3320 (let ((buffer-read-only nil)
3322 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3325 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3327 ;; Buffer may be narrowed.
3330 ;; Search a line to modify. If the buffer is large, the search
3331 ;; takes long time. In most cases, current point is on the line
3332 ;; we are looking for. So, first of all, check current line.
3335 (eq (get-text-property (point) 'gnus-group)
3340 (point-min) (point-max) 'gnus-group (intern group)))))
3341 ;; GROUP is listed in current buffer. So, delete old line.
3345 (delete-region (point) (progn (forward-line 1) (point))))
3346 ;; No such line in the buffer, find out where it's supposed to
3347 ;; go, and insert it there (or at the end of the buffer).
3348 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3350 (let ((entry (cdr (gnus-gethash group gnus-newsrc-hashtb))))
3356 (point-min) (point-max)
3357 'gnus-group (intern (car (car entry)))))))
3358 (setq entry (cdr entry)))
3359 (or entry (goto-char (point-max)))))))
3360 (if (or visible (not visible-only))
3361 (gnus-group-insert-group-line-info group))
3362 (gnus-group-set-mode-line))))
3364 (defun gnus-group-set-mode-line ()
3365 (if (memq 'group gnus-updated-mode-lines)
3366 (let* ((gformat (or gnus-group-mode-line-format-spec
3367 (setq gnus-group-mode-line-format-spec
3369 gnus-group-mode-line-format
3370 gnus-group-mode-line-format-alist))))
3371 (news-server (car (cdr gnus-select-method)))
3372 (news-method (car gnus-select-method))
3374 (mode-string (eval gformat)))
3375 (setq mode-string (eval gformat))
3376 (if (> (length mode-string) max-len)
3377 (setq mode-string (substring mode-string 0 (- max-len 4))))
3378 (setq mode-line-buffer-identification mode-string)
3379 (set-buffer-modified-p t))))
3381 (defun gnus-group-group-name ()
3382 "Get the name of the newsgroup on the current line."
3383 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
3384 (and group (symbol-name group))))
3386 (defun gnus-group-group-level ()
3387 "Get the level of the newsgroup on the current line."
3388 (get-text-property (gnus-point-at-bol) 'gnus-level))
3390 (defun gnus-group-search-forward (&optional backward all level first-too)
3391 "Find the next newsgroup with unread articles.
3392 If BACKWARD is non-nil, find the previous newsgroup instead.
3393 If ALL is non-nil, just find any newsgroup.
3394 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3396 If FIRST-TOO, the current line is also eligeble as a target."
3397 (let ((way (if backward -1 1))
3401 (if (and backward (progn (beginning-of-line)) (bobp))
3403 (or first-too (forward-line way))
3411 (get-text-property (point) 'gnus-unread)))
3412 (or (eq unread t) (and unread (> unread 0))))
3413 (let ((lev (get-text-property
3414 (point) 'gnus-level)))
3415 (and lev (<= (get-text-property
3416 (point) 'gnus-level)
3417 gnus-level-subscribed)))))
3419 (let ((lev (get-text-property (point) 'gnus-level)))
3420 (if (and lev (<= lev level))
3425 (setq pos (point))))
3427 (zerop (forward-line way)))))
3429 (progn (gnus-group-position-cursor) t)
3430 (if pos (goto-char pos) (goto-char beg))
3433 ;;; Gnus group mode commands
3437 (defun gnus-group-mark-group (n &optional unmark)
3438 "Mark the current group."
3440 (let ((buffer-read-only nil)
3444 (setq group (gnus-group-group-name))
3452 (setq gnus-group-marked (delete group gnus-group-marked)))
3454 (setq gnus-group-marked (cons group gnus-group-marked)))
3456 (zerop (gnus-group-next-group 1)))
3458 (gnus-summary-position-cursor)
3461 (defun gnus-group-unmark-group (n)
3462 "Remove the mark from the current group."
3464 (gnus-group-mark-group n 'unmark))
3466 (defun gnus-group-mark-region (unmark beg end)
3467 "Mark all groups between point and mark.
3468 If UNMARK, remove the mark instead."
3469 (interactive "P\nr")
3470 (let ((num (count-lines beg end)))
3473 (- num (gnus-group-mark-group num unmark)))))
3475 (defun gnus-group-remove-mark (group)
3476 (and (gnus-group-goto-group group)
3478 (gnus-group-mark-group 1 'unmark))))
3480 ;; Return a list of groups to work on. Take into consideration N (the
3481 ;; prefix) and the list of marked groups.
3482 (defun gnus-group-process-prefix (n)
3484 (setq n (prefix-numeric-value n))
3485 ;; There is a prefix, so we return a list of the N next
3487 (let ((way (if (< n 0) -1 1))
3492 (setq group (gnus-group-group-name)))
3493 (setq groups (cons group groups))
3495 (forward-line way)))
3498 ;; No prefix, but a list of marked articles.
3499 (reverse gnus-group-marked))
3501 ;; Neither marked articles or a prefix, so we return the
3503 (let ((group (gnus-group-group-name)))
3504 (and group (list group))))))
3508 ;; Selecting groups.
3510 (defun gnus-group-read-group (all &optional no-article group)
3511 "Read news in this newsgroup.
3512 If argument ALL is non-nil, already read articles become readable.
3513 If optional argument NO-ARTICLE is non-nil, no article body is displayed."
3515 (let ((group (or group (gnus-group-group-name)))
3516 number active marked entry)
3517 (or group (error "No group on current line"))
3519 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3520 ;; This group might be a dead group. In that case we have to get
3521 ;; the number of unread articles from `gnus-active-hashtb'.
3523 (setq number (car entry))
3524 (if (setq active (gnus-gethash group gnus-active-hashtb))
3525 (setq number (- (1+ (cdr active)) (car active)))))
3526 (gnus-summary-read-group
3527 group (or all (and (numberp number)
3528 (zerop (+ number (length (cdr (assq 'tick marked)))
3529 (length (cdr (assq 'dormant marked)))))))
3532 (defun gnus-group-select-group (all)
3533 "Select this newsgroup.
3534 No article is selected automatically.
3535 If argument ALL is non-nil, already read articles become readable."
3537 (gnus-group-read-group all t))
3539 (defun gnus-group-jump-to-group (group)
3540 "Jump to newsgroup GROUP."
3541 (interactive (list (completing-read "Group: " gnus-active-hashtb nil
3542 (not (not gnus-read-active-file)))))
3544 (if (equal group "")
3545 (error "empty group name"))
3547 (let ((b (text-property-any (point-min) (point-max)
3548 'gnus-group (intern group))))
3550 ;; Either go to the line in the group buffer...
3552 ;; ... or insert the line.
3554 (gnus-gethash group gnus-active-hashtb)
3555 (gnus-activate-newsgroup group)
3556 (error "%s error: %s" group (gnus-status-message group)))
3558 (gnus-group-update-group group)
3559 (goto-char (text-property-any (point-min) (point-max)
3560 'gnus-group (intern group)))))
3561 ;; Adjust cursor point.
3562 (gnus-group-position-cursor))
3564 (defun gnus-group-goto-group (group)
3565 "Goto to newsgroup GROUP."
3566 (let ((b (text-property-any (point-min) (point-max)
3567 'gnus-group (intern group))))
3568 (and b (goto-char b))))
3570 (defun gnus-group-next-group (n)
3571 "Go to next N'th newsgroup.
3572 If N is negative, search backward instead.
3573 Returns the difference between N and the number of skips actually
3576 (gnus-group-next-unread-group n t))
3578 (defun gnus-group-next-unread-group (n &optional all level)
3579 "Go to next N'th unread newsgroup.
3580 If N is negative, search backward instead.
3581 If ALL is non-nil, choose any newsgroup, unread or not.
3582 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
3583 such group can be found, the next group with a level higher than
3585 Returns the difference between N and the number of skips actually
3588 (let ((backward (< n 0))
3591 (gnus-group-search-forward
3592 backward (or (not gnus-group-goto-unread) all) level))
3594 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
3595 (if level " on this level or higher" "")))
3598 (defun gnus-group-prev-group (n)
3599 "Go to previous N'th newsgroup.
3600 Returns the difference between N and the number of skips actually
3603 (gnus-group-next-unread-group (- n) t))
3605 (defun gnus-group-prev-unread-group (n)
3606 "Go to previous N'th unread newsgroup.
3607 Returns the difference between N and the number of skips actually
3610 (gnus-group-next-unread-group (- n)))
3612 (defun gnus-group-next-unread-group-same-level (n)
3613 "Go to next N'th unread newsgroup on the same level.
3614 If N is negative, search backward instead.
3615 Returns the difference between N and the number of skips actually
3618 (gnus-group-next-unread-group n t (gnus-group-group-level))
3619 (gnus-group-position-cursor))
3621 (defun gnus-group-prev-unread-group-same-level (n)
3622 "Go to next N'th unread newsgroup on the same level.
3623 Returns the difference between N and the number of skips actually
3626 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
3627 (gnus-group-position-cursor))
3629 (defun gnus-group-best-unread-group (&optional exclude-group)
3630 "Go to the group with the highest level.
3631 If EXCLUDE-GROUP, do not go to that group."
3633 (goto-char (point-min))
3636 (while (setq unread (get-text-property (point) 'gnus-unread))
3637 (if (and (numberp unread) (> unread 0))
3639 (or best-point (setq best-point (point)))
3640 (if (and (< (get-text-property (point) 'gnus-level) best)
3641 (or (not exclude-group)
3642 (not (equal exclude-group (gnus-group-group-name)))))
3644 (setq best (get-text-property (point) 'gnus-level))
3645 (setq best-point (point))))))
3647 (if best-point (goto-char best-point))
3648 (gnus-summary-position-cursor)
3649 (and best-point (gnus-group-group-name))))
3651 (defun gnus-group-first-unread-group ()
3652 "Go to the first group with unread articles."
3654 (goto-char (point-min))
3655 (or (not (zerop (or (get-text-property (point) 'gnus-unread) 0)))
3656 (gnus-group-next-unread-group 1))
3657 (gnus-group-position-cursor))
3659 (defun gnus-group-enter-server-mode ()
3660 "Jump to the server buffer."
3662 (gnus-server-setup-buffer)
3663 (gnus-configure-windows 'server)
3664 (gnus-server-prepare))
3666 (defun gnus-group-make-group (name method address)
3667 "Add a new newsgroup.
3668 The user will be prompted for a NAME, for a select METHOD, and an
3672 (read-string "Group name: ")
3675 "Method: " (append gnus-valid-select-methods gnus-server-alist)
3677 (if (assoc method gnus-valid-select-methods)
3679 (if (memq 'prompt-address
3680 (assoc method gnus-valid-select-methods))
3681 (read-string "Address: ")
3683 (list method nil)))))
3685 (let* ((meth (if address (list (intern method) address) method))
3686 (nname (gnus-group-prefixed-name name meth))
3688 (and (gnus-gethash nname gnus-newsrc-hashtb)
3689 (error "Group %s already exists" nname))
3690 (gnus-group-change-level
3691 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
3692 gnus-level-default-subscribed gnus-level-killed
3693 (gnus-gethash (or (gnus-group-group-name) "dummy.group")
3694 gnus-newsrc-hashtb) t)
3695 (gnus-sethash nname '(0 . 0) gnus-active-hashtb)
3697 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
3698 (gnus-group-insert-group-line-info nname)
3700 (and (gnus-check-backend-function 'request-create-group nname)
3701 (gnus-request-create-group nname))))
3703 (defun gnus-group-edit-group (group &optional part)
3704 "Edit the group on the current line."
3705 (interactive (list (gnus-group-group-name)))
3706 (let ((done-func '(lambda ()
3707 "Exit editing mode and update the information."
3709 (gnus-group-edit-group-done 'part 'group)))
3710 (part (or part 'info))
3711 (winconf (current-window-configuration))
3713 (if group (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
3714 (error "No group on current line"))
3715 (set-buffer (get-buffer-create gnus-group-edit-buffer))
3716 (gnus-configure-windows 'edit-group)
3717 (gnus-add-current-to-buffer-list)
3719 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3720 (use-local-map (copy-keymap emacs-lisp-mode-map))
3721 (local-set-key "\C-c\C-c" done-func)
3722 (make-local-variable 'gnus-prev-winconf)
3723 (setq gnus-prev-winconf winconf)
3724 ;; We modify the func to let it know what part it is editing.
3725 (setcar (cdr (nth 4 done-func)) (list 'quote part))
3726 (setcar (cdr (cdr (nth 4 done-func))) group)
3731 ";; Type `C-c C-c' after editing the select method.\n\n")
3733 ";; Type `C-c C-c' after editing the group parameters.\n\n")
3735 ";; Type `C-c C-c' after editing the group info.\n\n")))
3736 (let ((cinfo (gnus-copy-sequence info))
3738 (if (not (setq marked (nth 3 cinfo)))
3741 (or (eq 'score (car (car marked)))
3742 (eq 'bookmark (car (car marked)))
3743 (eq 'killed (car (car marked)))
3744 (setcdr (car marked)
3745 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
3746 (setq marked (cdr marked))))
3749 (cond ((eq part 'method)
3750 (or (nth 4 info) "native"))
3757 (defun gnus-group-edit-group-method (group)
3758 "Edit the select method of GROUP."
3759 (interactive (list (gnus-group-group-name)))
3760 (gnus-group-edit-group group 'method))
3762 (defun gnus-group-edit-group-parameters (group)
3763 "Edit the group parameters of GROUP."
3764 (interactive (list (gnus-group-group-name)))
3765 (gnus-group-edit-group group 'params))
3767 (defun gnus-group-edit-group-done (part group)
3768 "Get info from buffer, update variables and jump to the group buffer."
3769 (set-buffer (get-buffer-create gnus-group-edit-buffer))
3770 (goto-char (point-min))
3771 (let ((form (read (current-buffer)))
3772 (winconf gnus-prev-winconf))
3774 (gnus-group-set-info form)
3775 (gnus-group-set-info form group part))
3776 (kill-buffer (current-buffer))
3777 (and winconf (set-window-configuration winconf))
3778 (set-buffer gnus-group-buffer)
3779 (gnus-group-update-group (gnus-group-group-name))
3780 (gnus-group-position-cursor)))
3782 (defun gnus-group-make-help-group ()
3783 "Create the (ding) Gnus documentation group."
3785 (and (gnus-gethash (gnus-group-prefixed-name "gnus-help" '(nndoc ""))
3787 (error "Documentation group already exists"))
3788 (let ((path load-path))
3790 (not (file-exists-p (concat (file-name-as-directory (car path))
3792 (setq path (cdr path)))
3793 (or path (error "Couldn't find doc group"))
3794 (gnus-group-make-group
3796 (concat (file-name-as-directory (car path)) "doc.txt"))
3797 (gnus-group-position-cursor)))
3799 (defun gnus-group-make-archive-group ()
3800 "Create the (ding) Gnus archive group."
3802 (and (gnus-gethash (gnus-group-prefixed-name "ding.archives" '(nndir ""))
3804 (error "Archive group already exists"))
3805 (gnus-group-make-group "ding.archives" "nndir" gnus-group-archive-directory)
3806 (gnus-group-position-cursor))
3808 (defun gnus-group-make-directory-group (dir)
3809 "Create an nndir group.
3810 The user will be prompted for a directory. The contents of this
3811 directory will be used as a newsgroup. The directory should contain
3812 mail messages or news articles in files that have numeric names."
3814 (list (read-file-name "Create group from directory: ")))
3815 (or (file-exists-p dir) (error "No such directory"))
3816 (or (file-directory-p dir) (error "Not a directory"))
3817 (gnus-group-make-group dir "nndir" dir)
3818 (gnus-group-position-cursor))
3820 (defun gnus-group-make-kiboze-group (group address scores)
3821 "Create an nnkiboze group.
3822 The user will be prompted for a name, a regexp to match groups, and
3823 score file entries for articles to include in the group."
3826 (read-string "nnkiboze group name: ")
3827 (read-string "Source groups (regexp): ")
3828 (let ((headers (mapcar (lambda (group) (list group))
3829 '("subject" "from" "number" "date" "message-id"
3830 "references" "chars" "lines" "xref")))
3831 scores header regexp regexps)
3832 (while (not (equal "" (setq header (completing-read
3833 "Match on header: " headers nil t))))
3835 (while (not (equal "" (setq regexp (read-string
3836 (format "Match on %s (string): "
3838 (setq regexps (cons (list regexp nil nil 'r) regexps)))
3839 (setq scores (cons (cons header regexps) scores)))
3841 (gnus-group-make-group group "nnkiboze" address)
3843 (gnus-set-work-buffer)
3844 (let (emacs-lisp-mode-hook)
3845 (pp scores (current-buffer)))
3846 (write-region (point-min) (point-max)
3847 (concat (or gnus-kill-files-directory "~/News")
3848 "nnkiboze:" group "." gnus-score-file-suffix)))
3849 (gnus-group-position-cursor))
3851 (defun gnus-group-add-to-virtual (n vgroup)
3852 "Add the current group to a virtual group."
3854 (list current-prefix-arg
3855 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t)))
3856 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
3857 (error "%s is not an nnvirtual group" vgroup))
3858 (let* ((groups (gnus-group-process-prefix n))
3859 (method (nth 4 (nth 2 (gnus-gethash vgroup gnus-newsrc-hashtb)))))
3860 (setcar (cdr method)
3862 (nth 1 method) "\\|"
3865 (gnus-group-remove-mark s)
3866 (concat "\\(^" (regexp-quote s) "$\\)"))
3869 ;; Group sorting commands
3870 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
3872 (defun gnus-group-sort-groups ()
3873 "Sort the group buffer using `gnus-group-sort-function'."
3875 (setq gnus-newsrc-alist
3876 (sort (cdr gnus-newsrc-alist) gnus-group-sort-function))
3877 (gnus-make-hashtable-from-newsrc-alist)
3878 (gnus-get-unread-articles (1+ gnus-level-subscribed))
3879 (gnus-group-list-groups nil))
3881 (defun gnus-group-sort-by-alphabet (info1 info2)
3882 (string< (car info1) (car info2)))
3884 (defun gnus-group-sort-by-unread (info1 info2)
3885 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
3886 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
3887 (< (or (and (numberp n1) n1) 0)
3888 (or (and (numberp n2) n2) 0))))
3890 (defun gnus-group-sort-by-level (info1 info2)
3891 (< (nth 1 info1) (nth 1 info2)))
3893 ;; Group catching up.
3895 (defun gnus-group-catchup-current (n &optional all)
3896 "Mark all articles not marked as unread in current newsgroup as read.
3897 If prefix argument N is numeric, the ARG next newsgroups will be
3898 caught up. If ALL is non-nil, marked articles will also be marked as
3899 read. Cross references (Xref: header) of articles are ignored.
3900 The difference between N and actual number of newsgroups that were
3901 caught up is returned."
3903 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
3907 "Do you really want to mark all articles as read? "
3908 "Mark all unread articles as read? "))))
3910 (let ((groups (gnus-group-process-prefix n))
3913 (gnus-group-remove-mark (car groups))
3914 (if (not (gnus-group-goto-group (car groups)))
3916 (gnus-group-catchup (car groups) all)
3917 (gnus-group-update-group-line))
3918 (setq groups (cdr groups)))
3919 (gnus-group-next-unread-group 1)
3922 (defun gnus-group-catchup-current-all (n)
3923 "Mark all articles in current newsgroup as read.
3924 Cross references (Xref: header) of articles are ignored."
3926 (gnus-group-catchup-current n 'all))
3928 (defun gnus-group-catchup (group &optional all)
3929 "Mark all articles in GROUP as read.
3930 If ALL is non-nil, all articles are marked as read.
3931 The return value is the number of articles that were marked as read,
3932 or nil if no action could be taken."
3933 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3935 (marked (nth 3 (nth 2 entry)))
3937 (if (not (numberp (car entry)))
3938 (gnus-message 1 "Can't catch up; non-active group")
3939 ;; Do the updating only if the newsgroup isn't killed
3942 (setq ticked (if all nil (cdr (assq 'tick marked))))
3943 (gnus-update-read-articles group ticked nil ticked)
3944 (if (and all marked)
3945 (setcar (nthcdr 3 (nth 2 entry))
3946 (delq (assq 'dormant marked) marked))))))
3949 (defun gnus-group-expire-articles (n)
3950 "Expire all expirable articles in the current newsgroup."
3952 (let ((groups (gnus-group-process-prefix n))
3954 (or groups (error "No groups to expire"))
3956 (setq group (car groups)
3957 groups (cdr groups))
3958 (gnus-group-remove-mark group)
3959 (if (not (gnus-check-backend-function 'request-expire-articles group))
3961 (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
3962 (expirable (if (memq 'total-expire (nth 5 info))
3963 (cons nil (gnus-list-of-read-articles group))
3964 (assq 'expire (nth 3 info)))))
3967 (gnus-request-expire-articles
3968 (cdr expirable) group))))))))
3970 (defun gnus-group-expire-all-groups ()
3971 "Expire all expirable articles in all newsgroups."
3973 (gnus-message 5 "Expiring...")
3974 (let ((gnus-group-marked (mapcar (lambda (info) (car info))
3975 (cdr gnus-newsrc-alist))))
3976 (gnus-group-expire-articles nil))
3977 (gnus-message 5 "Expiring...done"))
3979 (defun gnus-group-set-current-level (n level)
3980 "Set the level of the next N groups to LEVEL."
3981 (interactive "P\nnLevel: ")
3982 (or (and (>= level 1) (<= level gnus-level-killed))
3983 (error "Illegal level: %d" level))
3984 (let ((groups (gnus-group-process-prefix n))
3987 (setq group (car groups)
3988 groups (cdr groups))
3989 (gnus-group-remove-mark group)
3990 (gnus-message 6 "Changed level of %s from %d to %d"
3991 group (gnus-group-group-level) level)
3992 (gnus-group-change-level group level
3993 (gnus-group-group-level))
3994 (gnus-group-update-group-line)))
3995 (gnus-group-position-cursor))
3997 (defun gnus-group-unsubscribe-current-group (arg)
3998 "Toggle subscribe from/to unsubscribe current group."
4000 (let ((group (gnus-group-group-name)))
4001 (or group (error "No newsgroup on current line"))
4002 (or arg (setq arg (if (<= (gnus-group-group-level) gnus-level-subscribed)
4003 gnus-level-default-unsubscribed
4004 gnus-level-default-subscribed)))
4005 (gnus-group-unsubscribe-group group arg)
4006 (gnus-group-next-group 1)))
4008 (defun gnus-group-unsubscribe-group (group &optional level)
4009 "Toggle subscribe from/to unsubscribe GROUP.
4010 New newsgroup is added to .newsrc automatically."
4012 (list (completing-read "Group: " gnus-active-hashtb nil
4013 gnus-have-read-active-file)))
4014 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
4016 ;; Toggle subscription flag.
4017 (gnus-group-change-level
4018 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
4019 gnus-level-subscribed)
4020 (1+ gnus-level-subscribed)
4021 gnus-level-default-subscribed)))
4022 (gnus-group-update-group group))
4023 ((and (stringp group)
4024 (or (not gnus-have-read-active-file)
4025 (gnus-gethash group gnus-active-hashtb)))
4026 ;; Add new newsgroup.
4027 (gnus-group-change-level
4029 (if level level gnus-level-default-subscribed)
4030 (or (and (member group gnus-zombie-list)
4033 (and (gnus-group-group-name)
4034 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
4035 (gnus-group-update-group group))
4036 (t (error "No such newsgroup: %s" group)))
4037 (gnus-group-position-cursor)))
4039 (defun gnus-group-transpose-groups (n)
4040 "Move the current newsgroup up N places.
4041 If given a negative prefix, move down instead. The difference between
4042 N and the number of steps taken is retured."
4044 (or (gnus-group-group-name)
4045 (error "No group on current line"))
4046 (gnus-group-kill-group 1)
4048 (forward-line (- n))
4049 (gnus-group-yank-group)
4050 (gnus-group-position-cursor)))
4052 (defun gnus-group-kill-all-zombies ()
4053 "Kill all zombie newsgroups."
4055 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
4056 (setq gnus-zombie-list nil)
4057 (funcall gnus-group-prepare-function gnus-level-subscribed nil nil)
4058 (goto-char (point-min))
4059 (gnus-group-position-cursor))
4061 (defun gnus-group-kill-region (begin end)
4062 "Kill newsgroups in current region (excluding current point).
4063 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
4066 ;; Exclude a line where current point is on.
4080 (beginning-of-line) ;Important when LINES < 1
4081 (gnus-group-kill-group lines)))
4083 (defun gnus-group-kill-group (n)
4084 "The the next N groups.
4085 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
4086 However, only groups that were alive can be yanked; already killed
4087 groups or zombie groups can't be yanked.
4088 The return value is the name of the (last) group that was killed."
4090 (let ((buffer-read-only nil)
4091 (groups (gnus-group-process-prefix n))
4094 (setq group (car groups)
4095 groups (cdr groups))
4096 (gnus-group-remove-mark group)
4097 (setq level (gnus-group-group-level))
4099 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
4100 (setq gnus-list-of-killed-groups
4101 (cons (cons (car entry) (nth 2 entry))
4102 gnus-list-of-killed-groups)))
4103 (gnus-group-change-level
4104 (if entry entry group) gnus-level-killed (if entry nil level)))
4105 (gnus-group-position-cursor)
4108 (defun gnus-group-yank-group (&optional arg)
4109 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
4110 inserting it before the current newsgroup. The numeric ARG specifies
4111 how many newsgroups are to be yanked. The name of the (last)
4112 newsgroup yanked is returned."
4114 (if (not arg) (setq arg 1))
4115 (let (info group prev)
4116 (while (>= (setq arg (1- arg)) 0)
4117 (if (not (setq info (car gnus-list-of-killed-groups)))
4118 (error "No more newsgroups to yank"))
4119 (setq group (nth 2 info))
4120 ;; Find which newsgroup to insert this one before - search
4121 ;; backward until something suitable is found. If there are no
4122 ;; other newsgroups in this buffer, just make this newsgroup the
4124 (setq prev (gnus-group-group-name))
4125 (gnus-group-change-level
4126 info (nth 2 info) gnus-level-killed
4127 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
4129 (gnus-group-insert-group-line-info (nth 1 info))
4130 (setq gnus-list-of-killed-groups
4131 (cdr gnus-list-of-killed-groups)))
4133 (gnus-group-position-cursor)
4136 (defun gnus-group-list-all-groups (arg)
4137 "List all newsgroups with level ARG or lower.
4138 Default is gnus-level-unsubscribed, which lists all subscribed and most
4139 unsubscribed groups."
4141 (setq arg (or arg gnus-level-unsubscribed))
4142 (gnus-group-list-groups arg t))
4144 (defun gnus-group-list-killed ()
4145 "List all killed newsgroups in the group buffer."
4147 (if (not gnus-killed-list)
4148 (gnus-message 6 "No killed groups")
4149 (funcall gnus-group-prepare-function gnus-level-killed t gnus-level-killed)
4150 (goto-char (point-min)))
4151 (gnus-group-position-cursor))
4153 (defun gnus-group-list-zombies ()
4154 "List all zombie newsgroups in the group buffer."
4156 (if (not gnus-zombie-list)
4157 (gnus-message 6 "No zombie groups")
4158 (funcall gnus-group-prepare-function gnus-level-zombie t gnus-level-zombie)
4159 (goto-char (point-min)))
4160 (gnus-group-position-cursor))
4162 (defun gnus-group-get-new-news (&optional arg)
4163 "Get newly arrived articles.
4164 If ARG is non-nil, it should be a number between one and nine to
4165 specify which levels you are interested in re-scanning."
4167 (run-hooks 'gnus-get-new-news-hook)
4169 (if (and gnus-read-active-file (not level))
4171 (gnus-read-active-file)
4172 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed))))
4173 (let ((gnus-read-active-file nil))
4174 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed)))))
4175 (gnus-group-list-groups
4176 (or gnus-group-always-list-unread level gnus-level-subscribed)
4177 gnus-have-all-newsgroups)))
4179 (defun gnus-group-get-new-news-this-group (n)
4180 "Check for newly arrived news in the current group (and the N-1 next groups).
4181 The difference between N and the number of newsgroup checked is returned.
4182 If N is negative, this group and the N-1 previous groups will be checked."
4184 (let* ((groups (gnus-group-process-prefix n))
4185 (ret (if (numberp n) (- n (length groups)) 0))
4186 (w-p (window-start))
4189 (setq group (car groups)
4190 groups (cdr groups))
4191 (gnus-group-remove-mark group)
4192 (or (gnus-get-new-news-in-group group)
4195 (message "%s error: %s" group (gnus-status-message group))
4197 ;; !!! I don't know why the buffer scrolls forward when updating
4198 ;; the first line in the group buffer, but it does. So we set the
4199 ;; window start forcibly.
4200 ; (set-window-start (get-buffer-window (current-buffer)) w-p)
4202 (gnus-summary-position-cursor)
4205 (defun gnus-get-new-news-in-group (group)
4207 (gnus-activate-newsgroup group)
4209 (gnus-get-unread-articles-in-group
4210 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
4211 (gnus-gethash group gnus-active-hashtb))
4212 (gnus-group-update-group-line)
4215 (defun gnus-group-fetch-faq (group)
4216 "Fetch the FAQ for the current group."
4217 (interactive (list (gnus-group-real-name (gnus-group-group-name))))
4218 (or group (error "No group name given"))
4219 (let ((file (concat gnus-group-faq-directory group)))
4220 (if (not (file-exists-p file))
4221 (error "No such file: %s" file)
4224 (defun gnus-group-describe-group (force &optional group)
4225 "Display a description of the current newsgroup."
4227 (and force (setq gnus-description-hashtb nil))
4228 (let ((group (or group (gnus-group-group-name)))
4230 (or group (error "No group name given"))
4231 (and (or gnus-description-hashtb
4232 (setq desc (gnus-group-get-description group))
4233 (gnus-read-descriptions-file))
4235 (or desc (gnus-gethash group gnus-description-hashtb)
4236 "No description available")))))
4238 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4239 (defun gnus-group-describe-all-groups (force)
4240 "Pop up a buffer with descriptons of all newsgroups."
4242 (and force (setq gnus-description-hashtb nil))
4243 (if (not (or gnus-description-hashtb
4244 (gnus-read-descriptions-file)))
4245 (error "Couldn't request descriptions file"))
4246 (let ((buffer-read-only nil)
4252 (insert (format " *: %-20s %s\n" (symbol-name group)
4253 (symbol-value group)))
4254 (add-text-properties
4255 b (1+ b) (list 'gnus-group group
4256 'gnus-unread t 'gnus-marked nil
4257 'gnus-level (1+ gnus-level-subscribed))))
4258 gnus-description-hashtb)
4259 (goto-char (point-min))
4260 (gnus-group-position-cursor)))
4262 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
4263 (defun gnus-group-apropos (regexp &optional search-description)
4264 "List all newsgroups that have names that match a regexp."
4265 (interactive "sGnus apropos (regexp): ")
4267 (obuf (current-buffer))
4269 ;; Go through all newsgroups that are known to Gnus.
4272 (and (string-match regexp (symbol-name group))
4273 (setq groups (cons (symbol-name group) groups))))
4275 ;; Go through all descriptions that are known to Gnus.
4276 (if search-description
4279 (and (string-match regexp (symbol-value group))
4280 (gnus-gethash (symbol-name group) gnus-active-hashtb)
4281 (setq groups (cons (symbol-name group) groups))))
4282 gnus-description-hashtb))
4284 (gnus-message 3 "No groups matched \"%s\"." regexp)
4285 ;; Print out all the groups.
4287 (pop-to-buffer "*Gnus Help*")
4288 (buffer-disable-undo (current-buffer))
4290 (setq groups (sort groups 'string<))
4292 ;; Groups may be entered twice into the list of groups.
4293 (if (not (string= (car groups) prev))
4295 (insert (setq prev (car groups)) "\n")
4296 (if (and gnus-description-hashtb
4297 (setq des (gnus-gethash (car groups)
4298 gnus-description-hashtb)))
4299 (insert " " des "\n"))))
4300 (setq groups (cdr groups)))
4301 (goto-char (point-min))))
4302 (pop-to-buffer obuf)))
4304 (defun gnus-group-description-apropos (regexp)
4305 "List all newsgroups that have names or desccriptions that match a regexp."
4306 (interactive "sGnus description apropos (regexp): ")
4307 (if (not (or gnus-description-hashtb
4308 (gnus-read-descriptions-file)))
4309 (error "Couldn't request descriptions file"))
4310 (gnus-group-apropos regexp t))
4312 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4313 (defun gnus-group-list-matching (level regexp &optional all lowest)
4314 "List all groups with unread articles that match REGEXP.
4315 If the prefix LEVEL is non-nil, it should be a number that says which
4316 level to cut off listing groups.
4317 If ALL, also list groups with no unread articles.
4318 If LOWEST, don't list groups with level lower than LOWEST."
4319 (interactive "P\nsList newsgroups matching: ")
4320 (gnus-group-prepare-flat (or level gnus-level-subscribed)
4321 all (or lowest 1) regexp)
4322 (goto-char (point-min))
4323 (gnus-group-position-cursor))
4325 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4326 "List all groups that match REGEXP.
4327 If the prefix LEVEL is non-nil, it should be a number that says which
4328 level to cut off listing groups.
4329 If LOWEST, don't list groups with level lower than LOWEST."
4330 (interactive "P\nsList newsgroups matching: ")
4331 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4333 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4334 (defun gnus-group-save-newsrc ()
4335 "Save the Gnus startup files."
4337 (gnus-save-newsrc-file))
4339 (defun gnus-group-restart (&optional arg)
4340 "Force Gnus to read the .newsrc file."
4342 (gnus-save-newsrc-file)
4343 (gnus-setup-news 'force)
4344 (gnus-group-list-groups arg gnus-have-all-newsgroups))
4346 (defun gnus-group-read-init-file ()
4347 "Read the Gnus elisp init file."
4349 (gnus-read-init-file))
4351 (defun gnus-group-check-bogus-groups ()
4352 "Check bogus newsgroups."
4354 (gnus-check-bogus-newsgroups (not gnus-expert-user)) ;Require confirmation.
4355 (gnus-group-list-groups nil gnus-have-all-newsgroups))
4357 (defun gnus-group-mail ()
4358 "Start composing a mail."
4362 (defun gnus-group-edit-global-kill (article &optional group)
4363 "Edit the global kill file.
4364 If GROUP, edit that local kill file instead."
4366 (setq gnus-current-kill-article article)
4367 (gnus-kill-file-edit-file group)
4369 (substitute-command-keys
4370 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
4372 (defun gnus-group-edit-local-kill (article group)
4373 "Edit a local kill file."
4374 (interactive (list nil (gnus-group-group-name)))
4375 (gnus-group-edit-global-kill article group))
4377 (defun gnus-group-force-update ()
4378 "Update `.newsrc' file."
4380 (gnus-save-newsrc-file))
4382 (defun gnus-group-suspend ()
4383 "Suspend the current Gnus session.
4384 In fact, cleanup buffers except for group mode buffer.
4385 The hook gnus-suspend-gnus-hook is called before actually suspending."
4387 (run-hooks 'gnus-suspend-gnus-hook)
4388 ;; Kill Gnus buffers except for group mode buffer.
4389 (let ((group-buf (get-buffer gnus-group-buffer)))
4390 ;; Do this on a separate list in case the user does a ^G before we finish
4391 (let ((gnus-buffer-list
4392 (delq group-buf (delq gnus-dribble-buffer
4393 (append gnus-buffer-list nil)))))
4394 (while gnus-buffer-list
4395 (gnus-kill-buffer (car gnus-buffer-list))
4396 (setq gnus-buffer-list (cdr gnus-buffer-list))))
4399 (setq gnus-buffer-list (list group-buf))
4400 (bury-buffer group-buf)
4401 (delete-windows-on group-buf t)))))
4403 (defun gnus-group-clear-dribble ()
4404 "Clear all information from the dribble buffer."
4406 (gnus-dribble-clear))
4408 (defun gnus-group-exit ()
4409 "Quit reading news after updating .newsrc.eld and .newsrc.
4410 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4412 (if (or noninteractive ;For gnus-batch-kill
4413 (zerop (buffer-size)) ;No news is good news.
4414 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
4415 (not gnus-interactive-exit) ;Without confirmation
4417 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4419 (run-hooks 'gnus-exit-gnus-hook)
4420 (gnus-save-newsrc-file)
4421 (gnus-close-backends)
4422 (gnus-clear-system))))
4424 (defun gnus-close-backends ()
4425 ;; Send a close request to all backends that support such a request.
4426 (let ((methods gnus-valid-select-methods)
4429 (if (fboundp (setq func (intern (concat (car (car methods))
4430 "-request-close"))))
4432 (setq methods (cdr methods)))))
4434 (defun gnus-group-quit ()
4435 "Quit reading news without updating .newsrc.eld or .newsrc.
4436 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4438 (if (or noninteractive ;For gnus-batch-kill
4439 (zerop (buffer-size))
4440 (not (gnus-server-opened gnus-select-method))
4442 (not gnus-current-startup-file)
4444 (format "Quit reading news without saving %s? "
4445 (file-name-nondirectory gnus-current-startup-file))))
4447 (run-hooks 'gnus-exit-gnus-hook)
4449 (gnus-close-backends)
4450 (gnus-clear-system))))
4452 (defun gnus-group-describe-briefly ()
4453 "Give a one line description of the group mode commands."
4456 (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")))
4458 (defun gnus-group-browse-foreign-server (method)
4459 "Browse a foreign news server.
4460 If called interactively, this function will ask for a select method
4461 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4462 If not, METHOD should be a list where the first element is the method
4463 and the second element is the address."
4465 (list (let ((how (completing-read
4467 (append gnus-valid-select-methods gnus-server-alist)
4469 ;; We either got a backend name or a virtual server name.
4470 ;; If the first, we also need an address.
4471 (if (assoc how gnus-valid-select-methods)
4473 ;; Suggested by mapjph@bath.ac.uk.
4476 (mapcar (lambda (server) (list server))
4477 gnus-secondary-servers)))
4478 ;; We got a server name, so we find the method.
4479 (gnus-server-to-method how)))))
4480 (gnus-browse-foreign-server method))
4484 ;;; Browse Server Mode
4487 (defvar gnus-browse-mode-hook nil)
4488 (defvar gnus-browse-mode-map nil)
4489 (put 'gnus-browse-mode 'mode-class 'special)
4491 (if gnus-browse-mode-map
4493 (setq gnus-browse-mode-map (make-keymap))
4494 (suppress-keymap gnus-browse-mode-map)
4495 (define-key gnus-browse-mode-map " " 'gnus-browse-read-group)
4496 (define-key gnus-browse-mode-map "=" 'gnus-browse-read-group)
4497 (define-key gnus-browse-mode-map "n" 'gnus-browse-next-group)
4498 (define-key gnus-browse-mode-map "p" 'gnus-browse-prev-group)
4499 (define-key gnus-browse-mode-map "\177" 'gnus-browse-prev-group)
4500 (define-key gnus-browse-mode-map "N" 'gnus-browse-next-group)
4501 (define-key gnus-browse-mode-map "P" 'gnus-browse-prev-group)
4502 (define-key gnus-browse-mode-map "\M-n" 'gnus-browse-next-group)
4503 (define-key gnus-browse-mode-map "\M-p" 'gnus-browse-prev-group)
4504 (define-key gnus-browse-mode-map "\r" 'gnus-browse-read-group)
4505 (define-key gnus-browse-mode-map "u" 'gnus-browse-unsubscribe-current-group)
4506 (define-key gnus-browse-mode-map "l" 'gnus-browse-exit)
4507 (define-key gnus-browse-mode-map "L" 'gnus-browse-exit)
4508 (define-key gnus-browse-mode-map "q" 'gnus-browse-exit)
4509 (define-key gnus-browse-mode-map "Q" 'gnus-browse-exit)
4510 (define-key gnus-browse-mode-map "\C-c\C-c" 'gnus-browse-exit)
4511 (define-key gnus-browse-mode-map "?" 'gnus-browse-describe-briefly)
4512 (define-key gnus-browse-mode-map "\C-c\C-i" 'gnus-info-find-node)
4515 (defvar gnus-browse-current-method nil)
4516 (defvar gnus-browse-return-buffer nil)
4518 (defvar gnus-browse-buffer "*Gnus Browse Server*")
4520 (defun gnus-browse-foreign-server (method &optional return-buffer)
4521 (setq gnus-browse-current-method method)
4522 (setq gnus-browse-return-buffer return-buffer)
4523 (let ((gnus-select-method method)
4525 (gnus-message 5 "Connecting to %s..." (nth 1 method))
4526 (or (gnus-server-opened method)
4527 (gnus-open-server method)
4528 (error "Unable to contact server: %s" (gnus-status-message method)))
4529 (or (gnus-request-list method)
4530 (error "Couldn't request list: %s" (gnus-status-message method)))
4531 (get-buffer-create gnus-browse-buffer)
4532 (gnus-add-current-to-buffer-list)
4533 (and gnus-carpal (gnus-carpal-setup-buffer 'browse))
4534 (gnus-configure-windows 'browse)
4535 (buffer-disable-undo (current-buffer))
4536 (let ((buffer-read-only nil))
4539 (setq mode-line-buffer-identification
4541 "(ding) Browse Server {%s:%s}" (car method) (car (cdr method))))
4543 (set-buffer nntp-server-buffer)
4544 (let ((cur (current-buffer)))
4545 (goto-char (point-min))
4546 (or (string= gnus-ignored-newsgroups "")
4547 (delete-matching-lines gnus-ignored-newsgroups))
4548 (while (re-search-forward
4549 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
4550 (goto-char (match-end 1))
4551 (setq groups (cons (cons (buffer-substring (match-beginning 1)
4553 (max 0 (- (1+ (read cur)) (read cur))))
4555 (setq groups (sort groups
4557 (string< (car l1) (car l2)))))
4558 (let ((buffer-read-only nil))
4560 (setq group (car groups))
4562 (format "K%7d: %s\n" (cdr group) (car group)))
4563 (setq groups (cdr groups))))
4564 (switch-to-buffer (current-buffer))
4565 (goto-char (point-min))
4566 (gnus-group-position-cursor)))
4568 (defun gnus-browse-mode ()
4569 "Major mode for browsing a foreign server."
4571 (kill-all-local-variables)
4572 (if gnus-visual (gnus-browse-make-menu-bar))
4573 (setq mode-line-modified "-- ")
4574 (make-local-variable 'mode-line-format)
4575 (setq mode-line-format (copy-sequence mode-line-format))
4576 (and (equal (nth 3 mode-line-format) " ")
4577 (setcar (nthcdr 3 mode-line-format) ""))
4578 (setq major-mode 'gnus-browse-mode)
4579 (setq mode-name "Browse Server")
4580 (setq mode-line-process nil)
4581 (use-local-map gnus-browse-mode-map)
4582 (buffer-disable-undo (current-buffer))
4583 (setq truncate-lines t)
4584 (setq buffer-read-only t)
4585 (run-hooks 'gnus-browse-mode-hook))
4587 (defun gnus-browse-read-group ()
4588 "Not implemented, and will probably never be."
4590 (error "You can't read while browsing"))
4592 (defun gnus-browse-next-group (n)
4593 "Go to the next group."
4597 (gnus-group-position-cursor)))
4599 (defun gnus-browse-prev-group (n)
4600 "Go to the next group."
4602 (gnus-browse-next-group (- n)))
4604 (defun gnus-browse-unsubscribe-current-group (arg)
4605 "(Un)subscribe to the next ARG groups."
4608 (error "No group at current line."))
4609 (let ((ward (if (< arg 0) -1 1))
4611 (while (and (> arg 0)
4613 (gnus-browse-unsubscribe-group)
4614 (zerop (gnus-browse-next-group ward)))
4615 (setq arg (1- arg)))
4616 (gnus-group-position-cursor)
4617 (if (/= 0 arg) (gnus-message 7 "No more newsgroups"))
4620 (defun gnus-browse-unsubscribe-group ()
4622 (buffer-read-only nil)
4626 (if (= (following-char) ?K) (setq sub t))
4627 (re-search-forward ": \\(.*\\)$" nil t)
4628 (setq group (gnus-group-prefixed-name
4629 (buffer-substring (match-beginning 1) (match-end 1))
4630 gnus-browse-current-method))
4635 (gnus-group-change-level
4636 (list t group gnus-level-default-subscribed
4637 nil nil gnus-browse-current-method)
4638 gnus-level-default-subscribed gnus-level-killed
4639 (gnus-gethash (car (nth 1 gnus-newsrc-alist)) gnus-newsrc-hashtb)
4642 (gnus-group-change-level
4643 group gnus-level-killed gnus-level-default-subscribed)
4647 (defun gnus-browse-exit ()
4648 "Quit browsing and return to the group buffer."
4650 (if (eq major-mode 'gnus-browse-mode)
4651 (kill-buffer (current-buffer)))
4652 (if gnus-browse-return-buffer
4653 (gnus-configure-windows 'server)
4654 (gnus-configure-windows 'group)))
4656 (defun gnus-browse-describe-briefly ()
4657 "Give a one line description of the group mode commands."
4660 (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")))
4664 ;;; Gnus summary mode
4667 (defvar gnus-summary-mode-map nil)
4668 (defvar gnus-summary-mark-map nil)
4669 (defvar gnus-summary-mscore-map nil)
4670 (defvar gnus-summary-article-map nil)
4671 (defvar gnus-summary-thread-map nil)
4672 (defvar gnus-summary-goto-map nil)
4673 (defvar gnus-summary-exit-map nil)
4674 (defvar gnus-summary-various-map nil)
4675 (defvar gnus-summary-interest-map nil)
4676 (defvar gnus-summary-sort-map nil)
4677 (defvar gnus-summary-backend-map nil)
4678 (defvar gnus-summary-save-map nil)
4679 (defvar gnus-summary-wash-map nil)
4680 (defvar gnus-summary-help-map nil)
4682 (put 'gnus-summary-mode 'mode-class 'special)
4684 (if gnus-summary-mode-map
4686 (setq gnus-summary-mode-map (make-keymap))
4687 (suppress-keymap gnus-summary-mode-map)
4689 ;; Non-orthogonal keys
4691 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
4692 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
4693 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
4694 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
4695 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
4696 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
4697 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
4698 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
4699 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
4700 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
4701 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
4702 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
4703 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
4704 (define-key gnus-summary-mode-map "\M-s" 'gnus-summary-search-article-forward)
4705 (define-key gnus-summary-mode-map "\M-r" 'gnus-summary-search-article-backward)
4706 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
4707 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
4708 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
4709 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
4710 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
4711 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
4712 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
4713 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
4714 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
4715 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
4716 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
4717 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
4718 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
4719 (define-key gnus-summary-mode-map "k" 'gnus-summary-kill-same-subject-and-select)
4720 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
4721 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
4722 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
4723 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
4724 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
4725 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
4726 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
4727 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
4728 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
4729 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
4730 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
4731 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
4732 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
4733 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
4734 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
4735 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
4736 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
4737 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
4738 (define-key gnus-summary-mode-map "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
4739 (define-key gnus-summary-mode-map "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
4740 (define-key gnus-summary-mode-map "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
4741 (define-key gnus-summary-mode-map "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
4742 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
4743 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
4744 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
4745 (define-key gnus-summary-mode-map "\C-x\C-s" 'gnus-summary-reselect-current-group)
4746 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
4747 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
4748 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
4749 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
4750 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
4751 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
4752 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
4753 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
4754 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
4755 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
4756 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
4757 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
4758 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
4759 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
4760 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
4761 (define-key gnus-summary-mode-map "V" 'gnus-version)
4762 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
4763 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
4764 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
4765 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
4766 (define-key gnus-summary-mode-map gnus-mouse-2 'gnus-mouse-pick-article)
4767 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
4768 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
4769 (define-key gnus-summary-mode-map "x" 'gnus-summary-remove-lines-marked-as-read)
4770 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
4771 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
4772 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
4773 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
4774 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
4775 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
4776 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
4777 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
4780 ;; Sort of orthogonal keymap
4781 (define-prefix-command 'gnus-summary-mark-map)
4782 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
4783 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
4784 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
4785 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
4786 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
4787 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
4788 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
4789 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
4790 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
4791 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
4792 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
4793 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
4794 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
4795 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
4796 (define-key gnus-summary-mark-map "\M-r" 'gnus-summary-remove-lines-marked-as-read)
4797 (define-key gnus-summary-mark-map "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
4798 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
4799 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
4800 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
4801 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
4802 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
4803 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
4804 (define-key gnus-summary-mark-map "k" 'gnus-summary-kill-same-subject-and-select)
4805 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
4807 (define-prefix-command 'gnus-summary-mscore-map)
4808 (define-key gnus-summary-mark-map "s" 'gnus-summary-mscore-map)
4809 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
4810 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
4811 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
4812 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
4814 (define-key gnus-summary-mark-map "p" 'gnus-uu-mark-map)
4816 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
4818 (define-prefix-command 'gnus-summary-goto-map)
4819 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
4820 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
4821 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
4822 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
4823 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
4824 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
4825 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
4826 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
4827 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
4828 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
4829 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
4830 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
4831 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
4832 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
4835 (define-prefix-command 'gnus-summary-thread-map)
4836 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
4837 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
4838 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
4839 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
4840 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
4841 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
4842 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
4843 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
4844 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
4845 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
4846 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
4847 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
4848 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
4849 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
4852 (define-prefix-command 'gnus-summary-exit-map)
4853 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
4854 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
4855 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
4856 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
4857 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
4858 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
4859 (define-key gnus-summary-exit-map "n" 'gnus-summary-catchup-and-goto-next-group)
4860 (define-key gnus-summary-exit-map "R" 'gnus-summary-reselect-current-group)
4861 (define-key gnus-summary-exit-map "G" 'gnus-summary-rescan-group)
4862 (define-key gnus-summary-exit-map "N" 'gnus-summary-next-group)
4863 (define-key gnus-summary-exit-map "P" 'gnus-summary-prev-group)
4866 (define-prefix-command 'gnus-summary-article-map)
4867 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
4868 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
4869 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
4870 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
4871 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
4872 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
4873 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
4874 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
4875 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
4876 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
4877 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
4878 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
4879 (define-key gnus-summary-article-map "w" 'gnus-summary-stop-page-breaking)
4880 (define-key gnus-summary-article-map "c" 'gnus-summary-caesar-message)
4881 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
4882 (define-key gnus-summary-article-map "t" 'gnus-summary-toggle-header)
4883 (define-key gnus-summary-article-map "m" 'gnus-summary-toggle-mime)
4884 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
4887 (define-prefix-command 'gnus-summary-wash-map)
4888 (define-key gnus-summary-mode-map "W" 'gnus-summary-wash-map)
4889 (define-key gnus-summary-wash-map "h" 'gnus-article-hide-headers)
4890 (define-key gnus-summary-wash-map "s" 'gnus-article-hide-signature)
4891 (define-key gnus-summary-wash-map "c" 'gnus-article-hide-citation)
4892 (define-key gnus-summary-wash-map "o" 'gnus-article-treat-overstrike)
4893 (define-key gnus-summary-wash-map "w" 'gnus-article-word-wrap)
4894 (define-key gnus-summary-wash-map "d" 'gnus-article-remove-cr)
4895 (define-key gnus-summary-wash-map "q" 'gnus-article-de-quoted-unreadable)
4896 (define-key gnus-summary-wash-map "f" 'gnus-article-display-x-face)
4897 (define-key gnus-summary-wash-map "t" 'gnus-article-date-ut)
4898 (define-key gnus-summary-wash-map "\C-t" 'gnus-article-date-local)
4899 (define-key gnus-summary-wash-map "T" 'gnus-article-date-lapsed)
4901 (define-key gnus-summary-wash-map "A" 'gnus-article-highlight)
4902 (define-key gnus-summary-wash-map "a" 'gnus-article-hide)
4903 (define-key gnus-summary-wash-map "H" 'gnus-article-highlight-headers)
4904 (define-key gnus-summary-wash-map "C" 'gnus-article-highlight-citation)
4905 (define-key gnus-summary-wash-map "S" 'gnus-article-highlight-signature)
4906 (define-key gnus-summary-wash-map "b" 'gnus-article-add-buttons)
4909 (define-prefix-command 'gnus-summary-help-map)
4910 (define-key gnus-summary-mode-map "H" 'gnus-summary-help-map)
4911 (define-key gnus-summary-help-map "v" 'gnus-version)
4912 (define-key gnus-summary-help-map "f" 'gnus-summary-fetch-faq)
4913 (define-key gnus-summary-help-map "d" 'gnus-summary-describe-group)
4914 (define-key gnus-summary-help-map "h" 'gnus-summary-describe-briefly)
4915 (define-key gnus-summary-help-map "i" 'gnus-info-find-node)
4918 (define-prefix-command 'gnus-summary-backend-map)
4919 (define-key gnus-summary-mode-map "B" 'gnus-summary-backend-map)
4920 (define-key gnus-summary-backend-map "e" 'gnus-summary-expire-articles)
4921 (define-key gnus-summary-backend-map "\177" 'gnus-summary-delete-article)
4922 (define-key gnus-summary-backend-map "m" 'gnus-summary-move-article)
4923 (define-key gnus-summary-backend-map "r" 'gnus-summary-respool-article)
4924 (define-key gnus-summary-backend-map "w" 'gnus-summary-edit-article)
4925 (define-key gnus-summary-backend-map "c" 'gnus-summary-copy-article)
4926 (define-key gnus-summary-backend-map "q" 'gnus-summary-fancy-query)
4929 (define-prefix-command 'gnus-summary-save-map)
4930 (define-key gnus-summary-mode-map "O" 'gnus-summary-save-map)
4931 (define-key gnus-summary-save-map "o" 'gnus-summary-save-article)
4932 (define-key gnus-summary-save-map "m" 'gnus-summary-save-article-mail)
4933 (define-key gnus-summary-save-map "r" 'gnus-summary-save-article-rmail)
4934 (define-key gnus-summary-save-map "f" 'gnus-summary-save-article-file)
4935 (define-key gnus-summary-save-map "h" 'gnus-summary-save-article-folder)
4936 (define-key gnus-summary-save-map "v" 'gnus-summary-save-article-vm)
4937 (define-key gnus-summary-save-map "p" 'gnus-summary-pipe-output)
4939 (define-key gnus-summary-mode-map "X" 'gnus-uu-extract-map)
4941 (define-prefix-command 'gnus-summary-various-map)
4942 (define-key gnus-summary-mode-map "V" 'gnus-summary-various-map)
4943 (define-key gnus-summary-various-map "u" 'gnus-summary-universal-argument)
4944 (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
4945 (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
4946 (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
4947 (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
4948 (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
4949 (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
4950 (define-key gnus-summary-various-map "D" 'gnus-summary-enter-digest-group)
4951 (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
4952 (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
4954 (define-key gnus-summary-various-map "S" 'gnus-summary-score-map)
4956 (define-prefix-command 'gnus-summary-sort-map)
4957 (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
4958 (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
4959 (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
4960 (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
4961 (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
4962 (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
4964 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-score)
4965 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-score)
4971 (defun gnus-summary-mode ()
4972 "Major mode for reading articles.
4974 All normal editing commands are switched off.
4975 \\<gnus-summary-mode-map>
4976 Each line in this buffer represents one article. To read an
4977 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
4978 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
4981 You can also post articles and send mail from this buffer. To
4982 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
4983 of an article, type `\\[gnus-summary-reply]'.
4985 There are approx. one gazillion commands you can execute in this
4986 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
4988 The following commands are available:
4990 \\{gnus-summary-mode-map}"
4992 (if gnus-visual (gnus-summary-make-menu-bar))
4993 (kill-all-local-variables)
4994 (let ((locals gnus-summary-local-variables))
4996 (if (consp (car locals))
4998 (make-local-variable (car (car locals)))
4999 (set (car (car locals)) (eval (cdr (car locals)))))
5000 (make-local-variable (car locals))
5001 (set (car locals) nil))
5002 (setq locals (cdr locals))))
5003 (gnus-make-thread-indent-array)
5004 (gnus-update-format-specifications)
5005 (setq mode-line-modified "-- ")
5006 (make-local-variable 'mode-line-format)
5007 (setq mode-line-format (copy-sequence mode-line-format))
5008 (and (equal (nth 3 mode-line-format) " ")
5009 (setcar (nthcdr 3 mode-line-format) ""))
5010 (setq major-mode 'gnus-summary-mode)
5011 (setq mode-name "Summary")
5012 (make-local-variable 'minor-mode-alist)
5013 (use-local-map gnus-summary-mode-map)
5014 (buffer-disable-undo (current-buffer))
5015 (setq buffer-read-only t) ;Disable modification
5016 (setq truncate-lines t)
5017 (setq selective-display t)
5018 (setq selective-display-ellipses t) ;Display `...'
5019 ;; Change the display table. Odd characters have a tendency to mess
5020 ;; up nicely formatted displays.
5021 (setq buffer-display-table (copy-sequence standard-display-table))
5023 (while (>= (setq i (1- i)) 0)
5024 (aset buffer-display-table i [??])))
5025 (aset buffer-display-table ?\n nil)
5027 (while (>= (setq i (1- i)) 127)
5028 (aset buffer-display-table i [??])))
5029 (run-hooks 'gnus-summary-mode-hook))
5031 (defun gnus-summary-clear-local-variables ()
5032 (let ((locals gnus-summary-local-variables))
5034 (if (consp (car locals))
5035 (and (vectorp (car (car locals)))
5036 (set (car (car locals)) nil))
5037 (and (vectorp (car locals))
5038 (set (car locals) nil)))
5039 (setq locals (cdr locals)))))
5041 (defun gnus-mouse-pick-article (e)
5044 (gnus-summary-next-page nil t))
5046 (defun gnus-summary-setup-buffer (group)
5047 "Initialize summary buffer."
5048 (let ((buffer (concat "*Summary " group "*")))
5049 (if (get-buffer buffer)
5052 (not gnus-newsgroup-threads))
5053 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
5054 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
5055 (gnus-add-current-to-buffer-list)
5057 (and gnus-carpal (gnus-carpal-setup-buffer 'summary))
5058 (setq gnus-newsgroup-name group)
5061 (defun gnus-set-global-variables ()
5062 ;; Set the global equivalents of the summary buffer-local variables
5063 ;; to the latest values they had. These reflect the summary buffer
5064 ;; that was in action when the last article was fetched.
5065 (if (eq major-mode 'gnus-summary-mode)
5067 (setq gnus-summary-buffer (current-buffer))
5068 (let ((name gnus-newsgroup-name)
5069 (marked gnus-newsgroup-marked)
5070 (unread gnus-newsgroup-unreads)
5071 (headers gnus-current-headers))
5073 (set-buffer gnus-group-buffer)
5074 (setq gnus-newsgroup-name name)
5075 (setq gnus-newsgroup-marked marked)
5076 (setq gnus-newsgroup-unreads unread)
5077 (setq gnus-current-headers headers))))))
5079 (defun gnus-summary-insert-dummy-line (sformat subject number)
5081 (setq sformat gnus-summary-dummy-line-format-spec))
5085 (insert (eval sformat))
5086 (add-text-properties
5088 (list 'gnus (list number ?Z 0)))))
5090 (defvar gnus-thread-indent-array nil)
5091 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
5092 (defun gnus-make-thread-indent-array ()
5094 (if (and gnus-thread-indent-array
5095 (= gnus-thread-indent-level gnus-thread-indent-array-level))
5097 (setq gnus-thread-indent-array (make-vector 201 "")
5098 gnus-thread-indent-array-level gnus-thread-indent-level)
5100 (aset gnus-thread-indent-array n
5101 (make-string (* n gnus-thread-indent-level) ? ))
5104 (defun gnus-summary-insert-line
5105 (sformat header level current unread replied expirable subject-or-nil
5106 &optional dummy score)
5107 (or sformat (setq sformat gnus-summary-line-format-spec))
5108 (let* ((indentation (aref gnus-thread-indent-array level))
5109 (lines (header-lines header))
5110 (score (or score gnus-summary-default-score 0))
5111 (score-char (if (or (null gnus-summary-default-score)
5112 (= score gnus-summary-default-score)) ?
5113 (if (< score gnus-summary-default-score)
5114 gnus-score-below-mark gnus-score-over-mark)))
5115 (replied (if replied gnus-replied-mark ? ))
5116 (from (header-from header))
5117 (name-address (funcall gnus-extract-address-components from))
5118 (address (car (cdr name-address)))
5119 (name (or (car name-address) (car (cdr name-address))))
5120 (subject (header-subject header))
5121 (number (header-number header))
5122 (opening-bracket (if dummy ?\< ?\[))
5123 (closing-bracket (if dummy ?\> ?\]))
5124 (buffer-read-only nil)
5125 (b (progn (beginning-of-line) (point))))
5126 (or (numberp lines) (setq lines 0))
5127 (insert (eval sformat))
5128 (add-text-properties
5129 b (1+ b) (list 'gnus (list number (or unread gnus-unread-mark) level)))))
5131 (defun gnus-summary-update-line (&optional dont-update)
5132 ;; Update summary line after change.
5133 (or (not gnus-summary-default-score)
5134 gnus-summary-inhibit-highlight
5135 (let ((gnus-summary-inhibit-highlight t)
5136 (article (gnus-summary-article-number)))
5139 (if (and gnus-summary-mark-below
5140 (< (gnus-summary-article-score)
5141 gnus-summary-mark-below))
5142 (and (not (memq article gnus-newsgroup-marked))
5143 (not (memq article gnus-newsgroup-dormant))
5144 (memq article gnus-newsgroup-unreads)
5145 (gnus-summary-mark-article nil gnus-low-score-mark))
5146 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
5147 (gnus-summary-mark-article nil gnus-unread-mark))))
5149 (run-hooks 'gnus-summary-update-hook))))))
5151 (defun gnus-summary-update-lines (&optional beg end)
5152 ;; Rehighlight summary buffer according to `gnus-summary-highlight'.
5153 (let ((beg (or beg (point-min)))
5154 (end (or end (point-max))))
5156 (set-buffer gnus-summary-buffer)
5158 (while (and (not (eobp)) (< (point) end))
5159 (gnus-summary-update-line)
5160 (forward-line 1)))))
5162 (defun gnus-summary-number-of-articles-in-thread (thread &optional char)
5163 ;; Sum up all elements (and sub-elements) in a list.
5167 '+ (mapcar 'gnus-summary-number-of-articles-in-thread thread))
5170 (if (> number 1) gnus-not-empty-thread-mark
5171 gnus-empty-thread-mark)
5174 (defun gnus-summary-read-group (group &optional show-all no-article kill-buffer)
5175 "Start reading news in newsgroup GROUP.
5176 If SHOW-ALL is non-nil, already read articles are also listed.
5177 If NO-ARTICLE is non-nil, no article is selected initially."
5178 (gnus-message 5 "Retrieving newsgroup: %s..." group)
5179 (let* ((new-group (gnus-summary-setup-buffer group))
5180 (did-select (and new-group (gnus-select-newsgroup group show-all)))
5181 (method (car (gnus-find-method-for-group group))))
5184 (gnus-set-global-variables)
5185 (gnus-kill-buffer kill-buffer)
5186 (gnus-configure-windows 'summary)
5187 (gnus-set-mode-line 'summary)
5188 (gnus-summary-position-cursor)
5192 (and (eq major-mode 'gnus-summary-mode)
5193 (not (equal (current-buffer) kill-buffer))
5195 (kill-buffer (current-buffer))
5196 (set-buffer gnus-group-buffer)
5197 (gnus-group-next-unread-group 1)))
5199 ((eq did-select 'quit)
5200 (and (eq major-mode 'gnus-summary-mode)
5201 (not (equal (current-buffer) kill-buffer))
5202 (kill-buffer (current-buffer)))
5203 (gnus-kill-buffer kill-buffer)
5204 (gnus-configure-windows 'group)
5205 (gnus-group-next-unread-group 1)
5208 (gnus-set-global-variables)
5209 ;; Save the active value in effect when the group was entered.
5210 (setq gnus-newsgroup-active
5212 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5213 ;; You can change the subjects in this hook.
5214 (run-hooks 'gnus-select-group-hook)
5215 ;; Do score processing.
5216 (and gnus-use-scoring (gnus-possibly-score-headers))
5217 ;; Update the format specifiers.
5218 (gnus-update-format-specifications)
5219 ;; Generate the summary buffer.
5220 (gnus-summary-prepare)
5221 (if (zerop (buffer-size))
5222 (cond (gnus-newsgroup-dormant
5223 (gnus-summary-show-all-dormant))
5224 ((and gnus-newsgroup-scored show-all)
5225 (gnus-summary-show-all-expunged))))
5226 ;; Function `gnus-apply-kill-file' must be called in this hook.
5227 (run-hooks 'gnus-apply-kill-hook)
5228 (if (zerop (buffer-size))
5230 ;; This newsgroup is empty.
5231 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
5232 (gnus-message 6 "No unread news")
5233 (gnus-kill-buffer kill-buffer))
5236 (let ((gnus-summary-buffer kill-buffer))
5237 (gnus-configure-windows 'group))))
5238 ;; Hide conversation thread subtrees. We cannot do this in
5239 ;; gnus-summary-prepare-hook since kill processing may not
5240 ;; work with hidden articles.
5241 (and gnus-show-threads
5242 gnus-thread-hide-subtree
5243 (gnus-summary-hide-all-threads))
5244 ;; Show first unread article if requested.
5245 (goto-char (point-min))
5246 (if (and (not no-article)
5247 gnus-auto-select-first
5248 (gnus-summary-first-unread-article))
5249 (gnus-configure-windows 'article)
5250 (gnus-configure-windows 'summary))
5251 (gnus-set-mode-line 'summary)
5252 (gnus-summary-position-cursor)
5253 ;; If in async mode, we send some info to the backend.
5254 (and gnus-newsgroup-async
5255 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
5256 (gnus-request-asynchronous
5258 (if (and gnus-asynchronous-article-function
5259 (fboundp gnus-asynchronous-article-function))
5260 (funcall gnus-asynchronous-article-function
5261 gnus-newsgroup-threads)
5262 gnus-newsgroup-threads)))
5263 (gnus-kill-buffer kill-buffer))))))
5265 (defun gnus-summary-prepare ()
5266 ;; Generate the summary buffer.
5267 (let ((buffer-read-only nil))
5269 (gnus-summary-prepare-threads
5270 (if gnus-show-threads
5271 (gnus-gather-threads
5273 (if gnus-summary-expunge-below
5274 (gnus-make-threads-and-expunge)
5275 (gnus-make-threads))))
5276 gnus-newsgroup-headers)
5278 ;; Erase header retrieval message.
5279 (gnus-summary-update-lines)
5281 ;; Call hooks for modifying summary buffer.
5282 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
5283 (goto-char (point-min))
5284 (run-hooks 'gnus-summary-prepare-hook)))
5286 (defun gnus-gather-threads (threads)
5287 "Gather threads that have lost their roots."
5288 (if (not gnus-summary-make-false-root)
5290 (let ((hashtb (gnus-make-hashtable 1023))
5293 thread subject hthread unre-subject whole-subject)
5295 (setq subject (header-subject (car (car threads)))
5296 whole-subject subject)
5297 (and gnus-summary-gather-subject-limit
5298 (or (and (numberp gnus-summary-gather-subject-limit)
5299 (> (length subject) gnus-summary-gather-subject-limit)
5301 (substring subject 0
5302 gnus-summary-gather-subject-limit)))
5303 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
5304 (setq subject (gnus-simplify-subject-fuzzy subject)))))
5307 (setq unre-subject (gnus-simplify-subject-re subject))
5310 (or (stringp (car (car hthread)))
5311 (setcar hthread (list whole-subject (car hthread))))
5312 (setcdr (car hthread) (nconc (cdr (car hthread))
5313 (list (car threads))))
5314 (setcdr prev (cdr threads))
5315 (setq threads prev))
5316 (gnus-sethash unre-subject threads hashtb))
5318 (setq threads (cdr threads)))
5321 (defun gnus-make-threads ()
5322 ;; This function takes the dependencies already made by
5323 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5324 ;; through the dependecies in the hash table and finds all the
5325 ;; roots. Roots do not refer back to any valid articles.
5327 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5328 (gnus-build-old-threads))
5331 (if (not (car (symbol-value refs)))
5332 (setq roots (append (cdr (symbol-value refs)) roots))
5333 ;; Ok, these refer back to valid articles, but if
5334 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5335 ;; the root has the same subject as its children. The children
5336 ;; that do not are made into roots and removed from the list
5338 (or gnus-thread-ignore-subject
5339 (let* ((prev (symbol-value refs))
5340 (subject (gnus-simplify-subject-re
5341 (header-subject (car prev))))
5342 (headers (cdr prev)))
5344 (if (not (string= subject
5345 (gnus-simplify-subject-re
5346 (header-subject (car headers)))))
5348 (setq roots (cons (car headers) roots))
5349 (setcdr prev (cdr headers)))
5350 (setq prev headers))
5351 (setq headers (cdr headers)))))))
5352 gnus-newsgroup-dependencies)
5354 (mapcar 'gnus-trim-thread
5356 (mapcar 'gnus-cut-thread
5357 (mapcar 'gnus-make-sub-thread roots))))))
5359 (defun gnus-make-threads-and-expunge ()
5360 ;; This function takes the dependencies already made by
5361 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5362 ;; through the dependecies in the hash table and finds all the
5363 ;; roots. Roots do not refer back to any valid articles.
5365 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5366 (gnus-build-old-threads))
5369 (if (not (car (symbol-value refs)))
5370 (if (and gnus-summary-expunge-below
5371 (not gnus-fetch-old-headers))
5372 (let ((headers (cdr (symbol-value refs))))
5374 (if (not (< (or (cdr (assq (header-number (car headers))
5375 gnus-newsgroup-scored))
5376 gnus-summary-default-score 0)
5377 gnus-summary-expunge-below))
5378 (setq roots (cons (car headers) roots))
5379 (setq gnus-newsgroup-unreads
5380 (delq (header-number (car headers))
5381 gnus-newsgroup-unreads)))
5382 (setq headers (cdr headers))))
5383 (setq roots (append (cdr (symbol-value refs)) roots)))
5384 ;; Ok, these refer back to valid articles, but if
5385 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5386 ;; the root has the same subject as its children. The children
5387 ;; that do not are made into roots and removed from the list
5389 (or gnus-thread-ignore-subject
5390 (let* ((prev (symbol-value refs))
5391 (subject (gnus-simplify-subject-re
5392 (header-subject (car prev))))
5393 (headers (cdr prev)))
5395 (if (not (string= subject
5396 (gnus-simplify-subject-re
5397 (header-subject (car headers)))))
5399 (if (not (< (or (cdr (assq (header-number (car headers))
5400 gnus-newsgroup-scored))
5401 gnus-summary-default-score 0)
5402 gnus-summary-expunge-below))
5403 (setq roots (cons (car headers) roots))
5404 (setq gnus-newsgroup-unreads
5405 (delq (header-number (car headers))
5406 gnus-newsgroup-unreads)))
5407 (setcdr prev (cdr headers)))
5408 (setq prev headers))
5409 (setq headers (cdr headers)))))
5410 (and gnus-summary-expunge-below
5411 (not gnus-fetch-old-headers)
5412 (let* ((prev (symbol-value refs))
5413 (headers (cdr prev))
5416 (if (not (< (or (cdr (assq (header-number (car headers))
5417 gnus-newsgroup-scored))
5418 gnus-summary-default-score 0)
5419 gnus-summary-expunge-below))
5420 (setq prev (cdr prev))
5421 (setq gnus-newsgroup-unreads
5422 (delq (header-number (car headers))
5423 gnus-newsgroup-unreads))
5424 (setcdr prev (cdr headers))
5425 (setq id (gnus-gethash (header-id (car headers))
5426 gnus-newsgroup-dependencies))
5429 (if (not (< (or (cdr (assq (header-number (car h))
5430 gnus-newsgroup-scored))
5431 gnus-summary-default-score 0)
5432 gnus-summary-expunge-below))
5433 (setq roots (cons (car h) roots)))
5435 (setq headers (cdr headers)))))))
5436 gnus-newsgroup-dependencies)
5438 (mapcar 'gnus-trim-thread
5440 (mapcar 'gnus-cut-thread
5441 (mapcar 'gnus-make-sub-thread roots))))))
5443 (defun gnus-cut-thread (thread)
5444 ;; Remove leaf dormant or ancient articles from THREAD.
5445 (let ((head (car thread))
5446 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
5447 (if (and (null tail)
5448 (let ((number (header-number head)))
5449 (or (memq number gnus-newsgroup-ancient)
5450 (memq number gnus-newsgroup-dormant)
5451 (and gnus-summary-expunge-below
5452 (eq gnus-fetch-old-headers 'some)
5453 (< (or (cdr (assq number gnus-newsgroup-scored))
5454 gnus-summary-default-score 0)
5455 gnus-summary-expunge-below)
5457 (setq gnus-newsgroup-unreads
5458 (delq number gnus-newsgroup-unreads))
5461 (list (cons head tail)))))
5463 (defun gnus-trim-thread (thread)
5464 ;; Remove root ancient articles with only one child from THREAD.
5465 (if (and (eq gnus-fetch-old-headers 'some)
5466 (memq (header-number (car thread)) gnus-newsgroup-ancient)
5467 (= (length thread) 2))
5468 (gnus-trim-thread (nth 1 thread))
5471 (defun gnus-make-sub-thread (root)
5472 ;; This function makes a sub-tree for a node in the tree.
5473 (let ((children (reverse (cdr (gnus-gethash (downcase (header-id root))
5474 gnus-newsgroup-dependencies)))))
5475 (cons root (mapcar 'gnus-make-sub-thread children))))
5477 (defun gnus-build-old-threads ()
5478 ;; Look at all the articles that refer back to old articles, and
5479 ;; fetch the headers for the articles that aren't there. This will
5480 ;; build complete threads - if the roots haven't been expired by the
5485 (if (not (car (symbol-value refs)))
5487 (setq heads (cdr (symbol-value refs)))
5489 (if (not (memq (header-number (car heads))
5490 gnus-newsgroup-dormant))
5492 (setq id (symbol-name refs))
5493 (while (and (setq id (gnus-build-get-header id))
5494 (not (car (gnus-gethash
5495 id gnus-newsgroup-dependencies)))))
5497 (setq heads (cdr heads)))))))
5498 gnus-newsgroup-dependencies)))
5500 (defun gnus-build-get-header (id)
5501 ;; Look through the buffer of NOV lines and find the header to
5502 ;; ID. Enter this line into the dependencies hash table, and return
5503 ;; the id of the parent article (if any).
5504 (let ((deps gnus-newsgroup-dependencies)
5508 (set-buffer nntp-server-buffer)
5509 (goto-char (point-min))
5510 (while (and (not found) (search-forward id nil t))
5512 (setq found (looking-at
5513 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
5514 (regexp-quote id))))
5515 (or found (beginning-of-line 2)))
5520 (setq header (gnus-nov-parse-line
5521 (read (current-buffer)) deps))
5522 (setq ref (header-references header))
5523 (string-match "\\(<[^>]+>\\) *$" ref)
5524 (substring ref (match-beginning 1) (match-end 1))))))
5526 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
5527 gnus-newsgroup-ancient (cons (header-number header)
5528 gnus-newsgroup-ancient))))))
5530 ;; Re-build the thread containing ID.
5531 (defun gnus-rebuild-thread (id)
5532 (let ((dep gnus-newsgroup-dependencies)
5533 (buffer-read-only nil)
5534 parent headers refs thread art)
5535 (while (and id (setq headers
5536 (car (setq art (gnus-gethash (downcase id) dep)))))
5538 (setq id (and (setq refs (header-references headers))
5539 (string-match "\\(<[^>]+>\\) *$" refs)
5540 (substring refs (match-beginning 1) (match-end 1)))))
5541 (setq thread (gnus-make-sub-thread (car parent)))
5542 (gnus-rebuild-remove-articles thread)
5543 (let ((beg (point)))
5544 (gnus-summary-prepare-threads (list thread) 0)
5545 (gnus-summary-update-lines beg (point)))))
5547 ;; Delete all lines in the summary buffer that correspond to articles
5549 (defun gnus-rebuild-remove-articles (thread)
5550 (and (gnus-summary-goto-subject (header-number (car thread)))
5552 (mapcar (lambda (th) (gnus-rebuild-remove-articles th)) (cdr thread)))
5554 (defun gnus-sort-threads (threads)
5555 ;; Sort threads as specified in `gnus-thread-sort-functions'.
5556 (let ((fun gnus-thread-sort-functions))
5558 (setq threads (sort threads (car fun))
5562 (defun gnus-thread-header (thread)
5563 ;; Return header of first article in THREAD.
5565 (if (stringp (car thread))
5566 (car (car (cdr thread)))
5570 (defun gnus-thread-sort-by-number (h1 h2)
5571 "Sort threads by root article number."
5572 (let ((h1 (gnus-thread-header h1))
5573 (h2 (gnus-thread-header h2)))
5574 (< (header-number h1) (header-number h2))))
5576 (defun gnus-thread-sort-by-author (h1 h2)
5577 "Sort threads by root author."
5578 (let ((h1 (gnus-thread-header h1))
5579 (h2 (gnus-thread-header h2)))
5581 (let ((extract (funcall
5582 gnus-extract-address-components (header-from h1))))
5583 (or (car extract) (cdr extract)))
5584 (let ((extract (funcall
5585 gnus-extract-address-components (header-from h2))))
5586 (or (car extract) (cdr extract))))))
5588 (defun gnus-thread-sort-by-subject (h1 h2)
5589 "Sort threads by root subject."
5590 (let ((h1 (gnus-thread-header h1))
5591 (h2 (gnus-thread-header h2)))
5593 (downcase (gnus-simplify-subject (header-subject h1)))
5594 (downcase (gnus-simplify-subject (header-subject h2))))))
5596 (defun gnus-thread-sort-by-date (h1 h2)
5597 "Sort threads by root article date."
5598 (let ((h1 (gnus-thread-header h1))
5599 (h2 (gnus-thread-header h2)))
5601 (gnus-sortable-date (header-date h1))
5602 (gnus-sortable-date (header-date h2)))))
5604 (defun gnus-thread-sort-by-score (h1 h2)
5605 "Sort threads by root article score.
5606 Unscored articles will be counted as havin a score of zero."
5607 (let ((h1 (gnus-thread-header h1))
5608 (h2 (gnus-thread-header h2)))
5609 (let ((s1 (assq (header-number h1) gnus-newsgroup-scored))
5610 (s2 (assq (header-number h2) gnus-newsgroup-scored)))
5611 (> (or (cdr s1) gnus-summary-default-score 0)
5612 (or (cdr s2) gnus-summary-default-score 0)))))
5614 (defun gnus-thread-sort-by-total-score (h1 h2)
5615 "Sort threads by the sum of all scores in the thread.
5616 Unscored articles will be counted as havin a score of zero."
5617 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5619 (defun gnus-thread-total-score (thread)
5620 ;; This function find the total score of THREAD.
5622 (if (stringp (car thread))
5623 (apply gnus-thread-score-function 0
5624 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5625 (gnus-thread-total-score-1 thread))
5626 (gnus-thread-total-score-1 (list thread))))
5628 (defun gnus-thread-total-score-1 (root)
5629 ;; This function find the total score of the thread below ROOT.
5630 (setq root (car root))
5631 (apply gnus-thread-score-function
5632 (or (cdr (assq (header-number root) gnus-newsgroup-scored))
5633 gnus-summary-default-score 0)
5634 (mapcar 'gnus-thread-total-score
5635 (cdr (gnus-gethash (downcase (header-id root))
5636 gnus-newsgroup-dependencies)))))
5638 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5639 (defvar gnus-tmp-prev-subject "")
5640 (defvar gnus-tmp-adopt-thread nil)
5642 ;; Basic ideas by Paul Dworkin <paul@media-lab.media.mit.edu>.
5643 (defun gnus-summary-prepare-threads
5644 (threads level &optional not-child no-subject cull)
5645 "Prepare summary buffer from THREADS and indentation LEVEL.
5646 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5647 or a straight list of headers."
5648 (let (thread header number subject clevel)
5650 (setq thread (car threads)
5651 threads (cdr threads))
5652 ;; If `thread' is a cons, hierarchical threads are used. If not,
5653 ;; `thread' is the header.
5655 (setq header (car thread))
5656 (setq header thread)
5658 (or (memq (setq number (header-number header))
5659 gnus-newsgroup-dormant)
5660 (and gnus-summary-expunge-below
5661 (< (or (cdr (assq number gnus-newsgroup-scored))
5662 gnus-summary-default-score 0)
5663 gnus-summary-expunge-below)))
5666 (setq gnus-newsgroup-unreads
5667 (delq number gnus-newsgroup-unreads)))))
5670 ;; The header is a dummy root.
5671 (cond ((eq gnus-summary-make-false-root 'adopt)
5672 ;; We let the first article adopt the rest.
5673 (let ((gnus-tmp-adopt-thread thread))
5674 (gnus-summary-prepare-threads (list (car (cdr thread))) 0))
5675 (setq thread (cdr (cdr thread)))
5677 (gnus-summary-prepare-threads (list (car thread)) 1 t)
5678 (setq thread (cdr thread))))
5679 ((eq gnus-summary-make-false-root 'dummy)
5680 ;; We output a dummy root.
5681 (gnus-summary-insert-dummy-line
5682 nil header (header-number (car (car (cdr thread)))))
5684 ((eq gnus-summary-make-false-root 'empty)
5685 ;; We print the articles with empty subject fields.
5686 (let ((gnus-tmp-adopt-thread thread))
5687 (gnus-summary-prepare-threads (list (car (cdr thread))) 0))
5688 (setq thread (cdr (cdr thread)))
5690 (gnus-summary-prepare-threads
5691 (list (car thread)) 0 nil
5692 (not (and (eq gnus-summary-gather-subject-limit 'fuzzy)
5694 (gnus-simplify-subject-re
5695 (header-subject (car (car thread))))
5696 (gnus-simplify-subject-re header))))))
5697 (setq thread (cdr thread))))
5699 ;; We do not make a root for the gathered
5700 ;; sub-threads at all.
5702 ;; Print the sub-threads.
5703 (and (consp thread) (cdr thread)
5704 (gnus-summary-prepare-threads (cdr thread) clevel)))
5705 ;; The header is a real article.
5707 (setq number (header-number header)
5708 subject (header-subject header))
5709 (and gnus-newsgroup-async
5710 (setq gnus-newsgroup-threads
5711 (cons (cons (header-number header)
5712 (header-lines header)) gnus-newsgroup-threads)))
5713 (gnus-summary-insert-line
5714 nil header level nil
5715 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
5716 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
5717 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
5718 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
5719 (t gnus-ancient-mark))
5720 (memq number gnus-newsgroup-replied)
5721 (memq number gnus-newsgroup-expirable)
5723 gnus-summary-same-subject
5724 (if (or (zerop level)
5725 (and gnus-thread-ignore-subject
5727 (gnus-simplify-subject-re gnus-tmp-prev-subject)
5728 (gnus-simplify-subject-re subject)))))
5730 gnus-summary-same-subject))
5732 (cdr (assq number gnus-newsgroup-scored)))
5733 (setq gnus-tmp-prev-subject subject)
5734 ;; Recursively print subthreads.
5735 (and (consp thread) (cdr thread)
5736 (gnus-summary-prepare-threads (cdr thread) (1+ level))))))))
5738 (defun gnus-select-newsgroup (group &optional read-all)
5739 "Select newsgroup GROUP.
5740 If READ-ALL is non-nil, all articles in the group are selected."
5741 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5742 (info (nth 2 entry))
5743 articles header-marks)
5744 (gnus-check-news-server
5745 (setq gnus-current-select-method (gnus-find-method-for-group group)))
5747 (or (gnus-server-opened gnus-current-select-method)
5748 (gnus-open-server gnus-current-select-method)
5749 (error "Couldn't open server"))
5751 (or (and (eq (car entry) t)
5752 (gnus-activate-newsgroup (car info)))
5753 (gnus-request-group group t)
5755 (kill-buffer (current-buffer))
5756 (error "Couldn't request group %s: %s"
5757 group (gnus-status-message group))))
5759 (setq gnus-newsgroup-name group)
5760 (setq gnus-newsgroup-unselected nil)
5761 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5763 (and gnus-asynchronous
5764 (gnus-check-backend-function
5765 'request-asynchronous gnus-newsgroup-name)
5766 (setq gnus-newsgroup-async
5767 (gnus-request-asynchronous gnus-newsgroup-name)))
5769 (setq articles (gnus-articles-to-read group read-all))
5773 (gnus-message 3 "Couldn't select newsgroup")
5775 ((eq articles 0) nil)
5777 ;; Init the dependencies hash table.
5778 (setq gnus-newsgroup-dependencies
5779 (gnus-make-hashtable (length articles)))
5780 ;; Retrieve the headers and read them in.
5781 (setq gnus-newsgroup-headers
5782 (if (eq 'nov (setq gnus-headers-retrieved-by
5783 (gnus-retrieve-headers
5784 (if gnus-fetch-old-headers
5785 (cons 1 articles) articles)
5786 gnus-newsgroup-name)))
5788 (gnus-get-newsgroup-headers-xover articles))
5789 (gnus-get-newsgroup-headers)))
5790 ;; If we were to fetch old headers, but the backend didn't
5791 ;; support XOVER, then it is possible we fetched one article
5792 ;; that we shouldn't have. If that's the case, we pop it off the
5794 (and (not (eq gnus-headers-retrieved-by 'nov))
5795 gnus-fetch-old-headers
5796 gnus-newsgroup-headers
5797 (/= (header-number (car gnus-newsgroup-headers)) (car articles))
5798 (setq gnus-newsgroup-headers (cdr gnus-newsgroup-headers)))
5799 ;; Remove cancelled articles from the list of unread articles.
5800 (setq gnus-newsgroup-unreads
5801 (gnus-set-sorted-intersection
5802 gnus-newsgroup-unreads
5803 (mapcar (lambda (headers) (header-number headers))
5804 gnus-newsgroup-headers)))
5805 ;; Adjust and set lists of article marks.
5808 (gnus-adjust-marked-articles info)
5809 (setq gnus-newsgroup-marked
5810 (cdr (assq 'tick (setq marked (nth 3 info)))))
5811 (setq gnus-newsgroup-replied (cdr (assq 'reply marked)))
5812 (setq gnus-newsgroup-expirable (cdr (assq 'expire marked)))
5813 (setq gnus-newsgroup-killed (cdr (assq 'killed marked)))
5814 (setq gnus-newsgroup-bookmarks (cdr (assq 'bookmark marked)))
5815 (setq gnus-newsgroup-dormant (cdr (assq 'dormant marked)))
5816 (setq gnus-newsgroup-scored (cdr (assq 'score marked)))
5817 (setq gnus-newsgroup-processable nil)))
5818 ;; Check whether auto-expire is to be done in this group.
5819 (setq gnus-newsgroup-auto-expire
5820 (or (and (stringp gnus-auto-expirable-newsgroups)
5821 (string-match gnus-auto-expirable-newsgroups group))
5822 (memq 'auto-expire (nth 5 info))))
5823 ;; First and last article in this newsgroup.
5824 (and gnus-newsgroup-headers
5825 (setq gnus-newsgroup-begin
5826 (header-number (car gnus-newsgroup-headers)))
5827 (setq gnus-newsgroup-end
5828 (header-number (gnus-last-element gnus-newsgroup-headers))))
5829 (setq gnus-reffed-article-number -1)
5830 ;; GROUP is successfully selected.
5831 (or gnus-newsgroup-headers t)))))
5833 (defun gnus-articles-to-read (group read-all)
5834 ;; Find out what articles the user wants to read.
5836 ;; Select all articles if `read-all' is non-nil, or if all the
5837 ;; unread articles are dormant articles.
5839 (= (length gnus-newsgroup-unreads)
5840 (length gnus-newsgroup-dormant)))
5841 (gnus-uncompress-range
5842 (gnus-gethash group gnus-active-hashtb))
5843 gnus-newsgroup-unreads))
5844 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5845 (scored (length scored-list))
5846 (number (length articles))
5847 (marked (+ (length gnus-newsgroup-marked)
5848 (length gnus-newsgroup-dormant)))
5851 (cond ((and (or (<= scored marked)
5853 (numberp gnus-large-newsgroup)
5854 (> number gnus-large-newsgroup))
5858 "How many articles from %s (default %d): "
5859 gnus-newsgroup-name number))))
5860 (if (string-equal input "")
5862 ((and (> scored marked) (< scored number))
5866 "%s %s (%d scored, %d total): "
5867 "How many articles from"
5868 group scored number))))
5869 (if (string-equal input "")
5874 (setq select (if (stringp select) (string-to-number select) select))
5875 (if (or (null select) (zerop select))
5877 (if (and (not (zerop scored)) (<= (abs select) scored))
5879 (setq articles (sort scored-list '<))
5880 (setq number (length articles)))
5881 (setq articles (copy-sequence articles)))
5883 (setq total-articles articles)
5885 (if (< (abs select) number)
5887 ;; Select the N oldest articles.
5888 (setcdr (nthcdr (1- (abs select)) articles) nil)
5889 ;; Select the N most recent articles.
5890 (setq articles (nthcdr (- number select) articles))))
5891 (setq gnus-newsgroup-unselected
5892 (gnus-sorted-intersection
5893 gnus-newsgroup-unreads
5894 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
5897 (defun gnus-killed-articles (killed articles)
5900 (if (inline (gnus-member-of-range (car articles) killed))
5901 (setq out (cons (car articles) out)))
5902 (setq articles (cdr articles)))
5905 (defun gnus-adjust-marked-articles (info &optional active)
5906 "Remove all marked articles that are no longer legal."
5907 (let ((marked-lists (nth 3 info))
5908 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
5910 ;; There are many types of marked articles.
5912 (setq m (cdr (setq prev (car marked-lists))))
5913 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
5914 ;; Make sure that all ticked articles are a subset of the
5915 ;; unread/unselected articles.
5917 (if (or (memq (car m) gnus-newsgroup-unreads)
5918 (memq (car m) gnus-newsgroup-unselected))
5920 (setcdr prev (cdr m)))
5922 ((eq 'score (car prev))
5923 ;; Scored articles should be a subset of
5924 ;; unread/unselected articles.
5926 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
5927 (memq (car (car m)) gnus-newsgroup-unreads))
5929 (setcdr prev (cdr m)))
5931 ((eq 'bookmark (car prev))
5932 ;; Bookmarks should be a subset of active articles.
5934 (if (< (car (car m)) (car active))
5935 (setcdr prev (cdr m))
5938 ((eq 'killed (car prev))
5939 ;; Articles that have been through the kill process are
5940 ;; to be a subset of active articles.
5941 (while (and m (< (or (and (numberp (car m)) (car m))
5944 (setcdr prev (cdr m))
5946 (if (and m (< (or (and (numberp (car m)) (car m))
5949 (setcar (if (numberp (car m)) m (car m)) (car active))))
5950 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
5951 ;; The replied and expirable articles have to be articles
5954 (if (< (car m) (car active))
5955 (setcdr prev (cdr m))
5958 (setq marked-lists (cdr marked-lists)))
5959 ;; Remove all lists that are empty.
5960 (setq marked-lists (nth 3 info))
5963 (while (= 1 (length (car marked-lists)))
5964 (setq marked-lists (cdr marked-lists)))
5965 (setq m (cdr (setq prev marked-lists)))
5967 (if (= 1 (length (car m)))
5968 (setcdr prev (cdr m))
5971 (setcar (nthcdr 3 info) marked-lists)))
5972 ;; Finally, if there are no marked lists at all left, and if there
5973 ;; are no elements after the lists in the info list, we just chop
5974 ;; the info list off before the marked lists.
5975 (and (null marked-lists)
5976 (not (nthcdr 4 info))
5977 (setcdr (nthcdr 2 info) nil)))
5980 (defun gnus-set-marked-articles
5981 (info ticked replied expirable killed dormant bookmark score)
5982 "Enter the various lists of marked articles into the newsgroup info list."
5984 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
5985 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
5986 (and expirable (setq newmarked (cons (cons 'expire expirable)
5988 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
5989 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
5990 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
5992 (and score (setq newmarked (cons (cons 'score score) newmarked)))
5995 (setcar (nthcdr 3 info) newmarked)
5996 (if (not (nthcdr 4 info))
5997 (setcdr (nthcdr 2 info) nil)
5998 (setcar (nthcdr 3 info) nil)))
6000 (setcdr (nthcdr 2 info) (cons newmarked nil))))))
6002 (defun gnus-add-marked-articles (group type articles &optional info force)
6003 ;; Add ARTICLES of TYPE to the info of GROUP.
6004 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
6005 ;; add, but replace marked articles of TYPE with ARTICLES.
6006 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6009 (and (not (setq marked (nthcdr 3 info)))
6010 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
6011 (and (not (setq m (assq type (car marked))))
6012 (setcar marked (cons (cons type articles) (car marked))))
6015 (nconc m articles)))))
6017 (defun gnus-set-mode-line (where)
6018 "This function sets the mode line of the article or summary buffers.
6019 If WHERE is `summary', the summary mode line format will be used."
6020 (if (memq where gnus-updated-mode-lines)
6023 (set-buffer gnus-summary-buffer)
6024 (let* ((mformat (if (eq where 'article)
6025 gnus-article-mode-line-format-spec
6026 gnus-summary-mode-line-format-spec))
6027 (group-name gnus-newsgroup-name)
6028 (article-number (or gnus-current-article 0))
6029 (unread (- (length gnus-newsgroup-unreads)
6030 (length gnus-newsgroup-dormant)))
6031 (unread-and-unticked
6032 (- unread (length gnus-newsgroup-marked)))
6033 (unselected (length gnus-newsgroup-unselected))
6034 (unread-and-unselected
6035 (cond ((and (zerop unread-and-unticked)
6036 (zerop unselected)) "")
6038 (format "{%d more}" unread-and-unticked))
6039 (t (format "{%d(+%d) more}"
6040 unread-and-unticked unselected))))
6042 (if gnus-current-headers
6043 (header-subject gnus-current-headers) ""))
6044 (max-len (and gnus-mode-non-string-length
6045 (- (frame-width) gnus-mode-non-string-length)))
6046 header) ;; passed as argument to any user-format-funcs
6047 (setq mode-string (eval mformat))
6048 (or (numberp max-len)
6049 (setq max-len (length mode-string)))
6050 (if (< max-len 4) (setq max-len 4))
6051 (if (> (length mode-string) max-len)
6053 (concat (substring mode-string 0 (- max-len 3))
6055 (setq mode-string (format (format "%%-%ds" max-len)
6057 (setq mode-line-buffer-identification mode-string)
6058 (set-buffer-modified-p t))))
6060 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6061 "Go through the HEADERS list and add all Xrefs to a hash table.
6062 The resulting hash table is returned, or nil if no Xrefs were found."
6063 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
6065 (gnus-group-foreign-p from-newsgroup)
6067 (assoc (symbol-name (car from-method))
6068 gnus-valid-select-methods))))
6069 (gnus-group-real-prefix from-newsgroup)))
6070 (xref-hashtb (make-vector 63 0))
6071 start group entry number xrefs header)
6073 (setq header (car headers))
6074 (if (and (setq xrefs (header-xref header))
6075 (not (memq (header-number header) unreads)))
6078 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
6079 (setq start (match-end 0))
6080 (setq group (concat prefix (substring xrefs (match-beginning 1)
6083 (string-to-int (substring xrefs (match-beginning 2)
6085 (if (setq entry (gnus-gethash group xref-hashtb))
6086 (setcdr entry (cons number (cdr entry)))
6087 (gnus-sethash group (cons number nil) xref-hashtb)))))
6088 (setq headers (cdr headers)))
6089 (if start xref-hashtb nil)))
6091 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
6092 "Look through all the headers and mark the Xrefs as read."
6093 (let ((virtual (memq 'virtual
6094 (assoc (symbol-name (car (gnus-find-method-for-group
6096 gnus-valid-select-methods)))
6097 name entry read info xref-hashtb idlist active num range exps method
6100 (set-buffer gnus-group-buffer)
6101 (if (setq xref-hashtb
6102 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6105 (if (string= from-newsgroup (setq name (symbol-name group)))
6107 (setq idlist (symbol-value group))
6108 ;; Dead groups are not updated.
6110 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
6112 (if (stringp (setq nth4 (nth 4 info)))
6113 (setq nth4 (gnus-server-to-method nth4))))
6114 ;; Only do the xrefs if the group has the same
6115 ;; select method as the group we have just read.
6116 (or (gnus-methods-equal-p
6117 nth4 (gnus-find-method-for-group from-newsgroup))
6120 (setq method (gnus-find-method-for-group
6122 (and (equal (car nth4) (car method))
6123 (equal (nth 1 nth4) (nth 1 method))))
6124 gnus-use-cross-reference
6125 (or (not (eq gnus-use-cross-reference t))
6127 ;; Only do cross-references on subscribed
6128 ;; groups, if that is what is wanted.
6129 (<= (nth 1 info) gnus-level-subscribed)))
6132 ;; Set the new list of read articles in this group.
6133 (setq active (gnus-gethash name gnus-active-hashtb))
6134 ;; First peel off all illegal article numbers.
6137 (ticked (cdr (assq 'tick (nth 3 info))))
6138 (dormant (cdr (assq 'dormant (nth 3 info))))
6143 (if (or (> id (cdr active))
6147 (setq idlist (delq id idlist)))
6148 (and (memq id expirable)
6149 (setq exps (cons id exps)))
6150 (setq ids (cdr ids)))))
6151 ;; Update expirable articles.
6152 (gnus-add-marked-articles nil 'expirable exps info)
6153 (and (null (nth 2 info))
6155 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
6156 (setcar (nthcdr 2 info)
6160 (setq idlist (sort idlist '<)))))
6161 ;; Then we have to re-compute how many unread
6162 ;; articles there are in this group.
6167 (setq num (- (1+ (cdr active)) (car active))))
6168 ((not (listp (cdr range)))
6169 (setq num (- (cdr active) (- (1+ (cdr range))
6173 (if (numberp (car range))
6175 (setq num (+ num (- (1+ (cdr (car range)))
6176 (car (car range))))))
6177 (setq range (cdr range)))
6178 (setq num (- (cdr active) num))))
6179 ;; Update the number of unread articles.
6183 (length (cdr (assq 'tick (nth 3 info))))
6185 (cdr (assq 'dormant (nth 3 info)))))))
6186 ;; Update the group buffer.
6187 (gnus-group-update-group name t)))))))
6190 (defun gnus-methods-equal-p (m1 m2)
6191 (let ((m1 (or m1 gnus-select-method))
6192 (m2 (or m2 gnus-select-method)))
6194 (and (eq (car m1) (car m2))
6195 (or (not (memq 'address (assoc (symbol-name (car m1))
6196 gnus-valid-select-methods)))
6197 (equal (nth 1 m1) (nth 1 m2)))))))
6199 (defsubst gnus-header-value ()
6200 (buffer-substring (match-end 0) (gnus-point-at-eol)))
6202 (defun gnus-get-newsgroup-headers ()
6203 (setq gnus-article-internal-prepare-hook nil)
6204 (let ((cur nntp-server-buffer)
6205 (dependencies gnus-newsgroup-dependencies)
6207 headers char article id dep end)
6209 (set-buffer nntp-server-buffer)
6210 (goto-char (point-min))
6211 ;; Search to the beginning of the next header. Error messages
6212 ;; do not begin with 2 or 3.
6213 (while (re-search-forward "^[23][0-9]+ " nil t)
6214 (let ((header (make-vector 9 nil))
6215 (c (following-char))
6216 (case-fold-search t)
6218 from subject in-reply-to references ref)
6224 (header-set-number header (setq article (read cur)))
6225 ;; This implementation of this function, with nine
6226 ;; search-forwards instead of the one re-search-forward and
6227 ;; a case (which basically was the old function) is actually
6228 ;; about twice as fast, even though it looks messier. You
6229 ;; can't have everything, I guess. Speed and elegance
6230 ;; doesn't always come hand in hand.
6232 (narrow-to-region (point) (save-excursion
6233 (search-forward "\n.\n" nil t)))
6234 (if (search-forward "\nfrom: " nil t)
6235 (header-set-from header (gnus-header-value))
6236 (header-set-from header "(nobody)"))
6238 (if (search-forward "\nsubject: " nil t)
6239 (header-set-subject header (gnus-header-value))
6240 (header-set-subject header "(none)"))
6242 (and (search-forward "\nxref: " nil t)
6243 (header-set-xref header (gnus-header-value)))
6245 (or (numberp (and (search-forward "\nlines: " nil t)
6246 (header-set-lines header (read cur))))
6247 (header-set-lines header 0))
6249 (and (search-forward "\ndate: " nil t)
6250 (header-set-date header (gnus-header-value)))
6252 (if (search-forward "\nmessage-id: " nil t)
6253 (header-set-id header (setq id (gnus-header-value)))
6254 ;; If there was no message-id, we just fake one to make
6255 ;; subsequent routines simpler.
6258 (setq id (concat "none+" (int-to-string
6259 (setq none-id (1+ none-id)))))))
6261 (if (search-forward "\nreferences: " nil t)
6263 (header-set-references header (gnus-header-value))
6264 (setq end (match-end 0))
6271 (search-backward ">" end t)
6274 (search-backward "<" end t)
6276 ;; Get the references from the in-reply-to header if there
6277 ;; ware no references and the in-reply-to header looks
6279 (if (and (search-forward "\nin-reply-to: " nil t)
6280 (setq in-reply-to (gnus-header-value))
6281 (string-match "<[^>]+>" in-reply-to))
6283 (header-set-references
6285 (setq ref (substring in-reply-to (match-beginning 0)
6287 (setq ref (downcase ref)))
6289 ;; We do some threading while we read the headers. The
6290 ;; message-id and the last reference are both entered into
6291 ;; the same hash table. Some tippy-toeing around has to be
6292 ;; done in case an article has arrived before the article
6293 ;; which it refers to.
6294 (if (boundp (setq dep (intern (downcase id) dependencies)))
6295 (if (car (symbol-value dep))
6296 ;; An article with this Message-ID has already
6297 ;; been seen, so we ignore this one, except we add
6298 ;; any additional Xrefs (in case the two articles
6299 ;; came from different servers.
6302 (car (symbol-value dep))
6303 (concat (or (header-xref (car (symbol-value dep))) "")
6304 (or (header-xref header) "")))
6306 (setcar (symbol-value dep) header))
6307 (set dep (list header)))
6310 (if (boundp (setq dep (intern ref dependencies)))
6311 (setcdr (symbol-value dep)
6312 (cons header (cdr (symbol-value dep))))
6313 (set dep (list nil header)))
6314 (setq headers (cons header headers))))
6315 (goto-char (point-max))))))
6316 (nreverse headers)))
6318 ;; The following macros and functions were written by Felix Lee
6319 ;; <flee@cse.psu.edu>.
6321 (defmacro gnus-nov-read-integer ()
6323 (if (= (following-char) ?\t)
6325 (let ((num (read buffer)))
6326 (if (numberp num) num 0)))
6327 (or (eobp) (forward-char 1))))
6329 (defmacro gnus-nov-skip-field ()
6330 '(search-forward "\t" eol 'move))
6332 (defmacro gnus-nov-field ()
6333 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
6335 ;; Goes through the xover lines and returns a list of vectors
6336 (defun gnus-get-newsgroup-headers-xover (sequence)
6337 "Parse the news overview data in the server buffer, and return a
6338 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
6339 ;; Get the Xref when the users reads the articles since most/some
6340 ;; NNTP servers do not include Xrefs when using XOVER.
6341 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6342 (let ((cur nntp-server-buffer)
6343 (dependencies gnus-newsgroup-dependencies)
6345 number headers header)
6347 (set-buffer nntp-server-buffer)
6348 (goto-char (point-min))
6349 (while (and sequence (not (eobp)))
6350 (setq number (read cur))
6351 (while (and sequence (< (car sequence) number))
6352 (setq sequence (cdr sequence)))
6354 (eq number (car sequence))
6356 (setq sequence (cdr sequence))
6358 (inline (gnus-nov-parse-line number dependencies)))
6359 (setq headers (cons header headers)))))
6361 (setq headers (nreverse headers)))
6364 ;; This function has to be called with point after the article number
6365 ;; on the beginning of the line.
6366 (defun gnus-nov-parse-line (number dependencies)
6368 (eol (gnus-point-at-eol))
6369 (buffer (current-buffer))
6372 ;; overview: [num subject from date id refs chars lines misc]
6373 (narrow-to-region (point) eol)
6380 (gnus-nov-field) ; subject
6381 (gnus-nov-field) ; from
6382 (gnus-nov-field) ; date
6383 (setq id (or (gnus-nov-field)
6386 (setq none (1+ none)))))) ; id
6389 (let ((beg (point)))
6390 (search-forward "\t" eol)
6391 (if (search-backward ">" beg t)
6397 (search-backward "<" beg t)
6400 (gnus-nov-field)) ; refs
6401 (gnus-nov-read-integer) ; chars
6402 (gnus-nov-read-integer) ; lines
6403 (if (= (following-char) ?\n)
6405 (gnus-nov-field)) ; misc
6413 ;; We build the thread tree.
6415 (if (boundp (setq dep (intern (downcase id) dependencies)))
6416 (if (car (symbol-value dep))
6417 ;; An article with this Message-ID has already been seen,
6418 ;; so we ignore this one, except we add any additional
6419 ;; Xrefs (in case the two articles came from different
6423 (car (symbol-value dep))
6424 (concat (or (header-xref (car (symbol-value dep))) "")
6425 (or (header-xref header) "")))
6427 (setcar (symbol-value dep) header))
6428 (set dep (list header))))
6431 (if (boundp (setq dep (intern (or ref "none")
6433 (setcdr (symbol-value dep)
6434 (cons header (cdr (symbol-value dep))))
6435 (set dep (list nil header)))))
6438 (defun gnus-article-get-xrefs ()
6439 "Fill in the Xref value in `gnus-current-headers', if necessary.
6440 This is meant to be called in `gnus-article-internal-prepare-hook'."
6441 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
6442 gnus-current-headers)))
6443 (or (not gnus-use-cross-reference)
6444 (and (header-xref headers)
6445 (not (string= (header-xref headers) "")))
6446 (let ((case-fold-search t)
6449 (gnus-narrow-to-headers)
6450 (goto-char (point-min))
6451 (if (or (and (eq (downcase (following-char)) ?x)
6452 (looking-at "Xref:"))
6453 (search-forward "\nXref:" nil t))
6455 (goto-char (1+ (match-end 0)))
6456 (setq xref (buffer-substring (point)
6457 (progn (end-of-line) (point))))
6458 (header-set-xref headers xref))))))))
6460 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
6461 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
6463 ;; Return a header specified by a NUMBER.
6464 (defun gnus-get-header-by-number (number)
6466 (set-buffer gnus-summary-buffer)
6467 (or gnus-newsgroup-headers-hashtb-by-number
6468 (gnus-make-headers-hashtable-by-number))
6469 (gnus-gethash (int-to-string number)
6470 gnus-newsgroup-headers-hashtb-by-number)))
6472 (defun gnus-make-headers-hashtable-by-number ()
6473 "Make hashtable for the variable gnus-newsgroup-headers by number."
6475 (set-buffer gnus-summary-buffer)
6476 (let ((headers gnus-newsgroup-headers)
6478 (setq gnus-newsgroup-headers-hashtb-by-number
6479 (gnus-make-hashtable (length headers)))
6481 (setq header (car headers))
6482 (gnus-sethash (int-to-string (header-number header))
6483 header gnus-newsgroup-headers-hashtb-by-number)
6484 (setq headers (cdr headers))))))
6486 (defun gnus-more-header-backward ()
6487 "Find new header backward."
6488 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6489 (artnum gnus-newsgroup-begin)
6491 (while (and (not header)
6493 (setq artnum (1- artnum))
6494 (setq header (gnus-read-header artnum)))
6497 (defun gnus-more-header-forward (&optional backward)
6498 "Find new header forward.
6499 If BACKWARD, find new header backward instead."
6501 (gnus-more-header-backward)
6502 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6503 (artnum gnus-newsgroup-end)
6505 (while (and (not header)
6507 (setq artnum (1+ artnum))
6508 (setq header (gnus-read-header artnum)))
6511 (defun gnus-extend-newsgroup (header &optional backward)
6512 "Extend newsgroup selection with HEADER.
6513 Optional argument BACKWARD means extend toward backward."
6515 (let ((artnum (header-number header)))
6516 (setq gnus-newsgroup-headers
6518 (cons header gnus-newsgroup-headers)
6519 (nconc gnus-newsgroup-headers (list header))))
6520 (setq gnus-newsgroup-unselected
6521 (delq artnum gnus-newsgroup-unselected))
6522 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
6523 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
6525 (defun gnus-summary-work-articles (n)
6526 "Return a list of articles to be worked upon. The prefix argument,
6527 the list of process marked articles, and the current article will be
6528 taken into consideration."
6530 (if (and n (numberp n))
6531 (let ((backward (< n 0))
6535 (setq articles (cons (gnus-summary-article-number)
6537 (gnus-summary-search-forward nil nil backward))
6539 (sort articles (function <)))
6540 (or (reverse gnus-newsgroup-processable)
6541 (list (gnus-summary-article-number))))))
6543 (defun gnus-summary-search-group (&optional backward use-level)
6544 "Search for next unread newsgroup.
6545 If optional argument BACKWARD is non-nil, search backward instead."
6547 (set-buffer gnus-group-buffer)
6549 ;; We don't want to alter current point of group mode buffer.
6550 (if (gnus-group-search-forward
6552 (if use-level (gnus-group-group-level) nil))
6553 (gnus-group-group-name)))))
6555 (defun gnus-summary-best-group (&optional exclude-group)
6556 "Find the name of the best unread group.
6557 If EXCLUDE-GROUP, do not go to this group."
6559 (set-buffer gnus-group-buffer)
6561 (gnus-group-best-unread-group exclude-group))))
6563 (defun gnus-summary-search-subject (&optional backward unread subject)
6564 "Search for article forward.
6565 If BACKWARD is non-nil, search backward.
6566 If UNREAD is non-nil, only unread articles are selected.
6567 If SUBJECT is non-nil, the article which has the same subject will be
6569 (let ((func (if backward 'previous-single-property-change
6570 'next-single-property-change))
6575 (and gnus-summary-check-current unread
6576 (eq (nth 1 (get-text-property (point) 'gnus)) gnus-unread-mark)
6580 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
6583 (setq pos (funcall func (point) 'gnus))
6584 (goto-char (if backward (1- pos) pos))
6588 (eq (nth 1 (get-text-property (point) 'gnus))
6591 (equal (gnus-simplify-subject-re subject)
6592 (gnus-simplify-subject-re
6593 (gnus-summary-subject-string)))))))
6594 (if backward (if (bobp) nil (forward-char -1) t)
6595 (if (eobp) nil (forward-char 1) t)))))
6597 (progn (goto-char beg) nil)
6599 (car (get-text-property (point) 'gnus))
6600 (gnus-summary-position-cursor)))))
6602 (defun gnus-summary-search-forward (&optional unread subject backward)
6603 "Search for article forward.
6604 If UNREAD is non-nil, only unread articles are selected.
6605 If SUBJECT is non-nil, the article which has the same subject will be
6607 If BACKWARD is non-nil, the search will be performed backwards instead."
6608 (gnus-summary-search-subject backward unread subject))
6610 (defun gnus-summary-search-backward (&optional unread subject)
6611 "Search for article backward.
6612 If 1st optional argument UNREAD is non-nil, only unread article is selected.
6613 If 2nd optional argument SUBJECT is non-nil, the article which has
6614 the same subject will be searched for."
6615 (gnus-summary-search-forward unread subject t))
6617 (defun gnus-summary-article-number (&optional number-or-nil)
6618 "The article number of the article on the current line.
6619 If there isn's an article number here, then we return the current
6622 (number (car (get-text-property
6623 (progn (beginning-of-line)
6624 (prog1 (point) (goto-char p)))
6626 (if number-or-nil number (or number gnus-current-article))))
6628 (defun gnus-summary-thread-level ()
6629 "The thread level of the article on the current line."
6630 (or (nth 2 (get-text-property (gnus-point-at-bol) 'gnus))
6633 (defun gnus-summary-pseudo-article ()
6634 "The thread level of the article on the current line."
6635 (get-text-property (gnus-point-at-bol) 'gnus-pseudo))
6637 (defun gnus-summary-article-mark ()
6638 "The mark on the current line."
6639 (nth 1 (get-text-property (gnus-point-at-bol) 'gnus)))
6641 (defun gnus-summary-subject-string ()
6642 "Return current subject string or nil if nothing."
6643 (let ((article (gnus-summary-article-number))
6646 (setq header (gnus-get-header-by-number article))
6648 (header-subject header))))
6650 (defalias 'gnus-summary-score 'gnus-summary-article-score)
6651 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
6652 (defun gnus-summary-article-score ()
6653 "Return current article score."
6654 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
6655 gnus-summary-default-score 0))
6657 ;; Written by Sudish Joseph <joseph@cis.ohio-state.edu>.
6659 (defun gnus-summary-recenter ()
6660 "Center point in the summary window.
6661 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6662 displayed, no centering will be performed."
6663 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6664 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6665 (let* ((top (cond ((< (window-height) 4) 0)
6666 ((< (window-height) 6) 1)
6668 (height (1- (window-height)))
6669 (bottom (save-excursion (goto-char (point-max))
6670 (forward-line (- height))
6672 (window (get-buffer-window (current-buffer))))
6674 ;; The user has to want it,
6675 gnus-auto-center-summary
6676 ;; the article buffer must be displayed,
6677 (get-buffer-window gnus-article-buffer)
6678 ;; Set the window start to either `bottom', which is the biggest
6679 ;; possible valid number, or the second line from the top,
6680 ;; whichever is the least.
6682 window (min bottom (save-excursion (forward-line (- top)) (point)))))))
6684 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
6685 (defun gnus-short-group-name (group &optional levels)
6686 "Collapse GROUP name LEVELS."
6687 (let ((name "") (foreign "")
6688 (levels (or levels 2)))
6689 (if (string-match ":" group)
6690 (setq foreign (substring group 0 (match-end 0))
6691 group (substring group (match-end 0))))
6693 (if (and (string-match "\\." group) (> levels 0))
6694 (setq name (concat name (substring group 0 1))
6695 group (substring group (match-end 0))
6697 name (concat name "."))
6698 (setq name (concat foreign name group)
6702 (defun gnus-summary-jump-to-group (newsgroup)
6703 "Move point to NEWSGROUP in group mode buffer."
6704 ;; Keep update point of group mode buffer if visible.
6705 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6706 (save-window-excursion
6707 ;; Take care of tree window mode.
6708 (if (get-buffer-window gnus-group-buffer)
6709 (pop-to-buffer gnus-group-buffer))
6710 (gnus-group-jump-to-group newsgroup))
6712 ;; Take care of tree window mode.
6713 (if (get-buffer-window gnus-group-buffer)
6714 (pop-to-buffer gnus-group-buffer)
6715 (set-buffer gnus-group-buffer))
6716 (gnus-group-jump-to-group newsgroup))))
6718 ;; This function returns a list of article numbers based on the
6719 ;; difference between the ranges of read articles in this group and
6720 ;; the range of active articles.
6721 (defun gnus-list-of-unread-articles (group)
6722 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6723 (active (gnus-gethash group gnus-active-hashtb))
6725 unread first nlast unread)
6726 ;; If none are read, then all are unread.
6728 (setq first (car active))
6729 ;; If the range of read articles is a single range, then the
6730 ;; first unread article is the article after the last read
6731 ;; article. Sounds logical, doesn't it?
6732 (if (not (listp (cdr read)))
6733 (setq first (1+ (cdr read)))
6734 ;; `read' is a list of ranges.
6735 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
6736 (car (car read)))) 1)
6740 (while (< first nlast)
6741 (setq unread (cons first unread))
6742 (setq first (1+ first))))
6743 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
6744 (setq nlast (if (atom (car (cdr read)))
6746 (car (car (cdr read)))))
6747 (setq read (cdr read)))))
6748 ;; And add the last unread articles.
6749 (while (<= first last)
6750 (setq unread (cons first unread))
6751 (setq first (1+ first)))
6752 ;; Return the list of unread articles.
6755 (defun gnus-list-of-read-articles (group)
6756 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
6757 (active (gnus-gethash group gnus-active-hashtb)))
6759 (gnus-sorted-complement
6760 (gnus-uncompress-range active)
6761 (gnus-list-of-unread-articles (nth 2 info))))))
6763 ;; Various summary commands
6765 (defun gnus-summary-universal-argument ()
6766 "Perform any operation on all articles marked with the process mark."
6768 (gnus-set-global-variables)
6769 (let ((articles (reverse gnus-newsgroup-processable))
6771 (or articles (error "No articles marked"))
6772 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
6773 (error "Undefined key"))
6775 (gnus-summary-goto-subject (car articles))
6776 (command-execute func)
6777 (gnus-summary-remove-process-mark (car articles))
6778 (setq articles (cdr articles)))))
6780 (defun gnus-summary-toggle-truncation (arg)
6781 "Toggle truncation of summary lines.
6782 With arg, turn line truncation on iff arg is positive."
6784 (setq truncate-lines
6785 (if (null arg) (not truncate-lines)
6786 (> (prefix-numeric-value arg) 0)))
6789 (defun gnus-summary-reselect-current-group (all)
6790 "Once exit and then reselect the current newsgroup.
6791 The prefix argument ALL means to select all articles."
6793 (gnus-set-global-variables)
6794 (let ((current-subject (gnus-summary-article-number))
6795 (group gnus-newsgroup-name))
6796 (setq gnus-newsgroup-threads nil)
6797 (gnus-summary-exit t)
6798 ;; We have to adjust the point of group mode buffer because the
6799 ;; current point was moved to the next unread newsgroup by
6801 (gnus-summary-jump-to-group group)
6802 (gnus-group-read-group all t)
6803 (gnus-summary-goto-subject current-subject)))
6805 (defun gnus-summary-rescan-group (all)
6806 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6808 (gnus-set-global-variables)
6809 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
6810 (let ((group gnus-newsgroup-name))
6812 (gnus-summary-jump-to-group group)
6814 (set-buffer gnus-group-buffer)
6815 (gnus-group-get-new-news-this-group 1))
6816 (gnus-summary-jump-to-group group)
6817 (gnus-group-read-group all)))
6819 (defun gnus-summary-update-info ()
6820 (let* ((group gnus-newsgroup-name)
6821 (method (car (gnus-find-method-for-group group))))
6822 (if gnus-newsgroup-kill-headers
6823 (setq gnus-newsgroup-killed
6824 (gnus-compress-sequence
6826 (gnus-set-sorted-intersection
6827 (gnus-uncompress-range gnus-newsgroup-killed)
6828 (setq gnus-newsgroup-unselected
6829 (sort gnus-newsgroup-unselected '<)))
6830 (setq gnus-newsgroup-unreads
6831 (sort gnus-newsgroup-unreads '<))) t)))
6832 (or (listp (cdr gnus-newsgroup-killed))
6833 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6835 (headers gnus-newsgroup-headers))
6836 (gnus-close-group group)
6837 (run-hooks 'gnus-exit-group-hook)
6838 (gnus-update-read-articles
6839 group gnus-newsgroup-unreads gnus-newsgroup-unselected
6840 gnus-newsgroup-marked
6841 t gnus-newsgroup-replied gnus-newsgroup-expirable
6842 gnus-newsgroup-killed gnus-newsgroup-dormant
6843 gnus-newsgroup-bookmarks
6844 (and gnus-save-score gnus-newsgroup-scored))
6845 (and gnus-use-cross-reference
6846 (gnus-mark-xrefs-as-read
6847 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
6848 ;; Do adaptive scoring, and possibly save score files.
6849 (and gnus-newsgroup-adaptive
6850 (gnus-score-adaptive))
6851 (and (fboundp 'gnus-score-save)
6852 (funcall 'gnus-score-save))
6853 ;; Do not switch windows but change the buffer to work.
6854 (set-buffer gnus-group-buffer)
6855 (or (eq 'nndigest method)
6856 (gnus-group-update-group group)))))
6858 (defun gnus-summary-exit (&optional temporary)
6859 "Exit reading current newsgroup, and then return to group selection mode.
6860 gnus-exit-group-hook is called with no arguments if that value is non-nil."
6862 (gnus-set-global-variables)
6863 (gnus-kill-save-kill-buffer)
6864 (let* ((group gnus-newsgroup-name)
6865 (quit-buffer (cdr (assoc 'quit-buffer (gnus-find-method-for-group
6866 gnus-newsgroup-name))))
6868 (method (car (gnus-find-method-for-group group)))
6869 (buf (current-buffer)))
6870 (gnus-summary-update-info) ; Make all changes in this group permanent.
6871 ;; Make sure where I was, and go to next newsgroup.
6872 (if (eq method 'nndigest)
6874 (gnus-group-jump-to-group group)
6875 (gnus-group-next-unread-group 1))
6878 ;; We set all buffer-local variables to nil. It is unclear why
6879 ;; this is needed, but if we don't, buffer-local variables are
6880 ;; not garbage-collected, it seems. This would the lead to en
6881 ;; ever-growing Emacs.
6883 (gnus-summary-clear-local-variables)
6884 ;; We clear the global counterparts of the buffer-local
6885 ;; variables as well, just to be on the safe side.
6886 (gnus-configure-windows 'group)
6887 (gnus-summary-clear-local-variables)
6888 ;; Return to group mode buffer.
6889 (if (eq mode 'gnus-summary-mode)
6890 (gnus-kill-buffer buf))
6891 (if (get-buffer gnus-article-buffer)
6892 (bury-buffer gnus-article-buffer))
6893 (setq gnus-current-select-method gnus-select-method)
6894 (pop-to-buffer gnus-group-buffer)
6895 (if (eq method 'nndigest)
6897 (gnus-group-jump-to-group group)
6898 (gnus-group-next-unread-group 1))
6899 (if (gnus-buffer-exists-p quit-buffer)
6901 (switch-to-buffer quit-buffer)
6902 (gnus-set-global-variables)
6903 (gnus-configure-windows 'summary))))))
6905 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6906 (defun gnus-summary-exit-no-update (&optional no-questions)
6907 "Quit reading current newsgroup without updating read article info."
6909 (let* ((group gnus-newsgroup-name)
6910 (quit-buffer (cdr (assoc 'quit-buffer
6911 (gnus-find-method-for-group group)))))
6912 (if (or no-questions
6914 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
6916 (gnus-close-group group)
6917 (gnus-summary-clear-local-variables)
6918 (set-buffer gnus-group-buffer)
6919 (gnus-summary-clear-local-variables)
6920 ;; Return to group selection mode.
6921 (gnus-configure-windows 'group)
6922 (if (get-buffer gnus-summary-buffer)
6923 (kill-buffer gnus-summary-buffer))
6924 (if (get-buffer gnus-article-buffer)
6925 (bury-buffer gnus-article-buffer))
6926 (if (equal (gnus-group-group-name) group)
6927 (gnus-group-next-unread-group 1))
6928 (if (gnus-buffer-exists-p quit-buffer)
6930 (switch-to-buffer quit-buffer)
6931 (gnus-configure-windows 'summary)))))))
6933 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6934 (defun gnus-summary-fetch-faq (group)
6935 "Fetch the FAQ for the current group."
6936 (interactive (list gnus-newsgroup-name))
6937 (gnus-configure-windows 'summary-faq)
6938 (find-file (concat gnus-group-faq-directory group)))
6940 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6941 (defun gnus-summary-describe-group (force)
6942 "Describe the current newsgroup."
6944 (gnus-group-describe-group force gnus-newsgroup-name))
6946 (defun gnus-summary-describe-briefly ()
6947 "Describe summary mode commands briefly."
6950 (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")))
6952 ;; Walking around group mode buffer from summary mode.
6954 (defun gnus-summary-next-group (&optional no-article group backward)
6955 "Exit current newsgroup and then select next unread newsgroup.
6956 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
6957 If BACKWARD, go to previous group instead."
6959 (gnus-set-global-variables)
6960 (let ((ingroup gnus-newsgroup-name)
6961 (sumbuf (current-buffer))
6963 (gnus-summary-exit t) ;Update all information.
6965 (or (and (numberp (setq num (car (gnus-gethash
6966 group gnus-newsrc-hashtb))))
6970 (gnus-group-jump-to-group group)
6972 (gnus-group-jump-to-group ingroup))
6973 (gnus-summary-search-group backward)
6974 (let ((group (or group (gnus-summary-search-group backward)))
6975 (buf gnus-summary-buffer))
6977 (gnus-summary-exit-no-update t)
6978 (gnus-message 5 "Selecting %s..." group)
6979 ;; We are now in group mode buffer.
6980 ;; Make sure group mode buffer point is on GROUP.
6981 (gnus-group-jump-to-group group)
6982 (if (not (eq gnus-auto-select-next 'quietly))
6984 (gnus-summary-read-group group nil no-article buf)
6985 (and (string= gnus-newsgroup-name ingroup)
6986 (bufferp sumbuf) (buffer-name sumbuf)
6988 (set-buffer (setq gnus-summary-buffer sumbuf))
6989 (gnus-summary-exit-no-update t))))
6990 (gnus-summary-read-group group nil no-article buf)
6991 (while (and (string= gnus-newsgroup-name ingroup)
6992 (bufferp sumbuf) (buffer-name sumbuf))
6993 (set-buffer gnus-group-buffer)
6994 (gnus-summary-read-group
6995 (gnus-group-group-name) nil no-article buf)))))))
6997 (defun gnus-summary-prev-group (no-article)
6998 "Exit current newsgroup and then select previous unread newsgroup.
6999 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7001 (gnus-summary-next-group no-article nil t))
7003 ;; Walking around summary lines.
7005 (defun gnus-summary-first-subject (unread)
7006 "Go to the first unread subject.
7007 If UNREAD is non-nil, go to the first unread article.
7008 Returns nil if there are no unread articles."
7010 (let ((begin (point)))
7011 (goto-char (point-min))
7014 (while (and (not (eq (nth 1 (get-text-property (point) 'gnus))
7016 (zerop (forward-line 1))))
7020 ;; If there is no unread articles, stay where you are.
7022 (gnus-message 3 "No more unread articles")
7024 (gnus-summary-position-cursor)))))
7026 (defun gnus-summary-next-subject (n &optional unread dont-display)
7027 "Go to next N'th summary line.
7028 If N is negative, go to the previous N'th subject line.
7029 If UNREAD is non-nil, only unread articles are selected.
7030 The difference between N and the actual number of steps taken is
7033 (let ((backward (< n 0))
7036 (gnus-summary-search-forward unread nil backward))
7038 (if (/= 0 n) (gnus-message 7 "No more%s articles"
7039 (if unread " unread" "")))
7042 (gnus-summary-recenter)
7043 (gnus-summary-position-cursor)))
7046 (defun gnus-summary-next-unread-subject (n)
7047 "Go to next N'th unread summary line."
7049 (gnus-summary-next-subject n t))
7051 (defun gnus-summary-prev-subject (n &optional unread)
7052 "Go to previous N'th summary line.
7053 If optional argument UNREAD is non-nil, only unread article is selected."
7055 (gnus-summary-next-subject (- n) unread))
7057 (defun gnus-summary-prev-unread-subject (n)
7058 "Go to previous N'th unread summary line."
7060 (gnus-summary-next-subject (- n) t))
7062 (defun gnus-summary-goto-subject (article)
7063 "Go the subject line of ARTICLE."
7067 (completing-read "Article number: "
7071 (int-to-string (header-number headers))))
7072 gnus-newsgroup-headers)
7073 nil 'require-match))))
7074 (or article (error "No article number"))
7076 (goto-char (point-min))
7077 (while (and (not (eq (car (get-text-property (point) 'gnus)) article))
7078 (zerop (forward-line 1))))
7079 ;; Skip dummy articles.
7080 (if (eq (gnus-summary-article-mark) ?Z)
7087 (gnus-summary-position-cursor))))
7089 ;; Walking around summary lines with displaying articles.
7091 (defun gnus-summary-expand-window ()
7092 "Expand summary window to show headers full window."
7094 (gnus-set-global-variables)
7095 (gnus-configure-windows 'summary))
7097 (defun gnus-summary-display-article (article &optional all-header)
7098 "Display ARTICLE in article buffer."
7099 (gnus-set-global-variables)
7102 (gnus-article-prepare article all-header)
7103 (if (eq (gnus-summary-article-mark) ?Z)
7106 (gnus-summary-position-cursor)))
7107 (run-hooks 'gnus-select-article-hook)
7108 (gnus-summary-recenter)
7109 ; (set-window-point (get-buffer-window (current-buffer)) (point-max))
7111 (gnus-summary-goto-subject article)
7112 ;; Successfully display article.
7113 (gnus-summary-update-line)
7114 (let ((bookmark (cdr (assq article gnus-newsgroup-bookmarks))))
7116 (get-buffer-window gnus-article-buffer)
7118 (set-buffer gnus-article-buffer)
7119 (goto-char (point-min))
7121 (gnus-message 6 "Moved to bookmark")
7122 (search-forward "\n\n" nil t)
7123 (forward-line bookmark)
7129 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7130 "Select the current article.
7131 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7132 non-nil, the article will be re-fetched even if it already present in
7133 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7135 (and (not pseudo) (gnus-summary-pseudo-article)
7136 (error "This is a pseudo-article."))
7137 (let ((article (or article (gnus-summary-article-number)))
7138 (all-headers (not (not all-headers))) ;Must be T or NIL.
7142 (set-buffer gnus-summary-buffer)
7143 (if (or (null gnus-current-article)
7144 (null gnus-article-current)
7145 (not (eq article (cdr gnus-article-current)))
7146 (not (equal (car gnus-article-current) gnus-newsgroup-name))
7148 ;; The requested article is different from the current article.
7150 (gnus-summary-display-article article all-headers)
7151 (gnus-configure-windows 'article)
7153 (if all-headers (gnus-article-show-all-headers))
7154 (gnus-configure-windows 'article)
7158 (let ((bookmark (cdr (assq article gnus-newsgroup-bookmarks))))
7160 (get-buffer-window gnus-article-buffer)
7162 (set-buffer gnus-article-buffer)
7163 (goto-char (point-min))
7165 (gnus-message 6 "Moved to bookmark")
7166 (search-forward "\n\n" nil t)
7167 (forward-line bookmark)
7170 (point-min))))))))))
7172 (defun gnus-summary-set-current-mark (&optional current-mark)
7173 "Obsolete function."
7176 (defun gnus-summary-next-article (unread &optional subject backward)
7177 "Select the next article.
7178 If UNREAD, only unread articles are selected.
7179 If SUBJECT, only articles with SUBJECT are selected.
7180 If BACKWARD, the previous article is selected instead of the next."
7182 (let ((opoint (point))
7183 (method (car (gnus-find-method-for-group gnus-newsgroup-name)))
7186 ;; Is there such an article?
7187 ((gnus-summary-display-article
7188 (gnus-summary-search-forward unread subject backward))
7189 (gnus-summary-position-cursor))
7190 ;; If not, we try the first unread, if that is wanted.
7192 gnus-auto-select-same
7193 (gnus-summary-first-unread-article))
7194 (gnus-message 6 "Wrapped"))
7195 ;; Try to get next/previous article not displayed in this group.
7196 ((and gnus-auto-extend-newsgroup
7197 (not unread) (not subject)
7198 (setq header (gnus-more-header-forward backward)))
7199 (gnus-extend-newsgroup header backward)
7200 (let ((buffer-read-only nil))
7201 (goto-char (if backward (point-min) (point-max)))
7202 (gnus-summary-prepare-threads (list header) 0))
7203 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
7204 gnus-newsgroup-end)))
7205 ;; Go to next/previous group.
7207 (or (eq method 'nndigest)
7208 (gnus-summary-jump-to-group gnus-newsgroup-name))
7209 (let ((cmd (aref (this-command-keys) 0))
7211 (if (eq gnus-keep-same-level 'best)
7212 (gnus-summary-best-group gnus-newsgroup-name)
7213 (gnus-summary-search-group backward gnus-keep-same-level))))
7214 ;; Keep just the event type of CMD.
7215 (and (listp cmd) (setq cmd (car cmd)))
7216 ;; Select next unread newsgroup automagically.
7218 ((not gnus-auto-select-next)
7219 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7220 ((eq gnus-auto-select-next 'quietly)
7222 (if (eq method 'nndigest)
7224 (gnus-message 7 "No more%s articles (%s)..."
7225 (if unread " unread" "")
7226 (if group (concat "selecting " group)
7228 (gnus-summary-next-group nil group backward)))
7230 (let ((keystrokes '(?\C-n ?\C-p))
7232 (while (or (null key) (memq key keystrokes))
7234 7 "No more%s articles%s" (if unread " unread" "")
7235 (if (and group (not (eq method 'nndigest)))
7236 (format " (Type %s for %s [%s])"
7237 (single-key-description cmd) group
7238 (car (gnus-gethash group gnus-newsrc-hashtb)))
7239 (format " (Type %s to exit %s)"
7240 (single-key-description cmd)
7241 gnus-newsgroup-name)))
7242 ;; Confirm auto selection.
7243 (let* ((event (read-event)))
7244 (setq key (if (listp event) (car event) event))
7245 (if (member key keystrokes)
7246 (let ((obuf (current-buffer)))
7247 (switch-to-buffer gnus-group-buffer)
7248 (gnus-group-jump-to-group group)
7249 (execute-kbd-macro (char-to-string key))
7250 (setq group (gnus-group-group-name))
7251 (switch-to-buffer obuf)))))
7253 (if (or (not group) (eq method 'nndigest))
7255 (gnus-summary-next-group nil group backward))
7256 (setq unread-command-events (list key)))))))))))
7258 (defun gnus-summary-next-unread-article ()
7259 "Select unread article after current one."
7261 (gnus-summary-next-article t (and gnus-auto-select-same
7262 (gnus-summary-subject-string))))
7264 (defun gnus-summary-prev-article (unread &optional subject)
7265 "Select the article after the current one.
7266 If UNREAD is non-nil, only unread articles are selected."
7268 (gnus-summary-next-article unread subject t))
7270 (defun gnus-summary-prev-unread-article ()
7271 "Select unred article before current one."
7273 (gnus-summary-prev-article t (and gnus-auto-select-same
7274 (gnus-summary-subject-string))))
7276 (defun gnus-summary-next-page (lines &optional circular)
7277 "Show next page of selected article.
7278 If end of article, select next article.
7279 Argument LINES specifies lines to be scrolled up.
7280 If CIRCULAR is non-nil, go to the start of the article instead of
7281 instead of selecting the next article when reaching the end of the
7284 (setq gnus-summary-buffer (current-buffer))
7285 (gnus-set-global-variables)
7286 (let ((article (gnus-summary-article-number))
7288 (if (or (null gnus-current-article)
7289 (null gnus-article-current)
7290 (/= article (cdr gnus-article-current))
7291 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7292 ;; Selected subject is different from current article's.
7293 (gnus-summary-display-article article)
7294 (gnus-configure-windows 'article)
7295 (gnus-eval-in-buffer-window
7297 (setq endp (gnus-article-next-page lines)))
7300 (gnus-summary-beginning-of-article))
7302 (gnus-message 3 "End of message"))
7304 (gnus-summary-next-unread-article)))))))
7306 (defun gnus-summary-prev-page (lines)
7307 "Show previous page of selected article.
7308 Argument LINES specifies lines to be scrolled down."
7310 (let ((article (gnus-summary-article-number)))
7311 (if (or (null gnus-current-article)
7312 (null gnus-article-current)
7313 (/= article (cdr gnus-article-current))
7314 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7315 ;; Selected subject is different from current article's.
7316 (gnus-summary-display-article article)
7317 (gnus-configure-windows 'article)
7318 (gnus-eval-in-buffer-window gnus-article-buffer
7319 (gnus-article-prev-page lines))))
7320 (gnus-summary-position-cursor))
7322 (defun gnus-summary-scroll-up (lines)
7323 "Scroll up (or down) one line current article.
7324 Argument LINES specifies lines to be scrolled up (or down if negative)."
7326 (or (gnus-summary-select-article nil nil 'pseudo)
7327 (gnus-eval-in-buffer-window
7330 (if (gnus-article-next-page lines)
7331 (gnus-message 3 "End of message")))
7333 (gnus-article-prev-page (- lines))))))
7334 (gnus-summary-position-cursor))
7336 (defun gnus-summary-next-same-subject ()
7337 "Select next article which has the same subject as current one."
7339 (gnus-summary-next-article nil (gnus-summary-subject-string)))
7341 (defun gnus-summary-prev-same-subject ()
7342 "Select previous article which has the same subject as current one."
7344 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
7346 (defun gnus-summary-next-unread-same-subject ()
7347 "Select next unread article which has the same subject as current one."
7349 (gnus-summary-next-article t (gnus-summary-subject-string)))
7351 (defun gnus-summary-prev-unread-same-subject ()
7352 "Select previous unread article which has the same subject as current one."
7354 (gnus-summary-prev-article t (gnus-summary-subject-string)))
7356 (defun gnus-summary-first-unread-article ()
7357 "Select the first unread article.
7358 Return nil if there are no unread articles."
7361 (if (gnus-summary-first-subject t)
7362 (gnus-summary-display-article (gnus-summary-article-number)))
7363 (gnus-summary-position-cursor)))
7365 (defun gnus-summary-best-unread-article ()
7366 "Select the unread article with the highest score."
7368 (gnus-set-global-variables)
7369 (let ((scored gnus-newsgroup-scored)
7373 (or (> best (cdr (car scored)))
7374 (and (memq (setq art (car (car scored))) gnus-newsgroup-unreads)
7375 (not (memq art gnus-newsgroup-marked))
7376 (not (memq art gnus-newsgroup-dormant))
7377 (if (= best (cdr (car scored)))
7378 (setq article (min art article))
7380 (setq best (cdr (car scored))))))
7381 (setq scored (cdr scored)))
7383 (gnus-summary-goto-article article)
7384 (gnus-summary-first-unread-article))
7385 (gnus-summary-position-cursor)))
7387 (defun gnus-summary-goto-article (article &optional all-headers)
7388 "Fetch ARTICLE and display it if it exists.
7389 If ALL-HEADERS is non-nil, no header lines are hidden."
7395 (mapcar (lambda (headers) (list (int-to-string (header-number headers))))
7396 gnus-newsgroup-headers)
7397 nil 'require-match))))
7399 (and (gnus-summary-goto-subject article)
7400 (gnus-summary-display-article article all-headers))
7401 (gnus-summary-position-cursor)))
7403 (defun gnus-summary-goto-last-article ()
7404 "Go to the last article."
7407 (and gnus-last-article
7408 (gnus-summary-goto-article gnus-last-article))
7409 (gnus-summary-position-cursor)))
7411 (defun gnus-summary-pop-article (number)
7412 "Pop one article off the history and go to the previous.
7413 NUMBER articles will be popped off."
7416 (setq gnus-newsgroup-history
7417 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7419 (gnus-summary-goto-article (car to))
7420 (error "Article history empty")))
7421 (gnus-summary-position-cursor))
7423 ;; Summary article oriented commands
7425 (defun gnus-summary-refer-parent-article (n)
7426 "Refer parent article N times.
7427 The difference between N and the number of articles fetched is returned."
7429 (gnus-set-global-variables)
7433 (let ((ref (header-references (gnus-get-header-by-number
7434 (gnus-summary-article-number)))))
7435 (if (and ref (not (equal ref ""))
7436 (string-match "<[^<>]*>[ \t]*$" ref))
7437 (gnus-summary-refer-article
7438 (substring ref (match-beginning 0) (match-end 0))))))
7441 (gnus-message 1 "No references in article or expired article."))
7442 (gnus-summary-position-cursor)
7445 (defun gnus-summary-refer-article (message-id)
7446 "Refer article specified by MESSAGE-ID.
7447 NOTE: This command only works with newsgroup that use NNTP."
7448 (interactive "sMessage-ID: ")
7449 (if (or (not (stringp message-id))
7450 (zerop (length message-id)))
7452 ;; Construct the correct Message-ID if necessary.
7453 ;; Suggested by tale@pawl.rpi.edu.
7454 (or (string-match "^<" message-id)
7455 (setq message-id (concat "<" message-id)))
7456 (or (string-match ">$" message-id)
7457 (setq message-id (concat message-id ">")))
7458 (let ((header (car (gnus-gethash (downcase message-id)
7459 gnus-newsgroup-dependencies))))
7461 (or (gnus-summary-goto-article (header-number header))
7462 ;; The header has been read, but the article had been
7463 ;; expunged, so we insert it again.
7465 (gnus-summary-insert-line
7466 nil header 0 nil gnus-read-mark nil nil
7467 (header-subject header))
7469 (header-number header)))
7470 (let ((gnus-override-method gnus-refer-article-method)
7471 (gnus-ancient-mark gnus-read-mark)
7473 (and gnus-refer-article-method
7474 (or (gnus-server-opened gnus-refer-article-method)
7475 (gnus-open-server gnus-refer-article-method)))
7476 (if (gnus-article-prepare
7477 message-id nil (gnus-read-header message-id))
7479 (setq number (header-number gnus-current-headers))
7480 (gnus-rebuild-thread message-id)
7481 (gnus-summary-goto-subject number)
7483 (gnus-message 1 "No such references")
7486 (defun gnus-summary-enter-digest-group ()
7487 "Enter a digest group based on the current article."
7489 (gnus-set-global-variables)
7490 (gnus-summary-select-article)
7491 ;; We do not want a narrowed article.
7492 (gnus-summary-stop-page-breaking)
7493 (let ((name (format "%s/%d"
7494 (gnus-group-prefixed-name
7495 gnus-newsgroup-name (list 'nndigest ""))
7496 gnus-current-article))
7497 (buf (current-buffer)))
7498 (set-buffer gnus-group-buffer)
7501 (list t nil (list name gnus-level-default-subscribed nil nil
7502 (list 'nndigest gnus-article-buffer
7503 (cons 'quit-buffer buf))))
7506 (gnus-group-read-group t nil name)
7509 (if (not (equal major-mode 'gnus-group-mode))
7511 (switch-to-buffer buf)
7512 (gnus-set-global-variables)
7513 (gnus-configure-windows 'summary)
7514 (gnus-message 3 "Article not a digest?"))))
7516 (defun gnus-summary-isearch-article ()
7517 "Do incremental search forward on current article."
7519 (gnus-set-global-variables)
7520 (gnus-summary-select-article)
7521 (gnus-eval-in-buffer-window gnus-article-buffer
7524 (defun gnus-summary-search-article-forward (regexp)
7525 "Search for an article containing REGEXP forward.
7526 gnus-select-article-hook is not called during the search."
7529 (concat "Search forward (regexp): "
7530 (if gnus-last-search-regexp
7531 (concat "(default " gnus-last-search-regexp ") "))))))
7532 (gnus-set-global-variables)
7533 (if (string-equal regexp "")
7534 (setq regexp (or gnus-last-search-regexp ""))
7535 (setq gnus-last-search-regexp regexp))
7536 (if (gnus-summary-search-article regexp nil)
7537 (gnus-eval-in-buffer-window
7540 (error "Search failed: \"%s\"" regexp)))
7542 (defun gnus-summary-search-article-backward (regexp)
7543 "Search for an article containing REGEXP backward.
7544 gnus-select-article-hook is not called during the search."
7547 (concat "Search backward (regexp): "
7548 (if gnus-last-search-regexp
7549 (concat "(default " gnus-last-search-regexp ") "))))))
7550 (gnus-set-global-variables)
7551 (if (string-equal regexp "")
7552 (setq regexp (or gnus-last-search-regexp ""))
7553 (setq gnus-last-search-regexp regexp))
7554 (if (gnus-summary-search-article regexp t)
7555 (gnus-eval-in-buffer-window
7558 (error "Search failed: \"%s\"" regexp)))
7560 (defun gnus-summary-search-article (regexp &optional backward)
7561 "Search for an article containing REGEXP.
7562 Optional argument BACKWARD means do search for backward.
7563 gnus-select-article-hook is not called during the search."
7564 (let ((gnus-select-article-hook nil) ;Disable hook.
7565 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7568 (function re-search-backward) (function re-search-forward)))
7571 ;; Hidden thread subtrees must be searched for ,too.
7572 (gnus-summary-show-all-threads)
7573 (if (eobp) (forward-line -1))
7574 ;; First of all, search current article.
7575 ;; We don't want to read article again from NNTP server nor reset
7577 (gnus-summary-select-article)
7578 (gnus-message 9 "Searching article: %d..." gnus-current-article)
7579 (setq last gnus-current-article)
7580 (gnus-eval-in-buffer-window gnus-article-buffer
7583 ;; Begin search from current point.
7584 (setq found (funcall re-search regexp nil t))))
7585 ;; Then search next articles.
7586 (while (and (not found)
7587 (gnus-summary-display-article
7588 (gnus-summary-search-subject backward nil nil)))
7589 (gnus-message 9 "Searching article: %d..." gnus-current-article)
7590 (gnus-eval-in-buffer-window gnus-article-buffer
7593 (goto-char (if backward (point-max) (point-min)))
7594 (setq found (funcall re-search regexp nil t)))))
7596 ;; Adjust article pointer.
7597 (or (eq last gnus-current-article)
7598 (setq gnus-last-article last))
7599 ;; Return T if found such article.
7602 (defun gnus-summary-execute-command (header regexp command &optional backward)
7603 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7604 If HEADER is an empty string (or nil), the match is done on the entire
7605 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7607 (list (let ((completion-ignore-case t))
7610 (mapcar (lambda (string) (list string))
7611 '("Number" "Subject" "From" "Lines" "Date"
7612 "Message-ID" "Xref" "References"))
7613 nil 'require-match))
7614 (read-string "Regexp: ")
7615 (read-key-sequence "Command: ")
7616 current-prefix-arg))
7617 (gnus-set-global-variables)
7618 ;; Hidden thread subtrees must be searched as well.
7619 (gnus-summary-show-all-threads)
7620 ;; We don't want to change current point nor window configuration.
7622 (save-window-excursion
7623 (gnus-message 6 "Executing %s..." (key-description command))
7624 ;; We'd like to execute COMMAND interactively so as to give arguments.
7625 (gnus-execute header regexp
7627 (call-interactively '(, (key-binding command)))))
7629 (gnus-message 6 "Executing %s... done" (key-description command)))))
7631 (defun gnus-summary-beginning-of-article ()
7632 "Scroll the article back to the beginning."
7634 (gnus-set-global-variables)
7635 (gnus-summary-select-article)
7636 (gnus-eval-in-buffer-window
7639 (goto-char (point-min))
7640 (and gnus-break-pages (gnus-narrow-to-page))))
7642 (defun gnus-summary-end-of-article ()
7643 "Scroll to the end of the article."
7645 (gnus-set-global-variables)
7646 (gnus-summary-select-article)
7647 (gnus-eval-in-buffer-window
7650 (goto-char (point-max))
7651 (and gnus-break-pages (gnus-narrow-to-page))))
7653 (defun gnus-summary-show-article ()
7654 "Force re-fetching of the current article."
7656 (gnus-set-global-variables)
7657 (gnus-summary-select-article gnus-have-all-headers t))
7659 (defun gnus-summary-toggle-header (arg)
7660 "Show the headers if they are hidden, or hide them if they are shown.
7661 If ARG is a positive number, show the entire header.
7662 If ARG is a negative number, hide the unwanted header lines."
7664 (gnus-set-global-variables)
7666 (set-buffer gnus-article-buffer)
7667 (let ((buffer-read-only nil))
7669 (if (> arg 0) (remove-text-properties (point-min) (point-max)
7670 gnus-hidden-properties)
7671 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
7672 (if (text-property-any (point-min) (point-max) 'invisible t)
7673 (remove-text-properties (point-min) (point-max)
7674 gnus-hidden-properties)
7675 (let ((gnus-have-all-headers nil))
7676 (run-hooks 'gnus-article-display-hook))))
7677 (set-window-point (get-buffer-window (current-buffer)) (point-min)))))
7679 (defun gnus-summary-show-all-headers ()
7680 "Make all header lines visible."
7682 (gnus-set-global-variables)
7683 (gnus-article-show-all-headers))
7685 (defun gnus-summary-toggle-mime (arg)
7686 "Toggle MIME processing.
7687 If ARG is a positive number, turn MIME processing on."
7689 (gnus-set-global-variables)
7690 (setq gnus-show-mime
7691 (if (null arg) (not gnus-show-mime)
7692 (> (prefix-numeric-value arg) 0)))
7693 (gnus-summary-select-article t 'force))
7695 (defun gnus-summary-caesar-message (rotnum)
7696 "Caesar rotates all letters of current message by 13/47 places.
7697 With prefix arg, specifies the number of places to rotate each letter forward.
7698 Caesar rotates Japanese letters by 47 places in any case."
7700 (gnus-set-global-variables)
7701 (gnus-summary-select-article)
7702 (let ((mail-header-separator "")) ; !!! Is this necessary?
7703 (gnus-overload-functions)
7704 (gnus-eval-in-buffer-window
7708 ;; We don't want to jump to the beginning of the message.
7709 ;; `save-excursion' does not do its job.
7710 (move-to-window-line 0)
7711 (let ((last (point)))
7712 (news-caesar-buffer-body rotnum)
7716 (defun gnus-summary-stop-page-breaking ()
7717 "Stop page breaking in the current article."
7719 (gnus-set-global-variables)
7720 (gnus-summary-select-article)
7721 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
7723 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
7725 (defun gnus-summary-move-article (n &optional to-newsgroup select-method)
7726 "Move the current article to a different newsgroup.
7727 If N is a positive number, move the N next articles.
7728 If N is a negative number, move the N previous articles.
7729 If N is nil and any articles have been marked with the process mark,
7730 move those articles instead.
7731 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7732 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
7733 re-spool using this method.
7734 For this function to work, both the current newsgroup and the
7735 newsgroup that you want to move to have to support the `request-move'
7736 and `request-accept' functions. (Ie. mail newsgroups at present.)"
7738 (gnus-set-global-variables)
7739 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
7740 (error "The current newsgroup does not support article moving"))
7741 (let ((articles (gnus-summary-work-articles n))
7742 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7744 (if (and (not to-newsgroup) (not select-method))
7747 (format "Where do you want to move %s? %s"
7748 (if (> (length articles) 1)
7749 (format "these %d articles" (length articles))
7751 (if gnus-current-move-group
7752 (format "(%s default) " gnus-current-move-group)
7754 gnus-active-hashtb nil nil prefix)))
7757 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
7758 (setq to-newsgroup (or gnus-current-move-group "")))
7759 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
7760 (gnus-activate-newsgroup to-newsgroup)
7761 (error "No such group: %s" to-newsgroup))
7762 (setq gnus-current-move-group to-newsgroup)))
7763 (or (gnus-check-backend-function 'request-accept-article
7764 (or select-method to-newsgroup))
7765 (error "%s does not support article moving" to-newsgroup))
7766 (gnus-message 6 "Moving to %s: %s..."
7767 (or select-method to-newsgroup) articles)
7770 (gnus-request-move-article
7771 (car articles) ; Article to move
7772 gnus-newsgroup-name ; From newsgrouo
7773 (nth 1 (gnus-find-method-for-group
7774 gnus-newsgroup-name)) ; Server
7775 (list 'gnus-request-accept-article
7777 (list 'quote select-method)
7779 (not (cdr articles))) ; Accept form
7780 (not (cdr articles)))) ; Only save nov last time
7781 (let* ((buffer-read-only nil)
7784 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7786 (gnus-group-prefixed-name
7788 (if select-method (list select-method "")
7789 (gnus-find-method-for-group to-newsgroup)))
7790 gnus-newsrc-hashtb)))
7791 (info (nth 2 entry))
7792 (article (car articles))
7793 (marked (nth 3 info)))
7794 (gnus-summary-goto-subject article)
7796 (delete-region (point)
7797 (progn (forward-line 1) (point)))
7798 (if (not (memq article gnus-newsgroup-unreads))
7799 (setcar (cdr (cdr info))
7800 (gnus-add-to-range (nth 2 info)
7801 (list (cdr art-group)))))
7802 ;; Copy any marks over to the new group.
7803 (let ((marks '((tick . gnus-newsgroup-marked)
7804 (dormant . gnus-newsgroup-dormant)
7805 (expire . gnus-newsgroup-expirable)
7806 (bookmark . gnus-newsgroup-bookmarks)
7807 ; (score . gnus-newsgroup-scored)
7808 (reply . gnus-newsgroup-replied)))
7809 (to-article (cdr art-group)))
7811 (if (memq article (symbol-value (cdr (car marks))))
7812 (gnus-add-marked-articles
7813 (car info) (car (car marks)) (list to-article) info))
7814 (setq marks (cdr marks))))
7815 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7816 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7817 (setq gnus-newsgroup-dormant
7818 (delq article gnus-newsgroup-dormant)))
7819 (gnus-message 1 "Couldn't move article %s" (car articles)))
7820 (gnus-summary-remove-process-mark (car articles))
7821 (setq articles (cdr articles)))))
7823 (defun gnus-summary-respool-article (n &optional respool-method)
7824 "Respool the current article.
7825 The article will be squeezed through the mail spooling process again,
7826 which means that it will be put in some mail newsgroup or other
7827 depending on `nnmail-split-methods'.
7828 If N is a positive number, respool the N next articles.
7829 If N is a negative number, respool the N previous articles.
7830 If N is nil and any articles have been marked with the process mark,
7831 respool those articles instead.
7833 Respooling can be done both from mail groups and \"real\" newsgroups.
7834 In the former case, the articles in question will be moved from the
7835 current group into whatever groups they are destined to. In the
7836 latter case, they will be copied into the relevant groups."
7838 (gnus-set-global-variables)
7839 (let ((respool-methods (gnus-methods-using 'respool))
7841 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
7843 (setq respool-method
7845 "What method do you want to use when respooling? "
7846 respool-methods nil t methname)))
7847 (or (string= respool-method "")
7848 (if (assoc (symbol-name
7849 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7851 (gnus-summary-move-article n nil (intern respool-method))
7852 (gnus-summary-copy-article n nil (intern respool-method))))))
7854 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
7855 (defun gnus-summary-copy-article (n &optional to-newsgroup select-method)
7856 "Move the current article to a different newsgroup.
7857 If N is a positive number, move the N next articles.
7858 If N is a negative number, move the N previous articles.
7859 If N is nil and any articles have been marked with the process mark,
7860 move those articles instead.
7861 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7862 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
7863 re-spool using this method.
7864 For this function to work, the newsgroup that you want to move to have
7865 to support the `request-move' and `request-accept'
7866 functions. (Ie. mail newsgroups at present.)"
7868 (gnus-set-global-variables)
7869 (let ((articles (gnus-summary-work-articles n))
7870 (copy-buf (get-buffer-create "*copy work*"))
7871 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7873 (buffer-disable-undo copy-buf)
7874 (if (and (not to-newsgroup) (not select-method))
7877 (format "Where do you want to copy %s? %s"
7878 (if (> (length articles) 1)
7879 (format "these %d articles" (length articles))
7881 (if gnus-current-move-group
7882 (format "(%s default) " gnus-current-move-group)
7884 gnus-active-hashtb nil nil prefix)))
7887 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
7888 (setq to-newsgroup (or gnus-current-move-group "")))
7889 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
7890 (gnus-activate-newsgroup to-newsgroup)
7891 (error "No such group: %s" to-newsgroup))
7892 (setq gnus-current-move-group to-newsgroup)))
7893 (or (gnus-check-backend-function 'request-accept-article
7894 (or select-method to-newsgroup))
7895 (error "%s does not support article copying" to-newsgroup))
7896 (gnus-message 6 "Copying to %s: %s..."
7897 (or select-method to-newsgroup) articles)
7901 (set-buffer copy-buf)
7902 (gnus-request-article-this-buffer
7903 (car articles) gnus-newsgroup-name)
7904 (gnus-request-accept-article
7905 (if select-method (quote select-method) to-newsgroup)
7906 (not (cdr articles)))))
7909 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7911 (gnus-group-prefixed-name
7913 (if select-method (list select-method "")
7914 (gnus-find-method-for-group to-newsgroup)))
7915 gnus-newsrc-hashtb)))
7916 (info (nth 2 entry))
7917 (article (car articles))
7918 (marked (nth 3 info)))
7919 (if (not (memq article gnus-newsgroup-unreads))
7920 (setcar (cdr (cdr info))
7921 (gnus-add-to-range (nth 2 info)
7922 (list (cdr art-group)))))
7923 ;; Copy any marks over to the new group.
7924 (let ((marks '((tick . gnus-newsgroup-marked)
7925 (dormant . gnus-newsgroup-dormant)
7926 (expire . gnus-newsgroup-expirable)
7927 (bookmark . gnus-newsgroup-bookmarks)
7928 ; (score . gnus-newsgroup-scored)
7929 (reply . gnus-newsgroup-replied)))
7930 (to-article (cdr art-group)))
7932 (if (memq article (symbol-value (cdr (car marks))))
7933 (gnus-add-marked-articles
7934 (car info) (car (car marks)) (list to-article) info))
7935 (setq marks (cdr marks)))))
7936 (gnus-message 1 "Couldn't copy article %s" (car articles)))
7937 (gnus-summary-remove-process-mark (car articles))
7938 (setq articles (cdr articles)))
7939 (kill-buffer copy-buf)))
7941 (defun gnus-summary-expire-articles ()
7942 "Expire all articles that are marked as expirable in the current group."
7944 (if (and gnus-newsgroup-expirable
7945 (gnus-check-backend-function
7946 'request-expire-articles gnus-newsgroup-name))
7947 (let ((expirable gnus-newsgroup-expirable))
7948 ;; The list of articles that weren't expired is returned.
7949 (setq gnus-newsgroup-expirable
7950 (gnus-request-expire-articles gnus-newsgroup-expirable
7951 gnus-newsgroup-name))
7952 ;; We go through the old list of expirable, and mark all
7953 ;; really expired articles as non-existant.
7955 (or (memq (car expirable) gnus-newsgroup-expirable)
7956 (gnus-summary-mark-as-read (car expirable) "%"))
7957 (setq expirable (cdr expirable))))))
7959 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7960 (defun gnus-summary-delete-article (n)
7961 "Delete the N next (mail) articles.
7962 This command actually deletes articles. This is not a marking
7963 command. The article will disappear forever from you life, never to
7965 If N is negative, delete backwards.
7966 If N is nil and articles have been marked with the process mark,
7967 delete these instead."
7969 (or (gnus-check-backend-function 'request-expire-articles
7970 gnus-newsgroup-name)
7971 (error "The current newsgroup does not support article deletion."))
7972 ;; Compute the list of articles to delete.
7973 (let ((articles (gnus-summary-work-articles n)))
7974 (if (and gnus-novice-user
7976 (format "Do you really want to delete %s forever? "
7977 (if (> (length articles) 1) "these articles"
7980 ;; Delete the articles.
7981 (setq gnus-newsgroup-expirable
7982 (gnus-request-expire-articles
7983 articles gnus-newsgroup-name 'force))
7985 (gnus-summary-remove-process-mark (car articles))
7986 ;; The backend might not have been able to delete the article
7988 (or (memq (car articles) gnus-newsgroup-expirable)
7989 (gnus-summary-mark-as-read (car articles) gnus-canceled-mark))
7990 (setq articles (cdr articles)))))
7991 (gnus-summary-position-cursor))
7993 (defun gnus-summary-edit-article ()
7994 "Enter into a buffer and edit the current article.
7995 This will have permanent effect only in mail groups."
7997 (or (gnus-check-backend-function
7998 'request-replace-article gnus-newsgroup-name)
7999 (error "The current newsgroup does not support article editing."))
8000 (gnus-summary-select-article t)
8002 (gnus-message 6 "C-c C-c to end edits")
8003 (setq buffer-read-only nil)
8005 (use-local-map (copy-keymap (current-local-map)))
8006 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
8007 (goto-char (point-min))
8008 (search-forward "\n\n" nil t))
8010 (defun gnus-summary-edit-article-done ()
8011 "Make edits to the current article permanent."
8013 (if (not (gnus-request-replace-article
8014 (cdr gnus-article-current) (car gnus-article-current)
8016 (error "Couldn't replace article.")
8018 (use-local-map gnus-article-mode-map)
8019 (setq buffer-read-only t)
8020 (pop-to-buffer gnus-summary-buffer)))
8022 (defun gnus-summary-fancy-query ()
8023 "Query where the fancy respool algorithm would put this article."
8025 (gnus-summary-select-article)
8027 (set-buffer gnus-article-buffer)
8029 (goto-char (point-min))
8030 (search-forward "\n\n")
8031 (narrow-to-region (point-min) (point))
8032 (pp-eval-expression (list 'quote (nnmail-split-fancy))))))
8034 ;; Summary score commands.
8036 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
8038 (defun gnus-summary-raise-score (n)
8039 "Raise the score of the current article by N."
8041 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
8043 (defun gnus-summary-lower-score (n)
8044 "Lower the score of the current article by N."
8046 (gnus-summary-raise-score (- n)))
8048 (defun gnus-summary-set-score (n)
8049 "Set the score of the current article to N."
8051 ;; Skip dummy header line.
8053 (if (eq (gnus-summary-article-mark) ?Z)
8055 (let ((buffer-read-only nil))
8057 (gnus-summary-update-mark
8058 (if (= n (or gnus-summary-default-score 0)) ?
8059 (if (< n (or gnus-summary-default-score 0))
8060 gnus-score-below-mark gnus-score-over-mark)) 'score))
8061 (let* ((article (gnus-summary-article-number))
8062 (score (assq article gnus-newsgroup-scored)))
8063 (if score (setcdr score n)
8064 (setq gnus-newsgroup-scored
8065 (cons (cons article n) gnus-newsgroup-scored))))
8066 (gnus-summary-update-line)))
8068 (defun gnus-summary-current-score ()
8069 "Return the score of the current article."
8071 (message "%s" (gnus-summary-article-score)))
8073 ;; Summary marking commands.
8075 (defun gnus-summary-raise-same-subject-and-select (score)
8076 "Raise articles which has the same subject with SCORE and select the next."
8078 (let ((subject (gnus-summary-subject-string)))
8079 (gnus-summary-raise-score score)
8080 (while (gnus-summary-search-subject nil nil subject)
8081 (gnus-summary-raise-score score))
8082 (gnus-summary-next-article t)))
8084 (defun gnus-summary-raise-same-subject (score)
8085 "Raise articles which has the same subject with SCORE."
8087 (let ((subject (gnus-summary-subject-string)))
8088 (gnus-summary-raise-score score)
8089 (while (gnus-summary-search-subject nil nil subject)
8090 (gnus-summary-raise-score score))
8091 (gnus-summary-next-subject 1 t)))
8093 (defun gnus-score-default (level)
8094 (if level (prefix-numeric-value level)
8095 gnus-score-interactive-default-score))
8097 (defun gnus-summary-raise-thread (score)
8098 "Raise articles under current thread with SCORE."
8100 (setq score (1- (gnus-score-default score)))
8103 (let ((level (gnus-summary-thread-level)))
8104 (gnus-summary-raise-score score)
8105 (while (and (zerop (gnus-summary-next-subject 1 nil t))
8106 (> (gnus-summary-thread-level) level))
8107 (gnus-summary-raise-score score))
8109 (let ((gnus-summary-check-current t))
8110 (or (zerop (gnus-summary-next-subject 1 t))
8112 (gnus-summary-recenter)
8113 (gnus-summary-position-cursor)
8114 (gnus-set-mode-line 'summary))
8116 (defun gnus-summary-lower-same-subject-and-select (score)
8117 "Raise articles which has the same subject with SCORE and select the next."
8119 (gnus-summary-raise-same-subject-and-select (- score)))
8121 (defun gnus-summary-lower-same-subject (score)
8122 "Raise articles which has the same subject with SCORE."
8124 (gnus-summary-raise-same-subject (- score)))
8126 (defun gnus-summary-lower-thread (score)
8127 "Raise articles under current thread with SCORE."
8129 (gnus-summary-raise-thread (- (1- (gnus-score-default score)))))
8131 (defun gnus-summary-kill-same-subject-and-select (unmark)
8132 "Mark articles which has the same subject as read, and then select the next.
8133 If UNMARK is positive, remove any kind of mark.
8134 If UNMARK is negative, tick articles."
8137 (setq unmark (prefix-numeric-value unmark)))
8139 (gnus-summary-mark-same-subject
8140 (gnus-summary-subject-string) unmark)))
8141 ;; Select next unread article. If auto-select-same mode, should
8142 ;; select the first unread article.
8143 (gnus-summary-next-article t (and gnus-auto-select-same
8144 (gnus-summary-subject-string)))
8145 (gnus-message 7 "%d articles are marked as %s"
8146 count (if unmark "unread" "read"))))
8148 (defun gnus-summary-kill-same-subject (unmark)
8149 "Mark articles which has the same subject as read.
8150 If UNMARK is positive, remove any kind of mark.
8151 If UNMARK is negative, tick articles."
8154 (setq unmark (prefix-numeric-value unmark)))
8156 (gnus-summary-mark-same-subject
8157 (gnus-summary-subject-string) unmark)))
8158 ;; If marked as read, go to next unread subject.
8160 ;; Go to next unread subject.
8161 (gnus-summary-next-subject 1 t))
8162 (gnus-message 7 "%d articles are marked as %s"
8163 count (if unmark "unread" "read"))))
8165 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8166 "Mark articles with same SUBJECT as read, and return marked number.
8167 If optional argument UNMARK is positive, remove any kinds of marks.
8168 If optional argument UNMARK is negative, mark articles as unread instead."
8171 (cond ((null unmark)
8172 (gnus-summary-mark-as-read nil gnus-killed-mark))
8174 (gnus-summary-tick-article nil t))
8176 (gnus-summary-tick-article)))
8178 (gnus-summary-search-forward nil subject))
8179 (cond ((null unmark)
8180 (gnus-summary-mark-as-read nil gnus-killed-mark))
8182 (gnus-summary-tick-article nil t))
8184 (gnus-summary-tick-article)))
8185 (setq count (1+ count))))
8186 ;; Hide killed thread subtrees. Does not work properly always.
8187 ;;(and (null unmark)
8188 ;; gnus-thread-hide-killed
8189 ;; (gnus-summary-hide-thread))
8190 ;; Return number of articles marked as read.
8193 (defun gnus-summary-mark-as-processable (n &optional unmark)
8194 "Set the process mark on the next N articles.
8195 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8196 the process mark instead. The difference between N and the actual
8197 number of articles marked is returned."
8199 (let ((backward (< n 0))
8204 (gnus-summary-remove-process-mark (gnus-summary-article-number))
8205 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8206 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8208 (if (/= 0 n) (gnus-message 7 "No more articles"))
8209 (gnus-summary-recenter)
8210 (gnus-summary-position-cursor)
8213 (defun gnus-summary-unmark-as-processable (n)
8214 "Remove the process mark from the next N articles.
8215 If N is negative, mark backward instead. The difference between N and
8216 the actual number of articles marked is returned."
8218 (gnus-summary-mark-as-processable n t))
8220 (defun gnus-summary-unmark-all-processable ()
8221 "Remove the process mark from all articles."
8224 (while gnus-newsgroup-processable
8225 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8226 (gnus-summary-position-cursor))
8228 (defun gnus-summary-mark-as-expirable (n)
8229 "Mark N articles forward as expirable.
8230 If N is negative, mark backward instead. The difference between N and
8231 the actual number of articles marked is returned."
8233 (gnus-summary-mark-forward n gnus-expirable-mark))
8235 (defun gnus-summary-mark-article-as-replied (article)
8236 "Mark ARTICLE replied and update the summary line."
8237 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
8238 (let ((buffer-read-only nil))
8239 (if (gnus-summary-goto-subject article)
8241 (gnus-summary-update-mark gnus-replied-mark 'replied)
8244 (defun gnus-summary-set-bookmark (article)
8245 "Set a bookmark in current article."
8246 (interactive (list (gnus-summary-article-number)))
8247 (if (or (not (get-buffer gnus-article-buffer))
8248 (not gnus-current-article)
8249 (not gnus-article-current)
8250 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8251 (error "No current article selected"))
8252 ;; Remove old bookmark, if one exists.
8253 (let ((old (assq article gnus-newsgroup-bookmarks)))
8254 (if old (setq gnus-newsgroup-bookmarks
8255 (delq old gnus-newsgroup-bookmarks))))
8256 ;; Set the new bookmark, which is on the form
8257 ;; (article-number . line-number-in-body).
8258 (setq gnus-newsgroup-bookmarks
8262 (set-buffer gnus-article-buffer)
8266 (goto-char (point-min))
8267 (search-forward "\n\n" nil t)
8270 gnus-newsgroup-bookmarks))
8271 (gnus-message 6 "A bookmark has been added to the current article."))
8273 (defun gnus-summary-remove-bookmark (article)
8274 "Remove the bookmark from the current article."
8275 (interactive (list (gnus-summary-article-number)))
8276 ;; Remove old bookmark, if one exists.
8277 (let ((old (assq article gnus-newsgroup-bookmarks)))
8280 (setq gnus-newsgroup-bookmarks
8281 (delq old gnus-newsgroup-bookmarks))
8282 (gnus-message 6 "Removed bookmark."))
8283 (gnus-message 6 "No bookmark in current article."))))
8285 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8286 (defun gnus-summary-mark-as-dormant (n)
8287 "Mark N articles forward as dormant.
8288 If N is negative, mark backward instead. The difference between N and
8289 the actual number of articles marked is returned."
8291 (gnus-summary-mark-forward n gnus-dormant-mark))
8293 (defun gnus-summary-set-process-mark (article)
8294 "Set the process mark on ARTICLE and update the summary line."
8295 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
8296 (let ((buffer-read-only nil))
8297 (if (gnus-summary-goto-subject article)
8299 (and (eq (gnus-summary-article-mark) ?Z)
8301 (gnus-summary-update-mark gnus-process-mark 'replied)
8304 (defun gnus-summary-remove-process-mark (article)
8305 "Remove the process mark from ARTICLE and update the summary line."
8306 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8307 (let ((buffer-read-only nil))
8308 (if (gnus-summary-goto-subject article)
8310 (and (eq (gnus-summary-article-mark) ?Z)
8312 (gnus-summary-update-mark ? 'replied)
8313 (if (memq article gnus-newsgroup-replied)
8314 (gnus-summary-update-mark gnus-replied-mark 'replied))
8317 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8318 "Mark N articles as read forwards.
8319 If N is negative, mark backwards instead.
8320 Mark with MARK. If MARK is ? , ?! or ??, articles will be
8322 The difference between N and the actual number of articles marked is
8325 (gnus-set-global-variables)
8326 (let ((backward (< n 0))
8328 (mark (or mark gnus-del-mark)))
8330 (gnus-summary-mark-article nil mark no-expire)
8331 (zerop (gnus-summary-next-subject
8332 (if backward -1 1) gnus-summary-goto-unread t)))
8334 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8335 (gnus-summary-recenter)
8336 (gnus-summary-position-cursor)
8337 (gnus-set-mode-line 'summary)
8340 (defun gnus-summary-mark-article (&optional article mark no-expire)
8341 "Mark ARTICLE with MARK.
8342 MARK can be any character.
8343 Five MARK strings are reserved: ? (unread),
8344 ?! (ticked), ?? (dormant), ?D (read), ?E (expirable).
8345 If MARK is nil, then the default character ?D is used.
8346 If ARTICLE is nil, then the article on the current line will be
8348 ;; If no mark is given, then we check auto-expiring.
8349 (and (not no-expire)
8350 gnus-newsgroup-auto-expire
8352 (and (numberp mark) (or (= mark gnus-killed-mark)
8353 (= mark gnus-del-mark)
8354 (= mark gnus-catchup-mark)
8355 (= mark gnus-low-score-mark)
8356 (= mark gnus-read-mark))))
8357 (setq mark gnus-expirable-mark))
8358 (let* ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-del-mark))
8359 (article (or article (gnus-summary-article-number))))
8360 (if (or (= mark gnus-unread-mark)
8361 (= mark gnus-ticked-mark)
8362 (= mark gnus-dormant-mark))
8363 (gnus-mark-article-as-unread article mark)
8364 (gnus-mark-article-as-read article mark))
8366 ;; See whether the article is to be put in the cache.
8369 (gnus-cache-possibly-enter-article
8370 gnus-newsgroup-name article
8371 (gnus-get-header-by-number article)
8372 (= mark gnus-ticked-mark)
8373 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8375 (if (gnus-summary-goto-subject article)
8376 (let ((buffer-read-only nil))
8377 (gnus-summary-show-thread)
8379 (and (eq (gnus-summary-article-mark) ?Z)
8382 (gnus-summary-update-mark mark 'unread)
8385 (defun gnus-summary-update-mark (mark type)
8387 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8391 (forward-char forward)
8392 (setq plist (text-properties-at (point)))
8394 (and (memq 'gnus plist)
8395 (setcar (cdr (car (cdr (memq 'gnus plist)))) mark))
8397 (and plist (add-text-properties (1- (point)) (point) plist))
8398 (gnus-summary-update-line (eq mark gnus-unread-mark)))))
8400 (defun gnus-mark-article-as-read (article &optional mark)
8401 "Enter ARTICLE in the pertinent lists and remove it from others."
8402 ;; Make the article expirable.
8403 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-del-mark)))
8404 (if (= mark gnus-expirable-mark)
8405 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
8406 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8407 ;; Remove from unread and marked lists.
8408 (setq gnus-newsgroup-unreads
8409 (delq article gnus-newsgroup-unreads))
8410 (setq gnus-newsgroup-marked
8411 (delq article gnus-newsgroup-marked))
8412 (setq gnus-newsgroup-dormant
8413 (delq article gnus-newsgroup-dormant))))
8415 (defun gnus-mark-article-as-unread (article &optional mark)
8416 "Enter ARTICLE in the pertinent lists and remove it from others."
8417 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-ticked-mark)))
8418 ;; Add to unread list.
8419 (or (memq article gnus-newsgroup-unreads)
8420 (setq gnus-newsgroup-unreads
8421 (cons article gnus-newsgroup-unreads)))
8422 ;; If CLEAR-MARK is non-nil, the article must be removed from marked
8423 ;; list. Otherwise, it must be added to the list.
8424 (setq gnus-newsgroup-marked
8425 (delq article gnus-newsgroup-marked))
8426 (setq gnus-newsgroup-dormant
8427 (delq article gnus-newsgroup-dormant))
8428 (setq gnus-newsgroup-expirable
8429 (delq article gnus-newsgroup-expirable))
8430 (if (= mark gnus-ticked-mark)
8431 (setq gnus-newsgroup-marked
8432 (cons article gnus-newsgroup-marked)))
8433 (if (= mark gnus-dormant-mark)
8434 (setq gnus-newsgroup-dormant
8435 (cons article gnus-newsgroup-dormant)))))
8437 (defalias 'gnus-summary-mark-as-unread-forward
8438 'gnus-summary-tick-article-forward)
8439 (make-obsolete 'gnus-summary-mark-as-unread-forward
8440 'gnus-summary-tick-article-forward)
8441 (defun gnus-summary-tick-article-forward (n)
8442 "Tick N articles forwards.
8443 If N is negative, tick backwards instead.
8444 The difference between N and the number of articles ticked is returned."
8446 (gnus-summary-mark-forward n gnus-ticked-mark))
8448 (defalias 'gnus-summary-mark-as-unread-backward
8449 'gnus-summary-tick-article-backward)
8450 (make-obsolete 'gnus-summary-mark-as-unread-backward
8451 'gnus-summary-tick-article-backward)
8452 (defun gnus-summary-tick-article-backward (n)
8453 "Tick N articles backwards.
8454 The difference between N and the number of articles ticked is returned."
8456 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8458 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8459 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8460 (defun gnus-summary-tick-article (&optional article clear-mark)
8461 "Mark current article as unread.
8462 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8463 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8464 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8467 (defun gnus-summary-mark-as-read-forward (n)
8468 "Mark N articles as read forwards.
8469 If N is negative, mark backwards instead.
8470 The difference between N and the actual number of articles marked is
8473 (gnus-summary-mark-forward n gnus-del-mark t))
8475 (defun gnus-summary-mark-as-read-backward (n)
8476 "Mark the N articles as read backwards.
8477 The difference between N and the actual number of articles marked is
8480 (gnus-summary-mark-forward (- n) gnus-del-mark t))
8482 (defun gnus-summary-mark-as-read (&optional article mark)
8483 "Mark current article as read.
8484 ARTICLE specifies the article to be marked as read.
8485 MARK specifies a string to be inserted at the beginning of the line."
8486 (gnus-summary-mark-article article mark))
8488 (defun gnus-summary-clear-mark-forward (n)
8489 "Clear marks from N articles forward.
8490 If N is negative, clear backward instead.
8491 The difference between N and the number of marks cleared is returned."
8493 (gnus-summary-mark-forward n gnus-unread-mark))
8495 (defun gnus-summary-clear-mark-backward (n)
8496 "Clear marks from N articles backward.
8497 The difference between N and the number of marks cleared is returned."
8499 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8501 (defun gnus-summary-mark-unread-as-read ()
8502 "Intended to be used by `gnus-summary-mark-article-hook'."
8503 (or (memq gnus-current-article gnus-newsgroup-marked)
8504 (memq gnus-current-article gnus-newsgroup-dormant)
8505 (memq gnus-current-article gnus-newsgroup-expirable)
8506 (gnus-summary-mark-as-read gnus-current-article gnus-read-mark)))
8508 (defun gnus-summary-mark-region-as-read (point mark all)
8509 "Mark all unread articles between point and mark as read.
8510 If given a prefix, mark all articles between point and mark as read,
8511 even ticked and dormant ones."
8512 (interactive "r\nP")
8522 (not (memq (gnus-summary-article-number)
8523 gnus-newsgroup-marked))
8524 (not (memq (gnus-summary-article-number)
8525 gnus-newsgroup-dormant))))
8526 (gnus-summary-mark-article
8527 (gnus-summary-article-number) gnus-del-mark))
8529 (zerop (forward-line 1))))))
8531 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
8532 (defalias 'gnus-summary-delete-marked-as-read
8533 'gnus-summary-remove-lines-marked-as-read)
8534 (make-obsolete 'gnus-summary-delete-marked-as-read
8535 'gnus-summary-remove-lines-marked-as-read)
8536 (defun gnus-summary-remove-lines-marked-as-read ()
8537 "Remove lines that are marked as read."
8539 (gnus-summary-remove-lines-marked-with
8541 (lambda (char) (char-to-string (symbol-value char)))
8542 '(gnus-del-mark gnus-read-mark gnus-ancient-mark
8543 gnus-killed-mark gnus-kill-file-mark
8544 gnus-low-score-mark gnus-expirable-mark)
8547 (defalias 'gnus-summary-delete-marked-with
8548 'gnus-summary-remove-lines-marked-with)
8549 (make-obsolete 'gnus-summary-delete-marked-with
8550 'gnus-summary-remove-lines-marked-with)
8551 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
8552 (defun gnus-summary-remove-lines-marked-with (marks)
8553 "Remove lines that are marked with MARKS (e.g. \"DK\")."
8554 (interactive "sMarks: ")
8555 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
8557 (set-buffer gnus-summary-buffer)
8558 (let ((buffer-read-only nil)
8559 (marks (concat "^[" marks "]")))
8560 (goto-char (point-min))
8561 (if gnus-newsgroup-adaptive
8562 (gnus-score-remove-lines-adaptive marks)
8563 (while (re-search-forward marks (point-max) t)
8565 (delete-region (point)
8566 (progn (forward-line 1) (point))))))
8567 (or (zerop (buffer-size))
8569 (gnus-summary-prev-subject 1)
8570 (gnus-summary-position-cursor)))))
8572 (defun gnus-summary-expunge-below (score)
8573 "Remove articles with score less than SCORE."
8575 (setq score (if score
8576 (prefix-numeric-value score)
8577 (or gnus-summary-default-score 0)))
8579 (set-buffer gnus-summary-buffer)
8580 (goto-char (point-min))
8581 (let ((buffer-read-only nil)
8584 (if (< (gnus-summary-article-score) score)
8588 (delete-region beg (point)))
8591 (or (zerop (buffer-size))
8593 (gnus-summary-prev-subject 1)
8594 (gnus-summary-position-cursor))))))
8596 (defun gnus-summary-mark-below (score mark)
8597 "Mark articles with score less than SCORE with MARK."
8598 (interactive "P\ncMark: ")
8599 (setq score (if score
8600 (prefix-numeric-value score)
8601 (or gnus-summary-default-score 0)))
8603 (set-buffer gnus-summary-buffer)
8604 (goto-char (point-min))
8606 (and (< (gnus-summary-article-score) score)
8607 (gnus-summary-mark-article nil mark))
8610 (defun gnus-summary-kill-below (score)
8611 "Mark articles with score below SCORE as read."
8613 (gnus-summary-mark-below score gnus-killed-mark))
8615 (defun gnus-summary-clear-above (score)
8616 "Clear all marks from articles with score above SCORE."
8618 (gnus-summary-mark-above score gnus-unread-mark))
8620 (defun gnus-summary-tick-above (score)
8621 "Tick all articles with score above SCORE."
8623 (gnus-summary-mark-above score gnus-ticked-mark))
8625 (defun gnus-summary-mark-above (score mark)
8626 "Mark articles with score over SCORE with MARK."
8627 (interactive "P\ncMark: ")
8628 (setq score (if score
8629 (prefix-numeric-value score)
8630 (or gnus-summary-default-score 0)))
8632 (set-buffer gnus-summary-buffer)
8633 (goto-char (point-min))
8635 (if (> (gnus-summary-article-score) score)
8637 (gnus-summary-mark-article nil mark)
8639 (forward-line 1)))))
8641 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8642 (defun gnus-summary-show-all-expunged ()
8643 "Display all the hidden articles that were expunged for low scores."
8645 (let ((buffer-read-only nil))
8646 (let ((scored gnus-newsgroup-scored)
8649 (or (gnus-summary-goto-subject (car (car scored)))
8650 (and (setq h (gnus-get-header-by-number (car (car scored))))
8651 (< (cdr (car scored)) gnus-summary-expunge-below)
8652 (setq headers (cons h headers))))
8653 (setq scored (cdr scored)))
8654 (or headers (error "No expunged articles hidden."))
8655 (goto-char (point-min))
8657 (gnus-summary-update-lines
8660 (gnus-summary-prepare-threads (nreverse headers) 0)
8662 (goto-char (point-min))
8663 (gnus-summary-position-cursor)))
8665 (defun gnus-summary-show-all-dormant ()
8666 "Display all the hidden articles that are marked as dormant."
8668 (let ((buffer-read-only nil))
8669 (goto-char (point-min))
8670 (let ((dormant gnus-newsgroup-dormant)
8673 (or (gnus-summary-goto-subject (car dormant))
8674 (and (setq h (gnus-get-header-by-number (car dormant)))
8675 (setq headers (cons h headers))))
8676 (setq dormant (cdr dormant)))
8677 (or headers (error "No dormant articles hidden."))
8679 (gnus-summary-update-lines
8682 (gnus-summary-prepare-threads (nreverse headers) 0)
8684 (goto-char (point-min))
8685 (gnus-summary-position-cursor)))
8687 (defun gnus-summary-hide-all-dormant ()
8688 "Hide all dormant articles."
8690 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
8691 (gnus-summary-position-cursor))
8693 (defun gnus-summary-catchup (all &optional quietly to-here not-mark)
8694 "Mark all articles not marked as unread in this newsgroup as read.
8695 If prefix argument ALL is non-nil, all articles are marked as read.
8696 If QUIETLY is non-nil, no questions will be asked.
8697 If TO-HERE is non-nil, it should be a point in the buffer. All
8698 articles before this point will be marked as read.
8699 The number of articles marked as read is returned."
8703 (not gnus-interactive-catchup) ;Without confirmation?
8707 "Mark absolutely all articles as read? "
8708 "Mark all unread articles as read? ")))
8710 (not gnus-newsgroup-adaptive)
8711 (not gnus-newsgroup-auto-expire))
8713 (and all (setq gnus-newsgroup-marked nil
8714 gnus-newsgroup-dormant nil))
8715 (setq gnus-newsgroup-unreads gnus-newsgroup-marked))
8716 (let ((unreads (length gnus-newsgroup-unreads)))
8717 (if (gnus-summary-first-subject (not all))
8718 (while (and (gnus-summary-mark-as-read nil gnus-catchup-mark)
8719 (if to-here (< (point) to-here) t)
8720 (gnus-summary-search-subject nil (not all)))))
8721 (- unreads (length gnus-newsgroup-unreads))
8723 (setq gnus-newsgroup-unreads gnus-newsgroup-marked)))))
8724 (gnus-summary-position-cursor)))
8726 (defun gnus-summary-catchup-to-here (&optional all)
8727 "Mark all unticked articles before the current one as read.
8728 If ALL is non-nil, also mark ticked and dormant articles as read."
8731 (gnus-summary-catchup all t (point))
8732 (gnus-summary-position-cursor))
8734 (defun gnus-summary-catchup-all (&optional quietly)
8735 "Mark all articles in this newsgroup as read."
8737 (gnus-summary-catchup t quietly))
8739 (defun gnus-summary-catchup-and-exit (all &optional quietly)
8740 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8741 If prefix argument ALL is non-nil, all articles are marked as read."
8743 (gnus-summary-catchup all quietly nil 'fast)
8744 ;; Select next newsgroup or exit.
8745 (if (eq gnus-auto-select-next 'quietly)
8746 (gnus-summary-next-group nil)
8747 (gnus-summary-exit)))
8749 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8750 "Mark all articles in this newsgroup as read, and then exit."
8752 (gnus-summary-catchup-and-exit t quietly))
8754 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8755 (defun gnus-summary-catchup-and-goto-next-group (all)
8756 "Mark all articles in this group as read and select the next group.
8757 If given a prefix, mark all articles, unread as well as ticked, as
8760 (gnus-summary-catchup all)
8761 (gnus-summary-next-group))
8763 ;; Thread-based commands.
8765 (defun gnus-summary-toggle-threads (arg)
8766 "Toggle showing conversation threads.
8767 If ARG is positive number, turn showing conversation threads on."
8769 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8770 (setq gnus-show-threads
8771 (if (null arg) (not gnus-show-threads)
8772 (> (prefix-numeric-value arg) 0)))
8773 (gnus-summary-prepare)
8774 (gnus-summary-goto-subject current)
8775 (gnus-summary-position-cursor)))
8777 (defun gnus-summary-show-all-threads ()
8781 (let ((buffer-read-only nil))
8782 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8783 (gnus-summary-position-cursor))
8785 (defun gnus-summary-show-thread ()
8786 "Show thread subtrees.
8787 Returns nil if no thread was there to be shown."
8791 (let ((buffer-read-only nil)
8792 ;; first goto end then to beg, to have point at beg after let
8793 (end (progn (end-of-line) (point)))
8794 (beg (progn (beginning-of-line) (point))))
8796 ;; Any hidden lines here?
8797 (search-forward "\r" end t)
8798 (subst-char-in-region beg end ?\^M ?\n t))))
8799 (gnus-summary-position-cursor)))
8801 (defun gnus-summary-hide-all-threads ()
8802 "Hide all thread subtrees."
8805 (goto-char (point-min))
8806 (gnus-summary-hide-thread)
8807 (while (and (not (eobp)) (zerop (forward-line 1)))
8808 (gnus-summary-hide-thread)))
8809 (gnus-summary-position-cursor))
8811 (defun gnus-summary-hide-thread ()
8812 "Hide thread subtrees.
8813 Returns nil if no threads were there to be hidden."
8815 (let ((buffer-read-only nil)
8817 (level (gnus-summary-thread-level))
8819 ;; Go forward until either the buffer ends or the subthread
8823 (while (and (zerop (forward-line 1))
8824 (> (gnus-summary-thread-level) level))
8829 (search-backward "\n" start t))
8830 (subst-char-in-region start end ?\n ?\^M t)
8831 (forward-line -1)))))
8833 (defun gnus-summary-go-to-next-thread (&optional previous)
8834 "Go to the same level (or less) next thread.
8835 If PREVIOUS is non-nil, go to previous thread instead.
8836 Return the article number moved to, or nil if moving was impossible."
8837 (let ((level (gnus-summary-thread-level))
8838 (article (gnus-summary-article-number)))
8840 (while (and (zerop (gnus-summary-prev-subject 1))
8841 (> (gnus-summary-thread-level) level)))
8842 (while (and (zerop (gnus-summary-next-subject 1))
8843 (> (gnus-summary-thread-level) level))))
8844 (gnus-summary-recenter)
8845 (gnus-summary-position-cursor)
8846 (let ((oart (gnus-summary-article-number)))
8847 (and (/= oart article) oart))))
8849 (defun gnus-summary-next-thread (n)
8850 "Go to the same level next N'th thread.
8851 If N is negative, search backward instead.
8852 Returns the difference between N and the number of skips actually
8855 (let ((backward (< n 0))
8858 (gnus-summary-go-to-next-thread backward))
8860 (gnus-summary-position-cursor)
8861 (if (/= 0 n) (gnus-message 7 "No more threads"))
8864 (defun gnus-summary-prev-thread (n)
8865 "Go to the same level previous N'th thread.
8866 Returns the difference between N and the number of skips actually
8869 (gnus-summary-next-thread (- n)))
8871 (defun gnus-summary-go-down-thread (&optional same)
8872 "Go down one level in the current thread.
8873 If SAME is non-nil, also move to articles of the same level."
8874 (let ((level (gnus-summary-thread-level))
8876 (if (and (zerop (forward-line 1))
8877 (> (gnus-summary-thread-level) level))
8882 (defun gnus-summary-go-up-thread ()
8883 "Go up one level in the current thread."
8884 (let ((level (gnus-summary-thread-level))
8886 (while (and (zerop (forward-line -1))
8887 (>= (gnus-summary-thread-level) level)))
8888 (if (>= (gnus-summary-thread-level) level)
8894 (defun gnus-summary-down-thread (n)
8895 "Go down thread N steps.
8896 If N is negative, go up instead.
8897 Returns the difference between N and how many steps down that were
8903 (if up (gnus-summary-go-up-thread)
8904 (gnus-summary-go-down-thread)))
8906 (gnus-summary-position-cursor)
8907 (if (/= 0 n) (gnus-message 7 "Can't go further"))
8910 (defun gnus-summary-up-thread (n)
8911 "Go up thread N steps.
8912 If N is negative, go up instead.
8913 Returns the difference between N and how many steps down that were
8916 (gnus-summary-down-thread (- n)))
8918 (defun gnus-summary-kill-thread (unmark)
8919 "Mark articles under current thread as read.
8920 If the prefix argument is positive, remove any kinds of marks.
8921 If the prefix argument is negative, tick articles instead."
8924 (setq unmark (prefix-numeric-value unmark)))
8926 (level (gnus-summary-thread-level)))
8929 ;; Mark the article...
8930 (cond ((null unmark) (gnus-summary-mark-as-read nil gnus-killed-mark))
8931 ((> unmark 0) (gnus-summary-tick-article nil t))
8932 (t (gnus-summary-tick-article)))
8933 ;; ...and go forward until either the buffer ends or the subtree
8935 (if (not (and (zerop (forward-line 1))
8936 (> (gnus-summary-thread-level) level)))
8937 (setq killing nil))))
8938 ;; Hide killed subtrees.
8940 gnus-thread-hide-killed
8941 (gnus-summary-hide-thread))
8942 ;; If marked as read, go to next unread subject.
8944 ;; Go to next unread subject.
8945 (gnus-summary-next-subject 1 t)))
8946 (gnus-set-mode-line 'summary))
8948 ;; Summary sorting commands
8950 (defun gnus-summary-sort-by-number (&optional reverse)
8951 "Sort summary buffer by article number.
8952 Argument REVERSE means reverse order."
8955 (cons 'gnus-summary-article-number 'gnus-thread-sort-by-number) reverse))
8957 (defun gnus-summary-sort-by-author (&optional reverse)
8958 "Sort summary buffer by author name alphabetically.
8959 If case-fold-search is non-nil, case of letters is ignored.
8960 Argument REVERSE means reverse order."
8965 (let ((extract (funcall
8966 gnus-extract-address-components
8967 (header-from (gnus-get-header-by-number
8968 (gnus-summary-article-number))))))
8969 (or (car extract) (cdr extract))))
8970 'gnus-thread-sort-by-author)
8973 (defun gnus-summary-sort-by-subject (&optional reverse)
8974 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
8975 If case-fold-search is non-nil, case of letters is ignored.
8976 Argument REVERSE means reverse order."
8981 (downcase (gnus-simplify-subject (gnus-summary-subject-string))))
8982 'gnus-thread-sort-by-subject)
8985 (defun gnus-summary-sort-by-date (&optional reverse)
8986 "Sort summary buffer by date.
8987 Argument REVERSE means reverse order."
8994 (gnus-get-header-by-number (gnus-summary-article-number)))))
8995 'gnus-thread-sort-by-date)
8998 (defun gnus-summary-sort-by-score (&optional reverse)
8999 "Sort summary buffer by score.
9000 Argument REVERSE means reverse order."
9003 (cons 'gnus-summary-article-score 'gnus-thread-sort-by-score)
9006 (defvar gnus-summary-already-sorted nil)
9007 (defun gnus-summary-sort (predicate reverse)
9008 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
9009 (if gnus-summary-already-sorted
9011 (let (buffer-read-only)
9012 (if (not gnus-show-threads)
9014 (goto-char (point-min))
9015 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
9016 (let ((gnus-thread-sort-functions (list (cdr predicate)))
9017 (gnus-summary-prepare-hook nil)
9018 (gnus-summary-already-sorted nil))
9019 (gnus-summary-prepare)
9020 (and gnus-show-threads
9021 gnus-thread-hide-subtree
9022 (gnus-summary-hide-all-threads)))))))
9024 (defun gnus-sortable-date (date)
9025 "Make sortable string by string-lessp from DATE.
9026 Timezone package is used."
9027 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
9028 (year (aref date 0))
9029 (month (aref date 1))
9030 (day (aref date 2)))
9031 (timezone-make-sortable-date
9033 (timezone-make-time-string
9034 (aref date 3) (aref date 4) (aref date 5)))))
9037 ;; Summary saving commands.
9039 (defun gnus-summary-save-article (n)
9040 "Save the current article using the default saver function.
9041 If N is a positive number, save the N next articles.
9042 If N is a negative number, save the N previous articles.
9043 If N is nil and any articles have been marked with the process mark,
9044 save those articles instead.
9045 The variable `gnus-default-article-saver' specifies the saver function."
9047 (let ((articles (gnus-summary-work-articles n)))
9049 (let ((header (gnus-get-header-by-number (car articles))))
9050 (if (vectorp header)
9052 (gnus-summary-select-article t nil nil (car articles))
9053 (or gnus-save-all-headers
9054 (gnus-article-hide-headers t))
9055 ;; Remove any X-Gnus lines.
9058 (set-buffer gnus-article-buffer)
9059 (let ((buffer-read-only nil))
9060 (goto-char (point-min))
9061 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
9063 (while (re-search-forward "^X-Gnus" nil t)
9065 (delete-region (point)
9066 (progn (forward-line 1) (point))))
9069 (if gnus-default-article-saver
9070 (funcall gnus-default-article-saver)
9071 (error "No default saver is defined."))))
9072 (if (assq 'name header)
9073 (gnus-copy-file (cdr (assq 'name header)))
9074 (gnus-message 1 "Article %d is unsaveable" (car articles)))))
9075 (gnus-summary-remove-process-mark (car articles))
9076 (setq articles (cdr articles)))
9077 (gnus-summary-position-cursor)
9080 (defun gnus-summary-pipe-output (arg)
9081 "Pipe the current article to a subprocess.
9082 If N is a positive number, pipe the N next articles.
9083 If N is a negative number, pipe the N previous articles.
9084 If N is nil and any articles have been marked with the process mark,
9085 pipe those articles instead."
9087 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9088 (gnus-summary-save-article arg)))
9090 (defun gnus-summary-save-article-mail (arg)
9091 "Append the current article to an mail file.
9092 If N is a positive number, save the N next articles.
9093 If N is a negative number, save the N previous articles.
9094 If N is nil and any articles have been marked with the process mark,
9095 save those articles instead."
9097 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9098 (gnus-summary-save-article arg)))
9100 (defun gnus-summary-save-article-rmail (arg)
9101 "Append the current article to an rmail file.
9102 If N is a positive number, save the N next articles.
9103 If N is a negative number, save the N previous articles.
9104 If N is nil and any articles have been marked with the process mark,
9105 save those articles instead."
9107 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9108 (gnus-summary-save-article arg)))
9110 (defun gnus-summary-save-article-file (arg)
9111 "Append the current article to a file.
9112 If N is a positive number, save the N next articles.
9113 If N is a negative number, save the N previous articles.
9114 If N is nil and any articles have been marked with the process mark,
9115 save those articles instead."
9117 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9118 (gnus-summary-save-article arg)))
9120 (defun gnus-summary-save-article-folder (arg)
9121 "Append the current article to an mh folder.
9122 If N is a positive number, save the N next articles.
9123 If N is a negative number, save the N previous articles.
9124 If N is nil and any articles have been marked with the process mark,
9125 save those articles instead."
9127 (let ((gnus-default-article-saver 'gnus-summary-save-in-folder))
9128 (gnus-summary-save-article arg)))
9130 (defun gnus-summary-save-article-vm (arg)
9131 "Append the current article to a vm folder.
9132 If N is a positive number, save the N next articles.
9133 If N is a negative number, save the N previous articles.
9134 If N is nil and any articles have been marked with the process mark,
9135 save those articles instead."
9137 (let ((gnus-default-article-saver 'gnus-summary-save-in-vm))
9138 (gnus-summary-save-article arg)))
9140 (defun gnus-read-save-file-name (prompt default-name)
9141 (let ((methods gnus-split-methods)
9143 (if (not gnus-split-methods)
9146 (set-buffer gnus-article-buffer)
9147 (gnus-narrow-to-headers)
9149 (goto-char (point-min))
9150 (and (condition-case ()
9151 (re-search-forward (car (car methods)) nil t)
9153 (setq split-name (cons (nth 1 (car methods)) split-name)))
9154 (setq methods (cdr methods)))
9156 (cond ((null split-name)
9158 (concat prompt " (default "
9159 (file-name-nondirectory default-name) ") ")
9160 (file-name-directory default-name)
9162 ((= 1 (length split-name))
9164 (concat prompt " (default " (car split-name) ") ")
9165 gnus-article-save-directory
9166 (concat gnus-article-save-directory (car split-name))))
9168 (setq split-name (mapcar (lambda (el) (list el))
9169 (nreverse split-name)))
9170 (let ((result (completing-read
9172 split-name nil nil)))
9173 (concat gnus-article-save-directory
9174 (if (string= result "")
9175 (car (car split-name))
9178 (defun gnus-summary-save-in-rmail (&optional filename)
9179 "Append this article to Rmail file.
9180 Optional argument FILENAME specifies file name.
9181 Directory to save to is default to `gnus-article-save-directory' which
9182 is initialized from the SAVEDIR environment variable."
9185 (funcall gnus-rmail-save-name gnus-newsgroup-name
9186 gnus-current-headers gnus-newsgroup-last-rmail)))
9188 (setq filename (gnus-read-save-file-name
9189 "Save in rmail file:" default-name)))
9190 (gnus-make-directory (file-name-directory filename))
9191 (gnus-eval-in-buffer-window
9196 (gnus-output-to-rmail filename))))
9197 ;; Remember the directory name to save articles.
9198 (setq gnus-newsgroup-last-rmail filename)))
9200 (defun gnus-summary-save-in-mail (&optional filename)
9201 "Append this article to Unix mail file.
9202 Optional argument FILENAME specifies file name.
9203 Directory to save to is default to `gnus-article-save-directory' which
9204 is initialized from the SAVEDIR environment variable."
9207 (funcall gnus-mail-save-name gnus-newsgroup-name
9208 gnus-current-headers gnus-newsgroup-last-mail)))
9210 (setq filename (gnus-read-save-file-name
9211 "Save in Unix mail file:" default-name)))
9213 (expand-file-name filename
9215 (file-name-directory default-name))))
9216 (gnus-make-directory (file-name-directory filename))
9217 (gnus-eval-in-buffer-window
9222 (if (and (file-readable-p filename) (rmail-file-p filename))
9223 (gnus-output-to-rmail filename)
9224 (rmail-output filename 1 t t)))))
9225 ;; Remember the directory name to save articles.
9226 (setq gnus-newsgroup-last-mail filename)))
9228 (defun gnus-summary-save-in-file (&optional filename)
9229 "Append this article to file.
9230 Optional argument FILENAME specifies file name.
9231 Directory to save to is default to `gnus-article-save-directory' which
9232 is initialized from the SAVEDIR environment variable."
9235 (funcall gnus-file-save-name gnus-newsgroup-name
9236 gnus-current-headers gnus-newsgroup-last-file)))
9238 (setq filename (gnus-read-save-file-name
9239 "Save in file:" default-name)))
9240 (gnus-make-directory (file-name-directory filename))
9241 (gnus-eval-in-buffer-window
9246 (gnus-output-to-file filename))))
9247 ;; Remember the directory name to save articles.
9248 (setq gnus-newsgroup-last-file filename)))
9250 (defun gnus-summary-save-in-pipe (&optional command)
9251 "Pipe this article to subprocess."
9253 (let ((command (read-string "Shell command on article: "
9254 gnus-last-shell-command)))
9255 (if (string-equal command "")
9256 (setq command gnus-last-shell-command))
9257 (gnus-eval-in-buffer-window
9261 (shell-command-on-region (point-min) (point-max) command nil)))
9262 (setq gnus-last-shell-command command)))
9264 ;; Summary extract commands
9266 (defun gnus-summary-insert-pseudos (pslist)
9267 (let ((buffer-read-only nil)
9268 (article (gnus-summary-article-number))
9270 (or (gnus-summary-goto-subject article)
9271 (error (format "No such article: %d" article)))
9272 (or gnus-newsgroup-headers-hashtb-by-number
9273 (gnus-make-headers-hashtable-by-number))
9274 (gnus-summary-position-cursor)
9275 ;; If all commands are to be bunched up on one line, we collect
9277 (if gnus-view-pseudos-separately
9279 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9282 (setq action (cdr (assq 'action (car ps))))
9283 (setq files (list (cdr (assq 'name (car ps)))))
9284 (while (and ps (cdr ps)
9285 (string= (or action "1")
9286 (or (cdr (assq 'action (car (cdr ps)))) "2")))
9287 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
9288 (setcdr ps (cdr (cdr ps))))
9291 (if (not (string-match "%s" action))
9292 (setq files (cons " " files)))
9293 (setq files (cons " " files))
9294 (and (assq 'execute (car ps))
9295 (setcdr (assq 'execute (car ps))
9296 (funcall (if (string-match "%s" action)
9299 (mapconcat (lambda (f) f) files " ")))))
9300 (setq ps (cdr ps)))))
9301 (if gnus-view-pseudos
9303 (and (assq 'execute (car pslist))
9304 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9305 (eq gnus-view-pseudos 'not-confirm)))
9306 (setq pslist (cdr pslist)))
9309 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
9310 (gnus-summary-article-number)))
9313 (insert " " (file-name-nondirectory
9314 (cdr (assq 'name (car pslist))))
9315 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9316 (add-text-properties
9317 b (1+ b) (list 'gnus (list gnus-reffed-article-number
9319 'gnus-pseudo (car pslist)))
9321 (gnus-sethash (int-to-string gnus-reffed-article-number)
9322 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
9323 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9324 (setq pslist (cdr pslist)))))))
9326 (defun gnus-pseudos< (p1 p2)
9327 (let ((c1 (cdr (assq 'action p1)))
9328 (c2 (cdr (assq 'action p2))))
9329 (and c1 c2 (string< c1 c2))))
9331 (defun gnus-request-pseudo-article (props)
9332 (cond ((assq 'execute props)
9333 (gnus-execute-command (cdr (assq 'execute props)))))
9334 (let ((gnus-current-article (gnus-summary-article-number)))
9335 (run-hooks 'gnus-mark-article-hook)))
9337 (defun gnus-execute-command (command &optional automatic)
9339 (gnus-article-setup-buffer)
9340 (set-buffer gnus-article-buffer)
9341 (let ((command (if automatic command (read-string "Command: " command)))
9342 (buffer-read-only nil))
9344 (insert "$ " command "\n\n")
9345 (if gnus-view-pseudo-asynchronously
9346 (start-process "gnus-execute" nil "sh" "-c" command)
9347 (call-process "sh" nil t nil "-c" command)))))
9349 (defun gnus-copy-file (file &optional to)
9352 (list (read-file-name "Copy file: " default-directory)
9353 (read-file-name "Copy file to: " default-directory)))
9354 (or to (setq to (read-file-name "Copy file to: " default-directory)))
9355 (and (file-directory-p to)
9356 (setq to (concat (file-name-as-directory to)
9357 (file-name-nondirectory file))))
9358 (copy-file file to))
9360 ;; Summary kill commands.
9362 (defun gnus-summary-edit-global-kill (article)
9363 "Edit the \"global\" kill file."
9364 (interactive (list (gnus-summary-article-number)))
9365 (gnus-group-edit-global-kill article))
9367 (defun gnus-summary-edit-local-kill ()
9368 "Edit a local kill file applied to the current newsgroup."
9370 (setq gnus-current-headers
9372 (int-to-string (gnus-summary-article-number))
9373 gnus-newsgroup-headers-hashtb-by-number))
9374 (gnus-set-global-variables)
9375 (gnus-group-edit-local-kill
9376 (gnus-summary-article-number) gnus-newsgroup-name))
9380 ;;; Gnus article mode
9383 (put 'gnus-article-mode 'mode-class 'special)
9385 (if gnus-article-mode-map
9387 (setq gnus-article-mode-map (make-keymap))
9388 (suppress-keymap gnus-article-mode-map)
9389 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
9390 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
9391 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
9392 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
9393 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
9394 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
9395 (define-key gnus-article-mode-map "\C-c\C-M" 'gnus-article-mail-with-original)
9396 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
9397 (define-key gnus-article-mode-map gnus-mouse-2 'gnus-article-push-button)
9398 (define-key gnus-article-mode-map "\r" 'gnus-article-press-button)
9399 (define-key gnus-article-mode-map "\t" 'gnus-article-next-button)
9401 ;; Duplicate almost all summary keystrokes in the article mode map.
9403 (list "#" "\M-#" "\C-c\M-#" "n" "p"
9404 "N" "P" "\M-\C-n" "\M-\C-p" "." "\M-s" "\M-r"
9405 "<" ">" "l" "j" "^" "\M-^" "-" "u" "U" "d" "D"
9406 "\M-u" "\M-U" "k" "\C-k" "\M-\C-k""x" "X"
9407 "\M-\C-x" "\M-\177" "b" "B" "$" "w" "\C-c\C-r"
9409 "m" "o" "\C-o" "|" "\M-m" "\M-\C-m" "\M-k" "M"
9412 (define-key gnus-article-mode-map (car commands)
9413 'gnus-article-summary-command)
9414 (setq commands (cdr commands))))
9416 (let ((commands (list "q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F")))
9418 (define-key gnus-article-mode-map (car commands)
9419 'gnus-article-summary-command-nosave)
9420 (setq commands (cdr commands)))))
9423 (defun gnus-article-mode ()
9424 "Major mode for displaying an article.
9426 All normal editing commands are switched off.
9428 The following commands are available:
9430 \\<gnus-article-mode-map>
9431 \\[gnus-article-next-page]\t Scroll the article one page forwards
9432 \\[gnus-article-prev-page]\t Scroll the article one page backwards
9433 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
9434 \\[gnus-article-show-summary]\t Display the summary buffer
9435 \\[gnus-article-mail]\t Send a reply to the address near point
9436 \\[gnus-article-mail-with-original]\t Send a reply to the address near point; include the original article
9437 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
9438 \\[gnus-info-find-node]\t Go to the Gnus info node"
9440 (if gnus-visual (gnus-article-make-menu-bar))
9441 (kill-all-local-variables)
9442 (setq mode-line-modified "-- ")
9443 (make-local-variable 'mode-line-format)
9444 (setq mode-line-format (copy-sequence mode-line-format))
9445 (and (equal (nth 3 mode-line-format) " ")
9446 (setcar (nthcdr 3 mode-line-format) ""))
9447 (setq mode-name "Article")
9448 (setq major-mode 'gnus-article-mode)
9449 (make-local-variable 'minor-mode-alist)
9450 (or (assq 'gnus-show-mime minor-mode-alist)
9451 (setq minor-mode-alist
9452 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
9453 (use-local-map gnus-article-mode-map)
9454 (make-local-variable 'page-delimiter)
9455 (setq page-delimiter gnus-page-delimiter)
9456 (buffer-disable-undo (current-buffer))
9457 (setq buffer-read-only t) ;Disable modification
9458 (run-hooks 'gnus-article-mode-hook))
9460 (defun gnus-article-setup-buffer ()
9461 "Initialize article mode buffer."
9462 (or (get-buffer gnus-article-buffer)
9464 (set-buffer (get-buffer-create gnus-article-buffer))
9465 (gnus-add-current-to-buffer-list)
9466 (gnus-article-mode))))
9468 (defun gnus-request-article-this-buffer (article group)
9469 "Get an article and insert it into this buffer."
9470 (setq group (or group gnus-newsgroup-name))
9472 ;; Open server if it has closed.
9473 (gnus-check-news-server (gnus-find-method-for-group group))
9475 ;; Using `gnus-request-article' directly will insert the article into
9476 ;; `nntp-server-buffer' - so we'll save some time by not having to
9477 ;; copy it from the server buffer into the article buffer.
9479 ;; We only request an article by message-id when we do not have the
9480 ;; headers for it, so we'll have to get those.
9481 (and (stringp article)
9482 (let ((gnus-override-method gnus-refer-article-method))
9483 (gnus-read-header article)))
9485 ;; If the article number is negative, that means that this article
9486 ;; doesn't belong in this newsgroup (possibly), so we find its
9487 ;; message-id and request it by id instead of number.
9488 (if (and (numberp article) (< article 0))
9490 (set-buffer gnus-summary-buffer)
9491 (let ((header (gnus-gethash (int-to-string article)
9492 gnus-newsgroup-headers-hashtb-by-number)))
9493 (if (vectorp header)
9494 ;; It's a real article.
9495 (setq article (header-id header))
9496 ;; It is an extracted pseudo-article.
9498 (gnus-request-pseudo-article header)))))
9501 (if (and gnus-use-cache
9503 (gnus-cache-request-article article group))
9505 ;; Get the article and into the article buffer.
9509 (let ((gnus-override-method
9510 (and (stringp article) gnus-refer-article-method)))
9511 (and (gnus-request-article article group (current-buffer))
9515 (defun gnus-read-header (id)
9516 "Read the headers of article ID and enter them into the Gnus system."
9517 (or gnus-newsgroup-headers-hashtb-by-number
9518 (gnus-make-headers-hashtable-by-number))
9520 (if (not (setq header
9521 (car (if (let ((gnus-nov-is-evil t))
9522 (gnus-retrieve-headers
9523 (list id) gnus-newsgroup-name))
9524 (gnus-get-newsgroup-headers)))))
9527 (header-set-number header gnus-reffed-article-number))
9528 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
9529 (gnus-sethash (int-to-string (header-number header)) header
9530 gnus-newsgroup-headers-hashtb-by-number)
9532 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
9533 (setq gnus-current-headers header)
9536 (defun gnus-article-prepare (article &optional all-headers header)
9537 "Prepare ARTICLE in article mode buffer.
9538 ARTICLE should either be an article number or a Message-ID.
9539 If ARTICLE is an id, HEADER should be the article headers.
9540 If ALL-HEADERS is non-nil, no headers are hidden."
9542 ;; Make sure we start in a summary buffer.
9543 (or (eq major-mode 'gnus-summary-mode)
9544 (set-buffer gnus-summary-buffer))
9545 (setq gnus-summary-buffer (current-buffer))
9546 ;; Make sure the connection to the server is alive.
9547 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
9549 (gnus-check-news-server
9550 (gnus-find-method-for-group gnus-newsgroup-name))
9551 (gnus-request-group gnus-newsgroup-name t)))
9552 (or gnus-newsgroup-headers-hashtb-by-number
9553 (gnus-make-headers-hashtable-by-number))
9554 (let* ((article (if header (header-number header) article))
9555 (summary-buffer (current-buffer))
9556 (internal-hook gnus-article-internal-prepare-hook)
9557 (group gnus-newsgroup-name)
9560 (gnus-article-setup-buffer)
9561 (set-buffer gnus-article-buffer)
9562 (if (not (setq result (let ((buffer-read-only nil))
9563 (gnus-request-article-this-buffer
9565 ;; There is no such article.
9568 (set-buffer gnus-summary-buffer)
9569 (setq gnus-current-article 0)
9570 (and (numberp article)
9571 (gnus-summary-mark-as-read article gnus-canceled-mark))
9572 (gnus-message 1 "No such article (may be canceled)")
9573 (and (numberp article)
9574 (setq gnus-current-article article))
9576 (and (numberp article)
9577 (setq gnus-article-current
9578 (cons gnus-newsgroup-name article)))
9580 (if (not (eq result 'article))
9583 (set-buffer summary-buffer)
9584 (setq gnus-last-article gnus-current-article
9585 gnus-newsgroup-history (cons gnus-current-article
9586 gnus-newsgroup-history)
9587 gnus-current-article 0
9588 gnus-current-headers nil
9589 gnus-article-current nil)
9590 (gnus-configure-windows 'article)
9591 (gnus-set-global-variables))
9592 (gnus-set-mode-line 'article))
9593 ;; The result from the `request' was an actual article -
9594 ;; or at least some text that is now displayed in the
9596 (if (and (numberp article)
9597 (not (eq article gnus-current-article)))
9598 ;; Seems like a new article has been selected.
9599 ;; `gnus-current-article' must be an article number.
9601 (set-buffer summary-buffer)
9602 (setq gnus-last-article gnus-current-article
9603 gnus-newsgroup-history (cons gnus-current-article
9604 gnus-newsgroup-history)
9605 gnus-current-article article
9606 gnus-current-headers
9607 (gnus-get-header-by-number gnus-current-article)
9608 gnus-article-current
9609 (cons gnus-newsgroup-name gnus-current-article))
9610 (run-hooks 'gnus-mark-article-hook)
9611 (gnus-set-mode-line 'summary)
9613 (run-hooks 'gnus-visual-mark-article-hook))
9614 ;; Set the global newsgroup variables here.
9615 ;; Suggested by Jim Sisolak
9616 ;; <sisolak@trans4.neep.wisc.edu>.
9617 (gnus-set-global-variables)
9619 (gnus-cache-possibly-enter-article
9621 (gnus-get-header-by-number article)
9622 (memq article gnus-newsgroup-marked)
9623 (memq article gnus-newsgroup-dormant)
9624 (memq article gnus-newsgroup-unreads)))))
9625 ;; gnus-have-all-headers must be either T or NIL.
9626 (setq gnus-have-all-headers
9627 (not (not (or all-headers gnus-show-all-headers))))
9628 ;; Hooks for getting information from the article.
9629 ;; This hook must be called before being narrowed.
9630 (run-hooks 'internal-hook)
9631 (run-hooks 'gnus-article-prepare-hook)
9632 ;; Decode MIME message.
9633 (if (and gnus-show-mime
9634 (gnus-fetch-field "Mime-Version"))
9635 (funcall gnus-show-mime-method))
9636 ;; Perform the article display hooks.
9637 (let ((buffer-read-only nil))
9638 (run-hooks 'gnus-article-display-hook))
9640 (goto-char (point-min))
9641 (and gnus-break-pages (gnus-narrow-to-page))
9642 (gnus-set-mode-line 'article)
9643 (gnus-configure-windows 'article)
9644 (goto-char (point-min))
9647 (defun gnus-article-show-all-headers ()
9648 "Show all article headers in article mode buffer."
9650 (gnus-article-setup-buffer)
9651 (set-buffer gnus-article-buffer)
9652 (let ((buffer-read-only nil))
9653 (remove-text-properties (point-min) (point-max)
9654 gnus-hidden-properties))))
9656 (defun gnus-article-hide-headers-if-wanted ()
9657 "Hide unwanted headers if `gnus-have-all-headers' is nil.
9658 Provided for backwards compatability."
9659 (or gnus-have-all-headers
9660 (gnus-article-hide-headers)))
9662 (defun gnus-article-hide-headers (&optional delete)
9663 "Hide unwanted headers and possibly sort them as well."
9666 (set-buffer gnus-article-buffer)
9668 (let ((sorted gnus-sorted-header-list)
9669 (buffer-read-only nil)
9670 want want-list beg want-l)
9671 ;; First we narrow to just the headers.
9673 (goto-char (point-min))
9674 ;; Hide any "From " lines at the beginning of (mail) articles.
9675 (while (looking-at "From ")
9678 (add-text-properties (point-min) (point) gnus-hidden-properties))
9679 ;; Then treat the rest of the header lines.
9682 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
9683 ;; Then we use the two regular expressions
9684 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
9685 ;; select which header lines is to remain visible in the
9687 (goto-char (point-min))
9688 (while (re-search-forward "^[^ \t]*:" nil t)
9690 ;; We add the headers we want to keep to a list and delete
9691 ;; them from the buffer.
9692 (if (or (and (stringp gnus-visible-headers)
9693 (looking-at gnus-visible-headers))
9694 (and (not (stringp gnus-visible-headers))
9695 (stringp gnus-ignored-headers)
9696 (not (looking-at gnus-ignored-headers))))
9700 ;; Be sure to get multi-line headers...
9701 (re-search-forward "^[^ \t]*:" nil t)
9704 (cons (buffer-substring beg (point)) want-list))
9705 (delete-region beg (point))
9708 ;; Next we perform the sorting by looking at
9709 ;; `gnus-sorted-header-list'.
9710 (goto-char (point-min))
9711 (while (and sorted want-list)
9712 (setq want-l want-list)
9714 (not (string-match (car sorted) (car want-l))))
9715 (setq want-l (cdr want-l)))
9718 (insert (car want-l))
9719 (setq want-list (delq (car want-l) want-list))))
9720 (setq sorted (cdr sorted)))
9721 ;; Any headers that were not matched by the sorted list we
9722 ;; just tack on the end of the visible header list.
9724 (insert (car want-list))
9725 (setq want-list (cdr want-list)))
9726 ;; And finally we make the unwanted headers invisible.
9728 (delete-region (point) (point-max))
9729 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
9730 (add-text-properties (point) (point-max) gnus-hidden-properties))))))
9732 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
9733 (defun gnus-article-treat-overstrike ()
9734 "Translate overstrikes into bold text."
9737 (set-buffer gnus-article-buffer)
9738 (let ((buffer-read-only nil))
9739 (while (search-forward "\b" nil t)
9740 (let ((next (following-char))
9741 (previous (char-after (- (point) 2))))
9742 (cond ((eq next previous)
9743 (delete-region (- (point) 2) (point))
9744 (put-text-property (point) (1+ (point))
9747 (delete-region (1- (point)) (1+ (point)))
9748 (put-text-property (1- (point)) (point)
9751 (delete-region (- (point) 2) (point))
9752 (put-text-property (point) (1+ (point))
9753 'face 'underline))))))))
9755 (defun gnus-article-word-wrap ()
9756 "Format too long lines."
9759 (set-buffer gnus-article-buffer)
9760 (let ((buffer-read-only nil))
9761 (goto-char (point-min))
9762 (search-forward "\n\n" nil t)
9764 (let ((paragraph-start "^\\W"))
9766 (and (>= (current-column) (window-width))
9767 (/= (preceding-char) ?:)
9768 (fill-paragraph nil))
9769 (end-of-line 2))))))
9771 (defun gnus-article-remove-cr ()
9772 "Remove carriage returns from an article."
9775 (set-buffer gnus-article-buffer)
9776 (let ((buffer-read-only nil))
9777 (goto-char (point-min))
9778 (while (search-forward "\r" nil t)
9779 (replace-match "" t t)))))
9781 (defun gnus-article-display-x-face (&optional force)
9782 "Look for an X-Face header and display it if present."
9783 (interactive (list 'force))
9785 (set-buffer gnus-article-buffer)
9786 (let ((inhibit-point-motion-hooks t)
9787 (case-fold-search nil))
9789 (goto-char (point-min))
9790 (search-forward "\n\n")
9791 (narrow-to-region (point-min) (point))
9792 (goto-char (point-min))
9793 (if (or (not gnus-article-x-face-command)
9795 (or (not gnus-article-x-face-too-ugly)
9796 (string-match gnus-article-x-face-too-ugly
9797 (mail-fetch-field "from"))))
9799 (goto-char (point-min))
9800 (not (re-search-forward "^X-Face: " nil t))))
9803 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
9804 (if (symbolp gnus-article-x-face-command)
9805 (and (or (fboundp gnus-article-x-face-command)
9806 (error "%s is not a function"
9807 gnus-article-x-face-command))
9808 (funcall gnus-article-x-face-command beg end))
9809 (call-process-region beg end "sh" nil 0 nil
9810 "-c" gnus-article-x-face-command))))))))
9812 (defun gnus-article-de-quoted-unreadable (&optional force)
9813 "Do a naïve translation of a quoted-printable-encoded article.
9814 This is in no way, shape or form meant as a replacement for real MIME
9815 processing, but is simply a stop-gap measure until MIME support is
9817 If FORCE, decode the article whether it is marked as quoted-printable
9819 (interactive (list 'force))
9821 (set-buffer gnus-article-buffer)
9822 (let ((case-fold-search t)
9823 (buffer-read-only nil)
9824 (type (gnus-fetch-field "content-transfer-encoding")))
9825 (if (or force (and type (string-match "quoted-printable" type)))
9827 (goto-char (point-min))
9828 (search-forward "\n\n" nil 'move)
9829 (gnus-mime-decode-quoted-printable (point) (point-max)))))))
9831 (defun gnus-mime-decode-quoted-printable (from to)
9832 ;; Decode quoted-printable from region between FROM and TO.
9835 (while (search-forward "=" to t)
9836 (cond ((eq (following-char) ?\n)
9839 ((looking-at "[0-9A-F][0-9A-F]")
9841 (insert (hexl-hex-string-to-integer
9842 (buffer-substring (point) (+ 2 (point)))))
9844 ((gnus-message 3 "Malformed MIME quoted-printable message"))))))
9846 (defun gnus-article-date-ut (&optional type)
9847 "Convert DATE date to universal time in the current article.
9848 If TYPE is `local', convert to local time; if it is `lapsed', output
9849 how much time has lapsed since DATE."
9850 (interactive (list 'ut))
9851 (let ((date (header-date (or gnus-current-headers
9852 (gnus-get-header-by-number
9853 (gnus-summary-article-number)))))
9854 (date-regexp "^Date: \\|^X-Sent: "))
9856 (set-buffer gnus-article-buffer)
9857 (let ((buffer-read-only nil))
9858 (goto-char (point-min))
9859 (if (and (re-search-forward date-regexp nil t)
9862 (looking-at date-regexp)))
9863 (delete-region (gnus-point-at-bol)
9864 (progn (end-of-line) (1+ (point))))
9865 (goto-char (point-min))
9866 (goto-char (- (search-forward "\n\n") 2)))
9870 (concat "Date: " (timezone-make-date-arpa-standard date) "\n"))
9872 (concat "Date: " (timezone-make-date-arpa-standard date nil "UT")
9875 (let* ((sec (- (gnus-seconds-since-epoch
9876 (timezone-make-date-arpa-standard
9877 (current-time-string) (current-time-zone) "UT"))
9878 (gnus-seconds-since-epoch
9879 (timezone-make-date-arpa-standard date nil "UT"))))
9880 (units (list (cons 'year (* 365.25 24 60 60))
9881 (cons 'week (* 7 24 60 60))
9882 (cons 'day (* 24 60 60))
9883 (cons 'hour (* 60 60))
9891 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
9893 (setq sec (- sec (* num (cdr unit))))
9895 (concat (if prev ", " "") (int-to-string (floor num))
9896 " " (symbol-name (car unit))
9897 (if (> num 1) "s" ""))
9902 (error "Unknown conversion type: %s" type))))))))
9904 (defun gnus-article-date-local ()
9905 "Convert the current article date to the local timezone."
9907 (gnus-article-date-ut 'local))
9909 (defun gnus-article-date-lapsed ()
9910 "Convert the current article date to time lapsed since it was sent."
9912 (gnus-article-date-ut 'lapsed))
9914 (defun gnus-article-maybe-highlight ()
9915 (if gnus-visual (gnus-article-highlight)))
9919 (defun gnus-output-to-rmail (file-name)
9920 "Append the current article to an Rmail file named FILE-NAME."
9922 ;; Most of these codes are borrowed from rmailout.el.
9923 (setq file-name (expand-file-name file-name))
9924 (setq rmail-default-rmail-file file-name)
9925 (let ((artbuf (current-buffer))
9926 (tmpbuf (get-buffer-create " *Gnus-output*")))
9928 (or (get-file-buffer file-name)
9929 (file-exists-p file-name)
9930 (if (gnus-yes-or-no-p
9931 (concat "\"" file-name "\" does not exist, create it? "))
9932 (let ((file-buffer (create-file-buffer file-name)))
9934 (set-buffer file-buffer)
9935 (rmail-insert-rmail-file-header)
9936 (let ((require-final-newline nil))
9937 (write-region (point-min) (point-max) file-name t 1)))
9938 (kill-buffer file-buffer))
9939 (error "Output file does not exist")))
9941 (buffer-disable-undo (current-buffer))
9943 (insert-buffer-substring artbuf)
9944 (gnus-convert-article-to-rmail)
9945 ;; Decide whether to append to a file or to an Emacs buffer.
9946 (let ((outbuf (get-file-buffer file-name)))
9948 (append-to-file (point-min) (point-max) file-name)
9949 ;; File has been visited, in buffer OUTBUF.
9951 (let ((buffer-read-only nil)
9952 (msg (and (boundp 'rmail-current-message)
9953 (symbol-value 'rmail-current-message))))
9954 ;; If MSG is non-nil, buffer is in RMAIL mode.
9957 (narrow-to-region (point-max) (point-max))))
9958 (insert-buffer-substring tmpbuf)
9961 (goto-char (point-min))
9963 (search-backward "\^_")
9964 (narrow-to-region (point) (point-max))
9965 (goto-char (1+ (point-min)))
9966 (rmail-count-new-messages t)
9967 (rmail-show-message msg)))))))
9968 (kill-buffer tmpbuf)))
9970 (defun gnus-output-to-file (file-name)
9971 "Append the current article to a file named FILE-NAME."
9972 (setq file-name (expand-file-name file-name))
9973 (let ((artbuf (current-buffer))
9974 (tmpbuf (get-buffer-create " *Gnus-output*")))
9977 (buffer-disable-undo (current-buffer))
9979 (insert-buffer-substring artbuf)
9980 ;; Append newline at end of the buffer as separator, and then
9982 (goto-char (point-max))
9984 (append-to-file (point-min) (point-max) file-name))
9985 (kill-buffer tmpbuf)))
9987 (defun gnus-convert-article-to-rmail ()
9988 "Convert article in current buffer to Rmail message format."
9989 (let ((buffer-read-only nil))
9990 ;; Convert article directly into Babyl format.
9991 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
9992 (goto-char (point-min))
9993 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
9994 (while (search-forward "\n\^_" nil t) ;single char
9995 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
9996 (goto-char (point-max))
9999 (defun gnus-narrow-to-page (&optional arg)
10000 "Make text outside current page invisible except for page delimiter.
10001 A numeric arg specifies to move forward or backward by that many pages,
10002 thus showing a page other than the one point was originally in."
10004 (setq arg (if arg (prefix-numeric-value arg) 0))
10006 (forward-page -1) ;Beginning of current page.
10011 (forward-page (1- arg))))
10012 ;; Find the end of the page.
10014 ;; If we stopped due to end of buffer, stay there.
10015 ;; If we stopped after a page delimiter, put end of restriction
10016 ;; at the beginning of that line.
10017 ;; These are commented out.
10018 ;; (if (save-excursion (beginning-of-line)
10019 ;; (looking-at page-delimiter))
10020 ;; (beginning-of-line))
10021 (narrow-to-region (point)
10023 ;; Find the top of the page.
10025 ;; If we found beginning of buffer, stay there.
10026 ;; If extra text follows page delimiter on same line,
10028 ;; Otherwise, show text starting with following line.
10029 (if (and (eolp) (not (bobp)))
10033 (defun gnus-gmt-to-local ()
10034 "Rewrite Date header described in GMT to local in current buffer.
10035 Intended to be used with gnus-article-prepare-hook."
10039 (goto-char (point-min))
10040 (narrow-to-region (point-min)
10041 (progn (search-forward "\n\n" nil 'move) (point)))
10042 (goto-char (point-min))
10043 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
10044 (let ((buffer-read-only nil)
10045 (date (buffer-substring (match-beginning 1) (match-end 1))))
10046 (delete-region (match-beginning 1) (match-end 1))
10048 (timezone-make-date-arpa-standard
10049 date nil (current-time-zone))))))))
10052 ;; Article mode commands
10054 (defun gnus-article-next-page (lines)
10055 "Show next page of current article.
10056 If end of article, return non-nil. Otherwise return nil.
10057 Argument LINES specifies lines to be scrolled up."
10059 (move-to-window-line -1)
10060 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
10061 (if (save-excursion
10063 (and (pos-visible-in-window-p) ;Not continuation line.
10065 ;; Nothing in this page.
10066 (if (or (not gnus-break-pages)
10069 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
10071 (gnus-narrow-to-page 1) ;Go to next page.
10073 ;; More in this page.
10077 ;; Long lines may cause an end-of-buffer error.
10078 (goto-char (point-max))))
10081 (defun gnus-article-prev-page (lines)
10082 "Show previous page of current article.
10083 Argument LINES specifies lines to be scrolled down."
10085 (move-to-window-line 0)
10086 (if (and gnus-break-pages
10088 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
10090 (gnus-narrow-to-page -1) ;Go to previous page.
10091 (goto-char (point-max))
10093 (scroll-down lines)))
10095 (defun gnus-article-refer-article ()
10096 "Read article specified by message-id around point."
10098 (search-forward ">" nil t) ;Move point to end of "<....>".
10099 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
10101 (buffer-substring (match-beginning 1) (match-end 1))))
10102 (set-buffer gnus-summary-buffer)
10103 (gnus-summary-refer-article message-id))
10104 (error "No references around point")))
10106 (defun gnus-article-show-summary ()
10107 "Reconfigure windows to show summary buffer."
10109 (gnus-configure-windows 'article)
10110 (gnus-summary-goto-subject gnus-current-article))
10112 (defun gnus-article-describe-briefly ()
10113 "Describe article mode commands briefly."
10116 (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")))
10118 (defun gnus-article-summary-command ()
10119 "Execute the last keystroke in the summary buffer."
10121 (let ((obuf (current-buffer))
10122 (owin (current-window-configuration))
10124 (switch-to-buffer gnus-summary-buffer 'norecord)
10125 (setq func (lookup-key (current-local-map) (this-command-keys)))
10126 (call-interactively func)
10128 (let ((npoint (point)))
10129 (set-window-configuration owin)
10130 (set-window-start (get-buffer-window (current-buffer)) (point)))))
10132 (defun gnus-article-summary-command-nosave ()
10133 "Execute the last keystroke in the summary buffer."
10135 (let ((obuf (current-buffer))
10136 (owin (current-window-configuration))
10138 (switch-to-buffer gnus-summary-buffer 'norecord)
10139 (setq func (lookup-key (current-local-map) (this-command-keys)))
10140 (call-interactively func)))
10142 ;; caesar-region written by phr@prep.ai.mit.edu Nov 86
10143 ;; Modified by tower@prep Nov 86
10144 ;; Modified by umerin@flab.flab.Fujitsu.JUNET for ROT47.
10146 (defun gnus-caesar-region (&optional n)
10147 "Caesar rotation of region by N, default 13, for decrypting netnews.
10148 ROT47 will be performed for Japanese text in any case."
10149 (interactive (if current-prefix-arg ; Was there a prefix arg?
10150 (list (prefix-numeric-value current-prefix-arg))
10152 (cond ((not (numberp n)) (setq n 13))
10153 (t (setq n (mod n 26)))) ;canonicalize N
10154 (if (not (zerop n)) ; no action needed for a rot of 0
10156 (if (or (not (boundp 'caesar-translate-table))
10157 (not caesar-translate-table)
10158 (/= (aref caesar-translate-table ?a) (+ ?a n)))
10160 (lower "abcdefghijklmnopqrstuvwxyz")
10162 (gnus-message 9 "Building caesar-translate-table...")
10163 (setq caesar-translate-table (make-vector 256 0))
10165 (aset caesar-translate-table i i)
10167 (setq lower (concat lower lower)
10168 upper (upcase lower)
10171 (aset caesar-translate-table (+ ?a i) (aref lower (+ i n)))
10172 (aset caesar-translate-table (+ ?A i) (aref upper (+ i n)))
10174 ;; ROT47 for Japanese text.
10175 ;; Thanks to ichikawa@flab.fujitsu.junet.
10177 (let ((t1 (logior ?O 128))
10178 (t2 (logior ?! 128))
10179 (t3 (logior ?~ 128)))
10181 (aset caesar-translate-table i
10182 (let ((v (aref caesar-translate-table i)))
10183 (if (<= v t1) (if (< v t2) v (+ v 47))
10184 (if (<= v t3) (- v 47) v))))
10186 (gnus-message 9 "Building caesar-translate-table... done")))
10187 (let ((from (region-beginning))
10190 (setq str (buffer-substring from to))
10191 (setq len (length str))
10193 (aset str i (aref caesar-translate-table (aref str i)))
10196 (delete-region from to)
10200 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
10203 (defalias 'gnus-batch-kill 'gnus-batch-score)
10205 (defun gnus-batch-score ()
10206 "Run batched scoring.
10207 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
10208 Newsgroups is a list of strings in Bnews format. If you want to score
10209 the comp hierarchy, you'd say \"comp.all\". If you would not like to
10210 score the alt hierarchy, you'd say \"!alt.all\"."
10213 (gnus-newsrc-parse-options
10214 (apply (function concat)
10215 (mapcar (lambda (g) (concat g " "))
10216 command-line-args-left))))
10217 (gnus-expert-user t)
10218 (nnmail-spool-file nil)
10219 (gnus-use-dribble-file nil)
10220 (yes (car yes-and-no))
10221 (no (cdr yes-and-no))
10222 group subscribed newsrc entry
10223 ;; Disable verbose message.
10224 gnus-novice-user gnus-large-newsgroup)
10225 ;; Eat all arguments.
10226 (setq command-line-args-left nil)
10229 ;; Apply kills to specified newsgroups in command line arguments.
10230 (setq newsrc (cdr gnus-newsrc-alist))
10232 (setq group (car (car newsrc)))
10233 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
10234 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
10236 (or (eq (car entry) t)
10237 (not (zerop (car entry)))))
10238 (if yes (string-match yes group) t)
10239 (or (null no) (not (string-match no group))))
10241 (gnus-summary-read-group group nil t)
10242 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
10243 (gnus-summary-exit))))
10244 (setq newsrc (cdr newsrc)))
10246 (switch-to-buffer gnus-group-buffer)
10247 (gnus-group-save-newsrc)))
10249 (defun gnus-apply-kill-file ()
10250 "Apply a kill file to the current newsgroup.
10251 Returns the number of articles marked as read."
10252 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
10253 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
10254 (gnus-apply-kill-file-internal)
10257 (defun gnus-kill-save-kill-buffer ()
10259 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
10260 (if (get-file-buffer file)
10262 (set-buffer (get-file-buffer file))
10263 (and (buffer-modified-p) (save-buffer))
10264 (kill-buffer (current-buffer)))))))
10266 (defvar gnus-kill-file-name "KILL"
10267 "Suffix of the kill files.")
10269 (defun gnus-newsgroup-kill-file (newsgroup)
10270 "Return the name of a kill file name for NEWSGROUP.
10271 If NEWSGROUP is nil, return the global kill file name instead."
10272 (cond ((or (null newsgroup)
10273 (string-equal newsgroup ""))
10274 ;; The global KILL file is placed at top of the directory.
10275 (expand-file-name gnus-kill-file-name
10276 (or gnus-kill-files-directory "~/News")))
10277 ((gnus-use-long-file-name 'not-kill)
10278 ;; Append ".KILL" to newsgroup name.
10279 (expand-file-name (concat newsgroup "." gnus-kill-file-name)
10280 (or gnus-kill-files-directory "~/News")))
10282 ;; Place "KILL" under the hierarchical directory.
10283 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
10284 "/" gnus-kill-file-name)
10285 (or gnus-kill-files-directory "~/News")))))
10292 (defvar gnus-dribble-ignore nil)
10294 (defun gnus-dribble-file-name ()
10295 (concat gnus-startup-file "-dribble"))
10297 (defun gnus-dribble-open ()
10300 (setq gnus-dribble-buffer (find-file-noselect (gnus-dribble-file-name))))
10301 (buffer-disable-undo (current-buffer))
10302 (bury-buffer gnus-dribble-buffer)
10304 (goto-char (point-max))))
10306 (defun gnus-dribble-enter (string)
10307 (if (and (not gnus-dribble-ignore)
10308 gnus-dribble-buffer
10309 (buffer-name gnus-dribble-buffer))
10310 (let ((obuf (current-buffer)))
10311 (set-buffer gnus-dribble-buffer)
10312 (insert string "\n")
10313 (set-window-point (get-buffer-window (current-buffer)) (point-max))
10314 (set-buffer obuf))))
10316 (defun gnus-dribble-read-file ()
10317 (let ((dribble-file (gnus-dribble-file-name)))
10319 (set-buffer (setq gnus-dribble-buffer
10321 (file-name-nondirectory dribble-file))))
10322 (gnus-add-current-to-buffer-list)
10324 (set-visited-file-name dribble-file)
10325 (buffer-disable-undo (current-buffer))
10326 (bury-buffer (current-buffer))
10327 (set-buffer-modified-p nil)
10328 (let ((auto (make-auto-save-file-name))
10329 (gnus-dribble-ignore t))
10330 (if (or (file-exists-p auto) (file-exists-p dribble-file))
10332 (if (file-newer-than-file-p auto dribble-file)
10333 (setq dribble-file auto))
10334 (insert-file-contents dribble-file)
10335 (if (not (zerop (buffer-size)))
10336 (set-buffer-modified-p t))
10338 "Auto-save file exists. Do you want to read it? ")
10340 (gnus-message 5 "Reading %s..." dribble-file)
10341 (eval-current-buffer)
10342 (gnus-message 5 "Reading %s...done" dribble-file)))))))))
10344 (defun gnus-dribble-delete-file ()
10345 (if (file-exists-p (gnus-dribble-file-name))
10346 (delete-file (gnus-dribble-file-name)))
10347 (if gnus-dribble-buffer
10349 (set-buffer gnus-dribble-buffer)
10350 (let ((auto (make-auto-save-file-name)))
10351 (if (file-exists-p auto)
10352 (delete-file auto))
10354 (set-buffer-modified-p nil)))))
10356 (defun gnus-dribble-save ()
10357 (if (and gnus-dribble-buffer
10358 (buffer-name gnus-dribble-buffer))
10360 (set-buffer gnus-dribble-buffer)
10363 (defun gnus-dribble-clear ()
10365 (if (gnus-buffer-exists-p gnus-dribble-buffer)
10367 (set-buffer gnus-dribble-buffer)
10369 (set-buffer-modified-p nil)
10370 (setq buffer-saved-size (buffer-size))))))
10373 ;;; Server Communication
10376 ;; All the Gnus backends have the same interface, and should return
10377 ;; data in a similar format. Below is an overview of what functions
10378 ;; these packages must supply and what results they should return.
10382 ;; `nntp-server-buffer' - All data should be returned to Gnus in this
10385 ;; Functions for the imaginary backend `choke':
10387 ;; `choke-retrieve-headers ARTICLES &optional GROUP SERVER'
10388 ;; Should return all headers for all ARTICLES, or return NOV lines for
10391 ;; `choke-request-group GROUP &optional SERVER DISCARD'
10392 ;; Switch to GROUP. If DISCARD is nil, active information on the group
10393 ;; must be returned.
10395 ;; `choke-close-group GROUP &optional SERVER'
10396 ;; Close group. Most backends won't have to do anything with this
10397 ;; call, but it is an opportunity to clean up, if that is needed. It
10398 ;; is called when Gnus exits a group.
10400 ;; `choke-request-article ARTICLE &optional GROUP SERVER'
10401 ;; Return ARTICLE, which is either an article number or
10402 ;; message-id. Note that not all backends can return articles based on
10405 ;; `choke-request-list SERVER'
10406 ;; Return a list of all newsgroups on SERVER.
10408 ;; `choke-request-list-newsgroups SERVER'
10409 ;; Return a list of descriptions of all newsgroups on SERVER.
10411 ;; `choke-request-newgroups DATE &optional SERVER'
10412 ;; Return a list of all groups that have arrived after DATE on
10413 ;; SERVER. Note that the date doesn't have to be respected - Gnus will
10414 ;; always check whether the groups are old or not. Backends that do
10415 ;; not store date information may just return the entire list of
10416 ;; groups, although this might not be a good idea in general.
10418 ;; `choke-request-post-buffer METHOD HEADER ARTICLE-BUFFER GROUP INFO'
10419 ;; Should return a buffer that is suitable for "posting". nnspool and
10420 ;; nntp return a `*post-buffer*', and nnmail return a `*mail*'
10421 ;; buffer. This function should fill out the appropriate headers.
10423 ;; `choke-request-post &optional SERVER'
10424 ;; Function that will be called from a buffer to be posted.
10426 ;; `choke-open-server SERVER &optional ARGUMENT'
10427 ;; Open a connection to SERVER.
10429 ;; `choke-close-server &optional SERVER'
10430 ;; Close the connection to SERVER.
10432 ;; `choke-server-opened &optional SERVER'
10433 ;; Whether the conenction to SERVER is opened or not.
10435 ;; `choke-server-status &optional SERVER'
10436 ;; Should return a status string (not in the nntp buffer, but as the
10437 ;; result of the function).
10439 ;; `choke-retrieve-groups GROUPS &optional SERVER'
10440 ;; Optional function for retrieving active file info on all groups in
10441 ;; GROUPS. Two return formats are supported: The normal active file
10442 ;; format, and a list of GROUP lines. This function should return (as
10443 ;; a function value) either `active' or `group', depending on what
10444 ;; format it returns.
10446 ;; The following functions are optional and apply only to backends
10447 ;; that are able to control the contents of their groups totally
10448 ;; (ie. mail backends.) Backends that aren't able to do that
10449 ;; shouldn't define these functions at all. Gnus will check for their
10450 ;; presence before attempting to call them.
10452 ;; `choke-request-expire-articles ARTICLES &optional NEWSGROUP SERVER'
10453 ;; Should expire (according to some aging scheme) all ARTICLES. Most
10454 ;; backends will not be able to expire articles. Should return a list
10455 ;; of all articles that were not expired.
10457 ;; `choke-request-move-article ARTICLE GROUP SERVER ACCEPT-FORM &optional LAST'
10458 ;; Should move ARTICLE from GROUP on SERVER by using ACCEPT-FORM.
10459 ;; Removes any information it has added to the article (extra headers,
10460 ;; whatever - make it as clean as possible), and then passes the
10461 ;; article on by evaling ACCEPT-FORM, which is normally a call to the
10462 ;; function described below. If the ACCEPT-FORM returns a non-nil
10463 ;; value, the article should then be deleted. If LAST is nil, that
10464 ;; means that there will be further calls to this function. This might
10465 ;; be taken as an advice not to save buffers/internal variables just
10466 ;; yet, but wait until the last call to speed things up.
10468 ;; `choke-request-accept-article GROUP &optional LAST'
10469 ;; The contents of the current buffer will be put into GROUP. There
10470 ;; should, of course, be an article in the current buffer. This
10471 ;; function is normally only called by the function described above,
10472 ;; and LAST works the same way as in that function.
10474 ;; `choke-request-replace-article ARTICLE GROUP BUFFER'
10475 ;; Replace ARTICLE in GROUP with the contents of BUFFER.
10476 ;; This provides an easy interface for allowing editing of
10477 ;; articles. Note that even headers may be edited, so the backend has
10478 ;; to update any tables (nov buffers, etc) that it maintains after
10479 ;; replacing the article.
10481 ;; `choke-request-create-group GROUP &optional SERVER'
10482 ;; Create GROUP on SERVER. This might be a new, empty group, or it
10483 ;; might be a group that already exists, but hasn't been registered
10486 ;; All these functions must return nil if they couldn't service the
10487 ;; request. If the optional arguments are not supplied, some "current"
10488 ;; or "default" values should be used. In short, one should emulate an
10489 ;; NNTP server, in a way.
10491 ;; If you want to write a new backend, you just have to supply the
10492 ;; functions listed above. In addition, you must enter the new backend
10493 ;; into the list of valid select methods:
10494 ;; (setq gnus-valid-select-methods
10495 ;; (cons '("choke" mail) gnus-valid-select-methods))
10496 ;; The first element in this list is the name of the backend. Other
10497 ;; elemnets may be `mail' (for mail groups), `post' (for news
10498 ;; groups), `none' (neither), `respool' (for groups that can control
10499 ;; their contents).
10501 (defun gnus-start-news-server (&optional confirm)
10502 "Open a method for getting news.
10503 If CONFIRM is non-nil, the user will be asked for an NNTP server."
10505 (if gnus-current-select-method
10506 ;; Stream is already opened.
10508 ;; Open NNTP server.
10509 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
10512 ;; Read server name with completion.
10513 (setq gnus-nntp-server
10514 (completing-read "NNTP server: "
10515 (mapcar (lambda (server) (list server))
10516 (cons (list gnus-nntp-server)
10517 gnus-secondary-servers))
10518 nil nil gnus-nntp-server))))
10520 (if (and gnus-nntp-server
10521 (stringp gnus-nntp-server)
10522 (not (string= gnus-nntp-server "")))
10523 (setq gnus-select-method
10524 (cond ((or (string= gnus-nntp-server "")
10525 (string= gnus-nntp-server "::"))
10526 (list 'nnspool (system-name)))
10527 ((string-match "^:" gnus-nntp-server)
10528 (list 'nnmh gnus-nntp-server
10529 (list 'nnmh-directory
10530 (file-name-as-directory
10532 (concat "~/" (substring
10533 gnus-nntp-server 1)))))))
10535 (list 'nntp gnus-nntp-server)))))
10537 (setq how (car gnus-select-method))
10538 (setq where (car (cdr gnus-select-method)))
10539 (cond ((eq how 'nnspool)
10541 (gnus-message 5 "Looking up local news spool..."))
10544 (gnus-message 5 "Looking up mh spool..."))
10547 (setq gnus-current-select-method gnus-select-method)
10548 (run-hooks 'gnus-open-server-hook)
10550 ;; gnus-open-server-hook might have opened it
10551 (gnus-server-opened gnus-select-method)
10552 (gnus-open-server gnus-select-method)
10555 "%s server on %s can't be opened. Continue? "
10556 (car gnus-select-method) (nth 1 gnus-select-method)))
10558 (gnus-message 1 "Couldn't open server on %s"
10559 (nth 1 gnus-select-method))
10563 (defun gnus-check-news-server (&optional method)
10564 "If the news server is down, start it up again."
10565 (let ((method (if method method gnus-select-method)))
10566 (and (stringp method)
10567 (setq method (gnus-server-to-method method)))
10568 (if (gnus-server-opened method)
10569 ;; Stream is already opened.
10572 (gnus-message 5 "Opening server %s on %s..." (car method) (nth 1 method))
10573 (run-hooks 'gnus-open-server-hook)
10574 (or (gnus-server-opened method)
10575 (gnus-open-server method))
10578 (defun gnus-nntp-message (&optional message)
10579 "Check the status of the NNTP server.
10580 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
10581 is returned insted of the status string."
10582 (let ((status (gnus-status-message (gnus-find-method-for-group
10583 gnus-newsgroup-name)))
10584 (message (or message "")))
10585 (if (and (stringp status) (> (length status) 0))
10588 (defun gnus-get-function (method function)
10589 (and (stringp method)
10590 (setq method (gnus-server-to-method method)))
10591 (let ((func (intern (format "%s-%s" (car method) function))))
10592 (if (not (fboundp func))
10594 (require (car method))
10595 (if (not (fboundp func))
10596 (error "No such function: %s" func))))
10599 ;;; Interface functions to the backends.
10601 (defun gnus-open-server (method)
10602 (funcall (gnus-get-function method 'open-server)
10603 (nth 1 method) (nthcdr 2 method)))
10605 (defun gnus-close-server (method)
10606 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
10608 (defun gnus-request-list (method)
10609 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
10611 (defun gnus-request-list-newsgroups (method)
10612 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
10614 (defun gnus-request-newgroups (date method)
10615 (funcall (gnus-get-function method 'request-newgroups)
10616 date (nth 1 method)))
10618 (defun gnus-server-opened (method)
10619 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
10621 (defun gnus-status-message (method)
10622 (let ((method (if (stringp method) (gnus-find-method-for-group method)
10624 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
10626 (defun gnus-request-group (group &optional dont-check)
10627 (let ((method (gnus-find-method-for-group group)))
10628 (funcall (gnus-get-function method 'request-group)
10629 (gnus-group-real-name group) (nth 1 method) dont-check)))
10631 (defun gnus-request-asynchronous (group &optional articles)
10632 (let ((method (gnus-find-method-for-group group)))
10633 (funcall (gnus-get-function method 'request-asynchronous)
10634 (gnus-group-real-name group) (nth 1 method) articles)))
10636 (defun gnus-list-active-group (group)
10637 (let ((method (gnus-find-method-for-group group))
10638 (func 'list-active-group))
10639 (and (gnus-check-backend-function func group)
10640 (funcall (gnus-get-function method func)
10641 (gnus-group-real-name group) (nth 1 method)))))
10643 (defun gnus-request-group-description (group)
10644 (let ((method (gnus-find-method-for-group group))
10645 (func 'request-group-description))
10646 (and (gnus-check-backend-function func group)
10647 (funcall (gnus-get-function method func)
10648 (gnus-group-real-name group) (nth 1 method)))))
10650 (defun gnus-close-group (group)
10651 (let ((method (gnus-find-method-for-group group)))
10652 (funcall (gnus-get-function method 'close-group)
10653 (gnus-group-real-name group) (nth 1 method))))
10655 (defun gnus-retrieve-headers (articles group)
10656 (let ((method (gnus-find-method-for-group group)))
10658 (gnus-cache-retrieve-headers articles group)
10659 (funcall (gnus-get-function method 'retrieve-headers)
10660 articles (gnus-group-real-name group) (nth 1 method)))))
10662 (defun gnus-retrieve-groups (groups method)
10663 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
10665 (defun gnus-request-article (article group &optional buffer)
10666 (let ((method (gnus-find-method-for-group group)))
10667 (funcall (gnus-get-function method 'request-article)
10668 article (gnus-group-real-name group) (nth 1 method) buffer)))
10670 (defun gnus-request-head (article group)
10671 (let ((method (gnus-find-method-for-group group)))
10672 (funcall (gnus-get-function method 'request-head)
10673 article (gnus-group-real-name group) (nth 1 method))))
10675 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
10676 (defun gnus-request-post-buffer (post group subject header artbuf
10677 info follow-to respect-poster)
10678 (let* ((info (or info (and group (nth 2 (gnus-gethash
10679 group gnus-newsrc-hashtb)))))
10681 (if (and gnus-post-method
10682 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
10684 (format "%s" (car (gnus-find-method-for-group
10685 gnus-newsgroup-name)))
10686 gnus-valid-select-methods)))
10688 (gnus-find-method-for-group gnus-newsgroup-name))))
10689 (or (gnus-server-opened method)
10690 (gnus-open-server method)
10691 (error "Can't open server %s:%s" (car method) (nth 1 method)))
10692 (let ((mail-self-blind nil)
10693 (mail-archive-file-name nil))
10694 (funcall (gnus-get-function method 'request-post-buffer)
10695 post group subject header artbuf info follow-to
10698 (defun gnus-request-post (method &optional force)
10699 (and (stringp method)
10700 (setq method (gnus-server-to-method method)))
10701 (and (not force) gnus-post-method
10702 (memq 'post (assoc (format "%s" (car method))
10703 gnus-valid-select-methods))
10704 (setq method gnus-post-method))
10705 (funcall (gnus-get-function method 'request-post)
10708 (defun gnus-request-expire-articles (articles group &optional force)
10709 (let ((method (gnus-find-method-for-group group)))
10710 (funcall (gnus-get-function method 'request-expire-articles)
10711 articles (gnus-group-real-name group) (nth 1 method)
10714 (defun gnus-request-move-article
10715 (article group server accept-function &optional last)
10716 (let ((method (gnus-find-method-for-group group)))
10717 (funcall (gnus-get-function method 'request-move-article)
10718 article (gnus-group-real-name group)
10719 (nth 1 method) accept-function last)))
10721 (defun gnus-request-accept-article (group &optional last)
10722 (let ((func (if (symbolp group) group
10723 (car (gnus-find-method-for-group group)))))
10724 (funcall (intern (format "%s-request-accept-article" func))
10725 (if (stringp group) (gnus-group-real-name group) group)
10728 (defun gnus-request-replace-article (article group buffer)
10729 (let ((func (car (gnus-find-method-for-group group))))
10730 (funcall (intern (format "%s-request-replace-article" func))
10731 article (gnus-group-real-name group) buffer)))
10733 (defun gnus-request-create-group (group)
10734 (let ((method (gnus-find-method-for-group group)))
10735 (funcall (gnus-get-function method 'request-create-group)
10736 (gnus-group-real-name group) (nth 1 method))))
10738 (defun gnus-member-of-valid (symbol group)
10739 (memq symbol (assoc
10740 (format "%s" (car (gnus-find-method-for-group group)))
10741 gnus-valid-select-methods)))
10743 (defun gnus-find-method-for-group (group &optional info)
10744 (or gnus-override-method
10746 gnus-select-method)
10747 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
10750 (not (setq method (nth 4 info))))
10751 (setq method gnus-select-method)
10753 (cond ((stringp method)
10754 (gnus-server-to-method method))
10755 ((stringp (car method))
10756 (gnus-server-extend-method group method))
10759 (gnus-server-add-address method))))
10761 (defun gnus-check-backend-function (func group)
10762 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
10764 (fboundp (intern (format "%s-%s" method func)))))
10766 (defun gnus-methods-using (method)
10767 (let ((valids gnus-valid-select-methods)
10770 (if (memq method (car valids))
10771 (setq outs (cons (car valids) outs)))
10772 (setq valids (cdr valids)))
10776 ;;; Active & Newsrc File Handling
10779 ;; Newsrc related functions.
10780 ;; Gnus internal format of gnus-newsrc-alist:
10781 ;; (("alt.general" 3 (1 . 1))
10782 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
10783 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
10784 ;; The first item is the group name; the second is the subscription
10785 ;; level; the third is either a range of a list of ranges of read
10786 ;; articles, the optional fourth element is a list of marked articles,
10787 ;; the optional fifth element is the select method.
10789 ;; Gnus internal format of gnus-newsrc-hashtb:
10790 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
10791 ;; This is the entry for "alt.misc". The first element is the number
10792 ;; of unread articles in "alt.misc". The cdr of this entry is the
10793 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is
10794 ;; trivial to remove or add new elements into gnus-newsrc-alist
10795 ;; without scanning the entire list. So, to get the actual information
10796 ;; of "alt.misc", you'd say something like
10797 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
10799 ;; Gnus internal format of gnus-active-hashtb:
10803 ;; The only element in each entry in this hash table is a range of
10804 ;; (possibly) available articles. (Articles in this range may have
10805 ;; been expired or cancelled.)
10807 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
10808 ;; ("alt.misc" "alt.test" "alt.general" ...)
10810 (defun gnus-setup-news (&optional rawfile level)
10811 "Setup news information.
10812 If RAWFILE is non-nil, the .newsrc file will also be read.
10813 If LEVEL is non-nil, the news will be set up at level LEVEL."
10814 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
10815 ;; Clear some variables to re-initialize news information.
10816 (if init (setq gnus-newsrc-alist nil gnus-active-hashtb nil))
10818 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
10819 (if init (gnus-read-newsrc-file rawfile))
10821 ;; Read the active file and create `gnus-active-hashtb'.
10822 ;; If `gnus-read-active-file' is nil, then we just create an empty
10823 ;; hash table. The partial filling out of the hash table will be
10824 ;; done in `gnus-get-unread-articles'.
10825 (if (and gnus-read-active-file
10827 (gnus-server-opened gnus-select-method))
10828 (gnus-read-active-file)
10829 (setq gnus-active-hashtb (make-vector 4095 0)))
10831 (and init gnus-use-dribble-file (gnus-dribble-read-file))
10833 ;; Find the number of unread articles in each non-dead group.
10834 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed)))
10835 ;; Find new newsgroups and treat them.
10836 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
10837 (gnus-server-opened gnus-select-method))
10838 (gnus-find-new-newsgroups))
10839 (if (and init gnus-check-bogus-newsgroups
10840 gnus-read-active-file (not level)
10841 (gnus-server-opened gnus-select-method))
10842 (gnus-check-bogus-newsgroups))))
10844 (defun gnus-find-new-newsgroups ()
10845 "Search for new newsgroups and add them.
10846 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
10847 The `-n' option line from .newsrc is respected."
10849 (or (gnus-check-first-time-used)
10850 (if (or (consp gnus-check-new-newsgroups)
10851 (eq gnus-check-new-newsgroups 'ask-server))
10852 (gnus-ask-server-for-new-groups)
10854 group new-newsgroups)
10855 (or gnus-have-read-active-file (gnus-read-active-file))
10856 (setq gnus-newsrc-last-checked-date (current-time-string))
10857 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
10858 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
10859 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
10862 (setq group (symbol-name sym))
10863 (if (or (gnus-gethash group gnus-killed-hashtb)
10864 (gnus-gethash group gnus-newsrc-hashtb))
10866 (let ((do-sub (gnus-matches-options-n group)))
10867 (cond ((eq do-sub 'subscribe)
10868 (setq groups (1+ groups))
10869 (gnus-sethash group group gnus-killed-hashtb)
10871 gnus-subscribe-options-newsgroup-method group))
10872 ((eq do-sub 'ignore)
10875 (setq groups (1+ groups))
10876 (gnus-sethash group group gnus-killed-hashtb)
10877 (if gnus-subscribe-hierarchical-interactive
10878 (setq new-newsgroups (cons group new-newsgroups))
10879 (funcall gnus-subscribe-newsgroup-method group)))))))
10880 gnus-active-hashtb)
10882 (gnus-subscribe-hierarchical-interactive new-newsgroups))
10883 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10885 (gnus-message 6 "%d new newsgroup%s arrived."
10886 groups (if (> groups 1) "s have" " has")))))))
10888 (defun gnus-matches-options-n (group)
10889 ;; Returns `subscribe' if the group is to be uncoditionally
10890 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
10891 ;; no match for the group.
10893 ;; First we check the two user variables.
10895 ((and gnus-options-subscribe
10896 (string-match gnus-options-not-subscribe group))
10898 ((and gnus-options-not-subscribe
10899 (string-match gnus-options-subscribe group))
10901 ;; Then we go through the list that was retrieved from the .newsrc
10902 ;; file. This list has elements on the form
10903 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
10904 ;; is in the reverse order of the options line) is returned.
10906 (let ((regs gnus-newsrc-options-n))
10908 (not (string-match (car (car gnus-newsrc-options-n)) group)))
10909 (setq regs (cdr regs)))
10910 (and regs (cdr (car regs)))))))
10912 (defun gnus-ask-server-for-new-groups ()
10913 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
10914 (methods (cons gnus-select-method
10916 (and (consp gnus-check-new-newsgroups)
10917 gnus-check-new-newsgroups)
10918 gnus-secondary-select-methods)))
10920 (new-date (current-time-string))
10921 hashtb group new-newsgroups got-new)
10922 ;; Go thorugh both primary and secondary select methods and
10923 ;; request new newsgroups.
10925 (if (gnus-request-newgroups date (car methods))
10928 (or hashtb (setq hashtb (gnus-make-hashtable
10929 (count-lines (point-min) (point-max)))))
10930 (set-buffer nntp-server-buffer)
10931 ;; Enter all the new groups in a hashtable.
10932 (gnus-active-to-gnus-format (car methods) hashtb)))
10933 (setq methods (cdr methods)))
10934 (and got-new (setq gnus-newsrc-last-checked-date new-date))
10935 ;; Now all new groups from all select methods are in `hashtb'.
10937 (lambda (group-sym)
10938 (setq group (symbol-name group-sym))
10939 (if (or (gnus-gethash group gnus-newsrc-hashtb)
10940 (member group gnus-zombie-list)
10941 (member group gnus-killed-list))
10942 ;; The group is already known.
10944 (gnus-sethash group (symbol-value group-sym) gnus-active-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)))))))
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")))
10968 (defun gnus-check-first-time-used ()
10969 (if (or (> (length gnus-newsrc-alist) 1)
10970 (file-exists-p gnus-startup-file)
10971 (file-exists-p (concat gnus-startup-file ".el"))
10972 (file-exists-p (concat gnus-startup-file ".eld")))
10974 (gnus-message 6 "First time user; subscribing you to default groups")
10975 (or gnus-have-read-active-file (gnus-read-active-file))
10976 (setq gnus-newsrc-last-checked-date (current-time-string))
10977 (let ((groups gnus-default-subscribed-newsgroups)
10981 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
10984 (setq group (symbol-name sym))
10985 (let ((do-sub (gnus-matches-options-n group)))
10986 (cond ((eq do-sub 'subscribe)
10987 (gnus-sethash group group gnus-killed-hashtb)
10989 gnus-subscribe-options-newsgroup-method group))
10990 ((eq do-sub 'ignore)
10993 (setq gnus-killed-list (cons group gnus-killed-list))))))
10994 gnus-active-hashtb)
10996 (if (gnus-gethash (car groups) gnus-active-hashtb)
10997 (gnus-group-change-level
10998 (car groups) gnus-level-default-subscribed gnus-level-killed))
10999 (setq groups (cdr groups)))
11000 (gnus-group-make-help-group)
11001 (and gnus-novice-user
11002 (gnus-message 7 "`A k' to list killed groups"))))))
11004 ;; `gnus-group-change-level' is the fundamental function for changing
11005 ;; subscription levels of newsgroups. This might mean just changing
11006 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
11007 ;; again, which subscribes/unsubscribes a group, which is equally
11008 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
11009 ;; from 8-9 to 1-7 means that you remove the group from the list of
11010 ;; killed (or zombie) groups and add them to the (kinda) subscribed
11011 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
11012 ;; which is trivial.
11013 ;; ENTRY can either be a string (newsgroup name) or a list (if
11014 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
11015 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
11017 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
11018 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
11020 (defun gnus-group-change-level (entry level &optional oldlevel
11021 previous fromkilled)
11022 (let ((pinfo entry)
11023 group info active num)
11024 ;; Glean what info we can from the arguments
11026 (if fromkilled (setq group (nth 1 entry))
11027 (setq group (car (nth 2 entry))))
11028 (setq group entry))
11029 (if (and (stringp entry)
11031 (< oldlevel gnus-level-zombie))
11032 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
11033 (if (and (not oldlevel)
11035 (setq oldlevel (car (cdr (nth 2 entry)))))
11036 (if (stringp previous)
11037 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
11039 (gnus-dribble-enter
11040 (format "(gnus-group-change-level %S %S %S %S %S)"
11041 group level oldlevel (car (nth 2 previous)) fromkilled))
11043 ;; Then we remove the newgroup from any old structures, if needed.
11044 ;; If the group was killed, we remove it from the killed or zombie
11045 ;; list. If not, and it is in fact going to be killed, we remove
11046 ;; it from the newsrc hash table and assoc.
11047 (cond ((>= oldlevel gnus-level-zombie)
11048 (if (= oldlevel gnus-level-zombie)
11049 (setq gnus-zombie-list (delete group gnus-zombie-list))
11050 (setq gnus-killed-list (delete group gnus-killed-list))))
11052 (if (>= level gnus-level-zombie)
11054 (gnus-sethash (car (nth 2 entry))
11055 nil gnus-newsrc-hashtb)
11057 (setcdr (gnus-gethash (car (nth 3 entry))
11058 gnus-newsrc-hashtb)
11060 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
11062 ;; Finally we enter (if needed) the list where it is supposed to
11063 ;; go, and change the subscription level. If it is to be killed,
11064 ;; we enter it into the killed or zombie list.
11065 (cond ((>= level gnus-level-zombie)
11066 (and (string= group (gnus-group-real-name group))
11067 (if (= level gnus-level-zombie)
11068 (setq gnus-zombie-list (cons group gnus-zombie-list))
11069 (setq gnus-killed-list (cons group gnus-killed-list)))))
11071 ;; If the list is to be entered into the newsrc assoc, and
11072 ;; it was killed, we have to create an entry in the newsrc
11073 ;; hashtb format and fix the pointers in the newsrc assoc.
11074 (if (>= oldlevel gnus-level-zombie)
11078 (setq info (cdr entry))
11079 (setq num (car entry)))
11080 (setq active (gnus-gethash group gnus-active-hashtb))
11081 (setq num (if active (- (1+ (cdr active)) (car active)) t))
11082 ;; Check whether the group is foreign. If so, the
11083 ;; foreign select method has to be entered into the
11085 (let ((method (gnus-group-method-name group)))
11086 (if (eq method gnus-select-method)
11087 (setq info (list group level nil))
11088 (setq info (list group level nil nil method)))))
11091 (let ((p gnus-newsrc-alist))
11092 (while (cdr (cdr p))
11095 (setq entry (cons info (cdr (cdr previous))))
11098 (setcdr (cdr previous) entry)
11099 (gnus-sethash group (cons num (cdr previous))
11100 gnus-newsrc-hashtb))
11101 (setcdr previous entry)
11102 (gnus-sethash group (cons num previous)
11103 gnus-newsrc-hashtb))
11105 (setcdr (gnus-gethash (car (car (cdr entry)))
11106 gnus-newsrc-hashtb)
11108 ;; It was alive, and it is going to stay alive, so we
11109 ;; just change the level and don't change any pointers or
11110 ;; hash table entries.
11111 (setcar (cdr (car (cdr (cdr entry)))) level))))))
11113 (defun gnus-kill-newsgroup (newsgroup)
11114 "Obsolete function. Kills a newsgroup."
11115 (gnus-group-change-level
11116 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
11118 (defun gnus-check-bogus-newsgroups (&optional confirm)
11119 "Remove bogus newsgroups.
11120 If CONFIRM is non-nil, the user has to confirm the deletion of every
11122 (let ((newsrc (cdr gnus-newsrc-alist))
11124 (gnus-message 5 "Checking bogus newsgroups...")
11125 (or gnus-have-read-active-file (gnus-read-active-file))
11126 ;; Find all bogus newsgroup that are subscribed.
11128 (setq group (car (car newsrc)))
11129 (if (or (gnus-gethash group gnus-active-hashtb)
11130 (nth 4 (car newsrc))
11132 (not (gnus-y-or-n-p
11133 (format "Remove bogus newsgroup: %s " group)))))
11134 ;; Active newsgroup.
11136 ;; Found a bogus newsgroup.
11137 (setq bogus (cons group bogus)))
11138 (setq newsrc (cdr newsrc)))
11139 ;; Remove all bogus subscribed groups by first killing them, and
11140 ;; then removing them from the list of killed groups.
11142 (gnus-group-change-level
11143 (gnus-gethash (car bogus) gnus-newsrc-hashtb) gnus-level-killed)
11144 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))
11145 (setq bogus (cdr bogus)))
11146 ;; Then we remove all bogus groups from the list of killed and
11147 ;; zombie groups. They are are removed without confirmation.
11148 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
11151 (setq killed (symbol-value (car dead-lists)))
11153 (setq group (car killed))
11154 (or (gnus-gethash group gnus-active-hashtb)
11155 ;; The group is bogus.
11156 (set (car dead-lists)
11157 (delete group (symbol-value (car dead-lists)))))
11158 (setq killed (cdr killed)))
11159 (setq dead-lists (cdr dead-lists))))
11160 (gnus-message 5 "Checking bogus newsgroups... done")))
11162 (defun gnus-check-duplicate-killed-groups ()
11163 "Remove duplicates from the list of killed groups."
11165 (let ((killed gnus-killed-list))
11167 (gnus-message 9 "%d" (length killed))
11168 (setcdr killed (delete (car killed) (cdr killed)))
11169 (setq killed (cdr killed)))))
11171 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
11172 ;; and compute how many unread articles there are in each group.
11173 (defun gnus-get-unread-articles (&optional level)
11174 (let* ((newsrc (cdr gnus-newsrc-alist))
11175 (conditional level)
11176 (level (or level (1+ gnus-level-subscribed)))
11177 info group active virtuals method)
11178 (gnus-message 5 "Checking new news...")
11180 (setq info (car newsrc))
11181 (setq group (car info))
11182 (setq active (gnus-gethash group gnus-active-hashtb))
11184 ;; Check newsgroups. If the user doesn't want to check them, or
11185 ;; they can't be checked (for instance, if the news server can't
11186 ;; be reached) we just set the number of unread articles in this
11187 ;; newsgroup to t. This means that Gnus thinks that there are
11188 ;; unread articles, but it has no idea how many.
11189 (if (and (setq method (nth 4 info))
11190 (not (gnus-server-equal gnus-select-method
11191 (gnus-server-get-method nil method))))
11192 (if (or (and gnus-activate-foreign-newsgroups
11193 (not (numberp gnus-activate-foreign-newsgroups)))
11194 (and (numberp gnus-activate-foreign-newsgroups)
11195 (<= (nth 1 info) gnus-activate-foreign-newsgroups)
11196 (<= (nth 1 info) level)))
11197 (if (eq (car (if (stringp method)
11198 (gnus-server-to-method method)
11199 (nth 4 info))) 'nnvirtual)
11200 (setq virtuals (cons info virtuals))
11201 (setq active (gnus-activate-newsgroup (car info)))))
11202 (if (and (not gnus-read-active-file)
11203 (<= (nth 1 info) level))
11205 (setq active (gnus-activate-newsgroup (car info))))))
11207 (or active (progn (gnus-sethash group nil gnus-active-hashtb)
11208 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
11210 (gnus-get-unread-articles-in-group info active)
11211 ;; Close the groups as we look at them!
11212 (gnus-close-group group))
11213 (setq newsrc (cdr newsrc)))
11215 ;; Activate the virtual groups. This has to be done after all the
11217 ;; !!! If one virtual group contains another virtual group, even
11218 ;; doing it this way might cause problems.
11220 (and (setq active (gnus-activate-newsgroup (car (car virtuals))))
11221 (gnus-get-unread-articles-in-group (car virtuals) active))
11222 (setq virtuals (cdr virtuals)))
11224 (gnus-message 5 "Checking new news... done")))
11226 ;; Create a hash table out of the newsrc alist. The `car's of the
11227 ;; alist elements are used as keys.
11228 (defun gnus-make-hashtable-from-newsrc-alist ()
11229 (let ((alist gnus-newsrc-alist)
11231 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
11233 (setq prev (setq gnus-newsrc-alist
11234 (cons (list "dummy.group" 0 nil) alist))))
11236 (gnus-sethash (car (car alist)) (cons nil prev) gnus-newsrc-hashtb)
11238 (setq alist (cdr alist)))))
11240 (defun gnus-make-hashtable-from-killed ()
11241 "Create a hash table from the killed and zombie lists."
11242 (let ((lists '(gnus-killed-list gnus-zombie-list))
11244 (setq gnus-killed-hashtb
11245 (gnus-make-hashtable
11246 (+ (length gnus-killed-list) (length gnus-zombie-list))))
11248 (setq list (symbol-value (car lists)))
11249 (setq lists (cdr lists))
11251 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
11252 (setq list (cdr list))))))
11254 (defun gnus-get-unread-articles-in-group (info active)
11255 (let* ((range (nth 2 info))
11257 (marked (nth 3 info))
11258 srange lowest group highest)
11259 ;; If a cache is present, we may have to alter the active info.
11260 (and gnus-use-cache
11261 (gnus-cache-possibly-alter-active (car info) active))
11262 ;; Modify the list of read articles according to what articles
11263 ;; are available; then tally the unread articles and add the
11264 ;; number to the group hash table entry.
11265 (cond ((zerop (cdr active))
11268 (setq num (- (1+ (cdr active)) (car active))))
11269 ((not (listp (cdr range)))
11270 ;; Fix a single (num . num) range according to the
11271 ;; active hash table.
11272 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
11273 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
11274 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
11275 ;; Compute number of unread articles.
11276 (setq num (max 0 (- (cdr active)
11277 (- (1+ (cdr range)) (car range))))))
11279 ;; The read list is a list of ranges. Fix them according to
11280 ;; the active hash table.
11281 ;; First peel off any elements that are below the lower
11283 (while (and (cdr range)
11285 (or (and (atom (car (cdr range))) (car (cdr range)))
11286 (car (car (cdr range))))))
11287 (if (numberp (car range))
11290 (or (and (numberp (car (cdr range)))
11292 (cdr (car (cdr range))))))
11293 (setcdr (car range)
11294 (or (and (numberp (nth 1 range)) (nth 1 range))
11295 (cdr (car (cdr range))))))
11296 (setcdr range (cdr (cdr range))))
11297 ;; Adjust the first element to be the same as the lower limit.
11298 (if (and (not (atom (car range)))
11299 (< (cdr (car range)) (car active)))
11300 (setcdr (car range) (1- (car active))))
11301 ;; Then we want to peel off any elements that are higher
11302 ;; than the upper active limit.
11303 (let ((srange range))
11304 ;; Go past all legal elements.
11305 (while (and (cdr srange)
11306 (<= (or (and (atom (car (cdr srange)))
11307 (car (cdr srange)))
11308 (car (car (cdr srange)))) (cdr active)))
11309 (setq srange (cdr srange)))
11311 ;; Nuke all remaining illegal elements.
11312 (setcdr srange nil))
11314 ;; Adjust the final element.
11315 (if (and (not (atom (car srange)))
11316 (> (cdr (car srange)) (cdr active)))
11317 (setcdr (car srange) (cdr active))))
11318 ;; Compute the number of unread articles.
11320 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
11321 (cdr (car range))))
11322 (or (and (atom (car range)) (car range))
11323 (car (car range))))))
11324 (setq range (cdr range)))
11325 (setq num (max 0 (- (cdr active) num)))))
11328 (and (assq 'tick marked)
11329 (inline (gnus-remove-illegal-marked-articles
11330 (assq 'tick marked) (nth 2 info))))
11331 (and (assq 'dormant marked)
11332 (inline (gnus-remove-illegal-marked-articles
11333 (assq 'dormant marked) (nth 2 info))))
11335 (gnus-gethash (car info) gnus-newsrc-hashtb)
11336 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
11337 (length (cdr (assq 'dormant marked)))))))))
11340 (defun gnus-remove-illegal-marked-articles (marked ranges)
11341 (let ((m (cdr marked)))
11342 ;; Make sure that all ticked articles are a subset of the unread
11345 (if (gnus-member-of-range (car m) ranges)
11346 (setcdr marked (cdr m))
11348 (setq m (cdr m)))))
11350 (defun gnus-activate-newsgroup (group)
11351 (let ((method (gnus-find-method-for-group group))
11353 (and (or (gnus-server-opened method) (gnus-open-server method))
11354 (gnus-request-group group)
11356 (set-buffer nntp-server-buffer)
11357 (goto-char (point-min))
11358 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
11360 (goto-char (match-beginning 1))
11362 group (setq active (cons (read (current-buffer))
11363 (read (current-buffer))))
11364 gnus-active-hashtb))
11367 (defun gnus-update-read-articles
11368 (group unread unselected ticked &optional domarks replied expirable killed
11369 dormant bookmark score)
11370 "Update the list of read and ticked articles in GROUP using the
11371 UNREAD and TICKED lists.
11372 Note: UNSELECTED has to be sorted over `<'.
11373 Returns whether the updating was successful."
11374 (let* ((active (or gnus-newsgroup-active
11375 (gnus-gethash group gnus-active-hashtb)))
11376 (entry (gnus-gethash group gnus-newsrc-hashtb))
11377 (number (car entry))
11378 (info (nth 2 entry))
11379 (marked (nth 3 info))
11381 (unread (sort (copy-sequence unread) (function <)))
11383 (if (or (not info) (not active))
11384 ;; There is no info on this group if it was, in fact,
11385 ;; killed. Gnus stores no information on killed groups, so
11386 ;; there's nothing to be done.
11387 ;; One could store the information somewhere temporarily,
11388 ;; perhaps... Hmmm...
11390 ;; Remove any negative articles numbers.
11391 (while (and unread (< (car unread) 0))
11392 (setq unread (cdr unread)))
11393 (setq unread (sort (append unselected unread) '<))
11394 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11395 (setcar entry (max 0 (- (length unread) (length ticked)
11396 (length dormant))))
11397 ;; Compute the ranges of read articles by looking at the list of
11398 ;; unread articles.
11400 (if (/= (car unread) prev)
11401 (setq read (cons (if (= prev (1- (car unread))) prev
11402 (cons prev (1- (car unread)))) read)))
11403 (setq prev (1+ (car unread)))
11404 (setq unread (cdr unread)))
11405 (if (<= prev (cdr active))
11406 (setq read (cons (cons prev (cdr active)) read)))
11407 ;; Enter this list into the group info.
11408 (setcar (cdr (cdr info))
11409 (if (> (length read) 1) (nreverse read) read))
11410 ;; Enter the list of ticked articles.
11411 (gnus-set-marked-articles
11413 (if domarks replied (cdr (assq 'reply marked)))
11414 (if domarks expirable (cdr (assq 'expire marked)))
11415 (if domarks killed (cdr (assq 'killed marked)))
11416 (if domarks dormant (cdr (assq 'dormant marked)))
11417 (if domarks bookmark (cdr (assq 'bookmark marked)))
11418 (if domarks score (cdr (assq 'score marked))))
11421 (defun gnus-make-articles-unread (group articles)
11422 "Mark ARTICLES in GROUP as unread."
11423 (let ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
11424 (gnus-gethash (gnus-group-real-name group)
11425 gnus-newsrc-hashtb)))))
11426 (setcar (nthcdr 2 info)
11427 (gnus-remove-from-range (nth 2 info) articles))
11428 (gnus-group-update-group group t)))
11430 (defun gnus-read-active-file ()
11431 "Get active file from NNTP server."
11432 (gnus-group-set-mode-line)
11433 (let ((methods (cons gnus-select-method gnus-secondary-select-methods))
11436 (setq gnus-have-read-active-file nil)
11438 (set-buffer nntp-server-buffer)
11440 (let* ((where (nth 1 (car methods)))
11441 (mesg (format "Reading active file%s via %s..."
11442 (if (and where (not (zerop (length where))))
11443 (concat " from " where) "")
11444 (car (car methods)))))
11445 (gnus-message 5 mesg)
11446 (gnus-check-news-server (car methods))
11448 ((and (eq gnus-read-active-file 'some)
11449 (gnus-check-backend-function
11450 'retrieve-groups (car (car methods))))
11451 (let ((newsrc (cdr gnus-newsrc-alist))
11454 (and (gnus-server-equal
11455 (gnus-find-method-for-group
11456 (car (car newsrc)) (car newsrc))
11457 (gnus-server-get-method nil (car methods)))
11458 (setq groups (cons (car (car newsrc)) groups)))
11459 (setq newsrc (cdr newsrc)))
11460 (setq list-type (gnus-retrieve-groups groups (car methods)))
11461 (cond ((not list-type)
11463 1 "Cannot read partial active file from %s server."
11464 (car (car methods)))
11467 ((eq list-type 'active)
11468 (gnus-active-to-gnus-format (and not-first (car methods)))
11469 (setq not-first t))
11471 (gnus-groups-to-gnus-format (and not-first (car methods)))
11472 (setq not-first t)))))
11474 (if (not (gnus-request-list (car methods)))
11476 (gnus-message 1 "Cannot read active file from %s server."
11477 (car (car methods)))
11479 (gnus-active-to-gnus-format
11480 (and gnus-have-read-active-file (car methods)))
11481 (setq gnus-have-read-active-file t)
11482 (gnus-message 5 "%s...done" mesg)))))
11483 (setq methods (cdr methods))))))
11485 ;; Read an active file and place the results in `gnus-active-hashtb'.
11486 (defun gnus-active-to-gnus-format (method &optional hashtb)
11487 (let ((cur (current-buffer))
11491 (setq gnus-active-hashtb
11492 (gnus-make-hashtable
11493 (count-lines (point-min) (point-max))))))))
11494 ;; Delete unnecessary lines.
11495 (goto-char (point-min))
11496 (while (search-forward "\nto." nil t)
11497 (delete-region (match-beginning 0) (progn (forward-line 1) (point))))
11498 (or (string= gnus-ignored-newsgroups "")
11500 (goto-char (point-min))
11501 (delete-matching-lines gnus-ignored-newsgroups)))
11502 (and method (not (eq method gnus-select-method))
11503 (let ((prefix (gnus-group-prefixed-name "" method)))
11504 (goto-char (point-min))
11505 (while (and (not (eobp))
11506 (null (insert prefix))
11507 (zerop (forward-line 1))))))
11508 (goto-char (point-min))
11509 ;; Store active file in hashtable.
11510 (goto-char (point-min))
11511 (if (string-match "%[oO]" gnus-group-line-format)
11512 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
11513 ;; If we want information on moderated groups, we use this
11515 (let* ((mod-hashtb (make-vector 7 0))
11516 (m (intern "m" mod-hashtb))
11518 (while (not (eobp))
11519 (condition-case nil
11521 (narrow-to-region (point) (gnus-point-at-eol))
11522 (setq group (let ((obarray hashtb)) (read cur)))
11523 (setq max (read cur))
11524 (set group (cons (read cur) max))
11525 ;; Enter moderated groups into a list.
11526 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
11527 (setq gnus-moderated-list
11528 (cons (symbol-name group) gnus-moderated-list))))
11532 ;; And if we do not care about moderation, we use this loop,
11533 ;; which is faster.
11535 (while (not (eobp))
11538 (narrow-to-region (point) (gnus-point-at-eol))
11539 ;; group gets set to a symbol interned in the hash table
11541 (setq group (let ((obarray hashtb)) (read cur)))
11542 (setq max (read cur))
11543 (set group (cons (read cur) max)))
11546 (gnus-message 3 "Illegal active: %s"
11548 (gnus-point-at-bol) (gnus-point-at-eol)))
11551 (forward-line 1))))))
11553 (defun gnus-groups-to-gnus-format (method &optional hashtb)
11554 ;; Parse a "groups" active file.
11555 (let ((cur (current-buffer))
11559 (setq gnus-active-hashtb
11560 (gnus-make-hashtable
11561 (count-lines (point-min) (point-max)))))))
11562 (prefix (and method (not (eq method gnus-select-method))
11563 (gnus-group-prefixed-name "" method))))
11565 (goto-char (point-min))
11567 ;; We split this into to separate loops, one with the prefix
11568 ;; and one without to speed the reading up somewhat.
11570 (let (min max opoint)
11571 (while (not (eobp))
11572 (read cur) (read cur)
11573 (setq min (read cur)
11576 (skip-chars-forward " \t")
11579 (set (let ((obarray hashtb)) (read cur))
11582 (let (min max opoint)
11583 (while (not (eobp))
11584 (if (= (following-char) ?2)
11586 (read cur) (read cur)
11587 (setq min (read cur)
11589 (set (let ((obarray hashtb)) (read cur))
11591 (forward-line 1))))
11593 (progn (ding) (gnus-message 3 "Possible error in active file."))))))
11595 (defun gnus-read-newsrc-file (&optional force)
11596 "Read startup file.
11597 If FORCE is non-nil, the .newsrc file is read."
11598 (setq gnus-current-startup-file (gnus-make-newsrc-file gnus-startup-file))
11599 ;; Reset variables that might be defined in the .newsrc.eld file.
11600 (let ((variables gnus-variable-list))
11602 (set (car variables) nil)
11603 (setq variables (cdr variables))))
11604 (let* ((newsrc-file gnus-current-startup-file)
11605 (quick-file (concat newsrc-file ".el")))
11607 ;; We always load the .newsrc.eld file. If always contains
11608 ;; much information that can not be gotten from the .newsrc
11609 ;; file (ticked articles, killed groups, foreign methods, etc.)
11610 (gnus-read-newsrc-el-file quick-file)
11613 (and (file-newer-than-file-p newsrc-file quick-file)
11614 (file-newer-than-file-p newsrc-file
11615 (concat quick-file "d")))
11616 (not gnus-newsrc-alist))
11617 ;; We read the .newsrc file. Note that if there if a
11618 ;; .newsrc.eld file exists, it has already been read, and
11619 ;; the `gnus-newsrc-hashtb' has been created. While reading
11620 ;; the .newsrc file, Gnus will only use the information it
11621 ;; can find there for changing the data already read -
11622 ;; ie. reading the .newsrc file will not trash the data
11623 ;; already read (except for read articles).
11625 (gnus-message 5 "Reading %s..." newsrc-file)
11626 (set-buffer (find-file-noselect newsrc-file))
11627 (buffer-disable-undo (current-buffer))
11628 (gnus-newsrc-to-gnus-format)
11629 (kill-buffer (current-buffer))
11630 (gnus-message 5 "Reading %s... done" newsrc-file))))))
11632 (defun gnus-read-newsrc-el-file (file)
11633 (let ((ding-file (concat file "d")))
11634 ;; We always, always read the .eld file.
11635 (gnus-message 5 "Reading %s..." ding-file)
11636 (let (gnus-newsrc-assoc)
11637 (condition-case nil
11638 (load ding-file t t t)
11640 (and gnus-newsrc-assoc (setq gnus-newsrc-alist gnus-newsrc-assoc)))
11641 (let ((inhibit-quit t))
11642 (gnus-uncompress-newsrc-assoc))
11643 (gnus-make-hashtable-from-newsrc-alist)
11644 (if (not (file-newer-than-file-p file ding-file))
11646 ;; Old format quick file
11647 (gnus-message 5 "Reading %s..." file)
11648 ;; The .el file is newer than the .eld file, so we read that one
11650 (gnus-read-old-newsrc-el-file file))))
11652 ;; Parse the old-style quick startup file
11653 (defun gnus-read-old-newsrc-el-file (file)
11654 (let (newsrc killed marked group g m len info)
11656 (let ((gnus-killed-assoc nil)
11657 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
11659 (condition-case nil
11662 (setq newsrc gnus-newsrc-assoc
11663 killed gnus-killed-assoc
11664 marked gnus-marked-assoc)))
11665 (setq gnus-newsrc-alist nil)
11667 (setq group (car newsrc))
11668 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
11671 (setcar (nthcdr 2 info) (cdr (cdr group)))
11673 (if (nth 1 group) gnus-level-default-subscribed
11674 gnus-level-default-unsubscribed))
11675 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
11676 (setq gnus-newsrc-alist
11680 (if (nth 1 group) gnus-level-default-subscribed
11681 gnus-level-default-unsubscribed)
11682 (cdr (cdr group))))
11683 gnus-newsrc-alist)))
11684 (if (setq m (assoc (car group) marked))
11685 (setcdr (cdr (cdr info)) (cons (list (cons 'tick (cdr m))) nil))))
11686 (setq newsrc (cdr newsrc)))
11687 (setq newsrc killed)
11689 (setcar newsrc (car (car newsrc)))
11690 (setq newsrc (cdr newsrc)))
11691 (setq gnus-killed-list killed))
11692 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
11693 (gnus-make-hashtable-from-newsrc-alist)))
11695 (defun gnus-make-newsrc-file (file)
11696 "Make server dependent file name by catenating FILE and server host name."
11697 (let* ((file (expand-file-name file nil))
11698 (real-file (concat file "-" (nth 1 gnus-select-method))))
11699 (if (file-exists-p real-file)
11702 (defun gnus-uncompress-newsrc-assoc ()
11703 ;; Uncompress all lists of marked articles in the newsrc assoc.
11704 (let ((newsrc gnus-newsrc-alist)
11707 (if (not (setq marked (nth 3 (car newsrc))))
11710 (or (eq 'score (car (car marked)))
11711 (eq 'bookmark (car (car marked)))
11712 (eq 'killed (car (car marked)))
11713 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
11714 (setq marked (cdr marked))))
11715 (setq newsrc (cdr newsrc)))))
11717 (defun gnus-compress-newsrc-assoc ()
11718 ;; Compress all lists of marked articles in the newsrc assoc.
11719 (let ((newsrc gnus-newsrc-alist)
11722 (if (not (setq marked (nth 3 (car newsrc))))
11725 (or (eq 'score (car (car marked)))
11726 (eq 'bookmark (car (car marked)))
11727 (eq 'killed (car (car marked)))
11728 (setcdr (car marked)
11729 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
11730 (setq marked (cdr marked))))
11731 (setq newsrc (cdr newsrc)))))
11733 (defun gnus-newsrc-to-gnus-format ()
11734 (setq gnus-newsrc-options "")
11735 (or gnus-active-hashtb
11736 (setq gnus-active-hashtb (make-vector 4095 0)))
11737 (let ((buf (current-buffer))
11738 (already-read (> (length gnus-newsrc-alist) 1))
11739 group level subscribed info options-symbol newsrc
11741 (goto-char (point-min))
11742 ;; We intern the symbol `options' in the active hashtb so that we
11743 ;; can `eq' against it later.
11744 (setq options-symbol (intern "options" gnus-active-hashtb))
11746 (while (not (eobp))
11747 ;; We first read the first word on the line by narrowing and
11748 ;; then reading into `gnus-active-hashtb'. Most groups will
11749 ;; already exist in that hashtb, so this will save some string
11753 (progn (skip-chars-forward "^ \t!:\n") (point)))
11754 (goto-char (point-min))
11756 (and (/= (point-min) (point-max))
11757 (let ((obarray gnus-active-hashtb)) (read buf))))
11759 ;; Now, the symbol we have read is either `options' or a group
11760 ;; name. If it is an options line, we just add it to a string.
11762 ((eq symbol options-symbol)
11763 (setq gnus-newsrc-options
11764 ;; This concatting is quite inefficient, but since our
11765 ;; thorough studies show that approx 99.37% of all
11766 ;; .newsrc files only contain a single options line, we
11767 ;; don't give a damn, frankly, my dear.
11768 (concat gnus-newsrc-options
11770 (gnus-point-at-bol)
11771 ;; Options may continue on the next line.
11772 (or (and (re-search-forward "^[^ \t]" nil 'move)
11773 (progn (beginning-of-line) (point)))
11776 ;; It was a group name.
11777 (setq subscribed (= (following-char) ?:)
11778 group (symbol-name symbol)
11781 ;; If the line ends here, this is clearly a buggy line, so
11782 ;; we put point a the beginning of line and let the cond
11783 ;; below do the error handling.
11784 (beginning-of-line)
11785 ;; We skip to the beginning of the ranges.
11786 (skip-chars-forward "!: \t"))
11787 ;; We are now at the beginning of the list of read articles.
11788 ;; We read them range by range.
11791 ((looking-at "[0-9]+")
11792 ;; We narrow and read a number instead of buffer-substring/
11793 ;; string-to-int because it's faster. narrow/widen is
11794 ;; faster than save-restriction/narrow, and save-restriction
11795 ;; produces a garbage object.
11797 (narrow-to-region (match-beginning 0) (match-end 0))
11800 ;; If the next character is a dash, then this is a range.
11801 (if (= (following-char) ?-)
11803 ;; We read the upper bound of the range.
11805 (if (not (looking-at "[0-9]+"))
11806 ;; This is a buggy line, by we pretend that
11807 ;; it's kinda OK. Perhaps the user should be
11809 (setq reads (cons num1 reads))
11813 (narrow-to-region (match-beginning 0)
11818 ;; It was just a simple number, so we add it to the
11820 (setq reads (cons num1 reads)))
11821 ;; If the next char in ?\n, then we have reached the end
11822 ;; of the line and return nil.
11823 (/= (following-char) ?\n))
11824 ((= (following-char) ?\n)
11825 ;; End of line, so we end.
11828 ;; Not numbers and not eol, so this might be a buggy
11830 (or (eobp) ; If it was eob instead of ?\n, we allow it.
11832 ;; The line was buggy.
11834 (gnus-message 3 "Mangled line: %s"
11835 (buffer-substring (gnus-point-at-bol)
11836 (gnus-point-at-eol)))
11840 ;; Skip past ", ". Spaces are illegal in these ranges, but
11841 ;; we allow them, because it's a common mistake to put a
11842 ;; space after the comma.
11843 (skip-chars-forward ", "))
11845 ;; We have already read .newsrc.eld, so we gently update the
11846 ;; data in the hash table with the information we have just
11850 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
11853 ;; There is an entry for this file in the alist.
11855 (setcar (nthcdr 2 info) (nreverse reads))
11856 ;; We update the level very gently. In fact, we
11857 ;; only change it if there's been a status change
11858 ;; from subscribed to unsubscribed, or vice versa.
11859 (setq level (nth 1 info))
11860 (cond ((and (<= level gnus-level-subscribed)
11862 (setq level (if reads
11863 gnus-level-default-unsubscribed
11864 (1+ gnus-level-default-unsubscribed))))
11865 ((and (> level gnus-level-subscribed) subscribed)
11866 (setq level gnus-level-default-subscribed)))
11867 (setcar (cdr info) level))
11868 ;; This is a new group.
11869 (setq info (list group
11871 gnus-level-default-subscribed
11873 (1+ gnus-level-subscribed)
11874 gnus-level-default-unsubscribed))
11875 (nreverse reads))))
11876 (setq newsrc (cons info newsrc))))
11877 (forward-line 1))))
11879 (setq newsrc (nreverse newsrc))
11881 (if (not already-read)
11883 ;; We now have two newsrc lists - `newsrc', which is what we
11884 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
11885 ;; what we've read from .newsrc.eld. We have to merge these
11886 ;; lists. We do this by "attaching" any (foreign) groups in the
11887 ;; gnus-newsrc-alist to the (native) group that precedes them.
11888 (let ((rc (cdr gnus-newsrc-alist))
11889 (prev gnus-newsrc-alist)
11892 (or (assoc (car (car rc)) newsrc)
11893 (if (setq entry (assoc (car (car prev)) newsrc))
11894 (setcdr (setq mentry (memq entry newsrc))
11895 (cons (car rc) (cdr mentry)))
11896 (setq newsrc (cons (car rc) newsrc))))
11900 (setq gnus-newsrc-alist newsrc)
11901 ;; We make the newsrc hashtb.
11902 (gnus-make-hashtable-from-newsrc-alist)
11904 ;; Finally, if we read some options lines, we parse them.
11905 (or (string= gnus-newsrc-options "")
11906 (gnus-newsrc-parse-options gnus-newsrc-options))
11909 ;; Parse options lines to find "options -n !all rec.all" and stuff.
11910 ;; The return value will be a list on the form
11911 ;; ((regexp1 . ignore)
11912 ;; (regexp2 . subscribe)...)
11913 ;; When handling new newsgroups, groups that match a `ignore' regexp
11914 ;; will be ignored, and groups that match a `subscribe' regexp will be
11915 ;; subscribed. A line like
11916 ;; options -n !all rec.all
11917 ;; will lead to a list that looks like
11918 ;; (("^rec\\..+" . subscribe)
11919 ;; ("^.+" . ignore))
11920 ;; So all "rec.*" groups will be subscribed, while all the other
11921 ;; groups will be ignored. Note that "options -n !all rec.all" is very
11922 ;; different from "options -n rec.all !all".
11923 (defun gnus-newsrc-parse-options (options)
11926 (gnus-set-work-buffer)
11927 (insert (regexp-quote options))
11928 ;; First we treat all continuation lines.
11929 (goto-char (point-min))
11930 (while (re-search-forward "\n[ \t]+" nil t)
11931 (replace-match " " t t))
11932 ;; Then we transform all "all"s into ".+"s.
11933 (goto-char (point-min))
11934 (while (re-search-forward "\\ball\\b" nil t)
11935 (replace-match ".+" t t))
11936 (goto-char (point-min))
11937 ;; We remove all other options than the "-n" ones.
11938 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
11939 (replace-match " ")
11941 (goto-char (point-min))
11943 ;; We are only interested in "options -n" lines - we
11944 ;; ignore the other option lines.
11945 (while (re-search-forward "[ \t]-n" nil t)
11947 (or (save-excursion
11948 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
11950 (gnus-point-at-eol)))
11951 ;; Search for all "words"...
11952 (while (re-search-forward "[^ \t,\n-]+" eol t)
11953 (if (= (char-after (match-beginning 0)) ?!)
11954 ;; If the word begins with a bang (!), this is a "not"
11955 ;; spec. We put this spec (minus the bang) and the
11956 ;; symbol `ignore' into the list.
11957 (setq out (cons (cons (concat
11958 "^" (buffer-substring
11959 (1+ (match-beginning 0))
11962 ;; There was no bang, so this is a "yes" spec.
11963 (setq out (cons (cons (concat
11964 "^" (buffer-substring (match-beginning 0)
11966 'subscribe) out)))))
11968 (setq gnus-newsrc-options-n out))))
11971 (defun gnus-save-newsrc-file ()
11972 "Save .newsrc file."
11973 ;; Note: We cannot save .newsrc file if all newsgroups are removed
11974 ;; from the variable gnus-newsrc-alist.
11975 (and (or gnus-newsrc-alist gnus-killed-list)
11976 gnus-current-startup-file
11977 (let ((make-backup-files t)
11978 (version-control nil)
11979 (require-final-newline t)) ;Don't ask even if requested.
11980 ;; You can stop or change version control of backup file.
11981 ;; Suggested by jason@violet.berkeley.edu.
11982 (run-hooks 'gnus-save-newsrc-hook)
11984 (if (or (not gnus-dribble-buffer)
11985 (not (buffer-name gnus-dribble-buffer))
11986 (zerop (save-excursion
11987 (set-buffer gnus-dribble-buffer)
11989 (gnus-message 4 "(No changes need to be saved)")
11990 (if gnus-save-newsrc-file
11992 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
11993 ;; Make backup file of master newsrc.
11994 (gnus-gnus-to-newsrc-format)
11995 (gnus-message 5 "Saving %s... done"
11996 gnus-current-startup-file)))
11997 ;; Quickly loadable .newsrc.
11998 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
11999 (gnus-add-current-to-buffer-list)
12000 (buffer-disable-undo (current-buffer))
12002 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
12003 (gnus-gnus-to-quick-newsrc-format)
12004 (write-region 1 (point-max)
12005 (concat gnus-current-startup-file ".eld")
12007 (kill-buffer (current-buffer))
12008 (gnus-message 5 "Saving %s.eld... done" gnus-current-startup-file)
12009 (gnus-dribble-delete-file))))))
12011 (defun gnus-gnus-to-quick-newsrc-format ()
12012 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
12013 (insert ";; (ding) Gnus startup file.\n")
12014 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
12015 (insert ";; to read .newsrc.\n")
12016 (let ((variables gnus-variable-list)
12018 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
12020 ;; insert lisp expressions.
12021 (gnus-compress-newsrc-assoc)
12023 (setq variable (car variables))
12024 (and (boundp variable)
12025 (symbol-value variable)
12026 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
12027 (insert "(setq " (symbol-name variable) " '"
12028 (prin1-to-string (symbol-value variable))
12030 (setq variables (cdr variables)))
12031 (gnus-uncompress-newsrc-assoc)))
12034 (defun gnus-gnus-to-newsrc-format ()
12035 ;; Generate and save the .newsrc file.
12036 (let ((newsrc (cdr gnus-newsrc-alist))
12039 (set-buffer (create-file-buffer gnus-startup-file))
12040 (buffer-disable-undo (current-buffer))
12043 (if gnus-newsrc-options (insert gnus-newsrc-options))
12044 ;; Write subscribed and unsubscribed.
12046 (setq info (car newsrc))
12047 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
12049 (insert (car info) (if (> (nth 1 info) gnus-level-subscribed)
12051 (if (setq ranges (nth 2 info))
12054 (if (not (listp (cdr ranges)))
12055 (if (= (car ranges) (cdr ranges))
12056 (insert (int-to-string (car ranges)))
12057 (insert (int-to-string (car ranges)) "-"
12058 (int-to-string (cdr ranges))))
12060 (setq range (car ranges)
12061 ranges (cdr ranges))
12062 (if (or (atom range) (= (car range) (cdr range)))
12063 (insert (int-to-string
12064 (or (and (atom range) range)
12066 (insert (int-to-string (car range)) "-"
12067 (int-to-string (cdr range))))
12068 (if ranges (insert ","))))))
12070 (setq newsrc (cdr newsrc)))
12071 (write-region 1 (point-max) gnus-current-startup-file nil 'nomesg)
12072 (kill-buffer (current-buffer)))))
12074 (defun gnus-read-descriptions-file ()
12075 (gnus-message 5 "Reading descriptions file...")
12077 ((not (or (gnus-server-opened gnus-select-method)
12078 (gnus-open-server gnus-select-method)))
12079 (gnus-message 1 "Couldn't open server")
12081 ((not (gnus-request-list-newsgroups gnus-select-method))
12082 (gnus-message 1 "Couldn't read newsgroups descriptions")
12086 (setq gnus-description-hashtb
12087 (gnus-make-hashtable (length gnus-active-hashtb)))
12090 (set-buffer nntp-server-buffer)
12091 (goto-char (point-min))
12092 (delete-non-matching-lines "^[-\\._+A-Za-z0-9]+[ \t]")
12093 (goto-char (point-min))
12094 (if (or (search-forward "\n.\n" nil t)
12095 (goto-char (point-max)))
12097 (beginning-of-line)
12098 (narrow-to-region (point-min) (point))))
12099 (goto-char (point-min))
12100 (while (not (eobp))
12101 (setq group (let ((obarray gnus-description-hashtb))
12102 (read (current-buffer))))
12103 (skip-chars-forward " \t")
12104 (and (symbolp group)
12105 (set group (buffer-substring (point) (gnus-point-at-eol))))
12106 (forward-line 1))))
12107 (gnus-message 5 "Reading descriptions file...done")
12110 (defun gnus-group-get-description (group)
12111 ;; Get the description of a group by sending XGTITLE to the server.
12112 (and (gnus-request-group-description group)
12114 (set-buffer nntp-server-buffer)
12115 (goto-char (point-min))
12116 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
12117 (buffer-substring (match-beginning 1) (match-end 1))))))
12123 (defvar gnus-server-mode-hook nil
12124 "Hook run in `gnus-server-mode' buffers.")
12126 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
12127 "Format of server lines.
12128 It works along the same lines as a normal formatting string,
12129 with some simple extensions.")
12131 (defvar gnus-server-mode-line-format "(ding) List of servers"
12132 "The format specification for the server mode line.")
12134 (defconst gnus-server-line-format-alist
12135 (list (list ?h 'how ?s)
12137 (list ?w 'where ?s)
12140 (defconst gnus-server-mode-line-format-alist
12141 (list (list ?S 'news-server ?s)
12142 (list ?M 'news-method ?s)
12143 (list ?u 'user-defined ?s)))
12145 (defvar gnus-server-line-format-spec nil)
12146 (defvar gnus-server-mode-line-format-spec nil)
12147 (defvar gnus-server-killed-servers nil)
12149 (defvar gnus-server-mode-map nil)
12150 (put 'gnus-server-mode 'mode-class 'special)
12152 (if gnus-server-mode-map
12154 (setq gnus-server-mode-map (make-sparse-keymap))
12155 (suppress-keymap gnus-server-mode-map)
12156 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
12157 (define-key gnus-server-mode-map "\r" 'gnus-server-read-server)
12158 (define-key gnus-server-mode-map gnus-mouse-2 'gnus-server-pick-server)
12159 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
12160 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
12161 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
12162 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
12163 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
12164 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
12165 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
12167 (defun gnus-server-mode ()
12168 "Major mode for listing and editing servers.
12170 All normal editing commands are switched off.
12171 \\<gnus-server-mode-map>
12173 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
12175 The following commands are available:
12177 \\{gnus-server-mode-map}"
12179 (if gnus-visual (gnus-server-make-menu-bar))
12180 (kill-all-local-variables)
12181 (setq mode-line-modified "-- ")
12182 (make-local-variable 'mode-line-format)
12183 (setq mode-line-format (copy-sequence mode-line-format))
12184 (and (equal (nth 3 mode-line-format) " ")
12185 (setcar (nthcdr 3 mode-line-format) ""))
12186 (setq major-mode 'gnus-server-mode)
12187 (setq mode-name "Server")
12188 ; (gnus-group-set-mode-line)
12189 (setq mode-line-process nil)
12190 (use-local-map gnus-server-mode-map)
12191 (buffer-disable-undo (current-buffer))
12192 (setq truncate-lines t)
12193 (setq buffer-read-only t)
12194 (run-hooks 'gnus-server-mode-hook))
12196 (defun gnus-server-insert-server-line (sformat name method)
12197 (let* ((sformat (or sformat gnus-server-line-format-spec))
12199 (where (nth 1 method))
12201 (beginning-of-line)
12203 ;; Insert the text.
12204 (insert (eval sformat))
12205 (add-text-properties
12206 b (1+ b) (list 'gnus-server (intern name)))))
12208 (defun gnus-server-setup-buffer ()
12209 (if (get-buffer gnus-server-buffer)
12212 (set-buffer (get-buffer-create gnus-server-buffer))
12214 (and gnus-carpal (gnus-carpal-setup-buffer 'server)))))
12216 (defun gnus-server-prepare ()
12217 (setq gnus-server-mode-line-format-spec
12218 (gnus-parse-format gnus-server-mode-line-format
12219 gnus-server-mode-line-format-alist))
12220 (setq gnus-server-line-format-spec
12221 (gnus-parse-format gnus-server-line-format
12222 gnus-server-line-format-alist))
12223 (let ((alist gnus-server-alist)
12224 (buffer-read-only nil))
12227 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
12228 (setq alist (cdr alist))))
12229 (goto-char (point-min))
12230 (gnus-server-position-cursor))
12232 (defun gnus-server-server-name ()
12233 (let ((server (get-text-property (gnus-point-at-bol) 'gnus-server)))
12234 (and server (symbol-name server))))
12236 (defalias 'gnus-server-position-cursor 'gnus-goto-colon)
12238 (defconst gnus-server-edit-buffer "*Gnus edit server*")
12240 (defun gnus-server-update-server (server)
12242 (set-buffer gnus-server-buffer)
12243 (let ((buffer-read-only nil)
12244 (info (cdr (assoc server gnus-server-alist))))
12245 (gnus-dribble-enter
12246 (concat "(gnus-server-set-info \"" server "\" '"
12247 (prin1-to-string info) ")"))
12248 ;; Buffer may be narrowed.
12251 (if (gnus-server-goto-server server)
12252 (delete-region (progn (beginning-of-line) (point))
12253 (progn (forward-line 1) (point))))
12254 (let ((entry (assoc server gnus-server-alist)))
12255 (gnus-server-insert-server-line nil (car entry) (cdr entry))
12256 (gnus-server-position-cursor))))))
12258 (defun gnus-server-set-info (server info)
12259 ;; Enter a select method into the virtual server alist.
12260 (gnus-dribble-enter
12261 (concat "(gnus-server-set-info \"" server "\" '"
12262 (prin1-to-string info) ")"))
12263 (let* ((server (nth 1 info))
12264 (entry (assoc server gnus-server-alist)))
12265 (if entry (setcdr entry info)
12266 (setq gnus-server-alist
12267 (nconc gnus-server-alist (list (cons server info)))))))
12269 (defun gnus-server-to-method (server)
12270 ;; Map virtual server names to select methods.
12271 (or (and (equal server "native") gnus-select-method)
12272 (cdr (assoc server gnus-server-alist))))
12274 (defun gnus-server-extend-method (group method)
12275 ;; This function "extends" a virtual server. If the server is
12276 ;; "hello", and the select method is ("hello" (my-var "something"))
12277 ;; in the group "alt.alt", this will result in a new virtual server
12278 ;; called "helly+alt.alt".
12280 (gnus-copy-sequence
12281 (if (equal (car method) "native") gnus-select-method
12282 (cdr (assoc (car method) gnus-server-alist))))))
12283 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
12284 (nconc entry (cdr method))))
12286 (defun gnus-server-get-method (group method)
12287 ;; Input either a server name, and extended server name, or a
12288 ;; select method, and return a select method.
12289 (cond ((stringp method)
12290 (gnus-server-to-method method))
12291 ((stringp (car method))
12292 (gnus-server-extend-method group method))
12294 (gnus-server-add-address method))))
12296 (defun gnus-server-add-address (method)
12297 (let ((method-name (symbol-name (car method))))
12298 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
12299 (not (assq (intern (concat method-name "-address")) method)))
12300 (append method (list (list (intern (concat method-name "-address"))
12304 (defun gnus-server-equal (s1 s2)
12306 (and (= (length s1) (length s2))
12308 (while (and s1 (member (car s1) s2))
12309 (setq s1 (cdr s1)))
12312 ;;; Interactive server functions.
12314 (defun gnus-server-kill-server (server)
12315 "Kill the server on the current line."
12316 (interactive (list (gnus-server-server-name)))
12317 (or (gnus-server-goto-server server)
12318 (if server (error "No such server: %s" server)
12319 (error "No server on the current line")))
12320 (let ((buffer-read-only nil))
12321 (delete-region (progn (beginning-of-line) (point))
12322 (progn (forward-line 1) (point))))
12323 (setq gnus-server-killed-servers
12324 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
12325 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
12326 gnus-server-alist))
12327 (gnus-server-position-cursor))
12329 (defun gnus-server-yank-server ()
12330 "Yank the previously killed server."
12332 (or gnus-server-killed-servers
12333 (error "No killed servers to be yanked"))
12334 (let ((alist gnus-server-alist)
12335 (server (gnus-server-server-name))
12336 (killed (car gnus-server-killed-servers)))
12338 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
12339 (if (string= server (car (car gnus-server-alist)))
12340 (setq gnus-server-alist (cons killed gnus-server-alist))
12341 (while (and (cdr alist)
12342 (not (string= server (car (car (cdr alist))))))
12343 (setq alist (cdr alist)))
12344 (setcdr alist (cons killed (cdr alist)))))
12345 (gnus-server-update-server (car killed))
12346 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
12347 (gnus-server-position-cursor)))
12349 (defun gnus-server-exit ()
12350 "Return to the group buffer."
12352 (kill-buffer (current-buffer))
12353 (switch-to-buffer gnus-group-buffer))
12355 (defun gnus-server-list-servers ()
12356 "List all available servers."
12358 (let ((cur (gnus-server-server-name)))
12359 (gnus-server-prepare)
12360 (if cur (gnus-server-goto-server cur)
12361 (goto-char (point-max))
12363 (gnus-server-position-cursor)))
12365 (defun gnus-server-copy-server (from to)
12368 (or (gnus-server-server-name)
12369 (error "No server on the current line"))
12370 (read-string "Copy to: ")))
12371 (or from (error "No server on current line"))
12372 (or (and to (not (string= to ""))) (error "No name to copy to"))
12373 (and (assoc to gnus-server-alist) (error "%s already exists" to))
12374 (or (assoc from gnus-server-alist)
12375 (error "%s: no such server" from))
12376 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
12377 (setcar to-entry to)
12378 (setcar (nthcdr 2 to-entry) to)
12379 (setq gnus-server-killed-servers
12380 (cons to-entry gnus-server-killed-servers))
12381 (gnus-server-yank-server)))
12383 (defun gnus-server-add-server (how where)
12385 (list (intern (completing-read "Server method: "
12386 gnus-valid-select-methods nil t))
12387 (read-string "Server name: ")))
12388 (setq gnus-server-killed-servers
12389 (cons (list where how where) gnus-server-killed-servers))
12390 (gnus-server-yank-server))
12392 (defun gnus-server-goto-server (server)
12393 "Jump to a server line."
12395 (list (completing-read "Goto server: " gnus-server-alist nil t)))
12396 (let ((to (text-property-any (point-min) (point-max)
12397 'gnus-server (intern server))))
12401 (gnus-server-position-cursor)))))
12403 (defun gnus-server-edit-server (server)
12404 "Edit the server on the current line."
12405 (interactive (list (gnus-server-server-name)))
12407 (error "No server on current line"))
12408 (let ((winconf (current-window-configuration)))
12409 (get-buffer-create gnus-server-edit-buffer)
12410 (gnus-configure-windows 'edit-server)
12411 (gnus-add-current-to-buffer-list)
12413 (make-local-variable 'gnus-prev-winconf)
12414 (setq gnus-prev-winconf winconf)
12415 (use-local-map (copy-keymap (current-local-map)))
12416 (let ((done-func '(lambda ()
12417 "Exit editing mode and update the information."
12419 (gnus-server-edit-server-done 'group))))
12420 (setcar (cdr (nth 4 done-func)) server)
12421 (local-set-key "\C-c\C-c" done-func))
12423 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
12424 (insert (pp-to-string (cdr (assoc server gnus-server-alist))))))
12426 (defun gnus-server-edit-server-done (server)
12428 (set-buffer (get-buffer-create gnus-server-edit-buffer))
12429 (goto-char (point-min))
12430 (let ((form (read (current-buffer)))
12431 (winconf gnus-prev-winconf))
12432 (gnus-server-set-info server form)
12433 (kill-buffer (current-buffer))
12434 (and winconf (set-window-configuration winconf))
12435 (set-buffer gnus-server-buffer)
12436 (gnus-server-update-server (gnus-server-server-name))
12437 (gnus-server-position-cursor)))
12439 (defun gnus-server-read-server (server)
12441 (interactive (list (gnus-server-server-name)))
12442 (gnus-browse-foreign-server (gnus-server-to-method server) (current-buffer)))
12444 (defun gnus-mouse-pick-server (e)
12446 (mouse-set-point e)
12447 (gnus-server-read-server (gnus-server-server-name)))
12449 ;; Allow redefinition of Gnus functions.
12451 (gnus-ems-redefine)
12455 ;;; gnus.el ends here