1 ;;; (ding) Gnus --- 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-assoc', `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
43 ;; Customization variables
45 (defvar gnus-select-method
46 (list 'nntp (or (getenv "NNTPSERVER")
47 (if (and gnus-default-nntp-server
48 (not (string= gnus-default-nntp-server "")))
49 gnus-default-nntp-server)
52 "Default method for selecting a newsgroup.
53 This variable should be a list, where the first element is how the
54 news is to be fetched, the second is the address. An optional third
55 element can be included to specify a port number if nntp is used.
57 For instance, if you want to get your news via NNTP from
58 \"flab.flab.edu\" on port 23, you could say:
60 (setq gnus-select-method '(nntp \"flab.flab.edu\" 23))
62 If you want to use your local spool, say:
64 (setq gnus-select-method (list 'nnspool (system-name)))
66 If you use this variable, you must set `gnus-nntp-server' to nil.")
68 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
69 (defvar gnus-post-method nil
70 "Preferred method for posting USENET news.
71 If this variable is nil, Gnus will use the current method to decide
72 which method to use when posting. If it is non-nil, it will override
73 the current method. This method will not be used in mail groups and
74 the like, only in \"real\" newsgroups.
76 The value must be a valid method as discussed in the documentation of
77 `gnus-select-method'.")
79 (defvar gnus-refer-article-method nil
80 "Preferred method for fetching an article by Message-ID.
81 If you are reading news from the local spool (with nnspool), fetching
82 articles by Message-ID is painfully slow. By setting this method to an
83 nntp method, you might get acceptable results.
85 The value of this variable must be a valid select method as discussed
86 in the documentation of `gnus-select-method'")
88 (defvar gnus-secondary-select-methods nil
89 "A list of secondary methods that will be used for reading news.
90 This is a list where each element is a complete select methdod (see
91 `gnus-select-method').
93 If, for instance, you want to read your mail with the nnml backend,
94 you could set this variable:
96 (setq gnus-secondary-select-methods '((nnml \"\"))")
98 (defvar gnus-secondary-servers nil
99 "List of NNTP servers that the user can choose between interactively.
100 To make Gnus query you for a server, you have to give `gnus' a
101 non-numeric prefix - `C-u M-x gnus', in short.")
103 (defvar gnus-nntp-server nil
104 "The name of the host running the NNTP server.
105 This variable is semi-obsolete. Use the `gnus-select-method'
108 (defvar gnus-nntp-service "nntp"
109 "NNTP service name (\"nntp\" or 119).
110 This is an obsolete variable, which is scarcely used. If you use an
111 nntp server for your newsgroup and want to change the port number
112 used to 899, you would say something along these lines:
114 (setq gnus-select-method '(nntp \"my.nntp.server\" 899))")
116 (defvar gnus-startup-file "~/.newsrc"
117 "Your `.newsrc' file.
118 `.newsrc-SERVER' will be used instead if that exists.")
120 (defvar gnus-signature-file "~/.signature"
121 "Your signature file.
122 If the variable is a string that doesn't correspond to a file, the
123 string itself is inserted.")
125 (defvar gnus-signature-function nil
126 "A function that should return a signature file name.
127 The function will be called with the name of the newsgroup being
129 If the function returns a string that doesn't correspond to a file, the
130 string itself is inserted.
131 If the function returns nil, the `gnus-signature-file' variable will
134 (defvar gnus-init-file "~/.gnus"
135 "Your Gnus elisp startup file.
136 If a file with the .el or .elc suffixes exist, it will be read
139 (defvar gnus-group-faq-directory
140 "/anonymous@rtfm.mit.edu:/pub/usenet-by-group/"
141 "Directory where the group FAQs are stored.
142 This will most commonly be on a remote machine, and the file will be
143 fetched by ange-ftp.")
145 (defvar gnus-group-archive-directory
146 "/ftp@sina.tcamc.uh.edu:/pub/emacs/ding-list/"
147 "The address of the (ding) archives.")
149 (defvar gnus-default-subscribed-newsgroups nil
150 "This variable lists what newsgroups should be susbcribed the first time Gnus is used.
151 It should be a list of strings.
152 If it is `t', Gnus will not do anything special the first time it is
153 started; it'll just use the normal newsgroups subscription methods.")
155 (defvar gnus-post-prepare-function nil
156 "Function that is run after a post buffer has been prepared.
157 It is called with the name of the newsgroup that is posted to. It
158 might be used, for instance, for inserting signatures based on the
159 newsgroup name. (In that case, `gnus-signature-file' and
160 `mail-signature' should both be set to nil).")
162 (defvar gnus-use-cross-reference t
163 "Non-nil means that cross referenced articles will be marked as read.
164 If nil, ignore cross references. If t, mark articles as read in
165 subscribed newsgroups. If neither t nor nil, mark as read in all
168 (defvar gnus-use-dribble-file t
169 "Non-nil means that Gnus will use a dribble file to store user updates.
170 If Emacs should crash without saving the .newsrc files, complete
171 information can be restored from the dribble file.")
173 (defvar gnus-use-followup-to 'use
174 "Specifies what to do with Followup-To header.
175 If nil, ignore the header. If it is t, use its value, but ignore
176 `poster'. If it is neither nil nor t, which is the default, always use
179 (defvar gnus-followup-to-function nil
180 "A variable that contains a function that returns a followup address.
181 The function will be called in the buffer of the article that is being
182 followed up. The buffer will be narrowed to the headers of the
183 article. To pick header headers, one might use `mail-fetch-field'. The
184 function will be called with the name of the current newsgroup as the
187 Here's an example `gnus-followup-to-function':
189 (setq gnus-followup-to-function
191 (cond ((string= group \"mail.list\")
192 (or (mail-fetch-field \"sender\")
193 (mail-fetch-field \"from\")))
195 (or (mail-fetch-field \"reply-to\")
196 (mail-fetch-field \"from\"))))))")
198 (defvar gnus-reply-to-function nil
199 "A variable that contains a function that returns a reply address.
200 See the `gnus-followup-to-function' variable for an explanation of how
201 this variable is used.
203 This function should return a string that will be used to fill in the
204 header. This function may also return a list. In that case, every
205 list element should be a cons where the first car should be a string
206 with the header name, and the cdr should be a string with the header
209 (defvar gnus-large-newsgroup 200
210 "The number of articles which indicates a large newsgroup.
211 If the number of articles in a newsgroup is greater than this value,
212 confirmation is required for selecting the newsgroup.")
214 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
215 (defvar gnus-no-groups-message "No news is horrible news"
216 "Message displayed by Gnus when no groups are available.")
218 (defvar gnus-author-copy (getenv "AUTHORCOPY")
219 "Save outgoing articles in this file.
220 Initialized from the AUTHORCOPY environment variable.
222 If this variable begins with the character \"|\", outgoing articles
223 will be piped to the named program. It is possible to save an article
224 in an MH folder as follows:
226 \(setq gnus-author-copy \"|/usr/local/lib/mh/rcvstore +Article\")
228 If the first character is not a pipe, articles are saved using the
229 function specified by the `gnus-author-copy-saver' variable.")
231 (defvar gnus-mail-self-blind nil
232 "Non-nil means insert a BCC header in all outgoing articles.
233 This will result in having a copy of the article mailed to yourself.
234 The BCC header is inserted when the post buffer is initialized, so you
235 can remove or alter the BCC header to override the default.")
237 (defvar gnus-author-copy-saver (function rmail-output)
238 "A function called to save outgoing articles.
239 This function will be called with the same of the file to store the
240 article in. The default function is `rmail-output' which saves in Unix
243 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
244 "Non-nil means that the default name of a file to save articles in is the group name.
245 If it's nil, the directory form of the group name is used instead.
247 If this variable is a list, and the list contains the element
248 `not-score', long file names will not be used for score files, if it
249 contains the element `not-save', long file names will not be used for
250 saving, and if it contains the element `not-kill', long file names
251 will not be used for kill files.")
253 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
254 "Name of the directory articles will be saved in (default \"~/News\").
255 Initialized from the SAVEDIR environment variable.")
257 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
258 "Name of the directory where kill files will be stored (default \"~/News\").
259 Initialized from the SAVEDIR environment variable.")
261 (defvar gnus-score-expiry-days 7
262 "*Number of days before unused score file entries are expired.")
264 (defvar gnus-default-article-saver (function gnus-summary-save-in-rmail)
265 "A function to save articles in your favorite format.
266 The function must be interactively callable (in other words, it must
267 be an Emacs command).
269 Gnus provides the following functions:
271 * gnus-summary-save-in-rmail (Rmail format)
272 * gnus-summary-save-in-mail (Unix mail format)
273 * gnus-summary-save-in-folder (MH folder)
274 * gnus-summary-save-in-file (article format).")
276 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
277 "A function generating a file name to save articles in Rmail format.
278 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
280 (defvar gnus-mail-save-name (function gnus-plain-save-name)
281 "A function generating a file name to save articles in Unix mail format.
282 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
284 (defvar gnus-folder-save-name (function gnus-folder-save-name)
285 "A function generating a file name to save articles in MH folder.
286 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
288 (defvar gnus-file-save-name (function gnus-numeric-save-name)
289 "A function generating a file name to save articles in article format.
290 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
292 (defvar gnus-score-file-suffix "SCORE"
293 "Suffix of the score files.")
295 (defvar gnus-fetch-old-headers nil
296 "Non-nil means that Gnus will try to build threads by grabbing old headers.
297 If an unread article in the group refers to an older, already read (or
298 just marked as read) article, the old article will not normally be
299 displayed in the Summary buffer. If this variable is non-nil, Gnus
300 will attempt to grab the headers to the old articles, and thereby
301 build complete threads. If it has the value `some', only enough
302 headers to connect otherwise loose threads will be displayed.
304 The server has to support XOVER for any of this to work.")
306 (defvar gnus-visual t
307 "*If non-nil, will do various highlighting.
308 If nil, no mouse highlights (or any other highlights) will be
309 performed. This might speed up Gnus some when generating large group
310 and summary buffers.")
312 (defvar gnus-novice-user t
313 "*Non-nil means that you are a usenet novice.
314 If non-nil, verbose messages may be displayed and confirmations may be
317 (defvar gnus-expert-user nil
318 "*Non-nil means that you will never be asked for confirmation about anything.
319 And that means *anything*.")
321 (defvar gnus-keep-same-level nil
322 "Non-nil means that the next newsgroup after the current will be on the same level.
323 When you type, for instance, `n' after reading the last article in the
324 current newsgroup, you will go to the next newsgroup. If this variable
325 is nil, the next newsgroup will be the next from the group
327 If this variable is non-nil, Gnus will either put you in the
328 next newsgroup with the same level, or, if no such newsgroup is
329 available, the next newsgroup with the lowest possible level higher
330 than the current level.
331 If this variable is `best', Gnus will make the next newsgroup the one
332 with the best level.")
334 (defvar gnus-summary-make-false-root 'adopt
335 "nil means that Gnus won't gather loose threads.
336 If the root of a thread has expired or been read in a previous
337 session, the information necessary to build a complete thread has been
338 lost. Instead of having many small sub-threads from this original thread
339 scattered all over the summary buffer, Gnus can gather them.
341 If non-nil, Gnus will try to gather all loose sub-threads from an
342 original thread into one large thread.
344 If this variable is non-nil, it should be one of `none', `adopt',
347 If this variable is `none', Gnus will not make a false root, but just
348 present the sub-threads after another.
349 If this variable is `dummy', Gnus will create a dummy root that will
350 have all the sub-threads as children.
351 If this variable is `adopt', Gnus will make one of the \"children\"
352 the parent and mark all the step-children as such.
353 If this variable is `empty', the \"children\" are printed with empty
354 subject fields. (Or rather, they will be printed with a string
355 given by the `gnus-summary-same-subject' variable.)")
357 (defvar gnus-summary-gather-subject-limit nil
358 "*Maximum length of subject comparisons when gathering loose threads.
359 Use nil to compare full subjects. Setting this variable to a low
360 number will help gather threads that have been corrupted by
361 newsreaders chopping off subject lines, but it might also mean that
362 unrelated articles that have subject that happen to begin with the
363 same few characters will be incorrectly gathered.
365 If this variable is `fuzzy', Gnus will use a fuzzy algortihm when
366 comparing subjects.")
368 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
369 (defvar gnus-summary-same-subject ""
370 "String indicating that the current article has the same subject as the previous.
371 This variable will only be used if the value of
372 `gnus-summary-make-false-root' is `empty'.")
374 (defvar gnus-summary-goto-unread nil
375 "If non-nil, marking commands will go to the next unread article.")
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 you set this variable to nil, you probably still want to be told
406 about new newsgroups that arrive. To do that, set
407 `gnus-check-new-newsgroups' to `ask-server'. This may not work
408 properly with all servers.")
410 (defvar gnus-activate-foreign-newsgroups nil
411 "If nil, Gnus will not check foreign newsgroups at startup.
412 If it is non-nil, it should be a number between one and nine. Foreign
413 newsgroups that have a level lower or equal to this number will be
414 activated on startup. For instance, if you want to active all
415 subscribed newsgroups, but not the rest, you'd set this variable to 5.
417 If you subscribe to lots of newsgroups from different servers, startup
418 might take a while. By setting this variable to nil, you'll save time,
419 but you won't be told how many unread articles there are in the
422 (defvar gnus-save-newsrc-file t
423 "Non-nil means that Gnus will save the `.newsrc' file.
424 Gnus always saves its own startup file, which is called
425 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
426 be readily understood by other newsreaders. If you don't plan on
427 using other newsreaders, set this variable to nil to save some time on
430 (defvar gnus-save-killed-list t
431 "If non-nil, save the list of killed groups to the startup file.
432 This will save both time (when starting and quitting) and space (both
433 memory and disk), but it will also mean that Gnus has no record of
434 which groups are new and which are old, so the automatic new
435 newsgroups subscription methods become meaningless. You should always
436 set `gnus-check-new-newsgroups' to `ask-server' or nil if you set this
439 (defvar gnus-interactive-catchup t
440 "If non-nil, require your confirmation when catching up a group.")
442 (defvar gnus-interactive-post t
443 "If non-nil, group name will be asked for when posting.")
445 (defvar gnus-interactive-exit t
446 "If non-nil, require your confirmation when exiting Gnus.")
448 (defvar gnus-kill-killed nil
449 "If non-nil, Gnus will apply kill files to already killed articles.
450 If it is nil, Gnus will never apply kill files to articles that have
451 already been through the scoring process, which might very well save lots
454 (defvar gnus-extract-address-components 'gnus-extract-address-components
455 "Function for extracting address components from a From header.
456 Two pre-defined function exist: `gnus-extract-address-components',
457 which is the default, quite fast, and too simplistic solution, and
458 `mail-extract-address-components', which works much better, but is
461 (defvar gnus-score-interactive-default-score 1000
462 "Scoring commands will raise/lower the score with this number as the default.")
464 (defvar gnus-save-score nil
465 "If non-nil, save group scoring info.")
467 (defvar gnus-global-score-files nil
468 "List of global score files and directories.
469 Set this variable if you want to use people's score files. One entry
470 for each score file or each score file directory. Gnus will decide
471 by itself what score files are applicable to which group.
473 Say you want to use the single score file
474 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all
475 score files in the \"/ftp.some-where:/pub/score\" directory.
477 (setq gnus-global-score-files
478 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\"
479 \"/ftp.some-where:/pub/score\"))")
481 (defvar gnus-summary-default-score 0
482 "Default article score level.
483 If this variable is nil, scoring will be disabled.")
485 (defvar gnus-group-default-list-level 5
486 "Default listing level.")
488 (defvar gnus-user-login-name nil
489 "The login name of the user.
490 Got from the function `user-login-name' if undefined.")
492 (defvar gnus-user-full-name nil
493 "The full name of the user.
494 Got from the NAME environment variable if undefined.")
496 (defvar gnus-user-from-line nil
497 "Your full, complete e-mail address.
498 Overrides the other Gnus variables if it is non-nil.
500 Here are two example values of this variable:
502 \"Lars Magne Ingebrigtsen <larsi@ifi.uio.no>\"
506 \"larsi@ifi.uio.no (Lars Magne Ingebrigtsen)\"
508 The first version is recommended, but the name has to be quoted if it
509 contains non-alphanumerical characters.")
511 (defvar gnus-show-mime nil
512 "*If non-ni, do mime processing of articles.
513 The articles will simply be fed to the function given by
514 `gnus-show-mime-method'.")
516 (defvar gnus-show-mime-method (function metamail-buffer)
517 "Function to process a MIME message.
518 The function is called from the article buffer.")
520 (defvar gnus-show-threads t
521 "*If non-nil, display threads in summary mode.")
523 (defvar gnus-thread-hide-subtree nil
524 "If non-nil, hide all threads initially.
525 If threads are hidden, you have to run the command
526 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
527 to expose hidden threads.")
529 (defvar gnus-thread-hide-killed t
530 "If non-nil, hide killed threads automatically.")
532 (defvar gnus-thread-ignore-subject nil
533 "If non-nil, ignore subjects and do all threading based on the Reference header.
534 If nil, which is the default, articles that have different subjects
535 from their parents will start separate threads.")
537 (defvar gnus-thread-indent-level 4
538 "Number that says how much each sub-thread should be indented.")
540 ;; jwz: nuke newsgroups whose name is all digits - that means that
541 ;; some loser has let articles get into the root of the news spool,
542 ;; which is toxic. Lines beginning with whitespace also tend to be
544 (defvar gnus-ignored-newsgroups
545 (purecopy (mapconcat 'identity
546 '("^to\\." ; not "real" groups
547 "^[0-9. \t]+ " ; all digits in name
548 "[][\"#'() ;\\]" ; bogus characters
551 "A regexp to match uninteresting newsgroups in the active file.
552 Any lines in the active file matching this regular expression are
553 removed from the newsgroup list before anything else is done to it,
554 thus making them effectively non-existant.")
556 (defvar gnus-ignored-headers
557 "^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:"
558 "All headers that match this regexp will be hidden.
559 Also see `gnus-visible-headers'.")
561 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
562 "All headers that do not match this regexp will be hidden.
563 Also see `gnus-ignored-headers'.")
565 (defvar gnus-sorted-header-list
566 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
567 "^Cc:" "^Date:" "^Organization:")
568 "This variable is a list of regular expressions.
569 If it is non-nil, headers that match the regular expressions will
570 be placed first in the article buffer in the sequence specified by
573 (defvar gnus-required-headers
574 '(From Date Newsgroups Subject Message-ID Organization Lines X-Newsreader)
575 "Headers to be generated or prompted for when posting an article.
576 RFC977 and RFC1036 require From, Date, Newsgroups, Subject, Message-ID
577 and Path headers. Organization, Lines and X-Newsreader are optional.
578 If you want Gnus not to insert some header, remove it from this
581 (defvar gnus-show-all-headers nil
582 "*If non-nil, don't hide any headers.")
584 (defvar gnus-save-all-headers t
585 "*If non-nil, don't remove any headers before saving.")
587 (defvar gnus-inhibit-startup-message nil
588 "If non-nil, the startup message will not be displayed.")
590 (defvar gnus-auto-extend-newsgroup t
591 "If non-nil, extend newsgroup forward and backward when requested.")
593 (defvar gnus-auto-select-first t
594 "If non-nil, select the first unread article when entering a group.
595 If you want to prevent automatic selection of the first unread article
596 in some newsgroups, set the variable to nil in
597 `gnus-select-group-hook'.")
599 (defvar gnus-auto-select-next t
600 "If non-nil, offer to go to the next group from the end of the previous.
601 If the value is t and the next newsgroup is empty, Gnus will exit
602 summary mode and go back to group mode. If the value is neither nil
603 nor t, Gnus will select the following unread newsgroup. In
604 particular, if the value is the symbol `quietly', the next unread
605 newsgroup will be selected without any confirmations.")
607 (defvar gnus-auto-select-same nil
608 "If non-nil, select the next article with the same subject.")
610 (defvar gnus-auto-center-summary t
611 "*If non-nil, always center the current summary buffer.")
613 (defvar gnus-auto-mail-to-author nil
614 "*If non-nil, mail the authors of articles a copy of your follow-ups.
615 If this variable is `ask', the user will be prompted for whether to
616 mail a copy. The string given by `gnus-mail-courtesy-message' will be
617 inserted at the beginning of the mail copy.
619 Mail is sent using the function specified by the
620 `gnus-mail-send-method' variable.")
622 ;; Added by Ethan Bradford <ethanb@ptolemy.astro.washington.edu>.
623 (defvar gnus-mail-courtesy-message
624 "The following message is a courtesy copy of an article\nthat has been posted as well.\n\n"
625 "This is inserted at the start of a mailed copy of a posted message.
626 If this variable is nil, no such courtesy message will be added.")
628 (defvar gnus-break-pages t
629 "*If non-nil, do page breaking on articles.
630 The page delimiter is specified by the `gnus-page-delimiter'
633 (defvar gnus-page-delimiter "^\^L"
634 "Regexp describing what to use as article page delimiters.
635 The default value is \"^\^L\", which is a form linefeed at the
636 beginning of a line.")
638 (defvar gnus-use-full-window t
639 "*If non-nil, use the entire Emacs screen.")
641 (defvar gnus-window-configuration
645 "Specify window configurations for each action.
646 The format of the variable is either a list of (ACTION (G S A)), where
647 G, S, and A are the relative height of group, summary, and article
648 windows, respectively, or a list of (ACTION FUNCTION), where FUNCTION
649 is a function that will be called with ACTION as an argument. ACTION
650 can be `summary', `newsgroups', or `article'.")
652 (defvar gnus-mail-reply-method (function gnus-mail-reply-using-mail)
653 "Function to compose a reply.
654 Two pre-made functions are `gnus-mail-reply-using-mail' (sendmail) and
655 `gnus-mail-reply-using-mhe' (MH-E).")
657 (defvar gnus-mail-forward-method (function gnus-mail-forward-using-mail)
658 "Function to forward the current message to another user.
659 Two pre-made functions are `gnus-mail-forward-using-mail' (sendmail)
660 and `gnus-mail-forward-using-mhe' (MH-E).")
662 (defvar gnus-mail-other-window-method 'gnus-mail-other-window-using-mail
663 "Function to compose mail in the other window.
664 Two pre-made functions are `gnus-mail-other-window-using-mail'
665 (sendmail) and `gnus-mail-other-window-using-mhe' (MH-E).")
667 (defvar gnus-mail-send-method send-mail-function
668 "Function to mail a message which is also being posted as an article.
669 The message must have To or Cc header. The default is copied from
670 the variable `send-mail-function'.")
672 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
673 "Function called with a group name when new group is detected.
674 A few pre-made functions are supplied: `gnus-subscribe-randomly'
675 inserts new groups at the beginning of the list of groups;
676 `gnus-subscribe-alphabetically' inserts new groups in strict
677 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
678 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
681 ;; Suggested by a bug report by Hallvard B Furuseth.
682 ;; <h.b.furuseth@usit.uio.no>.
683 (defvar gnus-subscribe-options-newsgroup-method
684 (function gnus-subscribe-alphabetically)
685 "This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
686 If, for instance, you want to subscribe to all newsgroups in the
687 \"no\" and \"alt\" hierarchies, you'd put the following in your
690 options -n no.all alt.all
692 Gnus will the subscribe all new newsgroups in these hierarchies with
693 the subscription method in this variable.")
695 (defvar gnus-subscribe-hierarchical-interactive nil
696 "If non-nil, Gnus will offer to subscribe hierarchically.
697 When a new hierarchy appears, Gnus will ask the user:
699 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
701 If the user pressed `d', Gnus will descend the hierarchy, `y' will
702 subscribe to all newsgroups in the hierarchy and `s' will skip this
703 hierarchy in its entirety.")
705 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
706 "Function used for sorting the group buffer.
707 This function will be called with group info entries as the arguments
708 for the groups to be sorted. Pre-made functions include
709 `gnus-sort-by-alphabet', `gnus-sort-by-unread' and
710 `gnus-sort-by-level'")
712 ;; Mark variables suggested by Thomas Michanek
713 ;; <Thomas.Michanek@telelogic.se>.
714 (defvar gnus-unread-mark ?
715 "Mark used for unread articles.")
716 (defvar gnus-ticked-mark ?!
717 "Mark used for ticked articles.")
718 (defvar gnus-dormant-mark ??
719 "Mark used for dormant articles.")
720 (defvar gnus-dread-mark ?D
721 "Mark used for read articles.")
722 (defvar gnus-read-mark ?d
723 "Mark used for read articles.")
724 (defvar gnus-expirable-mark ?E
725 "Mark used for expirable articles.")
726 (defvar gnus-killed-mark ?K
727 "Mark used for killed articles.")
728 (defvar gnus-kill-file-mark ?X
729 "Mark used for articles killed by kill files.")
730 (defvar gnus-low-score-mark ?Y
731 "Mark used for articles with a low score.")
732 (defvar gnus-catchup-mark ?C
733 "Mark used for articles that are caught up.")
734 (defvar gnus-replied-mark ?R
735 "Mark used for articles that have been replied to.")
736 (defvar gnus-process-mark ?#
738 (defvar gnus-ancient-mark ?A
739 "Mark used for ancient articles.")
740 (defvar gnus-canceled-mark ?G
741 "Mark used for cancelled articles.")
742 (defvar gnus-score-over-mark ?+
743 "Score mark used for articles with high scores.")
744 (defvar gnus-score-below-mark ?-
745 "Score mark used for articles with low scores.")
747 (defvar gnus-view-pseudo-asynchronously nil
748 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
750 (defvar gnus-view-pseudos nil
751 "If `automatic', pseudo-articles will be viewed automatically.
752 If `not-confirm', pseudos will be viewed automatically, and the user
753 will not be asked to confirm the command.")
755 (defvar gnus-group-line-format "%M%S%5y: %(%g%)\n"
756 "Format of groups lines.
757 It works along the same lines as a normal formatting string,
758 with some simple extensions.
760 %M Only marked articles (character, \"*\" or \" \")
761 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
762 %L Level of subscribedness (integer, 1-9)
763 %N Number of unread articles (integer)
764 %I Number of dormant articles (integer)
765 %i Number of ticked and dormant (integer)
766 %T Number of ticked articles (integer)
767 %R Number of read articles (integer)
768 %t Total number of articles (integer)
769 %y Number of unread, unticked articles (integer)
770 %G Group name (string)
771 %g Qualified group name (string)
772 %D Group description (string)
773 %s Select method (string)
774 %o Moderated group (char, \"m\")
775 %O Moderated group (string, \"(m)\" or \"\")
776 %n Select from where (string)
777 %z A string that look like `<%s:%n>' if a foreign select method is used
778 %u User defined specifier. The next character in the format string should
779 be a letter. Gnus will call the function gnus-user-format-function-X,
780 where X is the letter following %u. The function will be passed the
781 current header as argument. The function should return a string, which
782 will be inserted into the buffer just like information from any other
785 Text between %( and %) will be highlighted with `gnus-mouse-face' when
786 the mouse point move inside the area. There can only be one such area.
788 Note that this format specification is not always respected. For
789 reasons of efficiency, when listing killed groups, this specification
790 is ignored altogether. If the spec is changed considerably, your
791 output may end up looking strange when listing both alive and killed
794 If you use %o or %O, reading the active file will be slower and quite
795 a bit of extra memory will be used. %D will also worsen performance.
796 Also note that if you change the format specification to include any
797 of these specs, you must probably re-start Gnus to see them go into
800 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
801 "The format specification of the lines in the summary buffer.
803 It works along the same lines as a normal formatting string,
804 with some simple extensions.
806 %N Article number, left padded with spaces (string)
808 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
809 %n Name of the poster (string)
810 %A Address of the poster (string)
811 %L Number of lines in the article (integer)
812 %c Number of characters in the article (integer)
813 %D Date of the article (string)
814 %I Indentation based on thread level (a string of spaces)
815 %T A string with two possible values: 80 spaces if the article
816 is on thread level two or larger and 0 spaces on level one
817 %U Status of this article (character, \"D\", \"K\", \"-\" or \" \")
818 %[ Opening bracket (character, \"[\" or \"<\")
819 %] Closing bracket (character, \"]\" or \">\")
820 %> Spaces of length thread-level (string)
821 %< Spaces of length (- 20 thread-level) (string)
822 %i Article score (number)
823 %z Article zcore (character)
824 %t Number of articles under the current thread.
825 %u User defined specifier. The next character in the format string should
826 be a letter. Gnus will call the function gnus-user-format-function-X,
827 where X is the letter following %u. The function will be passed the
828 current header as argument. The function should return a string, which
829 will be inserted into the summary just like information from any other
832 Text between %( and %) will be highlighted with `gnus-mouse-face'
833 when the mouse point is placed inside the area. There can only be one
836 The %U (status), %R (replied) and %z (zcore) specs have to be handled
837 with care. For reasons of efficiency, Gnus will compute what column
838 these characters will end up in, and \"hard-code\" that. This means that
839 it is illegal to have these specs after a variable-length spec. Well,
840 you might not be arrested, but your summary buffer will look strange,
843 The smart choice is to have these specs as for to the left as
846 This restriction may disappear in later versions of Gnus.")
848 (defvar gnus-summary-dummy-line-format "* : : %S\n"
849 "The format specification for the dummy roots in the summary buffer.
850 It works along the same lines as a normal formatting string,
851 with some simple extensions.
855 (defvar gnus-summary-mode-line-format "(ding) %G/%A %Z"
856 "The format specification for the summary mode line.")
858 (defvar gnus-article-mode-line-format "(ding) %G/%A %S"
859 "The format specification for the article mode line.")
861 (defvar gnus-group-mode-line-format "(ding) List of groups {%M:%S} "
862 "The format specification for the group mode line.")
864 (defvar gnus-valid-select-methods
865 '(("nntp" post address prompt-address)
866 ("nnspool" post) ("nnvirtual" none virtual prompt-address)
867 ("nnmbox" mail respool) ("nnml" mail respool)
868 ("nnmh" mail respool) ("nndir" none prompt-address) ("nndigest" none)
869 ("nndoc" none prompt-address) ("nnbabyl" mail respool)
870 ("nnkiboze" none virtual) ("nnfolder" mail respool))
871 "An alist of valid select methods.
872 The first element of each list lists should be a string with the name
873 of the select method. The other elements may be be the category of
874 this method (ie. `post', `mail', `none' or whatever) or other
875 properties that this method has (like being respoolable).
876 If you implement a new select method, all you should have to change is
877 this variable. I think.")
879 (defvar gnus-updated-mode-lines '(group article summary)
880 "List of buffers that should update their mode lines.
881 The list may contain the symbols `group', `article' and `summary'. If
882 the corresponding symbol is present, Gnus will keep that mode line
883 updated with information that may be pertinent.
884 If this variable is nil, screen refresh may be quicker.")
886 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
887 (defvar gnus-mode-non-string-length 21
888 "Max length of mode-line non-string contents buffer contents.")
890 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
891 (defvar gnus-mouse-face 'highlight
892 "Face used for mouse highlighting in Gnus.
893 No mouse highlights will be done if `gnus-visual' is nil.")
895 (defvar gnus-summary-mark-below nil
896 "Mark all articles with a score below this variable as read.
897 This variable is local to each summary buffer and usually set by the
900 (defvar gnus-orphan-score nil
901 "All orphans get this score added. Set in the score file.")
903 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
904 "List of functions used for sorting threads in the summary buffer.
905 By default, threads are sorted by article number.
907 Each function takes two threads and return non-nil if the first thread
908 should be sorted before the other. If you use more than one function,
909 the primary sort function should be the last.
911 Ready-mady functions include `gnus-thread-sort-by-number',
912 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
913 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
914 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
916 The latter two only work on threads that have been scored prior to
917 entering the newsgroup.")
919 (defvar gnus-thread-score-function '+
920 "Function used for calculating the total score of a thread.
922 The function is called with the scores of the article and each
923 subthread and should then return the score of the thread.
925 Some functions you can use are `+', `max', or `min'.")
927 (defvar gnus-score-find-score-files-function 'gnus-score-find-bnews
928 "Function used to find SCORE files.
929 The function will be called with the group name as the argument, and
930 should return a list of score files to apply to that group. The score
931 files do not actually have to exist.
933 Predefined values are:
935 gnus-score-find-single: Only apply the group's own SCORE file.
936 gnus-score-find-hierarchical: Also apply SCORE files from parent groups.
937 gnus-score-find-bnews: Apply SCORE files whose names matches.
939 See the documentation to these functions for more information.
941 This variable can also be a list of functions to be called. Each
942 function should either return a list of score files, or the functions
943 may also return lists of score alists.")
945 (defvar gnus-options-subscribe nil
946 "All new groups matching this regexp will be subscribed unconditionally.
947 Note that this variable deals only with new newsgroups. This variable
948 does not affect old newsgroups.")
950 (defvar gnus-options-not-subscribe nil
951 "All new groups matching this regexp will be ignored.
952 Note that this variable deals only with new newsgroups. This variable
953 does not affect old (already subscribed) newsgroups.")
955 (defvar gnus-auto-expirable-newsgroups nil
956 "Groups in which to automatically mark read articles as expirable.
957 If non-nil, this should be a regexp that should match all groups in
958 which to perform auto-expiry. This only makes sense for mail groups.")
963 (defvar gnus-group-mode-hook nil
964 "A hook for Gnus group mode.")
966 (defvar gnus-summary-mode-hook nil
967 "A hook for Gnus summary mode.")
969 (defvar gnus-article-mode-hook nil
970 "A hook for Gnus article mode.")
972 (defvar gnus-open-server-hook nil
973 "A hook called just before opening connection to the news server.")
975 (defvar gnus-startup-hook nil
976 "A hook called at startup.
977 This hook is called after Gnus is connected to the NNTP server.")
979 (defvar gnus-get-new-news-hook nil
980 "A hook run just before Gnus checks for new news.")
982 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
983 "A function that is called to generate the group buffer.
984 The function is called with three arguments: The first is a number;
985 all group with a level less or equal to that number should be listed,
986 if the second is non-nil, empty groups should also be displayed. If
987 the third is non-nil, it is a number. No groups with a level lower
988 than this number should be displayed.
990 The only current function implemented is `gnus-group-prepare-flat'.")
992 (defvar gnus-group-prepare-hook nil
993 "A hook called after the group buffer has been generated.
994 If you want to modify the group buffer, you can use this hook.")
996 (defvar gnus-summary-prepare-hook nil
997 "A hook called after the summary buffer has been generated.
998 If you want to modify the summary buffer, you can use this hook.")
1000 (defvar gnus-article-prepare-hook nil
1001 "A hook called after an article has been prepared in the article buffer.
1002 If you want to run a special decoding program like nkf, use this hook.")
1004 (defvar gnus-article-display-hook nil
1005 "A hook called after the article is displayed in the article buffer.
1006 The hook is designed to change the contents of the article
1007 buffer. Typical functions that this hook may contain are
1008 `gnus-article-hide-headers' (hide selected headers),
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-select-group-hook nil
1015 "A hook called when a newsgroup is selected.
1017 If you'd like to simplify subjects like the
1018 `gnus-summary-next-same-subject' command does, you can use the
1021 (setq gnus-select-group-hook
1024 (mapcar (lambda (header)
1027 (gnus-simplify-subject
1028 (header-subject header) 're-only)))
1029 gnus-newsgroup-headers))))")
1031 (defvar gnus-select-article-hook
1032 '(gnus-summary-show-thread)
1033 "A hook called when an article is selected.
1034 The default hook shows conversation thread subtrees of the selected
1035 article automatically using `gnus-summary-show-thread'.")
1037 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1038 "A hook called to apply kill files to a group.
1039 This hook is intended to apply a kill file to the selected newsgroup.
1040 The function `gnus-apply-kill-file' is called by default.
1042 Since a general kill file is too heavy to use only for a few
1043 newsgroups, I recommend you to use a lighter hook function. For
1044 example, if you'd like to apply a kill file to articles which contains
1045 a string `rmgroup' in subject in newsgroup `control', you can use the
1048 \(setq gnus-apply-kill-hook
1051 (cond ((string-match \"control\" gnus-newsgroup-name)
1052 (gnus-kill \"Subject\" \"rmgroup\")
1053 (gnus-expunge \"X\"))))))")
1055 (defvar gnus-visual-mark-article-hook
1056 (list 'gnus-visual-highlight-selected-summary)
1057 "Hook run after selecting an article in the summary buffer.
1058 It is meant to be used for highlighting the article in some way. It
1059 is not run if `gnus-visual' is nil.")
1061 (defvar gnus-prepare-article-hook (list 'gnus-inews-insert-signature)
1062 "A hook called after preparing body, but before preparing header headers.
1063 The default hook (`gnus-inews-insert-signature') inserts a signature
1064 file specified by the variable `gnus-signature-file'.")
1066 (defvar gnus-inews-article-hook (list 'gnus-inews-do-fcc)
1067 "A hook called before finally posting an article.
1068 The default hook (`gnus-inews-do-fcc') does FCC processing (ie. saves
1069 the article to a file).")
1071 (defvar gnus-inews-article-header-hook nil
1072 "A hook called after inserting the headers in an article to be posted.
1073 The hook is called from the *post-news* buffer, narrowed to the
1076 (defvar gnus-exit-group-hook nil
1077 "A hook called when exiting (not quitting) summary mode.")
1079 (defvar gnus-suspend-gnus-hook nil
1080 "A hook called when suspending (not exiting) Gnus.")
1082 (defvar gnus-exit-gnus-hook nil
1083 "A hook called when exiting Gnus.")
1085 (defvar gnus-save-newsrc-hook nil
1086 "A hook called when saving the newsrc file.")
1088 (defvar gnus-visual-summary-update-hook
1089 (list 'gnus-visual-summary-highlight-line)
1090 "A hook called when a summary line is changed.
1091 The hook will not be called if `gnus-visual' is nil.
1093 The default function `gnus-visual-summary-highlight-line' will
1094 highlight the line according to the `gnus-visual-summary-highlight'
1097 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1098 "A hook called when an article is selected for the first time.
1099 The hook is intended to mark an article as read (or unread)
1100 automatically when it is selected.")
1102 ;; Site dependent variables. These variables should be defined in
1105 (defvar gnus-default-nntp-server nil
1106 "Specify a default NNTP server.
1107 This variable should be defined in paths.el, and should never be set
1109 If you want to change servers, you should use `gnus-select-method'.
1110 See the documentation to that variable.")
1112 (defconst gnus-backup-default-subscribed-newsgroups
1113 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
1114 "Default default new newsgroups the first time Gnus is run.
1115 Should be set in paths.el, and shouldn't be touched by the user.")
1117 (defvar gnus-local-domain nil
1118 "Local domain name without a host name.
1119 The DOMAINNAME environment variable is used instead if it is defined.
1120 If the `system-name' function returns the full Internet name, there is
1121 no need to set this variable.")
1123 (defvar gnus-local-organization nil
1124 "String with a description of what organization (if any) the user belongs to.
1125 The ORGANIZATION environment variable is used instead if it is defined.
1126 If this variable contains a function, this function will be called
1127 with the current newsgroup name as the argument. The function should
1129 In any case, if the string (either in the variable, in the environment
1130 variable, or returned by the function) is a file name, the contents of
1131 this file will be used as the organization.")
1133 (defvar gnus-use-generic-from nil
1134 "If nil, the full host name will be the system name prepended to the domain name.
1135 If this is a string, the full host name will be this string.
1136 If this is non-nil, non-string, the domain name will be used as the
1139 (defvar gnus-use-generic-path nil
1140 "If nil, use the NNTP server name in the Path header.
1141 If stringp, use this; if non-nil, use no host name (user name only).")
1144 ;; Internal variables
1146 ;; Avoid highlighting in kill files.
1147 (defvar gnus-summary-inhibit-highlight nil)
1148 (defvar gnus-newsgroup-selected-overlay nil)
1150 (defvar gnus-article-mode-map nil)
1151 (defvar caesar-translate-table nil)
1152 (defvar gnus-dribble-buffer nil)
1153 (defvar gnus-headers-retrieved-by nil)
1154 (defvar gnus-article-reply nil)
1155 (defvar gnus-override-method nil)
1156 (defvar gnus-article-check-size nil)
1157 (defvar gnus-score-file-list nil)
1158 (defvar gnus-internal-global-score-files nil)
1159 (defvar gnus-current-score-file nil)
1161 (defvar gnus-current-move-group nil)
1163 (defvar gnus-score-alist nil
1164 "Alist containing score information.
1165 The keys can be symbols or strings. The following symbols are defined.
1167 touched: If this alist has been modified.
1168 mark: Automatically mark articles below this.
1169 expunge: Automatically expunge articles below this.
1170 files: List of other SCORE files to load when loading this one.
1171 eval: Sexp to be evaluated when the score file is loaded.
1173 String entries have the form (HEADER (MATCH TYPE SCORE DATE) ...)
1174 where HEADER is the header being scored, MATCH is the string we are
1175 looking for, TYPE is a flag indicating whether it should use regexp or
1176 substring matching, SCORE is the score to add and DATE is the date
1177 of the last succesful match.")
1179 (defvar gnus-score-cache nil)
1180 (defvar gnus-scores-articles nil)
1181 (defvar gnus-header-index nil)
1182 (defvar gnus-score-index nil)
1184 (defvar gnus-newsgroup-dependencies nil)
1185 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1186 (defvar gnus-default-subscribe-level 2)
1187 (defvar gnus-default-unsubscribe-level 6)
1188 (defvar gnus-default-kill-level 9)
1190 (defconst gnus-group-line-format-alist
1191 (list (list ?M 'marked ?c)
1192 (list ?S 'subscribed ?c)
1194 (list ?N 'number ?s)
1195 (list ?I 'number-of-dormant ?d)
1196 (list ?T 'number-of-ticked ?d)
1197 (list ?R 'number-of-read ?s)
1198 (list ?t 'number-total ?d)
1199 (list ?y 'number-of-unread-unticked ?s)
1200 (list ?i 'number-of-ticked-and-dormant ?d)
1202 (list ?G 'qualified-group ?s)
1203 (list ?D 'newsgroup-description ?s)
1204 (list ?o 'moderated ?c)
1205 (list ?O 'moderated-string ?s)
1206 (list ?s 'news-server ?s)
1207 (list ?n 'news-method ?s)
1208 (list ?z 'news-method-string ?s)
1209 (list ?u 'user-defined ?s)))
1211 (defconst gnus-summary-line-format-alist
1212 (list (list ?N 'number ?s)
1213 (list ?S 'subject ?s)
1214 (list ?s 'subject-or-nil ?s)
1216 (list ?A 'address ?s)
1218 (list ?x (macroexpand '(header-xref header)) ?s)
1219 (list ?D (macroexpand '(header-date header)) ?s)
1220 (list ?M (macroexpand '(header-id header)) ?s)
1221 (list ?r (macroexpand '(header-references header)) ?s)
1222 (list ?c (macroexpand '(header-chars header)) ?d)
1224 (list ?I 'indentation ?s)
1225 (list ?T '(if (< level 1) "" (make-string (frame-width) ? )) ?s)
1226 (list ?R 'replied ?c)
1227 (list ?\[ 'opening-bracket ?c)
1228 (list ?\] 'closing-bracket ?c)
1229 (list ?\> '(make-string level ? ) ?s)
1230 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1232 (list ?z 'score-char ?c)
1233 (list ?U 'unread ?c)
1234 (list ?t '(gnus-summary-number-of-articles-in-thread thread) ?d)
1235 (list ?u 'user-defined ?s))
1236 "An alist of format specifications that can appear in summary lines,
1237 and what variables they correspond with, along with the type of the
1238 variable (string, integer, character, etc).")
1240 (defconst gnus-summary-dummy-line-format-alist
1241 (list (list ?S 'subject ?s)
1242 (list ?N 'number ?d)
1243 (list ?u 'user-defined ?s)))
1245 (defconst gnus-summary-mode-line-format-alist
1246 (list (list ?G 'group-name ?s)
1247 (list ?g '(gnus-short-group-name group-name))
1248 (list ?A 'article-number ?d)
1249 (list ?Z 'unread-and-unselected ?s)
1250 (list ?V 'gnus-version ?s)
1251 (list ?U 'unread ?d)
1252 (list ?S 'subject ?s)
1253 (list ?e 'unselected ?d)
1254 (list ?u 'user-defined ?s)
1255 (list ?s 'gnus-current-score-file ?s)))
1257 (defconst gnus-group-mode-line-format-alist
1258 (list (list ?S 'news-server ?s)
1259 (list ?M 'news-method ?s)
1260 (list ?u 'user-defined ?s)))
1262 (defvar gnus-have-read-active-file nil)
1264 (defconst gnus-maintainer "Lars Magne Ingebrigtsen <larsi@ifi.uio.no>"
1265 "The mail address of the Gnus maintainer.")
1267 (defconst gnus-version "(ding) Gnus v0.50"
1268 "Version number for this version of Gnus.")
1270 (defvar gnus-info-nodes
1271 '((gnus-group-mode "(gnus)The Group Buffer")
1272 (gnus-summary-mode "(gnus)The Summary Buffer")
1273 (gnus-article-mode "(gnus)The Article Buffer"))
1274 "Assoc list of major modes and related Info nodes.")
1276 (defvar gnus-documentation-group-file "~/dgnus/lisp/doc.txt"
1277 "The location of the (ding) Gnus documentation group.")
1279 (defvar gnus-group-buffer "*Group*")
1280 (defvar gnus-summary-buffer "*Summary*")
1281 (defvar gnus-article-buffer "*Article*")
1283 (defvar gnus-buffer-list nil
1284 "Gnus buffers that should be killed on exit.")
1286 (defvar gnus-variable-list
1287 '(gnus-newsrc-options gnus-newsrc-options-n
1288 gnus-newsrc-last-checked-date
1289 gnus-newsrc-assoc gnus-killed-list gnus-zombie-list)
1290 "Gnus variables saved in the quick startup file.")
1292 (defvar gnus-overload-functions
1293 '((news-inews gnus-inews-news "rnewspost")
1294 (caesar-region gnus-caesar-region "rnews"))
1295 "Functions overloaded by gnus.
1296 It is a list of `(original overload &optional file)'.")
1298 (defvar gnus-newsrc-options nil
1299 "Options line in the .newsrc file.")
1301 (defvar gnus-newsrc-options-n nil
1302 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1304 (defvar gnus-newsrc-last-checked-date nil
1305 "Date Gnus last asked server for new newsgroups.")
1307 (defvar gnus-newsrc-assoc nil
1308 "Assoc list of read articles.
1309 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1311 (defvar gnus-newsrc-hashtb nil
1312 "Hashtable of gnus-newsrc-assoc.")
1314 (defvar gnus-killed-list nil
1315 "List of killed newsgroups.")
1317 (defvar gnus-killed-hashtb nil
1318 "Hash table equivalent of gnus-killed-list.")
1320 (defvar gnus-zombie-list nil
1321 "List of almost dead newsgroups.")
1323 (defvar gnus-description-hashtb nil
1324 "Descriptions of newsgroups.")
1326 (defvar gnus-list-of-killed-groups nil
1327 "List of newsgroups that have recently been killed by the user.")
1329 (defvar gnus-active-hashtb nil
1330 "Hashtable of active articles.")
1332 (defvar gnus-moderated-list nil
1333 "List of moderated newsgroups.")
1335 (defvar gnus-current-startup-file nil
1336 "Startup file for the current host.")
1338 (defvar gnus-last-search-regexp nil
1339 "Default regexp for article search command.")
1341 (defvar gnus-last-shell-command nil
1342 "Default shell command on article.")
1344 (defvar gnus-current-select-method nil
1345 "The current method for selecting a newsgroup.")
1347 (defvar gnus-have-all-newsgroups nil)
1349 (defvar gnus-article-internal-prepare-hook nil)
1351 (defvar gnus-newsgroup-name nil)
1352 (defvar gnus-newsgroup-begin nil)
1353 (defvar gnus-newsgroup-end nil)
1354 (defvar gnus-newsgroup-last-rmail nil)
1355 (defvar gnus-newsgroup-last-mail nil)
1356 (defvar gnus-newsgroup-last-folder nil)
1357 (defvar gnus-newsgroup-last-file nil)
1358 (defvar gnus-newsgroup-auto-expire nil)
1360 (defvar gnus-newsgroup-unreads nil
1361 "List of unread articles in the current newsgroup.")
1363 (defvar gnus-newsgroup-unselected nil
1364 "List of unselected unread articles in the current newsgroup.")
1366 (defvar gnus-newsgroup-marked nil
1367 "List of ticked articles in the current newsgroup (a subset of unread art).")
1369 (defvar gnus-newsgroup-killed nil
1370 "List of ranges of articles that have been through the scoring process.")
1372 (defvar gnus-newsgroup-kill-headers nil)
1374 (defvar gnus-newsgroup-replied nil
1375 "List of articles that have been replied to in the current newsgroup.")
1377 (defvar gnus-newsgroup-expirable nil
1378 "List of articles in the current newsgroup that can be expired.")
1380 (defvar gnus-newsgroup-processable nil
1381 "List of articles in the current newsgroup that can be processed.")
1383 (defvar gnus-newsgroup-bookmarks nil
1384 "List of articles in the current newsgroup that have bookmarks.")
1386 (defvar gnus-newsgroup-dormant nil
1387 "List of dormant articles in the current newsgroup.")
1389 (defvar gnus-newsgroup-scored nil
1390 "List of scored articles in the current newsgroup.")
1392 (defvar gnus-newsgroup-headers nil
1393 "List of article headers in the current newsgroup.")
1394 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1396 (defvar gnus-newsgroup-ancient nil
1397 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1399 (defvar gnus-current-article nil)
1400 (defvar gnus-article-current nil)
1401 (defvar gnus-current-headers nil)
1402 (defvar gnus-have-all-headers nil)
1403 (defvar gnus-last-article nil)
1404 (defvar gnus-newsgroup-history nil)
1405 (defvar gnus-current-kill-article nil)
1407 ;; Save window configuration.
1408 (defvar gnus-winconf-edit-group nil)
1409 (defvar gnus-winconf-edit-score nil)
1412 (defvar gnus-summary-line-format-spec nil)
1413 (defvar gnus-summary-dummy-line-format-spec nil)
1414 (defvar gnus-group-line-format-spec nil)
1415 (defvar gnus-summary-mode-line-format-spec nil)
1416 (defvar gnus-article-mode-line-format-spec nil)
1417 (defvar gnus-group-mode-line-format-spec nil)
1418 (defvar gnus-summary-mark-positions nil)
1420 (defvar gnus-summary-expunge-below nil)
1421 (defvar gnus-reffed-article-number nil)
1423 (defvar rmail-default-file (expand-file-name "~/XMBOX"))
1424 (defvar rmail-default-rmail-file (expand-file-name "~/XNEWS"))
1426 (defconst gnus-summary-local-variables
1427 '(gnus-newsgroup-name
1428 gnus-newsgroup-begin gnus-newsgroup-end
1429 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1430 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1431 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1432 gnus-newsgroup-unselected gnus-newsgroup-marked
1433 gnus-newsgroup-replied gnus-newsgroup-expirable
1434 gnus-newsgroup-processable gnus-newsgroup-killed
1435 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1436 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1437 gnus-current-article gnus-current-headers gnus-have-all-headers
1438 gnus-last-article gnus-article-internal-prepare-hook
1439 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1440 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1441 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1442 gnus-summary-mark-below
1443 gnus-newsgroup-history gnus-newsgroup-ancient)
1444 "Variables that are buffer-local to the summary buffers.")
1446 ;;; End of variables.
1448 ;; Define some autoload functions Gnus might use.
1450 (autoload 'metamail-buffer "metamail")
1451 (autoload 'Info-goto-node "info")
1453 (autoload 'timezone-make-date-arpa-standard "timezone")
1454 (autoload 'timezone-fix-time "timezone")
1455 (autoload 'timezone-make-sortable-date "timezone")
1456 (autoload 'timezone-make-time-string "timezone")
1458 (autoload 'rmail-output "rmailout")
1459 (autoload 'mail-position-on-field "sendmail")
1460 (autoload 'mail-setup "sendmail")
1461 (autoload 'news-mail-other-window "rnewspost")
1463 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1464 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1465 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1466 (autoload 'gnus-summary-save-in-folder "gnus-mh")
1467 (autoload 'gnus-Folder-save-name "gnus-mh")
1468 (autoload 'gnus-folder-save-name "gnus-mh")
1470 (autoload 'gnus-group-make-menu-bar "gnus-visual")
1471 (autoload 'gnus-summary-make-menu-bar "gnus-visual")
1472 (autoload 'gnus-article-make-menu-bar "gnus-visual")
1473 (autoload 'gnus-visual-highlight-selected-summary "gnus-visual")
1474 (autoload 'gnus-visual-summary-highlight-line "gnus-visual")
1476 (autoload 'gnus-uu-mark-by-regexp "gnus-uu")
1477 (autoload 'gnus-uu-mark-region "gnus-uu")
1478 (autoload 'gnus-uu-mark-thread "gnus-uu")
1479 (autoload 'gnus-uu-mark-sparse "gnus-uu")
1480 (autoload 'gnus-uu-mark-series "gnus-uu")
1481 (autoload 'gnus-uu-mark-all "gnus-uu")
1482 (autoload 'gnus-uu-post-news "gnus-uu")
1483 (autoload 'gnus-uu-digest-and-forward "gnus-uu")
1485 (autoload 'gnus-uu-decode-uu "gnus-uu")
1486 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu")
1487 (autoload 'gnus-uu-decode-unshar "gnus-uu")
1488 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu")
1489 (autoload 'gnus-uu-decode-save "gnus-uu")
1490 (autoload 'gnus-uu-decode-binhex "gnus-uu")
1491 (autoload 'gnus-uu-decode-uu-view "gnus-uu")
1492 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu")
1493 (autoload 'gnus-uu-decode-unshar-view "gnus-uu")
1494 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu")
1495 (autoload 'gnus-uu-decode-save-view "gnus-uu")
1496 (autoload 'gnus-uu-decode-binhex-view "gnus-uu")
1498 (autoload 'gnus-kill "gnus-kill")
1499 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1500 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1501 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1502 (autoload 'gnus-execute "gnus-kill")
1505 (autoload 'pp-to-string "pp")
1506 (autoload 'mail-extract-address-components "mail-extr")
1511 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1512 ;; If you want the cursor to go somewhere else, set these two
1513 ;; functions in some startup hook to whatever you want.
1514 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon)
1515 (defalias 'gnus-group-position-cursor 'gnus-goto-colon)
1517 ;; Cruft to make Gnus work under GNU XEmacs.
1518 (defvar gnus-xemacs nil
1519 "Non-nil if Gnus is running under GNU XEmacs.")
1521 (if (not (string-match "XEmacs\\|Lucid" emacs-version))
1523 (setq gnus-xemacs t)
1525 '((or (memq 'underline (list-faces))
1526 (make-face 'underline))
1527 (or (face-differs-from-default-p 'underline)
1528 (set-face-underline-p 'underline t))
1530 (defun set-text-properties (start end props &optional buffer)
1532 (put-text-property start end (car props) (cadr props) buffer)
1533 (remove-text-properties start end ()))))))
1536 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1537 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1538 (` (let ((GnusStartBufferWindow (selected-window)))
1541 (pop-to-buffer (, buffer))
1543 (select-window GnusStartBufferWindow)))))
1545 (defun gnus-make-hashtable (&optional hashsize)
1546 "Make a hash table (default and minimum size is 255).
1547 Optional argument HASHSIZE specifies the table size."
1548 (make-vector (if hashsize
1549 (max (gnus-create-hash-size hashsize) 255)
1552 (defmacro gnus-gethash (string hashtable)
1553 "Get hash value of STRING in HASHTABLE."
1554 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1555 ;;(` (abbrev-expansion (, string) (, hashtable)))
1556 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1558 (defmacro gnus-sethash (string value hashtable)
1559 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1560 ;; We cannot use define-abbrev since it only accepts string as value.
1561 ; (set (intern string hashtable) value))
1562 (` (set (intern (, string) (, hashtable)) (, value))))
1564 (defsubst gnus-buffer-substring (beg end)
1565 (buffer-substring (match-beginning beg) (match-end end)))
1567 (defsubst gnus-simplify-subject-re (subject)
1568 "Remove \"Re:\" from subject lines."
1569 (let ((case-fold-search t))
1570 (if (string-match "^re: *" subject)
1571 (substring subject (match-end 0))
1574 (defsubst gnus-goto-char (point)
1575 (and point (goto-char point)))
1579 ;;; Gnus Utility Functions
1582 (defun gnus-extract-address-components (from)
1584 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1585 (setq address (substring from (match-beginning 0) (match-end 0))))
1587 (string-match (concat "<" (regexp-quote address) ">") from)
1588 (setq name (substring from 0 (1- (match-beginning 0)))))
1590 (and (string-match "(.+)" from)
1591 (setq name (substring from (1+ (match-beginning 0))
1592 (1- (match-end 0))))))
1593 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1594 (list (or name from) (or address from))))
1596 (defun gnus-fetch-field (field)
1597 "Return the value of the header FIELD of current article."
1600 (gnus-narrow-to-headers)
1601 (mail-fetch-field field))))
1603 (defun gnus-goto-colon ()
1605 (search-forward ":" (save-excursion (end-of-line) (point)) t))
1607 (defun gnus-narrow-to-headers ()
1611 (if (search-forward "\n\n")
1612 (narrow-to-region 1 (1- (point))))))
1614 ;; Get a number that is suitable for hashing; bigger than MIN
1615 (defun gnus-create-hash-size (min)
1621 (defun gnus-update-format-specifications ()
1622 (setq gnus-summary-line-format-spec
1624 gnus-summary-line-format gnus-summary-line-format-alist))
1625 (gnus-update-summary-mark-positions)
1626 (setq gnus-summary-dummy-line-format-spec
1627 (gnus-parse-format gnus-summary-dummy-line-format
1628 gnus-summary-dummy-line-format-alist))
1629 (setq gnus-group-line-format-spec
1631 gnus-group-line-format
1632 gnus-group-line-format-alist))
1633 (if (and (string-match "%D" gnus-group-line-format)
1634 (not gnus-description-hashtb)
1635 gnus-read-active-file)
1636 (gnus-read-descriptions-file))
1637 (setq gnus-summary-mode-line-format-spec
1638 (gnus-parse-format gnus-summary-mode-line-format
1639 gnus-summary-mode-line-format-alist))
1640 (setq gnus-article-mode-line-format-spec
1641 (gnus-parse-format gnus-article-mode-line-format
1642 gnus-summary-mode-line-format-alist))
1643 (setq gnus-group-mode-line-format-spec
1644 (gnus-parse-format gnus-group-mode-line-format
1645 gnus-group-mode-line-format-alist)))
1647 (defun gnus-update-summary-mark-positions ()
1649 (let ((gnus-replied-mark 129)
1650 (gnus-score-below-mark 130)
1651 (gnus-score-over-mark 130)
1653 (set-buffer (get-buffer-create " *gnus work*"))
1654 (buffer-disable-undo (current-buffer))
1656 (gnus-summary-insert-line
1657 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1658 (goto-char (point-min))
1659 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1661 (goto-char (point-min))
1662 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1663 (- (point) 2))) pos))
1664 (goto-char (point-min))
1665 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1666 (- (point) 2))) pos))
1667 (setq gnus-summary-mark-positions pos)
1668 (kill-buffer (current-buffer)))))
1670 (defun gnus-format-max-width (var length)
1672 (if (> (length (setq result (eval var))) length)
1673 (format "%s" (substring result 0 length))
1674 (format "%s" result))))
1676 (defun gnus-set-mouse-face (string)
1677 ;; Set mouse face property on STRING.
1679 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string))
1682 (defun gnus-parse-format (format spec-alist)
1683 ;; This function parses the FORMAT string with the help of the
1684 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1685 ;; string. If the FORMAT string contains the specifiers %( and %)
1686 ;; the text between them will have the mouse-face text property.
1687 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1688 (if (and gnus-visual gnus-mouse-face)
1689 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1690 (button (substring format (match-beginning 2) (match-end 2)))
1691 (post (substring format (match-beginning 3) (match-end 3))))
1693 (gnus-parse-simple-format pre spec-alist)
1694 (list 'gnus-set-mouse-face
1695 (gnus-parse-simple-format button spec-alist))
1696 (gnus-parse-simple-format post spec-alist)))
1697 (gnus-parse-simple-format
1698 (concat (substring format (match-beginning 1) (match-end 1))
1699 (substring format (match-beginning 2) (match-end 2))
1700 (substring format (match-beginning 3) (match-end 3)))
1702 (gnus-parse-simple-format format spec-alist)))
1704 (defun gnus-parse-simple-format (format spec-alist)
1705 ;; This function parses the FORMAT string with the help of the
1706 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1707 ;; string. The list will consist of the symbol `format', a format
1708 ;; specification string, and a list of forms depending on the
1711 spec flist fstring b newspec max-width elem beg)
1713 (set-buffer (get-buffer-create " *gnus work*"))
1714 (buffer-disable-undo (current-buffer))
1715 (gnus-add-current-to-buffer-list)
1719 (while (re-search-forward "%[-0-9]*\\(,[0-9]*\\)*\\(.\\)\\(.\\)?" nil t)
1720 (setq spec (string-to-char (buffer-substring (match-beginning 2)
1722 ;; First check if there are any specs that look anything like
1723 ;; "%12,12A", ie. with a "max width specification". These have
1724 ;; to be treated specially.
1725 (if (setq beg (match-beginning 1))
1728 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
1730 (setq beg (match-beginning 2)))
1731 ;; Find the specification from `spec-alist'.
1732 (if (not (setq elem (cdr (assq spec spec-alist))))
1733 (setq elem '("*" ?s)))
1734 ;; Treat user defined format specifiers specially
1735 (and (eq (car elem) 'user-defined)
1738 (list (intern (concat "gnus-user-format-function-"
1744 (delete-region (match-beginning 3) (match-end 3)))
1745 (if (not (zerop max-width))
1746 (let ((el (car elem)))
1747 (cond ((= (car (cdr elem)) ?c)
1748 (setq el (list 'char-to-string el)))
1749 ((= (car (cdr elem)) ?d)
1750 (numberp el) (setq el (list 'int-to-string el))))
1751 (setq flist (cons (list 'gnus-format-max-width
1755 (setq flist (cons (car elem) flist))
1756 (setq newspec (car (cdr elem))))
1757 ;; Remove the old specification (and possibly a ",12" string).
1758 (delete-region beg (match-end 2))
1759 ;; Insert the new specification.
1762 (setq fstring (buffer-substring 1 (point-max))))
1763 (cons 'format (cons fstring (nreverse flist)))))
1765 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
1766 (defun gnus-read-init-file ()
1768 (or (and (file-exists-p gnus-init-file)
1769 ;; Don't try to load a directory.
1770 (not (file-directory-p gnus-init-file)))
1771 (file-exists-p (concat gnus-init-file ".el"))
1772 (file-exists-p (concat gnus-init-file ".elc")))
1773 (load gnus-init-file nil t)))
1775 ;; Article file names when saving.
1777 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
1778 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1779 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
1780 Otherwise, it is like ~/News/news/group/num."
1783 (concat (if (gnus-use-long-file-name 'not-save)
1784 (gnus-capitalize-newsgroup newsgroup)
1785 (gnus-newsgroup-directory-form newsgroup))
1786 "/" (int-to-string (header-number headers)))
1787 (or gnus-article-save-directory "~/News"))))
1789 (string-equal (file-name-directory default)
1790 (file-name-directory last-file))
1791 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1793 (or last-file default))))
1795 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
1796 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1797 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group/num.
1798 Otherwise, it is like ~/News/news/group/num."
1801 (concat (if (gnus-use-long-file-name 'not-save)
1803 (gnus-newsgroup-directory-form newsgroup))
1804 "/" (int-to-string (header-number headers)))
1805 (or gnus-article-save-directory "~/News"))))
1807 (string-equal (file-name-directory default)
1808 (file-name-directory last-file))
1809 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1811 (or last-file default))))
1813 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
1814 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1815 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group.
1816 Otherwise, it is like ~/News/news/group/news."
1819 (if (gnus-use-long-file-name 'not-save)
1820 (gnus-capitalize-newsgroup newsgroup)
1821 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1822 (or gnus-article-save-directory "~/News"))))
1824 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
1825 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1826 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group.
1827 Otherwise, it is like ~/News/news/group/news."
1830 (if (gnus-use-long-file-name 'not-save)
1832 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1833 (or gnus-article-save-directory "~/News"))))
1835 ;; For subscribing new newsgroup
1837 (defun gnus-subscribe-hierarchical-interactive (groups)
1838 (let ((groups (sort groups 'string<))
1839 prefixes prefix start rest ans group starts)
1841 (setq prefixes (list "^"))
1842 (while (and groups prefixes)
1843 (while (not (string-match (car prefixes) (car groups)))
1844 (setq prefixes (cdr prefixes)))
1845 (setq prefix (car prefixes))
1846 (setq start (1- (length prefix)))
1847 (if (and (string-match "[^\\.]\\." (car groups) start)
1850 (concat "^" (substring (car groups) 0 (match-end 0))))
1851 (string-match prefix (car (cdr groups))))
1853 (setq prefixes (cons prefix prefixes))
1854 (message "Descend hierarchy %s? ([y]nsq): "
1855 (substring prefix 1 (1- (length prefix))))
1856 (setq ans (read-char))
1859 (string-match prefix
1860 (setq group (car groups))))
1861 (setq gnus-killed-list
1862 (cons group gnus-killed-list))
1863 (gnus-sethash group group gnus-killed-hashtb)
1864 (setq groups (cdr groups)))
1865 (setq starts (cdr starts)))
1868 (string-match prefix
1869 (setq group (car groups))))
1870 (gnus-sethash group group gnus-killed-hashtb)
1871 (gnus-subscribe-alphabetically (car groups))
1872 (setq groups (cdr groups)))
1873 (setq starts (cdr starts)))
1876 (setq group (car groups))
1877 (setq gnus-killed-list (cons group gnus-killed-list))
1878 (gnus-sethash group group gnus-killed-hashtb)
1879 (setq groups (cdr groups))))
1881 (message "Subscribe %s? ([n]yq)" (car groups))
1882 (setq ans (read-char))
1883 (setq group (car groups))
1885 (gnus-subscribe-alphabetically (car groups))
1886 (gnus-sethash group group gnus-killed-hashtb))
1889 (setq group (car groups))
1890 (setq gnus-killed-list (cons group gnus-killed-list))
1891 (gnus-sethash group group gnus-killed-hashtb)
1892 (setq groups (cdr groups))))
1894 (setq gnus-killed-list (cons group gnus-killed-list))
1895 (gnus-sethash group group gnus-killed-hashtb)))
1896 (setq groups (cdr groups)))))))
1898 (defun gnus-subscribe-randomly (newsgroup)
1899 "Subscribe new NEWSGROUP by making it the first newsgroup."
1900 (gnus-subscribe-newsgroup newsgroup))
1902 (defun gnus-subscribe-alphabetically (newgroup)
1903 "Subscribe new NEWSGROUP and insert it in alphabetical order."
1904 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
1905 (let ((groups (cdr gnus-newsrc-assoc))
1907 (while (and (not before) groups)
1908 (if (string< newgroup (car (car groups)))
1909 (setq before (car (car groups)))
1910 (setq groups (cdr groups))))
1911 (gnus-subscribe-newsgroup newgroup before)))
1913 (defun gnus-subscribe-hierarchically (newgroup)
1914 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
1915 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
1917 (set-buffer (find-file-noselect gnus-current-startup-file))
1918 (let ((groupkey newgroup)
1920 (while (and (not before) groupkey)
1921 (goto-char (point-min))
1923 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
1924 (while (and (re-search-forward groupkey-re nil t)
1926 (setq before (buffer-substring
1927 (match-beginning 1) (match-end 1)))
1928 (string< before newgroup)))))
1929 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
1931 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
1932 (substring groupkey (match-beginning 1) (match-end 1)))))
1933 (gnus-subscribe-newsgroup newgroup before))))
1935 (defun gnus-subscribe-interactively (newsgroup)
1936 "Subscribe new NEWSGROUP interactively.
1937 It is inserted in hierarchical newsgroup order if subscribed. If not,
1939 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
1940 (gnus-subscribe-hierarchically newsgroup)
1941 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
1943 (defun gnus-subscribe-zombies (newsgroup)
1944 "Make new NEWSGROUP a zombie group."
1945 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
1947 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
1948 "Subscribe new NEWSGROUP.
1949 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
1950 the first newsgroup."
1951 ;; We subscribe the group by changing its level to 3.
1952 (gnus-group-change-level
1953 newsgroup 3 9 (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
1954 (message "Subscribe newsgroup: %s" newsgroup))
1958 (defun gnus-newsgroup-directory-form (newsgroup)
1959 "Make hierarchical directory name from NEWSGROUP name."
1960 (let ((newsgroup (substring newsgroup 0)) ;Copy string.
1961 (len (length newsgroup))
1963 ;; Replace all occurrences of `.' with `/'.
1965 (if (= (aref newsgroup idx) ?.)
1966 (aset newsgroup idx ?/))
1967 (setq idx (1+ idx)))
1971 (defun gnus-make-directory (dir)
1972 "Make DIRECTORY recursively."
1973 (let* ((dir (expand-file-name dir default-directory))
1975 (if (string-match "/$" dir)
1976 (setq dir (substring dir 0 (match-beginning 0))))
1977 (while (not (file-exists-p dir))
1978 (setq dirs (cons dir dirs))
1979 (string-match "/[^/]+$" dir)
1980 (setq dir (substring dir 0 (match-beginning 0))))
1982 (make-directory (car dirs))
1983 (setq dirs (cdr dirs)))))
1985 (defun gnus-capitalize-newsgroup (newsgroup)
1986 "Capitalize NEWSGROUP name."
1987 (and (not (zerop (length newsgroup)))
1988 (concat (char-to-string (upcase (aref newsgroup 0)))
1989 (substring newsgroup 1))))
1993 (defun gnus-simplify-subject (subject &optional re-only)
1994 "Remove `Re:' and words in parentheses.
1995 If optional argument RE-ONLY is non-nil, strip `Re:' only."
1996 (let ((case-fold-search t)) ;Ignore case.
1997 ;; Remove `Re:' and `Re^N:'.
1998 (if (string-match "^re:[ \t]*" subject)
1999 (setq subject (substring subject (match-end 0))))
2000 ;; Remove words in parentheses from end.
2002 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2003 (setq subject (substring subject 0 (match-beginning 0)))))
2004 ;; Return subject string.
2007 (defun gnus-simplify-subject-fuzzy (subject)
2008 (let ((case-fold-search t))
2009 (and (string-match "^re:[ \t]*" subject)
2010 (setq subject (substring subject (match-end 0))))
2011 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2012 (setq subject (substring subject 0 (match-beginning 0))))
2015 (while (string-match "[ \t]+" subject beg)
2017 (concat osubject (substring
2018 subject beg (match-beginning 0)) " ")
2020 (setq osubject (concat osubject (substring subject beg)))
2021 (and (string-match " \\'" osubject)
2022 (setq osubject (substring osubject 0 (match-beginning 0))))
2025 (defun gnus-add-current-to-buffer-list ()
2026 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list)))
2028 (defun gnus-string> (s1 s2)
2029 (not (or (string< s1 s2)
2032 ;; Functions accessing headers.
2033 ;; Functions are more convenient than macros in some cases.
2035 (defun gnus-header-number (header)
2036 "Return article number in HEADER."
2037 (header-number header))
2039 (defun gnus-header-subject (header)
2040 "Return subject string in HEADER."
2041 (header-subject header))
2043 (defun gnus-header-from (header)
2044 "Return author string in HEADER."
2045 (header-from header))
2047 (defun gnus-header-xref (header)
2048 "Return xref string in HEADER."
2049 (header-xref header))
2051 (defun gnus-header-lines (header)
2052 "Return lines in HEADER."
2053 (header-lines header))
2055 (defun gnus-header-date (header)
2056 "Return date in HEADER."
2057 (header-date header))
2059 (defun gnus-header-id (header)
2060 "Return Id in HEADER."
2063 (defun gnus-header-references (header)
2064 "Return references in HEADER."
2065 (header-references header))
2067 (defun gnus-clear-system ()
2068 "Clear all variables and buffers."
2069 ;; Clear Gnus variables.
2070 (let ((variables gnus-variable-list))
2072 (set (car variables) nil)
2073 (setq variables (cdr variables))))
2074 ;; Clear other internal variables.
2075 (setq gnus-list-of-killed-groups nil
2076 gnus-have-read-active-file nil
2077 gnus-newsrc-assoc nil
2078 gnus-newsrc-hashtb nil
2079 gnus-killed-list nil
2080 gnus-zombie-list nil
2081 gnus-killed-hashtb nil
2082 gnus-active-hashtb nil
2083 gnus-moderated-list nil
2084 gnus-description-hashtb nil
2085 gnus-newsgroup-headers nil
2086 gnus-score-cache nil
2087 gnus-newsgroup-headers-hashtb-by-number nil
2088 gnus-newsgroup-name nil
2089 gnus-internal-global-score-files nil
2090 gnus-current-select-method nil)
2091 ;; Kill the startup file.
2092 (and gnus-current-startup-file
2093 (get-file-buffer gnus-current-startup-file)
2094 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2095 (gnus-dribble-clear)
2096 ;; Kill global KILL file buffer.
2097 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2098 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2099 ;; Kill Gnus buffers.
2100 (while gnus-buffer-list
2101 (if (and (get-buffer (car gnus-buffer-list))
2102 (buffer-name (get-buffer (car gnus-buffer-list))))
2103 (kill-buffer (car gnus-buffer-list)))
2104 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2106 (defun gnus-configure-windows (action &optional force)
2107 "Configure Gnus windows according to the next ACTION.
2108 The ACTION is either a symbol, such as `summary', or a
2109 configuration list such as `(1 1 2)'. If ACTION is not a list,
2110 configuration list is got from the variable gnus-window-configuration.
2111 If FORCE is non-nil, the updating will be done whether it is necessary
2114 (if (listp action) action
2115 (if (listp gnus-window-configuration)
2116 (car (cdr (assq action gnus-window-configuration)))
2117 gnus-window-configuration)))
2118 (grpwin (get-buffer-window gnus-group-buffer))
2119 (subwin (get-buffer-window gnus-summary-buffer))
2120 (artwin (get-buffer-window gnus-article-buffer))
2127 ;; Make split-window-vertically leave focus in upper window.
2128 (split-window-keep-point t))
2129 (if (and (symbolp windows) (fboundp windows))
2130 (funcall windows action)
2131 (if (and (not force)
2132 (or (null windows) ;No configuration is specified.
2133 (and (eq (null grpwin)
2134 (zerop (nth 0 windows)))
2136 (zerop (nth 1 windows)))
2138 (zerop (nth 2 windows))))))
2139 ;; No need to change window configuration.
2141 (select-window (or grpwin subwin artwin (selected-window)))
2142 ;; First of all, compute the height of each window.
2143 (cond (gnus-use-full-window
2144 ;; Take up the entire screen.
2145 (delete-other-windows)
2146 (setq height (window-height (selected-window))))
2148 (setq height (+ (if grpwin (window-height grpwin) 0)
2149 (if subwin (window-height subwin) 0)
2150 (if artwin (window-height artwin) 0)))))
2151 ;; The group buffer exits always. So, use it to extend the
2152 ;; group window so as to get enough window space.
2153 (switch-to-buffer gnus-group-buffer 'norecord)
2154 (and (get-buffer gnus-summary-buffer)
2155 (delete-windows-on gnus-summary-buffer))
2156 (and (get-buffer gnus-article-buffer)
2157 (delete-windows-on gnus-article-buffer))
2158 ;; Compute expected window height.
2159 (setq winsum (apply (function +) windows))
2160 (if (not (zerop (nth 0 windows)))
2161 (setq grpheight (max window-min-height
2162 (/ (* height (nth 0 windows)) winsum))))
2163 (if (not (zerop (nth 1 windows)))
2164 (setq subheight (max window-min-height
2165 (/ (* height (nth 1 windows)) winsum))))
2166 (if (not (zerop (nth 2 windows)))
2167 (setq artheight (max window-min-height
2168 (/ (* height (nth 2 windows)) winsum))))
2169 (setq height (+ grpheight subheight artheight))
2170 (enlarge-window (max 0 (- height (window-height (selected-window)))))
2171 ;; Then split the window.
2172 (and (not (zerop artheight))
2173 (or (not (zerop grpheight))
2174 (not (zerop subheight)))
2175 (split-window-vertically (+ grpheight subheight)))
2176 (and (not (zerop grpheight))
2177 (not (zerop subheight))
2178 (split-window-vertically grpheight))
2179 ;; Then select buffers in each window.
2180 (or (zerop grpheight)
2182 (switch-to-buffer gnus-group-buffer 'norecord)
2184 (or (zerop subheight)
2186 (switch-to-buffer gnus-summary-buffer 'norecord)
2188 (or (zerop artheight)
2190 ;; If article buffer does not exist, it will be created
2192 (gnus-article-setup-buffer)
2193 (switch-to-buffer gnus-article-buffer 'norecord)
2194 (setq buffer-read-only t) ; !!! Why!?!
2195 (bury-buffer gnus-summary-buffer)
2196 (bury-buffer gnus-group-buffer)))
2197 (or (zerop subheight)
2199 (pop-to-buffer gnus-summary-buffer)
2200 ;; It seems that some code in this function will set
2201 ;; buffer-read-only to nil. I have absolutely no idea
2203 (setq buffer-read-only t))))))) ; !!! Why!?!
2205 (defun gnus-window-configuration-split (action)
2206 (switch-to-buffer gnus-group-buffer t)
2207 (delete-other-windows)
2208 (split-window-horizontally)
2209 (cond ((or (eq action 'newsgoups) (eq action 'summary))
2210 (if (and (get-buffer gnus-summary-buffer)
2211 (buffer-name gnus-summary-buffer))
2212 (switch-to-buffer-other-window gnus-summary-buffer)))
2213 ((eq action 'article)
2214 (switch-to-buffer gnus-summary-buffer t)
2216 (gnus-article-setup-buffer)
2217 (switch-to-buffer gnus-article-buffer t))))
2219 (defun gnus-version ()
2220 "Version numbers of this version of Gnus."
2222 (let ((methods gnus-valid-select-methods)
2225 ;; Go through all the legal select methods and add their version
2226 ;; numbers to the total version string. Only the backends that are
2227 ;; currently in use will have their message numbers taken into
2230 (setq meth (intern (concat (car (car methods)) "-version")))
2232 (stringp (symbol-value meth))
2233 (setq mess (concat mess "; " (symbol-value meth))))
2234 (setq methods (cdr methods)))
2237 (defun gnus-info-find-node ()
2238 "Find Info documentation of Gnus."
2240 ;; Enlarge info window if needed.
2241 (cond ((eq major-mode 'gnus-group-mode)
2242 (gnus-configure-windows '(1 0 0)) ;Take all windows.
2243 (pop-to-buffer gnus-group-buffer))
2244 ((eq major-mode 'gnus-summary-mode)
2245 (gnus-configure-windows '(0 1 0)) ;Take all windows.
2246 (pop-to-buffer gnus-summary-buffer)))
2247 (Info-goto-node (car (cdr (assq major-mode gnus-info-nodes)))))
2250 "Send a bug report to the Gnus maintainers."
2252 (pop-to-buffer "*Gnus Bug*")
2254 (mail-setup gnus-maintainer "[Gnus Bug Report] " nil nil nil nil)
2255 (goto-char (point-min))
2256 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
2258 (insert (format "%s\n%s\n\n" (gnus-version) (emacs-version)))
2263 (defun gnus-debug ()
2264 "Attemps to go through the Gnus source file and report what variables have been changed.
2265 The source file has to be in the Emacs load path."
2267 (let ((dirs load-path)
2270 (if (file-exists-p (setq file (concat (car dirs) "/gnus.el")))
2273 (set-buffer (get-buffer-create "*gnus bug info*"))
2274 (buffer-disable-undo (current-buffer))
2276 (insert-file-contents file)
2277 (goto-char (point-min))
2278 (or (search-forward "\n;; Internal variables" nil t)
2279 (error "Malformed sources"))
2280 (narrow-to-region (point-min) (point))
2281 (goto-char (point-min))
2282 (while (setq expr (condition-case ()
2283 (read (current-buffer)) (error nil)))
2284 (and (eq (car expr) 'defvar)
2285 (stringp (nth 3 expr))
2286 (not (equal (eval (nth 2 expr))
2287 (and (boundp (nth 1 expr))
2288 (symbol-value (nth 1 expr)))))
2289 (setq olist (cons (nth 1 expr) olist))))
2290 (kill-buffer (current-buffer)))
2291 (setq dirs (cdr dirs))))
2293 (insert "(setq " (symbol-name (car olist)) " '"
2294 (prin1-to-string (symbol-value (car olist))) ")\n")
2295 (setq olist (cdr olist)))
2298 (defun gnus-overload-functions (&optional overloads)
2299 "Overload functions specified by optional argument OVERLOADS.
2300 If nothing is specified, use the variable gnus-overload-functions."
2302 (overloads (or overloads gnus-overload-functions)))
2304 (setq defs (car overloads))
2305 (setq overloads (cdr overloads))
2306 ;; Load file before overloading function if necessary. Make
2307 ;; sure we cannot use `require' always.
2308 (and (not (fboundp (car defs)))
2309 (car (cdr (cdr defs)))
2310 (load (car (cdr (cdr defs))) nil 'nomessage))
2311 (fset (car defs) (car (cdr defs))))))
2313 (defun gnus-replace-chars-in-string (string from to)
2314 "Replace characters in STRING from FROM to TO."
2315 (let ((string (substring string 0)) ;Copy string.
2316 (len (length string))
2318 ;; Replace all occurrences of FROM with TO.
2320 (if (= (aref string idx) from)
2321 (aset string idx to))
2322 (setq idx (1+ idx)))
2325 (defun gnus-days-between (date1 date2)
2326 ;; Return the number of days between date1 and date2.
2327 (let ((d1 (mapcar (lambda (s) (and s (string-to-int s)) )
2328 (timezone-parse-date date1)))
2329 (d2 (mapcar (lambda (s) (and s (string-to-int s)) )
2330 (timezone-parse-date date2))))
2331 (- (timezone-absolute-from-gregorian
2332 (nth 1 d1) (nth 2 d1) (car d1))
2333 (timezone-absolute-from-gregorian
2334 (nth 1 d2) (nth 2 d2) (car d2)))))
2336 (defun gnus-day-number (date)
2337 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2338 (timezone-parse-date date))))
2339 (timezone-absolute-from-gregorian
2340 (nth 1 dat) (nth 2 dat) (car dat))))
2342 (defun gnus-file-newer-than (file date)
2343 (let ((fdate (nth 5 (file-attributes file))))
2344 (or (> (car fdate) (car date))
2345 (and (= (car fdate) (car date))
2346 (> (nth 1 fdate) (nth 1 date))))))
2348 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2350 (defun gnus-y-or-n-p (prompt)
2355 (defun gnus-yes-or-no-p (prompt)
2357 (yes-or-no-p prompt)
2360 ;; Return a string of length POS+1 representing NUMber in BASE. The
2361 ;; resulting string will be left padded with zeds.
2362 (defun gnus-number-base-x (num pos base)
2367 (aref "zyxwvutsrqponmlkjihgfedcba9876543210" (/ num (expt base pos))))
2369 (% num (expt base pos)) (1- pos) base))))
2371 ;; Check whether to use long file names.
2372 (defun gnus-use-long-file-name (symbol)
2373 (and gnus-use-long-file-name
2374 (or (not (listp gnus-use-long-file-name))
2375 (not (memq 'symbol gnus-use-long-file-name)))))
2377 ;; List and range functions
2379 (defun gnus-last-element (list)
2380 "Return last element of LIST."
2382 (setq list (cdr list)))
2385 (defun gnus-copy-sequence (list)
2386 "Do a complete, total copy of a list."
2387 (mapcar (lambda (elem) (if (consp elem)
2388 (if (consp (cdr elem))
2389 (gnus-copy-sequence elem)
2390 (cons (car elem) (cdr elem)))
2394 (defun gnus-set-difference (list1 list2)
2395 "Return a list of elements of LIST1 that do not appear in LIST2."
2396 (let ((list1 (copy-sequence list1)))
2398 (setq list1 (delq (car list2) list1))
2399 (setq list2 (cdr list2)))
2402 (defun gnus-sorted-complement (list1 list2)
2403 "Return a list of elements of LIST1 that do not appear in LIST2.
2404 Both lists have to be sorted over <."
2406 (while (and list1 list2)
2407 (cond ((= (car list1) (car list2))
2408 (setq list1 (cdr list1)
2410 ((< (car list1) (car list2))
2411 (setq out (cons (car list1) out))
2412 (setq list1 (cdr list1)))
2414 (setq out (cons (car list2) out))
2415 (setq list2 (cdr list2)))))
2416 (nreverse (append (or list1 list2) out))))
2418 (defun gnus-intersection (list1 list2)
2421 (if (memq (car list2) list1)
2422 (setq result (cons (car list2) result)))
2423 (setq list2 (cdr list2)))
2426 (defun gnus-sorted-intersection (list1 list2)
2427 ;; LIST1 and LIST2 have to be sorted over <.
2429 (while (and list1 list2)
2430 (cond ((= (car list1) (car list2))
2431 (setq out (cons (car list1) out)
2434 ((< (car list1) (car list2))
2435 (setq list1 (cdr list1)))
2437 (setq list2 (cdr list2)))))
2440 (defun gnus-set-sorted-intersection (list1 list2)
2441 ;; LIST1 and LIST2 have to be sorted over <.
2442 ;; This function modifies LIST1.
2443 (let* ((top (cons nil list1))
2445 (while (and list1 list2)
2446 (cond ((= (car list1) (car list2))
2450 ((< (car list1) (car list2))
2451 (setcdr prev (cdr list1))
2452 (setq list1 (cdr list1)))
2454 (setq list2 (cdr list2)))))
2458 (defun gnus-compress-sequence (numbers &optional always-list)
2459 "Convert list of numbers to a list of ranges or a single range.
2460 If ALWAYS-LIST is non-nil, this function will always release a list of
2462 (let* ((first (car numbers))
2463 (last (car numbers))
2467 (if (not (listp (cdr numbers)))
2470 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2471 ((= (1+ last) (car numbers)) ;Still in sequence
2472 (setq last (car numbers)))
2473 (t ;End of one sequence
2475 (cons (if (= first last) first (cons first last)) result))
2476 (setq first (car numbers))
2477 (setq last (car numbers))))
2478 (setq numbers (cdr numbers)))
2479 (if (and (not always-list) (null result))
2480 (if (= first last) first (cons first last))
2481 (nreverse (cons (if (= first last) first (cons first last))
2484 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2485 (defun gnus-uncompress-range (ranges)
2486 "Expand a list of ranges into a list of numbers.
2487 RANGES is either a single range on the form `(num . num)' or a list of
2489 (let (first last result)
2493 ((not (listp (cdr ranges)))
2494 (setq first (car ranges))
2495 (setq last (cdr ranges))
2496 (while (<= first last)
2497 (setq result (cons first result))
2498 (setq first (1+ first)))
2502 (if (atom (car ranges))
2503 (if (numberp (car ranges))
2504 (setq result (cons (car ranges) result)))
2505 (setq first (car (car ranges)))
2506 (setq last (cdr (car ranges)))
2507 (while (<= first last)
2508 (setq result (cons first result))
2509 (setq first (1+ first))))
2510 (setq ranges (cdr ranges)))
2511 (nreverse result)))))
2513 (defun gnus-add-to-range (ranges list)
2514 "Return a list of ranges that has all articles from both RANGES and LIST.
2515 Note: LIST has to be sorted over `<'."
2517 (gnus-compress-sequence list t)
2518 (setq list (copy-sequence list))
2519 (or (listp (cdr ranges))
2520 (setq ranges (list ranges)))
2522 ilist lowest highest temp)
2523 (while (and ranges list)
2525 (setq lowest (or (and (atom (car ranges)) (car ranges))
2526 (car (car ranges))))
2527 (while (and list (cdr list) (< (car (cdr list)) lowest))
2528 (setq list (cdr list)))
2529 (if (< (car ilist) lowest)
2532 (setq list (cdr list))
2534 (setq out (nconc (gnus-compress-sequence ilist t) out))))
2535 (setq highest (or (and (atom (car ranges)) (car ranges))
2536 (cdr (car ranges))))
2537 (while (and list (<= (car list) highest))
2538 (setq list (cdr list)))
2539 (setq ranges (cdr ranges)))
2541 (setq out (nconc (gnus-compress-sequence list t) out)))
2542 (setq out (sort out (lambda (r1 r2)
2543 (< (or (and (atom r1) r1) (car r1))
2544 (or (and (atom r2) r2) (car r2))))))
2547 (if (atom (car ranges))
2549 (if (atom (car (cdr ranges)))
2550 (if (= (1+ (car ranges)) (car (cdr ranges)))
2552 (setcar ranges (cons (car ranges)
2553 (car (cdr ranges))))
2554 (setcdr ranges (cdr (cdr ranges)))))
2555 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
2557 (setcar (car (cdr ranges)) (car ranges))
2558 (setcar ranges (car (cdr ranges)))
2559 (setcdr ranges (cdr (cdr ranges)))))))
2561 (if (atom (car (cdr ranges)))
2562 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
2564 (setcdr (car ranges) (car (cdr ranges)))
2565 (setcdr ranges (cdr (cdr ranges)))))
2566 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
2568 (setcdr (car ranges) (cdr (car (cdr ranges))))
2569 (setcdr ranges (cdr (cdr ranges))))))))
2570 (setq ranges (cdr ranges)))
2573 (defun gnus-add-to-range-new (ranges list)
2574 (gnus-compress-sequence
2575 (sort (nconc (gnus-uncompress-range ranges) list) '<)))
2577 (defun gnus-add-to-range-old (ranges list)
2578 "Return a list of ranges that has all articles from both RANGES and LIST.
2579 Note: LIST has to be sorted over `<'."
2580 (let* ((ranges (if (and ranges (not (listp (cdr ranges))))
2581 (list ranges) ranges))
2584 range nranges first last)
2588 (gnus-compress-sequence list t)
2590 (> (car (car ranges)) 1)
2593 (setq inrange (setq ranges (cons (cons 1 1) ranges)))))
2594 (while (and ranges list)
2595 (setq range (car ranges))
2596 (while (and list (>= (car list) (car range))
2597 (<= (car list) (cdr range)))
2598 (setq list (cdr list)))
2599 (while (and list (= (1- (car list)) (cdr range)))
2600 (setcdr range (car list))
2601 (setq list (cdr list)))
2602 (if (and list (and (> (car list) (cdr range))
2604 (< (car list) (car (car (cdr ranges))))))
2605 (setcdr ranges (cons (cons (car list) (car list)) (cdr ranges))))
2606 (setq ranges (cdr ranges)))
2607 (if (and list (not ranges))
2608 (setq inrange (nconc inrange (gnus-compress-sequence list t))))
2610 (if (eq (cdr (car inrange)) 1)
2611 (setq inrange (cdr inrange))
2612 (setcar (car inrange) 2)))
2613 (setq ranges inrange)
2615 (if (and (cdr ranges) (>= (1+ (cdr (car ranges)))
2616 (car (car (cdr ranges)))))
2618 (setcdr (car ranges) (cdr (car (cdr ranges))))
2619 (setcdr ranges (cdr (cdr ranges))))
2620 (setq ranges (cdr ranges))))
2621 (if (not (cdr inrange))
2625 (defun gnus-remove-from-range (ranges list)
2626 "Return a list of ranges that has all articles from LIST removed from RANGES.
2627 Note: LIST has to be sorted over `<'."
2628 ;; !!! This function shouldn't look like this, but I've got a headache.
2629 (gnus-compress-sequence
2630 (gnus-sorted-complement
2631 (gnus-uncompress-range ranges) list)))
2633 (defun gnus-member-of-range (number ranges)
2634 (if (not (listp (cdr ranges)))
2635 (and (>= number (car ranges))
2636 (<= number (cdr ranges)))
2639 (if (numberp (car ranges))
2640 (>= number (car ranges))
2641 (>= number (car (car ranges))))
2643 (if (if (numberp (car ranges))
2644 (= number (car ranges))
2645 (and (>= number (car (car ranges)))
2646 (<= number (cdr (car ranges)))))
2647 (setq not-stop nil))
2648 (setq ranges (cdr ranges)))
2656 (defvar gnus-group-mode-map nil)
2657 (defvar gnus-group-make-map nil)
2658 (defvar gnus-group-list-map nil)
2659 (defvar gnus-group-sub-map nil)
2660 (put 'gnus-group-mode 'mode-class 'special)
2662 (if gnus-group-mode-map
2664 (setq gnus-group-mode-map (make-keymap))
2665 (suppress-keymap gnus-group-mode-map)
2666 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
2667 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
2668 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
2669 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
2670 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
2671 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
2672 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
2673 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
2674 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
2675 (define-key gnus-group-mode-map "\M-n" 'gnus-group-next-unread-group-same-level)
2676 (define-key gnus-group-mode-map "\M-p" 'gnus-group-prev-unread-group-same-level)
2677 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
2678 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
2679 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
2680 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
2681 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
2682 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
2683 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
2684 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
2685 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
2686 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
2687 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
2688 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
2689 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
2690 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
2691 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
2692 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
2693 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
2694 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
2695 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
2696 (define-key gnus-group-mode-map "\C-c\M-C-a" 'gnus-group-description-apropos)
2697 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
2698 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
2699 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
2700 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
2701 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
2702 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
2703 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
2704 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
2705 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
2706 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
2707 (define-key gnus-group-mode-map "V" 'gnus-version)
2708 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
2709 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
2710 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
2711 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
2712 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
2713 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
2714 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
2715 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
2716 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group)
2717 (define-key gnus-group-mode-map
2718 (if gnus-xemacs [button2] [mouse-2]) 'gnus-mouse-pick-group)
2720 (define-prefix-command 'gnus-group-make-map)
2721 (define-key gnus-group-mode-map "M" 'gnus-group-make-map)
2722 (define-key gnus-group-make-map "d" 'gnus-group-make-directory-group)
2723 (define-key gnus-group-make-map "h" 'gnus-group-make-help-group)
2724 (define-key gnus-group-make-map "a" 'gnus-group-make-archive-group)
2725 (define-key gnus-group-make-map "k" 'gnus-group-make-kiboze-group)
2726 (define-key gnus-group-make-map "m" 'gnus-group-make-group)
2727 (define-key gnus-group-make-map "e" 'gnus-group-edit-group)
2729 (define-prefix-command 'gnus-group-list-map)
2730 (define-key gnus-group-mode-map "G" 'gnus-group-list-map)
2731 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
2732 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
2733 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
2734 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
2735 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
2736 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
2737 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
2738 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
2740 (define-prefix-command 'gnus-group-sub-map)
2741 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
2742 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
2743 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
2744 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
2745 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
2746 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
2747 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
2748 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
2750 (defun gnus-group-mode ()
2751 "Major mode for reading news.
2753 All normal editing commands are switched off.
2754 \\<gnus-group-mode-map>
2755 The group buffer lists (some of) the groups available. For instance,
2756 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
2757 lists all zombie groups.
2759 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
2760 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
2762 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
2764 The following commands are available:
2766 \\{gnus-group-mode-map}"
2768 (if gnus-visual (gnus-group-make-menu-bar))
2769 (kill-all-local-variables)
2770 (setq mode-line-modified "-- ")
2771 (make-local-variable 'mode-line-format)
2772 (setq mode-line-format (copy-sequence mode-line-format))
2773 (and (equal (nth 3 mode-line-format) " ")
2774 (setcar (nthcdr 3 mode-line-format) ""))
2775 (setq major-mode 'gnus-group-mode)
2776 (setq mode-name "Group")
2777 (gnus-group-set-mode-line)
2778 (setq mode-line-process nil)
2779 (use-local-map gnus-group-mode-map)
2780 (buffer-disable-undo (current-buffer))
2781 (setq truncate-lines t)
2782 (setq buffer-read-only t)
2783 (run-hooks 'gnus-group-mode-hook))
2785 (defun gnus-mouse-pick-group (e)
2788 (gnus-group-read-group nil))
2791 (defun gnus-no-server (&optional arg)
2793 If ARG is a positive number, Gnus will use that as the
2794 startup level. If ARG is nil, Gnus will be started at level 2.
2795 If ARG is non-nil and not a positive number, Gnus will
2796 prompt the user for the name of an NNTP server to use.
2797 As opposed to `gnus', this command will not connect to the local server."
2799 (gnus (or arg 2) t))
2801 (defalias '\(ding\) 'gnus)
2804 (defun gnus (&optional arg dont-connect)
2806 If ARG is non-nil and a positive number, Gnus will use that as the
2807 startup level. If ARG is non-nil and not a positive number, Gnus will
2808 prompt the user for the name of an NNTP server to use."
2810 (if (get-buffer gnus-group-buffer)
2812 (switch-to-buffer gnus-group-buffer)
2813 (gnus-group-get-new-news))
2815 (gnus-read-init-file)
2816 (let ((level (and arg (numberp arg) (> arg 0) arg))
2820 (switch-to-buffer (get-buffer-create gnus-group-buffer))
2821 (gnus-add-current-to-buffer-list)
2825 (gnus-start-news-server (and arg (not level))))))
2826 (if (and (not dont-connect)
2829 (run-hooks 'gnus-startup-hook)
2830 ;; NNTP server is successfully open.
2831 (gnus-update-format-specifications)
2832 (let ((buffer-read-only nil))
2834 (if (not gnus-inhibit-startup-message)
2836 (gnus-group-startup-message)
2838 (gnus-setup-news nil level)
2839 (and gnus-use-dribble-file (gnus-dribble-open))
2840 (or t (not gnus-novice-user)
2842 (gnus-group-describe-briefly)) ;Show brief help message.
2843 (gnus-group-list-groups level))))))
2845 (defun gnus-group-startup-message (&optional x y)
2846 "Insert startup message in current buffer."
2847 ;; Insert the message.
2864 ;; And then hack it.
2865 ;; 18 is the longest line.
2866 (indent-rigidly (point-min) (point-max)
2867 (/ (max (- (window-width) (or x 28)) 0) 2))
2868 (goto-char (point-min))
2869 ;; +4 is fuzzy factor.
2870 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2)))
2872 (defun gnus-group-setup-buffer ()
2873 (or (get-buffer gnus-group-buffer)
2875 (switch-to-buffer (get-buffer-create gnus-group-buffer))
2876 (gnus-add-current-to-buffer-list)
2877 (gnus-group-mode))))
2879 (defun gnus-group-list-groups (level &optional unread)
2880 "List newsgroups with level LEVEL or lower that have unread alticles.
2881 Default is 5, which lists all subscribed groups.
2882 If argument UNREAD is non-nil, groups with no unread articles are also listed."
2884 (setq level (or level gnus-group-default-list-level 5))
2885 (gnus-group-setup-buffer) ;May call from out of group buffer
2886 (let ((case-fold-search nil)
2887 (group (gnus-group-group-name)))
2888 (funcall gnus-group-prepare-function level unread nil)
2889 (if (zerop (buffer-size))
2890 (message gnus-no-groups-message)
2891 (goto-char (point-min))
2893 ;; Go to the first group with unread articles.
2894 (gnus-group-search-forward nil nil nil t)
2895 ;; Find the right group to put point on. If the current group
2896 ;; has disapeared in the new listing, try to find the next
2897 ;; one. If no next one can be found, just leave point at the
2898 ;; first newsgroup in the buffer.
2899 (if (not (gnus-goto-char
2900 (text-property-any (point-min) (point-max)
2901 'gnus-group (intern group))))
2902 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
2904 (not (gnus-goto-char
2906 (point-min) (point-max) 'gnus-group
2908 (setq newsrc (cdr newsrc))))))
2909 ;; Adjust cursor point.
2910 (gnus-group-position-cursor))))
2912 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
2913 "List all newsgroups with unread articles of level LEVEL or lower.
2914 If ALL is non-nil, list groups that have no unread articles.
2915 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
2916 If REGEXP, only list groups matching REGEXP."
2917 (set-buffer gnus-group-buffer)
2918 (let ((buffer-read-only nil)
2919 (newsrc (cdr gnus-newsrc-assoc))
2920 (lowest (or lowest 1))
2921 info clevel unread group)
2924 ;; List living groups.
2926 (setq info (car newsrc)
2929 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
2930 (and unread ; This group might be bogus
2932 (string-match regexp group))
2933 (<= (setq clevel (car (cdr info))) level)
2935 (or all ; We list all groups?
2936 (eq unread t) ; We list unactivated groups
2937 (> unread 0) ; We list groups with unread articles
2938 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
2939 (gnus-group-insert-group-line
2940 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
2942 ;; List dead groups.
2943 (and (>= level 8) (<= lowest 8)
2944 (gnus-group-prepare-flat-list-dead
2945 (setq gnus-zombie-list (sort gnus-zombie-list 'string<)) 8 ?Z
2947 (and (>= level 9) (<= lowest 9)
2948 (gnus-group-prepare-flat-list-dead
2949 (setq gnus-killed-list (sort gnus-killed-list 'string<)) 9 ?K
2952 (gnus-group-set-mode-line)
2953 (setq gnus-have-all-newsgroups all)
2954 (run-hooks 'gnus-group-prepare-hook)))
2956 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
2957 ;; List zombies and killed lists somehwat faster, which was
2958 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
2959 ;; this by ignoring the group format specification altogether.
2962 (setq group (car groups)
2963 groups (cdr groups))
2964 (if (or (not regexp)
2965 (string-match regexp group))
2968 (insert (format " %c *: %s\n" mark group))
2969 (add-text-properties
2971 (list 'gnus-group (intern group)
2973 'gnus-level level)))))))
2975 (defun gnus-group-real-name (group)
2976 "Find the real name of a foreign newsgroup."
2977 (if (string-match "^[^:]+:" group)
2978 (substring group (match-end 0))
2981 (defun gnus-group-prefixed-name (group method)
2982 "Return the whole name from GROUP and METHOD."
2983 (concat (format "%s" (car method))
2984 (if (assoc (format "%s" (car method)) (gnus-methods-using 'address))
2985 (concat "+" (nth 1 method)))
2988 (defun gnus-group-real-prefix (group)
2989 "Return the prefix of the current group name."
2990 (if (string-match "^[^:]+:" group)
2991 (substring group 0 (match-end 0))
2994 (defun gnus-group-method-name (group)
2995 "Return the method used for selecting GROUP."
2996 (let ((prefix (gnus-group-real-prefix group)))
2997 (if (equal prefix "")
2999 (if (string-match "^[^\\+]+\\+" prefix)
3000 (list (intern (substring prefix 0 (1- (match-end 0))))
3001 (substring prefix (match-end 0) (1- (length prefix))))
3002 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3004 (defun gnus-group-foreign-p (group)
3005 "Return nil if GROUP is native, non-nil if it is foreign."
3006 (string-match ":" group))
3008 (defun gnus-group-set-info (info)
3009 (let ((entry (gnus-gethash (car info) gnus-newsrc-hashtb)))
3011 (if (not (setq marked (nth 3 info)))
3014 (or (eq 'score (car (car marked)))
3015 (eq 'bookmark (car (car marked)))
3016 (eq 'killed (car (car marked)))
3017 (setcdr (car marked)
3018 (gnus-uncompress-range (cdr (car marked)))))
3019 (setq marked (cdr marked)))))
3023 (set-buffer gnus-group-buffer)
3025 (gnus-group-make-group
3026 (gnus-group-real-name (car info))
3027 (prin1-to-string (car (nth 4 info)))
3028 (nth 1 (nth 4 info)))
3029 (gnus-group-make-group
3031 (prin1-to-string (car gnus-select-method))
3032 (nth 1 gnus-select-method)))
3033 (message "Note: New group created")
3035 (gnus-gethash (gnus-group-prefixed-name
3036 (gnus-group-real-name (car info))
3037 (or (nth 4 info) gnus-select-method))
3038 gnus-newsrc-hashtb))))
3041 (setcar (nthcdr 2 entry) info)
3042 (if (and (not (eq (car entry) t))
3043 (gnus-gethash (car info) gnus-active-hashtb))
3044 (let ((marked (nth 3 info)))
3046 (max 0 (- (length (gnus-list-of-unread-articles
3048 (length (cdr (assq 'tick marked)))
3049 (length (cdr (assq 'dormant marked)))))))))
3050 (error "No such group: %s" (car info)))))
3052 (defun gnus-group-update-group-line ()
3053 "This function updates the current line in the newsgroup buffer and
3054 moves the point to the colon."
3055 (let* ((buffer-read-only nil)
3056 (group (gnus-group-group-name))
3057 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3060 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3063 (delete-region (point) (save-excursion (forward-line 1) (point)))
3064 (gnus-group-insert-group-line-info group)
3066 (gnus-group-position-cursor)))
3068 (defun gnus-group-insert-group-line-info (group)
3069 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3073 (setq info (nth 2 entry))
3074 (gnus-group-insert-group-line
3075 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3076 (setq active (gnus-gethash group gnus-active-hashtb))
3077 (gnus-group-insert-group-line
3078 nil group (if (member group gnus-zombie-list) 8 9)
3079 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3081 (defun gnus-group-insert-group-line (gformat group level marked number method)
3082 (let* ((gformat (or gformat gnus-group-line-format-spec))
3083 (active (gnus-gethash group gnus-active-hashtb))
3084 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3085 (number-of-dormant (length (cdr (assq 'dormant marked))))
3086 (number-of-ticked (length (cdr (assq 'tick marked))))
3087 (number-of-ticked-and-dormant
3088 (+ number-of-ticked number-of-dormant))
3089 (number-of-unread-unticked
3090 (if (numberp number) (int-to-string (max 0 number))
3093 (if (numberp number)
3094 (max 0 (- number-total number))
3096 (subscribed (cond ((< level 6) ? )
3100 (qualified-group (gnus-group-real-name group))
3101 (newsgroup-description
3102 (if gnus-description-hashtb
3103 (or (gnus-gethash group gnus-description-hashtb) "")
3105 (moderated (if (member group gnus-moderated-list) ?m ? ))
3106 (moderated-string (if (eq moderated ?m) "(m)" ""))
3107 (news-server (or (car (cdr method)) ""))
3108 (news-method (or (car method) ""))
3110 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3114 (> number-of-ticked 0))
3116 (number (if (eq number t) "*" (+ number number-of-dormant
3118 (buffer-read-only nil)
3123 (insert (eval gformat))
3125 (add-text-properties
3126 b (1+ b) (list 'gnus-group (intern group)
3127 'gnus-unread (if (numberp number)
3128 (string-to-int number-of-unread-unticked)
3131 'gnus-level level))))
3133 (defun gnus-group-update-group (group &optional visible-only)
3134 "Update newsgroup info of GROUP.
3135 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3137 (set-buffer gnus-group-buffer)
3138 (let ((buffer-read-only nil)
3140 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3143 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3145 ;; Buffer may be narrowed.
3148 ;; Search a line to modify. If the buffer is large, the search
3149 ;; takes long time. In most cases, current point is on the line
3150 ;; we are looking for. So, first of all, check current line.
3153 (eq (get-text-property (point) 'gnus-group)
3158 (point-min) (point-max) 'gnus-group (intern group)))))
3159 ;; GROUP is listed in current buffer. So, delete old line.
3163 (delete-region (point) (progn (forward-line 1) (point))))
3164 ;; No such line in the buffer, find out where it's supposed to
3165 ;; go, and insert it there (or at the end of the buffer).
3166 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3168 (let ((entry (cdr (gnus-gethash group gnus-newsrc-hashtb))))
3173 (point-min) (point-max)
3174 'gnus-group (intern (car (car entry)))))))
3175 (setq entry (cdr entry)))
3176 (or entry (goto-char (point-max)))))))
3177 (if (or visible (not visible-only))
3178 (gnus-group-insert-group-line-info group))
3179 (gnus-group-set-mode-line))))
3181 (defun gnus-group-set-mode-line ()
3182 (if (memq 'group gnus-updated-mode-lines)
3183 (let* ((gformat (or gnus-group-mode-line-format-spec
3184 (setq gnus-group-mode-line-format-spec
3186 gnus-group-mode-line-format
3187 gnus-group-mode-line-format-alist))))
3188 (news-server (car (cdr gnus-select-method)))
3189 (news-method (car gnus-select-method))
3190 (mode-string (eval gformat))
3192 (if (> (length mode-string) max-len)
3193 (setq mode-string (substring mode-string 0 (- max-len 4))))
3194 (setq mode-line-buffer-identification mode-string)
3195 (set-buffer-modified-p t))))
3197 (defun gnus-group-group-name ()
3198 "Get the name of the newsgroup on the current line."
3199 (let ((group (get-text-property
3200 (save-excursion (beginning-of-line) (point)) 'gnus-group)))
3201 (and group (symbol-name group))))
3203 (defun gnus-group-group-level ()
3204 "Get the level of the newsgroup on the current line."
3205 (get-text-property (save-excursion (beginning-of-line) (point)) 'gnus-level))
3207 (defun gnus-group-search-forward (&optional backward all level first-too)
3208 "Find the next newsgroup with unread articles.
3209 If BACKWARD is non-nil, find the previous newsgroup instead.
3210 If ALL is non-nil, just find any newsgroup.
3211 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3213 If FIRST-TOO, the current line is also eligeble as a target."
3214 (let ((way (if backward -1 1))
3218 (or first-too (forward-line way))
3226 (get-text-property (point) 'gnus-unread)))
3227 (or (eq unread t) (and unread (> unread 0))))
3228 (let ((lev (get-text-property (point) 'gnus-level)))
3229 (and lev (< (get-text-property (point) 'gnus-level) 6)))))
3231 (let ((lev (get-text-property (point) 'gnus-level)))
3232 (if (and lev (<= lev level))
3237 (setq pos (point))))
3239 (zerop (forward-line way))))
3241 (progn (gnus-group-position-cursor) t)
3242 (if pos (goto-char pos) (goto-char beg))
3245 ;; Gnus group mode commands
3247 (defun gnus-group-read-group (all &optional no-article group)
3248 "Read news in this newsgroup.
3249 If argument ALL is non-nil, already read articles become readable.
3250 If optional argument NO-ARTICLE is non-nil, no article body is displayed."
3252 (let ((group (or group (gnus-group-group-name)))
3253 number active marked entry)
3254 (or group (error "No group on current line"))
3256 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3257 ;; This group might be a dead group. In that case we have to get
3258 ;; the number of unread articles from `gnus-active-hashtb'.
3260 (setq number (car entry))
3261 (if (setq active (gnus-gethash group gnus-active-hashtb))
3262 (setq number (- (1+ (cdr active)) (car active)))))
3263 (gnus-summary-read-group
3264 group (or all (and (numberp number)
3265 (zerop (+ number (length (cdr (assq 'tick marked)))
3266 (length (cdr (assq 'dormant marked)))))))
3269 (defun gnus-group-select-group (all)
3270 "Select this newsgroup.
3271 No article is selected automatically.
3272 If argument ALL is non-nil, already read articles become readable."
3274 (gnus-group-read-group all t))
3276 (defun gnus-group-jump-to-group (group)
3277 "Jump to newsgroup GROUP."
3278 (interactive (list (completing-read "Group: " gnus-active-hashtb nil
3279 (not (not gnus-read-active-file)))))
3281 (if (equal group "")
3282 (error "empty group name"))
3284 (let ((b (text-property-any (point-min) (point-max)
3285 'gnus-group (intern group))))
3287 ;; Either go to the line in the group buffer...
3289 ;; ... or insert the line.
3291 (gnus-gethash group gnus-active-hashtb)
3292 (gnus-activate-newsgroup group)
3293 (error "%s error: %s" group (gnus-status-message group)))
3295 (gnus-group-update-group group)
3296 (goto-char (text-property-any (point-min) (point-max)
3297 'gnus-group (intern group)))))
3298 ;; Adjust cursor point.
3299 (gnus-group-position-cursor))
3301 (defun gnus-group-next-group (n)
3302 "Go to next N'th newsgroup.
3303 If N is negative, search backward instead.
3304 Returns the difference between N and the number of skips actually
3307 (gnus-group-next-unread-group n t))
3309 (defun gnus-group-next-unread-group (n &optional all level)
3310 "Go to next N'th unread newsgroup.
3311 If N is negative, search backward instead.
3312 If ALL is non-nil, choose any newsgroup, unread or not.
3313 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
3314 such group can be found, the next group with a level higher than
3316 Returns the difference between N and the number of skips actually
3319 (let ((backward (< n 0))
3322 (gnus-group-search-forward backward all level))
3324 (if (/= 0 n) (message "No more%s newsgroups%s" (if all "" " unread")
3325 (if level " on this level or higher" "")))
3328 (defun gnus-group-prev-group (n)
3329 "Go to previous N'th newsgroup.
3330 Returns the difference between N and the number of skips actually
3333 (gnus-group-next-unread-group (- n) t))
3335 (defun gnus-group-prev-unread-group (n)
3336 "Go to previous N'th unread newsgroup.
3337 Returns the difference between N and the number of skips actually
3340 (gnus-group-next-unread-group (- n)))
3342 (defun gnus-group-next-unread-group-same-level (n)
3343 "Go to next N'th unread newsgroup on the same level.
3344 If N is negative, search backward instead.
3345 Returns the difference between N and the number of skips actually
3348 (gnus-group-next-unread-group n t (gnus-group-group-level))
3349 (gnus-group-position-cursor))
3351 (defun gnus-group-prev-unread-group-same-level (n)
3352 "Go to next N'th unread newsgroup on the same level.
3353 Returns the difference between N and the number of skips actually
3356 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
3357 (gnus-group-position-cursor))
3359 (defun gnus-group-best-unread-group (&optional exclude-group)
3360 "Go to the group with the highest level.
3361 If EXCLUDE-GROUP, do not go to that group."
3363 (goto-char (point-min))
3366 (while (setq unread (get-text-property (point) 'gnus-unread))
3367 (if (and (numberp unread) (> unread 0))
3369 (or best-point (setq best-point (point)))
3370 (if (and (< (get-text-property (point) 'gnus-level) best)
3371 (or (not exclude-group)
3372 (not (equal exclude-group (gnus-group-group-name)))))
3374 (setq best (get-text-property (point) 'gnus-level))
3375 (setq best-point (point))))))
3377 (if best-point (goto-char best-point))
3378 (gnus-summary-position-cursor)
3379 (and best-point (gnus-group-group-name))))
3381 (defun gnus-group-first-unread-group ()
3382 "Go to the first group with unread articles."
3384 (goto-char (point-min))
3385 (gnus-group-next-unread-group 1))
3387 (defun gnus-group-make-group (name method address)
3388 "Add a new newsgroup.
3389 The user will be prompted for a NAME, for a select METHOD, and an
3393 (read-string "Group name: ")
3396 "Method: " gnus-valid-select-methods nil t)))
3398 (if (memq 'prompt-address
3399 (assoc method gnus-valid-select-methods))
3400 (read-string "Address: ")
3402 (let ((nname (gnus-group-prefixed-name name (list (intern method) address)))
3404 (and (gnus-gethash nname gnus-active-hashtb)
3405 (error "Group %s already exists" nname))
3406 (gnus-group-change-level
3407 (setq info (list t nname 3 nil nil (list (intern method) address)))
3408 3 9 (gnus-gethash (or (gnus-group-group-name) "dummy.group")
3409 gnus-newsrc-hashtb) t)
3410 (gnus-sethash nname '(0 . 0) gnus-active-hashtb)
3412 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
3413 (gnus-group-insert-group-line-info nname)
3415 (and (gnus-check-backend-function 'request-create-group nname)
3416 (gnus-request-create-group nname))))
3418 (defun gnus-group-edit-group (group)
3419 (interactive (list (gnus-group-group-name)))
3421 (if group (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
3422 (error "No group on current line"))
3423 (setq gnus-winconf-edit-group (current-window-configuration))
3424 (pop-to-buffer (get-buffer-create gnus-group-edit-buffer))
3425 (gnus-add-current-to-buffer-list)
3427 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3428 (use-local-map (copy-keymap emacs-lisp-mode-map))
3429 (local-set-key "\C-c\C-c" 'gnus-group-edit-group-done)
3431 (insert ";; Type `C-c C-c' after you have edited the newsgroup entry.\n\n")
3432 (let ((cinfo (gnus-copy-sequence info))
3434 (if (not (setq marked (nth 3 cinfo)))
3437 (or (eq 'score (car (car marked)))
3438 (eq 'bookmark (car (car marked)))
3439 (eq 'killed (car (car marked)))
3440 (setcdr (car marked)
3441 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
3442 (setq marked (cdr marked))))
3443 (insert (pp-to-string (list 'gnus-group-set-info
3444 (list 'quote cinfo)))))))
3446 (defun gnus-group-edit-group-done ()
3448 (set-buffer (get-buffer-create gnus-group-edit-buffer))
3449 (eval-current-buffer)
3450 (kill-buffer (current-buffer))
3451 (and gnus-winconf-edit-group
3452 (set-window-configuration gnus-winconf-edit-group))
3453 (setq gnus-winconf-edit-group nil)
3454 (set-buffer gnus-group-buffer)
3455 (gnus-group-update-group (gnus-group-group-name))
3456 (gnus-group-position-cursor))
3458 (defun gnus-group-make-help-group ()
3459 "Create the (ding) Gnus documentation group."
3461 (and (gnus-gethash (gnus-group-prefixed-name "gnus-help" '(nndoc ""))
3463 (error "Documentation group already exists"))
3464 (let ((path load-path))
3466 (not (file-exists-p (concat (file-name-as-directory (car path))
3468 (setq path (cdr path)))
3469 (or path (error "Couldn't find doc group"))
3470 (gnus-group-make-group
3472 (concat (file-name-as-directory (car path)) "doc.txt"))
3473 (gnus-group-position-cursor)))
3475 (defun gnus-group-make-archive-group ()
3476 "Create the (ding) Gnus archive group."
3478 (and (gnus-gethash (gnus-group-prefixed-name "ding.archives" '(nndir ""))
3480 (error "Archive group already exists"))
3481 (gnus-group-make-group "ding.archives" "nndir" gnus-group-archive-directory)
3482 (gnus-group-position-cursor))
3484 (defun gnus-group-make-directory-group (dir)
3485 "Create an nndir group.
3486 The user will be prompted for a directory. The contents of this
3487 directory will be used as a newsgroup. The directory should contain
3488 mail messages or news articles in files that have numeric names."
3490 (list (read-file-name "Create group from directory: ")))
3491 (or (file-exists-p dir) (error "No such directory"))
3492 (or (file-directory-p dir) (error "Not a directory"))
3493 (gnus-group-make-group dir "nndir" dir)
3494 (gnus-group-position-cursor))
3496 (defun gnus-group-make-kiboze-group (group address scores)
3497 "Create an nnkiboze group.
3498 The user will be prompted for a name, a regexp to match groups, and
3499 score file entries for articles to include in the group."
3502 (read-string "nnkiboze group name: ")
3503 (read-string "Source groups (regexp): ")
3504 (let ((headers (mapcar (lambda (group) (list group))
3505 '("subject" "from" "number" "date" "message-id"
3506 "references" "chars" "lines" "xref")))
3507 scores header regexp regexps)
3508 (while (not (equal "" (setq header (completing-read
3509 "Match on header: " headers nil t))))
3511 (while (not (equal "" (setq regexp (read-string
3512 (format "Match on %s (string): "
3514 (setq regexps (cons (list regexp nil 1000 nil) regexps)))
3515 (setq scores (cons (cons header regexps) scores)))
3517 (gnus-group-make-group group "nnkiboze" address)
3519 (set-buffer (get-buffer-create " *gnus work*"))
3520 (buffer-disable-undo (current-buffer))
3521 (let (emacs-lisp-mode-hook)
3522 (pp (list 'setq 'gnus-score-alist
3523 (list 'quote (list scores)))
3525 (write-region (point-min) (point-max)
3526 (concat (or gnus-kill-files-directory "~/News")
3527 "nnkiboze:" group "." gnus-score-file-suffix))
3528 (kill-buffer (current-buffer)))
3529 (gnus-group-position-cursor))
3531 ;; Group sorting commands
3532 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
3534 (defun gnus-group-sort-groups ()
3535 "Sort the group buffer using `gnus-group-sort-function'."
3537 (setq gnus-newsrc-assoc
3538 (sort (cdr gnus-newsrc-assoc) gnus-group-sort-function))
3539 (gnus-make-hashtable-from-newsrc-alist)
3540 (gnus-get-unread-articles 6)
3541 (gnus-group-list-groups nil))
3543 (defun gnus-group-sort-by-alphabet (info1 info2)
3544 (string< (car info1) (car info2)))
3546 (defun gnus-group-sort-by-unread (info1 info2)
3547 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
3548 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
3549 (< (or (and (numberp n1) n1) 0)
3550 (or (and (numberp n2) n2) 0))))
3552 (defun gnus-group-sort-by-level (info1 info2)
3553 (< (nth 1 info1) (nth 1 info2)))
3555 ;; Group catching up.
3557 (defun gnus-group-catchup-current (n &optional all)
3558 "Mark all articles not marked as unread in current newsgroup as read.
3559 If prefix argument N is numeric, the ARG next newsgroups will be
3560 caught up. If ALL is non-nil, marked articles will also be marked as
3561 read. Cross references (Xref: header) of articles are ignored.
3562 The difference between N and actual number of newsgroups that were
3563 caught up is returned."
3565 (if (or (not gnus-interactive-catchup) ;Without confirmation?
3569 "Do you really want to mark all articles as read? "
3570 "Mark all unread articles as read? ")))
3576 (gnus-group-catchup (gnus-group-group-name) all)
3577 (gnus-group-update-group-line)
3579 (zerop (gnus-group-next-unread-group 1))))))
3582 (defun gnus-group-catchup-current-all (n)
3583 "Mark all articles in current newsgroup as read.
3584 Cross references (Xref: header) of articles are ignored."
3586 (gnus-group-catchup-current n 'all))
3588 (defun gnus-group-catchup (group &optional all)
3589 "Mark all articles in GROUP as read.
3590 If ALL is non-nil, all articles are marked as read.
3591 The return value is the number of articles that were marked as read,
3592 or nil if no action could be taken."
3593 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3595 (marked (nth 3 (nth 2 entry)))
3597 (if (not (numberp (car entry)))
3598 (message "Can't catch up; non-active group")
3599 ;; Do the updating only if the newsgroup isn't killed
3602 (setq ticked (if all nil (cdr (assq 'tick marked))))
3603 (gnus-update-read-articles group ticked nil ticked)
3604 (if (and all marked)
3605 (setcar (nthcdr 3 (nth 2 entry))
3606 (delq (assq 'dormant marked) marked))))))
3609 (defun gnus-group-expire-articles (newsgroup)
3610 "Expire all expirable articles in the current newsgroup."
3611 (interactive (list (gnus-group-group-name)))
3612 (if (not newsgroup) (error "No current newsgroup"))
3614 (assq 'expire (nth 3 (nth 2 (gnus-gethash newsgroup
3615 gnus-newsrc-hashtb))))))
3617 (gnus-check-backend-function 'request-expire-articles newsgroup)
3619 (gnus-request-expire-articles (cdr expirable) newsgroup)))))
3621 (defun gnus-group-expire-all-groups ()
3622 "Expire all expirable articles in all newsgroups."
3624 (message "Expiring...")
3625 (let ((newsrc (cdr gnus-newsrc-assoc)))
3627 (gnus-group-expire-articles (car (car newsrc)))
3628 (setq newsrc (cdr newsrc))))
3629 (message "Expiring...done"))
3631 (defun gnus-group-set-current-level (n)
3632 "Set the level of the current group to the numeric prefix."
3634 (setq n (or n (string-to-int
3637 (mapcar (lambda (n) (list (char-to-string n))) "123456789")
3639 (let ((group (gnus-group-group-name)))
3640 (if (not group) (error "No newsgroup on current line.")
3641 (if (and (numberp n) (>= n 1) (<= n 9))
3643 (message "Changed level of %s from %d to %d"
3644 group (gnus-group-group-level) n)
3645 (gnus-group-change-level group n (gnus-group-group-level))
3646 (gnus-group-update-group-line))
3647 (error "Illegal level: %s" n))))
3649 (gnus-group-position-cursor))
3651 (defun gnus-group-unsubscribe-current-group (arg)
3652 "Toggle subscribe from/to unsubscribe current group."
3654 (let ((group (gnus-group-group-name)))
3655 (or group (error "No newsgroup on current line"))
3656 (or arg (setq arg (if (<= (gnus-group-group-level) 5) 6 3)))
3657 (gnus-group-unsubscribe-group group arg)
3658 (gnus-group-next-group 1)))
3660 (defun gnus-group-unsubscribe-group (group &optional level)
3661 "Toggle subscribe from/to unsubscribe GROUP.
3662 New newsgroup is added to .newsrc automatically."
3664 (list (completing-read "Group: " gnus-active-hashtb nil
3665 gnus-have-read-active-file)))
3666 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3668 ;; Toggle subscription flag.
3669 (gnus-group-change-level
3670 newsrc (if level level (if (< (nth 1 (nth 2 newsrc)) 6) 6 4)))
3671 (gnus-group-update-group group))
3672 ((and (stringp group)
3673 (or (not gnus-have-read-active-file)
3674 (gnus-gethash group gnus-active-hashtb)))
3675 ;; Add new newsgroup.
3676 (gnus-group-change-level
3679 (or (and (member group gnus-zombie-list) 8) 9)
3680 (or (and (gnus-group-group-name)
3681 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb))
3682 (gnus-gethash (car (car gnus-newsrc-assoc))
3683 gnus-newsrc-hashtb)))
3684 (gnus-group-update-group group))
3685 (t (error "No such newsgroup: %s" group)))
3686 (gnus-group-position-cursor)))
3688 (defun gnus-group-transpose-groups (arg)
3689 "Exchange current newsgroup and previous newsgroup.
3690 With argument ARG, takes previous newsgroup and moves it past ARG newsgroup."
3692 ;; BUG: last newsgroup and the last but one cannot be transposed
3693 ;; since gnus-group-search-forward does not move forward beyond the
3694 ;; last. If we instead use forward-line, no problem, but I don't
3695 ;; want to use it for later extension.
3697 (gnus-group-search-forward t t)
3698 (gnus-group-kill-group 1)
3699 (gnus-group-search-forward nil t)
3700 (gnus-group-yank-group)
3701 (gnus-group-search-forward nil t)
3702 (setq arg (1- arg))))
3704 (defun gnus-group-kill-all-zombies ()
3705 "Kill all zombie newsgroups."
3707 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3708 (setq gnus-zombie-list nil)
3709 (funcall gnus-group-prepare-function 5 nil nil)
3710 (goto-char (point-min))
3711 (gnus-group-position-cursor))
3713 (defun gnus-group-kill-region (begin end)
3714 "Kill newsgroups in current region (excluding current point).
3715 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3718 ;; Exclude a line where current point is on.
3732 (beginning-of-line) ;Important when LINES < 1
3733 (gnus-group-kill-group lines)))
3735 (defun gnus-group-kill-group (n)
3736 "The the next N groups.
3737 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3738 However, only groups that were alive can be yanked; already killed
3739 groups or zombie groups can't be yanked.
3740 The return value is the name of the (last) newsgroup that was killed."
3742 (let ((buffer-read-only nil)
3744 (while (>= (setq n (1- n)) 0)
3745 (setq group (gnus-group-group-name))
3747 (signal 'end-of-buffer nil))
3748 (setq level (gnus-group-group-level))
3750 (delete-region (point) (progn (forward-line 1) (point)))
3751 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
3752 (setq gnus-list-of-killed-groups
3753 (cons (cons (car entry) (nth 2 entry))
3754 gnus-list-of-killed-groups)))
3755 (gnus-group-change-level (if entry entry group) 9 (if entry nil level)))
3758 (gnus-group-position-cursor)
3761 (defun gnus-group-yank-group (&optional arg)
3762 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
3763 inserting it before the current newsgroup. The numeric ARG specifies
3764 how many newsgroups are to be yanked. The name of the (last)
3765 newsgroup yanked is returned."
3767 (if (not arg) (setq arg 1))
3768 (let (info group prev)
3769 (while (>= (setq arg (1- arg)) 0)
3770 (if (not (setq info (car gnus-list-of-killed-groups)))
3771 (error "No more newsgroups to yank"))
3772 (setq group (nth 2 info))
3773 ;; Find which newsgroup to insert this one before - search
3774 ;; backward until something suitable is found. If there are no
3775 ;; other newsgroups in this buffer, just make this newsgroup the
3777 (while (and (not (setq prev (gnus-group-group-name)))
3778 (zerop (forward-line -1))))
3780 (setq prev (car (car gnus-newsrc-assoc))))
3781 (gnus-group-change-level
3783 (gnus-gethash prev gnus-newsrc-hashtb)
3785 (gnus-group-insert-group-line-info (nth 1 info))
3786 (setq gnus-list-of-killed-groups
3787 (cdr gnus-list-of-killed-groups)))
3789 (gnus-group-position-cursor)
3792 (defun gnus-group-list-all-groups (arg)
3793 "List all newsgroups with level ARG or lower.
3794 Default is 7, which lists all subscribed and most unsubscribed groups."
3796 (setq arg (or arg 7))
3797 (gnus-group-list-groups arg t))
3799 (defun gnus-group-list-killed ()
3800 "List all killed newsgroups in the group buffer."
3802 (if (not gnus-killed-list)
3803 (message "No killed groups")
3804 (funcall gnus-group-prepare-function 9 t 9)
3805 (goto-char (point-min)))
3806 (gnus-group-position-cursor))
3808 (defun gnus-group-list-zombies ()
3809 "List all zombie newsgroups in the group buffer."
3811 (if (not gnus-zombie-list)
3812 (message "No zombie groups")
3813 (funcall gnus-group-prepare-function 8 t 8)
3814 (goto-char (point-min)))
3815 (gnus-group-position-cursor))
3817 (defun gnus-group-get-new-news (&optional arg)
3818 "Get newly arrived articles.
3819 If ARG is non-nil, it should be a number between one and nine to
3820 specify which levels you are interested in re-scanning."
3822 (run-hooks 'gnus-get-new-news-hook)
3823 (if (and gnus-read-active-file (not arg))
3825 (gnus-read-active-file)
3826 (gnus-get-unread-articles (or arg 6)))
3827 (let ((gnus-read-active-file nil))
3828 (gnus-get-unread-articles (or arg 6))))
3829 (gnus-group-list-groups nil gnus-have-all-newsgroups))
3831 (defun gnus-group-get-new-news-this-group (n)
3832 "Check for newly arrived news in the current group (and the N-1 next groups).
3833 The difference between N and the number of newsgroup checked is returned.
3834 If N is negative, this group and the N-1 previous groups will be checked."
3836 (let ((way (if (< n 0) -1 1))
3838 (w-p (window-start))
3842 (or (gnus-get-new-news-in-group
3843 (setq group (gnus-group-group-name)))
3846 (message "%s error: %s"
3847 group (gnus-status-message group))))
3849 (zerop (gnus-group-next-group way)))
3851 (if (/= 0 n) (message "No more newsgroups"))
3852 ;; !!! I don't know why the buffer scrolls forward when updating
3853 ;; the first line in the group buffer, but it does. So we set the
3854 ;; window start forcibly.
3855 (set-window-start (get-buffer-window (current-buffer)) w-p)
3858 (defun gnus-get-new-news-in-group (group)
3860 (gnus-activate-newsgroup group)
3862 (gnus-get-unread-articles-in-group
3863 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
3864 (gnus-gethash group gnus-active-hashtb))
3865 (gnus-group-update-group-line)
3868 (defun gnus-group-fetch-faq (group)
3869 "Fetch the FAQ for the current group."
3870 (interactive (list (gnus-group-group-name)))
3871 (or group (error "No group name given"))
3872 (let ((file (concat gnus-group-faq-directory group)))
3873 (if (not (file-exists-p file))
3874 (error "No such file: %s" file)
3877 (defun gnus-group-describe-group (force &optional group)
3878 "Display a description of the current newsgroup."
3880 (and force (setq gnus-description-hashtb nil))
3881 (let ((group (or group (gnus-group-group-name)))
3883 (or group (message "No group name given"))
3884 (and (or gnus-description-hashtb
3885 (setq desc (gnus-group-get-description group))
3886 (gnus-read-descriptions-file))
3888 (or desc (gnus-gethash group gnus-description-hashtb)
3889 "No description available")))))
3891 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3892 (defun gnus-group-describe-all-groups (force)
3893 "Pop up a buffer with descriptons of all newsgroups."
3895 (and force (setq gnus-description-hashtb nil))
3896 (if (not (or gnus-description-hashtb
3897 (gnus-read-descriptions-file)))
3898 (error "Couldn't request descriptions file"))
3899 (let ((buffer-read-only nil)
3905 (insert (format " *: %-20s %s\n" (symbol-name group)
3906 (symbol-value group)))
3907 (add-text-properties
3908 b (1+ b) (list 'gnus-group group
3909 'gnus-unread t 'gnus-marked nil 'gnus-level 6)))
3910 gnus-description-hashtb)
3911 (goto-char (point-min))
3912 (gnus-group-position-cursor)))
3914 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
3915 (defun gnus-group-apropos (regexp &optional search-description)
3916 "List all newsgroups that have names that match a regexp."
3917 (interactive "sGnus apropos (regexp): ")
3919 (obuf (current-buffer))
3921 ;; Go through all newsgroups that are known to Gnus.
3924 (and (string-match regexp (symbol-name group))
3925 (setq groups (cons (symbol-name group) groups))))
3927 ;; Go through all descriptions that are known to Gnus.
3928 (if search-description
3931 (and (string-match regexp (symbol-value group))
3932 (gnus-gethash (symbol-name group) gnus-active-hashtb)
3933 (setq groups (cons (symbol-name group) groups))))
3934 gnus-description-hashtb))
3936 (message "No groups matched \"%s\"." regexp)
3937 ;; Print out all the groups.
3939 (pop-to-buffer (get-buffer-create "*Gnus Help*"))
3940 (buffer-disable-undo (current-buffer))
3942 (setq groups (sort groups 'string<))
3944 ;; Groups may be entered twice into the list of groups.
3945 (if (not (string= (car groups) prev))
3947 (insert (setq prev (car groups)) "\n")
3948 (if (and gnus-description-hashtb
3949 (setq des (gnus-gethash (car groups)
3950 gnus-description-hashtb)))
3951 (insert " " des "\n"))))
3952 (setq groups (cdr groups)))
3954 (pop-to-buffer obuf)))
3956 (defun gnus-group-description-apropos (regexp)
3957 "List all newsgroups that have names or desccriptions that match a regexp."
3958 (interactive "sGnus description apropos (regexp): ")
3959 (if (not (or gnus-description-hashtb
3960 (gnus-read-descriptions-file)))
3961 (error "Couldn't request descriptions file"))
3962 (gnus-group-apropos regexp t))
3964 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3965 (defun gnus-group-list-matching (level regexp &optional all lowest)
3966 "List all groups with unread articles that match REGEXP.
3967 If the prefix LEVEL is non-nil, it should be a number that says which
3968 level to cut off listing groups.
3969 If ALL, also list groups with no unread articles.
3970 If LOWEST, don't list groups with level lower than LOWEST."
3971 (interactive "P\nsList newsgroups matching: ")
3972 (gnus-group-prepare-flat (or level 5) all (or lowest 1) regexp)
3973 (goto-char (point-min))
3974 (gnus-group-position-cursor))
3976 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3977 "List all groups that match REGEXP.
3978 If the prefix LEVEL is non-nil, it should be a number that says which
3979 level to cut off listing groups.
3980 If LOWEST, don't list groups with level lower than LOWEST."
3981 (interactive "P\nsList newsgroups matching: ")
3982 (gnus-group-list-matching (or level 9) regexp t lowest))
3984 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3985 (defun gnus-group-save-newsrc ()
3986 "Save the Gnus startup files."
3988 (gnus-save-newsrc-file))
3990 (defun gnus-group-restart (&optional arg)
3991 "Force Gnus to read the .newsrc file."
3993 (gnus-save-newsrc-file)
3994 (gnus-setup-news 'force)
3995 (gnus-group-list-groups arg gnus-have-all-newsgroups))
3997 (defun gnus-group-read-init-file ()
3998 "Read the Gnus elisp init file."
4000 (gnus-read-init-file))
4002 (defun gnus-group-check-bogus-groups ()
4003 "Check bogus newsgroups."
4005 (gnus-check-bogus-newsgroups (not gnus-expert-user)) ;Require confirmation.
4006 (gnus-group-list-groups nil gnus-have-all-newsgroups))
4008 (defun gnus-group-mail ()
4009 "Start composing a mail."
4013 (defun gnus-group-edit-global-kill (article &optional group)
4014 "Edit the global kill file.
4015 If GROUP, edit that local kill file instead."
4017 (setq gnus-current-kill-article article)
4018 (gnus-kill-file-edit-file group)
4020 (substitute-command-keys
4021 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
4023 (defun gnus-group-edit-local-kill (article group)
4024 "Edit a local kill file."
4025 (interactive (list nil (gnus-group-group-name)))
4026 (gnus-group-edit-global-kill article group))
4028 (defun gnus-group-force-update ()
4029 "Update `.newsrc' file."
4031 (gnus-save-newsrc-file))
4033 (defun gnus-group-suspend ()
4034 "Suspend the current Gnus session.
4035 In fact, cleanup buffers except for group mode buffer.
4036 The hook gnus-suspend-gnus-hook is called before actually suspending."
4038 (run-hooks 'gnus-suspend-gnus-hook)
4039 ;; Kill Gnus buffers except for group mode buffer.
4040 (let ((group-buf (get-buffer gnus-group-buffer)))
4041 (while gnus-buffer-list
4042 (and (not (eq (get-buffer (car gnus-buffer-list)) group-buf))
4043 (not (eq (get-buffer (car gnus-buffer-list)) gnus-dribble-buffer))
4044 (get-buffer (car gnus-buffer-list))
4045 (buffer-name (get-buffer (car gnus-buffer-list)))
4046 (kill-buffer (car gnus-buffer-list)))
4047 (setq gnus-buffer-list (cdr gnus-buffer-list)))
4048 (setq gnus-buffer-list (list group-buf))
4049 (bury-buffer group-buf)
4050 (delete-windows-on group-buf t)))
4052 (defun gnus-group-clear-dribble ()
4053 "Clear all information from the dribble buffer."
4055 (gnus-dribble-clear))
4057 (defun gnus-group-exit ()
4058 "Quit reading news after updating .newsrc.eld and .newsrc.
4059 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4061 (if (or noninteractive ;For gnus-batch-kill
4062 (zerop (buffer-size)) ;No news is good news.
4063 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
4064 (not gnus-interactive-exit) ;Without confirmation
4066 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4068 (run-hooks 'gnus-exit-gnus-hook)
4069 (gnus-save-newsrc-file)
4070 (gnus-close-backends)
4071 (gnus-clear-system))))
4073 (defun gnus-close-backends ()
4074 ;; Send a close request to all backends that support such a request.
4075 (let ((methods gnus-valid-select-methods)
4078 (if (fboundp (setq func (intern (concat (car (car methods))
4079 "-request-close"))))
4081 (setq methods (cdr methods)))))
4083 (defun gnus-group-quit ()
4084 "Quit reading news without updating .newsrc.eld or .newsrc.
4085 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4087 (if (or noninteractive ;For gnus-batch-kill
4088 (zerop (buffer-size))
4089 (not (gnus-server-opened gnus-select-method))
4091 (not gnus-current-startup-file)
4093 (format "Quit reading news without saving %s? "
4094 (file-name-nondirectory gnus-current-startup-file))))
4096 (run-hooks 'gnus-exit-gnus-hook)
4098 (gnus-close-backends)
4099 (gnus-clear-system))))
4101 (defun gnus-group-describe-briefly ()
4102 "Give a one line description of the group mode commands."
4105 (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")))
4107 (defun gnus-group-browse-foreign-server (method)
4108 "Browse a foreign news server.
4109 If called interactively, this function will ask for a select method
4110 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4111 If not, METHOD should be a list where the first element is the method
4112 and the second element is the address."
4114 (list (list (intern (completing-read
4116 gnus-valid-select-methods nil t "nntp"))
4117 ;; Suggested by mapjph@bath.ac.uk.
4120 (mapcar (lambda (server) (list server))
4121 gnus-secondary-servers)))))
4122 (gnus-browse-foreign-server method))
4126 ;;; Browse Server Mode
4129 (defvar gnus-browse-server-mode-hook nil)
4130 (defvar gnus-browse-server-mode-map nil)
4131 (put 'gnus-browse-server-mode 'mode-class 'special)
4133 (if gnus-browse-server-mode-map
4135 (setq gnus-browse-server-mode-map (make-keymap))
4136 (suppress-keymap gnus-browse-server-mode-map)
4137 (define-key gnus-browse-server-mode-map " " 'gnus-browse-read-group)
4138 (define-key gnus-browse-server-mode-map "=" 'gnus-browse-read-group)
4139 (define-key gnus-browse-server-mode-map "n" 'gnus-browse-next-group)
4140 (define-key gnus-browse-server-mode-map "p" 'gnus-browse-prev-group)
4141 (define-key gnus-browse-server-mode-map "\177" 'gnus-browse-prev-group)
4142 (define-key gnus-browse-server-mode-map "N" 'gnus-browse-next-group)
4143 (define-key gnus-browse-server-mode-map "P" 'gnus-browse-prev-group)
4144 (define-key gnus-browse-server-mode-map "\M-n" 'gnus-browse-next-group)
4145 (define-key gnus-browse-server-mode-map "\M-p" 'gnus-browse-prev-group)
4146 (define-key gnus-browse-server-mode-map "\r" 'gnus-browse-read-group)
4147 (define-key gnus-browse-server-mode-map "u" 'gnus-browse-unsubscribe-current-group)
4148 (define-key gnus-browse-server-mode-map "l" 'gnus-browse-exit)
4149 (define-key gnus-browse-server-mode-map "L" 'gnus-browse-exit)
4150 (define-key gnus-browse-server-mode-map "q" 'gnus-browse-exit)
4151 (define-key gnus-browse-server-mode-map "Q" 'gnus-browse-exit)
4152 (define-key gnus-browse-server-mode-map "\C-c\C-c" 'gnus-browse-exit)
4153 (define-key gnus-browse-server-mode-map "?" 'gnus-browse-describe-briefly)
4154 (define-key gnus-browse-server-mode-map "\C-c\C-i" 'gnus-info-find-node)
4157 (defvar gnus-browse-current-method nil)
4159 (defun gnus-browse-foreign-server (method)
4160 (setq gnus-browse-current-method method)
4161 (let ((gnus-select-method method)
4163 (message "Connecting to %s..." (nth 1 method))
4164 (or (gnus-server-opened method)
4165 (gnus-open-server method)
4166 (error "Unable to contact server: %s" (gnus-status-message method)))
4167 (or (gnus-request-list method)
4168 (error "Couldn't request list: %s" (gnus-status-message method)))
4169 (set-buffer (get-buffer-create "*Gnus Browse Server*"))
4170 (gnus-add-current-to-buffer-list)
4171 (buffer-disable-undo (current-buffer))
4172 (let ((buffer-read-only nil))
4174 (gnus-browse-server-mode)
4175 (setq mode-line-buffer-identification
4177 "(ding) Browse Server {%s:%s}" (car method) (car (cdr method))))
4179 (set-buffer nntp-server-buffer)
4180 (let ((cur (current-buffer)))
4182 (delete-matching-lines gnus-ignored-newsgroups)
4183 (while (re-search-forward
4184 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
4185 (goto-char (match-end 1))
4186 (setq groups (cons (cons (buffer-substring (match-beginning 1)
4188 (- (read cur) (read cur)))
4190 (setq groups (sort groups
4192 (string< (car l1) (car l2)))))
4193 (let ((buffer-read-only nil))
4195 (setq group (car groups))
4197 (format "K%7d: %s\n" (cdr group) (car group)))
4198 (setq groups (cdr groups))))
4199 (switch-to-buffer (current-buffer))
4201 (gnus-group-position-cursor)))
4203 (defun gnus-browse-server-mode ()
4204 "Major mode for browsing a foreign server."
4206 (kill-all-local-variables)
4207 (setq mode-line-modified "-- ")
4208 (make-local-variable 'mode-line-format)
4209 (setq mode-line-format (copy-sequence mode-line-format))
4210 (and (equal (nth 3 mode-line-format) " ")
4211 (setcar (nthcdr 3 mode-line-format) ""))
4212 (setq major-mode 'gnus-browse-server-mode)
4213 (setq mode-name "Browse Server")
4214 (setq mode-line-process nil)
4215 (use-local-map gnus-browse-server-mode-map)
4216 (buffer-disable-undo (current-buffer))
4217 (setq truncate-lines t)
4218 (setq buffer-read-only t)
4219 (run-hooks 'gnus-browse-server-mode-hook))
4221 (defun gnus-browse-read-group ()
4222 "Not implemented, and will probably never be."
4224 (error "You can't read while browsing"))
4226 (defun gnus-browse-next-group (n)
4227 "Go to the next group."
4231 (gnus-group-position-cursor)))
4233 (defun gnus-browse-prev-group (n)
4234 "Go to the next group."
4236 (gnus-browse-next-group (- n)))
4238 (defun gnus-browse-unsubscribe-current-group (arg)
4239 "(Un)subscribe to the next ARG groups."
4242 (error "No group at current line."))
4243 (let ((ward (if (< arg 0) -1 1))
4245 (while (and (> arg 0)
4247 (gnus-browse-unsubscribe-group)
4248 (zerop (gnus-browse-next-group ward)))
4249 (setq arg (1- arg)))
4250 (gnus-group-position-cursor)
4251 (if (/= 0 arg) (message "No more newsgroups"))
4254 (defun gnus-browse-unsubscribe-group ()
4256 (buffer-read-only nil)
4260 (if (= (following-char) ?K) (setq sub t))
4261 (re-search-forward ": \\(.*\\)$" nil t)
4262 (setq group (gnus-group-prefixed-name
4263 (buffer-substring (match-beginning 1) (match-end 1))
4264 gnus-browse-current-method))
4269 (gnus-group-change-level
4270 (list t group 3 nil nil gnus-browse-current-method) 3 9
4271 (gnus-gethash (car (nth 1 gnus-newsrc-assoc)) gnus-newsrc-hashtb)
4274 (gnus-group-change-level group 9 3)
4278 (defun gnus-browse-exit ()
4279 "Quit browsing and return to the group buffer."
4281 (if (eq major-mode 'gnus-browse-server-mode)
4282 (kill-buffer (current-buffer)))
4283 (switch-to-buffer gnus-group-buffer)
4284 (gnus-group-list-groups nil))
4286 (defun gnus-browse-describe-briefly ()
4287 "Give a one line description of the group mode commands."
4290 (substitute-command-keys "\\<gnus-browse-server-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")))
4294 ;;; Gnus summary mode
4297 (defvar gnus-summary-mode-map nil)
4298 (defvar gnus-summary-mark-map nil)
4299 (defvar gnus-summary-mscore-map nil)
4300 (defvar gnus-summary-send-map nil)
4301 (defvar gnus-summary-extract-map nil)
4302 (defvar gnus-summary-extract-view-map nil)
4303 (defvar gnus-summary-article-map nil)
4304 (defvar gnus-summary-thread-map nil)
4305 (defvar gnus-summary-goto-map nil)
4306 (defvar gnus-summary-exit-map nil)
4307 (defvar gnus-summary-various-map nil)
4308 (defvar gnus-summary-interest-map nil)
4309 (defvar gnus-summary-process-map nil)
4310 (defvar gnus-summary-score-map nil)
4311 (defvar gnus-summary-sort-map nil)
4312 (defvar gnus-summary-mgroup-map nil)
4313 (defvar gnus-summary-vsave-map nil)
4314 (defvar gnus-summary-increase-map nil)
4315 (defvar gnus-summary-inc-subject-map nil)
4316 (defvar gnus-summary-inc-author-map nil)
4317 (defvar gnus-summary-inc-body-map nil)
4318 (defvar gnus-summary-inc-id-map nil)
4319 (defvar gnus-summary-inc-xref-map nil)
4320 (defvar gnus-summary-inc-thread-map nil)
4321 (defvar gnus-summary-inc-fol-map nil)
4322 (defvar gnus-summary-lower-map nil)
4323 (defvar gnus-summary-low-subject-map nil)
4324 (defvar gnus-summary-low-author-map nil)
4325 (defvar gnus-summary-low-body-map nil)
4326 (defvar gnus-summary-low-id-map nil)
4327 (defvar gnus-summary-low-xref-map nil)
4328 (defvar gnus-summary-low-thread-map nil)
4329 (defvar gnus-summary-low-fol-map nil)
4330 (put 'gnus-summary-mode 'mode-class 'special)
4332 (if gnus-summary-mode-map
4334 (setq gnus-summary-mode-map (make-keymap))
4335 (suppress-keymap gnus-summary-mode-map)
4337 ;; Non-orthogonal keys
4339 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
4340 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
4341 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
4342 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
4343 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
4344 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
4345 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
4346 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
4347 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
4348 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
4349 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
4350 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
4351 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
4352 (define-key gnus-summary-mode-map "\M-s" 'gnus-summary-search-article-forward)
4353 (define-key gnus-summary-mode-map "\M-r" 'gnus-summary-search-article-backward)
4354 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
4355 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
4356 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
4357 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
4358 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
4359 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
4360 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
4361 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
4362 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
4363 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
4364 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
4365 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
4366 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
4367 (define-key gnus-summary-mode-map "k" 'gnus-summary-kill-same-subject-and-select)
4368 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
4369 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
4370 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
4371 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
4372 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
4373 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
4374 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
4375 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
4376 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
4377 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
4378 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
4379 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
4380 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
4381 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
4382 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
4383 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
4384 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
4385 (define-key gnus-summary-mode-map "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
4386 (define-key gnus-summary-mode-map "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
4387 (define-key gnus-summary-mode-map "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
4388 (define-key gnus-summary-mode-map "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
4389 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
4390 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
4391 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
4392 (define-key gnus-summary-mode-map "\C-x\C-s" 'gnus-summary-reselect-current-group)
4393 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
4394 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
4395 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
4396 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
4397 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
4398 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
4399 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
4400 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
4401 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
4402 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
4403 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
4404 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
4405 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
4406 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
4407 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
4408 (define-key gnus-summary-mode-map "V" 'gnus-version)
4409 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
4410 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
4411 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
4412 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
4413 (define-key gnus-summary-mode-map
4414 (if gnus-xemacs [button2] [mouse-2]) 'gnus-mouse-pick-article)
4415 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
4416 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
4417 (define-key gnus-summary-mode-map "x" 'gnus-summary-delete-marked-as-read)
4418 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
4419 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
4420 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
4421 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
4422 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
4423 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
4424 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
4425 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
4428 ;; Sort of orthogonal keymap
4429 (define-prefix-command 'gnus-summary-mark-map)
4430 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
4431 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
4432 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
4433 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
4434 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
4435 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
4436 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
4437 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
4438 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
4439 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
4440 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
4441 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
4442 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
4443 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
4444 (define-key gnus-summary-mark-map "\M-r" 'gnus-summary-remove-lines-marked-as-read)
4445 (define-key gnus-summary-mark-map "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
4446 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
4447 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
4448 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
4449 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
4450 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
4451 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
4452 (define-key gnus-summary-mark-map "k" 'gnus-summary-kill-same-subject-and-select)
4453 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
4455 (define-prefix-command 'gnus-summary-mscore-map)
4456 (define-key gnus-summary-mark-map "s" 'gnus-summary-mscore-map)
4457 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
4458 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
4459 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
4460 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
4462 (define-prefix-command 'gnus-summary-process-map)
4463 (define-key gnus-summary-mark-map "p" 'gnus-summary-process-map)
4464 (define-key gnus-summary-process-map "p" 'gnus-summary-mark-as-processable)
4465 (define-key gnus-summary-process-map "u" 'gnus-summary-unmark-as-processable)
4466 (define-key gnus-summary-process-map "U" 'gnus-summary-unmark-all-processable)
4467 (define-key gnus-summary-process-map "s" 'gnus-uu-mark-series)
4468 (define-key gnus-summary-process-map "r" 'gnus-uu-mark-region)
4469 (define-key gnus-summary-process-map "R" 'gnus-uu-mark-by-regexp)
4470 (define-key gnus-summary-process-map "t" 'gnus-uu-mark-thread)
4471 (define-key gnus-summary-process-map "a" 'gnus-uu-mark-all)
4472 (define-key gnus-summary-process-map "S" 'gnus-uu-mark-sparse)
4475 (define-prefix-command 'gnus-summary-send-map)
4476 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
4477 (define-key gnus-summary-send-map "p" 'gnus-summary-post-news)
4478 (define-key gnus-summary-send-map "f" 'gnus-summary-followup)
4479 (define-key gnus-summary-send-map "F" 'gnus-summary-followup-with-original)
4480 (define-key gnus-summary-send-map "b" 'gnus-summary-followup-and-reply)
4481 (define-key gnus-summary-send-map "B" 'gnus-summary-followup-and-reply-with-original)
4482 (define-key gnus-summary-send-map "c" 'gnus-summary-cancel-article)
4483 (define-key gnus-summary-send-map "s" 'gnus-summary-supersede-article)
4484 (define-key gnus-summary-send-map "r" 'gnus-summary-reply)
4485 (define-key gnus-summary-send-map "R" 'gnus-summary-reply-with-original)
4486 (define-key gnus-summary-send-map "\C-f" 'gnus-summary-mail-forward)
4487 (define-key gnus-summary-send-map "m" 'gnus-summary-mail-other-window)
4488 (define-key gnus-summary-send-map "u" 'gnus-uu-post-news)
4489 (define-key gnus-summary-send-map "\M-f" 'gnus-uu-digest-and-forward)
4492 (define-prefix-command 'gnus-summary-goto-map)
4493 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
4494 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
4495 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
4496 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
4497 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
4498 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
4499 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
4500 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
4501 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
4502 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
4503 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
4504 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
4505 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
4506 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
4509 (define-prefix-command 'gnus-summary-thread-map)
4510 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
4511 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
4512 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
4513 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
4514 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
4515 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
4516 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
4517 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
4518 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
4519 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
4520 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
4521 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
4522 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
4523 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
4526 (define-prefix-command 'gnus-summary-exit-map)
4527 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
4528 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
4529 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
4530 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
4531 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
4532 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
4533 (define-key gnus-summary-exit-map "n" 'gnus-summary-catchup-and-goto-next-group)
4536 (define-prefix-command 'gnus-summary-article-map)
4537 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
4538 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
4539 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
4540 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
4541 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
4542 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
4543 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
4544 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
4545 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
4546 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
4547 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
4548 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
4549 (define-key gnus-summary-article-map "w" 'gnus-summary-stop-page-breaking)
4550 (define-key gnus-summary-article-map "c" 'gnus-summary-caesar-message)
4551 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
4552 (define-key gnus-summary-article-map "t" 'gnus-summary-toggle-header)
4553 (define-key gnus-summary-article-map "hh" 'gnus-article-hide-headers)
4554 (define-key gnus-summary-article-map "hs" 'gnus-article-hide-signature)
4555 (define-key gnus-summary-article-map "hc" 'gnus-article-hide-citation)
4556 (define-key gnus-summary-article-map "ho" 'gnus-article-treat-overstrike)
4557 (define-key gnus-summary-article-map "hw" 'gnus-article-word-wrap)
4558 (define-key gnus-summary-article-map "hd" 'gnus-article-remove-cr)
4559 (define-key gnus-summary-article-map "hq" 'gnus-article-de-quoted-unreadable)
4560 (define-key gnus-summary-article-map "m" 'gnus-summary-toggle-mime)
4561 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
4564 (define-prefix-command 'gnus-summary-extract-map)
4565 (define-key gnus-summary-mode-map "X" 'gnus-summary-extract-map)
4566 ; (define-key gnus-summary-extract-map "x" 'gnus-summary-extract-any)
4567 ; (define-key gnus-summary-extract-map "m" 'gnus-summary-extract-mime)
4568 (define-key gnus-summary-extract-map "u" 'gnus-uu-decode-uu)
4569 (define-key gnus-summary-extract-map "U" 'gnus-uu-decode-uu-and-save)
4570 (define-key gnus-summary-extract-map "s" 'gnus-uu-decode-unshar)
4571 (define-key gnus-summary-extract-map "S" 'gnus-uu-decode-unshar-and-save)
4572 (define-key gnus-summary-extract-map "o" 'gnus-uu-decode-save)
4573 (define-key gnus-summary-extract-map "O" 'gnus-uu-decode-save)
4574 (define-key gnus-summary-extract-map "b" 'gnus-uu-decode-binhex)
4575 (define-key gnus-summary-extract-map "B" 'gnus-uu-decode-binhex)
4577 (define-prefix-command 'gnus-summary-extract-view-map)
4578 (define-key gnus-summary-extract-map "v" 'gnus-summary-extract-view-map)
4579 (define-key gnus-summary-extract-view-map "u" 'gnus-uu-decode-uu-view)
4580 (define-key gnus-summary-extract-view-map "U" 'gnus-uu-decode-uu-and-save-view)
4581 (define-key gnus-summary-extract-view-map "s" 'gnus-uu-decode-unshar-view)
4582 (define-key gnus-summary-extract-view-map "S" 'gnus-uu-decode-unshar-and-save-view)
4583 (define-key gnus-summary-extract-view-map "o" 'gnus-uu-decode-save-view)
4584 (define-key gnus-summary-extract-view-map "O" 'gnus-uu-decode-save-view)
4585 (define-key gnus-summary-extract-view-map "b" 'gnus-uu-decode-binhex-view)
4586 (define-key gnus-summary-extract-view-map "B" 'gnus-uu-decode-binhex-view)
4589 (define-prefix-command 'gnus-summary-various-map)
4590 (define-key gnus-summary-mode-map "V" 'gnus-summary-various-map)
4591 (define-key gnus-summary-various-map "u" 'gnus-summary-universal-argument)
4592 (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
4593 (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
4594 (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
4595 (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
4596 (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
4597 (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
4598 (define-key gnus-summary-various-map "S" 'gnus-summary-reselect-current-group)
4599 (define-key gnus-summary-various-map "g" 'gnus-summary-rescan-group)
4600 (define-key gnus-summary-various-map "V" 'gnus-version)
4601 (define-key gnus-summary-various-map "f" 'gnus-summary-fetch-faq)
4602 (define-key gnus-summary-various-map "d" 'gnus-summary-describe-group)
4603 (define-key gnus-summary-various-map "?" 'gnus-summary-describe-briefly)
4604 (define-key gnus-summary-various-map "i" 'gnus-info-find-node)
4605 (define-key gnus-summary-various-map "D" 'gnus-summary-enter-digest-group)
4606 (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
4607 (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
4609 (define-prefix-command 'gnus-summary-vsave-map)
4610 (define-key gnus-summary-various-map "o" 'gnus-summary-vsave-map)
4611 (define-key gnus-summary-vsave-map "o" 'gnus-summary-save-article)
4612 (define-key gnus-summary-vsave-map "m" 'gnus-summary-save-article-mail)
4613 (define-key gnus-summary-vsave-map "r" 'gnus-summary-save-article-rmail)
4614 (define-key gnus-summary-vsave-map "f" 'gnus-summary-save-article-file)
4615 (define-key gnus-summary-vsave-map "h" 'gnus-summary-save-article-folder)
4616 (define-key gnus-summary-vsave-map "p" 'gnus-summary-pipe-output)
4618 (define-prefix-command 'gnus-summary-score-map)
4619 (define-key gnus-summary-various-map "S" 'gnus-summary-score-map)
4620 (define-key gnus-summary-score-map "s" 'gnus-summary-set-score)
4621 (define-key gnus-summary-score-map "c" 'gnus-score-change-score-file)
4622 (define-key gnus-summary-score-map "m" 'gnus-score-set-mark-below)
4623 (define-key gnus-summary-score-map "x" 'gnus-score-set-expunge-below)
4624 (define-key gnus-summary-score-map "e" 'gnus-score-edit-alist)
4625 (define-key gnus-summary-score-map "f" 'gnus-score-edit-file)
4627 (define-prefix-command 'gnus-summary-sort-map)
4628 (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
4629 (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
4630 (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
4631 (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
4632 (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
4633 (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
4635 (define-prefix-command 'gnus-summary-mgroup-map)
4636 (define-key gnus-summary-various-map "m" 'gnus-summary-mgroup-map)
4637 (define-key gnus-summary-mgroup-map "e" 'gnus-summary-expire-articles)
4638 (define-key gnus-summary-mgroup-map "\177" 'gnus-summary-delete-article)
4639 (define-key gnus-summary-mgroup-map "m" 'gnus-summary-move-article)
4640 (define-key gnus-summary-mgroup-map "r" 'gnus-summary-respool-article)
4641 (define-key gnus-summary-mgroup-map "w" 'gnus-summary-edit-article)
4642 (define-key gnus-summary-mgroup-map "c" 'gnus-summary-copy-article)
4645 (define-prefix-command 'gnus-summary-increase-map)
4646 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-map)
4647 (define-key gnus-summary-increase-map "i" 'gnus-summary-raise-same-subject-and-select)
4648 (define-key gnus-summary-increase-map "I" 'gnus-summary-raise-same-subject)
4649 (define-key gnus-summary-increase-map "\C-i" 'gnus-summary-raise-score)
4651 (define-prefix-command 'gnus-summary-inc-subject-map)
4652 (define-key gnus-summary-increase-map "s" 'gnus-summary-inc-subject-map)
4653 (define-key gnus-summary-increase-map "S" 'gnus-summary-temporarily-raise-by-subject)
4654 (define-key gnus-summary-inc-subject-map "s" 'gnus-summary-temporarily-raise-by-subject)
4655 (define-key gnus-summary-inc-subject-map "S" 'gnus-summary-raise-by-subject)
4656 (define-key gnus-summary-inc-subject-map "t" 'gnus-summary-temporarily-raise-by-subject)
4657 (define-key gnus-summary-inc-subject-map "p" 'gnus-summary-raise-by-subject)
4659 (define-prefix-command 'gnus-summary-inc-author-map)
4660 (define-key gnus-summary-increase-map "a" 'gnus-summary-inc-author-map)
4661 (define-key gnus-summary-increase-map "A" 'gnus-summary-temporarily-raise-by-author)
4662 (define-key gnus-summary-inc-author-map "a" 'gnus-summary-temporarily-raise-by-author)
4663 (define-key gnus-summary-inc-author-map "A" 'gnus-summary-raise-by-author)
4664 (define-key gnus-summary-inc-author-map "t" 'gnus-summary-temporarily-raise-by-author)
4665 (define-key gnus-summary-inc-author-map "p" 'gnus-summary-raise-by-author)
4667 (define-prefix-command 'gnus-summary-inc-body-map)
4668 (define-key gnus-summary-increase-map "b" 'gnus-summary-inc-body-map)
4669 (define-key gnus-summary-increase-map "B" 'gnus-summary-temporarily-raise-by-body)
4670 (define-key gnus-summary-inc-body-map "b" 'gnus-summary-temporarily-raise-by-body)
4671 (define-key gnus-summary-inc-body-map "B" 'gnus-summary-raise-by-body)
4672 (define-key gnus-summary-inc-body-map "t" 'gnus-summary-temporarily-raise-by-body)
4673 (define-key gnus-summary-inc-body-map "p" 'gnus-summary-raise-by-body)
4675 (define-prefix-command 'gnus-summary-inc-id-map)
4676 (define-key gnus-summary-increase-map "i" 'gnus-summary-inc-id-map)
4677 (define-key gnus-summary-increase-map "I" 'gnus-summary-temporarily-raise-by-id)
4678 (define-key gnus-summary-inc-id-map "i" 'gnus-summary-temporarily-raise-by-id)
4679 (define-key gnus-summary-inc-id-map "I" 'gnus-summary-raise-by-id)
4680 (define-key gnus-summary-inc-id-map "t" 'gnus-summary-temporarily-raise-by-id)
4681 (define-key gnus-summary-inc-id-map "p" 'gnus-summary-raise-by-id)
4683 (define-prefix-command 'gnus-summary-inc-thread-map)
4684 (define-key gnus-summary-increase-map "t" 'gnus-summary-inc-thread-map)
4685 (define-key gnus-summary-increase-map "T" 'gnus-summary-temporarily-raise-by-thread)
4686 (define-key gnus-summary-inc-thread-map "t" 'gnus-summary-temporarily-raise-by-thread)
4687 (define-key gnus-summary-inc-thread-map "T" 'gnus-summary-raise-by-thread)
4688 (define-key gnus-summary-inc-thread-map "t" 'gnus-summary-temporarily-raise-by-thread)
4689 (define-key gnus-summary-inc-thread-map "p" 'gnus-summary-raise-by-thread)
4691 (define-prefix-command 'gnus-summary-inc-xref-map)
4692 (define-key gnus-summary-increase-map "x" 'gnus-summary-inc-xref-map)
4693 (define-key gnus-summary-increase-map "X" 'gnus-summary-temporarily-raise-by-xref)
4694 (define-key gnus-summary-inc-xref-map "x" 'gnus-summary-temporarily-raise-by-xref)
4695 (define-key gnus-summary-inc-xref-map "X" 'gnus-summary-raise-by-xref)
4696 (define-key gnus-summary-inc-xref-map "t" 'gnus-summary-temporarily-raise-by-xref)
4697 (define-key gnus-summary-inc-xref-map "p" 'gnus-summary-raise-by-xref)
4699 (define-prefix-command 'gnus-summary-inc-fol-map)
4700 (define-key gnus-summary-increase-map "f" 'gnus-summary-inc-fol-map)
4701 (define-key gnus-summary-increase-map "F" 'gnus-summary-raise-followups-to-author)
4702 (define-key gnus-summary-inc-fol-map "f" 'gnus-summary-raise-followups-to-author)
4703 (define-key gnus-summary-inc-fol-map "F" 'gnus-summary-raise-followups-to-author)
4704 (define-key gnus-summary-inc-fol-map "t" 'gnus-summary-raise-followups-to-author)
4705 (define-key gnus-summary-inc-fol-map "p" 'gnus-summary-raise-followups-to-author)
4707 (define-prefix-command 'gnus-summary-lower-map)
4708 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-map)
4709 (define-key gnus-summary-lower-map "l" 'gnus-summary-lower-same-subject-and-select)
4710 (define-key gnus-summary-lower-map "L" 'gnus-summary-lower-same-subject)
4711 (define-key gnus-summary-lower-map "\C-l" 'gnus-summary-lower-score)
4713 (define-prefix-command 'gnus-summary-low-subject-map)
4714 (define-key gnus-summary-lower-map "s" 'gnus-summary-low-subject-map)
4715 (define-key gnus-summary-lower-map "S" 'gnus-summary-temporarily-lower-by-subject)
4716 (define-key gnus-summary-low-subject-map "s" 'gnus-summary-temporarily-lower-by-subject)
4717 (define-key gnus-summary-low-subject-map "S" 'gnus-summary-lower-by-subject)
4718 (define-key gnus-summary-low-subject-map "t" 'gnus-summary-temporarily-lower-by-subject)
4719 (define-key gnus-summary-low-subject-map "p" 'gnus-summary-lower-by-subject)
4721 (define-prefix-command 'gnus-summary-low-body-map)
4722 (define-key gnus-summary-lower-map "b" 'gnus-summary-low-body-map)
4723 (define-key gnus-summary-lower-map "B" 'gnus-summary-temporarily-lower-by-body)
4724 (define-key gnus-summary-low-body-map "b" 'gnus-summary-temporarily-lower-by-body)
4725 (define-key gnus-summary-low-body-map "B" 'gnus-summary-lower-by-body)
4726 (define-key gnus-summary-low-body-map "t" 'gnus-summary-temporarily-lower-by-body)
4727 (define-key gnus-summary-low-body-map "p" 'gnus-summary-lower-by-body)
4729 (define-prefix-command 'gnus-summary-low-author-map)
4730 (define-key gnus-summary-lower-map "a" 'gnus-summary-low-author-map)
4731 (define-key gnus-summary-lower-map "A" 'gnus-summary-temporarily-lower-by-author)
4732 (define-key gnus-summary-low-author-map "a" 'gnus-summary-temporarily-lower-by-author)
4733 (define-key gnus-summary-low-author-map "A" 'gnus-summary-lower-by-author)
4734 (define-key gnus-summary-low-author-map "t" 'gnus-summary-temporarily-lower-by-author)
4735 (define-key gnus-summary-low-author-map "p" 'gnus-summary-lower-by-author)
4737 (define-prefix-command 'gnus-summary-low-id-map)
4738 (define-key gnus-summary-lower-map "i" 'gnus-summary-low-id-map)
4739 (define-key gnus-summary-lower-map "I" 'gnus-summary-temporarily-lower-by-id)
4740 (define-key gnus-summary-low-id-map "i" 'gnus-summary-temporarily-lower-by-id)
4741 (define-key gnus-summary-low-id-map "I" 'gnus-summary-lower-by-id)
4742 (define-key gnus-summary-low-id-map "t" 'gnus-summary-temporarily-lower-by-id)
4743 (define-key gnus-summary-low-id-map "p" 'gnus-summary-lower-by-id)
4745 (define-prefix-command 'gnus-summary-low-thread-map)
4746 (define-key gnus-summary-lower-map "t" 'gnus-summary-low-thread-map)
4747 (define-key gnus-summary-lower-map "T" 'gnus-summary-temporarily-lower-by-thread)
4748 (define-key gnus-summary-low-thread-map "t" 'gnus-summary-temporarily-lower-by-thread)
4749 (define-key gnus-summary-low-thread-map "T" 'gnus-summary-lower-by-thread)
4750 (define-key gnus-summary-low-thread-map "t" 'gnus-summary-temporarily-lower-by-thread)
4751 (define-key gnus-summary-low-thread-map "p" 'gnus-summary-lower-by-thread)
4753 (define-prefix-command 'gnus-summary-low-xref-map)
4754 (define-key gnus-summary-lower-map "x" 'gnus-summary-low-xref-map)
4755 (define-key gnus-summary-lower-map "X" 'gnus-summary-temporarily-lower-by-xref)
4756 (define-key gnus-summary-low-xref-map "x" 'gnus-summary-temporarily-lower-by-xref)
4757 (define-key gnus-summary-low-xref-map "X" 'gnus-summary-lower-by-xref)
4758 (define-key gnus-summary-low-xref-map "t" 'gnus-summary-temporarily-lower-by-xref)
4759 (define-key gnus-summary-low-xref-map "p" 'gnus-summary-lower-by-xref)
4761 (define-prefix-command 'gnus-summary-low-fol-map)
4762 (define-key gnus-summary-lower-map "f" 'gnus-summary-low-fol-map)
4763 (define-key gnus-summary-lower-map "F" 'gnus-summary-lower-followups-to-author)
4764 (define-key gnus-summary-low-fol-map "f" 'gnus-summary-lower-followups-to-author)
4765 (define-key gnus-summary-low-fol-map "F" 'gnus-summary-lower-followups-to-author)
4766 (define-key gnus-summary-low-fol-map "t" 'gnus-summary-lower-followups-to-author)
4767 (define-key gnus-summary-low-fol-map "p" 'gnus-summary-lower-followups-to-author)
4773 (defun gnus-summary-mode ()
4774 "Major mode for reading articles.
4776 All normal editing commands are switched off.
4777 \\<gnus-summary-mode-map>
4778 Each line in this buffer represents one article. To read an
4779 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
4780 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
4783 You can also post articles and send mail from this buffer. To
4784 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
4785 of an article, type `\\[gnus-summary-reply]'.
4787 There are approx. one gazillion commands you can execute in this
4788 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
4790 The following commands are available:
4792 \\{gnus-summary-mode-map}"
4794 (if gnus-visual (gnus-summary-make-menu-bar))
4795 (kill-all-local-variables)
4796 (let ((locals gnus-summary-local-variables))
4798 (if (consp (car locals))
4800 (make-local-variable (car (car locals)))
4801 (set (car (car locals)) (eval (cdr (car locals)))))
4802 (make-local-variable (car locals))
4803 (set (car locals) nil))
4804 (setq locals (cdr locals))))
4805 (gnus-update-format-specifications)
4806 (setq mode-line-modified "-- ")
4807 (make-local-variable 'mode-line-format)
4808 (setq mode-line-format (copy-sequence mode-line-format))
4809 (and (equal (nth 3 mode-line-format) " ")
4810 (setcar (nthcdr 3 mode-line-format) ""))
4811 (setq major-mode 'gnus-summary-mode)
4812 (setq mode-name "Summary")
4813 (make-local-variable 'minor-mode-alist)
4814 (gnus-set-mode-line 'summary)
4815 (use-local-map gnus-summary-mode-map)
4816 (buffer-disable-undo (current-buffer))
4817 (setq buffer-read-only t) ;Disable modification
4818 (setq truncate-lines t)
4819 (setq selective-display t)
4820 (setq selective-display-ellipses t) ;Display `...'
4821 (run-hooks 'gnus-summary-mode-hook))
4823 (defun gnus-summary-clear-local-variables ()
4824 (let ((locals gnus-summary-local-variables))
4826 (if (consp (car locals))
4827 (set (car (car locals)) nil)
4828 (set (car locals) nil))
4829 (setq locals (cdr locals)))))
4831 (defun gnus-mouse-pick-article (e)
4834 (gnus-summary-next-page nil t))
4836 (defun gnus-summary-setup-buffer (group)
4837 "Initialize summary buffer."
4838 (let ((buffer (concat "*Summary " group "*")))
4839 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
4840 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
4841 (gnus-add-current-to-buffer-list)
4842 (gnus-summary-mode)))
4844 (defun gnus-set-global-variables ()
4845 ;; Set the global equivalents of the summary buffer-local variables
4846 ;; to the latest values they had. These reflect the summary buffer
4847 ;; that was in action when the last article was fetched.
4848 (if (eq major-mode 'gnus-summary-mode)
4850 (setq gnus-summary-buffer (current-buffer))
4851 (let ((name gnus-newsgroup-name)
4852 (marked gnus-newsgroup-marked)
4853 (unread gnus-newsgroup-unreads)
4854 (headers gnus-current-headers))
4856 (set-buffer gnus-group-buffer)
4857 (setq gnus-newsgroup-name name)
4858 (setq gnus-newsgroup-marked marked)
4859 (setq gnus-newsgroup-unreads unread)
4860 (setq gnus-current-headers headers))))))
4862 (defun gnus-summary-insert-dummy-line (sformat subject number)
4864 (setq sformat gnus-summary-dummy-line-format-spec))
4868 (insert (eval sformat))
4869 (add-text-properties
4871 (list 'gnus-subject (gnus-simplify-subject-re subject)
4876 (defun gnus-summary-insert-line
4877 (sformat header level current unread replied expirable subject-or-nil
4878 &optional dummy score)
4879 (or sformat (setq sformat gnus-summary-line-format-spec))
4881 (make-string (* level gnus-thread-indent-level) ? ))
4882 (lines (or (header-lines header) 0))
4883 (score (or score gnus-summary-default-score 0))
4884 (score-char (if (or (null gnus-summary-default-score)
4885 (= score gnus-summary-default-score)) ?
4886 (if (< score gnus-summary-default-score)
4887 gnus-score-below-mark gnus-score-over-mark)))
4888 (replied (if replied gnus-replied-mark ? ))
4889 (from (header-from header))
4890 (name-address (funcall gnus-extract-address-components from))
4891 (address (car (cdr name-address)))
4892 (name (or (car name-address) (car (cdr name-address))))
4893 (number (header-number header))
4894 (subject (header-subject header))
4895 (buffer-read-only nil)
4896 (opening-bracket (if dummy ?\< ?\[))
4897 (closing-bracket (if dummy ?\> ?\]))
4899 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
4900 (if (not (numberp lines)) (setq lines 0))
4903 (insert (eval sformat))
4904 (add-text-properties
4906 (list 'gnus-subject (gnus-simplify-subject-re subject)
4908 'gnus-mark (or unread gnus-unread-mark ? )
4909 'gnus-thread level))))
4911 (defun gnus-summary-update-line (&optional dont-update)
4912 ;; Update summary line after change.
4913 (or (not gnus-summary-default-score)
4914 gnus-summary-inhibit-highlight
4915 (let ((gnus-summary-inhibit-highlight t)
4916 (article (gnus-summary-article-number)))
4919 (if (and gnus-summary-mark-below
4920 (< (gnus-summary-article-score)
4921 gnus-summary-mark-below))
4922 (and (not (memq article gnus-newsgroup-marked))
4923 (not (memq article gnus-newsgroup-dormant))
4924 (memq article gnus-newsgroup-unreads)
4925 (gnus-summary-mark-article nil gnus-low-score-mark))
4926 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
4927 (gnus-summary-mark-article nil gnus-unread-mark))))
4929 (run-hooks 'gnus-visual-summary-update-hook))))))
4931 (defun gnus-summary-update-lines ()
4932 ;; Rehighlight summary buffer according to `gnus-summary-highlight'.
4933 (and (save-excursion
4934 (set-buffer gnus-summary-buffer)
4935 (goto-char (point-min))
4937 (gnus-summary-update-line)
4938 (forward-line 1)))))
4940 (defun gnus-summary-number-of-articles-in-thread (thread)
4941 ;; Sum up all elements (and sub-elements) in a list.
4943 (apply '+ (mapcar 'gnus-summary-number-of-articles-in-thread thread))
4946 (defun gnus-summary-read-group (group &optional show-all no-article kill-buffer)
4947 "Start reading news in newsgroup GROUP.
4948 If SHOW-ALL is non-nil, already read articles are also listed.
4949 If NO-ARTICLE is non-nil, no article is selected initially."
4950 (message "Retrieving newsgroup: %s..." group)
4951 (gnus-summary-setup-buffer group)
4952 (if (gnus-select-newsgroup group show-all)
4954 (gnus-set-global-variables)
4955 ;; You can change the subjects in this hook.
4956 (run-hooks 'gnus-select-group-hook)
4957 ;; Do Score Processing.
4958 (gnus-score-headers)
4959 ;; Update the format specifiers.
4960 (gnus-update-format-specifications)
4961 (gnus-summary-prepare)
4962 (if (zerop (buffer-size))
4963 (cond (gnus-newsgroup-dormant
4964 (gnus-summary-show-all-dormant))
4965 ((and gnus-newsgroup-scored show-all)
4966 (gnus-summary-show-all-expunged))))
4967 ;; Function `gnus-apply-kill-file' must be called in this hook.
4968 (run-hooks 'gnus-apply-kill-hook)
4969 (if (zerop (buffer-size))
4971 ;; This newsgroup is empty.
4972 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
4973 (message "No unread news")
4975 (get-buffer kill-buffer)
4976 (buffer-name (get-buffer kill-buffer))
4977 (kill-buffer kill-buffer)))
4980 (let ((gnus-summary-buffer kill-buffer))
4981 (gnus-configure-windows 'newsgroups t))))
4982 ;; Hide conversation thread subtrees. We cannot do this in
4983 ;; gnus-summary-prepare-hook since kill processing may not
4984 ;; work with hidden articles.
4985 (and gnus-show-threads
4986 gnus-thread-hide-subtree
4987 (gnus-summary-hide-all-threads))
4988 ;; Show first unread article if requested.
4989 (goto-char (point-min))
4990 (if (and (not no-article)
4991 gnus-auto-select-first
4992 (gnus-summary-first-unread-article))
4993 (gnus-configure-windows 'article)
4994 (gnus-configure-windows 'summary))
4995 (pop-to-buffer gnus-summary-buffer)
4996 (gnus-set-mode-line 'summary)
4997 (gnus-summary-position-cursor)
4998 (if (and kill-buffer
4999 (get-buffer kill-buffer)
5000 (buffer-name (get-buffer kill-buffer)))
5001 (kill-buffer kill-buffer))))
5002 ;; Cannot select newsgroup GROUP.
5003 (message "Couldn't select newsgroup")
5004 (and (eq major-mode 'gnus-summary-mode)
5005 (kill-buffer (current-buffer)))
5006 (switch-to-buffer gnus-group-buffer)))
5008 (defun gnus-summary-prepare ()
5009 "Prepare summary list of current newsgroup in summary buffer."
5010 (let ((buffer-read-only nil))
5012 (gnus-summary-prepare-threads
5013 (if gnus-show-threads
5014 (gnus-gather-threads
5016 (if gnus-summary-expunge-below
5017 (gnus-make-threads-and-expunge)
5018 (gnus-make-threads))))
5019 gnus-newsgroup-headers)
5021 ;; Erase header retrieval message.
5022 (gnus-summary-update-lines)
5024 ;; Call hooks for modifying summary buffer.
5025 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
5026 (goto-char (point-min))
5027 (run-hooks 'gnus-summary-prepare-hook)))
5029 (defun gnus-gather-threads (threads)
5030 "Gather threads that have lost their roots."
5031 (if (not gnus-summary-make-false-root)
5033 (let ((hashtb (gnus-make-hashtable 1023))
5036 thread subject hthread unre-subject whole-subject)
5038 (setq subject (header-subject (car (car threads)))
5039 whole-subject subject)
5040 (and gnus-summary-gather-subject-limit
5041 (or (and (numberp gnus-summary-gather-subject-limit)
5042 (> (length subject) gnus-summary-gather-subject-limit)
5044 (substring subject 0
5045 gnus-summary-gather-subject-limit)))
5046 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
5047 (setq subject (gnus-simplify-subject-fuzzy subject)))))
5050 (setq unre-subject (gnus-simplify-subject-re subject))
5053 (or (stringp (car (car hthread)))
5054 (setcar hthread (list whole-subject (car hthread))))
5055 (setcdr (car hthread) (nconc (cdr (car hthread))
5056 (list (car threads))))
5057 (setcdr prev (cdr threads))
5058 (setq threads prev))
5059 (gnus-sethash unre-subject threads hashtb))
5061 (setq threads (cdr threads)))
5064 (defun gnus-make-threads ()
5065 ;; This function takes the dependencies already made by
5066 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5067 ;; through the dependecies in the hash table and finds all the
5068 ;; roots. Roots do not refer back to any valid articles.
5070 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5071 (gnus-build-old-threads))
5074 (if (not (car (symbol-value refs)))
5075 (setq roots (append (cdr (symbol-value refs)) roots))
5076 ;; Ok, these refer back to valid articles, but if
5077 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5078 ;; the root has the same subject as its children. The children
5079 ;; that do not are made into roots and removed from the list
5081 (or gnus-thread-ignore-subject
5082 (let* ((prev (symbol-value refs))
5083 (subject (gnus-simplify-subject-re
5084 (header-subject (car prev))))
5085 (headers (cdr prev)))
5087 (if (not (string= subject
5088 (gnus-simplify-subject-re
5089 (header-subject (car headers)))))
5091 (setq roots (cons (car headers) roots))
5092 (setcdr prev (cdr headers)))
5093 (setq prev headers))
5094 (setq headers (cdr headers)))))))
5095 gnus-newsgroup-dependencies)
5097 (mapcar 'gnus-trim-thread
5099 (mapcar 'gnus-cut-thread
5100 (mapcar 'gnus-make-sub-thread roots))))))
5102 (defun gnus-make-threads-and-expunge ()
5103 ;; This function takes the dependencies already made by
5104 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5105 ;; through the dependecies in the hash table and finds all the
5106 ;; roots. Roots do not refer back to any valid articles.
5108 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5109 (gnus-build-old-threads))
5112 (if (not (car (symbol-value refs)))
5113 (if (and gnus-summary-expunge-below
5114 (not gnus-fetch-old-headers))
5115 (let ((headers (cdr (symbol-value refs))))
5117 (if (not (< (or (cdr (assq (header-number (car headers))
5118 gnus-newsgroup-scored))
5119 gnus-summary-default-score 0)
5120 gnus-summary-expunge-below))
5121 (setq roots (cons (car headers) roots))
5122 (setq gnus-newsgroup-unreads
5123 (delq (header-number (car headers))
5124 gnus-newsgroup-unreads)))
5125 (setq headers (cdr headers))))
5126 (setq roots (append (cdr (symbol-value refs)) roots)))
5127 ;; Ok, these refer back to valid articles, but if
5128 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5129 ;; the root has the same subject as its children. The children
5130 ;; that do not are made into roots and removed from the list
5132 (or gnus-thread-ignore-subject
5133 (let* ((prev (symbol-value refs))
5134 (subject (gnus-simplify-subject-re
5135 (header-subject (car prev))))
5136 (headers (cdr prev)))
5138 (if (not (string= subject
5139 (gnus-simplify-subject-re
5140 (header-subject (car headers)))))
5142 (setq roots (cons (car headers) roots))
5143 (setcdr prev (cdr headers)))
5144 (setq prev headers))
5145 (setq headers (cdr headers)))))
5146 (and gnus-summary-expunge-below
5147 (not gnus-fetch-old-headers)
5148 (let* ((prev (symbol-value refs))
5149 (headers (cdr prev))
5152 (if (not (< (or (cdr (assq (header-number (car headers))
5153 gnus-newsgroup-scored))
5154 gnus-summary-default-score 0)
5155 gnus-summary-expunge-below))
5156 (setq prev (cdr prev))
5157 (setq gnus-newsgroup-unreads
5158 (delq (header-number (car headers))
5159 gnus-newsgroup-unreads))
5160 (setcdr prev (cdr headers))
5161 (setq id (gnus-gethash (header-id (car headers))
5162 gnus-newsgroup-dependencies))
5165 (if (not (< (or (cdr (assq (header-number (car h))
5166 gnus-newsgroup-scored))
5167 gnus-summary-default-score 0)
5168 gnus-summary-expunge-below))
5169 (setq roots (cons (car h) roots)))
5171 (setq headers (cdr headers)))))))
5172 gnus-newsgroup-dependencies)
5174 (mapcar 'gnus-trim-thread
5176 (mapcar 'gnus-cut-thread
5177 (mapcar 'gnus-make-sub-thread roots))))))
5179 (defun gnus-cut-thread (thread)
5180 ;; Remove leaf dormant or ancient articles from THREAD.
5181 (let ((head (car thread))
5182 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
5183 (if (and (null tail)
5184 (let ((number (header-number head)))
5185 (or (memq number gnus-newsgroup-ancient)
5186 (memq number gnus-newsgroup-dormant)
5187 (and gnus-summary-expunge-below
5188 (eq gnus-fetch-old-headers 'some)
5189 (< (or (cdr (assq number gnus-newsgroup-scored))
5190 gnus-summary-default-score 0)
5191 gnus-summary-expunge-below)
5193 (setq gnus-newsgroup-unreads
5194 (delq number gnus-newsgroup-unreads))
5197 (list (cons head tail)))))
5199 (defun gnus-trim-thread (thread)
5200 ;; Remove root ancient articles with only one child from THREAD.
5201 (if (and (eq gnus-fetch-old-headers 'some)
5202 (memq (header-number (car thread)) gnus-newsgroup-ancient)
5203 (= (length thread) 2))
5204 (gnus-trim-thread (nth 1 thread))
5207 (defun gnus-make-sub-thread (root)
5208 ;; This function makes a sub-tree for a node in the tree.
5209 (let ((children (reverse (cdr (gnus-gethash (downcase (header-id root))
5210 gnus-newsgroup-dependencies)))))
5211 (cons root (mapcar 'gnus-make-sub-thread children))))
5213 (defun gnus-build-old-threads ()
5214 ;; Look at all the articles that refer back to old articles, and
5215 ;; fetch the headers for the articles that aren't there. This will
5216 ;; build complete threads - if the roots haven't been expired by the
5221 (if (not (car (symbol-value refs)))
5223 (setq heads (cdr (symbol-value refs)))
5225 (if (not (memq (header-number (car heads))
5226 gnus-newsgroup-dormant))
5228 (setq id (symbol-name refs))
5229 (while (and (setq id (gnus-build-get-header id))
5230 (not (car (gnus-gethash
5231 id gnus-newsgroup-dependencies)))))
5233 (setq heads (cdr heads)))))))
5234 gnus-newsgroup-dependencies)))
5236 (defun gnus-build-get-header (id)
5237 ;; Look through the buffer of NOV lines and find the header to
5238 ;; ID. Enter this line into the dependencies hash table, and return
5239 ;; the id of the parent article (if any).
5240 (let ((deps gnus-newsgroup-dependencies)
5244 (set-buffer nntp-server-buffer)
5245 (goto-char (point-min))
5246 (while (and (not found) (search-forward id nil t))
5248 (setq found (looking-at (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
5249 (regexp-quote id))))
5250 (or found (beginning-of-line 2)))
5255 (setq header (gnus-nov-parse-line
5256 (read (current-buffer)) deps))
5257 (setq ref (header-references header))
5258 (string-match "\\(<[^>]+>\\) *$" ref)
5259 (substring ref (match-beginning 1) (match-end 1))))))
5261 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
5262 gnus-newsgroup-ancient (cons (header-number header)
5263 gnus-newsgroup-ancient))))))
5265 (defun gnus-sort-threads (threads)
5266 ;; Sort threads as specified in `gnus-thread-sort-functions'.
5267 (let ((fun gnus-thread-sort-functions))
5269 (setq threads (sort threads (car fun))
5273 (defun gnus-thread-header (thread)
5274 ;; Return header of first article in THREAD.
5276 (if (stringp (car thread))
5277 (car (car (cdr thread)))
5281 (defun gnus-thread-sort-by-number (h1 h2)
5282 "Sort threads by root article number."
5283 (let ((h1 (gnus-thread-header h1))
5284 (h2 (gnus-thread-header h2)))
5285 (< (header-number h1) (header-number h2))))
5287 (defun gnus-thread-sort-by-author (h1 h2)
5288 "Sort threads by root author."
5289 (let ((h1 (gnus-thread-header h1))
5290 (h2 (gnus-thread-header h2)))
5292 (let ((extract (funcall
5293 gnus-extract-address-components (header-from h1))))
5294 (or (car extract) (cdr extract)))
5295 (let ((extract (funcall
5296 gnus-extract-address-components (header-from h2))))
5297 (or (car extract) (cdr extract))))))
5299 (defun gnus-thread-sort-by-subject (h1 h2)
5300 "Sort threads by root subject."
5301 (let ((h1 (gnus-thread-header h1))
5302 (h2 (gnus-thread-header h2)))
5304 (downcase (gnus-simplify-subject (header-subject h1)))
5305 (downcase (gnus-simplify-subject (header-subject h2))))))
5307 (defun gnus-thread-sort-by-date (h1 h2)
5308 "Sort threads by root article date."
5309 (let ((h1 (gnus-thread-header h1))
5310 (h2 (gnus-thread-header h2)))
5312 (gnus-sortable-date (header-date h1))
5313 (gnus-sortable-date (header-date h2)))))
5315 (defun gnus-thread-sort-by-score (h1 h2)
5316 "Sort threads by root article score.
5317 Unscored articles will be counted as havin a score of zero."
5318 (let ((h1 (gnus-thread-header h1))
5319 (h2 (gnus-thread-header h2)))
5320 (let ((s1 (assq (header-number h1) gnus-newsgroup-scored))
5321 (s2 (assq (header-number h2) gnus-newsgroup-scored)))
5322 (> (or (cdr s1) gnus-summary-default-score 0)
5323 (or (cdr s2) gnus-summary-default-score 0)))))
5325 (defun gnus-thread-sort-by-total-score (h1 h2)
5326 "Sort threads by the sum of all scores in the thread.
5327 Unscored articles will be counted as havin a score of zero."
5328 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5330 (defun gnus-thread-total-score (thread)
5331 ;; This function find the total score of THREAD.
5333 (if (stringp (car thread))
5334 (apply gnus-thread-score-function 0
5335 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5336 (gnus-thread-total-score-1 thread))
5337 (gnus-thread-total-score-1 (list thread))))
5339 (defun gnus-thread-total-score-1 (root)
5340 ;; This function find the total score of the thread below ROOT.
5341 (setq root (car root))
5342 (apply gnus-thread-score-function
5343 (or (cdr (assq (header-number root) gnus-newsgroup-scored))
5344 gnus-summary-default-score 0)
5345 (mapcar 'gnus-thread-total-score
5346 (cdr (gnus-gethash (downcase (header-id root))
5347 gnus-newsgroup-dependencies)))))
5349 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5350 (defvar gnus-tmp-prev-subject "")
5352 ;; Basic ideas by Paul Dworkin <paul@media-lab.media.mit.edu>.
5353 (defun gnus-summary-prepare-threads
5354 (threads level &optional not-child no-subject cull)
5355 "Prepare summary buffer from THREADS and indentation LEVEL.
5356 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5357 or a straight list of headers."
5358 (let (thread header number subject clevel)
5360 (setq thread (car threads)
5361 threads (cdr threads))
5362 ;; If `thread' is a cons, hierarchical threads are used. If not,
5363 ;; `thread' is the header.
5365 (setq header (car thread))
5366 (setq header thread)
5368 (or (memq (setq number (header-number header))
5369 gnus-newsgroup-dormant)
5370 (and gnus-summary-expunge-below
5371 (< (or (cdr (assq number gnus-newsgroup-scored))
5372 gnus-summary-default-score 0)
5373 gnus-summary-expunge-below)))
5376 (setq gnus-newsgroup-unreads
5377 (delq number gnus-newsgroup-unreads)))))
5380 ;; The header is a dummy root.
5381 (cond ((eq gnus-summary-make-false-root 'adopt)
5382 ;; We let the first article adopt the rest.
5383 (gnus-summary-prepare-threads (list (car (cdr thread))) 0)
5384 (setq thread (cdr (cdr thread)))
5386 (gnus-summary-prepare-threads (list (car thread)) 1 t)
5387 (setq thread (cdr thread))))
5388 ((eq gnus-summary-make-false-root 'dummy)
5389 ;; We output a dummy root.
5390 (gnus-summary-insert-dummy-line
5391 nil header (header-number (car (car (cdr thread)))))
5393 ((eq gnus-summary-make-false-root 'empty)
5394 ;; We print the articles with empty subject fields.
5395 (gnus-summary-prepare-threads (list (car (cdr thread))) 0)
5396 (setq thread (cdr (cdr thread)))
5398 (gnus-summary-prepare-threads
5399 (list (car thread)) 0 nil
5400 (not (and (eq gnus-summary-gather-subject-limit 'fuzzy)
5402 (gnus-simplify-subject-re
5403 (header-subject (car (car thread))))
5404 (gnus-simplify-subject-re header))))))
5405 (setq thread (cdr thread))))
5407 ;; We do not make a root for the gathered
5408 ;; sub-threads at all.
5410 ;; Print the sub-threads.
5411 (and (consp thread) (cdr thread)
5412 (gnus-summary-prepare-threads (cdr thread) clevel)))
5413 ;; The header is a real article.
5415 (setq number (header-number header)
5416 subject (header-subject header))
5417 (gnus-summary-insert-line
5418 nil header level nil
5419 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
5420 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
5421 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
5422 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
5423 (t gnus-ancient-mark))
5424 (memq number gnus-newsgroup-replied)
5425 (memq number gnus-newsgroup-expirable)
5427 gnus-summary-same-subject
5428 (if (or (zerop level)
5429 (and gnus-thread-ignore-subject
5431 (gnus-simplify-subject-re gnus-tmp-prev-subject)
5432 (gnus-simplify-subject-re subject)))))
5434 gnus-summary-same-subject))
5436 (cdr (assq number gnus-newsgroup-scored)))
5437 (setq gnus-tmp-prev-subject subject)
5438 ;; Recursively print subthreads.
5439 (and (consp thread) (cdr thread)
5440 (gnus-summary-prepare-threads (cdr thread) (1+ level))))))))
5442 (defun gnus-select-newsgroup (group &optional read-all)
5443 "Select newsgroup GROUP.
5444 If READ-ALL is non-nil, all articles in the group are selected."
5445 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5446 (info (nth 2 entry))
5447 articles header-marks)
5448 (and (eq (car entry) t)
5449 (or (gnus-activate-newsgroup (car info))
5451 (kill-buffer (current-buffer))
5452 (error "Couldn't request group %s: %s"
5453 group (gnus-status-message group)))))
5454 (setq gnus-current-select-method (or (nth 4 info) gnus-select-method))
5455 (gnus-check-news-server (nth 4 info))
5456 (or (gnus-request-group group t)
5458 (kill-buffer (current-buffer))
5459 (error "Couldn't request group %s: %s"
5460 group (gnus-status-message group))))
5462 (setq gnus-newsgroup-name group)
5463 (setq gnus-newsgroup-unselected nil)
5464 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5466 (if (not (setq articles (gnus-articles-to-read group read-all)))
5468 ;; Init the dependencies hash table.
5469 (setq gnus-newsgroup-dependencies
5470 (gnus-make-hashtable (length articles)))
5471 ;; Retrieve the headers and read them in.
5472 (setq gnus-newsgroup-headers
5473 (if (eq 'nov (setq gnus-headers-retrieved-by
5474 (gnus-retrieve-headers
5475 (if gnus-fetch-old-headers
5476 (cons 1 articles) articles)
5477 gnus-newsgroup-name)))
5479 (gnus-get-newsgroup-headers-xover articles))
5480 (gnus-get-newsgroup-headers)))
5481 ;; If we were to fetch old headers, but the backend didn't
5482 ;; support XOVER, then it is possible we fetched one article
5483 ;; that we shouldn't have. If that's the case, we pop it off the
5485 (and (not (eq gnus-headers-retrieved-by 'nov))
5486 gnus-fetch-old-headers
5487 gnus-newsgroup-headers
5488 (/= (header-number (car gnus-newsgroup-headers)) (car articles))
5489 (setq gnus-newsgroup-headers (cdr gnus-newsgroup-headers)))
5490 ;; Remove cancelled articles from the list of unread articles.
5491 (setq gnus-newsgroup-unreads
5492 (gnus-set-sorted-intersection
5493 gnus-newsgroup-unreads
5494 (mapcar (lambda (headers) (header-number headers))
5495 gnus-newsgroup-headers)))
5496 ;; Adjust and set lists of article marks.
5499 (gnus-adjust-marked-articles info)
5500 (setq gnus-newsgroup-marked
5501 (cdr (assq 'tick (setq marked (nth 3 info)))))
5502 (setq gnus-newsgroup-replied (cdr (assq 'reply marked)))
5503 (setq gnus-newsgroup-expirable (cdr (assq 'expire marked)))
5504 (setq gnus-newsgroup-killed (cdr (assq 'killed marked)))
5505 (setq gnus-newsgroup-bookmarks (cdr (assq 'bookmark marked)))
5506 (setq gnus-newsgroup-dormant (cdr (assq 'dormant marked)))
5507 (setq gnus-newsgroup-scored (cdr (assq 'score marked)))
5508 (setq gnus-newsgroup-processable nil)))
5509 ;; Check whether auto-expire is to be done in this group.
5510 (setq gnus-newsgroup-auto-expire
5511 (or (and (stringp gnus-auto-expirable-newsgroups)
5512 (string-match gnus-auto-expirable-newsgroups group))
5513 (memq 'auto-expire gnus-current-select-method)))
5514 ;; First and last article in this newsgroup.
5515 (and gnus-newsgroup-headers
5516 (setq gnus-newsgroup-begin
5517 (header-number (car gnus-newsgroup-headers)))
5518 (setq gnus-newsgroup-end
5519 (header-number (gnus-last-element gnus-newsgroup-headers))))
5520 (setq gnus-reffed-article-number -1)
5521 ;; GROUP is successfully selected.
5522 (or gnus-newsgroup-headers t))))
5524 (defun gnus-articles-to-read (group read-all)
5525 ;; Find out what articles the user wants to read.
5527 ;; Select all articles if `read-all' is non-nil, or if all the
5528 ;; unread articles are dormant articles.
5530 (= (length gnus-newsgroup-unreads)
5531 (length gnus-newsgroup-dormant)))
5532 (gnus-uncompress-range
5533 (gnus-gethash group gnus-active-hashtb))
5534 gnus-newsgroup-unreads))
5535 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5536 (scored (length scored-list))
5537 (number (length articles))
5538 (marked (+ (length gnus-newsgroup-marked)
5539 (length gnus-newsgroup-dormant)))
5542 (cond ((and (or (<= scored marked)
5544 (numberp gnus-large-newsgroup)
5545 (> number gnus-large-newsgroup))
5549 "How many articles from %s (default %d): "
5550 gnus-newsgroup-name number))))
5551 (if (string-equal input "")
5553 ((and (> scored marked) (< scored number))
5557 "%s %s (%d scored, %d total): "
5558 "How many articles from"
5559 group scored number))))
5560 (if (string-equal input "")
5565 (setq select (if (numberp select) select (string-to-number select)))
5568 (if (and (not (zerop scored)) (<= (abs select) scored))
5570 (setq articles (sort scored-list '<))
5571 (setq number (length articles)))
5572 (setq articles (copy-sequence articles)))
5574 (setq total-articles articles)
5576 (if (< (abs select) number)
5578 ;; Select the N oldest articles.
5579 (setcdr (nthcdr (1- (abs select)) articles) nil)
5580 ;; Select the N most recent articles.
5581 (setq articles (nthcdr (- number select) articles))))
5582 (setq gnus-newsgroup-unselected
5583 (gnus-sorted-intersection
5584 gnus-newsgroup-unreads
5585 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
5588 (defun gnus-killed-articles (killed articles)
5591 (if (inline (gnus-member-of-range (car articles) killed))
5592 (setq out (cons (car articles) out)))
5593 (setq articles (cdr articles)))
5596 (defun gnus-adjust-marked-articles (info &optional active)
5597 "Remove all marked articles that are no longer legal."
5598 (let ((marked-lists (nth 3 info))
5599 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
5601 ;; There are many types of marked articles.
5603 (setq m (cdr (setq prev (car marked-lists))))
5604 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
5605 ;; Make sure that all ticked articles are a subset of the
5606 ;; unread/unselected articles.
5608 (if (or (memq (car m) gnus-newsgroup-unreads)
5609 (memq (car m) gnus-newsgroup-unselected))
5611 (setcdr prev (cdr m)))
5613 ((eq 'score (car prev))
5614 ;; Scored articles should be a subset of
5615 ;; unread/unselected articles.
5617 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
5618 (memq (car (car m)) gnus-newsgroup-unreads))
5620 (setcdr prev (cdr m)))
5622 ((eq 'bookmark (car prev))
5623 ;; Bookmarks should be a subset of active articles.
5625 (if (< (car (car m)) (car active))
5626 (setcdr prev (cdr m))
5629 ((eq 'killed (car prev))
5630 ;; Articles that have been through the kill process are
5631 ;; to be a subset of active articles.
5632 (while (and m (< (or (and (numberp (car m)) (car m))
5635 (setcdr prev (cdr m))
5637 (if (and m (< (or (and (numberp (car m)) (car m))
5640 (setcar (if (numberp (car m)) m (car m)) (car active))))
5641 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
5642 ;; The replied and expirable articles have to be articles
5645 (if (< (car m) (car active))
5646 (setcdr prev (cdr m))
5649 (setq marked-lists (cdr marked-lists)))
5650 ;; Remove all lists that are empty.
5651 (setq marked-lists (nth 3 info))
5654 (while (= 1 (length (car marked-lists)))
5655 (setq marked-lists (cdr marked-lists)))
5656 (setq m (cdr (setq prev marked-lists)))
5658 (if (= 1 (length (car m)))
5659 (setcdr prev (cdr m))
5662 (setcar (nthcdr 3 info) marked-lists)))
5663 ;; Finally, if there are no marked lists at all left, and if there
5664 ;; are no elements after the lists in the info list, we just chop
5665 ;; the info list off before the marked lists.
5666 (and (null marked-lists)
5667 (not (nthcdr 4 info))
5668 (setcdr (nthcdr 2 info) nil)))
5671 (defun gnus-set-marked-articles
5672 (info ticked replied expirable killed dormant bookmark score)
5673 "Enter the various lists of marked articles into the newsgroup info list."
5675 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
5676 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
5677 (and expirable (setq newmarked (cons (cons 'expire expirable)
5679 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
5680 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
5681 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
5683 (and score (setq newmarked (cons (cons 'score score) newmarked)))
5686 (setcar (nthcdr 3 info) newmarked)
5687 (if (not (nthcdr 4 info))
5688 (setcdr (nthcdr 2 info) nil)
5689 (setcar (nthcdr 3 info) nil)))
5691 (setcdr (nthcdr 2 info) (cons newmarked nil))))))
5693 (defun gnus-add-marked-articles (group type articles &optional info force)
5694 ;; Add ARTICLES of TYPE to the info of GROUP.
5695 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
5696 ;; add, but replace marked articles of TYPE with ARTICLES.
5697 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
5700 (and (not (setq marked (nthcdr 3 info)))
5701 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
5702 (and (not (setq m (assq type (car marked))))
5703 (setcar marked (cons (cons type articles) (car marked))))
5706 (nconc m articles)))))
5708 (defun gnus-set-mode-line (where)
5709 "This function sets the mode line of the article or summary buffers.
5710 If WHERE is `summary', the summary mode line format will be used."
5711 (if (memq where gnus-updated-mode-lines)
5714 (set-buffer gnus-summary-buffer)
5715 (let* ((mformat (if (eq where 'article)
5716 gnus-article-mode-line-format-spec
5717 gnus-summary-mode-line-format-spec))
5718 (group-name gnus-newsgroup-name)
5719 (article-number (or gnus-current-article 0))
5720 (unread (- (length gnus-newsgroup-unreads)
5721 (length gnus-newsgroup-dormant)))
5722 (unread-and-unticked
5723 (- unread (length gnus-newsgroup-marked)))
5724 (unselected (length gnus-newsgroup-unselected))
5725 (unread-and-unselected
5726 (cond ((and (zerop unread-and-unticked)
5727 (zerop unselected)) "")
5729 (format "{%d more}" unread-and-unticked))
5730 (t (format "{%d(+%d) more}"
5731 unread-and-unticked unselected))))
5733 (if gnus-current-headers
5734 (header-subject gnus-current-headers) ""))
5735 (max-len (- (frame-width) gnus-mode-non-string-length)))
5736 (setq mode-string (eval mformat))
5737 (if (> (length mode-string) max-len)
5739 (concat (substring mode-string 0 (- max-len 3)) "...")))
5740 (setq mode-string (format (format "%%-%ds" max-len 5)
5742 (setq mode-line-buffer-identification mode-string)
5743 (set-buffer-modified-p t))))
5745 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5746 "Go through the HEADERS list and add all Xrefs to a hash table.
5747 The resulting hash table is returned, or nil if no Xrefs were found."
5748 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
5750 (gnus-group-foreign-p from-newsgroup)
5752 (assoc (symbol-name (car from-method))
5753 gnus-valid-select-methods))))
5754 (gnus-group-real-prefix from-newsgroup)))
5755 (xref-hashtb (make-vector 63 0))
5756 start group entry number xrefs header)
5758 (setq header (car headers))
5759 (if (and (setq xrefs (header-xref header))
5760 (not (memq (header-number header) unreads)))
5763 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
5764 (setq start (match-end 0))
5765 (setq group (concat prefix (substring xrefs (match-beginning 1)
5768 (string-to-int (substring xrefs (match-beginning 2)
5770 (if (setq entry (gnus-gethash group xref-hashtb))
5771 (setcdr entry (cons number (cdr entry)))
5772 (gnus-sethash group (cons number nil) xref-hashtb)))))
5773 (setq headers (cdr headers)))
5774 (if start xref-hashtb nil)))
5776 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
5777 "Look through all the headers and mark the Xrefs as read."
5778 (let ((virtual (memq 'virtual
5779 (assoc (symbol-name (car (gnus-find-method-for-group
5781 gnus-valid-select-methods)))
5782 name entry read info xref-hashtb idlist active num range exps method)
5784 (set-buffer gnus-group-buffer)
5785 (if (setq xref-hashtb
5786 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5789 (if (string= from-newsgroup (setq name (symbol-name group)))
5791 (setq idlist (symbol-value group))
5792 ;; Dead groups are not updated.
5793 (if (and (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5795 ;; Only do the xrefs if the group has the same
5796 ;; select method as the group we have just read.
5797 (or (gnus-methods-equal-p
5799 (gnus-find-method-for-group from-newsgroup))
5802 (setq method (gnus-find-method-for-group
5804 (and (equal (car (nth 4 info)) (car method))
5805 (equal (nth 1 (nth 4 info)) (nth 1 method))))
5806 gnus-use-cross-reference
5807 (or (not (eq gnus-use-cross-reference t))
5809 ;; Only do cross-references on subscribed
5810 ;; groups, if that is what is wanted.
5811 (<= (nth 1 info) 5)))
5814 ;; Set the new list of read articles in this group.
5815 (setq active (gnus-gethash name gnus-active-hashtb))
5816 ;; First peel off all illegal article numbers.
5819 (ticked (cdr (assq 'tick (nth 3 info))))
5820 (dormant (cdr (assq 'dormant (nth 3 info))))
5825 (if (or (> id (cdr active))
5829 (setq idlist (delq id idlist)))
5830 (and (memq id expirable)
5831 (setq exps (cons id exps)))
5832 (setq ids (cdr ids)))))
5833 ;; Update expirable articles.
5834 (gnus-add-marked-articles nil 'expirable exps info)
5835 (and (null (nth 2 info))
5837 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
5838 (setcar (nthcdr 2 info)
5842 (setq idlist (sort idlist '<)))))
5843 ;; Then we have to re-compute how many unread
5844 ;; articles there are in this group.
5849 (setq num (- (1+ (cdr active)) (car active))))
5850 ((not (listp (cdr range)))
5851 (setq num (- (cdr active) (- (1+ (cdr range))
5855 (if (numberp (car range))
5857 (setq num (+ num (- (1+ (cdr (car range)))
5858 (car (car range))))))
5859 (setq range (cdr range)))
5860 (setq num (- (cdr active) num))))
5861 ;; Update the number of unread articles.
5865 (length (cdr (assq 'tick (nth 3 info))))
5867 (cdr (assq 'dormant (nth 3 info)))))))
5868 ;; Update the group buffer.
5869 (gnus-group-update-group name t)))))))
5872 (defun gnus-methods-equal-p (m1 m2)
5873 (let ((m1 (or m1 gnus-select-method))
5874 (m2 (or m2 gnus-select-method)))
5876 (and (eq (car m1) (car m2))
5877 (or (not (memq 'address (assoc (symbol-name (car m1))
5878 gnus-valid-select-methods)))
5879 (equal (nth 1 m1) (nth 1 m2)))))))
5881 (defsubst gnus-header-value ()
5882 (buffer-substring (match-end 0) (save-excursion (end-of-line) (point))))
5884 (defun gnus-get-newsgroup-headers ()
5885 (setq gnus-article-internal-prepare-hook nil)
5886 (let ((cur nntp-server-buffer)
5887 (dependencies gnus-newsgroup-dependencies)
5889 headers char article id dep end)
5891 (set-buffer nntp-server-buffer)
5893 ;; Search to the beginning of the next header. Error messages
5894 ;; do not begin with 2 or 3.
5895 (while (re-search-forward "^[23][0-9]+ " nil t)
5896 (let ((header (make-vector 9 nil))
5897 (c (following-char))
5898 (case-fold-search t)
5900 from subject in-reply-to references ref)
5906 (header-set-number header (setq article (read cur)))
5907 ;; This implementation of this function, with nine
5908 ;; search-forwards instead of the one re-search-forward and
5909 ;; a case (which basically was the old function) is actually
5910 ;; about twice as fast, even though it looks messier. You
5911 ;; can't have everything, I guess. Speed and elegance
5912 ;; doesn't always come hand in hand.
5914 (narrow-to-region (point) (save-excursion
5915 (search-forward "\n.\n" nil t)))
5916 (if (search-forward "\nfrom: " nil t)
5917 (header-set-from header (gnus-header-value))
5918 (header-set-from header "(nobody)"))
5920 (if (search-forward "\nsubject: " nil t)
5921 (header-set-subject header (gnus-header-value))
5922 (header-set-subject header "(none)"))
5924 (and (search-forward "\nxref: " nil t)
5925 (header-set-xref header (gnus-header-value)))
5927 (and (search-forward "\nlines: " nil t)
5928 (header-set-lines header (read cur)))
5930 (and (search-forward "\ndate: " nil t)
5931 (header-set-date header (gnus-header-value)))
5933 (if (search-forward "\nmessage-id: " nil t)
5934 (header-set-id header (setq id (gnus-header-value)))
5935 ;; If there was no message-id, we just fake one to make
5936 ;; subsequent routines simpler.
5939 (setq id (concat "none+" (int-to-string
5940 (setq none-id (1+ none-id)))))))
5942 (if (search-forward "\nreferences: " nil t)
5944 (header-set-references header (gnus-header-value))
5945 (setq end (match-end 0))
5952 (search-backward ">" end t)
5955 (search-backward "<" end t)
5957 ;; Get the references from the in-reply-to header if there
5958 ;; ware no references and the in-reply-to header looks
5960 (if (and (search-forward "\nin-reply-to: " nil t)
5961 (setq in-reply-to (gnus-header-value))
5962 (string-match "<[^>]+>" in-reply-to))
5964 (header-set-references
5966 (setq ref (substring in-reply-to (match-beginning 0)
5968 (setq ref (downcase ref)))
5970 ;; We do some threading while we read the headers. The
5971 ;; message-id and the last reference are both entered into
5972 ;; the same hash table. Some tippy-toeing around has to be
5973 ;; done in case an article has arrived before the article
5974 ;; which it refers to.
5975 (if (boundp (setq dep (intern (downcase id) dependencies)))
5976 (if (car (symbol-value dep))
5977 ;; An article with this Message-ID has already
5978 ;; been seen, so we ignore this one, except we add
5979 ;; any additional Xrefs (in case the two articles
5980 ;; came from different servers.
5983 (car (symbol-value dep))
5984 (concat (or (header-xref (car (symbol-value dep))) "")
5985 (or (header-xref header) "")))
5987 (setcar (symbol-value dep) header))
5988 (set dep (list header)))
5991 (if (boundp (setq dep (intern ref dependencies)))
5992 (setcdr (symbol-value dep)
5993 (cons header (cdr (symbol-value dep))))
5994 (set dep (list nil header)))
5995 (setq headers (cons header headers))))
5996 (goto-char (point-max))))))
5997 (nreverse headers)))
5999 ;; The following macros and functions were written by Felix Lee
6000 ;; <flee@cse.psu.edu>.
6002 ;; This is almost 4x faster than (string-to-int (buffer-substring ... ))
6003 ;; primarily because of garbage collection. -jwz
6004 (defmacro gnus-read-integer (&optional point move-p)
6005 (` ((, (if move-p 'progn 'save-excursion))
6006 (,@ (if point (list (list 'goto-char point))))
6007 (if (and (<= (following-char) ?9)
6008 (>= (following-char) ?0))
6009 (read (current-buffer))
6012 (defmacro gnus-nov-skip-field ()
6013 '(search-forward "\t" eol 'end))
6015 (defmacro gnus-nov-field ()
6018 (progn (gnus-nov-skip-field) (1- (point)))))
6020 ;; Goes through the xover lines and returns a list of vectors
6021 (defun gnus-get-newsgroup-headers-xover (sequence)
6022 "Parse the news overview data in the server buffer, and return a
6023 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
6024 ;; Get the Xref when the users reads the articles since most/some
6025 ;; NNTP servers do not include Xrefs when using XOVER.
6026 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6027 (let ((cur nntp-server-buffer)
6028 (dependencies gnus-newsgroup-dependencies)
6030 number headers header)
6032 (set-buffer nntp-server-buffer)
6033 (goto-char (point-min))
6034 (while (and sequence (not (eobp)))
6035 (setq number (read cur))
6036 (while (and sequence (< (car sequence) number))
6037 (setq sequence (cdr sequence)))
6039 (eq number (car sequence))
6041 (setq sequence (cdr sequence))
6043 (inline (gnus-nov-parse-line number dependencies)))
6044 (setq headers (cons header headers)))))
6046 (setq headers (nreverse headers)))
6049 (defun gnus-nov-parse-line (number dependencies)
6050 "Point has to be after the number on the beginning of the line."
6052 header eol ref id dep)
6057 ;; overview: [num subject from date id refs chars lines misc]
6059 (narrow-to-region (point) eol)
6064 (gnus-nov-field) ; subject
6065 (gnus-nov-field) ; from
6066 (gnus-nov-field) ; date
6067 (setq id (or (gnus-nov-field)
6070 (setq none (1+ none)))))) ; id
6073 (let ((beg (point)))
6074 (search-forward "\t" eol)
6075 (if (search-backward ">" beg t)
6081 (search-backward "<" beg t)
6084 (gnus-nov-field)) ; refs
6085 (read (current-buffer)) ; chars
6086 (read (current-buffer)) ; lines
6087 (if (/= (following-char) ?\t)
6090 (gnus-nov-field)) ; misc
6095 ;; We build the thread tree.
6097 (if (boundp (setq dep (intern (downcase id) dependencies)))
6098 (if (car (symbol-value dep))
6099 ;; An article with this Message-ID has already been seen,
6100 ;; so we ignore this one, except we add any additional
6101 ;; Xrefs (in case the two articles came from different
6105 (car (symbol-value dep))
6106 (concat (or (header-xref (car (symbol-value dep))) "")
6107 (or (header-xref header) "")))
6109 (setcar (symbol-value dep) header))
6110 (set dep (list header))))
6113 (if (boundp (setq dep (intern (or ref "none")
6115 (setcdr (symbol-value dep)
6116 (cons header (cdr (symbol-value dep))))
6117 (set dep (list nil header)))))
6120 (defun gnus-article-get-xrefs ()
6121 "Fill in the Xref value in `gnus-current-headers', if necessary.
6122 This is meant to be called in `gnus-article-internal-prepare-hook'."
6123 (or (not gnus-use-cross-reference)
6124 (header-xref gnus-current-headers)
6125 (let ((case-fold-search t)
6128 (gnus-narrow-to-headers)
6129 (goto-char (point-min))
6130 (if (or (and (eq (downcase (following-char)) ?x)
6131 (looking-at "Xref:"))
6132 (search-forward "\nXref:" nil t))
6134 (goto-char (1+ (match-end 0)))
6135 (setq xref (buffer-substring (point)
6136 (progn (end-of-line) (point))))
6138 (set-buffer gnus-summary-buffer)
6139 (header-set-xref gnus-current-headers xref))))))))
6141 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
6142 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
6144 ;; Return a header specified by a NUMBER.
6145 (defun gnus-get-header-by-number (number)
6147 (set-buffer gnus-summary-buffer)
6148 (or gnus-newsgroup-headers-hashtb-by-number
6149 (gnus-make-headers-hashtable-by-number))
6150 (gnus-gethash (int-to-string number)
6151 gnus-newsgroup-headers-hashtb-by-number)))
6153 (defun gnus-make-headers-hashtable-by-number ()
6154 "Make hashtable for the variable gnus-newsgroup-headers by number."
6156 (set-buffer gnus-summary-buffer)
6157 (let ((headers gnus-newsgroup-headers)
6159 (setq gnus-newsgroup-headers-hashtb-by-number
6160 (gnus-make-hashtable (length headers)))
6162 (setq header (car headers))
6163 (gnus-sethash (int-to-string (header-number header))
6164 header gnus-newsgroup-headers-hashtb-by-number)
6165 (setq headers (cdr headers))))))
6167 (defun gnus-more-header-backward ()
6168 "Find new header backward."
6169 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6170 (artnum gnus-newsgroup-begin)
6172 (while (and (not header)
6174 (setq artnum (1- artnum))
6175 (setq header (gnus-read-header artnum)))
6178 (defun gnus-more-header-forward (&optional backward)
6179 "Find new header forward.
6180 If BACKWARD, find new header backward instead."
6182 (gnus-more-header-backward)
6183 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6184 (artnum gnus-newsgroup-end)
6186 (while (and (not header)
6188 (setq artnum (1+ artnum))
6189 (setq header (gnus-read-header artnum)))
6192 (defun gnus-extend-newsgroup (header &optional backward)
6193 "Extend newsgroup selection with HEADER.
6194 Optional argument BACKWARD means extend toward backward."
6196 (let ((artnum (header-number header)))
6197 (setq gnus-newsgroup-headers
6199 (cons header gnus-newsgroup-headers)
6200 (nconc gnus-newsgroup-headers (list header))))
6201 (setq gnus-newsgroup-unselected
6202 (delq artnum gnus-newsgroup-unselected))
6203 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
6204 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
6206 (defun gnus-summary-work-articles (n)
6207 "Return a list of articles to be worked upon. The prefix argument,
6208 the list of process marked articles, and the current article will be
6209 taken into consideration."
6211 (if (and n (numberp n))
6212 (let ((backward (< n 0))
6216 (setq articles (cons (gnus-summary-article-number)
6218 (gnus-summary-search-forward nil nil backward))
6220 (sort articles (function <)))
6221 (or (reverse gnus-newsgroup-processable)
6222 (list (gnus-summary-article-number))))))
6224 (defun gnus-summary-search-group (&optional backward use-level)
6225 "Search for next unread newsgroup.
6226 If optional argument BACKWARD is non-nil, search backward instead."
6228 (set-buffer gnus-group-buffer)
6230 ;; We don't want to alter current point of group mode buffer.
6231 (if (gnus-group-search-forward
6233 (if use-level (gnus-group-group-level) nil))
6234 (gnus-group-group-name)))))
6236 (defun gnus-summary-best-group (&optional exclude-group)
6237 "Find the name of the best unread group.
6238 If EXCLUDE-GROUP, do not go to this group."
6240 (set-buffer gnus-group-buffer)
6242 (gnus-group-best-unread-group exclude-group))))
6244 (defun gnus-summary-search-subject (&optional backward unread subject)
6245 "Search for article forward.
6246 If BACKWARD is non-nil, search backward.
6247 If UNREAD is non-nil, only unread articles are selected.
6248 If SUBJECT is non-nil, the article which has the same subject will be
6250 (let ((func (if backward 'previous-single-property-change
6251 'next-single-property-change))
6256 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
6257 (while (and (setq pos (funcall func (point) 'gnus-number))
6258 (goto-char (if backward (1- pos) pos))
6260 (not (and (or (not unread)
6261 (eq (get-text-property (point) 'gnus-mark)
6264 (equal (gnus-simplify-subject-re
6266 (gnus-simplify-subject-re
6269 'gnus-subject)))))))
6270 (if backward (if (bobp) nil (forward-char -1) t)
6271 (if (eobp) nil (forward-char 1) t))))
6273 (progn (goto-char beg) nil)
6275 (get-text-property (point) 'gnus-number)
6276 (gnus-summary-position-cursor)))))
6278 (defun gnus-summary-search-forward (&optional unread subject backward)
6279 "Search for article forward.
6280 If UNREAD is non-nil, only unread articles are selected.
6281 If SUBJECT is non-nil, the article which has the same subject will be
6283 If BACKWARD is non-nil, the search will be performed backwards instead."
6284 (gnus-summary-search-subject backward unread subject))
6286 (defun gnus-summary-search-backward (&optional unread subject)
6287 "Search for article backward.
6288 If 1st optional argument UNREAD is non-nil, only unread article is selected.
6289 If 2nd optional argument SUBJECT is non-nil, the article which has
6290 the same subject will be searched for."
6291 (gnus-summary-search-forward unread subject t))
6293 (defun gnus-summary-article-number (&optional number-or-nil)
6294 "The article number of the article on the current line.
6295 If there isn's an article number here, then we return the current
6298 (number (get-text-property
6299 (progn (beginning-of-line) (prog1 (point) (goto-char p)))
6301 (if number-or-nil number (or number gnus-current-article))))
6303 (defun gnus-summary-thread-level ()
6304 "The thread level of the article on the current line."
6305 (or (get-text-property
6306 (save-excursion (beginning-of-line) (point)) 'gnus-thread)
6309 (defun gnus-summary-pseudo-article ()
6310 "The thread level of the article on the current line."
6312 (save-excursion (beginning-of-line) (point)) 'gnus-pseudo))
6314 (defun gnus-summary-article-mark ()
6315 "The mark on the current line."
6316 (get-text-property (save-excursion (beginning-of-line) (point)) 'gnus-mark))
6318 (defun gnus-summary-subject-string ()
6319 "Return current subject string or nil if nothing."
6321 (save-excursion (beginning-of-line) (point)) 'gnus-subject))
6323 (defalias 'gnus-summary-score 'gnus-summary-article-score)
6324 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
6325 (defun gnus-summary-article-score ()
6326 "Return current article score."
6327 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
6328 gnus-summary-default-score 0))
6330 (defun gnus-summary-recenter ()
6331 "Center point in the summary window.
6332 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6333 displayed, no centering will be performed."
6334 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6335 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6336 (let ((top (cond ((< (window-height) 4) 0)
6337 ((< (window-height) 6) 1)
6340 ;; The user has to want it,
6341 gnus-auto-center-summary
6342 ;; the article buffer must be displayed,
6343 (get-buffer-window gnus-article-buffer)
6344 ;; there must be lines left to scroll forward,
6345 (zerop (save-excursion (forward-line (- (window-height) 1 top))))
6348 (get-buffer-window (current-buffer))
6349 (save-excursion (forward-line (- top)) (point))))))
6351 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
6352 (defun gnus-short-group-name (newsgroup)
6353 "Convert a long group name to an initialized form.
6354 The last part of the name is left intact: \"rec.arts.anime\" becomes
6358 (if (string-match "\\." newsgroup)
6360 (setq name (concat name (substring newsgroup 0 1))
6361 newsgroup (substring newsgroup (match-end 0))
6362 name (concat name ".")))
6363 (setq name (concat name newsgroup)
6368 (defun gnus-summary-jump-to-group (newsgroup)
6369 "Move point to NEWSGROUP in group mode buffer."
6370 ;; Keep update point of group mode buffer if visible.
6371 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6372 (save-window-excursion
6373 ;; Take care of tree window mode.
6374 (if (get-buffer-window gnus-group-buffer)
6375 (pop-to-buffer gnus-group-buffer))
6376 (gnus-group-jump-to-group newsgroup))
6378 ;; Take care of tree window mode.
6379 (if (get-buffer-window gnus-group-buffer)
6380 (pop-to-buffer gnus-group-buffer)
6381 (set-buffer gnus-group-buffer))
6382 (gnus-group-jump-to-group newsgroup))))
6384 ;; This function returns a list of article numbers based on the
6385 ;; difference between the ranges of read articles in this group and
6386 ;; the range of active articles.
6387 (defun gnus-list-of-unread-articles (group)
6388 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6389 (active (gnus-gethash group gnus-active-hashtb))
6391 unread first nlast unread)
6392 ;; If none are read, then all are unread.
6394 (setq first (car active))
6395 ;; If the range of read articles is a single range, then the
6396 ;; first unread article is the article after the last read
6397 ;; article. Sounds logical, doesn't it?
6398 (if (not (listp (cdr read)))
6399 (setq first (1+ (cdr read)))
6400 ;; `read' is a list of ranges.
6401 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
6402 (car (car read)))) 1)
6406 (while (< first nlast)
6407 (setq unread (cons first unread))
6408 (setq first (1+ first))))
6409 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
6410 (setq nlast (if (atom (car (cdr read)))
6412 (car (car (cdr read)))))
6413 (setq read (cdr read)))))
6414 ;; And add the last unread articles.
6415 (while (<= first last)
6416 (setq unread (cons first unread))
6417 (setq first (1+ first)))
6418 ;; Return the list of unread articles.
6422 ;; Various summary commands
6424 (defun gnus-summary-universal-argument ()
6425 "Perform any operation on all articles marked with the process mark."
6427 (gnus-set-global-variables)
6428 (let ((articles (reverse gnus-newsgroup-processable))
6430 (or articles (error "No articles marked"))
6431 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
6432 (error "Undefined key"))
6434 (gnus-summary-goto-subject (car articles))
6435 (command-execute func)
6436 (gnus-summary-remove-process-mark (car articles))
6437 (setq articles (cdr articles)))))
6439 (defun gnus-summary-toggle-truncation (arg)
6440 "Toggle truncation of summary lines.
6441 With arg, turn line truncation on iff arg is positive."
6443 (setq truncate-lines
6444 (if (null arg) (not truncate-lines)
6445 (> (prefix-numeric-value arg) 0)))
6448 (defun gnus-summary-reselect-current-group (all)
6449 "Once exit and then reselect the current newsgroup.
6450 The prefix argument ALL means to select all articles."
6452 (gnus-set-global-variables)
6453 (let ((current-subject (gnus-summary-article-number)))
6454 (gnus-summary-exit t)
6455 ;; We have to adjust the point of group mode buffer because the
6456 ;; current point was moved to the next unread newsgroup by
6458 (gnus-summary-jump-to-group gnus-newsgroup-name)
6459 (gnus-group-read-group all t)
6460 (gnus-summary-goto-subject current-subject)))
6462 (defun gnus-summary-rescan-group (all)
6463 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6465 (gnus-set-global-variables)
6466 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
6467 (let ((group gnus-newsgroup-name))
6468 (gnus-summary-exit t)
6469 (gnus-summary-jump-to-group group)
6471 (set-buffer gnus-group-buffer)
6472 (gnus-group-get-new-news-this-group 1))
6473 (gnus-summary-jump-to-group group)
6474 (gnus-group-read-group all)))
6476 (defun gnus-summary-exit (&optional temporary)
6477 "Exit reading current newsgroup, and then return to group selection mode.
6478 gnus-exit-group-hook is called with no arguments if that value is non-nil."
6480 (gnus-set-global-variables)
6481 (gnus-kill-save-kill-buffer)
6482 (let* ((group gnus-newsgroup-name)
6483 (quit-buffer (cdr (assoc 'quit-buffer (gnus-find-method-for-group
6484 gnus-newsgroup-name))))
6486 (method (car (gnus-find-method-for-group group)))
6487 (buf (current-buffer)))
6488 (if gnus-newsgroup-kill-headers
6489 (setq gnus-newsgroup-killed
6490 (gnus-compress-sequence
6492 (gnus-set-sorted-intersection
6493 (gnus-uncompress-range gnus-newsgroup-killed)
6494 (setq gnus-newsgroup-unselected
6495 (sort gnus-newsgroup-unselected '<)))
6496 (setq gnus-newsgroup-unreads
6497 (sort gnus-newsgroup-unreads '<))) t)))
6498 (or (listp (cdr gnus-newsgroup-killed))
6499 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6501 (headers gnus-newsgroup-headers))
6502 (gnus-close-group group)
6503 (run-hooks 'gnus-exit-group-hook)
6505 (gnus-update-read-articles
6506 group gnus-newsgroup-unreads gnus-newsgroup-unselected
6507 gnus-newsgroup-marked
6508 t gnus-newsgroup-replied gnus-newsgroup-expirable
6509 gnus-newsgroup-killed gnus-newsgroup-dormant
6510 gnus-newsgroup-bookmarks
6511 (and gnus-save-score gnus-newsgroup-scored))
6512 (and gnus-use-cross-reference
6513 (gnus-mark-xrefs-as-read
6514 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
6515 ;; Do not switch windows but change the buffer to work.
6516 (set-buffer gnus-group-buffer)
6517 (or (eq 'nndigest method)
6518 (gnus-group-update-group group)))
6519 ;; Make sure where I was, and go to next newsgroup.
6520 (if (eq method 'nndigest)
6522 (gnus-group-jump-to-group group)
6523 (gnus-group-next-unread-group 1))
6525 ;; If exiting temporary, caller should adjust group mode
6526 ;; buffer point by itself.
6528 ;; We set all buffer-local variables to nil. It is unclear why
6529 ;; this is needed, but if we don't, buffer-local variables are
6530 ;; not garbage-collected, it seems. This would the lead to en
6531 ;; ever-growing Emacs.
6533 (gnus-summary-clear-local-variables)
6534 ;; We clear the global counterparts of the buffer-local
6535 ;; variables as well, just to be on the safe side.
6536 (set-buffer gnus-group-buffer)
6537 (gnus-summary-clear-local-variables)
6538 (gnus-configure-windows 'newsgroups t)
6539 ;; Return to group mode buffer.
6540 (and (get-buffer buf)
6541 (eq mode 'gnus-summary-mode)
6543 (if (get-buffer gnus-article-buffer)
6544 (bury-buffer gnus-article-buffer))
6545 (setq gnus-current-select-method gnus-select-method)
6546 (pop-to-buffer gnus-group-buffer)
6547 (if (and quit-buffer (buffer-name quit-buffer))
6549 (switch-to-buffer quit-buffer)
6550 (gnus-set-global-variables)
6551 (gnus-configure-windows 'summary))))))
6553 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6554 (defun gnus-summary-exit-no-update (&optional no-questions)
6555 "Quit reading current newsgroup without updating read article info."
6557 (let* ((group gnus-newsgroup-name)
6558 (quit-buffer (cdr (assoc 'quit-buffer
6559 (gnus-find-method-for-group group)))))
6560 (if (or no-questions
6562 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
6564 (gnus-close-group group)
6565 (gnus-summary-clear-local-variables)
6566 (set-buffer gnus-group-buffer)
6567 (gnus-summary-clear-local-variables)
6568 ;; Return to group selection mode.
6569 (gnus-configure-windows 'newsgroups)
6570 (if (get-buffer gnus-summary-buffer)
6571 (kill-buffer gnus-summary-buffer))
6572 (if (get-buffer gnus-article-buffer)
6573 (bury-buffer gnus-article-buffer))
6574 (pop-to-buffer gnus-group-buffer)
6575 (gnus-group-jump-to-group group)
6576 (gnus-group-next-group 1)
6577 (if (and quit-buffer (buffer-name quit-buffer))
6579 (switch-to-buffer quit-buffer)
6580 (gnus-configure-windows 'summary)))))))
6582 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6583 (defun gnus-summary-fetch-faq (group)
6584 "Fetch the FAQ for the current group."
6585 (interactive (list gnus-newsgroup-name))
6586 (gnus-configure-windows 'article)
6587 (pop-to-buffer gnus-article-buffer)
6588 (find-file (concat gnus-group-faq-directory group)))
6590 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6591 (defun gnus-summary-describe-group (force)
6592 "Describe the current newsgroup."
6594 (gnus-group-describe-group force gnus-newsgroup-name))
6596 (defun gnus-summary-describe-briefly ()
6597 "Describe summary mode commands briefly."
6600 (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")))
6602 ;; Walking around group mode buffer from summary mode.
6604 (defun gnus-summary-next-group (&optional no-article group backward)
6605 "Exit current newsgroup and then select next unread newsgroup.
6606 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
6607 If BACKWARD, go to previous group instead."
6609 (gnus-set-global-variables)
6610 (let ((ingroup gnus-newsgroup-name)
6611 (sumbuf (current-buffer))
6613 (gnus-summary-exit t) ;Update all information.
6615 (or (and (numberp (setq num (car (gnus-gethash
6616 group gnus-newsrc-hashtb))))
6620 (gnus-group-jump-to-group group)
6622 (gnus-group-jump-to-group ingroup))
6623 (let ((group (or group (gnus-summary-search-group backward)))
6624 (buf gnus-summary-buffer))
6626 (gnus-summary-exit-no-update t)
6627 (message "Selecting %s..." group)
6628 ;; We are now in group mode buffer.
6629 ;; Make sure group mode buffer point is on GROUP.
6630 (gnus-group-jump-to-group group)
6632 (gnus-summary-read-group group nil no-article buf)
6633 (and (string= gnus-newsgroup-name ingroup)
6634 (bufferp sumbuf) (buffer-name sumbuf)
6636 (set-buffer (setq gnus-summary-buffer sumbuf))
6637 (gnus-summary-exit-no-update t))))))))
6639 (defun gnus-summary-prev-group (no-article)
6640 "Exit current newsgroup and then select previous unread newsgroup.
6641 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6643 (gnus-summary-next-group no-article nil t))
6645 ;; Walking around summary lines.
6647 (defun gnus-summary-first-subject (unread)
6648 "Go to the first unread subject.
6649 If UNREAD is non-nil, go to the first unread article.
6650 Returns nil if there are no unread articles."
6652 (let ((begin (point)))
6654 (if (not (gnus-goto-char
6655 (text-property-any (point-min) (point-max)
6656 'gnus-mark gnus-unread-mark)))
6658 ;; If there is no unread articles, stay where you are.
6660 (message "No more unread articles")
6663 (goto-char (point-min)))))
6665 (defun gnus-summary-next-subject (n &optional unread)
6666 "Go to next N'th summary line.
6667 If N is negative, go to the previous N'th subject line.
6668 If UNREAD is non-nil, only unread articles are selected.
6669 The difference between N and the actual number of steps taken is
6672 (let ((backward (< n 0))
6675 (gnus-summary-search-forward unread nil backward))
6677 (gnus-summary-recenter)
6678 (if (/= 0 n) (message "No more%s articles" (if unread " unread" "")))
6679 (gnus-summary-position-cursor)
6682 (defun gnus-summary-next-unread-subject (n)
6683 "Go to next N'th unread summary line."
6685 (gnus-summary-next-subject n t))
6687 (defun gnus-summary-prev-subject (n &optional unread)
6688 "Go to previous N'th summary line.
6689 If optional argument UNREAD is non-nil, only unread article is selected."
6691 (gnus-summary-next-subject (- n) unread))
6693 (defun gnus-summary-prev-unread-subject (n)
6694 "Go to previous N'th unread summary line."
6696 (gnus-summary-next-subject (- n) t))
6698 (defun gnus-summary-goto-subject (article)
6699 "Go the subject line of ARTICLE."
6703 (completing-read "Article number: "
6707 (int-to-string (header-number headers))))
6708 gnus-newsgroup-headers)
6709 nil 'require-match))))
6710 (or article (error "No article number"))
6711 (if (or (eq article (gnus-summary-article-number t))
6714 (point-min) (point-max) 'gnus-number article)))
6717 ;; Walking around summary lines with displaying articles.
6719 (defun gnus-summary-expand-window ()
6720 "Expand summary window to show headers full window."
6722 (gnus-set-global-variables)
6723 (gnus-configure-windows 'summary)
6724 (pop-to-buffer gnus-summary-buffer))
6726 (defun gnus-summary-display-article (article &optional all-header)
6727 "Display ARTICLE in article buffer."
6728 (gnus-set-global-variables)
6731 (gnus-article-prepare article all-header)
6732 (if (eq (gnus-summary-article-mark) ?Z)
6735 (gnus-summary-position-cursor)))
6736 (run-hooks 'gnus-select-article-hook)
6737 (gnus-summary-recenter)
6738 ; (set-window-point (get-buffer-window (current-buffer)) (point-max))
6740 (gnus-summary-goto-subject article)
6741 ;; Successfully display article.
6742 (gnus-summary-update-line)
6745 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6746 "Select the current article.
6747 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6748 non-nil, the article will be re-fetched even if it already present in
6749 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6751 (and (not pseudo) (gnus-summary-pseudo-article)
6752 (error "This is a pseudo-article."))
6753 (let ((article (or article (gnus-summary-article-number)))
6754 (all-headers (not (not all-headers)))) ;Must be T or NIL.
6755 (if (or (null gnus-current-article)
6756 (null gnus-article-current)
6757 (/= article (cdr gnus-article-current))
6758 (not (equal (car gnus-article-current) gnus-newsgroup-name))
6760 ;; The requested article is different from the current article.
6762 (gnus-summary-display-article article all-headers)
6764 (if all-headers (gnus-article-show-all-headers))
6765 (gnus-configure-windows 'article)
6766 (pop-to-buffer gnus-summary-buffer)
6769 (defun gnus-summary-set-current-mark (&optional current-mark)
6770 "Obsolete function."
6773 (defun gnus-summary-next-article (unread &optional subject backward)
6774 "Select the next article.
6775 If UNREAD, only unread articles are selected.
6776 If SUBJECT, only articles with SUBJECT are selected.
6777 If BACKWARD, the previous article is selected instead of the next."
6779 (let ((opoint (point))
6780 (method (car (gnus-find-method-for-group gnus-newsgroup-name)))
6783 ;; Is there such an article?
6784 ((gnus-summary-display-article
6785 (gnus-summary-search-forward unread subject backward))
6786 (gnus-summary-position-cursor))
6787 ;; If not, we try the first unread, if that is wanted.
6789 gnus-auto-select-same
6790 (gnus-summary-first-unread-article))
6791 (message "Wrapped"))
6792 ;; Try to get next/previous article not displayed in this group.
6793 ((and gnus-auto-extend-newsgroup
6794 (not unread) (not subject)
6795 (setq header (gnus-more-header-forward backward)))
6796 (gnus-extend-newsgroup header backward)
6797 (let ((buffer-read-only nil))
6798 (goto-char (if backward (point-min) (point-max)))
6799 (gnus-summary-prepare-threads (list header) 0))
6800 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
6801 gnus-newsgroup-end)))
6802 ;; Go to next/previous group.
6804 (gnus-summary-jump-to-group gnus-newsgroup-name)
6805 (let ((cmd (aref (this-command-keys) 0))
6807 (if (eq gnus-keep-same-level 'best)
6808 (gnus-summary-best-group gnus-newsgroup-name)
6809 (gnus-summary-search-group backward gnus-keep-same-level))))
6810 ;; Keep just the event type of CMD.
6811 (and (listp cmd) (setq cmd (car cmd)))
6812 ;; Select next unread newsgroup automagically.
6814 ((not gnus-auto-select-next)
6815 (message "No more%s articles" (if unread " unread" "")))
6816 ((eq gnus-auto-select-next 'quietly)
6818 (if (eq method 'nndigest)
6820 (message "No more%s articles (%s)..."
6821 (if unread " unread" "")
6822 (if group (concat "selecting " group)
6824 (gnus-summary-next-group nil group backward)))
6826 (let ((keystrokes '(?\C-n ?\C-p))
6828 (while (or (null key) (memq key keystrokes))
6830 "No more%s articles%s" (if unread " unread" "")
6831 (if (and group (not (eq method 'nndigest)))
6832 (format " (Type %s for %s [%s])"
6833 (single-key-description cmd) group
6834 (car (gnus-gethash group gnus-newsrc-hashtb)))
6835 (format " (Type %s to exit %s)"
6836 (single-key-description cmd)
6837 gnus-newsgroup-name)))
6838 ;; Confirm auto selection.
6839 (let* ((event (read-event)))
6840 (setq key (if (listp event) (car event) event))
6841 (if (member key keystrokes)
6842 (let ((obuf (current-buffer)))
6843 (switch-to-buffer gnus-group-buffer)
6844 (gnus-group-jump-to-group group)
6845 (execute-kbd-macro (char-to-string key))
6846 (setq group (gnus-group-group-name))
6847 (switch-to-buffer obuf)))))
6849 (if (or (not group) (eq method 'nndigest))
6851 (gnus-summary-next-group nil group backward))
6852 (setq unread-command-events (list key)))))))))))
6854 (defun gnus-summary-next-unread-article ()
6855 "Select unread article after current one."
6857 (gnus-summary-next-article t (and gnus-auto-select-same
6858 (gnus-summary-subject-string))))
6860 (defun gnus-summary-prev-article (unread &optional subject)
6861 "Select the article after the current one.
6862 If UNREAD is non-nil, only unread articles are selected."
6864 (gnus-summary-next-article unread subject t))
6866 (defun gnus-summary-prev-unread-article ()
6867 "Select unred article before current one."
6869 (gnus-summary-prev-article t (and gnus-auto-select-same
6870 (gnus-summary-subject-string))))
6872 (defun gnus-summary-next-page (lines &optional circular)
6873 "Show next page of selected article.
6874 If end of article, select next article.
6875 Argument LINES specifies lines to be scrolled up.
6876 If CIRCULAR is non-nil, go to the start of the article instead of
6877 instead of selecting the next article when reaching the end of the
6880 (setq gnus-summary-buffer (current-buffer))
6881 (let ((article (gnus-summary-article-number))
6883 (if (or (null gnus-current-article)
6884 (null gnus-article-current)
6885 (/= article (cdr gnus-article-current))
6886 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6887 ;; Selected subject is different from current article's.
6888 (gnus-summary-display-article article)
6889 (gnus-configure-windows 'article)
6890 (pop-to-buffer gnus-summary-buffer)
6891 (gnus-eval-in-buffer-window
6893 (setq endp (gnus-article-next-page lines)))
6896 (gnus-summary-beginning-of-article))
6898 (message "End of message"))
6900 (gnus-summary-next-unread-article))))))
6901 (gnus-summary-position-cursor))
6903 (defun gnus-summary-prev-page (lines)
6904 "Show previous page of selected article.
6905 Argument LINES specifies lines to be scrolled down."
6907 (let ((article (gnus-summary-article-number)))
6908 (if (or (null gnus-current-article)
6909 (null gnus-article-current)
6910 (/= article (cdr gnus-article-current))
6911 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6912 ;; Selected subject is different from current article's.
6913 (gnus-summary-display-article article)
6914 (gnus-configure-windows 'article)
6915 (pop-to-buffer gnus-summary-buffer)
6916 (gnus-eval-in-buffer-window gnus-article-buffer
6917 (gnus-article-prev-page lines))))
6918 (gnus-summary-position-cursor))
6920 (defun gnus-summary-scroll-up (lines)
6921 "Scroll up (or down) one line current article.
6922 Argument LINES specifies lines to be scrolled up (or down if negative)."
6924 (or (gnus-summary-select-article nil nil 'pseudo)
6925 (gnus-eval-in-buffer-window
6928 (if (gnus-article-next-page lines)
6929 (message "End of message")))
6931 (gnus-article-prev-page (- lines))))))
6932 (gnus-summary-position-cursor))
6934 (defun gnus-summary-next-same-subject ()
6935 "Select next article which has the same subject as current one."
6937 (gnus-summary-next-article nil (gnus-summary-subject-string)))
6939 (defun gnus-summary-prev-same-subject ()
6940 "Select previous article which has the same subject as current one."
6942 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
6944 (defun gnus-summary-next-unread-same-subject ()
6945 "Select next unread article which has the same subject as current one."
6947 (gnus-summary-next-article t (gnus-summary-subject-string)))
6949 (defun gnus-summary-prev-unread-same-subject ()
6950 "Select previous unread article which has the same subject as current one."
6952 (gnus-summary-prev-article t (gnus-summary-subject-string)))
6954 (defun gnus-summary-first-unread-article ()
6955 "Select the first unread article.
6956 Return nil if there are no unread articles."
6959 (if (gnus-summary-first-subject t)
6960 (gnus-summary-display-article (gnus-summary-article-number)))
6961 (gnus-summary-position-cursor)))
6963 (defun gnus-summary-best-unread-article ()
6964 "Select the unread article with the highest score."
6966 (gnus-set-global-variables)
6967 (let ((scored gnus-newsgroup-scored)
6971 (or (> best (cdr (car scored)))
6972 (and (memq (setq art (car (car scored))) gnus-newsgroup-unreads)
6973 (not (memq art gnus-newsgroup-marked))
6974 (not (memq art gnus-newsgroup-dormant))
6975 (if (= best (cdr (car scored)))
6976 (setq article (min art article))
6978 (setq best (cdr (car scored))))))
6979 (setq scored (cdr scored)))
6981 (gnus-summary-goto-article article)
6982 (gnus-summary-first-unread-article))
6983 (gnus-summary-position-cursor)))
6985 (defun gnus-summary-goto-article (article &optional all-headers)
6986 "Fetch ARTICLE and display it if it exists.
6987 If ALL-HEADERS is non-nil, no header lines are hidden."
6993 (mapcar (lambda (headers) (list (int-to-string (header-number headers))))
6994 gnus-newsgroup-headers)
6995 nil 'require-match))))
6996 (if (gnus-summary-goto-subject article)
6997 (gnus-summary-display-article article all-headers))
6998 (gnus-summary-position-cursor))
7000 (defun gnus-summary-goto-last-article ()
7001 "Go to the last article."
7003 (if gnus-last-article
7004 (gnus-summary-goto-article gnus-last-article))
7005 (gnus-summary-position-cursor))
7007 (defun gnus-summary-pop-article (number)
7008 "Pop one article off the history and go to the previous.
7009 NUMBER articles will be popped off."
7012 (setq gnus-newsgroup-history
7013 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7015 (gnus-summary-goto-article (car to))
7016 (error "Article history empty")))
7017 (gnus-summary-position-cursor))
7019 ;; Summary article oriented commands
7021 (defun gnus-summary-refer-parent-article (n)
7022 "Refer parent article N times.
7023 The difference between N and the number of articles fetched is returned."
7025 (gnus-set-global-variables)
7029 (let ((ref (header-references (gnus-get-header-by-number
7030 (gnus-summary-article-number)))))
7031 (if (and ref (not (equal ref ""))
7032 (string-match "<[^<>]*>[ \t]*$" ref))
7033 (gnus-summary-refer-article
7034 (substring ref (match-beginning 0) (match-end 0))))))
7036 (or (zerop n) (message "No references in article or expired article."))
7037 (gnus-summary-position-cursor)
7040 (defun gnus-summary-refer-article (message-id)
7041 "Refer article specified by MESSAGE-ID.
7042 NOTE: This command only works with newsgroup that use NNTP."
7043 (interactive "sMessage-ID: ")
7044 (if (or (not (stringp message-id))
7045 (zerop (length message-id)))
7047 ;; Construct the correct Message-ID if necessary.
7048 ;; Suggested by tale@pawl.rpi.edu.
7049 (or (string-match "^<" message-id)
7050 (setq message-id (concat "<" message-id)))
7051 (or (string-match ">$" message-id)
7052 (setq message-id (concat message-id ">")))
7053 (let ((header (car (gnus-gethash (downcase message-id)
7054 gnus-newsgroup-dependencies))))
7056 (gnus-summary-goto-article (header-number header))
7057 (let ((gnus-override-method gnus-refer-article-method))
7058 (if (gnus-article-prepare
7059 message-id nil (gnus-read-header message-id))
7061 (gnus-summary-insert-line
7062 nil gnus-current-headers 0 nil gnus-read-mark nil nil
7063 (header-subject gnus-current-headers))
7065 (gnus-summary-position-cursor)
7066 (gnus-summary-update-line)
7068 (message "No such references")
7071 (defun gnus-summary-enter-digest-group ()
7072 "Enter a digest group based on the current article."
7074 (gnus-summary-select-article)
7075 (let ((name (format "%s/%d"
7076 (gnus-group-prefixed-name
7077 gnus-newsgroup-name (list 'nndigest ""))
7078 gnus-current-article))
7079 (buf (current-buffer)))
7080 (set-buffer gnus-group-buffer)
7083 (list t nil (list name 3 nil nil
7084 (list 'nndigest gnus-article-buffer
7085 (cons 'quit-buffer buf))))
7087 (gnus-group-read-group t nil name)))
7089 (defun gnus-summary-isearch-article ()
7090 "Do incremental search forward on current article."
7092 (gnus-summary-select-article)
7093 (gnus-eval-in-buffer-window gnus-article-buffer
7096 (defun gnus-summary-search-article-forward (regexp)
7097 "Search for an article containing REGEXP forward.
7098 gnus-select-article-hook is not called during the search."
7101 (concat "Search forward (regexp): "
7102 (if gnus-last-search-regexp
7103 (concat "(default " gnus-last-search-regexp ") "))))))
7104 (if (string-equal regexp "")
7105 (setq regexp (or gnus-last-search-regexp ""))
7106 (setq gnus-last-search-regexp regexp))
7107 (if (gnus-summary-search-article regexp nil)
7108 (gnus-eval-in-buffer-window
7111 (error "Search failed: \"%s\"" regexp)))
7113 (defun gnus-summary-search-article-backward (regexp)
7114 "Search for an article containing REGEXP backward.
7115 gnus-select-article-hook is not called during the search."
7118 (concat "Search backward (regexp): "
7119 (if gnus-last-search-regexp
7120 (concat "(default " gnus-last-search-regexp ") "))))))
7121 (if (string-equal regexp "")
7122 (setq regexp (or gnus-last-search-regexp ""))
7123 (setq gnus-last-search-regexp regexp))
7124 (if (gnus-summary-search-article regexp t)
7125 (gnus-eval-in-buffer-window
7128 (error "Search failed: \"%s\"" regexp)))
7130 (defun gnus-summary-search-article (regexp &optional backward)
7131 "Search for an article containing REGEXP.
7132 Optional argument BACKWARD means do search for backward.
7133 gnus-select-article-hook is not called during the search."
7134 (let ((gnus-select-article-hook nil) ;Disable hook.
7135 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7138 (function re-search-backward) (function re-search-forward)))
7141 ;; Hidden thread subtrees must be searched for ,too.
7142 (gnus-summary-show-all-threads)
7143 (if (eobp) (forward-line -1))
7144 ;; First of all, search current article.
7145 ;; We don't want to read article again from NNTP server nor reset
7147 (gnus-summary-select-article)
7148 (message "Searching article: %d..." gnus-current-article)
7149 (setq last gnus-current-article)
7150 (gnus-eval-in-buffer-window gnus-article-buffer
7153 ;; Begin search from current point.
7154 (setq found (funcall re-search regexp nil t))))
7155 ;; Then search next articles.
7156 (while (and (not found)
7157 (gnus-summary-display-article
7158 (gnus-summary-search-subject backward nil nil)))
7159 (message "Searching article: %d..." gnus-current-article)
7160 (gnus-eval-in-buffer-window gnus-article-buffer
7163 (goto-char (if backward (point-max) (point-min)))
7164 (setq found (funcall re-search regexp nil t)))))
7166 ;; Adjust article pointer.
7167 (or (eq last gnus-current-article)
7168 (setq gnus-last-article last))
7169 ;; Return T if found such article.
7172 (defun gnus-summary-execute-command (header regexp command &optional backward)
7173 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7174 If HEADER is an empty string (or nil), the match is done on the entire
7175 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7177 (list (let ((completion-ignore-case t))
7180 (mapcar (string) (list string)
7181 '("Number" "Subject" "From" "Lines" "Date"
7182 "Message-ID" "Xref" "References")
7183 nil 'require-match)))
7184 (read-string "Regexp: ")
7185 (read-key-sequence "Command: ")
7186 current-prefix-arg))
7187 ;; Hidden thread subtrees must be searched as well.
7188 (gnus-summary-show-all-threads)
7189 ;; We don't want to change current point nor window configuration.
7191 (save-window-excursion
7192 (message "Executing %s..." (key-description command))
7193 ;; We'd like to execute COMMAND interactively so as to give arguments.
7194 (gnus-execute header regexp
7196 (call-interactively '(, (key-binding command)))))
7198 (message "Executing %s... done" (key-description command)))))
7200 (defun gnus-summary-beginning-of-article ()
7201 "Scroll the article back to the beginning."
7203 (gnus-summary-select-article)
7204 (gnus-eval-in-buffer-window
7207 (goto-char (point-min))
7208 (and gnus-break-pages (gnus-narrow-to-page))))
7210 (defun gnus-summary-end-of-article ()
7211 "Scroll to the end of the article."
7213 (gnus-summary-select-article)
7214 (gnus-eval-in-buffer-window
7217 (goto-char (point-max))
7218 (and gnus-break-pages (gnus-narrow-to-page))))
7220 (defun gnus-summary-show-article ()
7221 "Force re-fetching of the current article."
7223 (gnus-summary-select-article gnus-have-all-headers t t))
7225 (defun gnus-summary-toggle-header (arg)
7226 "Show the headers if they are hidden, or hide them if they are shown.
7227 If ARG is a positive number, show the entire header.
7228 If ARG is a negative number, hide the unwanted header lines."
7230 (gnus-set-global-variables)
7232 (set-buffer gnus-article-buffer)
7233 (let ((buffer-read-only nil))
7235 (if (> arg 0) (remove-text-properties 1 (point-max) '(invisible t))
7236 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
7237 (if (text-property-any 1 (point-max) 'invisible t)
7238 (remove-text-properties 1 (point-max) '(invisible t))
7239 (let ((gnus-have-all-headers nil))
7240 (run-hooks 'gnus-article-display-hook))))
7241 (set-window-point (get-buffer-window (current-buffer)) 1))))
7243 (defun gnus-summary-show-all-headers ()
7244 "Make all header lines visible."
7246 (gnus-article-show-all-headers))
7248 (defun gnus-summary-toggle-mime (arg)
7249 "Toggle MIME processing.
7250 If ARG is a positive number, turn MIME processing on."
7252 (setq gnus-show-mime
7253 (if (null arg) (not gnus-show-mime)
7254 (> (prefix-numeric-value arg) 0)))
7255 (gnus-summary-select-article t 'force))
7257 (defun gnus-summary-caesar-message (rotnum)
7258 "Caesar rotates all letters of current message by 13/47 places.
7259 With prefix arg, specifies the number of places to rotate each letter forward.
7260 Caesar rotates Japanese letters by 47 places in any case."
7262 (gnus-summary-select-article)
7263 (let ((mail-header-separator "")) ; !!! Is this necessary?
7264 (gnus-overload-functions)
7265 (gnus-eval-in-buffer-window
7269 ;; We don't want to jump to the beginning of the message.
7270 ;; `save-excursion' does not do its job.
7271 (move-to-window-line 0)
7272 (let ((last (point)))
7273 (news-caesar-buffer-body rotnum)
7277 (defun gnus-summary-stop-page-breaking ()
7278 "Stop page breaking in the current article."
7280 (gnus-summary-select-article)
7281 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
7283 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
7285 (defun gnus-summary-move-article (n &optional to-newsgroup select-method)
7286 "Move the current article to a different newsgroup.
7287 If N is a positive number, move the N next articles.
7288 If N is a negative number, move the N previous articles.
7289 If N is nil and any articles have been marked with the process mark,
7290 move those articles instead.
7291 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7292 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
7293 re-spool using this method.
7294 For this function to work, both the current newsgroup and the
7295 newsgroup that you want to move to have to support the `request-move'
7296 and `request-accept' functions. (Ie. mail newsgroups at present.)"
7298 (gnus-set-global-variables)
7299 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
7300 (error "The current newsgroup does not support article moving"))
7301 (let ((articles (gnus-summary-work-articles n))
7303 (if (and (not to-newsgroup) (not select-method))
7306 (format "Where do you want to move %s? %s"
7307 (if (> (length articles) 1)
7308 (format "these %d articles" (length articles))
7310 (if gnus-current-move-group
7311 (format "(%s default) " gnus-current-move-group)
7313 gnus-active-hashtb nil nil
7314 (gnus-group-real-prefix gnus-newsgroup-name))))
7315 (if (string= to-newsgroup "")
7316 (setq to-newsgroup (or gnus-current-move-group "")))
7317 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
7318 (error "No such group: %s" to-newsgroup))
7319 (setq gnus-current-move-group to-newsgroup)
7320 (or (gnus-check-backend-function 'request-accept-article
7321 (or select-method to-newsgroup))
7322 (error "%s does not support article moving" to-newsgroup))
7323 (message "Moving to %s: %s..." (or select-method to-newsgroup) articles)
7326 (gnus-request-move-article
7327 (car articles) ; Article to move
7328 gnus-newsgroup-name ; From newsgrouo
7329 (nth 1 (gnus-find-method-for-group
7330 gnus-newsgroup-name)) ; Server
7331 (list 'gnus-request-accept-article
7333 (quote select-method)
7335 (not (cdr articles))) ; Accept form
7336 (not (cdr articles)))) ; Only save nov last time
7337 (let* ((buffer-read-only nil)
7340 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7342 (gnus-group-prefixed-name
7344 (if select-method (list select-method "")
7345 (gnus-find-method-for-group to-newsgroup)))
7346 gnus-newsrc-hashtb)))
7347 (info (nth 2 entry))
7348 (article (car articles))
7349 (marked (nth 3 info)))
7350 (gnus-summary-goto-subject article)
7351 (delete-region (progn (beginning-of-line) (point))
7352 (progn (forward-line 1) (point)))
7353 (if (not (memq article gnus-newsgroup-unreads))
7354 (setcar (cdr (cdr info))
7355 (gnus-add-to-range (nth 2 info)
7356 (list (cdr art-group)))))
7357 ;; Copy any marks over to the new group.
7358 (let ((marks '((tick . gnus-newsgroup-marked)
7359 (dormant . gnus-newsgroup-dormant)
7360 (expire . gnus-newsgroup-expirable)
7361 (bookmark . gnus-newsgroup-bookmarks)
7362 ; (score . gnus-newsgroup-scored)
7363 (reply . gnus-newsgroup-replied)))
7364 (to-article (cdr art-group)))
7366 (if (memq article (symbol-value (cdr (car marks))))
7367 (gnus-add-marked-articles
7368 (car info) (car (car marks)) (list to-article) info))
7369 (setq marks (cdr marks))))
7370 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7371 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7372 (setq gnus-newsgroup-dormant
7373 (delq article gnus-newsgroup-dormant)))
7374 (message "Couldn't move article %s" (car articles)))
7375 (gnus-summary-remove-process-mark (car articles))
7376 (setq articles (cdr articles)))))
7378 (defun gnus-summary-respool-article (n &optional respool-method)
7379 "Respool the current article.
7380 The article will be squeezed through the mail spooling process again,
7381 which means that it will be put in some mail newsgroup or other
7382 depending on `nnmail-split-methods'.
7383 If N is a positive number, respool the N next articles.
7384 If N is a negative number, respool the N previous articles.
7385 If N is nil and any articles have been marked with the process mark,
7386 respool those articles instead.
7387 For this function to work, both the current newsgroup and the
7388 newsgroup that you want to move to have to support the `request-move'
7389 and `request-accept' functions. (Ie. mail newsgroups at present.)"
7391 (gnus-set-global-variables)
7393 (setq respool-method
7395 "What method do you want to use when respooling? "
7396 (gnus-methods-using 'respool) nil t)))
7397 (gnus-summary-move-article n nil (intern respool-method)))
7399 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
7400 (defun gnus-summary-copy-article (n &optional to-newsgroup select-method)
7401 "Move the current article to a different newsgroup.
7402 If N is a positive number, move the N next articles.
7403 If N is a negative number, move the N previous articles.
7404 If N is nil and any articles have been marked with the process mark,
7405 move those articles instead.
7406 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7407 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
7408 re-spool using this method.
7409 For this function to work, the newsgroup that you want to move to have
7410 to support the `request-move' and `request-accept'
7411 functions. (Ie. mail newsgroups at present.)"
7413 (gnus-set-global-variables)
7414 (let ((articles (gnus-summary-work-articles n))
7415 (copy-buf (get-buffer-create "*copy work*"))
7417 (buffer-disable-undo copy-buf)
7418 (if (and (not to-newsgroup) (not select-method))
7421 (format "Where do you want to copy %s? %s"
7422 (if (> (length articles) 1)
7423 (format "these %d articles" (length articles))
7425 (if gnus-current-move-group
7426 (format "(%s default) " gnus-current-move-group)
7428 gnus-active-hashtb nil nil
7429 (gnus-group-real-prefix gnus-newsgroup-name))))
7430 (if (string= to-newsgroup "")
7431 (setq to-newsgroup (or gnus-current-move-group "")))
7432 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
7433 (error "No such group: %s" to-newsgroup))
7434 (setq gnus-current-move-group to-newsgroup)
7435 (or (gnus-check-backend-function 'request-accept-article
7436 (or select-method to-newsgroup))
7437 (error "%s does not support article copying" to-newsgroup))
7438 (message "Moving to %s: %s..." (or select-method to-newsgroup) articles)
7442 (set-buffer copy-buf)
7443 (gnus-request-article-this-buffer
7444 (car articles) gnus-newsgroup-name)
7445 (gnus-request-accept-article
7446 (if select-method (quote select-method) to-newsgroup)
7447 (not (cdr articles)))))
7450 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7452 (gnus-group-prefixed-name
7454 (if select-method (list select-method "")
7455 (gnus-find-method-for-group to-newsgroup)))
7456 gnus-newsrc-hashtb)))
7457 (info (nth 2 entry))
7458 (article (car articles))
7459 (marked (nth 3 info)))
7460 (if (not (memq article gnus-newsgroup-unreads))
7461 (setcar (cdr (cdr info))
7462 (gnus-add-to-range (nth 2 info)
7463 (list (cdr art-group)))))
7464 ;; Copy any marks over to the new group.
7465 (let ((marks '((tick . gnus-newsgroup-marked)
7466 (dormant . gnus-newsgroup-dormant)
7467 (expire . gnus-newsgroup-expirable)
7468 (bookmark . gnus-newsgroup-bookmarks)
7469 ; (score . gnus-newsgroup-scored)
7470 (reply . gnus-newsgroup-replied)))
7471 (to-article (cdr art-group)))
7473 (if (memq article (symbol-value (cdr (car marks))))
7474 (gnus-add-marked-articles
7475 (car info) (car (car marks)) (list to-article) info))
7476 (setq marks (cdr marks)))))
7477 (message "Couldn't copy article %s" (car articles)))
7478 (gnus-summary-remove-process-mark (car articles))
7479 (setq articles (cdr articles)))
7480 (kill-buffer copy-buf)))
7482 (defun gnus-summary-expire-articles ()
7483 "Expire all articles that are marked as expirable in the current group."
7485 (if (and gnus-newsgroup-expirable
7486 (gnus-check-backend-function
7487 'request-expire-articles gnus-newsgroup-name))
7488 (let ((expirable gnus-newsgroup-expirable))
7489 ;; The list of articles that weren't expired is returned.
7490 (setq gnus-newsgroup-expirable
7491 (gnus-request-expire-articles gnus-newsgroup-expirable
7492 gnus-newsgroup-name))
7493 ;; We go through the old list of expirable, and mark all
7494 ;; really expired articles as non-existant.
7496 (or (memq (car expirable) gnus-newsgroup-expirable)
7497 (gnus-summary-mark-as-read (car expirable) "%"))
7498 (setq expirable (cdr expirable))))))
7500 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7501 (defun gnus-summary-delete-article (n)
7502 "Delete the N next (mail) articles.
7503 This command actually deletes articles. This is not a marking
7504 command. The article will disappear forever from you life, never to
7506 If N is negative, delete backwards.
7507 If N is nil and articles have been marked with the process mark,
7508 delete these instead."
7510 (or (gnus-check-backend-function 'request-expire-articles
7511 gnus-newsgroup-name)
7512 (error "The current newsgroup does not support article deletion."))
7513 ;; Compute the list of articles to delete.
7514 (let ((articles (gnus-summary-work-articles n)))
7515 (if (and gnus-novice-user
7517 (format "Do you really want to delete %s forever? "
7518 (if (> (length articles) 1) "these articles"
7521 ;; Delete the articles.
7522 (setq gnus-newsgroup-expirable
7523 (gnus-request-expire-articles
7524 articles gnus-newsgroup-name 'force))
7526 (gnus-summary-remove-process-mark (car articles))
7527 ;; The backend might not have been able to delete the article
7529 (or (memq (car articles) gnus-newsgroup-expirable)
7530 (gnus-summary-mark-as-read (car articles) gnus-canceled-mark))
7531 (setq articles (cdr articles))))))
7533 (defun gnus-summary-edit-article ()
7534 "Enter into a buffer and edit the current article.
7535 This will have permanent effect only in mail groups."
7537 (or (gnus-check-backend-function
7538 'request-replace-article gnus-newsgroup-name)
7539 (error "The current newsgroup does not support article editing."))
7540 (gnus-summary-select-article t)
7542 (message "C-c C-c to end edits")
7543 (setq buffer-read-only nil)
7545 (use-local-map (copy-keymap (current-local-map)))
7546 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
7548 (search-forward "\n\n" nil t))
7550 (defun gnus-summary-edit-article-done ()
7551 "Make edits to the current article permanent."
7553 (if (not (gnus-request-replace-article
7554 (cdr gnus-article-current) (car gnus-article-current)
7556 (error "Couldn't replace article.")
7558 (use-local-map gnus-article-mode-map)
7559 (setq buffer-read-only t)
7560 (pop-to-buffer gnus-summary-buffer)))
7562 ;; Summary score commands.
7564 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
7566 (defun gnus-summary-raise-score (n)
7567 "Raise the score of the current article by N."
7569 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
7571 (defun gnus-summary-lower-score (n)
7572 "Lower the score of the current article by N."
7574 (gnus-summary-raise-score (- n)))
7576 (defun gnus-summary-set-score (n)
7577 "Set the score of the current article to N."
7579 ;; Skip dummy header line.
7581 (if (eq (gnus-summary-article-mark) ?Z)
7583 (let ((buffer-read-only nil))
7585 (gnus-summary-update-mark
7586 (if (= n (or gnus-summary-default-score 0)) ?
7587 (if (< n (or gnus-summary-default-score 0))
7588 gnus-score-below-mark gnus-score-over-mark)) 'score))
7589 (let* ((article (gnus-summary-article-number))
7590 (score (assq article gnus-newsgroup-scored)))
7591 (if score (setcdr score n)
7592 (setq gnus-newsgroup-scored
7593 (cons (cons article n) gnus-newsgroup-scored))))
7594 (gnus-summary-update-line)))
7596 ;; Summary marking commands.
7598 (defun gnus-summary-raise-same-subject-and-select (score)
7599 "Raise articles which has the same subject with SCORE and select the next."
7601 (let ((subject (gnus-summary-subject-string)))
7602 (gnus-summary-raise-score score)
7603 (while (gnus-summary-search-subject nil nil subject)
7604 (gnus-summary-raise-score score))
7605 (gnus-summary-next-article t)))
7607 (defun gnus-summary-raise-same-subject (score)
7608 "Raise articles which has the same subject with SCORE."
7610 (let ((subject (gnus-summary-subject-string)))
7611 (gnus-summary-raise-score score)
7612 (while (gnus-summary-search-subject nil nil subject)
7613 (gnus-summary-raise-score score))
7614 (gnus-summary-next-subject 1 t)))
7616 (defun gnus-summary-raise-thread (score)
7617 "Raise articles under current thread with SCORE."
7621 (let ((level (gnus-summary-thread-level)))
7622 (gnus-summary-raise-score score)
7623 (while (and (zerop (gnus-summary-next-subject 1))
7624 (> (gnus-summary-thread-level) level))
7625 (gnus-summary-raise-score score))
7627 (or (zerop (gnus-summary-next-subject 1 t))
7629 (gnus-summary-position-cursor)
7630 (gnus-set-mode-line 'summary))
7632 (defun gnus-summary-lower-same-subject-and-select (score)
7633 "Raise articles which has the same subject with SCORE and select the next."
7635 (gnus-summary-raise-same-subject-and-select (- score)))
7637 (defun gnus-summary-lower-same-subject (score)
7638 "Raise articles which has the same subject with SCORE."
7640 (gnus-summary-raise-same-subject (- score)))
7642 (defun gnus-summary-lower-thread (score)
7643 "Raise articles under current thread with SCORE."
7645 (gnus-summary-raise-thread (- score)))
7647 (defun gnus-summary-kill-same-subject-and-select (unmark)
7648 "Mark articles which has the same subject as read, and then select the next.
7649 If UNMARK is positive, remove any kind of mark.
7650 If UNMARK is negative, tick articles."
7653 (setq unmark (prefix-numeric-value unmark)))
7655 (gnus-summary-mark-same-subject
7656 (gnus-summary-subject-string) unmark)))
7657 ;; Select next unread article. If auto-select-same mode, should
7658 ;; select the first unread article.
7659 (gnus-summary-next-article t (and gnus-auto-select-same
7660 (gnus-summary-subject-string)))
7661 (message "%d articles are marked as %s"
7662 count (if unmark "unread" "read"))))
7664 (defun gnus-summary-kill-same-subject (unmark)
7665 "Mark articles which has the same subject as read.
7666 If UNMARK is positive, remove any kind of mark.
7667 If UNMARK is negative, tick articles."
7670 (setq unmark (prefix-numeric-value unmark)))
7672 (gnus-summary-mark-same-subject
7673 (gnus-summary-subject-string) unmark)))
7674 ;; If marked as read, go to next unread subject.
7676 ;; Go to next unread subject.
7677 (gnus-summary-next-subject 1 t))
7678 (message "%d articles are marked as %s"
7679 count (if unmark "unread" "read"))))
7681 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7682 "Mark articles with same SUBJECT as read, and return marked number.
7683 If optional argument UNMARK is positive, remove any kinds of marks.
7684 If optional argument UNMARK is negative, mark articles as unread instead."
7687 (cond ((null unmark)
7688 (gnus-summary-mark-as-read nil gnus-killed-mark))
7690 (gnus-summary-tick-article nil t))
7692 (gnus-summary-tick-article)))
7694 (gnus-summary-search-forward nil subject))
7695 (cond ((null unmark)
7696 (gnus-summary-mark-as-read nil gnus-killed-mark))
7698 (gnus-summary-tick-article nil t))
7700 (gnus-summary-tick-article)))
7701 (setq count (1+ count))))
7702 ;; Hide killed thread subtrees. Does not work properly always.
7703 ;;(and (null unmark)
7704 ;; gnus-thread-hide-killed
7705 ;; (gnus-summary-hide-thread))
7706 ;; Return number of articles marked as read.
7709 (defun gnus-summary-mark-as-processable (n &optional unmark)
7710 "Set the process mark on the next N articles.
7711 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7712 the process mark instead. The difference between N and the actual
7713 number of articles marked is returned."
7715 (let ((backward (< n 0))
7720 (gnus-summary-remove-process-mark (gnus-summary-article-number))
7721 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7722 (zerop (gnus-summary-next-subject (if backward -1 1))))
7724 (if (/= 0 n) (message "No more articles"))
7727 (defun gnus-summary-unmark-as-processable (n)
7728 "Remove the process mark from the next N articles.
7729 If N is negative, mark backward instead. The difference between N and
7730 the actual number of articles marked is returned."
7732 (gnus-summary-mark-as-processable n t))
7734 (defun gnus-summary-unmark-all-processable ()
7735 "Remove the process mark from all articles."
7738 (while gnus-newsgroup-processable
7739 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7740 (gnus-summary-position-cursor))
7742 (defun gnus-summary-mark-as-expirable (n)
7743 "Mark N articles forward as expirable.
7744 If N is negative, mark backward instead. The difference between N and
7745 the actual number of articles marked is returned."
7747 (gnus-summary-mark-forward n gnus-expirable-mark))
7749 (defun gnus-summary-mark-article-as-replied (article)
7750 "Mark ARTICLE replied and update the summary line."
7751 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
7752 (let ((buffer-read-only nil))
7753 (if (gnus-summary-goto-subject article)
7755 (gnus-summary-update-mark gnus-replied-mark 'replied)
7758 (defun gnus-summary-set-bookmark (article)
7759 "Set a bookmark in current article."
7760 (interactive (list (gnus-summary-article-number)))
7761 (if (or (not (get-buffer gnus-article-buffer))
7762 (not gnus-current-article)
7763 (not gnus-article-current)
7764 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7765 (error "No current article selected"))
7766 ;; Remove old bookmark, if one exists.
7767 (let ((old (assq article gnus-newsgroup-bookmarks)))
7768 (if old (setq gnus-newsgroup-bookmarks
7769 (delq old gnus-newsgroup-bookmarks))))
7770 ;; Set the new bookmark, which is on the form
7771 ;; (article-number . line-number-in-body).
7772 (setq gnus-newsgroup-bookmarks
7776 (set-buffer gnus-article-buffer)
7781 (search-forward "\n\n" nil t)
7784 gnus-newsgroup-bookmarks))
7785 (message "A bookmark has been added to the current article."))
7787 (defun gnus-summary-remove-bookmark (article)
7788 "Remove the bookmark from the current article."
7789 (interactive (list (gnus-summary-article-number)))
7790 ;; Remove old bookmark, if one exists.
7791 (let ((old (assq article gnus-newsgroup-bookmarks)))
7794 (setq gnus-newsgroup-bookmarks
7795 (delq old gnus-newsgroup-bookmarks))
7796 (message "Removed bookmark."))
7797 (message "No bookmark in current article."))))
7799 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7800 (defun gnus-summary-mark-as-dormant (n)
7801 "Mark N articles forward as dormant.
7802 If N is negative, mark backward instead. The difference between N and
7803 the actual number of articles marked is returned."
7805 (gnus-summary-mark-forward n gnus-dormant-mark))
7807 (defun gnus-summary-set-process-mark (article)
7808 "Set the process mark on ARTICLE and update the summary line."
7809 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
7810 (let ((buffer-read-only nil))
7811 (if (gnus-summary-goto-subject article)
7813 (and (eq (gnus-summary-article-mark) ?Z)
7815 (gnus-summary-update-mark gnus-process-mark 'replied)
7818 (defun gnus-summary-remove-process-mark (article)
7819 "Remove the process mark from ARTICLE and update the summary line."
7820 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7821 (let ((buffer-read-only nil))
7822 (if (gnus-summary-goto-subject article)
7824 (and (eq (gnus-summary-article-mark) ?Z)
7826 (gnus-summary-update-mark ? 'replied)
7827 (if (memq article gnus-newsgroup-replied)
7828 (gnus-summary-update-mark gnus-replied-mark 'replied))
7831 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7832 "Mark N articles as read forwards.
7833 If N is negative, mark backwards instead.
7834 Mark with MARK. If MARK is ? , ?! or ??, articles will be
7836 The difference between N and the actual number of articles marked is
7839 (gnus-set-global-variables)
7840 (let ((backward (< n 0))
7842 (mark (or mark gnus-dread-mark)))
7844 (gnus-summary-mark-article nil mark no-expire)
7845 (zerop (gnus-summary-next-subject
7846 (if backward -1 1) gnus-summary-goto-unread)))
7848 (if (/= 0 n) (message "No more %sarticles" (if mark "" "unread ")))
7849 (gnus-set-mode-line 'summary)
7852 (defun gnus-summary-mark-article (&optional article mark no-expire)
7853 "Mark ARTICLE with MARK.
7854 MARK can be any character.
7855 Five MARK strings are reserved: ? (unread),
7856 ?! (ticked), ?? (dormant), ?D (read), ?E (expirable).
7857 If MARK is nil, then the default character ?D is used.
7858 If ARTICLE is nil, then the article on the current line will be
7860 ;; If no mark is given, then we check auto-expiring.
7861 (and (not no-expire)
7862 gnus-newsgroup-auto-expire
7864 (and (numberp mark) (or (= mark gnus-killed-mark)
7865 (= mark gnus-dread-mark)
7866 (= mark gnus-catchup-mark)
7867 (= mark gnus-low-score-mark)
7868 (= mark gnus-read-mark))))
7869 (setq mark gnus-expirable-mark))
7870 (let* ((buffer-read-only nil)
7871 (mark (or (and (stringp mark) (aref mark 0)) mark gnus-dread-mark))
7872 (article (or article (gnus-summary-article-number))))
7873 (if (or (= mark gnus-unread-mark)
7874 (= mark gnus-ticked-mark)
7875 (= mark gnus-dormant-mark))
7876 (gnus-mark-article-as-unread article mark)
7877 (gnus-mark-article-as-read article mark))
7878 (if (gnus-summary-goto-subject article)
7880 (gnus-summary-show-thread)
7882 (and (eq (gnus-summary-article-mark) ?Z)
7885 (gnus-summary-update-mark mark 'unread)
7888 (defun gnus-summary-update-mark (mark type)
7890 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7894 (forward-char forward)
7895 (setq plist (text-properties-at (point)))
7897 (and (memq 'gnus-mark plist) (setcar (cdr (memq 'gnus-mark plist)) mark))
7899 (and plist (add-text-properties (1- (point)) (point) plist))
7900 (gnus-summary-update-line (eq mark gnus-unread-mark)))))
7902 (defun gnus-mark-article-as-read (article &optional mark)
7903 "Enter ARTICLE in the pertinent lists and remove it from others."
7904 ;; Make the article expirable.
7905 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-dread-mark)))
7906 (if (= mark gnus-expirable-mark)
7907 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
7908 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7909 ;; Remove from unread and marked lists.
7910 (setq gnus-newsgroup-unreads
7911 (delq article gnus-newsgroup-unreads))
7912 (setq gnus-newsgroup-marked
7913 (delq article gnus-newsgroup-marked))
7914 (setq gnus-newsgroup-dormant
7915 (delq article gnus-newsgroup-dormant))))
7917 (defun gnus-mark-article-as-unread (article &optional mark)
7918 "Enter ARTICLE in the pertinent lists and remove it from others."
7919 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-ticked-mark)))
7920 ;; Add to unread list.
7921 (or (memq article gnus-newsgroup-unreads)
7922 (setq gnus-newsgroup-unreads
7923 (cons article gnus-newsgroup-unreads)))
7924 ;; If CLEAR-MARK is non-nil, the article must be removed from marked
7925 ;; list. Otherwise, it must be added to the list.
7926 (setq gnus-newsgroup-marked
7927 (delq article gnus-newsgroup-marked))
7928 (setq gnus-newsgroup-dormant
7929 (delq article gnus-newsgroup-dormant))
7930 (setq gnus-newsgroup-expirable
7931 (delq article gnus-newsgroup-expirable))
7932 (if (= mark gnus-ticked-mark)
7933 (setq gnus-newsgroup-marked
7934 (cons article gnus-newsgroup-marked)))
7935 (if (= mark gnus-dormant-mark)
7936 (setq gnus-newsgroup-dormant
7937 (cons article gnus-newsgroup-dormant)))))
7939 (defalias 'gnus-summary-mark-as-unread-forward
7940 'gnus-summary-tick-article-forward)
7941 (make-obsolete 'gnus-summary-mark-as-unread-forward
7942 'gnus-summary-tick-article-forward)
7943 (defun gnus-summary-tick-article-forward (n)
7944 "Tick N articles forwards.
7945 If N is negative, tick backwards instead.
7946 The difference between N and the number of articles ticked is returned."
7948 (gnus-summary-mark-forward n gnus-ticked-mark))
7950 (defalias 'gnus-summary-mark-as-unread-backward
7951 'gnus-summary-tick-article-backward)
7952 (make-obsolete 'gnus-summary-mark-as-unread-backward
7953 'gnus-summary-tick-article-backward)
7954 (defun gnus-summary-tick-article-backward (n)
7955 "Tick N articles backwards.
7956 The difference between N and the number of articles ticked is returned."
7958 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7960 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7961 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7962 (defun gnus-summary-tick-article (&optional article clear-mark)
7963 "Mark current article as unread.
7964 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7965 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7966 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7969 (defun gnus-summary-mark-as-read-forward (n)
7970 "Mark N articles as read forwards.
7971 If N is negative, mark backwards instead.
7972 The difference between N and the actual number of articles marked is
7975 (gnus-summary-mark-forward n gnus-dread-mark t))
7977 (defun gnus-summary-mark-as-read-backward (n)
7978 "Mark the N articles as read backwards.
7979 The difference between N and the actual number of articles marked is
7982 (gnus-summary-mark-forward (- n) gnus-dread-mark t))
7984 (defun gnus-summary-mark-as-read (&optional article mark)
7985 "Mark current article as read.
7986 ARTICLE specifies the article to be marked as read.
7987 MARK specifies a string to be inserted at the beginning of the line."
7988 (gnus-summary-mark-article article mark))
7990 (defun gnus-summary-clear-mark-forward (n)
7991 "Clear marks from N articles forward.
7992 If N is negative, clear backward instead.
7993 The difference between N and the number of marks cleared is returned."
7995 (gnus-summary-mark-forward n gnus-unread-mark))
7997 (defun gnus-summary-clear-mark-backward (n)
7998 "Clear marks from N articles backward.
7999 The difference between N and the number of marks cleared is returned."
8001 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8003 (defun gnus-summary-mark-unread-as-read ()
8004 "Intended to be used by `gnus-summary-mark-article-hook'."
8005 (or (memq gnus-current-article gnus-newsgroup-marked)
8006 (memq gnus-current-article gnus-newsgroup-dormant)
8007 (memq gnus-current-article gnus-newsgroup-expirable)
8008 (gnus-summary-mark-as-read gnus-current-article gnus-read-mark)))
8010 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
8011 (defalias 'gnus-summary-delete-marked-as-read
8012 'gnus-summary-remove-lines-marked-as-read)
8013 (make-obsolete 'gnus-summary-delete-marked-as-read
8014 'gnus-summary-remove-lines-marked-as-read)
8015 (defun gnus-summary-remove-lines-marked-as-read ()
8016 "Remove lines that are marked as read."
8018 (gnus-summary-remove-lines-marked-with
8020 (lambda (char) (char-to-string (symbol-value char)))
8021 '(gnus-dread-mark gnus-read-mark
8022 gnus-killed-mark gnus-kill-file-mark
8023 gnus-low-score-mark gnus-expirable-mark)
8026 (defalias 'gnus-summary-delete-marked-with
8027 'gnus-summary-remove-lines-marked-with)
8028 (make-obsolete 'gnus-summary-delete-marked-with
8029 'gnus-summary-remove-lines-marked-with)
8030 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
8031 (defun gnus-summary-remove-lines-marked-with (marks)
8032 "Remove lines that are marked with MARKS (e.g. \"DK\")."
8033 (interactive "sMarks: ")
8034 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
8036 (set-buffer gnus-summary-buffer)
8037 (let ((buffer-read-only nil)
8038 (marks (concat "^[" marks "]")))
8039 (goto-char (point-min))
8040 (while (search-forward-regexp marks (point-max) t)
8041 (delete-region (progn (beginning-of-line) (point))
8042 (progn (forward-line 1) (point)))))
8043 (or (zerop (buffer-size))
8045 (gnus-summary-prev-subject 1)
8046 (gnus-summary-position-cursor)))))
8048 (defun gnus-summary-expunge-below (score)
8049 "Remove articles with score less than SCORE."
8051 (setq score (if score
8052 (prefix-numeric-value score)
8053 (or gnus-summary-default-score 0)))
8055 (set-buffer gnus-summary-buffer)
8056 (goto-char (point-min))
8057 (let ((buffer-read-only nil)
8060 (if (< (gnus-summary-article-score) score)
8064 (delete-region beg (point)))
8067 (or (zerop (buffer-size))
8069 (gnus-summary-prev-subject 1)
8070 (gnus-summary-position-cursor))))))
8072 (defun gnus-summary-mark-below (score mark)
8073 "Mark articles with score less than SCORE with MARK."
8074 (interactive "P\ncMark: ")
8075 (setq score (if score
8076 (prefix-numeric-value score)
8077 (or gnus-summary-default-score 0)))
8079 (set-buffer gnus-summary-buffer)
8080 (goto-char (point-min))
8082 (and (< (gnus-summary-article-score) score)
8083 (gnus-summary-mark-article nil mark))
8086 (defun gnus-summary-kill-below (score)
8087 "Mark articles with score below SCORE as read."
8089 (gnus-summary-mark-below score gnus-killed-mark))
8091 (defun gnus-summary-clear-above (score)
8092 "Clear all marks from articles with score above SCORE."
8094 (gnus-summary-mark-above score gnus-unread-mark))
8096 (defun gnus-summary-tick-above (score)
8097 "Tick all articles with score above SCORE."
8099 (gnus-summary-mark-above score gnus-ticked-mark))
8101 (defun gnus-summary-mark-above (score mark)
8102 "Mark articles with score over SCORE with MARK."
8103 (interactive "P\ncMark: ")
8104 (setq score (if score
8105 (prefix-numeric-value score)
8106 (or gnus-summary-default-score 0)))
8108 (set-buffer gnus-summary-buffer)
8109 (goto-char (point-min))
8111 (if (> (gnus-summary-article-score) score)
8113 (gnus-summary-mark-article nil mark)
8115 (forward-line 1)))))
8117 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8118 (defun gnus-summary-show-all-expunged ()
8119 "Display all the hidden articles that were expunged for low scores."
8121 (let ((buffer-read-only nil))
8122 (let ((scored gnus-newsgroup-scored)
8125 (or (gnus-summary-goto-subject (car (car scored)))
8126 (and (setq h (gnus-get-header-by-number (car (car scored))))
8127 (< (cdr (car scored)) gnus-summary-expunge-below)
8128 (setq headers (cons h headers))))
8129 (setq scored (cdr scored)))
8130 (or headers (error "No expunged articles hidden."))
8131 (goto-char (point-min))
8133 (gnus-summary-prepare-threads (nreverse headers) 0)))
8134 (goto-char (point-min))
8135 (gnus-summary-position-cursor)))
8137 (defun gnus-summary-show-all-dormant ()
8138 "Display all the hidden articles that are marked as dormant."
8140 (let ((buffer-read-only nil))
8141 (goto-char (point-min))
8142 (let ((dormant gnus-newsgroup-dormant)
8145 (or (gnus-summary-goto-subject (car dormant))
8146 (and (setq h (gnus-get-header-by-number (car dormant)))
8147 (setq headers (cons h headers))))
8148 (setq dormant (cdr dormant)))
8149 (or headers (error "No dormant articles hidden."))
8150 (save-excursion (gnus-summary-prepare-threads (nreverse headers) 0)))
8151 (goto-char (point-min))
8152 (gnus-summary-position-cursor)))
8154 (defun gnus-summary-hide-all-dormant ()
8155 "Hide all dormant articles."
8157 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
8158 (gnus-summary-position-cursor))
8160 (defun gnus-summary-catchup (all &optional quietly to-here)
8161 "Mark all articles not marked as unread in this newsgroup as read.
8162 If prefix argument ALL is non-nil, all articles are marked as read.
8163 If QUIETLY is non-nil, no questions will be asked.
8164 If TO-HERE is non-nil, it should be a point in the buffer. All
8165 articles before this point will be marked as read.
8166 The number of articles marked as read is returned."
8170 (not gnus-interactive-catchup) ;Without confirmation?
8174 "Mark absolutely all articles as read? "
8175 "Mark all unread articles as read? ")))
8176 (let ((unreads (length gnus-newsgroup-unreads)))
8177 (if (gnus-summary-first-subject (not all))
8178 (while (and (gnus-summary-mark-as-read nil gnus-catchup-mark)
8179 (if to-here (< (point) to-here) t)
8180 (gnus-summary-search-subject nil (not all)))))
8181 (- unreads (length gnus-newsgroup-unreads))
8183 (setq gnus-newsgroup-unreads gnus-newsgroup-marked))))
8184 (gnus-summary-position-cursor)))
8186 (defun gnus-summary-catchup-to-here (&optional all)
8187 "Mark all unticked articles before the current one as read.
8188 If ALL is non-nil, also mark ticked and dormant articles as read."
8191 (gnus-summary-catchup all t (point))
8192 (gnus-summary-position-cursor))
8194 (defun gnus-summary-catchup-all (&optional quietly)
8195 "Mark all articles in this newsgroup as read."
8197 (gnus-summary-catchup t quietly))
8199 (defun gnus-summary-catchup-and-exit (all &optional quietly)
8200 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8201 If prefix argument ALL is non-nil, all articles are marked as read."
8203 (gnus-summary-catchup all quietly)
8204 ;; Select next newsgroup or exit.
8205 (if (eq gnus-auto-select-next 'quietly)
8206 (gnus-summary-next-group nil)
8207 (gnus-summary-exit)))
8209 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8210 "Mark all articles in this newsgroup as read, and then exit."
8212 (gnus-summary-catchup-and-exit t quietly))
8214 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8215 (defun gnus-summary-catchup-and-goto-next-group (all)
8216 "Mark all articles in this group as read and select the next group.
8217 If given a prefix, mark all articles, unread as well as ticked, as
8220 (gnus-summary-catchup all)
8221 (gnus-summary-next-group))
8223 ;; Thread-based commands.
8225 (defun gnus-summary-toggle-threads (arg)
8226 "Toggle showing conversation threads.
8227 If ARG is positive number, turn showing conversation threads on."
8229 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8230 (setq gnus-show-threads
8231 (if (null arg) (not gnus-show-threads)
8232 (> (prefix-numeric-value arg) 0)))
8233 (gnus-summary-prepare)
8234 (gnus-summary-goto-subject current)
8235 (gnus-summary-position-cursor)))
8237 (defun gnus-summary-show-all-threads ()
8241 (let ((buffer-read-only nil))
8242 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8243 (gnus-summary-position-cursor))
8245 (defun gnus-summary-show-thread ()
8246 "Show thread subtrees.
8247 Returns nil if no thread was there to be shown."
8251 (let ((buffer-read-only nil)
8252 (beg (progn (beginning-of-line) (point)))
8253 (end (save-excursion (end-of-line) (point))))
8255 ;; Any hidden lines here?
8256 (search-forward "\r" end t)
8257 (subst-char-in-region beg end ?\^M ?\n t))))
8258 (gnus-summary-position-cursor)))
8260 (defun gnus-summary-hide-all-threads ()
8261 "Hide all thread subtrees."
8264 (goto-char (point-min))
8265 (gnus-summary-hide-thread)
8266 (while (and (not (eobp)) (zerop (forward-line 1)))
8267 (gnus-summary-hide-thread)))
8268 (gnus-summary-position-cursor))
8270 (defun gnus-summary-hide-thread ()
8271 "Hide thread subtrees.
8272 Returns nil if no threads were there to be hidden."
8274 (let ((buffer-read-only nil)
8276 (level (gnus-summary-thread-level))
8278 ;; Go forward until either the buffer ends or the subthread
8282 (while (and (zerop (forward-line 1))
8283 (> (gnus-summary-thread-level) level))
8288 (search-backward "\n" start t))
8289 (subst-char-in-region start end ?\n ?\^M t)
8290 (forward-line -1)))))
8292 (defun gnus-summary-go-to-next-thread (&optional previous)
8293 "Go to the same level (or less) next thread.
8294 If PREVIOUS is non-nil, go to previous thread instead.
8295 Return the article number moved to, or nil if moving was impossible."
8296 (let ((level (gnus-summary-thread-level))
8297 (article (gnus-summary-article-number)))
8299 (while (and (zerop (gnus-summary-prev-subject 1))
8300 (> (gnus-summary-thread-level) level)))
8301 (while (and (zerop (gnus-summary-next-subject 1))
8302 (> (gnus-summary-thread-level) level))))
8303 (let ((oart (gnus-summary-article-number)))
8304 (and (/= oart article) oart))))
8306 (defun gnus-summary-next-thread (n)
8307 "Go to the same level next N'th thread.
8308 If N is negative, search backward instead.
8309 Returns the difference between N and the number of skips actually
8312 (let ((backward (< n 0))
8315 (gnus-summary-go-to-next-thread backward))
8317 (gnus-summary-position-cursor)
8318 (if (/= 0 n) (message "No more threads"))
8321 (defun gnus-summary-prev-thread (n)
8322 "Go to the same level previous N'th thread.
8323 Returns the difference between N and the number of skips actually
8326 (gnus-summary-next-thread (- n)))
8328 (defun gnus-summary-go-down-thread (&optional same)
8329 "Go down one level in the current thread.
8330 If SAME is non-nil, also move to articles of the same level."
8331 (let ((level (gnus-summary-thread-level))
8333 (if (and (zerop (forward-line 1))
8334 (> (gnus-summary-thread-level) level))
8339 (defun gnus-summary-go-up-thread ()
8340 "Go up one level in the current thread."
8341 (let ((level (gnus-summary-thread-level))
8343 (while (and (zerop (forward-line -1))
8344 (>= (gnus-summary-thread-level) level)))
8345 (if (>= (gnus-summary-thread-level) level)
8351 (defun gnus-summary-down-thread (n)
8352 "Go down thread N steps.
8353 If N is negative, go up instead.
8354 Returns the difference between N and how many steps down that were
8360 (if up (gnus-summary-go-up-thread)
8361 (gnus-summary-go-down-thread)))
8363 (gnus-summary-position-cursor)
8364 (if (/= 0 n) (message "Can't go further"))
8367 (defun gnus-summary-up-thread (n)
8368 "Go up thread N steps.
8369 If N is negative, go up instead.
8370 Returns the difference between N and how many steps down that were
8373 (gnus-summary-down-thread (- n)))
8375 (defun gnus-summary-kill-thread (unmark)
8376 "Mark articles under current thread as read.
8377 If the prefix argument is positive, remove any kinds of marks.
8378 If the prefix argument is negative, tick articles instead."
8381 (setq unmark (prefix-numeric-value unmark)))
8383 (level (gnus-summary-thread-level)))
8386 ;; Mark the article...
8387 (cond ((null unmark) (gnus-summary-mark-as-read nil gnus-killed-mark))
8388 ((> unmark 0) (gnus-summary-tick-article nil t))
8389 (t (gnus-summary-tick-article)))
8390 ;; ...and go forward until either the buffer ends or the subtree
8392 (if (not (and (zerop (forward-line 1))
8393 (> (gnus-summary-thread-level) level)))
8394 (setq killing nil))))
8395 ;; Hide killed subtrees.
8397 gnus-thread-hide-killed
8398 (gnus-summary-hide-thread))
8399 ;; If marked as read, go to next unread subject.
8401 ;; Go to next unread subject.
8402 (gnus-summary-next-subject 1 t)))
8403 (gnus-set-mode-line 'summary))
8405 ;; Summary sorting commands
8407 (defun gnus-summary-sort-by-number (reverse)
8408 "Sort summary buffer by article number.
8409 Argument REVERSE means reverse order."
8412 (cons 'gnus-summary-article-number 'gnus-thread-sort-by-number) reverse))
8414 (defun gnus-summary-sort-by-author (reverse)
8415 "Sort summary buffer by author name alphabetically.
8416 If case-fold-search is non-nil, case of letters is ignored.
8417 Argument REVERSE means reverse order."
8422 (let ((extract (funcall
8423 gnus-extract-address-components
8424 (header-from (gnus-get-header-by-number
8425 (gnus-summary-article-number))))))
8426 (or (car extract) (cdr extract))))
8427 'gnus-thread-sort-by-author)
8430 (defun gnus-summary-sort-by-subject (reverse)
8431 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
8432 If case-fold-search is non-nil, case of letters is ignored.
8433 Argument REVERSE means reverse order."
8438 (downcase (gnus-simplify-subject (gnus-summary-subject-string))))
8439 'gnus-thread-sort-by-subject)
8442 (defun gnus-summary-sort-by-date (reverse)
8443 "Sort summary buffer by date.
8444 Argument REVERSE means reverse order."
8451 (gnus-get-header-by-number (gnus-summary-article-number)))))
8452 'gnus-thread-sort-by-date)
8455 (defun gnus-summary-sort-by-score (reverse)
8456 "Sort summary buffer by score.
8457 Argument REVERSE means reverse order."
8460 (cons 'gnus-summary-article-score 'gnus-thread-sort-by-score)
8463 (defvar gnus-summary-already-sorted nil)
8464 (defun gnus-summary-sort (predicate reverse)
8465 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
8466 (if gnus-summary-already-sorted
8468 (let (buffer-read-only)
8469 (if (not gnus-show-threads)
8471 (goto-char (point-min))
8472 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
8473 (let ((gnus-thread-sort-functions (list (cdr predicate)))
8474 (gnus-summary-already-sorted nil))
8475 (gnus-summary-prepare))))))
8477 (defun gnus-sortable-date (date)
8478 "Make sortable string by string-lessp from DATE.
8479 Timezone package is used."
8480 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
8481 (year (aref date 0))
8482 (month (aref date 1))
8483 (day (aref date 2)))
8484 (timezone-make-sortable-date
8486 (timezone-make-time-string
8487 (aref date 3) (aref date 4) (aref date 5)))))
8490 ;; Summary saving commands.
8492 (defun gnus-summary-save-article (n)
8493 "Save the current article using the default saver function.
8494 If N is a positive number, save the N next articles.
8495 If N is a negative number, save the N previous articles.
8496 If N is nil and any articles have been marked with the process mark,
8497 save those articles instead.
8498 The variable `gnus-default-article-saver' specifies the saver function."
8500 (let (articles process)
8501 (if (and n (numberp n))
8502 (let ((backward (< n 0))
8506 (setq articles (cons (gnus-summary-article-number)
8508 (gnus-summary-search-forward nil nil backward))
8510 (setq articles (sort articles (function <))))
8511 (if gnus-newsgroup-processable
8513 (setq articles (setq gnus-newsgroup-processable
8514 (nreverse gnus-newsgroup-processable)))
8516 (setq articles (list (gnus-summary-article-number)))))
8518 (let ((header (gnus-gethash (int-to-string (car articles))
8519 gnus-newsgroup-headers-hashtb-by-number)))
8520 (if (vectorp header)
8522 (gnus-summary-select-article t nil nil (car articles))
8523 (or gnus-save-all-headers
8524 (gnus-article-hide-headers t))
8525 ;; Remove any X-Gnus lines.
8528 (set-buffer gnus-article-buffer)
8529 (let ((buffer-read-only nil))
8530 (goto-char (point-min))
8531 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
8533 (while (re-search-forward "^X-Gnus" nil t)
8534 (delete-region (progn (beginning-of-line) (point))
8535 (progn (forward-line 1) (point))))
8537 (if gnus-default-article-saver
8538 (funcall gnus-default-article-saver)
8539 (error "No default saver is defined.")))
8540 (if (assq 'name header)
8541 (gnus-copy-file (cdr (assq 'name header)))
8542 (message "Article %d is unsaveable" (car articles)))))
8544 (gnus-summary-remove-process-mark (car articles)))
8545 (setq articles (cdr articles)))
8546 (if process (setq gnus-newsgroup-processable
8547 (nreverse gnus-newsgroup-processable)))
8548 (gnus-summary-position-cursor)
8551 (defun gnus-summary-pipe-output (arg)
8552 "Pipe the current article to a subprocess.
8553 If N is a positive number, pipe the N next articles.
8554 If N is a negative number, pipe the N previous articles.
8555 If N is nil and any articles have been marked with the process mark,
8556 pipe those articles instead."
8558 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8559 (gnus-summary-save-article arg)))
8561 (defun gnus-summary-save-article-mail (arg)
8562 "Append the current article to an mail file.
8563 If N is a positive number, save the N next articles.
8564 If N is a negative number, save the N previous articles.
8565 If N is nil and any articles have been marked with the process mark,
8566 save those articles instead."
8568 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8569 (gnus-summary-save-article arg)))
8571 (defun gnus-summary-save-article-rmail (arg)
8572 "Append the current article to an rmail file.
8573 If N is a positive number, save the N next articles.
8574 If N is a negative number, save the N previous articles.
8575 If N is nil and any articles have been marked with the process mark,
8576 save those articles instead."
8578 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8579 (gnus-summary-save-article arg)))
8581 (defun gnus-summary-save-article-file (arg)
8582 "Append the current article to a file.
8583 If N is a positive number, save the N next articles.
8584 If N is a negative number, save the N previous articles.
8585 If N is nil and any articles have been marked with the process mark,
8586 save those articles instead."
8588 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8589 (gnus-summary-save-article arg)))
8591 (defun gnus-summary-save-article-folder (arg)
8592 "Append the current article to an mh folder.
8593 If N is a positive number, save the N next articles.
8594 If N is a negative number, save the N previous articles.
8595 If N is nil and any articles have been marked with the process mark,
8596 save those articles instead."
8598 (let ((gnus-default-article-saver 'gnus-summary-save-in-folder))
8599 (gnus-summary-save-article arg)))
8601 (defun gnus-summary-save-in-rmail (&optional filename)
8602 "Append this article to Rmail file.
8603 Optional argument FILENAME specifies file name.
8604 Directory to save to is default to `gnus-article-save-directory' which
8605 is initialized from the SAVEDIR environment variable."
8608 (funcall gnus-rmail-save-name gnus-newsgroup-name
8609 gnus-current-headers gnus-newsgroup-last-rmail)))
8613 (concat "Save in rmail file: (default "
8614 (file-name-nondirectory default-name) ") ")
8615 (file-name-directory default-name)
8617 (gnus-make-directory (file-name-directory filename))
8618 (gnus-eval-in-buffer-window
8623 (gnus-output-to-rmail filename))))
8624 ;; Remember the directory name to save articles.
8625 (setq gnus-newsgroup-last-rmail filename)))
8627 (defun gnus-summary-save-in-mail (&optional filename)
8628 "Append this article to Unix mail file.
8629 Optional argument FILENAME specifies file name.
8630 Directory to save to is default to `gnus-article-save-directory' which
8631 is initialized from the SAVEDIR environment variable."
8634 (funcall gnus-mail-save-name gnus-newsgroup-name
8635 gnus-current-headers gnus-newsgroup-last-mail)))
8639 (concat "Save in Unix mail file: (default "
8640 (file-name-nondirectory default-name) ") ")
8641 (file-name-directory default-name)
8644 (expand-file-name filename
8646 (file-name-directory default-name))))
8647 (gnus-make-directory (file-name-directory filename))
8648 (gnus-eval-in-buffer-window
8653 (if (and (file-readable-p filename) (rmail-file-p filename))
8654 (gnus-output-to-rmail filename)
8655 (rmail-output filename 1 t t)))))
8656 ;; Remember the directory name to save articles.
8657 (setq gnus-newsgroup-last-mail filename)))
8659 (defun gnus-summary-save-in-file (&optional filename)
8660 "Append this article to file.
8661 Optional argument FILENAME specifies file name.
8662 Directory to save to is default to `gnus-article-save-directory' which
8663 is initialized from the SAVEDIR environment variable."
8666 (funcall gnus-file-save-name gnus-newsgroup-name
8667 gnus-current-headers gnus-newsgroup-last-file)))
8671 (concat "Save in file: (default "
8672 (file-name-nondirectory default-name) ") ")
8673 (file-name-directory default-name)
8675 (gnus-make-directory (file-name-directory filename))
8676 (gnus-eval-in-buffer-window
8681 (gnus-output-to-file filename))))
8682 ;; Remember the directory name to save articles.
8683 (setq gnus-newsgroup-last-file filename)))
8685 (defun gnus-summary-save-in-pipe (&optional command)
8686 "Pipe this article to subprocess."
8688 (let ((command (read-string "Shell command on article: "
8689 gnus-last-shell-command)))
8690 (if (string-equal command "")
8691 (setq command gnus-last-shell-command))
8692 (gnus-eval-in-buffer-window
8696 (shell-command-on-region (point-min) (point-max) command nil)))
8697 (setq gnus-last-shell-command command)))
8699 ;; Summary extract commands
8701 (defun gnus-summary-insert-pseudos (pslist)
8702 (let ((buffer-read-only nil)
8703 (article (gnus-summary-article-number))
8705 (or (gnus-summary-goto-subject article)
8706 (error (format "No such article: %d" article)))
8707 (or gnus-newsgroup-headers-hashtb-by-number
8708 (gnus-make-headers-hashtable-by-number))
8709 (gnus-summary-position-cursor)
8710 (if gnus-view-pseudos
8712 (and (assq 'execute (car pslist))
8713 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8714 (eq gnus-view-pseudos 'not-confirm)))
8715 (setq pslist (cdr pslist)))
8718 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
8719 (gnus-summary-article-number)))
8722 (insert " " (file-name-nondirectory
8723 (cdr (assq 'name (car pslist))))
8724 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8725 (add-text-properties
8726 b (1+ b) (list 'gnus-subject (cdr (assq 'name (car pslist)))
8727 'gnus-number gnus-reffed-article-number
8728 'gnus-mark gnus-unread-mark
8729 'gnus-pseudo (car pslist)
8731 (gnus-sethash (int-to-string gnus-reffed-article-number)
8732 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
8733 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8734 (setq pslist (cdr pslist)))))))
8736 (defun gnus-request-pseudo-article (props)
8737 (cond ((assq 'execute props)
8738 (gnus-execute-command (cdr (assq 'execute props)))))
8739 (let ((gnus-current-article (gnus-summary-article-number)))
8740 (run-hooks 'gnus-mark-article-hook)))
8742 (defun gnus-execute-command (command &optional automatic)
8744 (gnus-article-setup-buffer)
8745 (set-buffer gnus-article-buffer)
8746 (let ((command (if automatic command (read-string "Command: " command)))
8747 (buffer-read-only nil))
8749 (insert "$ " command "\n\n")
8750 (if gnus-view-pseudo-asynchronously
8751 (start-process "gnus-execute" nil "sh" "-c" command)
8752 (call-process "sh" nil t nil "-c" command)))))
8754 (defun gnus-copy-file (file &optional to)
8757 (list (read-file-name "Copy file: " default-directory)
8758 (read-file-name "Copy file to: " default-directory)))
8759 (or to (setq to (read-file-name "Copy file to: " default-directory)))
8760 (and (file-directory-p to)
8761 (setq to (concat (file-name-as-directory to)
8762 (file-name-nondirectory file))))
8763 (copy-file file to))
8765 ;; Summary score file commands
8767 ;; Much modification of the kill (ahem, score) code and lots of the
8768 ;; functions are written by Per Abrahamsen <amanda@iesd.auc.dk>.
8770 (defun gnus-summary-header (header)
8771 ;; Return HEADER for current articles, or error.
8772 (let ((article (gnus-summary-article-number)))
8774 (aref (gnus-get-header-by-number article)
8775 (nth 1 (assoc header gnus-header-index)))
8776 (error "No article on current line"))))
8778 (defun gnus-summary-score-entry (header match type score date &optional prompt)
8779 "Enter score file entry.
8780 HEADER is the header being scored.
8781 MATCH is the string we are looking for.
8782 TYPE is a flag indicating if it is a regexp or substring.
8783 SCORE is the score to add.
8784 DATE is the expire date."
8786 (list (completing-read "Header: "
8788 (lambda (x) (fboundp (nth 2 x)))
8790 (read-string "Match: ")
8791 (y-or-n-p "Use regexp match? ")
8792 (prefix-numeric-value current-prefix-arg)
8793 (if (y-or-n-p "Expire kill? ")
8794 (current-time-string)
8796 (let ((score (gnus-score-default score))
8797 (header (downcase header)))
8798 (and prompt (setq match (read-string
8799 (format "Match %s on %s, %s: "
8800 (if date "temp" "permanent")
8802 (if (< score 0) "lower" "raise"))
8804 (and (>= (nth 1 (assoc header gnus-header-index)) 0)
8805 (gnus-summary-score-effect header match type score))
8806 (and (= score gnus-score-interactive-default-score)
8808 (let ((new (cond (type
8809 (list match score (and date (gnus-day-number date)) type))
8811 (list match score (gnus-day-number date)))
8816 (old (gnus-score-get header)))
8819 (if old (cons new old) (list new))))
8820 (gnus-score-set 'touched '(t))))
8822 (defun gnus-summary-score-effect (header match type score)
8823 "Simulate the effect of a score file entry.
8824 HEADER is the header being scored.
8825 MATCH is the string we are looking for.
8826 TYPE is a flag indicating if it is a regexp or substring.
8827 SCORE is the score to add."
8828 (interactive (list (completing-read "Header: "
8830 (lambda (x) (fboundp (nth 2 x)))
8832 (read-string "Match: ")
8833 (y-or-n-p "Use regexp match? ")
8834 (prefix-numeric-value current-prefix-arg)))
8836 (or (and (stringp match) (> (length match) 0))
8838 (goto-char (point-min))
8839 (let ((regexp (if type
8841 (concat "\\`.*" (regexp-quote match) ".*\\'"))))
8843 (let ((content (gnus-summary-header header))
8844 (case-fold-search t))
8846 (if (string-match regexp content)
8847 (gnus-summary-raise-score score))))
8848 (beginning-of-line 2)))))
8850 (defun gnus-summary-score-crossposting (score date)
8851 ;; Enter score file entry for current crossposting.
8852 ;; SCORE is the score to add.
8853 ;; DATE is the expire date.
8854 (let ((xref (gnus-summary-header "xref"))
8857 (or xref (error "This article is not crossposted"))
8858 (while (string-match " \\([^ \t]+\\):" xref start)
8859 (setq start (match-end 0))
8862 (substring xref (match-beginning 1) (match-end 1)))
8863 gnus-newsgroup-name))
8864 (gnus-summary-score-entry
8865 "xref" (concat " " group ":") nil score date t)))))
8867 (defun gnus-summary-temporarily-lower-by-subject (level)
8868 "Temporarily lower score by LEVEL for current subject.
8869 See `gnus-score-expiry-days'."
8871 (gnus-summary-score-entry
8872 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
8873 nil (- (gnus-score-default level))
8874 (current-time-string) t))
8876 (defun gnus-summary-temporarily-lower-by-author (level)
8877 "Temporarily lower score by LEVEL for current author.
8878 See `gnus-score-expiry-days'."
8880 (gnus-summary-score-entry
8881 "from" (gnus-summary-header "from") nil (- (gnus-score-default level))
8882 (current-time-string) t))
8884 (defun gnus-summary-temporarily-lower-by-body (level)
8885 "Temporarily lower score by LEVEL for a match on the body of the article.
8886 See `gnus-score-expiry-days'."
8888 (gnus-summary-score-entry
8889 "body" "" nil (- (gnus-score-default level)) (current-time-string) t))
8891 (defun gnus-summary-temporarily-lower-by-id (level)
8892 "Temporarily lower score by LEVEL for current message-id.
8893 See `gnus-score-expiry-days'."
8895 (gnus-summary-score-entry
8896 "message-id" (gnus-summary-header "message-id")
8897 nil (- (gnus-score-default level))
8898 (current-time-string)))
8900 (defun gnus-summary-temporarily-lower-by-xref (level)
8901 "Temporarily lower score by LEVEL for current xref.
8902 See `gnus-score-expiry-days'."
8904 (gnus-summary-score-crossposting
8905 (- (gnus-score-default level)) (current-time-string)))
8907 (defun gnus-summary-temporarily-lower-by-thread (level)
8908 "Temporarily lower score by LEVEL for current thread.
8909 See `gnus-score-expiry-days'."
8911 (gnus-summary-score-entry
8912 "references" (gnus-summary-header "message-id")
8913 nil (- (gnus-score-default level)) (current-time-string)))
8915 (defun gnus-summary-lower-by-subject (level)
8916 "Lower score by LEVEL for current subject."
8918 (gnus-summary-score-entry
8919 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
8920 nil (- (gnus-score-default level))
8923 (defun gnus-summary-lower-by-author (level)
8924 "Lower score by LEVEL for current author."
8926 (gnus-summary-score-entry
8927 "from" (gnus-summary-header "from") nil
8928 (- (gnus-score-default level)) nil t))
8930 (defun gnus-summary-lower-by-body (level)
8931 "Lower score by LEVEL for a match on the body of the article."
8933 (gnus-summary-score-entry
8934 "body" "" nil (- (gnus-score-default level)) nil t))
8936 (defun gnus-summary-lower-by-id (level)
8937 "Lower score by LEVEL for current message-id."
8939 (gnus-summary-score-entry
8940 "message-id" (gnus-summary-header "message-id") nil
8941 (- (gnus-score-default level)) nil))
8943 (defun gnus-summary-lower-by-xref (level)
8944 "Lower score by LEVEL for current xref."
8946 (gnus-summary-score-crossposting (- (gnus-score-default level)) nil))
8948 (defun gnus-summary-lower-followups-to-author (level)
8949 "Lower score by LEVEL for all followups to the current author."
8951 (gnus-summary-raise-followups-to-author
8952 (- (gnus-score-default level))))
8954 (defun gnus-summary-temporarily-raise-by-subject (level)
8955 "Temporarily raise score by LEVEL for current subject.
8956 See `gnus-score-expiry-days'."
8958 (gnus-summary-score-entry
8959 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
8960 nil level (current-time-string) t))
8962 (defun gnus-summary-temporarily-raise-by-author (level)
8963 "Temporarily raise score by LEVEL for current author.
8964 See `gnus-score-expiry-days'."
8966 (gnus-summary-score-entry
8967 "from" (gnus-summary-header "from") nil level (current-time-string) t))
8969 (defun gnus-summary-temporarily-raise-by-body (level)
8970 "Temporarily raise score by LEVEL for a match on the body of the article.
8971 See `gnus-score-expiry-days'."
8973 (gnus-summary-score-entry "body" "" nil level (current-time-string) t))
8975 (defun gnus-summary-temporarily-raise-by-id (level)
8976 "Temporarily raise score by LEVEL for current message-id.
8977 See `gnus-score-expiry-days'."
8979 (gnus-summary-score-entry
8980 "message-id" (gnus-summary-header "message-id")
8981 nil level (current-time-string)))
8983 (defun gnus-summary-temporarily-raise-by-xref (level)
8984 "Temporarily raise score by LEVEL for current xref.
8985 See `gnus-score-expiry-days'."
8987 (gnus-summary-score-crossposting level (current-time-string)))
8989 (defun gnus-summary-temporarily-raise-by-thread (level)
8990 "Temporarily raise score by LEVEL for current thread.
8991 See `gnus-score-expiry-days'."
8993 (gnus-summary-score-entry
8994 "references" (gnus-summary-header "message-id")
8995 nil level (current-time-string)))
8997 (defun gnus-summary-raise-by-subject (level)
8998 "Raise score by LEVEL for current subject."
9000 (gnus-summary-score-entry
9001 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
9004 (defun gnus-summary-raise-by-author (level)
9005 "Raise score by LEVEL for current author."
9007 (gnus-summary-score-entry
9008 "from" (gnus-summary-header "from") nil level nil t))
9010 (defun gnus-summary-raise-by-body (level)
9011 "Raise score by LEVEL for a match on the body of the article."
9013 (gnus-summary-score-entry "body" "" nil level nil t))
9015 (defun gnus-summary-raise-by-id (level)
9016 "Raise score by LEVEL for current message-id."
9018 (gnus-summary-score-entry
9019 "message-id" (gnus-summary-header "message-id") nil level nil))
9021 (defun gnus-summary-raise-by-xref (level)
9022 "Raise score by LEVEL for current xref."
9024 (gnus-summary-score-crossposting level nil))
9026 (defun gnus-summary-raise-followups-to-author (level)
9027 "Raise score by LEVEL for all followups to the current author."
9029 (let ((article (gnus-summary-article-number)))
9030 (if article (setq gnus-current-headers (gnus-get-header-by-number article))
9031 (error "No article on current line")))
9032 (gnus-kill-file-raise-followups-to-author
9033 (gnus-score-default level)))
9035 ;; Summary kill commands.
9037 (defun gnus-summary-edit-global-kill (article)
9038 "Edit the global score file."
9039 (interactive (list (gnus-summary-article-number)))
9040 (gnus-group-edit-global-kill article))
9042 (defun gnus-summary-edit-local-kill ()
9043 "Edit a local score file applied to the current newsgroup."
9045 (setq gnus-current-headers
9047 (int-to-string (gnus-summary-article-number))
9048 gnus-newsgroup-headers-hashtb-by-number))
9049 (gnus-set-global-variables)
9050 (gnus-group-edit-local-kill
9051 (gnus-summary-article-number) gnus-newsgroup-name))
9055 ;;; Gnus article mode
9058 (put 'gnus-article-mode 'mode-class 'special)
9060 (if gnus-article-mode-map
9062 (setq gnus-article-mode-map (make-keymap))
9063 (suppress-keymap gnus-article-mode-map)
9064 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
9065 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
9066 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
9067 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
9068 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
9069 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
9070 (define-key gnus-article-mode-map "\C-c\C-M" 'gnus-article-mail-with-original)
9071 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
9073 ;; Duplicate almost all summary keystrokes in the article mode map.
9075 (list "#" "\M-#" "\C-c\M-#" "\r" "n" "p"
9076 "N" "P" "\M-\C-n" "\M-\C-p" "." "\M-s" "\M-r"
9077 "<" ">" "l" "j" "^" "\M-^" "-" "u" "U" "d" "D"
9078 "\M-u" "\M-U" "k" "\C-k" "\M-\C-k" "c" "x" "X"
9079 "\M-\C-x" "\M-\177" "b" "B" "$" "w" "\C-c\C-r"
9080 "t" "\M-t" "a" "f" "F" "C" "S" "r" "R" "\C-c\C-f"
9081 "m" "o" "\C-o" "|" "\M-m" "\M-\C-m" "\M-k" "m" "M"
9082 "V" "\C-c\C-d" "q" "Q")))
9084 (define-key gnus-article-mode-map (car commands)
9085 'gnus-article-summary-command)
9086 (setq commands (cdr commands)))))
9089 (defun gnus-article-mode ()
9090 "Major mode for displaying an article.
9092 All normal editing commands are switched off.
9094 The following commands are available:
9096 \\<gnus-article-mode-map>
9097 \\[gnus-article-next-page]\t Scroll the article one page forwards
9098 \\[gnus-article-prev-page]\t Scroll the article one page backwards
9099 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
9100 \\[gnus-article-show-summary]\t Display the summary buffer
9101 \\[gnus-article-mail]\t Send a reply to the address near point
9102 \\[gnus-article-mail-with-original]\t Send a reply to the address near point; include the original article
9103 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
9104 \\[gnus-info-find-node]\t Go to the Gnus info node"
9106 (if gnus-visual (gnus-article-make-menu-bar))
9107 (kill-all-local-variables)
9108 (setq mode-line-modified "-- ")
9109 (make-local-variable 'mode-line-format)
9110 (setq mode-line-format (copy-sequence mode-line-format))
9111 (and (equal (nth 3 mode-line-format) " ")
9112 (setcar (nthcdr 3 mode-line-format) ""))
9113 (setq mode-name "Article")
9114 (setq major-mode 'gnus-article-mode)
9115 (make-local-variable 'minor-mode-alist)
9116 (or (assq 'gnus-show-mime minor-mode-alist)
9117 (setq minor-mode-alist
9118 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
9119 (use-local-map gnus-article-mode-map)
9120 (make-local-variable 'page-delimiter)
9121 (setq page-delimiter gnus-page-delimiter)
9122 (buffer-disable-undo (current-buffer))
9123 (setq buffer-read-only t) ;Disable modification
9124 (run-hooks 'gnus-article-mode-hook))
9126 (defun gnus-article-setup-buffer ()
9127 "Initialize article mode buffer."
9128 (or (get-buffer gnus-article-buffer)
9130 (set-buffer (get-buffer-create gnus-article-buffer))
9131 (gnus-add-current-to-buffer-list)
9132 (gnus-article-mode))))
9134 (defun gnus-request-article-this-buffer (article &optional group)
9135 "Get an article and insert it into this buffer."
9136 (setq group (or group gnus-newsgroup-name))
9137 ;; Using `gnus-request-article' directly will insert the article into
9138 ;; `nntp-server-buffer' - so we'll save some time by not having to
9139 ;; copy it from the server buffer into the article buffer.
9141 ;; We only request an article by message-id when we do not have the
9142 ;; headers for it, so we'll have to get those.
9143 (and (stringp article)
9144 (let ((gnus-override-method gnus-refer-article-method))
9145 (gnus-read-header article)))
9147 ;; If the article number is negative, that means that this article
9148 ;; doesn't belong in this newsgroup (possibly), so we find its
9149 ;; message-id and request it by id instead of number.
9150 (if (and (numberp article) (< article 0))
9152 (set-buffer gnus-summary-buffer)
9153 (let ((header (gnus-gethash (int-to-string article)
9154 gnus-newsgroup-headers-hashtb-by-number)))
9155 (if (vectorp header)
9156 ;; It's a real article.
9157 (setq article (header-id header))
9158 ;; It is an extracted pseudo-article.
9160 (gnus-request-pseudo-article header)))))
9161 ;; Get the article and into the article buffer.
9165 (let ((gnus-override-method
9166 (and (stringp article) gnus-refer-article-method)))
9167 (and (gnus-request-article article group (current-buffer))
9171 (defun gnus-read-header (id)
9172 "Read the headers of article ID and enter them into the Gnus system."
9173 (or gnus-newsgroup-headers-hashtb-by-number
9174 (gnus-make-headers-hashtable-by-number))
9176 (if (not (setq header
9177 (car (if (let ((gnus-nov-is-evil t))
9178 (gnus-retrieve-headers
9179 (list id) gnus-newsgroup-name))
9180 (gnus-get-newsgroup-headers)))))
9183 (header-set-number header gnus-reffed-article-number))
9184 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
9185 (gnus-sethash (int-to-string (header-number header)) header
9186 gnus-newsgroup-headers-hashtb-by-number)
9188 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
9189 (setq gnus-current-headers header)
9192 (defun gnus-article-prepare (article &optional all-headers header)
9193 "Prepare ARTICLE in article mode buffer.
9194 ARTICLE should either be an article number or a Message-ID.
9195 If ARTICLE is an id, HEADER should be the article headers.
9196 If ALL-HEADERS is non-nil, no headers are hidden."
9198 ;; Make sure we start in a summary buffer.
9199 (or (eq major-mode 'gnus-summary-mode)
9200 (set-buffer gnus-summary-buffer))
9201 (setq gnus-summary-buffer (current-buffer))
9202 ;; Make sure the connection to the server is alive.
9203 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
9205 (gnus-check-news-server
9206 (gnus-find-method-for-group gnus-newsgroup-name))
9207 (gnus-request-group gnus-newsgroup-name t)))
9208 (or gnus-newsgroup-headers-hashtb-by-number
9209 (gnus-make-headers-hashtable-by-number))
9210 (let* ((article (if header (header-number header) article))
9211 (summary-buffer (current-buffer))
9212 (internal-hook gnus-article-internal-prepare-hook)
9213 (bookmark (cdr (assq article gnus-newsgroup-bookmarks)))
9214 (group gnus-newsgroup-name)
9217 (gnus-article-setup-buffer)
9218 (set-buffer gnus-article-buffer)
9219 (let ((buffer-read-only nil))
9220 (if (not (setq result (gnus-request-article-this-buffer
9222 ;; There is no such article.
9225 (set-buffer gnus-summary-buffer)
9226 (setq gnus-current-article 0)
9227 (and (numberp article)
9228 (gnus-summary-mark-as-read article gnus-canceled-mark))
9229 (message "No such article (may be canceled)")
9231 (setq gnus-article-current nil)
9233 (if (not (eq result 'article))
9236 (set-buffer summary-buffer)
9237 (setq gnus-last-article gnus-current-article
9238 gnus-newsgroup-history (cons gnus-current-article
9239 gnus-newsgroup-history)
9240 gnus-current-article 0
9241 gnus-current-headers nil
9242 gnus-article-current nil)
9243 (gnus-configure-windows 'article)
9244 (gnus-set-global-variables))
9245 (gnus-set-mode-line 'article))
9246 ;; The result from the `request' was an actual article -
9247 ;; or at least some text that is now displayed in the
9249 (if (and (numberp article)
9250 (not (eq article gnus-current-article)))
9251 ;; Seems like a new article has been selected.
9252 ;; `gnus-current-article' must be an article number.
9254 (set-buffer summary-buffer)
9255 (setq gnus-last-article gnus-current-article
9256 gnus-newsgroup-history (cons gnus-current-article
9257 gnus-newsgroup-history)
9258 gnus-current-article article
9259 gnus-current-headers
9260 (gnus-get-header-by-number gnus-current-article)
9261 gnus-article-current
9262 (cons gnus-newsgroup-name gnus-current-article))
9263 (run-hooks 'gnus-mark-article-hook)
9264 (gnus-set-mode-line 'summary)
9266 (run-hooks 'gnus-visual-mark-article-hook))
9267 ;; Set the global newsgroup variables here.
9268 ;; Suggested by Jim Sisolak
9269 ;; <sisolak@trans4.neep.wisc.edu>.
9270 (gnus-set-global-variables)))
9271 ;; gnus-have-all-headers must be either T or NIL.
9272 (setq gnus-have-all-headers
9273 (not (not (or all-headers gnus-show-all-headers))))
9274 ;; Hooks for getting information from the article.
9275 ;; This hook must be called before being narrowed.
9276 (run-hooks 'internal-hook)
9277 (run-hooks 'gnus-article-prepare-hook)
9278 ;; Decode MIME message.
9279 (if (and gnus-show-mime
9280 (gnus-fetch-field "Mime-Version"))
9281 (funcall gnus-show-mime-method))
9282 ;; Perform the article display hooks.
9283 (let ((buffer-read-only nil))
9284 (run-hooks 'gnus-article-display-hook))
9286 (goto-char (point-min))
9287 (and gnus-break-pages (gnus-narrow-to-page))
9288 (gnus-set-mode-line 'article)
9289 (gnus-configure-windows 'article)
9292 (get-buffer-window gnus-article-buffer) (point-min))
9295 (message "Moved to bookmark")
9296 (search-forward "\n\n" nil t)
9297 (forward-line bookmark)))
9300 (defun gnus-article-show-all-headers ()
9301 "Show all article headers in article mode buffer."
9303 (setq gnus-have-all-headers t)
9304 (gnus-article-setup-buffer)
9305 (set-buffer gnus-article-buffer)
9306 (let ((buffer-read-only nil))
9307 (remove-text-properties 1 (point-max) '(invisible t)))))
9309 (defun gnus-article-hide-headers-if-wanted ()
9310 "Hide unwanted headers if `gnus-have-all-headers' is nil.
9311 Provided for backwards compatability."
9312 (or gnus-have-all-headers
9313 (gnus-article-hide-headers)))
9315 (defun gnus-article-hide-headers (&optional delete)
9316 "Hide unwanted headers and possibly sort them as well."
9319 (set-buffer gnus-article-buffer)
9321 (let ((sorted gnus-sorted-header-list)
9322 (buffer-read-only nil)
9323 want want-list beg want-l)
9324 ;; First we narrow to just the headers.
9327 ;; Hide any "From " lines at the beginning of (mail) articles.
9328 (while (looking-at rmail-unix-mail-delimiter)
9331 (add-text-properties 1 (point) '(invisible t)))
9332 ;; Then treat the rest of the header lines.
9335 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
9336 ;; Then we use the two regular expressions
9337 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
9338 ;; select which header lines is to remain visible in the
9341 (while (re-search-forward "^[^ \t]*:" nil t)
9343 ;; We add the headers we want to keep to a list and delete
9344 ;; them from the buffer.
9345 (if (or (and (stringp gnus-visible-headers)
9346 (looking-at gnus-visible-headers))
9347 (and (not (stringp gnus-visible-headers))
9348 (stringp gnus-ignored-headers)
9349 (not (looking-at gnus-ignored-headers))))
9353 ;; Be sure to get multi-line headers...
9354 (re-search-forward "^[^ \t]*:" nil t)
9357 (cons (buffer-substring beg (point)) want-list))
9358 (delete-region beg (point))
9361 ;; Next we perform the sorting by looking at
9362 ;; `gnus-sorted-header-list'.
9364 (while (and sorted want-list)
9365 (setq want-l want-list)
9367 (not (string-match (car sorted) (car want-l))))
9368 (setq want-l (cdr want-l)))
9371 (insert (car want-l))
9372 (setq want-list (delq (car want-l) want-list))))
9373 (setq sorted (cdr sorted)))
9374 ;; Any headers that were not matched by the sorted list we
9375 ;; just tack on the end of the visible header list.
9377 (insert (car want-list))
9378 (setq want-list (cdr want-list)))
9379 ;; And finally we make the unwanted headers invisible.
9381 (delete-region (point) (point-max))
9382 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
9383 (add-text-properties (point) (point-max) '(invisible t)))))))
9385 (defun gnus-article-hide-signature ()
9386 "Hides the signature in an article.
9387 It does this by hiding everyting after \"^-- *$\", which is what all
9388 signatures should be preceded by. Note that this may mean that parts
9389 of an article may disappear if the article has such a line in the
9390 middle of the text."
9393 (set-buffer gnus-article-buffer)
9394 (let ((buffer-read-only nil))
9395 (goto-char (point-max))
9396 (if (re-search-backward "^-- *$" nil t)
9398 (add-text-properties (point) (point-max) '(invisible t)))))))
9400 (defun gnus-article-hide-citation ()
9401 "Hide all cited text.
9402 This function uses the famous, extremely intelligent \"shoot in foot\"
9403 algorithm - which is simply deleting all lines that start with
9404 \">\". Your mileage may vary. If you come up with anything better,
9405 please do mail it to me."
9408 (set-buffer gnus-article-buffer)
9409 (let ((buffer-read-only nil))
9411 (search-forward "\n\n" nil t)
9413 (if (looking-at ">")
9414 (add-text-properties
9415 (point) (save-excursion (forward-line 1) (point))
9417 (forward-line 1)))))
9419 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
9420 (defun gnus-article-treat-overstrike ()
9421 ;; Prepare article for overstrike commands.
9424 (set-buffer gnus-article-buffer)
9425 (let ((buffer-read-only nil))
9426 (while (search-forward "\b" nil t)
9427 (let ((next (following-char))
9428 (previous (char-after (- (point) 2))))
9429 (cond ((eq next previous)
9430 (delete-region (- (point) 2) (point))
9431 (put-text-property (point) (1+ (point))
9434 (delete-region (1- (point)) (1+ (point)))
9435 (put-text-property (1- (point)) (point)
9438 (delete-region (- (point) 2) (point))
9439 (put-text-property (point) (1+ (point))
9440 'face 'underline))))))))
9442 (defun gnus-article-word-wrap ()
9443 "Format too long lines."
9446 (set-buffer gnus-article-buffer)
9447 (let ((buffer-read-only nil))
9449 (search-forward "\n\n" nil t)
9451 (let ((paragraph-start "^\\W"))
9453 (and (>= (current-column) (window-width))
9454 (/= (preceding-char) ?:)
9455 (fill-paragraph nil))
9456 (end-of-line 2))))))
9458 (defun gnus-article-remove-cr ()
9461 (set-buffer gnus-article-buffer)
9462 (let ((buffer-read-only nil))
9463 (goto-char (point-min))
9464 (while (search-forward "\r" nil t)
9465 (replace-match "")))))
9467 (defun gnus-article-de-quoted-unreadable ()
9471 (set-buffer gnus-article-buffer)
9472 (let ((buffer-read-only nil))
9474 (goto-char (point-min))
9475 (while (re-search-forward "=[0-9A-F][0-9A-F]" nil t)
9479 (* 16 (gnus-hex-char-to-integer
9480 (char-after (1+ (match-beginning 0)))))
9481 (gnus-hex-char-to-integer
9482 (char-after (1- (match-end 0))))))))))))
9484 ;; Taken from hexl.el.
9485 (defun gnus-hex-char-to-integer (character)
9486 "Take a char and return its value as if it was a hex digit."
9487 (if (and (>= character ?0) (<= character ?9))
9489 (let ((ch (logior character 32)))
9490 (if (and (>= ch ?a) (<= ch ?f))
9492 (error (format "Invalid hex digit `%c'." ch))))))
9496 (defun gnus-output-to-rmail (file-name)
9497 "Append the current article to an Rmail file named FILE-NAME."
9499 ;; Most of these codes are borrowed from rmailout.el.
9500 (setq file-name (expand-file-name file-name))
9501 (setq rmail-default-rmail-file file-name)
9502 (let ((artbuf (current-buffer))
9503 (tmpbuf (get-buffer-create " *Gnus-output*")))
9505 (or (get-file-buffer file-name)
9506 (file-exists-p file-name)
9507 (if (gnus-yes-or-no-p
9508 (concat "\"" file-name "\" does not exist, create it? "))
9509 (let ((file-buffer (create-file-buffer file-name)))
9511 (set-buffer file-buffer)
9512 (rmail-insert-rmail-file-header)
9513 (let ((require-final-newline nil))
9514 (write-region (point-min) (point-max) file-name t 1)))
9515 (kill-buffer file-buffer))
9516 (error "Output file does not exist")))
9518 (buffer-disable-undo (current-buffer))
9520 (insert-buffer-substring artbuf)
9521 (gnus-convert-article-to-rmail)
9522 ;; Decide whether to append to a file or to an Emacs buffer.
9523 (let ((outbuf (get-file-buffer file-name)))
9525 (append-to-file (point-min) (point-max) file-name)
9526 ;; File has been visited, in buffer OUTBUF.
9528 (let ((buffer-read-only nil)
9529 (msg (and (boundp 'rmail-current-message)
9530 rmail-current-message)))
9531 ;; If MSG is non-nil, buffer is in RMAIL mode.
9534 (narrow-to-region (point-max) (point-max))))
9535 (insert-buffer-substring tmpbuf)
9538 (goto-char (point-min))
9540 (search-backward "\^_")
9541 (narrow-to-region (point) (point-max))
9542 (goto-char (1+ (point-min)))
9543 (rmail-count-new-messages t)
9544 (rmail-show-message msg)))))))
9545 (kill-buffer tmpbuf)))
9547 (defun gnus-output-to-file (file-name)
9548 "Append the current article to a file named FILE-NAME."
9549 (setq file-name (expand-file-name file-name))
9550 (let ((artbuf (current-buffer))
9551 (tmpbuf (get-buffer-create " *Gnus-output*")))
9554 (buffer-disable-undo (current-buffer))
9556 (insert-buffer-substring artbuf)
9557 ;; Append newline at end of the buffer as separator, and then
9559 (goto-char (point-max))
9561 (append-to-file (point-min) (point-max) file-name))
9562 (kill-buffer tmpbuf)))
9564 (defun gnus-convert-article-to-rmail ()
9565 "Convert article in current buffer to Rmail message format."
9566 (let ((buffer-read-only nil))
9567 ;; Convert article directly into Babyl format.
9568 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
9569 (goto-char (point-min))
9570 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
9571 (while (search-forward "\n\^_" nil t) ;single char
9572 (replace-match "\n^_")) ;2 chars: "^" and "_"
9573 (goto-char (point-max))
9576 (defun gnus-narrow-to-page (&optional arg)
9577 "Make text outside current page invisible except for page delimiter.
9578 A numeric arg specifies to move forward or backward by that many pages,
9579 thus showing a page other than the one point was originally in."
9581 (setq arg (if arg (prefix-numeric-value arg) 0))
9583 (forward-page -1) ;Beginning of current page.
9588 (forward-page (1- arg))))
9589 ;; Find the end of the page.
9591 ;; If we stopped due to end of buffer, stay there.
9592 ;; If we stopped after a page delimiter, put end of restriction
9593 ;; at the beginning of that line.
9594 ;; These are commented out.
9595 ;; (if (save-excursion (beginning-of-line)
9596 ;; (looking-at page-delimiter))
9597 ;; (beginning-of-line))
9598 (narrow-to-region (point)
9600 ;; Find the top of the page.
9602 ;; If we found beginning of buffer, stay there.
9603 ;; If extra text follows page delimiter on same line,
9605 ;; Otherwise, show text starting with following line.
9606 (if (and (eolp) (not (bobp)))
9610 (defun gnus-gmt-to-local ()
9611 "Rewrite Date header described in GMT to local in current buffer.
9612 Intended to be used with gnus-article-prepare-hook."
9616 (goto-char (point-min))
9617 (narrow-to-region (point-min)
9618 (progn (search-forward "\n\n" nil 'move) (point)))
9619 (goto-char (point-min))
9620 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
9621 (let ((buffer-read-only nil)
9622 (date (buffer-substring (match-beginning 1) (match-end 1))))
9623 (delete-region (match-beginning 1) (match-end 1))
9625 (timezone-make-date-arpa-standard
9626 date nil (current-time-zone))))))))
9629 ;; Article mode commands
9631 (defun gnus-article-next-page (lines)
9632 "Show next page of current article.
9633 If end of article, return non-nil. Otherwise return nil.
9634 Argument LINES specifies lines to be scrolled up."
9636 (move-to-window-line -1)
9637 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
9640 (and (pos-visible-in-window-p) ;Not continuation line.
9642 ;; Nothing in this page.
9643 (if (or (not gnus-break-pages)
9646 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
9648 (gnus-narrow-to-page 1) ;Go to next page.
9650 ;; More in this page.
9654 ;; Long lines may cause an end-of-buffer error.
9655 (goto-char (point-max))))
9658 (defun gnus-article-prev-page (lines)
9659 "Show previous page of current article.
9660 Argument LINES specifies lines to be scrolled down."
9662 (move-to-window-line 0)
9663 (if (and gnus-break-pages
9665 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
9667 (gnus-narrow-to-page -1) ;Go to previous page.
9668 (goto-char (point-max))
9670 (scroll-down lines)))
9672 (defun gnus-article-refer-article ()
9673 "Read article specified by message-id around point."
9675 (search-forward ">" nil t) ;Move point to end of "<....>".
9676 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
9678 (buffer-substring (match-beginning 1) (match-end 1))))
9679 (set-buffer gnus-summary-buffer)
9680 (gnus-summary-refer-article message-id))
9681 (error "No references around point")))
9683 (defun gnus-article-mail (yank)
9684 "Send a reply to the address near point.
9685 If YANK is non-nil, include the original article."
9689 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
9690 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
9693 (switch-to-buffer gnus-summary-buffer)
9694 (funcall gnus-mail-reply-method yank address)))))
9696 (defun gnus-article-mail-with-original ()
9697 "Send a reply to the address near point and include the original article."
9699 (gnus-article-mail 'yank))
9701 (defun gnus-article-show-summary ()
9702 "Reconfigure windows to show summary buffer."
9704 (gnus-configure-windows 'article)
9705 (pop-to-buffer gnus-summary-buffer)
9706 (gnus-summary-goto-subject gnus-current-article))
9708 (defun gnus-article-describe-briefly ()
9709 "Describe article mode commands briefly."
9712 (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")))
9714 (defun gnus-article-summary-command ()
9715 "Execute the last keystroke in the summary buffer."
9718 (let ((obuf (current-buffer))
9719 (owin (current-window-configuration)))
9720 (switch-to-buffer gnus-summary-buffer 'norecord)
9721 (execute-kbd-macro (this-command-keys))
9723 (let ((npoint (point)))
9724 (set-window-configuration owin)
9725 (set-window-start (get-buffer-window (current-buffer)) (point)))))
9727 ;; caesar-region written by phr@prep.ai.mit.edu Nov 86
9728 ;; Modified by tower@prep Nov 86
9729 ;; Modified by umerin@flab.flab.Fujitsu.JUNET for ROT47.
9731 (defun gnus-caesar-region (&optional n)
9732 "Caesar rotation of region by N, default 13, for decrypting netnews.
9733 ROT47 will be performed for Japanese text in any case."
9734 (interactive (if current-prefix-arg ; Was there a prefix arg?
9735 (list (prefix-numeric-value current-prefix-arg))
9737 (cond ((not (numberp n)) (setq n 13))
9738 (t (setq n (mod n 26)))) ;canonicalize N
9739 (if (not (zerop n)) ; no action needed for a rot of 0
9741 (if (or (not (boundp 'caesar-translate-table))
9742 (not caesar-translate-table)
9743 (/= (aref caesar-translate-table ?a) (+ ?a n)))
9745 (lower "abcdefghijklmnopqrstuvwxyz")
9747 (message "Building caesar-translate-table...")
9748 (setq caesar-translate-table (make-vector 256 0))
9750 (aset caesar-translate-table i i)
9752 (setq lower (concat lower lower)
9753 upper (upcase lower)
9756 (aset caesar-translate-table (+ ?a i) (aref lower (+ i n)))
9757 (aset caesar-translate-table (+ ?A i) (aref upper (+ i n)))
9759 ;; ROT47 for Japanese text.
9760 ;; Thanks to ichikawa@flab.fujitsu.junet.
9762 (let ((t1 (logior ?O 128))
9763 (t2 (logior ?! 128))
9764 (t3 (logior ?~ 128)))
9766 (aset caesar-translate-table i
9767 (let ((v (aref caesar-translate-table i)))
9768 (if (<= v t1) (if (< v t2) v (+ v 47))
9769 (if (<= v t3) (- v 47) v))))
9771 (message "Building caesar-translate-table... done")))
9772 (let ((from (region-beginning))
9775 (setq str (buffer-substring from to))
9776 (setq len (length str))
9778 (aset str i (aref caesar-translate-table (aref str i)))
9781 (delete-region from to)
9785 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
9788 (defalias 'gnus-batch-kill 'gnus-batch-score)
9790 (defun gnus-batch-score ()
9791 "Run batched scoring.
9792 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
9793 Newsgroups is a list of strings in Bnews format. If you want to score
9794 the comp hierarchy, you'd say \"comp.all\". If you would not like to
9795 score the alt hierarchy, you'd say \"!alt.all\"."
9798 (gnus-parse-n-options
9799 (apply (function concat)
9800 (mapcar (lambda (g) (concat g " "))
9801 command-line-args-left))))
9802 (gnus-expert-user t)
9803 (nnmail-spool-file nil)
9804 (gnus-use-dribble-file nil)
9805 (yes (car yes-and-no))
9806 (no (cdr yes-and-no))
9807 group subscribed newsrc entry
9808 ;; Disable verbose message.
9809 gnus-novice-user gnus-large-newsgroup)
9810 ;; Eat all arguments.
9811 (setq command-line-args-left nil)
9814 ;; Apply kills to specified newsgroups in command line arguments.
9815 (setq newsrc (cdr gnus-newsrc-assoc))
9817 (setq group (car (car newsrc)))
9818 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
9819 (if (and (<= (nth 1 (car newsrc)) 5)
9821 (or (eq (car entry) t)
9822 (not (zerop (car entry)))))
9823 (if yes (string-match yes group) t)
9824 (or (null no) (not (string-match no group))))
9826 (gnus-summary-read-group group nil t)
9827 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
9828 (gnus-summary-exit))))
9829 (setq newsrc (cdr newsrc)))
9831 (switch-to-buffer gnus-group-buffer)
9832 (gnus-group-save-newsrc)))
9834 (defun gnus-apply-kill-file ()
9835 "Apply a kill file to the current newsgroup.
9836 Returns the number of articles marked as read."
9837 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
9838 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
9839 (gnus-apply-kill-file-internal)
9842 (defun gnus-kill-save-kill-buffer ()
9844 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
9845 (if (get-file-buffer file)
9847 (set-buffer (get-file-buffer file))
9848 (and (buffer-modified-p) (save-buffer))
9849 (kill-buffer (current-buffer)))))))
9851 (defvar gnus-kill-file-name "KILL"
9852 "Suffix of the kill files.")
9854 (defun gnus-newsgroup-kill-file (newsgroup)
9855 "Return the name of a kill file name for NEWSGROUP.
9856 If NEWSGROUP is nil, return the global kill file name instead."
9857 (cond ((or (null newsgroup)
9858 (string-equal newsgroup ""))
9859 ;; The global KILL file is placed at top of the directory.
9860 (expand-file-name gnus-kill-file-name
9861 (or gnus-kill-files-directory "~/News")))
9862 ((gnus-use-long-file-name 'not-kill)
9863 ;; Append ".KILL" to newsgroup name.
9864 (expand-file-name (concat newsgroup "." gnus-kill-file-name)
9865 (or gnus-kill-files-directory "~/News")))
9867 ;; Place "KILL" under the hierarchical directory.
9868 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
9869 "/" gnus-kill-file-name)
9870 (or gnus-kill-files-directory "~/News")))))
9874 ;;; Gnus Score Files
9877 ;; All score code written by Per Abrahamsen <abraham@iesd.auc.dk>.
9879 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9880 (defun gnus-score-set-mark-below (score)
9881 "Automatically mark articles with score below SCORE as read."
9883 (list (or (and current-prefix-arg (prefix-numeric-value current-prefix-arg))
9884 (string-to-int (read-string "Mark below: ")))))
9885 (setq score (or score gnus-summary-default-score 0))
9886 (gnus-score-set 'mark (list score))
9887 (gnus-score-set 'touched '(t))
9888 (setq gnus-summary-mark-below score)
9889 (gnus-summary-update-lines))
9891 (defun gnus-score-set-expunge-below (score)
9892 "Automatically expunge articles with score below SCORE."
9894 (list (or (and current-prefix-arg (prefix-numeric-value current-prefix-arg))
9895 (string-to-int (read-string "Expunge below: ")))))
9896 (setq score (or score gnus-summary-default-score 0))
9897 (gnus-score-set 'expunge (list score))
9898 (gnus-score-set 'touched '(t)))
9900 (defun gnus-score-default (level)
9901 (if level (prefix-numeric-value level)
9902 gnus-score-interactive-default-score))
9904 (defun gnus-score-set (symbol value &optional alist)
9905 ;; Set SYMBOL to VALUE in ALIST.
9910 (gnus-score-load (gnus-score-file-name gnus-newsgroup-name))
9912 (entry (assoc symbol alist)))
9913 (cond ((gnus-score-get 'read-only alist)
9914 ;; This is a read-only score file, so we do nothing.
9917 (setcdr entry value))
9919 (error "Empty alist"))
9922 (cons (cons symbol value) (cdr alist)))))))
9924 (defun gnus-score-get (symbol &optional alist)
9925 ;; Get SYMBOL's definition in ALIST.
9931 (gnus-score-file-name gnus-newsgroup-name))
9932 gnus-score-alist)))))
9934 (defun gnus-score-change-score-file (file)
9935 "Change current score alist."
9937 (list (completing-read "Score file: " gnus-score-cache)))
9938 (setq gnus-current-score-file file)
9939 (gnus-score-load-file file))
9941 (defun gnus-score-edit-alist (file)
9942 "Edit the current score alist."
9943 (interactive (list gnus-current-score-file))
9944 (and (buffer-name gnus-summary-buffer) (gnus-score-save))
9945 (setq gnus-winconf-edit-score (current-window-configuration))
9946 (gnus-configure-windows 'article)
9947 (pop-to-buffer (find-file-noselect file))
9948 (message (substitute-command-keys
9949 "\\<gnus-score-mode-map>\\[gnus-score-edit-done] to save edits"))
9952 (defun gnus-score-edit-file (file)
9953 "Edit a score file."
9955 (list (read-file-name "Edit score file: " gnus-kill-files-directory)))
9956 (and (buffer-name gnus-summary-buffer) (gnus-score-save))
9957 (setq gnus-winconf-edit-score (current-window-configuration))
9958 (gnus-configure-windows 'article)
9959 (pop-to-buffer (find-file-noselect file))
9960 (message (substitute-command-keys
9961 "\\<gnus-score-mode-map>\\[gnus-score-edit-done] to save edits"))
9964 (defun gnus-score-load-file (file)
9965 ;; Load score file FILE. Returns a list a retrieved score-alists.
9966 (setq gnus-kill-files-directory (or gnus-kill-files-directory "~/News/"))
9967 (let* ((file (expand-file-name
9968 (or (and (string-match
9969 (concat "^" (expand-file-name
9970 gnus-kill-files-directory))
9971 (expand-file-name file))
9973 (concat gnus-kill-files-directory file))))
9974 (cached (assoc file gnus-score-cache))
9975 (global (member file gnus-internal-global-score-files))
9978 ;; The score file was already loaded.
9979 (setq alist (cdr cached))
9980 ;; We load the score file.
9981 (setq gnus-score-alist nil)
9982 (setq alist (gnus-score-load-score-alist file))
9983 ;; We add '(touched) to the alist to signify that it hasn't been
9985 (or (assq 'touched alist) (setq alist (cons (list 'touched nil) alist)))
9986 ;; If it is a global score file, we make it read-only.
9988 (not (assq 'read-only alist))
9989 (setq alist (cons (list 'read-only t) alist)))
9991 (setq gnus-score-cache
9992 (cons (cons file alist) gnus-score-cache)))
9993 ;; If there are actual scores in the alist, we add it to the
9994 ;; return value of this function.
9995 (if (memq t (mapcar (lambda (e) (stringp (car e))) alist))
9996 (setq lists (list alist)))
9997 ;; Treat the other possible atoms in the score alist.
9998 (let ((mark (car (gnus-score-get 'mark alist)))
9999 (expunge (car (gnus-score-get 'expunge alist)))
10001 (car (gnus-score-get 'mark-and-expunge alist)))
10002 (read-only (gnus-score-get 'read-only alist))
10003 (files (gnus-score-get 'files alist))
10004 (exclude-files (gnus-score-get 'exclude-files alist))
10005 (orphan (gnus-score-get 'orphan alist))
10006 (eval (gnus-score-get 'eval alist)))
10007 ;; We do not respect eval and files atoms from global score
10009 (and files (not global)
10010 (setq lists (apply 'append lists
10011 (mapcar (lambda (file)
10012 (gnus-score-load-file file))
10014 (and eval (not global) (eval eval))
10015 (if orphan (setq gnus-orphan-score (car orphan)))
10016 (setq gnus-summary-mark-below
10017 (or mark mark-and-expunge gnus-summary-mark-below))
10018 (setq gnus-summary-expunge-below
10019 (or expunge mark-and-expunge gnus-summary-expunge-below)))
10020 (setq gnus-current-score-file file)
10021 (setq gnus-score-alist alist)
10024 (defun gnus-score-load (file)
10025 ;; Load score FILE.
10026 (let ((cache (assoc file gnus-score-cache)))
10028 (setq gnus-score-alist (cdr cache))
10029 (setq gnus-score-alist nil)
10030 (gnus-score-load-score-alist file)
10031 (or gnus-score-alist
10032 (setq gnus-score-alist (copy-alist '((touched nil)))))
10033 (setq gnus-score-cache
10034 (cons (cons file gnus-score-alist) gnus-score-cache)))))
10036 (defun gnus-score-remove-from-cache (file)
10037 (setq gnus-score-cache
10038 (delq (assoc file gnus-score-cache) gnus-score-cache)))
10040 (defun gnus-score-load-score-alist (file)
10042 (if (file-readable-p file)
10045 (set-buffer (get-buffer-create " *gnus work*"))
10046 (buffer-disable-undo (current-buffer))
10048 (insert-file-contents file)
10049 (goto-char (point-min))
10050 ;; Only do the loading if the score file isn't empty.
10051 (if (save-excursion (re-search-forward "[()0-9a-zA-Z]" nil t))
10054 (read (current-buffer))
10057 (message "Problem with score file %s" file)
10061 (if (eq (car alist) 'setq)
10062 (setq gnus-score-alist (gnus-score-transform-old-to-new alist))
10063 (setq gnus-score-alist alist))
10064 (setq gnus-score-alist
10065 (gnus-score-check-syntax gnus-score-alist)))
10066 (setq gnus-score-alist nil))))
10068 (defun gnus-score-check-syntax (alist)
10072 ((not (consp alist))
10073 (message "Score file is not a list: %s" alist)
10079 (while (and a (not err))
10080 (cond ((not (listp (car a)))
10081 (message "Illegal score element: %s" (car a))
10083 ((and (stringp (car (car a)))
10084 (not (listp (nth 1 (car a)))))
10085 (message "Illegal header match: %s" (nth 1 (car a)))
10088 (setq a (cdr a)))))
10095 (defun gnus-score-transform-old-to-new (alist)
10096 (let* ((alist (nth 2 alist))
10098 (if (eq (car alist) 'quote)
10099 (setq alist (nth 1 alist)))
10101 (setq entry (car alist))
10102 (if (stringp (car entry))
10103 (let ((scor (cdr entry)))
10104 (setq out (cons entry out))
10107 (list (car (car scor)) (nth 2 (car scor))
10108 (and (nth 3 (car scor))
10109 (gnus-day-number (nth 3 (car scor))))
10110 (if (nth 1 (car scor)) 'r 's)))
10111 (setq scor (cdr scor))))
10112 (setq out (cons (if (not (listp (cdr entry)))
10113 (list (car entry) (cdr entry))
10116 (setq alist (cdr alist)))
10117 (cons (list 'touched t) (nreverse out))))
10119 (defun gnus-score-save ()
10120 ;; Save all SCORE information.
10121 (let ((cache gnus-score-cache))
10123 (setq gnus-score-alist nil)
10124 (set-buffer (get-buffer-create "*Score*"))
10125 (buffer-disable-undo (current-buffer))
10126 (let (entry score file)
10128 (setq entry (car cache)
10132 (if (or (not (equal (gnus-score-get 'touched score) '(t)))
10133 (gnus-score-get 'read-only score)
10134 (not (file-writable-p file)))
10136 (setq score (delq (assq 'touched score) score))
10138 (let (emacs-lisp-mode-hook)
10139 (pp score (current-buffer)))
10140 (gnus-make-directory (file-name-directory file))
10141 (write-region (point-min) (point-max) file nil 'silent))))
10142 (kill-buffer (current-buffer)))))
10144 (defun gnus-score-headers ()
10145 ;; Score `gnus-newsgroup-headers'.
10146 (let ((func gnus-score-find-score-files-function)
10147 score-files scores)
10148 (and func (not (listp func))
10149 (setq func (list func)))
10150 ;; Go through all the functions for finding score files (or actual
10151 ;; scores) and add them to a list.
10153 (and (symbolp (car func))
10154 (fboundp (car func))
10156 (nconc score-files (funcall (car func) gnus-newsgroup-name))))
10157 (setq func (cdr func)))
10158 ;; PLM: probably this is not the best place to clear orphan-score
10159 (setq gnus-orphan-score nil)
10160 ;; Load the SCORE files.
10162 (if (stringp (car score-files))
10163 (setq scores (nconc (gnus-score-load-file (car score-files)) scores))
10164 (setq scores (nconc (car score-files) scores)))
10165 (setq score-files (cdr score-files)))
10166 (if (not (and gnus-summary-default-score
10168 (> (length gnus-newsgroup-headers)
10169 (length gnus-newsgroup-scored))))
10171 (let* ((entries gnus-header-index)
10172 (now (gnus-day-number (current-time-string)))
10173 (expire (- now gnus-score-expiry-days))
10174 (headers gnus-newsgroup-headers)
10176 (message "Scoring...")
10177 ;; Create articles, an alist of the form `(HEADER . SCORE)'.
10179 (setq header (car headers)
10180 headers (cdr headers))
10181 ;; WARNING: The assq makes the function O(N*S) while it could
10182 ;; be written as O(N+S), where N is (length gnus-newsgroup-headers)
10183 ;; and S is (length gnus-newsgroup-scored).
10184 (or (assq (header-number header) gnus-newsgroup-scored)
10185 (setq gnus-scores-articles ;Total of 2 * N cons-cells used.
10186 (cons (cons header (or gnus-summary-default-score 0))
10187 gnus-scores-articles))))
10190 (set-buffer (get-buffer-create "*Headers*"))
10191 (buffer-disable-undo (current-buffer))
10193 (if gnus-orphan-score
10195 (setq gnus-score-index
10196 (nth 1 (assoc "references" gnus-header-index)))
10197 (gnus-score-orphans gnus-orphan-score)))
10198 ;; Run each header through the score process.
10200 (setq entry (car entries)
10201 header (nth 0 entry)
10202 entries (cdr entries))
10203 (setq gnus-score-index (nth 1 (assoc header gnus-header-index)))
10204 (if (< 0 (apply 'max (mapcar
10206 (length (gnus-score-get header score)))
10208 (funcall (nth 2 entry) scores header now expire)))
10209 ;; Remove the buffer.
10210 (kill-buffer (current-buffer)))
10212 ;; Add articles to `gnus-newsgroup-scored'.
10213 (while gnus-scores-articles
10214 (or (= gnus-summary-default-score (cdr (car gnus-scores-articles)))
10215 (setq gnus-newsgroup-scored
10216 (cons (cons (header-number
10217 (car (car gnus-scores-articles)))
10218 (cdr (car gnus-scores-articles)))
10219 gnus-newsgroup-scored)))
10220 (setq gnus-scores-articles (cdr gnus-scores-articles)))
10222 (message "Scoring...done")))))
10225 (defun gnus-get-new-thread-ids (articles)
10226 (let ((index (nth 1 (assoc "message-id" gnus-header-index)))
10227 (refind gnus-score-index)
10228 id-list art this tref)
10230 (setq art (car articles)
10231 this (aref (car art) index)
10232 tref (aref (car art) refind)
10233 articles (cdr articles))
10234 (if (string-equal tref "") ;no references line
10235 (setq id-list (cons this id-list))))
10238 ;; Orphan functions written by plm@atcmp.nl (Peter Mutsaers).
10239 (defun gnus-score-orphans (score)
10240 (let ((new-thread-ids (gnus-get-new-thread-ids gnus-scores-articles))
10241 (index (nth 1 (assoc "references" gnus-header-index)))
10242 alike articles art arts this last this-id)
10244 (setq gnus-scores-articles (sort gnus-scores-articles 'gnus-score-string<)
10245 articles gnus-scores-articles)
10247 ;;more or less the same as in gnus-score-string
10250 (setq art (car articles)
10251 this (aref (car art) gnus-score-index)
10252 articles (cdr articles))
10253 ;;completely skip if this is empty (not a child, so not an orphan)
10254 (if (not (string= this ""))
10255 (if (equal last this)
10256 ;; O(N*H) cons-cells used here, where H is the number of
10258 (setq alike (cons art alike))
10261 ;; Insert the line, with a text property on the
10262 ;; terminating newline refering to the articles with
10265 (put-text-property (1- (point)) (point) 'articles alike)))
10266 (setq alike (list art)
10268 (and last ; Bwadr, duplicate code.
10271 (put-text-property (1- (point)) (point) 'articles alike)))
10273 ;; PLM: now delete those lines that contain an entry from new-thread-ids
10274 (while new-thread-ids
10275 (setq this-id (car new-thread-ids)
10276 new-thread-ids (cdr new-thread-ids))
10277 (goto-char (point-min))
10278 (while (search-forward this-id nil t)
10279 ;; found a match. remove this line
10281 (beginning-of-line)
10284 ;; now for each line: update its articles with score by moving to
10285 ;; every end-of-line in the buffer and read the articles property
10286 (goto-char (point-min))
10287 (while (eq 0 (progn
10289 (setq arts (get-text-property (point) 'articles))
10291 (setq art (car arts)
10293 (setcdr art (+ score (cdr art))))
10294 (forward-line))))))
10297 (defun gnus-score-integer (scores header now expire)
10298 (let ((gnus-score-index (nth 1 (assoc header gnus-header-index)))
10299 alike last this art entries alist articles)
10303 (setq alist (car scores)
10304 scores (cdr scores)
10305 entries (assoc header alist))
10306 (while (cdr entries) ;First entry is the header index.
10307 (let* ((rest (cdr entries))
10309 (match (nth 0 kill))
10310 (type (or (nth 3 kill) '>))
10311 (score (or (nth 1 kill) gnus-score-interactive-default-score))
10312 (date (nth 2 kill))
10314 (match-func (if (or (eq type '>) (eq type '<) (eq type '<=)
10315 (eq type '>=) (eq type '=))
10317 (error "Illegal match type: %s" type)))
10318 (articles gnus-scores-articles)
10320 ;; Instead of doing all the clever stuff that
10321 ;; `gnus-score-string' does to minimize searches and stuff,
10322 ;; I will assume that people generally will put so few
10323 ;; matches on numbers that any cleverness will take more
10324 ;; time than one would gain.
10326 (and (funcall match-func match
10327 (or (aref (car (car articles)) gnus-score-index) 0))
10330 (setcdr (car articles) (+ score (cdr (car articles))))))
10331 (setq articles (cdr articles)))
10332 ;; Update expire date
10333 (cond ((null date)) ;Permanent entry.
10334 (found ;Match, update date.
10335 (gnus-score-set 'touched '(t) alist)
10336 (setcar (nthcdr 2 kill) now))
10337 ((< date expire) ;Old entry, remove.
10338 (gnus-score-set 'touched '(t) alist)
10339 (setcdr entries (cdr rest))
10340 (setq rest entries)))
10341 (setq entries rest))))))
10343 (defun gnus-score-date (scores header now expire)
10344 (let ((gnus-score-index (nth 1 (assoc header gnus-header-index)))
10345 alike last this art entries alist articles)
10349 (setq alist (car scores)
10350 scores (cdr scores)
10351 entries (assoc header alist))
10352 (while (cdr entries) ;First entry is the header index.
10353 (let* ((rest (cdr entries))
10355 (match (timezone-make-date-sortable (nth 0 kill)))
10356 (type (or (nth 3 kill) 'before))
10357 (score (or (nth 1 kill) gnus-score-interactive-default-score))
10358 (date (nth 2 kill))
10361 (cond ((eq type 'after) 'string<)
10362 ((eq type 'before) 'gnus-string>)
10363 ((eq type 'at) 'string=)
10364 (t (error "Illegal match type: %s" type))))
10365 (articles gnus-scores-articles)
10367 ;; Instead of doing all the clever stuff that
10368 ;; `gnus-score-string' does to minimize searches and stuff,
10369 ;; I will assume that people generally will put so few
10370 ;; matches on numbers that any cleverness will take more
10371 ;; time than one would gain.
10374 (setq l (aref (car (car articles)) gnus-score-index))
10375 (funcall match-func match (timezone-make-date-sortable l))
10378 (setcdr (car articles) (+ score (cdr (car articles))))))
10379 (setq articles (cdr articles)))
10380 ;; Update expire date
10381 (cond ((null date)) ;Permanent entry.
10382 (found ;Match, update date.
10383 (gnus-score-set 'touched '(t) alist)
10384 (setcar (nthcdr 2 kill) now))
10385 ((< date expire) ;Old entry, remove.
10386 (gnus-score-set 'touched '(t) alist)
10387 (setcdr entries (cdr rest))
10388 (setq rest entries)))
10389 (setq entries rest))))))
10391 (defun gnus-score-body (scores header now expire)
10393 (set-buffer nntp-server-buffer)
10395 (let* ((buffer-read-only nil)
10396 (articles gnus-scores-articles)
10397 (all-scores scores)
10398 (request-func (cond ((string= "head" (downcase header))
10399 'gnus-request-head)
10400 ((string= "body" (downcase header))
10401 'gnus-request-body)
10402 (t 'gnus-request-article)))
10403 alike last this art entries alist ofunc article)
10404 ;; Not all backends support partial fetching. In that case,
10405 ;; we just fetch the entire article.
10406 (or (gnus-check-backend-function request-func gnus-newsgroup-name)
10408 (setq ofunc request-func)
10409 (setq request-func 'gnus-request-article)))
10411 (setq article (header-number (car (car articles))))
10412 (message "Scoring on article %s..." article)
10413 (if (not (funcall request-func article gnus-newsgroup-name))
10416 (goto-char (point-min))
10417 ;; If just parts of the article is to be searched, but the
10418 ;; backend didn't support partial fetching, we just narrow
10419 ;; to the relevant parts.
10421 (if (eq ofunc 'gnus-request-head)
10424 (or (search-forward "\n\n" nil t) (point-max)))
10426 (or (search-forward "\n\n" nil t) (point))
10428 (setq scores all-scores)
10431 (setq alist (car scores)
10432 scores (cdr scores)
10433 entries (assoc header alist))
10434 (while (cdr entries) ;First entry is the header index.
10435 (let* ((rest (cdr entries))
10437 (match (nth 0 kill))
10438 (type (or (nth 3 kill) 's))
10439 (score (or (nth 1 kill)
10440 gnus-score-interactive-default-score))
10441 (date (nth 2 kill))
10444 (not (or (eq type 'R) (eq type 'S)
10445 (eq type 'Regexp) (eq type 'String))))
10447 (cond ((or (eq type 'r) (eq type 'R)
10448 (eq type 'regexp) (eq type 'Regexp))
10449 're-search-forward)
10450 ((or (eq type 's) (eq type 'S)
10451 (eq type 'string) (eq type 'String))
10454 (error "Illegal match type: %s" type))))
10456 (goto-char (point-min))
10457 (if (funcall search-func match nil t)
10458 ;; Found a match, update scores.
10460 (setcdr (car articles) (+ score (cdr (car articles))))
10462 ;; Update expire date
10463 (cond ((null date)) ;Permanent entry.
10464 (found ;Match, update date.
10465 (gnus-score-set 'touched '(t) alist)
10466 (setcar (nthcdr 2 kill) now))
10467 ((< date expire) ;Old entry, remove.
10468 (gnus-score-set 'touched '(t) alist)
10469 (setcdr entries (cdr rest))
10470 (setq rest entries)))
10471 (setq entries rest)))))
10472 (setq articles (cdr articles)))))))
10474 (defun gnus-score-string (scores header now expire)
10475 ;; Score ARTICLES according to HEADER in SCORES.
10476 ;; Update matches entries to NOW and remove unmatched entried older
10479 ;; Insert the unique article headers in the buffer.
10480 (let ((gnus-score-index (nth 1 (assoc header gnus-header-index)))
10481 ;; gnus-score-index is used as a free variable.
10482 alike last this art entries alist articles)
10484 ;; Sorting the articles costs os O(N*log N) but will allow us to
10485 ;; only match with each unique header. Thus the actual matching
10486 ;; will be O(M*U) where M is the number of strings to match with,
10487 ;; and U is the number of unique headers. It is assumed (but
10488 ;; untested) this will be a net win because of the large constant
10489 ;; factor involved with string matching.
10490 (setq gnus-scores-articles (sort gnus-scores-articles 'gnus-score-string<)
10491 articles gnus-scores-articles)
10495 (setq art (car articles)
10496 this (aref (car art) gnus-score-index)
10497 articles (cdr articles))
10498 (if (equal last this)
10499 ;; O(N*H) cons-cells used here, where H is the number of
10501 (setq alike (cons art alike))
10504 ;; Insert the line, with a text property on the
10505 ;; terminating newline refering to the articles with
10508 (put-text-property (1- (point)) (point) 'articles alike)))
10509 (setq alike (list art)
10511 (and last ; Bwadr, duplicate code.
10514 (put-text-property (1- (point)) (point) 'articles alike)))
10518 (setq alist (car scores)
10519 scores (cdr scores)
10520 entries (assoc header alist))
10521 (while (cdr entries) ;First entry is the header index.
10522 (let* ((rest (cdr entries))
10524 (match (nth 0 kill))
10525 (type (or (nth 3 kill) 's))
10526 (score (or (nth 1 kill) gnus-score-interactive-default-score))
10527 (date (nth 2 kill))
10530 (not (or (eq type 'R) (eq type 'S)
10531 (eq type 'Regexp) (eq type 'String))))
10532 (search-func (cond ((or (eq type 'r) (eq type 'R)
10533 (eq type 'regexp) (eq type 'Regexp))
10534 're-search-forward)
10535 ((or (eq type 's) (eq type 'S)
10536 (eq type 'string) (eq type 'String))
10539 (error "Illegal match type: %s" type))))
10541 (goto-char (point-min))
10542 (while (funcall search-func match nil t)
10545 arts (get-text-property (point) 'articles))
10546 ;; Found a match, update scores.
10548 (setq art (car arts)
10550 (setcdr art (+ score (cdr art)))))
10551 ;; Update expire date
10552 (cond ((null date)) ;Permanent entry.
10553 (found ;Match, update date.
10554 (gnus-score-set 'touched '(t) alist)
10555 (setcar (nthcdr 2 kill) now))
10556 ((< date expire) ;Old entry, remove.
10557 (gnus-score-set 'touched '(t) alist)
10558 (setcdr entries (cdr rest))
10559 (setq rest entries)))
10560 (setq entries rest))))))
10562 (defun gnus-score-string< (a1 a2)
10563 ;; Compare headers in articles A2 and A2.
10564 ;; The header index used is the free variable `gnus-score-index'.
10565 (string-lessp (aref (car a1) gnus-score-index)
10566 (aref (car a2) gnus-score-index)))
10568 (defun gnus-score-build-cons (article)
10569 ;; Build a `gnus-newsgroup-scored' type cons from ARTICLE.
10570 (cons (header-number (car article)) (cdr article)))
10572 (defconst gnus-header-index
10573 ;; Name to index alist.
10574 '(("number" 0 gnus-score-integer)
10575 ("subject" 1 gnus-score-string)
10576 ("from" 2 gnus-score-string)
10577 ("date" 3 gnus-score-date)
10578 ("message-id" 4 gnus-score-string)
10579 ("references" 5 gnus-score-string)
10580 ("chars" 6 gnus-score-integer)
10581 ("lines" 7 gnus-score-integer)
10582 ("xref" 8 gnus-score-string)
10583 ("head" -1 gnus-score-body)
10584 ("body" -1 gnus-score-body)
10585 ("all" -1 gnus-score-body)))
10587 (defun gnus-score-file-name (newsgroup)
10588 "Return the name of a score file for NEWSGROUP."
10589 (cond ((or (null newsgroup)
10590 (string-equal newsgroup ""))
10591 ;; The global score file is placed at top of the directory.
10592 (expand-file-name gnus-score-file-suffix
10593 (or gnus-kill-files-directory "~/News")))
10594 ((gnus-use-long-file-name 'not-score)
10595 ;; Append ".SCORE" to newsgroup name.
10596 (expand-file-name (concat newsgroup "." gnus-score-file-suffix)
10597 (or gnus-kill-files-directory "~/News")))
10599 ;; Place "SCORE" under the hierarchical directory.
10600 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
10601 "/" gnus-score-file-suffix)
10602 (or gnus-kill-files-directory "~/News")))))
10604 (defun gnus-score-score-files (group)
10605 "Return a list of all possible score files."
10606 (and gnus-global-score-files
10607 (or gnus-internal-global-score-files
10608 (gnus-score-search-global-directories gnus-global-score-files)))
10609 (setq gnus-kill-files-directory
10610 (file-name-as-directory
10611 (or gnus-kill-files-directory "~/News/")))
10612 (if (not (file-readable-p gnus-kill-files-directory))
10613 (setq gnus-score-file-list nil)
10614 (if (gnus-use-long-file-name 'not-score)
10615 (if (or (not gnus-score-file-list)
10616 (gnus-file-newer-than gnus-kill-files-directory
10617 (car gnus-score-file-list)))
10618 (setq gnus-score-file-list
10619 (cons (nth 5 (file-attributes gnus-kill-files-directory))
10622 gnus-kill-files-directory t
10623 (concat gnus-score-file-suffix "$"))))))
10624 (let ((dir (expand-file-name
10625 (concat gnus-kill-files-directory
10626 (gnus-replace-chars-in-string group ?. ?/))))
10627 (mdir (length (expand-file-name gnus-kill-files-directory)))
10629 (if (file-exists-p (concat dir "/" gnus-score-file-suffix))
10630 (setq files (list (concat dir "/" gnus-score-file-suffix))))
10631 (while (>= (1+ (length dir)) mdir)
10632 (and (file-exists-p (concat dir "/all/" gnus-score-file-suffix))
10633 (setq files (cons (concat dir "/all/" gnus-score-file-suffix)
10635 (string-match "/[^/]*$" dir)
10636 (setq dir (substring dir 0 (match-beginning 0))))
10637 (setq gnus-score-file-list
10638 (cons nil (nreverse files)))))
10639 (cdr gnus-score-file-list)))
10641 (defun gnus-score-find-single (group)
10642 "Return list containing the score file for GROUP."
10643 (list (gnus-score-file-name group)))
10645 (defun gnus-score-find-hierarchical (group)
10646 "Return list of score files for GROUP.
10647 This includes the score file for the group and all its parents."
10648 (let ((all (copy-sequence '(nil)))
10650 (while (string-match "\\." group (1+ start))
10651 (setq start (match-beginning 0))
10652 (setq all (cons (substring group 0 start) all)))
10653 (setq all (cons group all))
10654 (mapcar 'gnus-score-file-name (nreverse all))))
10656 (defun gnus-score-find-bnews (group)
10657 "Return a list of score files for GROUP.
10658 The score files are those files in the ~/News directory which matches
10659 GROUP using BNews sys file syntax."
10660 (let* ((sfiles (append (gnus-score-score-files group)
10661 gnus-internal-global-score-files))
10662 (kill-dir (file-name-as-directory
10663 (expand-file-name gnus-kill-files-directory)))
10664 (klen (length kill-dir))
10665 ofiles not-match regexp)
10667 (set-buffer (get-buffer-create "*gnus score files*"))
10668 (buffer-disable-undo (current-buffer))
10669 ;; Go through all score file names and create regexp with them
10673 (insert (car sfiles))
10675 ;; First remove the suffix itself.
10676 (re-search-forward (concat "." gnus-score-file-suffix "$"))
10679 (if (looking-at (regexp-quote kill-dir))
10680 ;; If the file name was just "SCORE", `klen' is one character
10682 (delete-char (min (1- (point-max)) klen))
10683 (goto-char (point-max))
10684 (search-backward "/")
10685 (delete-region (1+ (point)) (point-min)))
10686 ;; Translate "all" to ".*".
10687 (while (search-forward "all" nil t)
10688 (replace-match ".*"))
10690 ;; Deal with "not."s.
10691 (if (looking-at "not.")
10694 (setq regexp (buffer-substring 5 (point-max))))
10695 (setq regexp (buffer-substring 1 (point-max)))
10696 (setq not-match nil))
10697 ;; Finally - if this resulting regexp matches the group name,
10698 ;; we add this score file to the list of score files
10699 ;; applicable to this group.
10700 (if (or (and not-match
10701 (not (string-match regexp group)))
10702 (and (not not-match)
10703 (string-match regexp group)))
10704 (setq ofiles (cons (car sfiles) ofiles)))
10705 (setq sfiles (cdr sfiles)))
10706 (kill-buffer (current-buffer))
10707 ;; Slight kludge here - the last score file returned should be
10708 ;; the local score file, whether it exists or not. This is so
10709 ;; that any score commands the user enters will go to the right
10710 ;; file, and not end up in some global score file.
10713 (if (gnus-use-long-file-name 'not-score)
10714 (concat gnus-kill-files-directory group "."
10715 gnus-score-file-suffix)
10716 (concat gnus-kill-files-directory
10717 (gnus-replace-chars-in-string group ?. ?/)
10718 "/" gnus-score-file-suffix)))))
10719 (and (member localscore ofiles)
10720 (delete localscore ofiles))
10721 (setq ofiles (cons localscore ofiles)))
10722 (nreverse ofiles))))
10724 (defun gnus-score-search-global-directories (files)
10725 "Scan all global score directories for score files."
10726 ;; Set the variable `gnus-internal-global-score-files' to all
10727 ;; available global score files.
10728 (interactive (list gnus-global-score-files))
10731 (if (string-match "/$" (car files))
10732 (setq out (nconc (directory-files
10734 (concat gnus-score-file-suffix "$"))))
10735 (setq out (cons (car files) out)))
10736 (setq files (cdr files)))
10737 (setq gnus-internal-global-score-files out)))
10743 (defvar gnus-score-mode-map nil)
10744 (defvar gnus-score-mode-hook nil)
10746 (if gnus-score-mode-map
10748 (setq gnus-score-mode-map (copy-keymap emacs-lisp-mode-map))
10749 (define-key gnus-score-mode-map "\C-c\C-c" 'gnus-score-edit-done)
10750 (define-key gnus-score-mode-map "\C-c\C-d" 'gnus-score-edit-insert-date))
10752 (defun gnus-score-mode ()
10753 "Mode for editing score files.
10754 This mode is an extended emacs-lisp mode.
10756 \\{gnus-score-mode-map}"
10758 (kill-all-local-variables)
10759 (use-local-map gnus-score-mode-map)
10760 (set-syntax-table emacs-lisp-mode-syntax-table)
10761 (setq major-mode 'gnus-score-mode)
10762 (setq mode-name "Score")
10763 (lisp-mode-variables nil)
10764 (run-hooks 'emacs-lisp-mode-hook 'gnus-score-mode-hook))
10766 (defun gnus-score-edit-insert-date ()
10767 "Insert date in numerical format."
10769 (insert (int-to-string (gnus-day-number (current-time-string)))))
10771 (defun gnus-score-edit-done ()
10772 "Save the score file and return to the summary buffer."
10774 (let ((bufnam (buffer-file-name (current-buffer))))
10776 (kill-buffer (current-buffer))
10777 (and gnus-winconf-edit-score
10778 (set-window-configuration gnus-winconf-edit-score))
10779 (gnus-score-remove-from-cache bufnam)
10780 (gnus-score-load-file bufnam)))
10784 ;;; Gnus Posting Functions
10787 (defvar gnus-organization-file "/usr/lib/news/organization"
10788 "*Local news organization file.")
10790 (defvar gnus-post-news-buffer "*post-news*")
10791 (defvar gnus-winconf-post-news nil)
10793 ;;; Post news commands of Gnus group mode and summary mode
10795 (defun gnus-group-post-news ()
10798 (gnus-set-global-variables)
10799 ;; Save window configuration.
10800 (setq gnus-winconf-post-news (current-window-configuration))
10801 (let ((gnus-newsgroup-name nil))
10803 (gnus-post-news 'post)
10804 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
10805 (not (zerop (buffer-size))))
10806 ;; Restore last window configuration.
10807 (and gnus-winconf-post-news
10808 (set-window-configuration gnus-winconf-post-news)))))
10809 ;; We don't want to return to summary buffer nor article buffer later.
10810 (setq gnus-winconf-post-news nil)
10811 (if (get-buffer gnus-summary-buffer)
10812 (bury-buffer gnus-summary-buffer))
10813 (if (get-buffer gnus-article-buffer)
10814 (bury-buffer gnus-article-buffer)))
10816 (defun gnus-summary-post-news ()
10819 (gnus-set-global-variables)
10820 ;; Save window configuration.
10821 (setq gnus-winconf-post-news (current-window-configuration))
10823 (gnus-post-news 'post gnus-newsgroup-name)
10824 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
10825 (not (zerop (buffer-size))))
10826 ;; Restore last window configuration.
10827 (and gnus-winconf-post-news
10828 (set-window-configuration gnus-winconf-post-news))))
10829 ;; We don't want to return to article buffer later.
10830 (if (get-buffer gnus-article-buffer)
10831 (bury-buffer gnus-article-buffer)))
10833 (defun gnus-summary-followup (yank)
10834 "Compose a followup to an article.
10835 If prefix argument YANK is non-nil, original article is yanked automatically."
10837 (gnus-set-global-variables)
10838 (save-window-excursion
10839 (gnus-summary-select-article t))
10840 (let ((headers gnus-current-headers)
10841 (gnus-newsgroup-name gnus-newsgroup-name))
10842 ;; Check Followup-To: poster.
10843 (set-buffer gnus-article-buffer)
10844 (if (and gnus-use-followup-to
10845 (string-equal "poster" (gnus-fetch-field "followup-to"))
10846 (or (not (eq gnus-use-followup-to t))
10847 (not (gnus-y-or-n-p
10848 "Do you want to ignore `Followup-To: poster'? "))))
10849 ;; Mail to the poster. Gnus is now RFC1036 compliant.
10850 (gnus-summary-reply yank)
10851 ;; Save window configuration.
10852 (setq gnus-winconf-post-news (current-window-configuration))
10854 (gnus-post-news nil gnus-newsgroup-name
10855 headers gnus-article-buffer yank)
10856 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
10857 (not (zerop (buffer-size))))
10858 ;; Restore last window configuration.
10859 (and gnus-winconf-post-news
10860 (set-window-configuration gnus-winconf-post-news))))
10861 ;; We don't want to return to article buffer later.
10862 (bury-buffer gnus-article-buffer)))
10863 (gnus-article-hide-headers-if-wanted))
10865 (defun gnus-summary-followup-with-original ()
10866 "Compose a followup to an article and include the original article."
10868 (gnus-summary-followup t))
10870 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10871 (defun gnus-summary-followup-and-reply (yank)
10872 "Compose a followup and do an auto mail to author."
10874 (let ((gnus-auto-mail-to-author t))
10875 (gnus-summary-followup yank)))
10877 (defun gnus-summary-followup-and-reply-with-original ()
10878 "Compose a followup, include the original, and do an auto mail to author."
10880 (gnus-summary-followup-and-reply t))
10882 (defun gnus-summary-cancel-article ()
10883 "Cancel an article you posted."
10885 (gnus-set-global-variables)
10886 (gnus-summary-select-article t)
10887 (gnus-eval-in-buffer-window gnus-article-buffer (gnus-cancel-news))
10888 (gnus-article-hide-headers-if-wanted))
10890 (defun gnus-summary-supersede-article ()
10891 "Compose an article that will supersede a previous article.
10892 This is done simply by taking the old article and adding a Supersedes
10893 header line with the old Message-ID."
10895 (gnus-set-global-variables)
10898 (downcase (mail-strip-quoted-names
10899 (header-from gnus-current-headers)))
10900 (downcase (mail-strip-quoted-names (gnus-inews-user-name)))))
10901 (error "This article is not yours."))
10902 (gnus-summary-select-article t)
10904 (set-buffer gnus-article-buffer)
10905 (let ((buffer-read-only nil))
10906 (goto-char (point-min))
10907 (search-forward "\n\n" nil t)
10908 (if (not (re-search-backward "^Message-ID: " nil t))
10909 (error "No Message-ID in this article"))))
10910 (if (gnus-post-news 'post gnus-newsgroup-name)
10913 (insert-buffer gnus-article-buffer)
10914 (goto-char (point-min))
10915 (search-forward "\n\n" nil t)
10916 (if (not (re-search-backward "^Message-ID: " nil t))
10917 (error "No Message-ID in this article")
10918 (replace-match "Supersedes: "))
10919 (search-forward "\n\n")
10921 (insert mail-header-separator))))
10925 (fset 'sendnews 'gnus-post-news)
10928 (fset 'postnews 'gnus-post-news)
10930 (defun gnus-post-news (post &optional group header article-buffer yank)
10931 "Begin editing a new USENET news article to be posted.
10932 Type \\[describe-mode] in the buffer to get a list of commands."
10933 (interactive (list t))
10934 (if (or (not gnus-novice-user)
10938 (format "%s" (car (gnus-find-method-for-group
10939 gnus-newsgroup-name)))
10940 gnus-valid-select-methods))))
10941 (assq 'to-address (gnus-find-method-for-group gnus-newsgroup-name))
10942 (gnus-y-or-n-p "Are you sure you want to post to all of USENET? "))
10943 (let ((sumart (if (not post)
10945 (set-buffer gnus-summary-buffer)
10946 (cons (current-buffer) gnus-current-article))))
10947 (from (and header (header-from header)))
10948 subject follow-to real-group)
10949 (and gnus-interactive-post
10950 (not gnus-expert-user)
10954 (completing-read "Group: " gnus-active-hashtb nil t))
10955 (setq subject (read-string "Subject: "))))
10956 (setq mail-reply-buffer article-buffer)
10958 (let ((gnus-newsgroup-name (or group gnus-newsgroup-name "")))
10959 (setq real-group (and group (gnus-group-real-name group)))
10960 (setq gnus-post-news-buffer
10961 (gnus-request-post-buffer
10962 post real-group subject header article-buffer
10963 (nth 2 (and group (gnus-gethash group gnus-newsrc-hashtb)))
10964 (if (and (boundp 'gnus-followup-to-function)
10965 gnus-followup-to-function)
10968 (set-buffer article-buffer)
10969 (funcall gnus-followup-to-function group))))
10970 (eq gnus-use-followup-to t)))
10973 (gnus-configure-windows '(1 0 0))
10974 (switch-to-buffer gnus-post-news-buffer))
10975 (gnus-configure-windows '(0 1 0))
10978 (switch-to-buffer article-buffer)
10979 (pop-to-buffer gnus-post-news-buffer))
10980 (switch-to-buffer gnus-post-news-buffer)))
10981 (gnus-overload-functions)
10982 (make-local-variable 'gnus-article-reply)
10983 (make-local-variable 'gnus-article-check-size)
10984 (setq gnus-article-reply sumart)
10985 ;; Handle `gnus-auto-mail-to-author'.
10986 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10987 (let ((to (if (eq gnus-auto-mail-to-author 'ask)
10988 (and (y-or-n-p "Also send mail to author? ") from)
10989 (and gnus-auto-mail-to-author from))))
10992 (if (mail-fetch-field "To")
10994 (beginning-of-line)
10995 (insert "Cc: " to "\n"))
10996 (mail-position-on-field "To")
10998 ;; Handle author copy using BCC field.
10999 (if (and gnus-mail-self-blind
11000 (not (mail-fetch-field "bcc")))
11002 (mail-position-on-field "Bcc")
11003 (insert (if (stringp gnus-mail-self-blind)
11004 gnus-mail-self-blind
11005 (user-login-name)))))
11006 ;; Handle author copy using FCC field.
11007 (if gnus-author-copy
11009 (mail-position-on-field "Fcc")
11010 (insert gnus-author-copy)))
11011 (goto-char (point-min))
11014 (re-search-forward "^Newsgroup:" nil t)
11017 (re-search-forward "^Subject:" nil t)
11021 (concat "^" (regexp-quote mail-header-separator) "$"))
11024 (concat "^" (regexp-quote mail-header-separator) "$"))
11028 (run-hooks 'news-reply-header-hook)
11029 (mail-yank-original nil)))
11030 (if gnus-post-prepare-function
11031 (funcall gnus-post-prepare-function group))))))
11032 (setq gnus-article-check-size (cons (buffer-size) (gnus-article-checksum)))
11036 (defun gnus-inews-news (&optional use-group-method)
11037 "Send a news message.
11038 If given a prefix, and the group is a foreign group, this function
11039 will attempt to use the foreign server to post the article."
11041 ;; Check whether the article is a good Net Citizen.
11042 (if (and gnus-article-check-size (not (gnus-inews-check-post)))
11045 ;; Looks ok, so we do the nasty.
11046 (let* ((case-fold-search nil)
11047 (server-running (gnus-server-opened gnus-select-method))
11048 (reply gnus-article-reply))
11050 ;; Connect to default NNTP server if necessary.
11051 ;; Suggested by yuki@flab.fujitsu.junet.
11052 (gnus-start-news-server) ;Use default server.
11053 ;; NNTP server must be opened before current buffer is modified.
11055 (goto-char (point-min))
11056 (run-hooks 'news-inews-hook)
11061 (goto-char (point-min))
11063 (concat "^" (regexp-quote mail-header-separator) "$"))))
11065 ;; Correct newsgroups field: change sequence of spaces to comma and
11066 ;; eliminate spaces around commas. Eliminate imbedded line breaks.
11067 (goto-char (point-min))
11068 (if (search-forward-regexp "^Newsgroups: +" nil t)
11072 (if (re-search-forward "^[^ \t]" nil 'end)
11073 (match-beginning 0)
11075 (goto-char (point-min))
11076 (replace-regexp "\n[ \t]+" " ") ;No line breaks (too confusing)
11077 (goto-char (point-min))
11078 (replace-regexp "[ \t\n]*,[ \t\n]*\\|[ \t]+" ",")))
11080 ;; Added by Per Abrahamsen <abraham@iesd.auc.dk>.
11081 ;; Help save the the world!
11084 (let ((newsgroups (mail-fetch-field "newsgroups"))
11085 (followup-to (mail-fetch-field "followup-to"))
11087 (if (and (string-match "," newsgroups) (not followup-to))
11089 (while (string-match "," newsgroups)
11091 (cons (list (substring newsgroups
11092 0 (match-beginning 0)))
11094 (setq newsgroups (substring newsgroups (match-end 0))))
11095 (setq groups (nreverse (cons (list newsgroups) groups)))
11098 (completing-read "Followups to: (default all groups) "
11100 (if (> (length to) 0)
11102 (goto-char (point-min))
11103 (insert "Followup-To: " to "\n")))))))
11105 ;; Cleanup Followup-To.
11106 (goto-char (point-min))
11107 (if (search-forward-regexp "^Followup-To: +" nil t)
11111 (if (re-search-forward "^[^ \t]" nil 'end)
11112 (match-beginning 0)
11114 (goto-char (point-min))
11115 (replace-regexp "\n[ \t]+" " ") ;No line breaks (too confusing)
11116 (goto-char (point-min))
11117 (replace-regexp "[ \t\n]*,[ \t\n]*\\|[ \t]+" ",")))
11119 ;; Mail the message too if To:, Bcc:. or Cc: exists.
11120 (if (or (mail-fetch-field "to" nil t)
11121 (mail-fetch-field "bcc" nil t)
11122 (mail-fetch-field "cc" nil t))
11123 (if gnus-mail-send-method
11127 (message "Sending via mail...")
11129 (if gnus-mail-courtesy-message
11131 ;; Insert "courtesy" mail message.
11134 (concat "^" (regexp-quote
11135 mail-header-separator) "$"))
11137 (insert gnus-mail-courtesy-message)
11138 (funcall gnus-mail-send-method)
11140 (search-forward gnus-mail-courtesy-message)
11141 (replace-match ""))
11142 (funcall gnus-mail-send-method))
11144 (message "Sending via mail... done")
11148 1 (re-search-forward
11149 (concat "^" (regexp-quote
11150 mail-header-separator) "$")))
11152 (delete-matching-lines "BCC:.*")))
11154 (message "No mailer defined. To: and/or Cc: fields ignored.")
11157 ;; Send to NNTP server.
11158 (message "Posting to USENET...")
11159 (if (gnus-inews-article use-group-method)
11161 (message "Posting to USENET... done")
11163 (get-buffer (car reply))
11164 (buffer-name (car reply)))
11167 (set-buffer gnus-summary-buffer)
11168 (gnus-summary-mark-article-as-replied
11170 ;; We cannot signal an error.
11171 (ding) (message "Article rejected: %s"
11172 (gnus-status-message gnus-select-method)))
11173 (set-buffer-modified-p nil))
11174 ;; If NNTP server is opened by gnus-inews-news, close it by myself.
11176 (gnus-close-server (gnus-find-method-for-group gnus-newsgroup-name)))
11177 (and (fboundp 'bury-buffer) (bury-buffer))
11178 ;; Restore last window configuration.
11179 (and gnus-winconf-post-news
11180 (set-window-configuration gnus-winconf-post-news))
11181 (setq gnus-winconf-post-news nil))))
11183 (defun gnus-inews-check-post ()
11184 "Check whether the post looks ok."
11186 ;; Check excessive size.
11187 (if (> (buffer-size) 60000)
11188 (gnus-y-or-n-p (format "The article is %d octets long. Really post? "
11191 ;; Check for commands in Subject.
11194 (goto-char (point-min))
11198 (concat "^" (regexp-quote mail-header-separator) "$")))
11199 (if (string-match "^cmsg " (mail-fetch-field "subject"))
11201 "The control code \"cmsg \" is in the subject. Really post? ")
11203 ;; Check for control characters.
11205 (if (re-search-forward "[\000-\007\013\015-\037\200-\237]" nil t)
11207 "The article contains control characters. Really post? ")
11209 ;; Check for multiple identical headers.
11213 (goto-char (point-min))
11217 (concat "^" (regexp-quote mail-header-separator) "$")))
11218 (goto-char (point-min))
11219 (while (and (not found) (re-search-forward "^[^ \t:]+: " nil t))
11221 (or (re-search-forward
11222 (concat "^" (setq found
11223 (buffer-substring (match-beginning 0)
11226 (setq found nil))))
11229 (format "Multiple %s headers. Really post? " found))
11231 ;; Check for version and sendsys.
11234 (goto-char (point-min))
11238 (concat "^" (regexp-quote mail-header-separator) "$")))
11239 (if (re-search-backward "^Sendsys:\\|^Version:" nil t)
11241 (format "The article contains a %s command. Really post? "
11242 (buffer-substring (match-beginning 0) (match-end 0))))
11244 ;; Check the From header.
11247 (goto-char (point-min))
11251 (concat "^" (regexp-quote mail-header-separator) "$")))
11252 (let* ((case-fold-search t)
11253 (from (mail-fetch-field "from")))
11255 (string-match "@" from)
11256 (not (string-match "@[^\\.]*\\." from)))
11258 (format "The domain looks strange: \"%s\". Really post? "
11261 ;; Check for long lines.
11264 (goto-char (point-min))
11268 (concat "^" (regexp-quote mail-header-separator) "$")))
11273 (< (current-column) 80))
11274 (zerop (forward-line 1))))
11278 "You have lines longer than 79 characters. Really post? ")))))
11279 ;; Use the (size . checksum) variable to see whether the
11280 ;; article is empty or has only quoted text.
11281 (if (and (= (buffer-size) (car gnus-article-check-size))
11282 (= (gnus-article-checksum) (cdr gnus-article-check-size)))
11284 "It looks like there's no new text in your article. Really post? ")
11287 (defun gnus-article-checksum ()
11290 (while (not (eobp))
11291 (setq sum (logxor sum (following-char)))
11295 (defun gnus-cancel-news ()
11296 "Cancel an article you posted."
11298 (if (gnus-yes-or-no-p "Do you really want to cancel this article? ")
11302 (distribution nil))
11304 ;; Get header info. from original article.
11306 (gnus-article-show-all-headers)
11307 (goto-char (point-min))
11308 (search-forward "\n\n" nil 'move)
11309 (narrow-to-region (point-min) (point))
11310 (setq from (mail-fetch-field "from"))
11311 (setq newsgroups (mail-fetch-field "newsgroups"))
11312 (setq message-id (mail-fetch-field "message-id"))
11313 (setq distribution (mail-fetch-field "distribution")))
11314 ;; Verify if the article is absolutely user's by comparing
11315 ;; user id with value of its From: field.
11318 (downcase (mail-strip-quoted-names from))
11319 (downcase (mail-strip-quoted-names (gnus-inews-user-name)))))
11321 (ding) (message "This article is not yours."))
11322 ;; Make control article.
11323 (set-buffer (get-buffer-create " *Gnus-canceling*"))
11324 (buffer-disable-undo (current-buffer))
11326 (insert "Newsgroups: " newsgroups "\n"
11327 "Subject: cancel " message-id "\n"
11328 "Control: cancel " message-id "\n"
11329 mail-header-separator "\n"
11330 "This is a cancel message from " from ".\n")
11331 ;; Send the control article to NNTP server.
11332 (message "Canceling your article...")
11333 (if (gnus-inews-article)
11334 (message "Canceling your article... done")
11335 (ding) (message "Failed to cancel your article"))
11336 ;; Kill the article buffer.
11337 (kill-buffer (current-buffer)))))))
11340 ;;; Lowlevel inews interface
11342 (defun gnus-inews-article (&optional use-group-method)
11343 "Post an article in current buffer using NNTP protocol."
11344 (let ((artbuf (current-buffer))
11345 (tmpbuf (get-buffer-create " *Gnus-posting*")))
11347 (goto-char (point-max))
11348 ;; require a newline at the end for inews to append .signature to
11349 (or (= (preceding-char) ?\n)
11351 ;; Prepare article headers. All message body such as signature
11352 ;; must be inserted before Lines: field is prepared.
11354 (goto-char (point-min))
11359 (concat "^" (regexp-quote mail-header-separator) "$"))
11360 (match-beginning 0)))
11361 (gnus-inews-insert-headers)
11362 (run-hooks gnus-inews-article-header-hook)
11365 (set-buffer tmpbuf)
11366 (buffer-disable-undo (current-buffer))
11368 (insert-buffer-substring artbuf)
11369 ;; Remove the header separator.
11370 (goto-char (point-min))
11372 (concat "^" (regexp-quote mail-header-separator) "$"))
11373 (replace-match "\n\n")
11374 ;; This hook may insert a signature.
11375 (run-hooks 'gnus-prepare-article-hook)
11376 ;; Run final inews hooks. This hook may do FCC.
11377 ;; The article must be saved before being posted because
11378 ;; `gnus-request-post' modifies the buffer.
11379 (run-hooks 'gnus-inews-article-hook)
11380 ;; Post an article to NNTP server.
11381 ;; Return NIL if post failed.
11384 (if use-group-method
11385 (gnus-find-method-for-group gnus-newsgroup-name)
11386 gnus-select-method) use-group-method)
11387 (kill-buffer (current-buffer))))))
11389 (defun gnus-inews-insert-headers ()
11390 "Prepare article headers.
11391 Headers already prepared in the buffer are not modified.
11392 Headers in `gnus-required-headers' will be generated."
11393 (let ((Date (gnus-inews-date))
11394 (Message-ID (gnus-inews-message-id))
11395 (Organization (gnus-inews-organization))
11396 (From (gnus-inews-user-name))
11397 (Path (gnus-inews-path))
11401 (Lines (gnus-inews-lines))
11402 (X-Newsreader gnus-version)
11403 (headers gnus-required-headers)
11404 (case-fold-search t)
11406 ;; First we remove any old Message-IDs. This might be slightly
11407 ;; fascist, but if the user really wants to generate Message-IDs
11408 ;; by herself, she should remove it from the `gnus-required-list'.
11409 (goto-char (point-min))
11410 (and (memq 'Message-ID headers)
11411 (re-search-forward "^Message-ID:" nil t)
11412 (delete-region (progn (beginning-of-line) (point))
11413 (progn (forward-line 1) (point))))
11414 ;; Remove NNTP-posting-host.
11415 (goto-char (point-min))
11416 (and (re-search-forward "nntp-posting-host^:" nil t)
11417 (delete-region (progn (beginning-of-line) (point))
11418 (progn (forward-line 1) (point))))
11419 ;; Insert new Sender if the From is strange.
11420 (let ((from (mail-fetch-field "from")))
11421 (if (and from (not (string= (downcase from) (downcase From))))
11423 (goto-char (point-min))
11424 (and (re-search-forward "^Sender:" nil t)
11425 (delete-region (progn (beginning-of-line) (point))
11426 (progn (forward-line 1) (point))))
11427 (insert "Sender: " From "\n"))))
11428 ;; If there are References, and no "Re: ", then the thread has
11429 ;; changed name. See Son-of-1036.
11430 (if (and (mail-fetch-field "references")
11431 (get-buffer gnus-article-buffer))
11432 (let ((psubject (gnus-simplify-subject-re
11433 (mail-fetch-field "subject")))
11436 (set-buffer (get-buffer gnus-article-buffer))
11438 (gnus-narrow-to-headers)
11439 (if (setq subject (mail-fetch-field "subject"))
11441 (and gnus-summary-gather-subject-limit
11442 (numberp gnus-summary-gather-subject-limit)
11443 (> (length subject) gnus-summary-gather-subject-limit)
11445 (substring subject 0
11446 gnus-summary-gather-subject-limit)))
11447 (setq subject (gnus-simplify-subject-re subject))))))
11448 (or (and psubject subject (string= subject psubject))
11450 (string-match "@" Message-ID)
11452 (concat (substring Message-ID 0 (match-beginning 0))
11454 (substring Message-ID (match-beginning 0))))))))
11455 ;; Go through all the required headers and see if they are in the
11456 ;; articles already. If they are not, or are empty, they are
11457 ;; inserted automatically - except for Subject, Newsgroups and
11460 (goto-char (point-min))
11461 (setq header (car headers))
11462 (if (or (not (re-search-forward
11463 (concat "^" (downcase (symbol-name header)) ":") nil t))
11465 (if (= (following-char) ? ) (forward-char 1) (insert " "))
11466 (looking-at "[ \t]*$")))
11468 (setq value (or (and (boundp header) (symbol-value header))
11469 (read-from-minibuffer
11470 (format "Empty header for %s; enter value: "
11474 (goto-char (point-max))
11475 (insert (symbol-name header) ": " value "\n"))
11476 (replace-match value))))
11477 (setq headers (cdr headers)))))
11479 (defun gnus-inews-insert-signature ()
11480 "Insert a signature file.
11481 If `gnus-signature-function' is bound and returns a string, this
11482 string is used instead of the variable `gnus-signature-file'.
11483 In either case, if the string is a file name, this file is
11484 inserted. If the string is not a file name, the string itself is
11486 If you never want any signature inserted, set both those variables to
11490 (or (and gnus-signature-function
11491 (fboundp gnus-signature-function)
11492 (funcall gnus-signature-function gnus-newsgroup-name))
11493 gnus-signature-file))
11496 (or (file-exists-p signature)
11497 (string-match " " signature)
11499 "^/[^/]+/" (expand-file-name signature)))))
11501 (goto-char (point-max))
11502 ;; Delete any previous signatures.
11503 (if (and mail-signature (search-backward "\n-- \n" nil t))
11504 (delete-region (1+ (point)) (point-max)))
11506 (and (< 4 (setq b (count-lines
11509 (if (file-exists-p signature)
11510 (insert-file-contents signature)
11511 (insert signature))
11512 (goto-char (point-max))
11513 (or (bolp) (insert "\n"))
11515 (not gnus-expert-user)
11519 "Your .sig is %d lines; it should be max 4. Really post? "
11521 (if (file-exists-p signature)
11522 (error (format "Edit %s." signature))
11523 (error "Trim your signature."))))))))
11525 (defun gnus-inews-do-fcc ()
11526 "Process FCC: fields in current article buffer.
11527 Unless the first character of the field is `|', the article is saved
11528 to the specified file using the function specified by the variable
11529 gnus-author-copy-saver. The default function rmail-output saves in
11530 Unix mailbox format.
11531 If the first character is `|', the contents of the article is send to
11532 a program specified by the rest of the value."
11533 (let ((fcc-list nil)
11535 (case-fold-search t)) ;Should ignore case.
11538 (goto-char (point-min))
11539 (search-forward "\n\n")
11540 (narrow-to-region (point-min) (point))
11541 (goto-char (point-min))
11542 (while (re-search-forward "^FCC:[ \t]*" nil t)
11544 (cons (buffer-substring
11548 (skip-chars-backward " \t")
11551 (delete-region (match-beginning 0)
11552 (progn (forward-line 1) (point))))
11553 ;; Process FCC operations.
11556 (setq fcc-file (car fcc-list))
11557 (setq fcc-list (cdr fcc-list))
11558 (cond ((string-match "^[ \t]*|[ \t]*\\(.*\\)[ \t]*$" fcc-file)
11559 (let ((program (substring fcc-file
11560 (match-beginning 1) (match-end 1))))
11561 ;; Suggested by yuki@flab.fujitsu.junet.
11562 ;; Send article to named program.
11563 (call-process-region (point-min) (point-max) shell-file-name
11564 nil nil nil "-c" program)))
11566 ;; Suggested by hyoko@flab.fujitsu.junet.
11567 ;; Save article in Unix mail format by default.
11568 (if (and gnus-author-copy-saver
11569 (not (eq gnus-author-copy-saver 'rmail-output)))
11570 (funcall gnus-author-copy-saver fcc-file)
11571 (if (and (file-readable-p fcc-file) (rmail-file-p fcc-file))
11572 (gnus-output-to-rmail fcc-file)
11573 (rmail-output fcc-file 1 t t))))))))))
11575 (defun gnus-inews-path ()
11576 "Return uucp path."
11577 (let ((login-name (gnus-inews-login-name)))
11578 (cond ((null gnus-use-generic-path)
11579 (concat (nth 1 gnus-select-method) "!" login-name))
11580 ((stringp gnus-use-generic-path)
11581 ;; Support GENERICPATH. Suggested by vixie@decwrl.dec.com.
11582 (concat gnus-use-generic-path "!" login-name))
11585 (defun gnus-inews-user-name ()
11586 "Return user's network address as \"NAME@DOMAIN (FULL-NAME)\"."
11587 (let ((full-name (gnus-inews-full-name)))
11588 (or gnus-user-from-line
11589 (concat (if (or gnus-user-login-name gnus-use-generic-from
11590 gnus-local-domain (getenv "DOMAINNAME"))
11591 (concat (gnus-inews-login-name) "@"
11592 (gnus-inews-domain-name gnus-use-generic-from))
11594 ;; User's full name.
11595 (cond ((string-equal full-name "") "")
11596 ((string-equal full-name "&") ;Unix hack.
11597 (concat " (" (user-login-name) ")"))
11599 (concat " (" full-name ")")))))))
11601 (defun gnus-inews-login-name ()
11602 "Return login name."
11603 (or gnus-user-login-name (getenv "LOGNAME") (user-login-name)))
11605 (defun gnus-inews-full-name ()
11606 "Return full user name."
11607 (or gnus-user-full-name (getenv "NAME") (user-full-name)))
11609 (defun gnus-inews-domain-name (&optional genericfrom)
11610 "Return user's domain name.
11611 If optional argument GENERICFROM is a string, use it as the domain
11612 name; if it is non-nil, strip off local host name from the domain name.
11613 If the function `system-name' returns full internet name and the
11614 domain is undefined, the domain name is got from it."
11615 (if (or genericfrom gnus-local-domain (getenv "DOMAINNAME"))
11616 (let* ((system-name (system-name))
11618 (or (if (stringp genericfrom) genericfrom)
11619 (getenv "DOMAINNAME")
11621 ;; Function `system-name' may return full internet name.
11622 ;; Suggested by Mike DeCorte <mrd@sun.soe.clarkson.edu>.
11623 (if (string-match "\\." system-name)
11624 (substring system-name (match-end 0)))
11625 (read-string "Domain name (no host): ")))
11626 (host (or (if (string-match "\\." system-name)
11627 (substring system-name 0 (match-beginning 0)))
11629 (if (string-equal "." (substring domain 0 1))
11630 (setq domain (substring domain 1)))
11631 ;; Support GENERICFROM as same as standard Bnews system.
11632 ;; Suggested by ohm@kaba.junet and vixie@decwrl.dec.com.
11633 (cond ((null genericfrom)
11634 (concat host "." domain))
11635 ;;((stringp genericfrom) genericfrom)
11637 (if (string-match "\\." (system-name))
11639 (substring user-mail-address
11640 (1+ (string-match "@" user-mail-address))))))
11642 (defun gnus-inews-full-address ()
11643 (let ((domain (gnus-inews-domain-name))
11644 (system (system-name))
11645 (case-fold-search t))
11646 (if (string-match "\\." system) system
11647 (if (string-match (concat "^" (regexp-quote system)) domain) domain
11648 (concat system "." domain)))))
11650 (defun gnus-inews-message-id ()
11651 "Generate unique Message-ID for user."
11652 ;; Message-ID should not contain a slash and should be terminated by
11653 ;; a number. I don't know the reason why it is so.
11654 (concat "<" (gnus-inews-unique-id) "@" (gnus-inews-full-address) ">"))
11656 (defun gnus-inews-unique-id ()
11657 "Generate unique ID from user name and current time."
11658 (concat (downcase (gnus-inews-login-name))
11660 (lambda (num) (gnus-number-base-x num 3 31))
11661 (current-time) "")))
11663 (defun gnus-inews-date ()
11664 "Current time string."
11665 (timezone-make-date-arpa-standard
11666 (current-time-string) (current-time-zone)))
11668 (defun gnus-inews-organization ()
11669 "Return user's organization.
11670 The ORGANIZATION environment variable is used if defined.
11671 If not, the variable `gnus-local-organization' is used instead.
11672 If it is a function, the function will be called with the current
11673 newsgroup name as the argument.
11674 If this is a file name, the contents of this file will be used as the
11676 (let* ((organization
11677 (or (getenv "ORGANIZATION")
11678 (if gnus-local-organization
11679 (if (and (symbolp gnus-local-organization)
11680 (fboundp gnus-local-organization))
11681 (funcall gnus-local-organization gnus-newsgroup-name)
11682 gnus-local-organization))
11683 gnus-organization-file
11684 "~/.organization")))
11685 (and (stringp organization)
11686 (> (length organization) 0)
11687 (or (file-exists-p organization)
11688 (string-match " " organization)
11689 (not (string-match "^/[^/]+/" (expand-file-name organization))))
11691 (set-buffer (get-buffer-create " *Gnus organization*"))
11692 (buffer-disable-undo (current-buffer))
11694 (if (file-exists-p organization)
11695 (insert-file-contents organization)
11696 (insert organization))
11697 (goto-char (point-min))
11698 (while (re-search-forward " *\n *" nil t)
11699 (replace-match " "))
11700 (buffer-substring (point-min) (point-max))))))
11702 (defun gnus-inews-lines ()
11703 "Count the number of lines and return numeric string."
11707 (goto-char (point-min))
11708 (search-forward "\n\n" nil 'move)
11709 (int-to-string (count-lines (point) (point-max))))))
11713 ;;; Gnus Mail Functions
11716 ;;; Mail reply commands of Gnus summary mode
11718 (defun gnus-summary-reply (yank)
11719 "Reply mail to news author.
11720 If prefix argument YANK is non-nil, original article is yanked automatically.
11721 Customize the variable gnus-mail-reply-method to use another mailer."
11723 ;; Bug fix by jbw@bigbird.bu.edu (Joe Wells)
11724 ;; Stripping headers should be specified with mail-yank-ignored-headers.
11725 (gnus-set-global-variables)
11726 (gnus-summary-select-article t)
11727 (setq gnus-winconf-post-news (current-window-configuration))
11728 (let ((gnus-newsgroup-name gnus-newsgroup-name))
11729 (bury-buffer gnus-article-buffer)
11730 (funcall gnus-mail-reply-method yank))
11731 (gnus-article-hide-headers-if-wanted))
11733 (defun gnus-summary-reply-with-original ()
11734 "Reply mail to news author with original article.
11735 Customize the variable gnus-mail-reply-method to use another mailer."
11737 (gnus-summary-reply t))
11739 (defun gnus-summary-mail-forward ()
11740 "Forward the current message to another user.
11741 Customize the variable gnus-mail-forward-method to use another mailer."
11743 (gnus-summary-select-article t)
11744 (setq gnus-winconf-post-news (current-window-configuration))
11745 (set-buffer gnus-article-buffer)
11746 (let ((gnus-newsgroup-name gnus-newsgroup-name))
11747 (funcall gnus-mail-forward-method))
11748 (gnus-article-hide-headers-if-wanted))
11750 (defun gnus-summary-mail-other-window ()
11751 "Compose mail in other window.
11752 Customize the variable `gnus-mail-other-window-method' to use another
11755 (setq gnus-winconf-post-news (current-window-configuration))
11756 (let ((gnus-newsgroup-name gnus-newsgroup-name))
11757 (funcall gnus-mail-other-window-method)))
11759 (defun gnus-mail-reply-using-mail (&optional yank to-address)
11761 (set-buffer gnus-summary-buffer)
11762 (let ((info (nth 2 (gnus-gethash gnus-newsgroup-name gnus-newsrc-hashtb)))
11763 (group (gnus-group-real-name gnus-newsgroup-name))
11764 (cur (cons (current-buffer) (cdr gnus-article-current)))
11765 from subject date to reply-to message-of
11766 references message-id sender follow-to cc)
11767 (set-buffer (get-buffer-create "*mail*"))
11769 (make-local-variable 'gnus-article-reply)
11770 (setq gnus-article-reply cur)
11771 (use-local-map (copy-keymap mail-mode-map))
11772 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
11773 (if (and (buffer-modified-p)
11774 (> (buffer-size) 0)
11775 (not (gnus-y-or-n-p
11776 "Unsent article being composed; erase it? ")))
11780 (set-buffer gnus-article-buffer)
11781 (let ((buffer-read-only nil))
11782 (goto-char (point-min))
11783 (narrow-to-region (point-min)
11784 (progn (search-forward "\n\n") (point)))
11785 (add-text-properties (point-min) (point-max) '(invisible nil)))
11786 (if (and (boundp 'gnus-reply-to-function)
11787 gnus-reply-to-function)
11790 (gnus-narrow-to-headers)
11791 (setq follow-to (funcall gnus-reply-to-function group)))))
11792 (setq from (mail-fetch-field "from"))
11793 (setq date (mail-fetch-field "date"))
11796 (string-match " *at \\| *@ \\| *(\\| *<" from)))
11798 (concat (if stop-pos (substring from 0 stop-pos) from)
11799 "'s message of " date))))
11800 (setq sender (mail-fetch-field "sender"))
11801 (setq subject (or (mail-fetch-field "subject")
11803 (or (string-match "^[Rr][Ee]:" subject)
11804 (setq subject (concat "Re: " subject)))
11805 (setq cc (mail-fetch-field "cc"))
11806 (setq reply-to (mail-fetch-field "reply-to"))
11807 (setq references (mail-fetch-field "references"))
11808 (setq message-id (mail-fetch-field "message-id"))
11810 (setq news-reply-yank-from from)
11811 (setq news-reply-yank-message-id message-id)
11812 (mail-setup (or to-address
11813 (if (and follow-to (not (stringp follow-to))) ""
11814 (or follow-to reply-to from sender "")))
11815 subject message-of nil gnus-article-buffer nil)
11816 (if (and follow-to (listp follow-to))
11818 (goto-char (point-min))
11820 (insert (car (car follow-to)) ": " (cdr (car follow-to)) "\n")
11821 (setq follow-to (cdr follow-to)))))
11822 ;; Fold long references line to follow RFC1036.
11823 (mail-position-on-field "References")
11824 (let ((begin (- (point) (length "References: ")))
11826 (fill-prefix "\t"))
11827 (if references (insert references))
11828 (if (and references message-id) (insert " "))
11829 (if message-id (insert message-id))
11830 ;; The region must end with a newline to fill the region
11831 ;; without inserting extra newline.
11832 (fill-region-as-paragraph begin (1+ (point))))
11833 (goto-char (point-min))
11835 (concat "^" (regexp-quote mail-header-separator) "$"))
11838 (let ((last (point)))
11839 (run-hooks 'news-reply-header-hook)
11840 (mail-yank-original nil)
11841 (goto-char last))))
11843 (let ((mail (current-buffer)))
11844 (gnus-configure-windows '(0 0 1))
11845 (switch-to-buffer-other-window mail))
11846 (gnus-configure-windows '(0 1 0))
11847 (switch-to-buffer (current-buffer))))))
11849 (defun gnus-mail-yank-original ()
11851 (run-hooks 'news-reply-header-hook)
11852 (mail-yank-original nil))
11854 (defun gnus-mail-send-and-exit ()
11856 (let ((cbuf (current-buffer)))
11857 (mail-send-and-exit nil)
11858 (if (get-buffer gnus-group-buffer)
11862 (let ((reply gnus-article-reply))
11864 (get-buffer (car reply))
11865 (buffer-name (car reply)))
11867 (set-buffer (car reply))
11869 (gnus-summary-mark-article-as-replied
11871 (and gnus-winconf-post-news
11872 (set-window-configuration gnus-winconf-post-news))
11873 (setq gnus-winconf-post-news nil)))))
11875 (defun gnus-mail-forward-using-mail ()
11876 "Forward the current message to another user using mail."
11877 ;; This is almost a carbon copy of rmail-forward in rmail.el.
11878 (let ((forward-buffer (current-buffer))
11880 (concat "[" (if (memq 'mail (assoc (symbol-name
11881 (car (gnus-find-method-for-group
11882 gnus-newsgroup-name)))
11883 gnus-valid-select-methods))
11884 (gnus-fetch-field "From")
11885 gnus-newsgroup-name)
11886 "] " (or (gnus-fetch-field "Subject") "")))
11888 ;; If only one window, use it for the mail buffer.
11889 ;; Otherwise, use another window for the mail buffer
11890 ;; so that the Rmail buffer remains visible
11891 ;; and sending the mail will get back to it.
11892 (if (if (one-window-p t)
11893 (mail nil nil subject)
11894 (mail-other-window nil nil subject))
11896 (use-local-map (copy-keymap emacs-lisp-mode-map))
11897 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
11898 (setq beg (goto-char (point-max)))
11899 (insert "------- Start of forwarded message -------\n")
11900 (insert-buffer forward-buffer)
11901 (goto-char (point-max))
11902 (insert "------- End of forwarded message -------\n")
11903 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
11905 (while (setq beg (next-single-property-change (point) 'invisible))
11907 (delete-region beg (or (next-single-property-change
11908 (point) 'invisible)
11910 ;; You have a chance to arrange the message.
11911 (run-hooks 'gnus-mail-forward-hook)))))
11913 (defun gnus-mail-other-window-using-mail ()
11914 "Compose mail other window using mail."
11915 (mail-other-window nil nil nil nil nil (get-buffer gnus-article-buffer))
11916 (use-local-map (copy-keymap (current-local-map)))
11917 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit))
11924 (defvar gnus-dribble-ignore nil)
11926 (defun gnus-dribble-file-name ()
11927 (concat gnus-startup-file "-dribble"))
11929 (defun gnus-dribble-open ()
11932 (setq gnus-dribble-buffer (find-file-noselect (gnus-dribble-file-name))))
11933 (buffer-disable-undo (current-buffer))
11934 (bury-buffer gnus-dribble-buffer)
11936 (goto-char (point-max))))
11938 (defun gnus-dribble-enter (string)
11939 (if (and (not gnus-dribble-ignore)
11940 gnus-dribble-buffer
11941 (buffer-name gnus-dribble-buffer))
11942 (let ((obuf (current-buffer)))
11943 (set-buffer gnus-dribble-buffer)
11944 (insert string "\n")
11945 (set-window-point (get-buffer-window (current-buffer)) (point-max))
11946 (set-buffer obuf))))
11948 (defun gnus-dribble-read-file ()
11949 (let ((dribble-file (gnus-dribble-file-name)))
11951 (set-buffer (setq gnus-dribble-buffer
11953 (file-name-nondirectory dribble-file))))
11954 (gnus-add-current-to-buffer-list)
11956 (set-visited-file-name dribble-file)
11957 (buffer-disable-undo (current-buffer))
11958 (bury-buffer (current-buffer))
11959 (set-buffer-modified-p nil)
11960 (let ((auto (make-auto-save-file-name))
11961 (gnus-dribble-ignore t))
11962 (if (or (file-exists-p auto) (file-exists-p dribble-file))
11964 (if (file-newer-than-file-p auto dribble-file)
11965 (setq dribble-file auto))
11966 (insert-file-contents dribble-file)
11967 (if (not (zerop (buffer-size)))
11968 (set-buffer-modified-p t))
11970 "Auto-save file exists. Do you want to read it? ")
11972 (message "Reading %s..." dribble-file)
11973 (eval-current-buffer)
11974 (message "Reading %s...done" dribble-file)))))))))
11976 (defun gnus-dribble-delete-file ()
11977 (if (file-exists-p (gnus-dribble-file-name))
11978 (delete-file (gnus-dribble-file-name)))
11979 (if gnus-dribble-buffer
11981 (set-buffer gnus-dribble-buffer)
11982 (let ((auto (make-auto-save-file-name)))
11983 (if (file-exists-p auto)
11984 (delete-file auto))
11986 (set-buffer-modified-p nil)))))
11988 (defun gnus-dribble-save ()
11989 (if (and gnus-dribble-buffer
11990 (buffer-name gnus-dribble-buffer))
11992 (set-buffer gnus-dribble-buffer)
11995 (defun gnus-dribble-clear ()
11997 (if (and gnus-dribble-buffer
11998 (buffer-name (get-buffer gnus-dribble-buffer)))
12000 (set-buffer gnus-dribble-buffer)
12002 (set-buffer-modified-p nil)
12003 (setq buffer-saved-size (buffer-size))))))
12006 ;;; Server Communication
12009 ;; All the Gnus backends have the same interface, and should return
12010 ;; data in a similar format. Below is an overview of what functions
12011 ;; these packages must supply and what results they should return.
12015 ;; `nntp-server-buffer' - All data should be returned to Gnus in this
12018 ;; Functions for the imaginary backend `choke':
12020 ;; `choke-retrieve-headers ARTICLES &optional GROUP SERVER'
12021 ;; Should return all headers for all ARTICLES, or return NOV lines for
12024 ;; `choke-request-group GROUP &optional SERVER DISCARD'
12025 ;; Switch to GROUP. If DISCARD is nil, active information on the group
12026 ;; must be returned.
12028 ;; `choke-close-group GROUP &optional SERVER'
12029 ;; Close group. Most backends won't have to do anything with this
12030 ;; call, but it is an opportunity to clean up, if that is needed. It
12031 ;; is called when Gnus exits a group.
12033 ;; `choke-request-article ARTICLE &optional GROUP SERVER'
12034 ;; Return ARTICLE, which is either an article number or
12035 ;; message-id. Note that not all backends can return articles based on
12038 ;; `choke-request-list SERVER'
12039 ;; Return a list of all newsgroups on SERVER.
12041 ;; `choke-request-list-newsgroups SERVER'
12042 ;; Return a list of descriptions of all newsgroups on SERVER.
12044 ;; `choke-request-newgroups DATE &optional SERVER'
12045 ;; Return a list of all groups that have arrived after DATE on
12046 ;; SERVER. Note that the date doesn't have to be respected - Gnus will
12047 ;; always check whether the groups are old or not. Backends that do
12048 ;; not store date information may just return the entire list of
12049 ;; groups, although this might not be a good idea in general.
12051 ;; `choke-request-post-buffer METHOD HEADER ARTICLE-BUFFER GROUP INFO'
12052 ;; Should return a buffer that is suitable for "posting". nnspool and
12053 ;; nntp return a `*post-buffer*', and nnmail return a `*mail*'
12054 ;; buffer. This function should fill out the appropriate headers.
12056 ;; `choke-request-post &optional SERVER'
12057 ;; Function that will be called from a buffer to be posted.
12059 ;; `choke-open-server SERVER &optional ARGUMENT'
12060 ;; Open a connection to SERVER.
12062 ;; `choke-close-server &optional SERVER'
12063 ;; Close the connection to SERVER.
12065 ;; `choke-server-opened &optional SERVER'
12066 ;; Whether the conenction to SERVER is opened or not.
12068 ;; `choke-server-status &optional SERVER'
12069 ;; Should return a status string (not in the nntp buffer, but as the
12070 ;; result of the function).
12072 ;; The following functions are optional and apply only to backends
12073 ;; that are able to control the contents of their groups totally
12074 ;; (ie. mail backends.) Backends that aren't able to do that
12075 ;; shouldn't define these functions at all. Gnus will check for their
12076 ;; presence before attempting to call them.
12078 ;; `choke-request-expire-articles ARTICLES &optional NEWSGROUP SERVER'
12079 ;; Should expire (according to some aging scheme) all ARTICLES. Most
12080 ;; backends will not be able to expire articles. Should return a list
12081 ;; of all articles that were not expired.
12083 ;; `choke-request-move-article ARTICLE GROUP SERVER ACCEPT-FORM &optional LAST'
12084 ;; Should move ARTICLE from GROUP on SERVER by using ACCEPT-FORM.
12085 ;; Removes any information it has added to the article (extra headers,
12086 ;; whatever - make it as clean as possible), and then passes the
12087 ;; article on by evaling ACCEPT-FORM, which is normally a call to the
12088 ;; function described below. If the ACCEPT-FORM returns a non-nil
12089 ;; value, the article should then be deleted. If LAST is nil, that
12090 ;; means that there will be further calls to this function. This might
12091 ;; be taken as an advice not to save buffers/internal variables just
12092 ;; yet, but wait until the last call to speed things up.
12094 ;; `choke-request-accept-article GROUP &optional LAST'
12095 ;; The contents of the current buffer will be put into GROUP. There
12096 ;; should, of course, be an article in the current buffer. This
12097 ;; function is normally only called by the function described above,
12098 ;; and LAST works the same way as in that function.
12100 ;; `choke-request-replace-article ARTICLE GROUP BUFFER'
12101 ;; Replace ARTICLE in GROUP with the contents of BUFFER.
12102 ;; This provides an easy interface for allowing editing of
12103 ;; articles. Note that even headers may be edited, so the backend has
12104 ;; to update any tables (nov buffers, etc) that it maintains after
12105 ;; replacing the article.
12107 ;; `choke-request-create-group GROUP &optional SERVER'
12108 ;; Create GROUP on SERVER. This might be a new, empty group, or it
12109 ;; might be a group that already exists, but hasn't been registered
12112 ;; All these functions must return nil if they couldn't service the
12113 ;; request. If the optional arguments are not supplied, some "current"
12114 ;; or "default" values should be used. In short, one should emulate an
12115 ;; NNTP server, in a way.
12117 ;; If you want to write a new backend, you just have to supply the
12118 ;; functions listed above. In addition, you must enter the new backend
12119 ;; into the list of valid select methods:
12120 ;; (setq gnus-valid-select-methods
12121 ;; (cons '("choke" mail) gnus-valid-select-methods))
12122 ;; The first element in this list is the name of the backend. Other
12123 ;; elemnets may be `mail' (for mail groups), `post' (for news
12124 ;; groups), `none' (neither), `respool' (for groups that can control
12125 ;; their contents).
12127 (defun gnus-start-news-server (&optional confirm)
12128 "Open a method for getting news.
12129 If CONFIRM is non-nil, the user will be asked for an NNTP server."
12131 (if gnus-current-select-method
12132 ;; Stream is already opened.
12134 ;; Open NNTP server.
12135 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
12138 ;; Read server name with completion.
12139 (setq gnus-nntp-server
12140 (completing-read "NNTP server: "
12141 (mapcar (lambda (server) (list server))
12142 (cons (list gnus-nntp-server)
12143 gnus-secondary-servers))
12144 nil nil gnus-nntp-server))))
12146 (if (and gnus-nntp-server
12147 (stringp gnus-nntp-server)
12148 (not (string= gnus-nntp-server "")))
12149 (setq gnus-select-method
12150 (cond ((or (string= gnus-nntp-server "")
12151 (string= gnus-nntp-server "::"))
12152 (list 'nnspool (system-name)))
12153 ((string-match ":" gnus-nntp-server)
12154 (list 'nnmh gnus-nntp-server))
12156 (list 'nntp gnus-nntp-server)))))
12158 (setq how (car gnus-select-method))
12159 (setq where (car (cdr gnus-select-method)))
12160 (cond ((eq how 'nnspool)
12162 (message "Looking up local news spool..."))
12165 (message "Looking up mh spool..."))
12168 (setq gnus-current-select-method gnus-select-method)
12169 (run-hooks 'gnus-open-server-hook)
12171 ;; gnus-open-server-hook might have opened it
12172 (gnus-server-opened gnus-select-method)
12173 (gnus-open-server gnus-select-method)
12176 "%s server on %s can't be opened. Continue? "
12177 (car gnus-select-method) (nth 1 gnus-select-method)))
12179 (message "Couldn't open server on %s" (nth 1 gnus-select-method))
12183 (defun gnus-check-news-server (method)
12184 "If the news server is down, start it up again."
12185 (let ((method (if method method gnus-select-method)))
12186 (if (gnus-server-opened method)
12187 ;; Stream is already opened.
12190 (message "Opening server %s on %s..." (car method) (nth 1 method))
12191 (run-hooks 'gnus-open-server-hook)
12192 (or (gnus-server-opened method)
12193 (gnus-open-server method))
12196 (defun gnus-nntp-message (&optional message)
12197 "Check the status of the NNTP server.
12198 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
12199 is returned insted of the status string."
12200 (let ((status (gnus-status-message (gnus-find-method-for-group
12201 gnus-newsgroup-name)))
12202 (message (or message "")))
12203 (if (and (stringp status) (> (length status) 0))
12206 (defun gnus-get-function (method function)
12207 (let ((func (intern (format "%s-%s" (car method) function))))
12208 (if (not (fboundp func))
12210 (require (car method))
12211 (if (not (fboundp func))
12212 (error "No such function: %s" func))))
12215 ;; Specifying port number suggested by Stephane Laveau <laveau@corse.inria.fr>.
12216 (defun gnus-open-server (method)
12217 (apply (gnus-get-function method 'open-server) (cdr method)))
12219 (defun gnus-close-server (method)
12220 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
12222 (defun gnus-request-list (method)
12223 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
12225 (defun gnus-request-list-newsgroups (method)
12226 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
12228 (defun gnus-request-newgroups (date method)
12229 (funcall (gnus-get-function method 'request-newgroups)
12230 date (nth 1 method)))
12232 (defun gnus-server-opened (method)
12233 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
12235 (defun gnus-status-message (method)
12236 (let ((method (if (stringp method) (gnus-find-method-for-group method)
12238 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
12240 (defun gnus-request-group (group &optional dont-check)
12241 (let ((method (gnus-find-method-for-group group)))
12242 (funcall (gnus-get-function method 'request-group)
12243 (gnus-group-real-name group) (nth 1 method) dont-check)))
12245 (defun gnus-list-active-group (group)
12246 (let ((method (gnus-find-method-for-group group))
12247 (func 'list-active-group))
12248 (and (gnus-check-backend-function func group)
12249 (funcall (gnus-get-function method func)
12250 (gnus-group-real-name group) (nth 1 method)))))
12252 (defun gnus-request-group-description (group)
12253 (let ((method (gnus-find-method-for-group group))
12254 (func 'request-group-description))
12255 (and (gnus-check-backend-function func group)
12256 (funcall (gnus-get-function method func)
12257 (gnus-group-real-name group) (nth 1 method)))))
12259 (defun gnus-close-group (group)
12260 (let ((method (gnus-find-method-for-group group)))
12261 (funcall (gnus-get-function method 'close-group)
12262 (gnus-group-real-name group) (nth 1 method))))
12264 (defun gnus-retrieve-headers (articles group)
12265 (let ((method (gnus-find-method-for-group group)))
12266 (funcall (gnus-get-function method 'retrieve-headers)
12267 articles (gnus-group-real-name group) (nth 1 method))))
12269 (defun gnus-request-article (article group &optional buffer)
12270 (let ((method (gnus-find-method-for-group group)))
12271 (funcall (gnus-get-function method 'request-article)
12272 article (gnus-group-real-name group) (nth 1 method) buffer)))
12274 (defun gnus-request-head (article group)
12275 (let ((method (gnus-find-method-for-group group)))
12276 (funcall (gnus-get-function method 'request-head)
12277 article (gnus-group-real-name group) (nth 1 method))))
12279 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
12280 (defun gnus-request-post-buffer (post group subject header artbuf
12281 info follow-to respect-poster)
12282 (let* ((info (or info (and group (nth 2 (gnus-gethash
12283 group gnus-newsrc-hashtb)))))
12285 (if (and gnus-post-method
12286 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
12288 (format "%s" (car (gnus-find-method-for-group
12289 gnus-newsgroup-name)))
12290 gnus-valid-select-methods)))
12292 (gnus-find-method-for-group gnus-newsgroup-name))))
12293 (let ((mail-self-blind nil)
12294 (mail-archive-file-name nil))
12295 (funcall (gnus-get-function method 'request-post-buffer)
12296 post group subject header artbuf info follow-to
12299 (defun gnus-request-post (method &optional force)
12300 (and (not force) gnus-post-method
12301 (memq 'post (assoc (format "%s" (car method))
12302 gnus-valid-select-methods))
12303 (setq method gnus-post-method))
12304 (funcall (gnus-get-function method 'request-post)
12307 (defun gnus-request-expire-articles (articles group &optional force)
12308 (let ((method (gnus-find-method-for-group group)))
12309 (funcall (gnus-get-function method 'request-expire-articles)
12310 articles (gnus-group-real-name group) (nth 1 method)
12313 (defun gnus-request-move-article
12314 (article group server accept-function &optional last)
12315 (let ((method (gnus-find-method-for-group group)))
12316 (funcall (gnus-get-function method 'request-move-article)
12317 article (gnus-group-real-name group)
12318 (nth 1 method) accept-function last)))
12320 (defun gnus-request-accept-article (group &optional last)
12321 (let ((func (if (symbolp group) group
12322 (car (gnus-find-method-for-group group)))))
12323 (funcall (intern (format "%s-request-accept-article" func))
12324 (if (stringp group) (gnus-group-real-name group) group)
12327 (defun gnus-request-replace-article (article group buffer)
12328 (let ((func (car (gnus-find-method-for-group group))))
12329 (funcall (intern (format "%s-request-replace-article" func))
12330 article (gnus-group-real-name group) buffer)))
12332 (defun gnus-request-create-group (group)
12333 (let ((method (gnus-find-method-for-group group)))
12334 (funcall (gnus-get-function method 'request-create-group)
12335 (gnus-group-real-name group) (nth 1 method))))
12338 (defun gnus-find-method-for-group (group)
12339 (or gnus-override-method
12341 gnus-select-method)
12342 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
12344 (not (nth 4 info)))
12348 (defun gnus-check-backend-function (func group)
12349 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
12351 (fboundp (intern (format "%s-%s" method func)))))
12353 (defun gnus-methods-using (method)
12354 (let ((valids gnus-valid-select-methods)
12357 (if (memq method (car valids))
12358 (setq outs (cons (car valids) outs)))
12359 (setq valids (cdr valids)))
12363 ;;; Active & Newsrc File Handling
12366 ;; Newsrc related functions.
12367 ;; Gnus internal format of gnus-newsrc-assoc:
12368 ;; (("alt.general" 3 (1 . 1))
12369 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
12370 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
12371 ;; The first item is the group name; the second is the subscription
12372 ;; level; the third is either a range of a list of ranges of read
12373 ;; articles, the optional fourth element is a list of marked articles,
12374 ;; the optional fifth element is the select method.
12376 ;; Gnus internal format of gnus-newsrc-hashtb:
12377 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
12378 ;; This is the entry for "alt.misc". The first element is the number
12379 ;; of unread articles in "alt.misc". The cdr of this entry is the
12380 ;; element *before* "alt.misc" in gnus-newsrc-assoc, which makes is
12381 ;; trivial to remove or add new elements into gnus-newsrc-assoc
12382 ;; without scanning the entire list. So, to get the actual information
12383 ;; of "alt.misc", you'd say something like
12384 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
12386 ;; Gnus internal format of gnus-active-hashtb:
12390 ;; The only element in each entry in this hash table is a range of
12391 ;; (possibly) available articles. (Articles in this range may have
12392 ;; been expired or cancelled.)
12394 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
12395 ;; ("alt.misc" "alt.test" "alt.general" ...)
12397 (defun gnus-setup-news (&optional rawfile level)
12398 "Setup news information.
12399 If RAWFILE is non-nil, the .newsrc file will also be read.
12400 If LEVEL is non-nil, the news will be set up at level LEVEL."
12401 (let ((init (not (and gnus-newsrc-assoc gnus-active-hashtb (not rawfile)))))
12402 ;; Clear some variables to re-initialize news information.
12403 (if init (setq gnus-newsrc-assoc nil gnus-active-hashtb nil))
12404 ;; Read the active file and create `gnus-active-hashtb'.
12405 ;; If `gnus-read-active-file' is nil, then we just create an empty
12406 ;; hash table. The partial filling out of the hash table will be
12407 ;; done in `gnus-get-unread-articles'.
12408 (if (and gnus-read-active-file
12410 (gnus-server-opened gnus-select-method))
12411 (gnus-read-active-file)
12412 (setq gnus-active-hashtb (make-vector 4095 0)))
12414 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
12415 (if init (gnus-read-newsrc-file rawfile))
12416 ;; Find the number of unread articles in each non-dead group.
12417 (gnus-get-unread-articles (or level 6))
12418 ;; Find new newsgroups and treat them.
12419 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
12420 (gnus-server-opened gnus-select-method))
12421 (gnus-find-new-newsgroups))
12422 (if (and init gnus-check-bogus-newsgroups
12423 gnus-read-active-file (not level)
12424 (gnus-server-opened gnus-select-method))
12425 (gnus-check-bogus-newsgroups))))
12427 (defun gnus-find-new-newsgroups ()
12428 "Search for new newsgroups and add them.
12429 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
12430 The `-n' option line from .newsrc is respected."
12432 (or (gnus-check-first-time-used)
12433 (if (or (consp gnus-check-new-newsgroups)
12434 (eq gnus-check-new-newsgroups 'ask-server))
12435 (gnus-ask-server-for-new-groups)
12437 group new-newsgroups)
12438 (or gnus-have-read-active-file (gnus-read-active-file))
12439 (setq gnus-newsrc-last-checked-date (current-time-string))
12440 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
12441 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
12442 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
12445 (setq group (symbol-name sym))
12446 (if (or (gnus-gethash group gnus-killed-hashtb)
12447 (gnus-gethash group gnus-newsrc-hashtb))
12449 (let ((do-sub (gnus-matches-options-n group)))
12450 (cond ((eq do-sub 'subscribe)
12451 (setq groups (1+ groups))
12452 (gnus-sethash group group gnus-killed-hashtb)
12454 gnus-subscribe-options-newsgroup-method group))
12455 ((eq do-sub 'ignore)
12458 (setq groups (1+ groups))
12459 (gnus-sethash group group gnus-killed-hashtb)
12460 (if gnus-subscribe-hierarchical-interactive
12461 (setq new-newsgroups (cons group new-newsgroups))
12462 (funcall gnus-subscribe-newsgroup-method group)))))))
12463 gnus-active-hashtb)
12465 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12466 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12468 (message "%d new newsgroup%s arrived."
12469 groups (if (> groups 1) "s have" " has")))))))
12471 (defun gnus-matches-options-n (group)
12472 ;; Returns `subscribe' if the group is to be uncoditionally
12473 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
12474 ;; no match for the group.
12476 ;; First we check the two user variables.
12478 ((and gnus-options-not-subscribe
12479 (string-match gnus-options-not-subscribe group))
12481 ((and gnus-options-subscribe
12482 (string-match gnus-options-subscribe group))
12484 ;; Then we go through the list that was retrieved from the .newsrc
12485 ;; file. This list has elements on the form
12486 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
12487 ;; is in the reverse order of the options line) is returned.
12489 (let ((regs gnus-newsrc-options-n))
12491 (not (string-match (car (car gnus-newsrc-options-n)) group)))
12492 (setq regs (cdr regs)))
12493 (and regs (cdr (car regs)))))))
12495 (defun gnus-ask-server-for-new-groups ()
12496 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
12497 (methods (cons gnus-select-method
12499 (and (consp gnus-check-new-newsgroups)
12500 gnus-check-new-newsgroups)
12501 gnus-secondary-select-methods)))
12503 (new-date (current-time-string))
12504 hashtb group new-newsgroups got-new)
12505 ;; Go thorugh both primary and secondary select methods and
12506 ;; request new newsgroups.
12508 (if (gnus-request-newgroups date (car methods))
12511 (or hashtb (setq hashtb (gnus-make-hashtable
12512 (count-lines (point-min) (point-max)))))
12513 (set-buffer nntp-server-buffer)
12514 ;; Enter all the new groups in a hashtable.
12515 (gnus-active-to-gnus-format (car methods) hashtb)))
12516 (setq methods (cdr methods)))
12517 (and got-new (setq gnus-newsrc-last-checked-date new-date))
12518 ;; Now all new groups from all select methods are in `hashtb'.
12520 (lambda (group-sym)
12521 (setq group (symbol-name group-sym))
12522 (if (or (gnus-gethash group gnus-newsrc-hashtb)
12523 (member group gnus-zombie-list)
12524 (member group gnus-killed-list))
12525 ;; The group is already known.
12527 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb)
12528 (let ((do-sub (gnus-matches-options-n group)))
12529 (cond ((eq do-sub 'subscribe)
12530 (setq groups (1+ groups))
12531 (gnus-sethash group group gnus-killed-hashtb)
12533 gnus-subscribe-options-newsgroup-method group))
12534 ((eq do-sub 'ignore)
12537 (setq groups (1+ groups))
12538 (gnus-sethash group group gnus-killed-hashtb)
12539 (if gnus-subscribe-hierarchical-interactive
12540 (setq new-newsgroups (cons group new-newsgroups))
12541 (funcall gnus-subscribe-newsgroup-method group)))))))
12544 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12545 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12547 (message "%d new newsgroup%s arrived."
12548 groups (if (> groups 1) "s have" " has")))
12551 (defun gnus-check-first-time-used ()
12552 (if (or (> (length gnus-newsrc-assoc) 1)
12553 (file-exists-p gnus-startup-file)
12554 (file-exists-p (concat gnus-startup-file ".el"))
12555 (file-exists-p (concat gnus-startup-file ".eld")))
12557 (message "First time user; subscribing you to default groups")
12558 (or gnus-have-read-active-file (gnus-read-active-file))
12559 (setq gnus-newsrc-last-checked-date (current-time-string))
12560 (let ((groups gnus-default-subscribed-newsgroups)
12564 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
12567 (setq group (symbol-name sym))
12568 (let ((do-sub (gnus-matches-options-n group)))
12569 (cond ((eq do-sub 'subscribe)
12570 (gnus-sethash group group gnus-killed-hashtb)
12572 gnus-subscribe-options-newsgroup-method group))
12573 ((eq do-sub 'ignore)
12576 (setq gnus-killed-list (cons group gnus-killed-list))))))
12577 gnus-active-hashtb)
12579 (if (gnus-gethash (car groups) gnus-active-hashtb)
12580 (gnus-group-change-level (car groups) 3 9))
12581 (setq groups (cdr groups)))
12582 (gnus-group-make-help-group)
12583 (and gnus-novice-user
12584 (message (substitute-command-keys "\\<gnus-group-mode-map>\\[gnus-group-list-killed] to list killed groups")))))))
12586 ;; `gnus-group-change-level' is the fundamental function for changing
12587 ;; subscription levels of newsgroups. This might mean just changing
12588 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
12589 ;; again, which subscribes/unsubscribes a group, which is equally
12590 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
12591 ;; from 8-9 to 1-7 means that you remove the group from the list of
12592 ;; killed (or zombie) groups and add them to the (kinda) subscribed
12593 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
12594 ;; which is trivial.
12595 ;; ENTRY can either be a string (newsgroup name) or a list (if
12596 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
12597 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
12599 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
12600 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
12602 (defun gnus-group-change-level (entry level &optional oldlevel
12603 previous fromkilled)
12604 (let ((pinfo entry)
12605 group info active num)
12606 ;; Glean what info we can from the arguments
12608 (if fromkilled (setq group (nth 1 entry))
12609 (setq group (car (nth 2 entry))))
12610 (setq group entry))
12611 (if (and (stringp entry)
12614 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
12615 (if (and (not oldlevel)
12617 (setq oldlevel (car (cdr (nth 2 entry)))))
12618 (if (stringp previous)
12619 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
12621 (gnus-dribble-enter
12622 (format "(gnus-group-change-level %S %S %S %S %S)"
12623 group level oldlevel (car (nth 2 previous)) fromkilled))
12625 ;; Then we remove the newgroup from any old structures, if needed.
12626 ;; If the group was killed, we remove it from the killed or zombie
12627 ;; list. If not, and it is in fact going to be killed, we remove
12628 ;; it from the newsrc hash table and assoc.
12629 (cond ((>= oldlevel 8)
12631 (setq gnus-zombie-list (delete group gnus-zombie-list))
12632 (setq gnus-killed-list (delete group gnus-killed-list))))
12636 (gnus-sethash (car (nth 2 entry))
12637 nil gnus-newsrc-hashtb)
12639 (setcdr (gnus-gethash (car (nth 3 entry))
12640 gnus-newsrc-hashtb)
12642 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
12644 ;; Finally we enter (if needed) the list where it is supposed to
12645 ;; go, and change the subscription level. If it is to be killed,
12646 ;; we enter it into the killed or zombie list.
12647 (cond ((>= level 8)
12648 (and (string= group (gnus-group-real-name group))
12650 (setq gnus-zombie-list (cons group gnus-zombie-list))
12651 (setq gnus-killed-list (cons group gnus-killed-list)))))
12653 ;; If the list is to be entered into the newsrc assoc, and
12654 ;; it was killed, we have to create an entry in the newsrc
12655 ;; hashtb format and fix the pointers in the newsrc assoc.
12656 (if (>= oldlevel 8)
12660 (setq info (cdr entry))
12661 (setq num (car entry)))
12662 (setq active (gnus-gethash group gnus-active-hashtb))
12663 (setq num (if active (- (1+ (cdr active)) (car active)) t))
12664 ;; Check whether the group is foreign. If so, the
12665 ;; foreign select method has to be entered into the
12667 (let ((method (gnus-group-method-name group)))
12668 (if (eq method gnus-select-method)
12669 (setq info (list group level nil))
12670 (setq info (list group level nil nil method)))))
12671 (setq entry (cons info (if previous (cdr (cdr previous))
12672 (cdr gnus-newsrc-assoc))))
12673 (setcdr (if previous (cdr previous) gnus-newsrc-assoc)
12675 (gnus-sethash group (cons num (if previous (cdr previous)
12676 gnus-newsrc-assoc))
12677 gnus-newsrc-hashtb)
12679 (setcdr (gnus-gethash (car (car (cdr entry)))
12680 gnus-newsrc-hashtb)
12682 ;; It was alive, and it is going to stay alive, so we
12683 ;; just change the level and don't change any pointers or
12684 ;; hash table entries.
12685 (setcar (cdr (car (cdr (cdr entry)))) level))))))
12687 (defun gnus-kill-newsgroup (newsgroup)
12688 "Obsolete function. Kills a newsgroup."
12689 (gnus-group-change-level (gnus-gethash newsgroup gnus-newsrc-hashtb) 9))
12691 (defun gnus-check-bogus-newsgroups (&optional confirm)
12692 "Remove bogus newsgroups.
12693 If CONFIRM is non-nil, the user has to confirm the deletion of every
12695 (let ((newsrc (cdr gnus-newsrc-assoc))
12697 (message "Checking bogus newsgroups...")
12698 (or gnus-have-read-active-file (gnus-read-active-file))
12699 ;; Find all bogus newsgroup that are subscribed.
12701 (setq group (car (car newsrc)))
12702 (if (or (gnus-gethash group gnus-active-hashtb)
12703 (nth 4 (car newsrc))
12705 (not (gnus-y-or-n-p
12706 (format "Remove bogus newsgroup: %s " group)))))
12707 ;; Active newsgroup.
12709 ;; Found a bogus newsgroup.
12710 (setq bogus (cons group bogus)))
12711 (setq newsrc (cdr newsrc)))
12712 ;; Remove all bogus subscribed groups by first killing them, and
12713 ;; then removing them from the list of killed groups.
12715 (gnus-group-change-level
12716 (gnus-gethash (car bogus) gnus-newsrc-hashtb) 9)
12717 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))
12718 (setq bogus (cdr bogus)))
12719 ;; Then we remove all bogus groups from the list of killed and
12720 ;; zombie groups. They are are removed without confirmation.
12721 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
12724 (setq killed (symbol-value (car dead-lists)))
12726 (setq group (car killed))
12727 (or (gnus-gethash group gnus-active-hashtb)
12728 ;; The group is bogus.
12729 (set (car dead-lists)
12730 (delete group (symbol-value (car dead-lists)))))
12731 (setq killed (cdr killed)))
12732 (setq dead-lists (cdr dead-lists))))
12733 (message "Checking bogus newsgroups... done")))
12735 (defun gnus-check-duplicate-killed-groups ()
12736 "Remove duplicates from the list of killed groups."
12738 (let ((killed gnus-killed-list))
12740 (message "%d" (length killed))
12741 (setcdr killed (delete (car killed) (cdr killed)))
12742 (setq killed (cdr killed)))))
12744 ;; Go though `gnus-newsrc-assoc' and compare with `gnus-active-hashtb'
12745 ;; and compute how many unread articles there are in each group.
12746 (defun gnus-get-unread-articles (&optional level)
12747 (let ((newsrc (cdr gnus-newsrc-assoc))
12748 (level (or level 6))
12749 info group active virtuals)
12750 (message "Checking new news...")
12752 (setq info (car newsrc))
12753 (setq group (car info))
12754 (setq active (gnus-gethash group gnus-active-hashtb))
12756 ;; Check newsgroups. If the user doesn't want to check them, or
12757 ;; they can't be checked (for instance, if the news server can't
12758 ;; be reached) we just set the number of unread articles in this
12759 ;; newsgroup to t. This means that Gnus thinks that there are
12760 ;; unread articles, but it has no idea how many.
12762 (if (or (and gnus-activate-foreign-newsgroups
12763 (not (numberp gnus-activate-foreign-newsgroups)))
12764 (and (numberp gnus-activate-foreign-newsgroups)
12765 (<= (nth 1 info) gnus-activate-foreign-newsgroups)
12766 (<= (nth 1 info) level)))
12767 (if (eq (car (nth 4 info)) 'nnvirtual)
12768 (setq virtuals (cons info virtuals))
12769 (setq active (gnus-activate-newsgroup (car info)))))
12770 (if (and (not gnus-read-active-file)
12771 (<= (nth 1 info) level))
12773 (setq active (gnus-activate-newsgroup (car info))))))
12775 (or active (progn (gnus-sethash group nil gnus-active-hashtb)
12776 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
12777 (and active (gnus-get-unread-articles-in-group info active))
12778 (setq newsrc (cdr newsrc)))
12780 ;; Activate the virtual groups. This has to be done after all the
12782 ;; !!! If one virtual group contains another virtual group, even
12783 ;; doing it this way might cause problems.
12785 (and (setq active (gnus-activate-newsgroup (car (car virtuals))))
12786 (gnus-get-unread-articles-in-group (car virtuals) active))
12787 (setq virtuals (cdr virtuals)))
12789 (message "Checking new news... done")))
12791 ;; Create a hash table out of the newsrc alist. The `car's of the
12792 ;; alist elements are used as keys.
12793 (defun gnus-make-hashtable-from-newsrc-alist ()
12794 (let ((alist gnus-newsrc-assoc)
12796 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
12798 (setq prev (setq gnus-newsrc-assoc
12799 (cons (list "dummy.group" 0 nil) alist))))
12801 (gnus-sethash (car (car alist)) (cons nil prev) gnus-newsrc-hashtb)
12803 (setq alist (cdr alist)))))
12805 (defun gnus-make-hashtable-from-killed ()
12806 "Create a hash table from the killed and zombie lists."
12807 (let ((lists '(gnus-killed-list gnus-zombie-list))
12809 (setq gnus-killed-hashtb
12810 (gnus-make-hashtable
12811 (+ (length gnus-killed-list) (length gnus-zombie-list))))
12813 (setq list (symbol-value (car lists)))
12814 (setq lists (cdr lists))
12816 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
12817 (setq list (cdr list))))))
12819 (defun gnus-get-unread-articles-in-group (info active)
12820 (let* ((range (nth 2 info))
12822 (marked (nth 3 info))
12823 srange lowest group highest)
12824 ;; Modify the list of read articles according to what articles
12825 ;; are available; then tally the unread articles and add the
12826 ;; number to the group hash table entry.
12827 (cond ((zerop (cdr active))
12830 (setq num (- (1+ (cdr active)) (car active))))
12831 ((not (listp (cdr range)))
12832 ;; Fix a single (num . num) range according to the
12833 ;; active hash table.
12834 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
12835 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
12836 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
12837 ;; Compute number of unread articles.
12838 (setq num (max 0 (- (cdr active)
12839 (- (1+ (cdr range)) (car range))))))
12841 ;; The read list is a list of ranges. Fix them according to
12842 ;; the active hash table.
12843 ;; First peel off any elements that are below the lower
12845 (while (and (cdr range)
12847 (or (and (atom (car (cdr range))) (car (cdr range)))
12848 (car (car (cdr range))))))
12849 (if (numberp (car range))
12852 (or (and (numberp (car (cdr range)))
12854 (cdr (car (cdr range))))))
12855 (setcdr (car range)
12856 (or (and (numberp (nth 1 range)) (nth 1 range))
12857 (cdr (car (cdr range))))))
12858 (setcdr range (cdr (cdr range))))
12859 ;; Adjust the first element to be the same as the lower limit.
12860 (if (and (not (atom (car range)))
12861 (< (cdr (car range)) (car active)))
12862 (setcdr (car range) (1- (car active))))
12863 ;; Then we want to peel off any elements that are higher
12864 ;; than the upper active limit.
12865 (let ((srange range))
12866 ;; Go past all legal elements.
12867 (while (and (cdr srange)
12868 (<= (or (and (atom (car (cdr srange)))
12869 (car (cdr srange)))
12870 (car (car (cdr srange)))) (cdr active)))
12871 (setq srange (cdr srange)))
12873 ;; Nuke all remaining illegal elements.
12874 (setcdr srange nil))
12876 ;; Adjust the final element.
12877 (if (and (not (atom (car srange)))
12878 (> (cdr (car srange)) (cdr active)))
12879 (setcdr (car srange) (cdr active))))
12880 ;; Compute the number of unread articles.
12882 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
12883 (cdr (car range))))
12884 (or (and (atom (car range)) (car range))
12885 (car (car range))))))
12886 (setq range (cdr range)))
12887 (setq num (max 0 (- (cdr active) num)))))
12890 (and (assq 'tick marked)
12891 (inline (gnus-remove-illegal-marked-articles
12892 (assq 'tick marked) (nth 2 info))))
12893 (and (assq 'dormant marked)
12894 (inline (gnus-remove-illegal-marked-articles
12895 (assq 'dormant marked) (nth 2 info))))
12897 (gnus-gethash (car info) gnus-newsrc-hashtb)
12898 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
12899 (length (cdr (assq 'dormant marked)))))))))
12902 (defun gnus-remove-illegal-marked-articles (marked ranges)
12903 (let ((m (cdr marked)))
12904 ;; Make sure that all ticked articles are a subset of the unread
12907 (if (gnus-member-of-range (car m) ranges)
12908 (setcdr marked (cdr m))
12910 (setq m (cdr m)))))
12912 (defun gnus-activate-newsgroup (group)
12913 (let ((method (gnus-find-method-for-group group))
12915 (and (or (gnus-server-opened method) (gnus-open-server method))
12916 (gnus-request-group group)
12918 (set-buffer nntp-server-buffer)
12920 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
12922 (goto-char (match-beginning 1))
12924 group (setq active (cons (read (current-buffer))
12925 (read (current-buffer))))
12926 gnus-active-hashtb))
12929 (defun gnus-update-read-articles
12930 (group unread unselected ticked &optional domarks replied expirable killed
12931 dormant bookmark score)
12932 "Update the list of read and ticked articles in GROUP using the
12933 UNREAD and TICKED lists.
12934 Note: UNSELECTED has to be sorted over `<'.
12935 Returns whether the updating was successful."
12936 (let* ((active (gnus-gethash group gnus-active-hashtb))
12937 (entry (gnus-gethash group gnus-newsrc-hashtb))
12938 (number (car entry))
12939 (info (nth 2 entry))
12940 (marked (nth 3 info))
12942 (unread (sort (copy-sequence unread) (function <)))
12944 (if (or (not info) (not active))
12945 ;; There is no info on this group if it was, in fact,
12946 ;; killed. Gnus stores no information on killed groups, so
12947 ;; there's nothing to be done.
12948 ;; One could store the information somewhere temporarily,
12949 ;; perhaps... Hmmm...
12951 ;; Remove any negative articles numbers.
12952 (while (and unread (< (car unread) 0))
12953 (setq unread (cdr unread)))
12954 (setq unread (sort (append unselected unread) '<))
12955 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12956 (setcar entry (max 0 (- (length unread) (length ticked)
12957 (length dormant))))
12958 ;; Compute the ranges of read articles by looking at the list of
12959 ;; unread articles.
12961 (if (/= (car unread) prev)
12962 (setq read (cons (if (= prev (1- (car unread))) prev
12963 (cons prev (1- (car unread)))) read)))
12964 (setq prev (1+ (car unread)))
12965 (setq unread (cdr unread)))
12966 (if (<= prev (cdr active))
12967 (setq read (cons (cons prev (cdr active)) read)))
12968 ;; Enter this list into the group info.
12969 (setcar (cdr (cdr info))
12970 (if (> (length read) 1) (nreverse read) read))
12971 ;; Enter the list of ticked articles.
12972 (gnus-set-marked-articles
12974 (if domarks replied (cdr (assq 'reply marked)))
12975 (if domarks expirable (cdr (assq 'expire marked)))
12976 (if domarks killed (cdr (assq 'killed marked)))
12977 (if domarks dormant (cdr (assq 'dormant marked)))
12978 (if domarks bookmark (cdr (assq 'bookmark marked)))
12979 (if domarks score (cdr (assq 'score marked))))
12982 (defun gnus-make-articles-unread (group articles)
12983 "Mark ARTICLES in GROUP as unread."
12984 (let ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
12985 (gnus-gethash (gnus-group-real-name group)
12986 gnus-newsrc-hashtb)))))
12987 (setcar (nthcdr 2 info)
12988 (gnus-remove-from-range (nth 2 info) articles))
12989 (gnus-group-update-group group t)))
12991 (defun gnus-read-active-file ()
12992 "Get active file from NNTP server."
12993 (gnus-group-set-mode-line)
12994 (let ((methods (cons gnus-select-method gnus-secondary-select-methods)))
12995 (setq gnus-have-read-active-file nil)
12997 (let* ((where (nth 1 (car methods)))
12998 (mesg (format "Reading active file%s via %s..."
12999 (if (and where (not (zerop (length where))))
13000 (concat " from " where) "")
13001 (car (car methods)))))
13003 (gnus-check-news-server (car methods))
13004 (if (gnus-request-list (car methods)) ; Get active
13006 (set-buffer nntp-server-buffer)
13007 (gnus-active-to-gnus-format
13008 (and gnus-have-read-active-file (car methods)))
13009 (setq gnus-have-read-active-file t)
13010 (message "%s...done" mesg))
13011 (message "Cannot read active file from %s server."
13012 (car (car methods)))
13014 (setq methods (cdr methods)))))
13016 ;; rewritten by jwz based on ideas from Rick Sladkey <jrs@world.std.com>
13017 ;; Further rewrites by lmi.
13018 (defun gnus-active-to-gnus-format (method &optional hashtb)
13019 "Convert active file format to internal format.
13020 Lines matching `gnus-ignored-newsgroups' are ignored."
13021 (let ((cur (current-buffer))
13025 (setq gnus-active-hashtb
13026 (gnus-make-hashtable
13027 (count-lines (point-min) (point-max))))))))
13028 ;; Delete unnecessary lines.
13029 (goto-char (point-min))
13030 (delete-matching-lines gnus-ignored-newsgroups)
13031 (and method (not (eq method gnus-select-method))
13032 (let ((prefix (gnus-group-prefixed-name "" method)))
13033 (goto-char (point-min))
13034 (while (and (not (eobp))
13035 (null (insert prefix))
13036 (zerop (forward-line 1))))))
13037 (goto-char (point-min))
13038 ;; Store active file in hashtable.
13040 (if (or (re-search-forward "\n.\r?$" nil t)
13041 (goto-char (point-max)))
13043 (beginning-of-line)
13044 (narrow-to-region (point-min) (point))))
13045 (goto-char (point-min))
13046 (if (string-match "%[oO]" gnus-group-line-format)
13047 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
13048 ;; If we want information on moderated groups, we use this
13051 (let ((mod-hashtb (make-vector 7 0))
13053 (while (not (eobp))
13054 (setq group (let ((obarray hashtb))
13056 (setq max (read cur))
13057 (set group (cons (read cur) max))
13058 ;; Enter moderated groups into a list.
13060 (symbol-name (let ((obarray mod-hashtb)) (read cur)))
13062 (setq gnus-moderated-list
13063 (cons (symbol-name group) gnus-moderated-list)))
13066 (progn (ding) (message "Possible error in active file."))))
13067 ;; And if we do not care about moderation, we use this loop,
13068 ;; which is faster.
13071 (while (not (eobp))
13072 ;; group gets set to a symbol interned in the hash table
13074 (setq group (let ((obarray hashtb)) (read cur)))
13075 (setq max (read cur))
13076 (set group (cons (read cur) max))
13079 (progn (ding) (message "Possible error in active file."))))))))
13081 (defun gnus-read-newsrc-file (&optional force)
13082 "Read startup file.
13083 If FORCE is non-nil, the .newsrc file is read."
13084 (setq gnus-current-startup-file (gnus-make-newsrc-file gnus-startup-file))
13085 ;; Reset variables that might be defined in the .newsrc.eld file.
13086 (let ((variables gnus-variable-list))
13088 (set (car variables) nil)
13089 (setq variables (cdr variables))))
13090 (let* ((newsrc-file gnus-current-startup-file)
13091 (quick-file (concat newsrc-file ".el")))
13093 ;; We always load the .newsrc.eld file. If always contains
13094 ;; much information that can not be gotten from the .newsrc
13095 ;; file (ticked articles, killed groups, foreign methods, etc.)
13096 (gnus-read-newsrc-el-file quick-file)
13099 (and (file-newer-than-file-p newsrc-file quick-file)
13100 (file-newer-than-file-p newsrc-file
13101 (concat quick-file "d")))
13102 (not gnus-newsrc-assoc))
13103 ;; We read the .newsrc file. Note that if there if a
13104 ;; .newsrc.eld file exists, it has already been read, and
13105 ;; the `gnus-newsrc-hashtb' has been created. While reading
13106 ;; the .newsrc file, Gnus will only use the information it
13107 ;; can find there for changing the data already read -
13108 ;; ie. reading the .newsrc file will not trash the data
13109 ;; already read (except for read articles).
13111 (message "Reading %s..." newsrc-file)
13112 (set-buffer (find-file-noselect newsrc-file))
13113 (buffer-disable-undo (current-buffer))
13114 (gnus-newsrc-to-gnus-format)
13115 (kill-buffer (current-buffer))
13116 (message "Reading %s... done" newsrc-file)))
13117 (and gnus-use-dribble-file (gnus-dribble-read-file)))))
13119 (defun gnus-read-newsrc-el-file (file)
13120 (let ((ding-file (concat file "d")))
13121 ;; We always, always read the .eld file.
13122 (message "Reading %s..." ding-file)
13123 (condition-case nil
13124 (load ding-file t t t)
13126 (gnus-uncompress-newsrc-assoc)
13127 (gnus-make-hashtable-from-newsrc-alist)
13128 (if (not (file-newer-than-file-p file ding-file))
13130 ;; Old format quick file
13131 (message "Reading %s..." file)
13132 ;; The .el file is newer than the .eld file, so we read that one
13134 (gnus-read-old-newsrc-el-file file))))
13136 ;; Parse the old-style quick startup file
13137 (defun gnus-read-old-newsrc-el-file (file)
13138 (let (newsrc killed marked group g m len info)
13140 (let (gnus-killed-assoc gnus-marked-assoc gnus-newsrc-assoc)
13142 (condition-case nil
13145 (setq newsrc gnus-newsrc-assoc
13146 killed gnus-killed-assoc
13147 marked gnus-marked-assoc)))
13148 (setq gnus-newsrc-assoc nil)
13150 (setq group (car newsrc))
13151 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
13154 (setcar (nthcdr 2 info) (cdr (cdr group)))
13155 (setcar (cdr info) (if (nth 1 group) 3 6))
13156 (setq gnus-newsrc-assoc (cons info gnus-newsrc-assoc)))
13157 (setq gnus-newsrc-assoc
13161 (if (nth 1 group) 3 6) (cdr (cdr group))))
13162 gnus-newsrc-assoc)))
13163 (if (setq m (assoc (car group) marked))
13164 (setcdr (cdr (cdr info)) (cons (list (cons 'tick (cdr m))) nil))))
13165 (setq newsrc (cdr newsrc)))
13166 (setq newsrc killed)
13168 (setcar newsrc (car (car newsrc)))
13169 (setq newsrc (cdr newsrc)))
13170 (setq gnus-killed-list killed))
13171 (setq gnus-newsrc-assoc (nreverse gnus-newsrc-assoc))
13172 (gnus-make-hashtable-from-newsrc-alist)))
13174 (defun gnus-make-newsrc-file (file)
13175 "Make server dependent file name by catenating FILE and server host name."
13176 (let* ((file (expand-file-name file nil))
13177 (real-file (concat file "-" (nth 1 gnus-select-method))))
13178 (if (file-exists-p real-file)
13181 (defun gnus-uncompress-newsrc-assoc ()
13182 ;; Uncompress all lists of marked articles in the newsrc assoc.
13183 (let ((newsrc gnus-newsrc-assoc)
13186 (if (not (setq marked (nth 3 (car newsrc))))
13189 (or (eq 'score (car (car marked)))
13190 (eq 'bookmark (car (car marked)))
13191 (eq 'killed (car (car marked)))
13192 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
13193 (setq marked (cdr marked))))
13194 (setq newsrc (cdr newsrc)))))
13196 (defun gnus-compress-newsrc-assoc ()
13197 ;; Compress all lists of marked articles in the newsrc assoc.
13198 (let ((newsrc gnus-newsrc-assoc)
13201 (if (not (setq marked (nth 3 (car newsrc))))
13204 (or (eq 'score (car (car marked)))
13205 (eq 'bookmark (car (car marked)))
13206 (eq 'killed (car (car marked)))
13207 (setcdr (car marked)
13208 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
13209 (setq marked (cdr marked))))
13210 (setq newsrc (cdr newsrc)))))
13212 ;; jwz: rewrote this function to be much more efficient, and not be
13213 ;; subject to regexp overflow errors when it encounters very long
13214 ;; lines -- the old behavior was to blow off the rest of the *file*
13215 ;; when a line was encountered that was too long to match!! Now it
13216 ;; uses only simple looking-at calls, and doesn't create as many
13217 ;; temporary strings. It also now handles multiple consecutive
13218 ;; options lines (before it only handled the first.)
13219 ;; Tiny rewrite by lmi.
13220 (defun gnus-newsrc-to-gnus-format ()
13221 "Parse current buffer as .newsrc file."
13222 ;; We have to re-initialize these variables (except for
13223 ;; gnus-killed-list) because the quick startup file may contain bogus
13225 (setq gnus-newsrc-options nil)
13226 (setq gnus-newsrc-options-n nil)
13227 (gnus-parse-options-lines)
13228 (gnus-parse-newsrc-body))
13230 (defun gnus-parse-options-lines ()
13231 ;; newsrc.5 seems to indicate that the options line can come anywhere
13232 ;; in the file, and that there can be any number of them:
13234 ;; An options line starts with the word options (left-
13235 ;; justified). Then there are the list of options just as
13236 ;; they would be on the readnews command line. For instance:
13238 ;; options -n all !net.sf-lovers !mod.human-nets -r
13241 ;; A string of lines beginning with a space or tab after the
13242 ;; initial options line will be considered continuation
13245 ;; For now, we only accept it at the beginning of the file.
13247 (goto-char (point-min))
13248 (skip-chars-forward " \t\n")
13249 (setq gnus-newsrc-options nil)
13250 (while (looking-at "^options[ \t]*\\(.*\\)\n")
13251 ;; handle consecutive options lines
13252 (setq gnus-newsrc-options (concat gnus-newsrc-options
13253 (if gnus-newsrc-options "\n\t")
13254 (buffer-substring (match-beginning 1)
13257 (while (looking-at "[ \t]+\\(.*\\)\n")
13258 ;; handle subsequent continuation lines of this options line
13259 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n\t"
13260 (buffer-substring (match-beginning 1)
13263 ;; Gather all "-n" options lines.
13266 (if gnus-newsrc-options
13267 (while (and (string-match "^[ \t]*-n\\([^\n]*\\)$"
13268 gnus-newsrc-options
13270 (setq start (match-end 0)))
13271 (setq result (concat result
13273 (substring gnus-newsrc-options
13274 (match-beginning 1)
13277 (and result (gnus-parse-n-options result))
13280 (defun gnus-parse-newsrc-body ()
13281 ;; Point has been positioned after the options lines. We shouldn't
13282 ;; see any more in here.
13284 (let ((subscribe nil)
13286 (line (1+ (count-lines (point-min) (point))))
13290 (skip-chars-forward " \t")
13291 (while (not (eobp))
13293 ((= (following-char) ?\n)
13294 ;; skip blank lines
13298 (skip-chars-forward "^:!\n")
13299 (if (= (following-char) ?\n)
13300 (error "line %d is unparsable in %s" line (buffer-name)))
13302 (skip-chars-backward " \t")
13304 ;; #### note: we could avoid consing a string here by binding obarray
13305 ;; and reading the newsgroup directly into the gnus-newsrc-hashtb,
13306 ;; then setq'ing newsgroup to symbol-name of that, like we do in
13307 ;; gnus-active-to-gnus-format.
13308 (setq newsgroup (buffer-substring p (point)))
13311 (setq subscribe (= (following-char) ?:))
13312 (setq read-list nil)
13314 (forward-char 1) ; after : or !
13315 (skip-chars-forward " \t")
13316 (while (not (= (following-char) ?\n))
13317 (skip-chars-forward " \t")
13320 ((looking-at "\\([0-9]+\\)-\\([0-9]+\\)") ; a range
13325 ;; faster that buffer-substring/string-to-int
13326 (narrow-to-region (point-min) (match-end 1))
13327 (read (current-buffer)))
13329 (narrow-to-region (point-min) (match-end 2))
13330 (forward-char) ; skip over "-"
13332 (read (current-buffer))
13336 ((looking-at "[0-9]+")
13337 ;; faster that buffer-substring/string-to-int
13338 (narrow-to-region (point-min) (match-end 0))
13339 (setq p (read (current-buffer)))
13341 (setq read-list (cons (cons p p) read-list))
13344 ;; bogus chars in ranges
13347 (goto-char (match-end 0))
13348 (skip-chars-forward " \t")
13349 (cond ((= (following-char) ?,)
13352 ((= (following-char) ?\n)
13355 ;; bogus char after range
13357 ;; if we get here, the parse failed
13359 (end-of-line) ; give up on this line
13361 (message "Ignoring bogus line %d for %s in %s"
13362 line newsgroup (buffer-name))
13364 ;; We have already read .newsrc.eld, so we gently update the
13365 ;; data in the hash table with the information we have just
13367 (let ((info (nth 2 (gnus-gethash newsgroup gnus-newsrc-hashtb))))
13370 (setcar (nthcdr 2 info) (nreverse read-list))
13371 (setcar (cdr info) (if subscribe 3 (if read-list 6 7))))
13372 (setq gnus-newsrc-assoc
13373 (cons (list newsgroup (if subscribe 3 (if read-list 6 7))
13374 (nreverse read-list))
13375 gnus-newsrc-assoc))))))
13376 (setq line (1+ line))
13377 (forward-line 1))))
13378 (setq gnus-newsrc-assoc (cdr gnus-newsrc-assoc))
13379 (gnus-make-hashtable-from-newsrc-alist)
13382 (defun gnus-parse-n-options (options)
13383 "Parse -n NEWSGROUPS options and return a cons of YES and NO regexps."
13384 (let (yes no yes-or-no out newsgroup)
13385 ;; Parse each newsgroup description such as "comp.all". Commas
13386 ;; and white spaces can be a newsgroup separator.
13388 (string-match "^[ \t\n,]*\\(!?\\)\\([^- \t\n,][^ \t\n,]*\\)" options)
13390 (substring options (match-beginning 1) (match-end 1)))
13394 (match-beginning 2) (match-end 2))))
13395 (setq options (substring options (match-end 2)))
13396 ;; Rewrite "all" to ".+" not ".*". ".+" requires at least one
13398 (while (string-match "\\(^\\|\\\\[.]\\)all\\(\\\\[.]\\|$\\)" newsgroup)
13400 (concat (substring newsgroup 0 (match-end 1))
13402 (substring newsgroup (match-beginning 2)))))
13403 ;; It is yes or no.
13404 (setq out (cons (cons (if (string= yes-or-no "!") 'ignore 'subscribe)
13405 (concat "^" newsgroup "$"))
13407 (setq gnus-newsrc-options-n out)))
13409 (defun gnus-save-newsrc-file ()
13410 "Save .newsrc file."
13411 ;; Note: We cannot save .newsrc file if all newsgroups are removed
13412 ;; from the variable gnus-newsrc-assoc.
13413 (and (or gnus-newsrc-assoc gnus-killed-list)
13414 gnus-current-startup-file
13416 (if (or (not gnus-dribble-buffer)
13417 (not (buffer-name gnus-dribble-buffer))
13418 (zerop (save-excursion
13419 (set-buffer gnus-dribble-buffer)
13421 (message "(No changes need to be saved)")
13422 (if gnus-save-newsrc-file
13423 (let ((make-backup-files t)
13424 (version-control nil)
13425 (require-final-newline t)) ;Don't ask even if requested.
13426 (message "Saving %s..." gnus-current-startup-file)
13427 ;; Make backup file of master newsrc.
13428 ;; You can stop or change version control of backup file.
13429 ;; Suggested by jason@violet.berkeley.edu.
13430 (run-hooks 'gnus-save-newsrc-hook)
13431 (gnus-gnus-to-newsrc-format)
13432 (message "Saving %s... done" gnus-current-startup-file)))
13433 ;; Quickly loadable .newsrc.
13434 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
13435 (gnus-add-current-to-buffer-list)
13436 (buffer-disable-undo (current-buffer))
13438 (message "Saving %s.eld..." gnus-current-startup-file)
13439 (gnus-gnus-to-quick-newsrc-format)
13440 (let ((make-backup-files nil)
13441 (version-control nil)
13442 (require-final-newline t)) ;Don't ask even if requested.
13443 (write-region 1 (point-max)
13444 (concat gnus-current-startup-file ".eld")
13446 (kill-buffer (current-buffer))
13447 (message "Saving %s.eld... done" gnus-current-startup-file)
13448 (gnus-dribble-delete-file)))))
13450 (defun gnus-gnus-to-quick-newsrc-format ()
13451 "Insert Gnus variables such as gnus-newsrc-assoc in lisp format."
13452 (insert ";; (ding) Gnus startup file.\n")
13453 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
13454 (insert ";; to read .newsrc.\n")
13455 (let ((variables gnus-variable-list)
13456 (gnus-newsrc-assoc (cdr gnus-newsrc-assoc))
13458 ;; insert lisp expressions.
13459 (gnus-compress-newsrc-assoc)
13461 (setq variable (car variables))
13462 (and (boundp variable)
13463 (symbol-value variable)
13464 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
13465 (insert "(setq " (symbol-name variable) " '"
13466 (prin1-to-string (symbol-value variable))
13468 (setq variables (cdr variables)))
13469 (gnus-uncompress-newsrc-assoc)))
13472 (defun gnus-gnus-to-newsrc-format ()
13473 ;; Generate and save the .newsrc file.
13474 (let ((newsrc (cdr gnus-newsrc-assoc))
13477 (set-buffer (create-file-buffer gnus-startup-file))
13478 (buffer-disable-undo (current-buffer))
13481 (if gnus-newsrc-options (insert "options " gnus-newsrc-options "\n"))
13482 ;; Write subscribed and unsubscribed.
13484 (setq info (car newsrc))
13485 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
13487 (insert (car info) (if (>= (nth 1 info) 6) "!" ":"))
13488 (if (setq ranges (nth 2 info))
13491 (if (not (listp (cdr ranges)))
13492 (if (= (car ranges) (cdr ranges))
13493 (insert (int-to-string (car ranges)))
13494 (insert (int-to-string (car ranges)) "-"
13495 (int-to-string (cdr ranges))))
13497 (setq range (car ranges)
13498 ranges (cdr ranges))
13499 (if (or (atom range) (= (car range) (cdr range)))
13500 (insert (int-to-string
13501 (or (and (atom range) range)
13503 (insert (int-to-string (car range)) "-"
13504 (int-to-string (cdr range))))
13505 (if ranges (insert ","))))))
13507 (setq newsrc (cdr newsrc)))
13508 (write-region 1 (point-max) gnus-current-startup-file nil 'nomesg)
13509 (kill-buffer (current-buffer)))))
13511 (defun gnus-read-descriptions-file ()
13512 (message "Reading descriptions file...")
13513 (if (not (gnus-request-list-newsgroups gnus-select-method))
13515 (message "Couldn't read newsgroups descriptions")
13518 (setq gnus-description-hashtb
13519 (gnus-make-hashtable (length gnus-active-hashtb)))
13522 (set-buffer nntp-server-buffer)
13523 (goto-char (point-min))
13524 (delete-non-matching-lines "^[-\\._+A-Za-z0-9]+[ \t]")
13525 (goto-char (point-min))
13526 (if (or (search-forward "\n.\n" nil t)
13527 (goto-char (point-max)))
13529 (beginning-of-line)
13530 (narrow-to-region (point-min) (point))))
13531 (goto-char (point-min))
13532 (while (not (eobp))
13533 (setq group (let ((obarray gnus-description-hashtb))
13534 (read (current-buffer))))
13535 (skip-chars-forward " \t")
13536 (set group (buffer-substring
13537 (point) (save-excursion (end-of-line) (point))))
13538 (forward-line 1))))
13539 (message "Reading descriptions file...done")
13542 (defun gnus-group-get-description (group)
13543 ;; Get the description of a group by sending XGTITLE to the server.
13544 (and (gnus-request-group-description group)
13546 (set-buffer nntp-server-buffer)
13547 (goto-char (point-min))
13548 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
13549 (buffer-substring (match-beginning 1) (match-end 1))))))
13553 ;;; gnus.el ends here