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 "/ftp@rtfm.mit.edu:/pub/usenet-by-group/"
140 "Directory where the group FAQs are stored.
141 This will most commonly be on a remote machine, and the file will be
142 fetched by ange-ftp.")
144 (defvar gnus-default-subscribed-newsgroups nil
145 "This variable lists what newsgroups should be susbcribed the first time Gnus is used.
146 It should be a list of strings.
147 If it is `t', Gnus will not do anything special the first time it is
148 started; it'll just use the normal newsgroups subscription methods.")
150 (defvar gnus-post-prepare-function nil
151 "Function that is run after a post buffer has been prepared.
152 It is called with the name of the newsgroup that is posted to. It
153 might be used, for instance, for inserting signatures based on the
154 newsgroup name. (In that case, `gnus-signature-file' and
155 `mail-signature' should both be set to nil).")
157 (defvar gnus-use-cross-reference t
158 "Non-nil means that cross referenced articles will be marked as read.
159 If nil, ignore cross references. If t, mark articles as read in
160 subscribed newsgroups. If neither t nor nil, mark as read in all
163 (defvar gnus-use-dribble-file t
164 "Non-nil means that Gnus will use a dribble file to store user updates.
165 If Emacs should crash without saving the .newsrc files, complete
166 information can be restored from the dribble file.")
168 (defvar gnus-use-followup-to 'use
169 "Specifies what to do with Followup-To header.
170 If nil, ignore the header. If it is t, use its value, but ignore
171 `poster'. If it is neither nil nor t, which is the default, always use
174 (defvar gnus-followup-to-function nil
175 "A variable that contains a function that returns a followup address.
176 The function will be called in the buffer of the article that is being
177 followed up. The buffer will be narrowed to the headers of the
178 article. To pick header headers, one might use `mail-fetch-field'. The
179 function will be called with the name of the current newsgroup as the
182 Here's an example `gnus-followup-to-function':
184 (setq gnus-followup-to-function
186 (cond ((string= group \"mail.list\")
187 (or (mail-fetch-field \"sender\")
188 (mail-fetch-field \"from\")))
190 (or (mail-fetch-field \"reply-to\")
191 (mail-fetch-field \"from\"))))))")
193 (defvar gnus-reply-to-function nil
194 "A variable that contains a function that returns a reply address.
195 See the `gnus-followup-to-function' variable for an explanation of how
196 this variable is used.")
198 (defvar gnus-large-newsgroup 200
199 "The number of articles which indicates a large newsgroup.
200 If the number of articles in a newsgroup is greater than this value,
201 confirmation is required for selecting the newsgroup.")
203 (defvar gnus-author-copy (getenv "AUTHORCOPY")
204 "Save outgoing articles in this file.
205 Initialized from the AUTHORCOPY environment variable.
207 If this variable begins with the character \"|\", outgoing articles
208 will be piped to the named program. It is possible to save an article
209 in an MH folder as follows:
211 \(setq gnus-author-copy \"|/usr/local/lib/mh/rcvstore +Article\")
213 If the first character is not a pipe, articles are saved using the
214 function specified by the `gnus-author-copy-saver' variable.")
216 (defvar gnus-mail-self-blind nil
217 "Non-nil means insert a BCC header in all outgoing articles.
218 This will result in having a copy of the article mailed to yourself.
219 The BCC header is inserted when the post buffer is initialized, so you
220 can remove or alter the BCC header to override the default.")
222 (defvar gnus-author-copy-saver (function rmail-output)
223 "A function called to save outgoing articles.
224 This function will be called with the same of the file to store the
225 article in. The default function is `rmail-output' which saves in Unix
228 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
229 "Non-nil means that the default name of a file to save articles in is the group name.
230 If it's nil, the directory form of the group name is used instead.")
232 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
233 "Name of the directory articles will be saved in (default \"~/News\").
234 Initialized from the SAVEDIR environment variable.")
236 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
237 "Name of the directory where kill files will be stored (default \"~/News\").
238 Initialized from the SAVEDIR environment variable.")
240 (defvar gnus-score-expiry-days 7
241 "*Number of days before unused score file entries are expired.")
243 (defvar gnus-default-article-saver (function gnus-summary-save-in-rmail)
244 "A function to save articles in your favorite format.
245 The function must be interactively callable (in other words, it must
246 be an Emacs command).
248 Gnus provides the following functions:
250 * gnus-summary-save-in-rmail (Rmail format)
251 * gnus-summary-save-in-mail (Unix mail format)
252 * gnus-summary-save-in-folder (MH folder)
253 * gnus-summary-save-in-file (article format).")
255 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
256 "A function generating a file name to save articles in Rmail format.
257 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
259 (defvar gnus-mail-save-name (function gnus-plain-save-name)
260 "A function generating a file name to save articles in Unix mail format.
261 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
263 (defvar gnus-folder-save-name (function gnus-folder-save-name)
264 "A function generating a file name to save articles in MH folder.
265 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
267 (defvar gnus-file-save-name (function gnus-numeric-save-name)
268 "A function generating a file name to save articles in article format.
269 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
271 (defvar gnus-score-file-suffix "SCORE"
272 "Suffix of the score files.")
274 (defvar gnus-fetch-old-headers nil
275 "Non-nil means that Gnus will try to build threads by grabbing old headers.
276 If an unread article in the group refers to an older, already read (or
277 just marked as read) article, the old article will not normally be
278 displayed in the Summary buffer. If this variable is non-nil, Gnus
279 will attempt to grab the headers to the old articles, and thereby
280 build complete threads. If it has the value `some', only enough
281 headers to connect otherwise loose threads will be displayed.
283 The server has to support XOVER for any of this to work.")
285 (defvar gnus-visual t
286 "*If non-nil, will do various highlighting.
287 If nil, no mouse highlights (or any other highlights) will be
288 performed. This might speed up Gnus some when generating large group
289 and summary buffers.")
291 (defvar gnus-novice-user t
292 "*Non-nil means that you are a usenet novice.
293 If non-nil, verbose messages may be displayed and confirmations may be
296 (defvar gnus-expert-user nil
297 "*Non-nil means that you will never be asked for confirmation about anything.
298 And that means *anything*.")
300 (defvar gnus-keep-same-level nil
301 "Non-nil means that the next newsgroup after the current will be on the same level.
302 When you type, for instance, `n' after reading the last article in the
303 current newsgroup, you will go to the next newsgroup. If this variable
304 is nil, the next newsgroup will be the next from the group
306 If this variable is non-nil, Gnus will either put you in the
307 next newsgroup with the same level, or, if no such newsgroup is
308 available, the next newsgroup with the lowest possible level higher
309 than the current level.
310 If this variable is `best', Gnus will make the next newsgroup the one
311 with the best level.")
313 (defvar gnus-summary-make-false-root 'adopt
314 "nil means that Gnus won't gather loose threads.
315 If the root of a thread has expired or been read in a previous
316 session, the information necessary to build a complete thread has been
317 lost. Instead of having many small sub-threads from this original thread
318 scattered all over the summary buffer, Gnus can gather them.
320 If non-nil, Gnus will try to gather all loose sub-threads from an
321 original thread into one large thread.
323 If this variable is non-nil, it should be one of `none', `adopt',
326 If this variable is `none', Gnus will not make a false root, but just
327 present the sub-threads after another.
328 If this variable is `dummy', Gnus will create a dummy root that will
329 have all the sub-threads as children.
330 If this variable is `adopt', Gnus will make one of the \"children\"
331 the parent and mark all the step-children as such.
332 If this variable is `empty', the \"children\" are printed with empty
333 subject fields. (Or rather, they will be printed with a string
334 given by the `gnus-summary-same-subject' variable.)")
336 (defvar gnus-summary-gather-subject-limit nil
337 "*Maximum length of subject comparisons when gathering loose threads.
338 Use nil to compare full subjects. Setting this variable to a low
339 number will help gather threads that have been corrupted by
340 newsreaders chopping off subject lines, but it might also mean that
341 unrelated articles that have subject that happen to begin with the
342 same few characters will be incorrectly gathered.")
344 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
345 (defvar gnus-summary-same-subject ""
346 "String indicating that the current article has the same subject as the previous.
347 This variable will only be used if the value of
348 `gnus-summary-make-false-root' is `empty'.")
350 (defvar gnus-summary-goto-unread nil
351 "If non-nil, marking commands will go to the next unread article.")
353 (defvar gnus-check-new-newsgroups t
354 "Non-nil means that Gnus will add new newsgroups at startup.
355 If this variable is `ask-server', Gnus will ask the server for new
356 groups since the last time it checked. This means that the killed list
357 is no longer necessary, so you could set `gnus-save-killed-list' to
360 A variant is to have this variable be a list of select methods. Gnus
361 will then use the `ask-server' method on all these select methods to
362 query for new groups from all those servers.
365 (setq gnus-check-new-newsgroups
366 '((nntp \"some.server\") (nntp \"other.server\")))
368 If this variable is nil, then you have to tell Gnus explicitly to
369 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
371 (defvar gnus-check-bogus-newsgroups nil
372 "Non-nil means that Gnus will check and remove bogus newsgroup at startup.
373 If this variable is nil, then you have to tell Gnus explicitly to
374 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
376 (defvar gnus-read-active-file t
377 "Non-nil means that Gnus will read the entire active file at startup.
378 If this variable is nil, Gnus will only read parts of the active file.")
380 (defvar gnus-activate-foreign-newsgroups nil
381 "If nil, Gnus will not check foreign newsgroups at startup.
382 If it is non-nil, it should be a number between one and nine. Foreign
383 newsgroups that have a level lower or equal to this number will be
384 activated on startup. For instance, if you want to active all
385 subscribed newsgroups, but not the rest, you'd set this variable to 5.
387 If you subscribe to lots of newsgroups from different servers, startup
388 might take a while. By setting this variable to nil, you'll save time,
389 but you won't be told how many unread articles there are in the
392 (defvar gnus-save-newsrc-file t
393 "Non-nil means that Gnus will save the `.newsrc' file.
394 Gnus always saves its own startup file, which is called
395 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
396 be readily understood by other newsreaders. If you don't plan on
397 using other newsreaders, set this variable to nil to save some time on
400 (defvar gnus-save-killed-list t
401 "If non-nil, save the list of killed groups to the startup file.
402 This will save both time (when starting and quitting) and space (both
403 memory and disk), but it will also mean that Gnus has no record of
404 which groups are new and which are old, so the automatic new
405 newsgroups subscription methods become meaningless. You should always
406 set `gnus-check-new-newsgroups' to `ask-server' or nil if you set this
409 (defvar gnus-interactive-catchup t
410 "If non-nil, require your confirmation when catching up a group.")
412 (defvar gnus-interactive-post t
413 "If non-nil, group name will be asked for when posting.")
415 (defvar gnus-interactive-exit t
416 "If non-nil, require your confirmation when exiting Gnus.")
418 (defvar gnus-kill-killed nil
419 "If non-nil, Gnus will apply kill files to already killed articles.
420 If it is nil, Gnus will never apply kill files to articles that have
421 already been through the scoring process, which might very well save lots
424 (defvar gnus-extract-address-components 'gnus-extract-address-components
425 "Function for extracting address components from a From header.
426 Two pre-defined function exist: `gnus-extract-address-components',
427 which is the default, quite fast, and too simplistic solution, and
428 `mail-extract-address-components', which works much better, but is
431 (defvar gnus-score-interactive-default-score 1000
432 "Scoring commands will raise/lower the score with this number as the default.")
434 (defvar gnus-save-score nil
435 "If non-nil, save group scoring info.")
437 (defvar gnus-global-score-files nil
438 "List of global score files and directories.
439 Set this variable if you want to use people's score files. One entry
440 for each score file or each score file directory. Gnus will decide
441 by itself what score files are applicable to which group.
443 Say you want to use the single score file
444 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all
445 score files in the \"/ftp.some-where:/pub/score\" directory.
447 (setq gnus-global-score-files
448 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\"
449 \"/ftp.some-where:/pub/score\"))")
451 (defvar gnus-summary-default-score 0
452 "Default article score level.
453 If this variable is nil, scoring will be disabled.")
455 (defvar gnus-user-login-name nil
456 "The login name of the user.
457 Got from the function `user-login-name' if undefined.")
459 (defvar gnus-user-full-name nil
460 "The full name of the user.
461 Got from the NAME environment variable if undefined.")
463 (defvar gnus-show-mime nil
464 "*If non-ni, do mime processing of articles.
465 The articles will simply be fed to the function given by
466 `gnus-show-mime-method'.")
468 (defvar gnus-show-mime-method (function metamail-buffer)
469 "Function to process a MIME message.
470 The function is called from the article buffer.")
472 (defvar gnus-show-threads t
473 "*If non-nil, display threads in summary mode.")
475 (defvar gnus-thread-hide-subtree nil
476 "If non-nil, hide all threads initially.
477 If threads are hidden, you have to run the command
478 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
479 to expose hidden threads.")
481 (defvar gnus-thread-hide-killed t
482 "If non-nil, hide killed threads automatically.")
484 (defvar gnus-thread-ignore-subject nil
485 "If non-nil, ignore subjects and do all threading based on the Reference header.
486 If nil, which is the default, articles that have different subjects
487 from their parents will start separate threads.")
489 (defvar gnus-thread-indent-level 4
490 "Number that says how much each sub-thread should be indented.")
492 ;; jwz: nuke newsgroups whose name is all digits - that means that
493 ;; some loser has let articles get into the root of the news spool,
494 ;; which is toxic. Lines beginning with whitespace also tend to be
496 (defvar gnus-ignored-newsgroups
497 (purecopy (mapconcat 'identity
498 '("^to\\." ; not "real" groups
499 "^[0-9. \t]+ " ; all digits in name
500 "[][\"#'() ;\\]" ; bogus characters
503 "A regexp to match uninteresting newsgroups in the active file.
504 Any lines in the active file matching this regular expression are
505 removed from the newsgroup list before anything else is done to it,
506 thus making them effectively non-existant.")
508 (defvar gnus-ignored-headers
509 "^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:"
510 "All headers that match this regexp will be hidden.
511 Also see `gnus-visible-headers'.")
513 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
514 "All headers that do not match this regexp will be hidden.
515 Also see `gnus-ignored-headers'.")
517 (defvar gnus-sorted-header-list
518 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
519 "^Cc:" "^Date:" "^Organization:")
520 "This variable is a list of regular expressions.
521 If it is non-nil, headers that match the regular expressions will
522 be placed first in the article buffer in the sequence specified by
525 (defvar gnus-required-headers
526 '(From Date Newsgroups Subject Message-ID Organization Lines X-Newsreader)
527 "Headers to be generated or prompted for when posting an article.
528 RFC977 and RFC1036 require From, Date, Newsgroups, Subject, Message-ID
529 and Path headers. Organization, Lines and X-Newsreader are optional.
530 If you want Gnus not to insert some header, remove it from this
533 (defvar gnus-show-all-headers nil
534 "*If non-nil, don't hide any headers.")
536 (defvar gnus-save-all-headers t
537 "*If non-nil, don't remove any headers before saving.")
539 (defvar gnus-inhibit-startup-message nil
540 "If non-nil, the startup message will not be displayed.")
542 (defvar gnus-auto-extend-newsgroup t
543 "If non-nil, extend newsgroup forward and backward when requested.")
545 (defvar gnus-auto-select-first t
546 "If non-nil, select the first unread article when entering a group.
547 If you want to prevent automatic selection of the first unread article
548 in some newsgroups, set the variable to nil in
549 `gnus-select-group-hook'.")
551 (defvar gnus-auto-select-next t
552 "If non-nil, offer to go to the next group from the end of the previous.
553 If the value is t and the next newsgroup is empty, Gnus will exit
554 summary mode and go back to group mode. If the value is neither nil
555 nor t, Gnus will select the following unread newsgroup. In
556 particular, if the value is the symbol `quietly', the next unread
557 newsgroup will be selected without any confirmations.")
559 (defvar gnus-auto-select-same nil
560 "If non-nil, select the next article with the same subject.")
562 (defvar gnus-auto-center-summary t
563 "*If non-nil, always center the current summary buffer.")
565 (defvar gnus-auto-mail-to-author nil
566 "*If non-nil, mail the authors of articles a copy of your follow-ups.
567 If this variable is `ask', the user will be prompted for whether to
568 mail a copy. The string given by `gnus-mail-courtesy-message' will be
569 inserted at the beginning of the mail copy.
571 Mail is sent using the function specified by the
572 `gnus-mail-send-method' variable.")
574 ;; Added by Ethan Bradford <ethanb@ptolemy.astro.washington.edu>.
575 (defvar gnus-mail-courtesy-message
576 "The following message is a courtesy copy of an article\nthat has been posted as well.\n\n"
577 "This is inserted at the start of a mailed copy of a posted message.
578 If this variable is nil, no such courtesy message will be added.")
580 (defvar gnus-break-pages t
581 "*If non-nil, do page breaking on articles.
582 The page delimiter is specified by the `gnus-page-delimiter'
585 (defvar gnus-page-delimiter "^\^L"
586 "Regexp describing what to use as article page delimiters.
587 The default value is \"^\^L\", which is a form linefeed at the
588 beginning of a line.")
590 (defvar gnus-use-full-window t
591 "*If non-nil, use the entire Emacs screen.")
593 (defvar gnus-window-configuration
597 "Specify window configurations for each action.
598 The format of the variable is either a list of (ACTION (G S A)), where
599 G, S, and A are the relative height of group, summary, and article
600 windows, respectively, or a list of (ACTION FUNCTION), where FUNCTION
601 is a function that will be called with ACTION as an argument. ACTION
602 can be `summary', `newsgroups', or `article'.")
604 (defvar gnus-mail-reply-method (function gnus-mail-reply-using-mail)
605 "Function to compose a reply.
606 Two pre-made functions are `gnus-mail-reply-using-mail' (sendmail) and
607 `gnus-mail-reply-using-mhe' (MH-E).")
609 (defvar gnus-mail-forward-method (function gnus-mail-forward-using-mail)
610 "Function to forward the current message to another user.
611 Two pre-made functions are `gnus-mail-forward-using-mail' (sendmail)
612 and `gnus-mail-forward-using-mhe' (MH-E).")
614 (defvar gnus-mail-other-window-method 'gnus-mail-other-window-using-mail
615 "Function to compose mail in the other window.
616 Two pre-made functions are `gnus-mail-other-window-using-mail'
617 (sendmail) and `gnus-mail-other-window-using-mhe' (MH-E).")
619 (defvar gnus-mail-send-method send-mail-function
620 "Function to mail a message which is also being posted as an article.
621 The message must have To or Cc header. The default is copied from
622 the variable `send-mail-function'.")
624 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
625 "Function called with a group name when new group is detected.
626 A few pre-made functions are supplied: `gnus-subscribe-randomly'
627 inserts new groups at the beginning of the list of groups;
628 `gnus-subscribe-alphabetically' inserts new groups in strict
629 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
630 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
633 ;; Suggested by a bug report by Hallvard B Furuseth
634 ;; <h.b.furuseth@usit.uio.no>.
635 (defvar gnus-subscribe-options-newsgroup-method
636 (function gnus-subscribe-alphabetically)
637 "This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
638 If, for instance, you want to subscribe to all newsgroups in the
639 \"no\" and \"alt\" hierarchies, you'd put the following in your
642 options -n no.all alt.all
644 Gnus will the subscribe all new newsgroups in these hierarchies with
645 the subscription method in this variable.")
647 (defvar gnus-subscribe-hierarchical-interactive nil
648 "If non-nil, Gnus will offer to subscribe hierarchically.
649 When a new hierarchy appears, Gnus will ask the user:
651 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
653 If the user pressed `d', Gnus will descend the hierarchy, `y' will
654 subscribe to all newsgroups in the hierarchy and `s' will skip this
655 hierarchy in its entirety.")
657 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
658 "Function used for sorting the group buffer.
659 This function will be called with group info entries as the arguments
660 for the groups to be sorted. Pre-made functions include
661 `gnus-sort-by-alphabet', `gnus-sort-by-unread' and
662 `gnus-sort-by-level'")
664 ;; Mark variables suggested by Thomas Michanek
665 ;; <Thomas.Michanek@telelogic.se>.
666 (defvar gnus-unread-mark ?
667 "Mark used for unread articles.")
668 (defvar gnus-ticked-mark ?!
669 "Mark used for ticked articles.")
670 (defvar gnus-dormant-mark ??
671 "Mark used for dormant articles.")
672 (defvar gnus-dread-mark ?D
673 "Mark used for read articles.")
674 (defvar gnus-read-mark ?d
675 "Mark used for read articles.")
676 (defvar gnus-expirable-mark ?E
677 "Mark used for expirable articles.")
678 (defvar gnus-killed-mark ?K
679 "Mark used for killed articles.")
680 (defvar gnus-kill-file-mark ?X
681 "Mark used for articles killed by kill files.")
682 (defvar gnus-low-score-mark ?Y
683 "Mark used for articles with a low score.")
684 (defvar gnus-catchup-mark ?C
685 "Mark used for articles that are caught up.")
686 (defvar gnus-replied-mark ?R
687 "Mark used for articles that have been replied to.")
688 (defvar gnus-process-mark ?#
690 (defvar gnus-ancient-mark ?A
691 "Mark used for ancient articles.")
692 (defvar gnus-canceled-mark ?G
693 "Mark used for cancelled articles.")
694 (defvar gnus-score-over-mark ?+
695 "Score mark used for articles with high scores.")
696 (defvar gnus-score-below-mark ?-
697 "Score mark used for articles with low scores.")
699 (defvar gnus-view-pseudo-asynchronously nil
700 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
702 (defvar gnus-view-pseudos nil
703 "If `automatic', pseudo-articles will be viewed automatically.
704 If `not-confirm', pseudos will be viewed automatically, and the user
705 will not be asked to confirm the command.")
707 (defvar gnus-group-line-format "%M%S%5y: %(%g%)\n"
708 "Format of groups lines.
709 It works along the same lines as a normal formatting string,
710 with some simple extensions.
712 %M Only marked articles (character, \"*\" or \" \")
713 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
714 %L Level of subscribedness (integer, 1-9)
715 %N Number of unread articles (integer)
716 %I Number of dormant articles (integer)
717 %i Number of ticked and dormant (integer)
718 %T Number of ticked articles (integer)
719 %R Number of read articles (integer)
720 %t Total number of articles (integer)
721 %y Number of unread, unticked articles (integer)
722 %G Group name (string)
723 %g Qualified group name (string)
724 %D Group description (string)
725 %s Select method (string)
726 %o Moderated group (char, \"m\")
727 %O Moderated group (string, \"(m)\" or \"\")
728 %n Select from where (string)
729 %z A string that look like `<%s:%n>' if a foreign select method is used
730 %u User defined specifier. The next character in the format string should
731 be a letter. Gnus will call the function gnus-user-format-function-X,
732 where X is the letter following %u. The function will be passed the
733 current header as argument. The function should return a string, which
734 will be inserted into the buffer just like information from any other
737 Text between %( and %) will be highlighted with `gnus-mouse-face' when
738 the mouse point move inside the area. There can only be one such area.
740 Note that this format specification is not always respected. For
741 reasons of efficiency, when listing killed groups, this specification
742 is ignored altogether. If the spec is changed considerably, your
743 output may end up looking strange when listing both alive and killed
746 If you use %o or %O, reading the active file will be slower and quite
747 a bit of extra memory will be used. %D will also worsen performance.
748 Also note that if you change the format specification to include any
749 of these specs, you must probably re-start Gnus to see them go into
752 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
753 "The format specification of the lines in the summary buffer.
755 It works along the same lines as a normal formatting string,
756 with some simple extensions.
758 %N Article number, left padded with spaces (string)
760 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
761 %n Name of the poster (string)
762 %A Address of the poster (string)
763 %L Number of lines in the article (integer)
764 %c Number of characters in the article (integer)
765 %D Date of the article (string)
766 %I Indentation based on thread level (a string of spaces)
767 %T A string with two possible values: 80 spaces if the article
768 is on thread level two or larger and 0 spaces on level one
769 %U Status of this article (character, \"D\", \"K\", \"-\" or \" \")
770 %[ Opening bracket (character, \"[\" or \"<\")
771 %] Closing bracket (character, \"]\" or \">\")
772 %> Spaces of length thread-level (string)
773 %< Spaces of length (- 20 thread-level) (string)
774 %i Article score (number)
775 %z Article zcore (character)
776 %u User defined specifier. The next character in the format string should
777 be a letter. Gnus will call the function gnus-user-format-function-X,
778 where X is the letter following %u. The function will be passed the
779 current header as argument. The function should return a string, which
780 will be inserted into the summary just like information from any other
783 Text between %( and %) will be highlighted with `gnus-mouse-face'
784 when the mouse point is placed inside the area. There can only be one
787 The %U (status), %R (replied) and %z (zcore) specs have to be handled
788 with care. For reasons of efficiency, Gnus will compute what column
789 these characters will end up in, and \"hard-code\" that. This means that
790 it is illegal to have these specs after a variable-length spec. Well,
791 you might not be arrested, but your summary buffer will look strange,
794 The smart choice is to have these specs as for to the left as
797 This restriction may disappear in later versions of Gnus.")
799 (defvar gnus-summary-dummy-line-format "* : : %S\n"
800 "The format specification for the dummy roots in the summary buffer.
801 It works along the same lines as a normal formatting string,
802 with some simple extensions.
806 (defvar gnus-summary-mode-line-format "(ding) %G/%A %Z"
807 "The format specification for the summary mode line.")
809 (defvar gnus-article-mode-line-format "(ding) %G/%A %S"
810 "The format specification for the article mode line.")
812 (defvar gnus-group-mode-line-format "(ding) List of groups {%M:%S} "
813 "The format specification for the group mode line.")
815 (defvar gnus-valid-select-methods
816 '(("nntp" post address prompt-address)
817 ("nnspool" post) ("nnvirtual" none virtual prompt-address)
818 ("nnmbox" mail respool) ("nnml" mail respool)
819 ("nnmh" mail respool) ("nndir" none prompt-address) ("nndigest" none)
820 ("nndoc" none prompt-address) ("nnbabyl" mail respool)
821 ("nnkiboze" none virtual) ("nnfolder" mail respool))
822 "An alist of valid select methods.
823 The first element of each list lists should be a string with the name
824 of the select method. The other elements may be be the category of
825 this method (ie. `post', `mail', `none' or whatever) or other
826 properties that this method has (like being respoolable).
827 If you implement a new select method, all you should have to change is
828 this variable. I think.")
830 (defvar gnus-updated-mode-lines '(group article summary)
831 "List of buffers that should update their mode lines.
832 The list may contain the symbols `group', `article' and `summary'. If
833 the corresponding symbol is present, Gnus will keep that mode line
834 updated with information that may be pertinent.
835 If this variable is nil, screen refresh may be quicker.")
837 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
838 (defvar gnus-mode-non-string-length 21
839 "Max length of mode-line non-string contents buffer contents.")
841 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
842 (defvar gnus-mouse-face 'highlight
843 "Face used for mouse highlighting in Gnus.
844 No mouse highlights will be done if `gnus-visual' is nil.")
846 (defvar gnus-summary-mark-below nil
847 "Mark all articles with a score below this variable as read.
848 This variable is local to each summary buffer and usually set by the
851 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
852 "List of functions used for sorting threads in the summary buffer.
853 By default, threads are sorted by article number.
855 Each function takes two threads and return non-nil if the first thread
856 should be sorted before the other. If you use more than one function,
857 the primary sort function should be the last.
859 Ready-mady functions include `gnus-thread-sort-by-number',
860 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
861 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
862 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
864 The latter two only work on threads that have been scored prior to
865 entering the newsgroup.")
867 (defvar gnus-thread-score-function '+
868 "Function used for calculating the total score of a thread.
870 The function is called with the scores of the article and each
871 subthread and should then return the score of the thread.
873 Some functions you can use are `+', `max', or `min'.")
875 (defvar gnus-score-find-score-files-function 'gnus-score-find-bnews
876 "Function used to find SCORE files.
877 The function will be called with the group name as the argument, and
878 should return a list of score files to apply to that group. The score
879 files do not actually have to exist.
881 Predefined values are:
883 gnus-score-find-single: Only apply the group's own SCORE file.
884 gnus-score-find-hierarchical: Also apply SCORE files from parent groups.
885 gnus-score-find-bnews: Apply SCORE files whose names matches.
887 See the documentation to these functions for more information.")
889 (defvar gnus-options-subscribe nil
890 "All new groups matching this regexp will be subscribed unconditionally.
891 Note that this variable deals only with new newsgroups. This variable
892 does not affect old newsgroups.")
894 (defvar gnus-options-not-subscribe nil
895 "All new groups matching this regexp will be ignored.
896 Note that this variable deals only with new newsgroups. This variable
897 does not affect old (already subscribed) newsgroups.")
899 (defvar gnus-auto-expirable-newsgroups nil
900 "Groups in which to automatically mark read articles as expirable.
901 If non-nil, this should be a regexp that should match all groups in
902 which to perform auto-expiry. This only makes sense for mail groups.")
907 (defvar gnus-group-mode-hook nil
908 "A hook for Gnus group mode.")
910 (defvar gnus-summary-mode-hook nil
911 "A hook for Gnus summary mode.")
913 (defvar gnus-article-mode-hook nil
914 "A hook for Gnus article mode.")
916 (defvar gnus-open-server-hook nil
917 "A hook called just before opening connection to the news server.")
919 (defvar gnus-startup-hook nil
920 "A hook called at startup.
921 This hook is called after Gnus is connected to the NNTP server.")
923 (defvar gnus-get-new-news-hook nil
924 "A hook run just before Gnus checks for new news.")
926 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
927 "A function that is called to generate the group buffer.
928 The function is called with three arguments: The first is a number;
929 all group with a level less or equal to that number should be listed,
930 if the second is non-nil, empty groups should also be displayed. If
931 the third is non-nil, it is a number. No groups with a level lower
932 than this number should be displayed.
934 The only current function implemented is `gnus-group-prepare-flat'.")
936 (defvar gnus-group-prepare-hook nil
937 "A hook called after the group buffer has been generated.
938 If you want to modify the group buffer, you can use this hook.")
940 (defvar gnus-summary-prepare-hook nil
941 "A hook called after the summary buffer has been generated.
942 If you want to modify the summary buffer, you can use this hook.")
944 (defvar gnus-article-prepare-hook nil
945 "A hook called after an article has been prepared in the article buffer.
946 If you want to run a special decoding program like nkf, use this hook.")
948 (defvar gnus-article-display-hook nil
949 "A hook called after the article is displayed in the article buffer.
950 The hook is designed to change the contents of the article
951 buffer. Typical functions that this hook may contain are
952 `gnus-article-hide-headers' (hide selected headers),
953 `gnus-article-hide-signature' (hide signature) and
954 `gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
955 (add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
956 (add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
958 (defvar gnus-select-group-hook nil
959 "A hook called when a newsgroup is selected.
961 If you'd like to simplify subjects like the
962 `gnus-summary-next-same-subject' command does, you can use the
965 (setq gnus-select-group-hook
968 (mapcar (lambda (header)
971 (gnus-simplify-subject
972 (header-subject header) 're-only)))
973 gnus-newsgroup-headers))))")
975 (defvar gnus-select-article-hook
976 '(gnus-summary-show-thread)
977 "A hook called when an article is selected.
978 The default hook shows conversation thread subtrees of the selected
979 article automatically using `gnus-summary-show-thread'.")
981 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
982 "A hook called to apply kill files to a group.
983 This hook is intended to apply a kill file to the selected newsgroup.
984 The function `gnus-apply-kill-file' is called by default.
986 Since a general kill file is too heavy to use only for a few
987 newsgroups, I recommend you to use a lighter hook function. For
988 example, if you'd like to apply a kill file to articles which contains
989 a string `rmgroup' in subject in newsgroup `control', you can use the
992 \(setq gnus-apply-kill-hook
995 (cond ((string-match \"control\" gnus-newsgroup-name)
996 (gnus-kill \"Subject\" \"rmgroup\")
997 (gnus-expunge \"X\"))))))")
999 (defvar gnus-visual-mark-article-hook
1000 (list 'gnus-visual-highlight-selected-summary)
1001 "Hook run after selecting an article in the summary buffer.
1002 It is meant to be used for highlighting the article in some way. It
1003 is not run if `gnus-visual' is nil.")
1005 (defvar gnus-prepare-article-hook (list 'gnus-inews-insert-signature)
1006 "A hook called after preparing body, but before preparing header headers.
1007 The default hook (`gnus-inews-insert-signature') inserts a signature
1008 file specified by the variable `gnus-signature-file'.")
1010 (defvar gnus-inews-article-hook (list 'gnus-inews-do-fcc)
1011 "A hook called before finally posting an article.
1012 The default hook (`gnus-inews-do-fcc') does FCC processing (ie. saves
1013 the article to a file).")
1015 (defvar gnus-inews-article-header-hook nil
1016 "A hook called after inserting the headers in an article to be posted.
1017 The hook is called from the *post-news* buffer, narrowed to the
1020 (defvar gnus-exit-group-hook nil
1021 "A hook called when exiting (not quitting) summary mode.")
1023 (defvar gnus-suspend-gnus-hook nil
1024 "A hook called when suspending (not exiting) Gnus.")
1026 (defvar gnus-exit-gnus-hook nil
1027 "A hook called when exiting Gnus.")
1029 (defvar gnus-save-newsrc-hook nil
1030 "A hook called when saving the newsrc file.")
1032 (defvar gnus-visual-summary-update-hook
1033 (list 'gnus-visual-summary-highlight-line)
1034 "A hook called when a summary line is changed.
1035 The hook will not be called if `gnus-visual' is nil.
1037 The default function `gnus-visual-summary-highlight-line' will
1038 highlight the line according to the `gnus-visual-summary-highlight'
1041 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1042 "A hook called when an article is selected for the first time.
1043 The hook is intended to mark an article as read (or unread)
1044 automatically when it is selected.")
1046 ;; Site dependent variables. These variables should be defined in
1049 (defvar gnus-default-nntp-server nil
1050 "Specify a default NNTP server.
1051 This variable should be defined in paths.el, and should never be set
1053 If you want to change servers, you should use `gnus-select-method'.
1054 See the documentation to that variable.")
1056 (defconst gnus-backup-default-subscribed-newsgroups
1057 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
1058 "Default default new newsgroups the first time Gnus is run.
1059 Should be set in paths.el, and shouldn't be touched by the user.")
1061 (defvar gnus-local-domain nil
1062 "Local domain name without a host name.
1063 The DOMAINNAME environment variable is used instead if it is defined.
1064 If the `system-name' function returns the full Internet name, there is
1065 no need to set this variable.")
1067 (defvar gnus-local-organization nil
1068 "String with a description of what organization (if any) the user belongs to.
1069 The ORGANIZATION environment variable is used instead if it is defined.
1070 If this variable contains a function, this function will be called
1071 with the current newsgroup name as the argument. The function should
1073 In any case, if the string (either in the variable, in the environment
1074 variable, or returned by the function) is a file name, the contents of
1075 this file will be used as the organization.")
1077 (defvar gnus-use-generic-from nil
1078 "If nil, the full host name will be the system name prepended to the domain name.
1079 If this is a string, the full host name will be this string.
1080 If this is non-nil, non-string, the domain name will be used as the
1083 (defvar gnus-use-generic-path nil
1084 "If nil, use the NNTP server name in the Path header.
1085 If stringp, use this; if non-nil, use no host name (user name only).")
1088 ;; Internal variables
1090 ;; Avoid highlighting in kill files.
1091 (defvar gnus-summary-inhibit-highlight nil)
1092 (defvar gnus-newsgroup-selected-overlay nil)
1094 (defvar gnus-article-mode-map nil)
1095 (defvar caesar-translate-table nil)
1096 (defvar gnus-dribble-buffer nil)
1097 (defvar gnus-headers-retrieved-by nil)
1098 (defvar gnus-article-reply nil)
1099 (defvar gnus-override-method nil)
1100 (defvar gnus-article-check-size nil)
1101 (defvar gnus-score-file-list nil)
1102 (defvar gnus-internal-global-score-files nil)
1103 (defvar gnus-current-score-file nil)
1105 (defvar gnus-score-alist nil
1106 "Alist containing score information.
1107 The keys can be symbols or strings. The following symbols are defined.
1109 touched: If this alist has been modified.
1110 mark: Automatically mark articles below this.
1111 expunge: Automatically expunge articles below this.
1112 files: List of other SCORE files to load when loading this one.
1113 eval: Sexp to be evaluated when the score file is loaded.
1115 String entries have the form (HEADER (MATCH TYPE SCORE DATE) ...)
1116 where HEADER is the header being scored, MATCH is the string we are
1117 looking for, TYPE is a flag indicating whether it should use regexp or
1118 substring matching, SCORE is the score to add and DATE is the date
1119 of the last succesful match.")
1121 (defvar gnus-score-cache nil)
1122 (defvar gnus-scores-articles nil)
1123 (defvar gnus-header-index nil)
1124 (defvar gnus-score-index nil)
1126 (defvar gnus-newsgroup-dependencies nil)
1127 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1128 (defvar gnus-default-subscribe-level 2)
1129 (defvar gnus-default-unsubscribe-level 6)
1130 (defvar gnus-default-kill-level 9)
1132 (defconst gnus-group-line-format-alist
1133 (list (list ?M 'marked ?c)
1134 (list ?S 'subscribed ?c)
1136 (list ?N 'number ?s)
1137 (list ?I 'number-of-dormant ?d)
1138 (list ?T 'number-of-ticked ?d)
1139 (list ?R 'number-of-read ?s)
1140 (list ?t 'number-total ?d)
1141 (list ?y 'number-of-unread-unticked ?s)
1142 (list ?i 'number-of-ticked-and-dormant ?d)
1144 (list ?G 'qualified-group ?s)
1145 (list ?D 'newsgroup-description ?s)
1146 (list ?o 'moderated ?c)
1147 (list ?O 'moderated-string ?s)
1148 (list ?s 'news-server ?s)
1149 (list ?n 'news-method ?s)
1150 (list ?z 'news-method-string ?s)
1151 (list ?u 'user-defined ?s)))
1153 (defconst gnus-summary-line-format-alist
1154 (list (list ?N 'number ?s)
1155 (list ?S 'subject ?s)
1156 (list ?s 'subject-or-nil ?s)
1158 (list ?A 'address ?s)
1160 (list ?x (macroexpand '(header-xref header)) ?s)
1161 (list ?D (macroexpand '(header-date header)) ?s)
1162 (list ?M (macroexpand '(header-id header)) ?s)
1163 (list ?r (macroexpand '(header-references header)) ?s)
1164 (list ?c (macroexpand '(header-chars header)) ?d)
1166 (list ?I 'indentation ?s)
1167 (list ?T '(if (< level 1) "" (make-string (frame-width) ? )) ?s)
1168 (list ?R 'replied ?c)
1169 (list ?\[ 'opening-bracket ?c)
1170 (list ?\] 'closing-bracket ?c)
1171 (list ?\> '(make-string level ? ) ?s)
1172 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1174 (list ?z 'score-char ?c)
1175 (list ?U 'unread ?c)
1176 (list ?u 'user-defined ?s))
1177 "An alist of format specifications that can appear in summary lines,
1178 and what variables they correspond with, along with the type of the
1179 variable (string, integer, character, etc).")
1181 (defconst gnus-summary-dummy-line-format-alist
1182 (list (list ?S 'subject ?s)
1183 (list ?N 'number ?d)))
1185 (defconst gnus-summary-mode-line-format-alist
1186 (list (list ?G 'group-name ?s)
1187 (list ?A 'article-number ?d)
1188 (list ?Z 'unread-and-unselected ?s)
1189 (list ?V 'gnus-version ?s)
1190 (list ?U 'unread ?d)
1191 (list ?S 'subject ?s)
1192 (list ?u 'unselected ?d)))
1194 (defconst gnus-group-mode-line-format-alist
1195 (list (list ?S 'news-server ?s)
1196 (list ?M 'news-method ?s)))
1198 (defvar gnus-have-read-active-file nil)
1200 (defconst gnus-maintainer "Lars Magne Ingebrigtsen <larsi@ifi.uio.no>"
1201 "The mail address of the Gnus maintainer.")
1203 (defconst gnus-version "(ding) Gnus v0.41"
1204 "Version number for this version of Gnus.")
1206 (defvar gnus-info-nodes
1207 '((gnus-group-mode "(gnus)The Group Buffer")
1208 (gnus-summary-mode "(gnus)The Summary Buffer")
1209 (gnus-article-mode "(gnus)The Article Buffer"))
1210 "Assoc list of major modes and related Info nodes.")
1212 (defvar gnus-documentation-group-file "~/dgnus/lisp/doc.txt"
1213 "The location of the (ding) Gnus documentation group.")
1215 (defvar gnus-group-buffer "*Group*")
1216 (defvar gnus-summary-buffer "*Summary*")
1217 (defvar gnus-article-buffer "*Article*")
1219 (defvar gnus-buffer-list nil
1220 "Gnus buffers that should be killed on exit.")
1222 (defvar gnus-variable-list
1223 '(gnus-newsrc-options
1224 gnus-newsrc-options-n-yes gnus-newsrc-options-n-no
1225 gnus-newsrc-last-checked-date
1226 gnus-newsrc-assoc gnus-killed-list gnus-zombie-list)
1227 "Gnus variables saved in the quick startup file.")
1229 (defvar gnus-overload-functions
1230 '((news-inews gnus-inews-news "rnewspost")
1231 (caesar-region gnus-caesar-region "rnews"))
1232 "Functions overloaded by gnus.
1233 It is a list of `(original overload &optional file)'.")
1235 (defvar gnus-newsrc-options nil
1236 "Options line in the .newsrc file.")
1238 (defvar gnus-newsrc-options-n-yes nil
1239 "Regexp representing groups to be subscribed to unconditionally.")
1241 (defvar gnus-newsrc-options-n-no nil
1242 "Regexp representing group to be ignored unconditionally.")
1244 (defvar gnus-newsrc-last-checked-date nil
1245 "Date Gnus last asked server for new newsgroups.")
1247 (defvar gnus-newsrc-assoc nil
1248 "Assoc list of read articles.
1249 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1251 (defvar gnus-newsrc-hashtb nil
1252 "Hashtable of gnus-newsrc-assoc.")
1254 (defvar gnus-killed-list nil
1255 "List of killed newsgroups.")
1257 (defvar gnus-killed-hashtb nil
1258 "Hash table equivalent of gnus-killed-list.")
1260 (defvar gnus-zombie-list nil
1261 "List of almost dead newsgroups.")
1263 (defvar gnus-description-hashtb nil
1264 "Descriptions of newsgroups.")
1266 (defvar gnus-list-of-killed-groups nil
1267 "List of newsgroups that have recently been killed by the user.")
1269 (defvar gnus-active-hashtb nil
1270 "Hashtable of active articles.")
1272 (defvar gnus-moderated-list nil
1273 "List of moderated newsgroups.")
1275 (defvar gnus-current-startup-file nil
1276 "Startup file for the current host.")
1278 (defvar gnus-last-search-regexp nil
1279 "Default regexp for article search command.")
1281 (defvar gnus-last-shell-command nil
1282 "Default shell command on article.")
1284 (defvar gnus-current-select-method nil
1285 "The current method for selecting a newsgroup.")
1287 (defvar gnus-have-all-newsgroups nil)
1289 (defvar gnus-article-internal-prepare-hook nil)
1291 (defvar gnus-newsgroup-name nil)
1292 (defvar gnus-newsgroup-begin nil)
1293 (defvar gnus-newsgroup-end nil)
1294 (defvar gnus-newsgroup-last-rmail nil)
1295 (defvar gnus-newsgroup-last-mail nil)
1296 (defvar gnus-newsgroup-last-folder nil)
1297 (defvar gnus-newsgroup-last-file nil)
1298 (defvar gnus-newsgroup-auto-expire nil)
1300 (defvar gnus-newsgroup-unreads nil
1301 "List of unread articles in the current newsgroup.")
1303 (defvar gnus-newsgroup-unselected nil
1304 "List of unselected unread articles in the current newsgroup.")
1306 (defvar gnus-newsgroup-marked nil
1307 "List of ticked articles in the current newsgroup (a subset of unread art).")
1309 (defvar gnus-newsgroup-killed nil
1310 "List of ranges of articles that have been through the scoring process.")
1312 (defvar gnus-newsgroup-kill-headers nil)
1314 (defvar gnus-newsgroup-replied nil
1315 "List of articles that have been replied to in the current newsgroup.")
1317 (defvar gnus-newsgroup-expirable nil
1318 "List of articles in the current newsgroup that can be expired.")
1320 (defvar gnus-newsgroup-processable nil
1321 "List of articles in the current newsgroup that can be processed.")
1323 (defvar gnus-newsgroup-bookmarks nil
1324 "List of articles in the current newsgroup that have bookmarks.")
1326 (defvar gnus-newsgroup-dormant nil
1327 "List of dormant articles in the current newsgroup.")
1329 (defvar gnus-newsgroup-scored nil
1330 "List of scored articles in the current newsgroup.")
1332 (defvar gnus-newsgroup-headers nil
1333 "List of article headers in the current newsgroup.")
1334 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1336 (defvar gnus-newsgroup-ancient nil
1337 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1339 (defvar gnus-current-article nil)
1340 (defvar gnus-article-current nil)
1341 (defvar gnus-current-headers nil)
1342 (defvar gnus-have-all-headers nil)
1343 (defvar gnus-last-article nil)
1344 (defvar gnus-newsgroup-history nil)
1345 (defvar gnus-current-kill-article nil)
1347 ;; Save window configuration.
1348 (defvar gnus-winconf-edit-group nil)
1349 (defvar gnus-winconf-edit-score nil)
1352 (defvar gnus-summary-line-format-spec nil)
1353 (defvar gnus-summary-dummy-line-format-spec nil)
1354 (defvar gnus-group-line-format-spec nil)
1355 (defvar gnus-summary-mode-line-format-spec nil)
1356 (defvar gnus-article-mode-line-format-spec nil)
1357 (defvar gnus-group-mode-line-format-spec nil)
1358 (defvar gnus-summary-mark-positions nil)
1360 (defvar gnus-summary-expunge-below nil)
1361 (defvar gnus-reffed-article-number nil)
1363 (defvar rmail-default-file (expand-file-name "~/XMBOX"))
1364 (defvar rmail-default-rmail-file (expand-file-name "~/XNEWS"))
1366 (defconst gnus-summary-local-variables
1367 '(gnus-newsgroup-name
1368 gnus-newsgroup-begin gnus-newsgroup-end
1369 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1370 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1371 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1372 gnus-newsgroup-unselected gnus-newsgroup-marked
1373 gnus-newsgroup-replied gnus-newsgroup-expirable
1374 gnus-newsgroup-processable gnus-newsgroup-killed
1375 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1376 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1377 gnus-current-article gnus-current-headers gnus-have-all-headers
1378 gnus-last-article gnus-article-internal-prepare-hook
1379 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1380 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1381 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1382 gnus-summary-mark-below
1383 gnus-newsgroup-history gnus-newsgroup-ancient)
1384 "Variables that are buffer-local to the summary buffers.")
1386 ;;; End of variables.
1388 ;; Define some autoload functions Gnus might use.
1390 (autoload 'metamail-buffer "metamail")
1391 (autoload 'Info-goto-node "info")
1393 (autoload 'timezone-make-date-arpa-standard "timezone")
1394 (autoload 'timezone-fix-time "timezone")
1395 (autoload 'timezone-make-sortable-date "timezone")
1396 (autoload 'timezone-make-time-string "timezone")
1398 (autoload 'rmail-output "rmailout")
1399 (autoload 'mail-position-on-field "sendmail")
1400 (autoload 'mail-setup "sendmail")
1401 (autoload 'news-mail-other-window "rnewspost")
1403 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1404 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1405 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1406 (autoload 'gnus-summary-save-in-folder "gnus-mh")
1407 (autoload 'gnus-Folder-save-name "gnus-mh")
1408 (autoload 'gnus-folder-save-name "gnus-mh")
1410 (autoload 'gnus-group-make-menu-bar "gnus-visual")
1411 (autoload 'gnus-summary-make-menu-bar "gnus-visual")
1412 (autoload 'gnus-article-make-menu-bar "gnus-visual")
1413 (autoload 'gnus-visual-highlight-selected-summary "gnus-visual")
1414 (autoload 'gnus-visual-summary-highlight-line "gnus-visual")
1416 (autoload 'gnus-uu-mark-by-regexp "gnus-uu")
1417 (autoload 'gnus-uu-mark-region "gnus-uu")
1418 (autoload 'gnus-uu-mark-thread "gnus-uu")
1419 (autoload 'gnus-uu-mark-sparse "gnus-uu")
1420 (autoload 'gnus-uu-mark-series "gnus-uu")
1421 (autoload 'gnus-uu-mark-all "gnus-uu")
1422 (autoload 'gnus-uu-post-news "gnus-uu")
1423 (autoload 'gnus-uu-digest-and-forward "gnus-uu")
1425 (autoload 'gnus-uu-decode-uu "gnus-uu")
1426 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu")
1427 (autoload 'gnus-uu-decode-unshar "gnus-uu")
1428 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu")
1429 (autoload 'gnus-uu-decode-save "gnus-uu")
1430 (autoload 'gnus-uu-decode-binhex "gnus-uu")
1431 (autoload 'gnus-uu-decode-uu-view "gnus-uu")
1432 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu")
1433 (autoload 'gnus-uu-decode-unshar-view "gnus-uu")
1434 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu")
1435 (autoload 'gnus-uu-decode-save-view "gnus-uu")
1436 (autoload 'gnus-uu-decode-binhex-view "gnus-uu")
1438 (autoload 'gnus-kill "gnus-kill")
1439 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1440 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1441 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1442 (autoload 'gnus-execute "gnus-kill")
1445 (autoload 'pp-to-string "pp")
1446 (autoload 'mail-extract-address-components "mail-extr")
1449 (put 'gnus-group-mode 'mode-class 'special)
1450 (put 'gnus-summary-mode 'mode-class 'special)
1451 (put 'gnus-article-mode 'mode-class 'special)
1455 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1456 (defun gnus-summary-position-cursor () nil)
1457 (defun gnus-group-position-cursor () nil)
1458 (fset 'gnus-summary-position-cursor 'gnus-goto-colon)
1459 (fset 'gnus-group-position-cursor 'gnus-goto-colon)
1461 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1462 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1463 (` (let ((GnusStartBufferWindow (selected-window)))
1466 (pop-to-buffer (, buffer))
1468 (select-window GnusStartBufferWindow)))))
1470 (defun gnus-make-hashtable (&optional hashsize)
1471 "Make a hash table (default and minimum size is 255).
1472 Optional argument HASHSIZE specifies the table size."
1473 (make-vector (if hashsize
1474 (max (gnus-create-hash-size hashsize) 255)
1477 (defmacro gnus-gethash (string hashtable)
1478 "Get hash value of STRING in HASHTABLE."
1479 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1480 ;;(` (abbrev-expansion (, string) (, hashtable)))
1481 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1483 (defmacro gnus-sethash (string value hashtable)
1484 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1485 ;; We cannot use define-abbrev since it only accepts string as value.
1486 ; (set (intern string hashtable) value))
1487 (` (set (intern (, string) (, hashtable)) (, value))))
1489 (defsubst gnus-buffer-substring (beg end)
1490 (buffer-substring (match-beginning beg) (match-end end)))
1492 (defsubst gnus-simplify-subject-re (subject)
1493 "Remove \"Re:\" from subject lines."
1494 (let ((case-fold-search t))
1495 (if (string-match "^re: *" subject)
1496 (substring subject (match-end 0))
1499 (defsubst gnus-goto-char (point)
1500 (and point (goto-char point)))
1504 ;;; Gnus Utility Functions
1507 (defun gnus-extract-address-components (from)
1509 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1510 (setq address (substring from (match-beginning 0) (match-end 0))))
1512 (string-match (concat "<" (regexp-quote address) ">") from)
1513 (setq name (substring from 0 (1- (match-beginning 0)))))
1515 (and (string-match "(.+)" from)
1516 (setq name (substring from (1+ (match-beginning 0))
1517 (1- (match-end 0))))))
1518 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1519 (list (or name from) (or address from))))
1521 (defun gnus-fetch-field (field)
1522 "Return the value of the header FIELD of current article."
1525 (gnus-narrow-to-headers)
1526 (mail-fetch-field field))))
1528 (defun gnus-goto-colon ()
1530 (search-forward ":" (save-excursion (end-of-line) (point)) t))
1532 (defun gnus-narrow-to-headers ()
1536 (if (search-forward "\n\n")
1537 (narrow-to-region 1 (1- (point))))))
1539 ;; Get a number that is suitable for hashing; bigger than MIN
1540 (defun gnus-create-hash-size (min)
1546 (defun gnus-update-format-specifications ()
1547 (setq gnus-summary-line-format-spec
1549 gnus-summary-line-format gnus-summary-line-format-alist))
1550 (gnus-update-summary-mark-positions)
1551 (setq gnus-summary-dummy-line-format-spec
1552 (gnus-parse-format gnus-summary-dummy-line-format
1553 gnus-summary-dummy-line-format-alist))
1554 (setq gnus-group-line-format-spec
1556 gnus-group-line-format
1557 gnus-group-line-format-alist))
1558 (if (and (string-match "%D" gnus-group-line-format)
1559 (not gnus-description-hashtb)
1560 gnus-read-active-file)
1561 (gnus-read-descriptions-file))
1562 (setq gnus-summary-mode-line-format-spec
1563 (gnus-parse-format gnus-summary-mode-line-format
1564 gnus-summary-mode-line-format-alist))
1565 (setq gnus-article-mode-line-format-spec
1566 (gnus-parse-format gnus-article-mode-line-format
1567 gnus-summary-mode-line-format-alist))
1568 (setq gnus-group-mode-line-format-spec
1569 (gnus-parse-format gnus-group-mode-line-format
1570 gnus-group-mode-line-format-alist)))
1572 (defun gnus-update-summary-mark-positions ()
1574 (let ((gnus-replied-mark 129)
1575 (gnus-score-below-mark 130)
1576 (gnus-score-over-mark 130)
1578 (set-buffer (get-buffer-create " *gnus work*"))
1579 (buffer-disable-undo (current-buffer))
1581 (gnus-summary-insert-line
1582 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1583 (goto-char (point-min))
1584 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1586 (goto-char (point-min))
1587 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1588 (- (point) 2))) pos))
1589 (goto-char (point-min))
1590 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1591 (- (point) 2))) pos))
1592 (setq gnus-summary-mark-positions pos)
1593 (kill-buffer (current-buffer)))))
1595 (defun gnus-format-max-width (var length)
1597 (if (> (length (setq result (eval var))) length)
1598 (format "%s" (substring result 0 length))
1599 (format "%s" result))))
1601 (defun gnus-set-mouse-face (string)
1602 ;; Set mouse face property on STRING.
1603 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string)
1606 (defun gnus-parse-format (format spec-alist)
1607 ;; This function parses the FORMAT string with the help of the
1608 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1609 ;; string. If the FORMAT string contains the specifiers %( and %)
1610 ;; the text between them will have the mouse-face text property.
1611 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1612 (if (and gnus-visual gnus-mouse-face)
1613 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1614 (button (substring format (match-beginning 2) (match-end 2)))
1615 (post (substring format (match-beginning 3) (match-end 3))))
1617 (gnus-parse-simple-format pre spec-alist)
1618 (list 'gnus-set-mouse-face
1619 (gnus-parse-simple-format button spec-alist))
1620 (gnus-parse-simple-format post spec-alist)))
1621 (gnus-parse-simple-format
1622 (concat (substring format (match-beginning 1) (match-end 1))
1623 (substring format (match-beginning 2) (match-end 2))
1624 (substring format (match-beginning 3) (match-end 3)))
1626 (gnus-parse-simple-format format spec-alist)))
1628 (defun gnus-parse-simple-format (format spec-alist)
1629 ;; This function parses the FORMAT string with the help of the
1630 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1631 ;; string. The list will consist of the symbol `format', a format
1632 ;; specification string, and a list of forms depending on the
1635 spec flist fstring b newspec max-width elem beg)
1637 (set-buffer (get-buffer-create " *gnus work*"))
1638 (buffer-disable-undo (current-buffer))
1639 (gnus-add-current-to-buffer-list)
1643 (while (re-search-forward "%[-0-9]*\\(,[0-9]*\\)*\\(.\\)\\(.\\)?" nil t)
1644 (setq spec (string-to-char (buffer-substring (match-beginning 2)
1646 ;; First check if there are any specs that look anything like
1647 ;; "%12,12A", ie. with a "max width specification". These have
1648 ;; to be treated specially.
1649 (if (setq beg (match-beginning 1))
1652 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
1654 (setq beg (match-beginning 2)))
1655 ;; Find the specification from `spec-alist'.
1656 (if (not (setq elem (cdr (assq spec spec-alist))))
1657 (setq elem '("*" ?s)))
1658 ;; Treat user defined format specifiers specially
1659 (and (eq (car elem) 'user-defined)
1662 (list (intern (concat "gnus-user-format-function-"
1668 (delete-region (match-beginning 3) (match-end 3)))
1669 (if (not (zerop max-width))
1670 (let ((el (car elem)))
1671 (cond ((= (car (cdr elem)) ?c)
1672 (setq el (list 'char-to-string el)))
1673 ((= (car (cdr elem)) ?d)
1674 (numberp el) (setq el (list 'int-to-string el))))
1675 (setq flist (cons (list 'gnus-format-max-width
1679 (setq flist (cons (car elem) flist))
1680 (setq newspec (car (cdr elem))))
1681 ;; Remove the old specification (and possibly a ",12" string).
1682 (delete-region beg (match-end 2))
1683 ;; Insert the new specification.
1686 (setq fstring (buffer-substring 1 (point-max))))
1687 (cons 'format (cons fstring (nreverse flist)))))
1689 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
1690 (defun gnus-read-init-file ()
1692 (or (file-exists-p gnus-init-file)
1693 (file-exists-p (concat gnus-init-file ".el"))
1694 (file-exists-p (concat gnus-init-file ".elc")))
1695 (load gnus-init-file nil t)))
1697 ;; Article file names when saving.
1699 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
1700 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1701 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
1702 Otherwise, it is like ~/News/news/group/num."
1705 (concat (if gnus-use-long-file-name
1706 (gnus-capitalize-newsgroup newsgroup)
1707 (gnus-newsgroup-directory-form newsgroup))
1708 "/" (int-to-string (header-number headers)))
1709 (or gnus-article-save-directory "~/News"))))
1711 (string-equal (file-name-directory default)
1712 (file-name-directory last-file))
1713 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1715 (or last-file default))))
1717 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
1718 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1719 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group/num.
1720 Otherwise, it is like ~/News/news/group/num."
1723 (concat (if gnus-use-long-file-name
1725 (gnus-newsgroup-directory-form newsgroup))
1726 "/" (int-to-string (header-number headers)))
1727 (or gnus-article-save-directory "~/News"))))
1729 (string-equal (file-name-directory default)
1730 (file-name-directory last-file))
1731 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1733 (or last-file default))))
1735 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
1736 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1737 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group.
1738 Otherwise, it is like ~/News/news/group/news."
1741 (if gnus-use-long-file-name
1742 (gnus-capitalize-newsgroup newsgroup)
1743 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1744 (or gnus-article-save-directory "~/News"))))
1746 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
1747 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1748 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group.
1749 Otherwise, it is like ~/News/news/group/news."
1752 (if gnus-use-long-file-name
1754 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1755 (or gnus-article-save-directory "~/News"))))
1757 ;; For subscribing new newsgroup
1759 (defun gnus-subscribe-hierarchical-interactive (groups)
1760 (let ((groups (sort groups 'string<))
1761 prefixes prefix start rest ans group starts)
1763 (setq prefixes (list "^"))
1764 (while (and groups prefixes)
1765 (while (not (string-match (car prefixes) (car groups)))
1766 (setq prefixes (cdr prefixes)))
1767 (setq prefix (car prefixes))
1768 (setq start (1- (length prefix)))
1769 (if (and (string-match "[^\\.]\\." (car groups) start)
1772 (concat "^" (substring (car groups) 0 (match-end 0))))
1773 (string-match prefix (car (cdr groups))))
1775 (setq prefixes (cons prefix prefixes))
1776 (message "Descend hierarchy %s? ([y]nsq): "
1777 (substring prefix 1 (1- (length prefix))))
1778 (setq ans (read-char))
1781 (string-match prefix
1782 (setq group (car groups))))
1783 (setq gnus-killed-list
1784 (cons group gnus-killed-list))
1785 (gnus-sethash group group gnus-killed-hashtb)
1786 (setq groups (cdr groups)))
1787 (setq starts (cdr starts)))
1790 (string-match prefix
1791 (setq group (car groups))))
1792 (gnus-sethash group group gnus-killed-hashtb)
1793 (gnus-subscribe-alphabetically (car groups))
1794 (setq groups (cdr groups)))
1795 (setq starts (cdr starts)))
1798 (setq group (car groups))
1799 (setq gnus-killed-list (cons group gnus-killed-list))
1800 (gnus-sethash group group gnus-killed-hashtb)
1801 (setq groups (cdr groups))))
1803 (message "Subscribe %s? ([n]yq)" (car groups))
1804 (setq ans (read-char))
1805 (setq group (car groups))
1807 (gnus-subscribe-alphabetically (car groups))
1808 (gnus-sethash group group gnus-killed-hashtb))
1811 (setq group (car groups))
1812 (setq gnus-killed-list (cons group gnus-killed-list))
1813 (gnus-sethash group group gnus-killed-hashtb)
1814 (setq groups (cdr groups))))
1816 (setq gnus-killed-list (cons group gnus-killed-list))
1817 (gnus-sethash group group gnus-killed-hashtb)))
1818 (setq groups (cdr groups)))))))
1820 (defun gnus-subscribe-randomly (newsgroup)
1821 "Subscribe new NEWSGROUP by making it the first newsgroup."
1822 (gnus-subscribe-newsgroup newsgroup))
1824 (defun gnus-subscribe-alphabetically (newgroup)
1825 "Subscribe new NEWSGROUP and insert it in alphabetical order."
1826 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
1827 (let ((groups (cdr gnus-newsrc-assoc))
1829 (while (and (not before) groups)
1830 (if (string< newgroup (car (car groups)))
1831 (setq before (car (car groups)))
1832 (setq groups (cdr groups))))
1833 (gnus-subscribe-newsgroup newgroup before)))
1835 (defun gnus-subscribe-hierarchically (newgroup)
1836 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
1837 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
1839 (set-buffer (find-file-noselect gnus-current-startup-file))
1840 (let ((groupkey newgroup)
1842 (while (and (not before) groupkey)
1843 (goto-char (point-min))
1845 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
1846 (while (and (re-search-forward groupkey-re nil t)
1848 (setq before (buffer-substring
1849 (match-beginning 1) (match-end 1)))
1850 (string< before newgroup)))))
1851 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
1853 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
1854 (substring groupkey (match-beginning 1) (match-end 1)))))
1855 (gnus-subscribe-newsgroup newgroup before))))
1857 (defun gnus-subscribe-interactively (newsgroup)
1858 "Subscribe new NEWSGROUP interactively.
1859 It is inserted in hierarchical newsgroup order if subscribed. If not,
1861 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
1862 (gnus-subscribe-hierarchically newsgroup)
1863 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
1865 (defun gnus-subscribe-zombies (newsgroup)
1866 "Make new NEWSGROUP a zombie group."
1867 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
1869 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
1870 "Subscribe new NEWSGROUP.
1871 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
1872 the first newsgroup."
1873 ;; We subscribe the group by changing its level to 3.
1874 (gnus-group-change-level
1875 newsgroup 3 9 (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
1876 (message "Subscribe newsgroup: %s" newsgroup))
1880 (defun gnus-newsgroup-directory-form (newsgroup)
1881 "Make hierarchical directory name from NEWSGROUP name."
1882 (let ((newsgroup (substring newsgroup 0)) ;Copy string.
1883 (len (length newsgroup))
1885 ;; Replace all occurrences of `.' with `/'.
1887 (if (= (aref newsgroup idx) ?.)
1888 (aset newsgroup idx ?/))
1889 (setq idx (1+ idx)))
1893 (defun gnus-make-directory (dir)
1894 "Make DIRECTORY recursively."
1895 (let* ((dir (expand-file-name dir default-directory))
1897 (if (string-match "/$" dir)
1898 (setq dir (substring dir 0 (match-beginning 0))))
1899 (while (not (file-exists-p dir))
1900 (setq dirs (cons dir dirs))
1901 (string-match "/[^/]+$" dir)
1902 (setq dir (substring dir 0 (match-beginning 0))))
1904 (make-directory (car dirs))
1905 (setq dirs (cdr dirs)))))
1907 (defun gnus-capitalize-newsgroup (newsgroup)
1908 "Capitalize NEWSGROUP name."
1909 (and (not (zerop (length newsgroup)))
1910 (concat (char-to-string (upcase (aref newsgroup 0)))
1911 (substring newsgroup 1))))
1915 (defun gnus-simplify-subject (subject &optional re-only)
1916 "Remove `Re:' and words in parentheses.
1917 If optional argument RE-ONLY is non-nil, strip `Re:' only."
1918 (let ((case-fold-search t)) ;Ignore case.
1919 ;; Remove `Re:' and `Re^N:'.
1920 (if (string-match "^re:[ \t]*" subject)
1921 (setq subject (substring subject (match-end 0))))
1922 ;; Remove words in parentheses from end.
1924 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1925 (setq subject (substring subject 0 (match-beginning 0)))))
1926 ;; Return subject string.
1930 (defun gnus-add-current-to-buffer-list ()
1931 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list)))
1933 ;; Functions accessing headers.
1934 ;; Functions are more convenient than macros in some cases.
1936 (defun gnus-header-number (header)
1937 "Return article number in HEADER."
1938 (header-number header))
1940 (defun gnus-header-subject (header)
1941 "Return subject string in HEADER."
1942 (header-subject header))
1944 (defun gnus-header-from (header)
1945 "Return author string in HEADER."
1946 (header-from header))
1948 (defun gnus-header-xref (header)
1949 "Return xref string in HEADER."
1950 (header-xref header))
1952 (defun gnus-header-lines (header)
1953 "Return lines in HEADER."
1954 (header-lines header))
1956 (defun gnus-header-date (header)
1957 "Return date in HEADER."
1958 (header-date header))
1960 (defun gnus-header-id (header)
1961 "Return Id in HEADER."
1964 (defun gnus-header-references (header)
1965 "Return references in HEADER."
1966 (header-references header))
1968 (defun gnus-clear-system ()
1969 "Clear all variables and buffers."
1970 ;; Clear Gnus variables.
1971 (let ((variables gnus-variable-list))
1973 (set (car variables) nil)
1974 (setq variables (cdr variables))))
1975 ;; Clear other internal variables.
1976 (setq gnus-list-of-killed-groups nil
1977 gnus-have-read-active-file nil
1978 gnus-newsrc-assoc nil
1979 gnus-newsrc-hashtb nil
1980 gnus-killed-list nil
1981 gnus-zombie-list nil
1982 gnus-killed-hashtb nil
1983 gnus-active-hashtb nil
1984 gnus-moderated-list nil
1985 gnus-description-hashtb nil
1986 gnus-newsgroup-headers nil
1987 gnus-score-cache nil
1988 gnus-newsgroup-headers-hashtb-by-number nil
1989 gnus-newsgroup-name nil
1990 gnus-internal-global-score-files nil
1991 gnus-current-select-method nil)
1992 ;; Kill the startup file.
1993 (and gnus-current-startup-file
1994 (get-file-buffer gnus-current-startup-file)
1995 (kill-buffer (get-file-buffer gnus-current-startup-file)))
1996 (gnus-dribble-clear)
1997 ;; Kill global KILL file buffer.
1998 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
1999 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2000 ;; Kill Gnus buffers.
2001 (while gnus-buffer-list
2002 (if (and (get-buffer (car gnus-buffer-list))
2003 (buffer-name (get-buffer (car gnus-buffer-list))))
2004 (kill-buffer (car gnus-buffer-list)))
2005 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2007 (defun gnus-configure-windows (action &optional force)
2008 "Configure Gnus windows according to the next ACTION.
2009 The ACTION is either a symbol, such as `summary', or a
2010 configuration list such as `(1 1 2)'. If ACTION is not a list,
2011 configuration list is got from the variable gnus-window-configuration.
2012 If FORCE is non-nil, the updating will be done whether it is necessary
2015 (if (listp action) action
2016 (if (listp gnus-window-configuration)
2017 (car (cdr (assq action gnus-window-configuration)))
2018 gnus-window-configuration)))
2019 (grpwin (get-buffer-window gnus-group-buffer))
2020 (subwin (get-buffer-window gnus-summary-buffer))
2021 (artwin (get-buffer-window gnus-article-buffer))
2028 ;; Make split-window-vertically leave focus in upper window.
2029 (split-window-keep-point t))
2030 (if (and (symbolp windows) (fboundp windows))
2031 (funcall windows action)
2032 (if (and (not force)
2033 (or (null windows) ;No configuration is specified.
2034 (and (eq (null grpwin)
2035 (zerop (nth 0 windows)))
2037 (zerop (nth 1 windows)))
2039 (zerop (nth 2 windows))))))
2040 ;; No need to change window configuration.
2042 (select-window (or grpwin subwin artwin (selected-window)))
2043 ;; First of all, compute the height of each window.
2044 (cond (gnus-use-full-window
2045 ;; Take up the entire screen.
2046 (delete-other-windows)
2047 (setq height (window-height (selected-window))))
2049 (setq height (+ (if grpwin (window-height grpwin) 0)
2050 (if subwin (window-height subwin) 0)
2051 (if artwin (window-height artwin) 0)))))
2052 ;; The group buffer exits always. So, use it to extend the
2053 ;; group window so as to get enough window space.
2054 (switch-to-buffer gnus-group-buffer 'norecord)
2055 (and (get-buffer gnus-summary-buffer)
2056 (delete-windows-on gnus-summary-buffer))
2057 (and (get-buffer gnus-article-buffer)
2058 (delete-windows-on gnus-article-buffer))
2059 ;; Compute expected window height.
2060 (setq winsum (apply (function +) windows))
2061 (if (not (zerop (nth 0 windows)))
2062 (setq grpheight (max window-min-height
2063 (/ (* height (nth 0 windows)) winsum))))
2064 (if (not (zerop (nth 1 windows)))
2065 (setq subheight (max window-min-height
2066 (/ (* height (nth 1 windows)) winsum))))
2067 (if (not (zerop (nth 2 windows)))
2068 (setq artheight (max window-min-height
2069 (/ (* height (nth 2 windows)) winsum))))
2070 (setq height (+ grpheight subheight artheight))
2071 (enlarge-window (max 0 (- height (window-height (selected-window)))))
2072 ;; Then split the window.
2073 (and (not (zerop artheight))
2074 (or (not (zerop grpheight))
2075 (not (zerop subheight)))
2076 (split-window-vertically (+ grpheight subheight)))
2077 (and (not (zerop grpheight))
2078 (not (zerop subheight))
2079 (split-window-vertically grpheight))
2080 ;; Then select buffers in each window.
2081 (or (zerop grpheight)
2083 (switch-to-buffer gnus-group-buffer 'norecord)
2085 (or (zerop subheight)
2087 (switch-to-buffer gnus-summary-buffer 'norecord)
2089 (or (zerop artheight)
2091 ;; If article buffer does not exist, it will be created
2093 (gnus-article-setup-buffer)
2094 (switch-to-buffer gnus-article-buffer 'norecord)
2095 (setq buffer-read-only t) ; !!! Why!?!
2096 (bury-buffer gnus-summary-buffer)
2097 (bury-buffer gnus-group-buffer)))
2098 (or (zerop subheight)
2100 (pop-to-buffer gnus-summary-buffer)
2101 ;; It seems that some code in this function will set
2102 ;; buffer-read-only to nil. I have absolutely no idea
2104 (setq buffer-read-only t))))))) ; !!! Why!?!
2106 (defun gnus-window-configuration-split (action)
2107 (switch-to-buffer gnus-group-buffer t)
2108 (delete-other-windows)
2109 (split-window-horizontally)
2110 (cond ((or (eq action 'newsgoups) (eq action 'summary))
2111 (if (and (get-buffer gnus-summary-buffer)
2112 (buffer-name gnus-summary-buffer))
2113 (switch-to-buffer-other-window gnus-summary-buffer)))
2114 ((eq action 'article)
2115 (switch-to-buffer gnus-summary-buffer t)
2117 (gnus-article-setup-buffer)
2118 (switch-to-buffer gnus-article-buffer t))))
2120 (defun gnus-version ()
2121 "Version numbers of this version of Gnus."
2123 (let ((methods gnus-valid-select-methods)
2126 ;; Go through all the legal select methods and add their version
2127 ;; numbers to the total version string. Only the backends that are
2128 ;; currently in use will have their message numbers taken into
2131 (setq meth (intern (concat (car (car methods)) "-version")))
2133 (stringp (symbol-value meth))
2134 (setq mess (concat mess "; " (symbol-value meth))))
2135 (setq methods (cdr methods)))
2138 (defun gnus-info-find-node ()
2139 "Find Info documentation of Gnus."
2141 ;; Enlarge info window if needed.
2142 (cond ((eq major-mode 'gnus-group-mode)
2143 (gnus-configure-windows '(1 0 0)) ;Take all windows.
2144 (pop-to-buffer gnus-group-buffer))
2145 ((eq major-mode 'gnus-summary-mode)
2146 (gnus-configure-windows '(0 1 0)) ;Take all windows.
2147 (pop-to-buffer gnus-summary-buffer)))
2148 (Info-goto-node (car (cdr (assq major-mode gnus-info-nodes)))))
2151 "Send a bug report to the Gnus maintainers."
2153 (pop-to-buffer "*Gnus Bug*")
2155 (mail-setup gnus-maintainer "[Gnus Bug Report] " nil nil nil nil)
2156 (goto-char (point-min))
2157 (search-forward mail-header-separator)
2159 (insert (format "%s\n%s\n\n" (gnus-version) (emacs-version)))
2164 (defun gnus-debug ()
2165 "Attemps to go through the Gnus source file and report what variables have been changed.
2166 The source file has to be in the Emacs load path."
2168 (let ((dirs load-path)
2171 (if (file-exists-p (setq file (concat (car dirs) "/gnus.el")))
2174 (set-buffer (get-buffer-create "*gnus bug info*"))
2175 (buffer-disable-undo (current-buffer))
2177 (insert-file-contents file)
2178 (goto-char (point-min))
2179 (or (search-forward "\n;; Internal variables" nil t)
2180 (error "Malformed sources"))
2181 (narrow-to-region (point-min) (point))
2182 (goto-char (point-min))
2183 (while (setq expr (condition-case ()
2184 (read (current-buffer)) (error nil)))
2185 (and (eq (car expr) 'defvar)
2186 (stringp (nth 3 expr))
2187 (not (equal (eval (nth 2 expr))
2188 (and (boundp (nth 1 expr))
2189 (symbol-value (nth 1 expr)))))
2190 (setq olist (cons (nth 1 expr) olist))))
2191 (kill-buffer (current-buffer)))
2192 (setq dirs (cdr dirs))))
2194 (insert "(setq " (symbol-name (car olist)) " '"
2195 (prin1-to-string (symbol-value (car olist))) ")\n")
2196 (setq olist (cdr olist)))
2199 (defun gnus-overload-functions (&optional overloads)
2200 "Overload functions specified by optional argument OVERLOADS.
2201 If nothing is specified, use the variable gnus-overload-functions."
2203 (overloads (or overloads gnus-overload-functions)))
2205 (setq defs (car overloads))
2206 (setq overloads (cdr overloads))
2207 ;; Load file before overloading function if necessary. Make
2208 ;; sure we cannot use `require' always.
2209 (and (not (fboundp (car defs)))
2210 (car (cdr (cdr defs)))
2211 (load (car (cdr (cdr defs))) nil 'nomessage))
2212 (fset (car defs) (car (cdr defs))))))
2214 (defun gnus-replace-chars-in-string (string from to)
2215 "Replace characters in STRING from FROM to TO."
2216 (let ((string (substring string 0)) ;Copy string.
2217 (len (length string))
2219 ;; Replace all occurrences of FROM with TO.
2221 (if (= (aref string idx) from)
2222 (aset string idx to))
2223 (setq idx (1+ idx)))
2226 (defun gnus-days-between (date1 date2)
2227 ;; Return the number of days between date1 and date2.
2228 (let ((d1 (mapcar (lambda (s) (and s (string-to-int s)) )
2229 (timezone-parse-date date1)))
2230 (d2 (mapcar (lambda (s) (and s (string-to-int s)) )
2231 (timezone-parse-date date2))))
2232 (- (timezone-absolute-from-gregorian
2233 (nth 1 d1) (nth 2 d1) (car d1))
2234 (timezone-absolute-from-gregorian
2235 (nth 1 d2) (nth 2 d2) (car d2)))))
2237 (defun gnus-day-number (date)
2238 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2239 (timezone-parse-date date))))
2240 (timezone-absolute-from-gregorian
2241 (nth 1 dat) (nth 2 dat) (car dat))))
2243 (defun gnus-file-newer-than (file date)
2244 (let ((fdate (nth 5 (file-attributes file))))
2245 (or (> (car fdate) (car date))
2246 (and (= (car fdate) (car date))
2247 (> (nth 1 fdate) (nth 1 date))))))
2249 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2251 (defun gnus-y-or-n-p (prompt)
2256 (defun gnus-yes-or-no-p (prompt)
2258 (yes-or-no-p prompt)
2261 ;; Return a string of length POS+1 representing NUMber in BASE. The
2262 ;; resulting string will be left padded with zeds.
2263 (defun gnus-number-base-x (num pos base)
2268 (aref "zyxwvutsrqponmlkjihgfedcba9876543210" (/ num (expt base pos))))
2270 (% num (expt base pos)) (1- pos) base))))
2272 ;; List and range functions
2274 (defun gnus-last-element (list)
2275 "Return last element of LIST."
2277 (setq list (cdr list)))
2280 (defun gnus-copy-sequence (list)
2281 "Do a complete, total copy of a list."
2282 (mapcar (lambda (elem) (if (consp elem)
2283 (if (consp (cdr elem))
2284 (gnus-copy-sequence elem)
2285 (cons (car elem) (cdr elem)))
2289 (defun gnus-set-difference (list1 list2)
2290 "Return a list of elements of LIST1 that do not appear in LIST2."
2291 (let ((list1 (copy-sequence list1)))
2293 (setq list1 (delq (car list2) list1))
2294 (setq list2 (cdr list2)))
2297 (defun gnus-sorted-complement (list1 list2)
2298 "Return a list of elements of LIST1 that do not appear in LIST2.
2299 Both lists have to be sorted over <."
2301 (while (and list1 list2)
2302 (cond ((= (car list1) (car list2))
2303 (setq list1 (cdr list1)
2305 ((< (car list1) (car list2))
2306 (setq out (cons (car list1) out))
2307 (setq list1 (cdr list1)))
2309 (setq out (cons (car list2) out))
2310 (setq list2 (cdr list2)))))
2311 (append (or list1 list2) out)))
2313 (defun gnus-intersection (list1 list2)
2316 (if (memq (car list2) list1)
2317 (setq result (cons (car list2) result)))
2318 (setq list2 (cdr list2)))
2321 (defun gnus-sorted-intersection (list1 list2)
2322 ;; LIST1 and LIST2 have to be sorted over <.
2324 (while (and list1 list2)
2325 (cond ((= (car list1) (car list2))
2326 (setq out (cons (car list1) out)
2329 ((< (car list1) (car list2))
2330 (setq list1 (cdr list1)))
2332 (setq list2 (cdr list2)))))
2335 (defun gnus-set-sorted-intersection (list1 list2)
2336 ;; LIST1 and LIST2 have to be sorted over <.
2337 ;; This function modifies LIST1.
2338 (let* ((top (cons nil list1))
2340 (while (and list1 list2)
2341 (cond ((= (car list1) (car list2))
2345 ((< (car list1) (car list2))
2346 (setcdr prev (cdr list1))
2347 (setq list1 (cdr list1)))
2349 (setq list2 (cdr list2)))))
2353 (defun gnus-compress-sequence (numbers &optional always-list)
2354 "Convert list of numbers to a list of ranges or a single range.
2355 If ALWAYS-LIST is non-nil, this function will always release a list of
2357 (let* ((first (car numbers))
2358 (last (car numbers))
2363 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2364 ((= (1+ last) (car numbers)) ;Still in sequence
2365 (setq last (car numbers)))
2366 (t ;End of one sequence
2368 (cons (if (= first last) first (cons first last)) result))
2369 (setq first (car numbers))
2370 (setq last (car numbers))))
2371 (setq numbers (cdr numbers)))
2372 (if (and (not always-list) (null result))
2373 (if (= first last) first (cons first last))
2374 (nreverse (cons (if (= first last) first (cons first last))
2377 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2378 (defun gnus-uncompress-range (ranges)
2379 "Expand a list of ranges into a list of numbers.
2380 RANGES is either a single range on the form `(num . num)' or a list of
2382 (let (first last result)
2386 ((not (listp (cdr ranges)))
2387 (setq first (car ranges))
2388 (setq last (cdr ranges))
2389 (while (<= first last)
2390 (setq result (cons first result))
2391 (setq first (1+ first)))
2395 (if (atom (car ranges))
2396 (if (numberp (car ranges))
2397 (setq result (cons (car ranges) result)))
2398 (setq first (car (car ranges)))
2399 (setq last (cdr (car ranges)))
2400 (while (<= first last)
2401 (setq result (cons first result))
2402 (setq first (1+ first))))
2403 (setq ranges (cdr ranges)))
2404 (nreverse result)))))
2406 (defun gnus-add-to-range (ranges list)
2407 "Return a list of ranges that has all articles from both RANGES and LIST.
2408 Note: LIST has to be sorted over `<'."
2410 (gnus-compress-sequence list t)
2411 (setq list (copy-sequence list))
2412 (or (listp (cdr ranges))
2413 (setq ranges (list ranges)))
2415 ilist lowest highest temp)
2416 (while (and ranges list)
2418 (setq lowest (or (and (atom (car ranges)) (car ranges))
2419 (car (car ranges))))
2420 (while (and list (cdr list) (< (car (cdr list)) lowest))
2421 (setq list (cdr list)))
2422 (if (< (car ilist) lowest)
2425 (setq list (cdr list))
2427 (setq out (nconc (gnus-compress-sequence ilist t) out))))
2428 (setq highest (or (and (atom (car ranges)) (car ranges))
2429 (cdr (car ranges))))
2430 (while (and list (<= (car list) highest))
2431 (setq list (cdr list)))
2432 (setq ranges (cdr ranges)))
2434 (setq out (nconc (gnus-compress-sequence list t) out)))
2435 (setq out (sort out (lambda (r1 r2)
2436 (< (or (and (atom r1) r1) (car r1))
2437 (or (and (atom r2) r2) (car r2))))))
2440 (if (atom (car ranges))
2442 (if (atom (car (cdr ranges)))
2443 (if (= (1+ (car ranges)) (car (cdr ranges)))
2445 (setcar ranges (cons (car ranges)
2446 (car (cdr ranges))))
2447 (setcdr ranges (cdr (cdr ranges)))))
2448 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
2450 (setcar (car (cdr ranges)) (car ranges))
2451 (setcar ranges (car (cdr ranges)))
2452 (setcdr ranges (cdr (cdr ranges)))))))
2454 (if (atom (car (cdr ranges)))
2455 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
2457 (setcdr (car ranges) (car (cdr ranges)))
2458 (setcdr ranges (cdr (cdr ranges)))))
2459 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
2461 (setcdr (car ranges) (cdr (car (cdr ranges))))
2462 (setcdr ranges (cdr (cdr ranges))))))))
2463 (setq ranges (cdr ranges)))
2466 (defun gnus-add-to-range-new (ranges list)
2467 (gnus-compress-sequence
2468 (sort (nconc (gnus-uncompress-range ranges) list) '<)))
2470 (defun gnus-add-to-range-old (ranges list)
2471 "Return a list of ranges that has all articles from both RANGES and LIST.
2472 Note: LIST has to be sorted over `<'."
2473 (let* ((ranges (if (and ranges (atom (car ranges))) (list ranges) ranges))
2476 range nranges first last)
2480 (gnus-compress-sequence list t)
2482 (> (car (car ranges)) 1)
2485 (setq inrange (setq ranges (cons (cons 1 1) ranges)))))
2486 (while (and ranges list)
2487 (setq range (car ranges))
2488 (while (and list (>= (car list) (car range))
2489 (<= (car list) (cdr range)))
2490 (setq list (cdr list)))
2491 (while (and list (= (1- (car list)) (cdr range)))
2492 (setcdr range (car list))
2493 (setq list (cdr list)))
2494 (if (and list (and (> (car list) (cdr range))
2496 (< (car list) (car (car (cdr ranges))))))
2497 (setcdr ranges (cons (cons (car list) (car list)) (cdr ranges))))
2498 (setq ranges (cdr ranges)))
2499 (if (and list (not ranges))
2500 (setq inrange (nconc inrange (gnus-compress-sequence list t))))
2502 (if (eq (cdr (car inrange)) 1)
2503 (setq inrange (cdr inrange))
2504 (setcar (car inrange) 2)))
2505 (setq ranges inrange)
2507 (if (and (cdr ranges) (>= (1+ (cdr (car ranges)))
2508 (car (car (cdr ranges)))))
2510 (setcdr (car ranges) (cdr (car (cdr ranges))))
2511 (setcdr ranges (cdr (cdr ranges))))
2512 (setq ranges (cdr ranges))))
2513 (if (not (cdr inrange))
2517 (defun gnus-remove-from-range (ranges list)
2518 "Return a list of ranges that has all articles from LIST removed from RANGES.
2519 Note: LIST has to be sorted over `<'."
2520 ;; !!! This function shouldn't look like this, but I've got a headache.
2521 (gnus-compress-sequence
2522 (gnus-sorted-complement
2523 (gnus-uncompress-range ranges) list)))
2525 (defun gnus-member-of-range (number ranges)
2526 (if (not (listp (cdr ranges)))
2527 (and (>= number (car ranges))
2528 (<= number (cdr ranges)))
2531 (if (numberp (car ranges))
2532 (>= number (car ranges))
2533 (>= number (car (car ranges))))
2535 (if (if (numberp (car ranges))
2536 (= number (car ranges))
2537 (and (>= number (car (car ranges)))
2538 (<= number (cdr (car ranges)))))
2539 (setq not-stop nil))
2540 (setq ranges (cdr ranges)))
2548 (defvar gnus-group-mode-map nil)
2549 (defvar gnus-group-make-map nil)
2550 (defvar gnus-group-list-map nil)
2552 (if gnus-group-mode-map
2554 (setq gnus-group-mode-map (make-keymap))
2555 (suppress-keymap gnus-group-mode-map)
2556 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
2557 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
2558 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
2559 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
2560 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
2561 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
2562 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
2563 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
2564 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
2565 (define-key gnus-group-mode-map "\M-n" 'gnus-group-next-unread-group-same-level)
2566 (define-key gnus-group-mode-map "\M-p" 'gnus-group-prev-unread-group-same-level)
2567 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
2568 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
2569 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
2570 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
2571 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
2572 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
2573 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
2574 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
2575 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
2576 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
2577 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
2578 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
2579 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
2580 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
2581 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
2582 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
2583 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
2584 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
2585 (define-key gnus-group-mode-map "\C-c\M-C-a" 'gnus-group-description-apropos)
2586 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
2587 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
2588 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
2589 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
2590 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
2591 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
2592 (define-key gnus-group-mode-map "\M-z" 'gnus-group-kill-all-zombies)
2593 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
2594 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
2595 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
2596 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
2597 (define-key gnus-group-mode-map "V" 'gnus-version)
2598 (define-key gnus-group-mode-map "S" 'gnus-group-set-current-level)
2599 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
2600 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
2601 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
2602 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
2603 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
2604 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
2605 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
2606 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
2607 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group)
2608 (define-key gnus-group-mode-map [mouse-2] 'gnus-mouse-pick-group)
2610 (define-prefix-command 'gnus-group-make-map)
2611 (define-key gnus-group-mode-map "M" 'gnus-group-make-map)
2612 (define-key gnus-group-make-map "d" 'gnus-group-make-directory-group)
2613 (define-key gnus-group-make-map "h" 'gnus-group-make-help-group)
2614 (define-key gnus-group-make-map "k" 'gnus-group-make-kiboze-group)
2615 (define-key gnus-group-make-map "m" 'gnus-group-make-group)
2616 (define-key gnus-group-make-map "e" 'gnus-group-edit-group)
2618 (define-prefix-command 'gnus-group-list-map)
2619 (define-key gnus-group-mode-map "G" 'gnus-group-list-map)
2620 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
2621 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
2622 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
2623 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
2624 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
2625 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
2626 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
2627 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
2630 (defun gnus-group-mode ()
2631 "Major mode for reading news.
2633 All normal editing commands are switched off.
2634 \\<gnus-group-mode-map>
2635 The group buffer lists (some of) the groups available. For instance,
2636 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
2637 lists all zombie groups.
2639 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
2640 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
2642 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
2644 The following commands are available:
2646 \\{gnus-group-mode-map}"
2648 (if gnus-visual (gnus-group-make-menu-bar))
2649 (kill-all-local-variables)
2650 (setq mode-line-modified "-- ")
2651 (make-local-variable 'mode-line-format)
2652 (setq mode-line-format (copy-sequence mode-line-format))
2653 (and (equal (nth 3 mode-line-format) " ")
2654 (setcar (nthcdr 3 mode-line-format) ""))
2655 (setq major-mode 'gnus-group-mode)
2656 (setq mode-name "Group")
2657 (gnus-group-set-mode-line)
2658 (setq mode-line-process nil)
2659 (use-local-map gnus-group-mode-map)
2660 (buffer-disable-undo (current-buffer))
2661 (setq truncate-lines t)
2662 (setq buffer-read-only t)
2663 (run-hooks 'gnus-group-mode-hook))
2665 (defun gnus-mouse-pick-group (e)
2668 (gnus-group-read-group nil))
2671 (defun gnus-no-server (&optional arg)
2673 If ARG is a positive number, Gnus will use that as the
2674 startup level. If ARG is nil, Gnus will be started at level 2.
2675 If ARG is non-nil and not a positive number, Gnus will
2676 prompt the user for the name of an NNTP server to use.
2677 As opposed to `gnus', this command will not connect to the local server."
2679 (gnus (or arg 2) t))
2681 (defalias '\(ding\) 'gnus)
2684 (defun gnus (&optional arg dont-connect)
2686 If ARG is non-nil and a positive number, Gnus will use that as the
2687 startup level. If ARG is non-nil and not a positive number, Gnus will
2688 prompt the user for the name of an NNTP server to use."
2690 (if (get-buffer gnus-group-buffer)
2692 (switch-to-buffer gnus-group-buffer)
2693 (gnus-group-get-new-news))
2695 (gnus-read-init-file)
2696 (let ((level (and arg (numberp arg) (> arg 0) arg)))
2699 (switch-to-buffer (get-buffer-create gnus-group-buffer))
2700 (gnus-add-current-to-buffer-list)
2702 (or dont-connect (gnus-start-news-server (and arg (not level)))))
2703 (if (and (not dont-connect)
2704 (not (gnus-server-opened gnus-select-method)))
2706 (run-hooks 'gnus-startup-hook)
2707 ;; NNTP server is successfully open.
2708 (gnus-update-format-specifications)
2709 (let ((buffer-read-only nil))
2711 (if (not gnus-inhibit-startup-message)
2713 (gnus-group-startup-message)
2715 (gnus-setup-news nil level)
2716 (and gnus-use-dribble-file (gnus-dribble-open))
2717 (or t (not gnus-novice-user)
2719 (gnus-group-describe-briefly)) ;Show brief help message.
2720 (gnus-group-list-groups (or level 5)))))))
2722 (defun gnus-group-startup-message (&optional x y)
2723 "Insert startup message in current buffer."
2724 ;; Insert the message.
2741 ;; And then hack it.
2742 ;; 18 is the longest line.
2743 (indent-rigidly (point-min) (point-max)
2744 (/ (max (- (window-width) (or x 28)) 0) 2))
2745 (goto-char (point-min))
2746 ;; +4 is fuzzy factor.
2747 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2)))
2749 (defun gnus-group-setup-buffer ()
2750 (or (get-buffer gnus-group-buffer)
2752 (switch-to-buffer (get-buffer-create gnus-group-buffer))
2753 (gnus-add-current-to-buffer-list)
2754 (gnus-group-mode))))
2756 (defun gnus-group-list-groups (level &optional unread)
2757 "List newsgroups with level LEVEL or lower that have unread alticles.
2758 Default is 5, which lists all subscribed groups.
2759 If argument UNREAD is non-nil, groups with no unread articles are also listed."
2761 (setq level (or level 5))
2762 (gnus-group-setup-buffer) ;May call from out of group buffer
2763 (let ((case-fold-search nil)
2764 (group (gnus-group-group-name)))
2765 (funcall gnus-group-prepare-function level unread nil)
2766 (if (zerop (buffer-size))
2767 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
2768 (message "No news is horrible news")
2769 (goto-char (point-min))
2771 ;; Go to the first group with unread articles.
2772 (gnus-group-search-forward nil nil nil t)
2773 ;; Find the right group to put point on. If the current group
2774 ;; has disapeared in the new listing, try to find the next
2775 ;; one. If no next one can be found, just leave point at the
2776 ;; first newsgroup in the buffer.
2777 (if (not (gnus-goto-char
2778 (text-property-any (point-min) (point-max)
2779 'gnus-group (intern group))))
2780 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
2782 (not (gnus-goto-char
2784 (point-min) (point-max) 'gnus-group
2786 (setq newsrc (cdr newsrc))))))
2787 ;; Adjust cursor point.
2788 (gnus-group-position-cursor))))
2790 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
2791 "List all newsgroups with unread articles of level LEVEL or lower.
2792 If ALL is non-nil, list groups that have no unread articles.
2793 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
2794 If REGEXP, only list groups matching REGEXP."
2795 (set-buffer gnus-group-buffer)
2796 (let ((buffer-read-only nil)
2797 (newsrc (cdr gnus-newsrc-assoc))
2798 (lowest (or lowest 1))
2799 info clevel unread group)
2802 ;; List living groups.
2804 (setq info (car newsrc)
2807 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
2808 (and unread ; This group might be bogus
2810 (string-match regexp group))
2811 (<= (setq clevel (car (cdr info))) level)
2813 (or all ; We list all groups?
2814 (eq unread t) ; We list unactivated groups
2815 (> unread 0) ; We list groups with unread articles
2816 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
2817 (gnus-group-insert-group-line
2818 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
2820 ;; List dead groups.
2821 (and (>= level 8) (<= lowest 8)
2822 (gnus-group-prepare-flat-list-dead
2823 (setq gnus-zombie-list (sort gnus-zombie-list 'string<)) 8 ?Z
2825 (and (>= level 9) (<= lowest 9)
2826 (gnus-group-prepare-flat-list-dead
2827 (setq gnus-killed-list (sort gnus-killed-list 'string<)) 9 ?K
2830 (gnus-group-set-mode-line)
2831 (setq gnus-have-all-newsgroups all)
2832 (run-hooks 'gnus-group-prepare-hook)))
2834 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
2835 ;; List zombies and killed lists somehwat faster, which was
2836 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
2837 ;; this by ignoring the group format specification altogether.
2840 (setq group (car groups)
2841 groups (cdr groups))
2842 (if (or (not regexp)
2843 (string-match regexp group))
2846 (insert (format " %c *: %s\n" mark group))
2847 (add-text-properties
2849 (list 'gnus-group (intern group)
2851 'gnus-level level)))))))
2853 (defun gnus-group-real-name (group)
2854 "Find the real name of a foreign newsgroup."
2855 (if (string-match "^[^:]+:" group)
2856 (substring group (match-end 0))
2859 (defun gnus-group-prefixed-name (group method)
2860 "Return the whole name from GROUP and METHOD."
2861 (concat (format "%s" (car method))
2862 (if (assoc (format "%s" (car method)) (gnus-methods-using 'address))
2863 (concat "+" (nth 1 method)))
2866 (defun gnus-group-real-prefix (group)
2867 "Return the prefix of the current group name."
2868 (if (string-match "^[^:]+:" group)
2869 (substring group 0 (match-end 0))
2872 (defun gnus-group-method-name (group)
2873 "Return the method used for selecting GROUP."
2874 (let ((prefix (gnus-group-real-prefix group)))
2875 (if (equal prefix "")
2877 (if (string-match "^[^\\+]+\\+" prefix)
2878 (list (intern (substring prefix 0 (1- (match-end 0))))
2879 (substring prefix (match-end 0) (1- (length prefix))))
2880 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
2882 (defun gnus-group-foreign-p (group)
2883 "Return nil if GROUP is native, non-nil if it is foreign."
2884 (string-match ":" group))
2886 (defun gnus-group-set-info (info)
2887 (let ((entry (gnus-gethash (car info) gnus-newsrc-hashtb)))
2889 (if (not (setq marked (nth 3 info)))
2892 (or (eq 'score (car (car marked)))
2893 (not (or (atom (cdr (cdr (car marked))))
2894 (not (atom (car (cdr (car marked)))))))
2895 (setcdr (car marked)
2896 (gnus-uncompress-range (cdr (car marked)))))
2897 (setq marked (cdr marked)))))
2901 (set-buffer gnus-group-buffer)
2903 (gnus-group-make-group
2904 (gnus-group-real-name (car info))
2905 (prin1-to-string (car (nth 4 info)))
2906 (nth 1 (nth 4 info)))
2907 (gnus-group-make-group
2909 (prin1-to-string (car gnus-select-method))
2910 (nth 1 gnus-select-method)))
2911 (message "Note: New group created")
2913 (gnus-gethash (gnus-group-prefixed-name
2914 (gnus-group-real-name (car info))
2915 (or (nth 4 info) gnus-select-method))
2916 gnus-newsrc-hashtb))))
2919 (setcar (nthcdr 2 entry) info)
2920 (if (and (not (eq (car entry) t))
2921 (gnus-gethash (car info) gnus-active-hashtb))
2922 (let ((marked (nth 3 info)))
2924 (max 0 (- (length (gnus-list-of-unread-articles
2926 (length (cdr (assq 'tick marked)))
2927 (length (cdr (assq 'dormant marked)))))))))
2928 (error "No such group: %s" (car info)))))
2930 (defun gnus-group-update-group-line ()
2931 "This function updates the current line in the newsgroup buffer and
2932 moves the point to the colon."
2933 (let* ((buffer-read-only nil)
2934 (group (gnus-group-group-name))
2935 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
2938 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
2941 (delete-region (point) (save-excursion (forward-line 1) (point)))
2942 (gnus-group-insert-group-line-info group)
2944 (gnus-group-position-cursor)))
2946 (defun gnus-group-insert-group-line-info (group)
2947 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
2951 (setq info (nth 2 entry))
2952 (gnus-group-insert-group-line
2953 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
2954 (setq active (gnus-gethash group gnus-active-hashtb))
2955 (gnus-group-insert-group-line
2956 nil group (if (member group gnus-zombie-list) 8 9)
2957 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
2959 (defun gnus-group-insert-group-line (gformat group level marked number method)
2960 (let* ((gformat (or gformat gnus-group-line-format-spec))
2961 (active (gnus-gethash group gnus-active-hashtb))
2962 (number-total (if active (1+ (- (cdr active) (car active))) 0))
2963 (number-of-dormant (length (cdr (assq 'dormant marked))))
2964 (number-of-ticked (length (cdr (assq 'tick marked))))
2965 (number-of-ticked-and-dormant
2966 (+ number-of-ticked number-of-dormant))
2967 (number-of-unread-unticked
2968 (if (numberp number) (int-to-string (max 0 number))
2971 (if (numberp number)
2972 (max 0 (- number-total number))
2974 (subscribed (cond ((< level 6) ? )
2978 (qualified-group (gnus-group-real-name group))
2979 (newsgroup-description
2980 (if gnus-description-hashtb
2981 (or (gnus-gethash group gnus-description-hashtb) "")
2983 (moderated (if (member group gnus-moderated-list) ?m ? ))
2984 (moderated-string (if (eq moderated ?m) "(m)" ""))
2985 (news-server (or (car (cdr method)) ""))
2986 (news-method (or (car method) ""))
2988 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
2992 (> number-of-ticked 0))
2994 (number (if (eq number t) "*" (+ number number-of-dormant
2996 (buffer-read-only nil)
3001 (insert (eval gformat))
3003 (add-text-properties
3004 b (1+ b) (list 'gnus-group (intern group)
3005 'gnus-unread (if (numberp number)
3006 (string-to-int number-of-unread-unticked)
3009 'gnus-level level))))
3011 (defun gnus-group-update-group (group &optional visible-only)
3012 "Update newsgroup info of GROUP.
3013 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3015 (set-buffer gnus-group-buffer)
3016 (let ((buffer-read-only nil)
3018 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3021 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3023 ;; Buffer may be narrowed.
3026 ;; Search a line to modify. If the buffer is large, the search
3027 ;; takes long time. In most cases, current point is on the line
3028 ;; we are looking for. So, first of all, check current line.
3031 (eq (get-text-property (point) 'gnus-group)
3036 (point-min) (point-max) 'gnus-group (intern group)))))
3037 ;; GROUP is listed in current buffer. So, delete old line.
3041 (delete-region (point) (progn (forward-line 1) (point))))
3042 ;; No such line in the buffer, find out where it's supposed to
3043 ;; go, and insert it there (or at the end of the buffer).
3044 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3046 (let ((entry (cdr (gnus-gethash group gnus-newsrc-hashtb))))
3051 (point-min) (point-max)
3052 'gnus-group (intern (car (car entry)))))))
3053 (setq entry (cdr entry)))
3054 (or entry (goto-char (point-max)))))))
3055 (if (or visible (not visible-only))
3056 (gnus-group-insert-group-line-info group))
3057 (gnus-group-set-mode-line))))
3059 (defun gnus-group-set-mode-line ()
3060 (if (memq 'group gnus-updated-mode-lines)
3061 (let* ((gformat (or gnus-group-mode-line-format-spec
3062 (setq gnus-group-mode-line-format-spec
3064 gnus-group-mode-line-format
3065 gnus-group-mode-line-format-alist))))
3066 (news-server (car (cdr gnus-select-method)))
3067 (news-method (car gnus-select-method))
3068 (mode-string (eval gformat))
3070 (if (> (length mode-string) max-len)
3071 (setq mode-string (substring mode-string 0 (- max-len 4))))
3072 (setq mode-line-buffer-identification mode-string)
3073 (set-buffer-modified-p t))))
3075 (defun gnus-group-group-name ()
3076 "Get the name of the newsgroup on the current line."
3077 (let ((group (get-text-property
3078 (save-excursion (beginning-of-line) (point)) 'gnus-group)))
3079 (and group (symbol-name group))))
3081 (defun gnus-group-group-level ()
3082 "Get the level of the newsgroup on the current line."
3083 (get-text-property (save-excursion (beginning-of-line) (point)) 'gnus-level))
3085 (defun gnus-group-search-forward (&optional backward all level first-too)
3086 "Find the next newsgroup with unread articles.
3087 If BACKWARD is non-nil, find the previous newsgroup instead.
3088 If ALL is non-nil, just find any newsgroup.
3089 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3091 If FIRST-TOO, the current line is also eligeble as a target."
3092 (let ((way (if backward -1 1))
3096 (or first-too (forward-line way))
3104 (get-text-property (point) 'gnus-unread)))
3105 (or (eq unread t) (and unread (> unread 0))))
3106 (< (get-text-property (point) 'gnus-level) 6)))
3108 (let ((lev (get-text-property (point) 'gnus-level)))
3114 (setq pos (point))))
3116 (zerop (forward-line way))))
3118 (progn (gnus-group-position-cursor) t)
3119 (if pos (goto-char pos) (goto-char beg))
3122 ;; Gnus group mode commands
3124 (defun gnus-group-read-group (all &optional no-article group)
3125 "Read news in this newsgroup.
3126 If argument ALL is non-nil, already read articles become readable.
3127 If optional argument NO-ARTICLE is non-nil, no article body is displayed."
3129 (let ((group (or group (gnus-group-group-name)))
3130 number active marked entry)
3131 (or group (error "No group on current line"))
3133 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3134 ;; This group might be a dead group. In that case we have to get
3135 ;; the number of unread articles from `gnus-active-hashtb'.
3137 (setq number (car entry))
3138 (if (setq active (gnus-gethash group gnus-active-hashtb))
3139 (setq number (- (1+ (cdr active)) (car active)))))
3140 (gnus-summary-read-group
3141 group (or all (and (numberp number)
3142 (zerop (+ number (length (cdr (assq 'tick marked)))
3143 (length (cdr (assq 'dormant marked)))))))
3146 (defun gnus-group-select-group (all)
3147 "Select this newsgroup.
3148 No article is selected automatically.
3149 If argument ALL is non-nil, already read articles become readable."
3151 (gnus-group-read-group all t))
3153 (defun gnus-group-jump-to-group (group)
3154 "Jump to newsgroup GROUP."
3157 (completing-read "Group: " gnus-active-hashtb nil t)))
3159 ;; Either go to the line in the group buffer...
3160 (or (and (setq b (text-property-any (point-min) (point-max)
3161 'gnus-group (intern group)))
3163 ;; ... or insert the line.
3164 (progn (gnus-group-update-group group)
3165 (goto-char (text-property-any (point-min) (point-max)
3166 'gnus-group (intern group))))))
3167 ;; Adjust cursor point.
3168 (gnus-group-position-cursor))
3170 (defun gnus-group-next-group (n)
3171 "Go to next N'th newsgroup.
3172 If N is negative, search backward instead.
3173 Returns the difference between N and the number of skips actually
3176 (gnus-group-next-unread-group n t))
3178 (defun gnus-group-next-unread-group (n &optional all level)
3179 "Go to next N'th unread newsgroup.
3180 If N is negative, search backward instead.
3181 If ALL is non-nil, choose any newsgroup, unread or not.
3182 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
3183 such group can be found, the next group with a level higher than
3185 Returns the difference between N and the number of skips actually
3188 (let ((backward (< n 0))
3191 (gnus-group-search-forward backward all level))
3193 (if (/= 0 n) (message "No more%s newsgroups%s" (if all "" " unread")
3194 (if level " on this level or higher" "")))
3197 (defun gnus-group-prev-group (n)
3198 "Go to previous N'th newsgroup.
3199 Returns the difference between N and the number of skips actually
3202 (gnus-group-next-unread-group (- n) t))
3204 (defun gnus-group-prev-unread-group (n)
3205 "Go to previous N'th unread newsgroup.
3206 Returns the difference between N and the number of skips actually
3209 (gnus-group-next-unread-group (- n)))
3211 (defun gnus-group-next-unread-group-same-level (n)
3212 "Go to next N'th unread newsgroup on the same level.
3213 If N is negative, search backward instead.
3214 Returns the difference between N and the number of skips actually
3217 (gnus-group-next-unread-group n t (gnus-group-group-level))
3218 (gnus-group-position-cursor))
3220 (defun gnus-group-prev-unread-group-same-level (n)
3221 "Go to next N'th unread newsgroup on the same level.
3222 Returns the difference between N and the number of skips actually
3225 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
3226 (gnus-group-position-cursor))
3228 (defun gnus-group-best-unread-group ()
3229 "Go to the group with the highest level."
3231 (goto-char (point-min))
3234 (while (setq unread (get-text-property (point) 'gnus-unread))
3235 (if (and (numberp unread) (> unread 0))
3237 (or best-point (setq best-point (point)))
3238 (if (< (get-text-property (point) 'gnus-level) best)
3240 (setq best (get-text-property (point) 'gnus-level))
3241 (setq best-point (point))))))
3243 (if best-point (goto-char best-point))
3244 (gnus-summary-position-cursor)
3245 (and best-point (gnus-group-group-name))))
3247 (defun gnus-group-make-group (name method address)
3248 "Add a new newsgroup.
3249 The user will be prompted for a NAME, for a select METHOD, and an
3253 (read-string "Group name: ")
3256 "Method: " gnus-valid-select-methods nil t)))
3258 (if (memq 'prompt-address
3259 (assoc method gnus-valid-select-methods))
3260 (read-string "Address: ")
3262 (let ((nname (gnus-group-prefixed-name name (list (intern method) address)))
3264 (gnus-group-change-level
3265 (setq info (list t nname 3 nil nil (list (intern method) address)))
3266 3 9 (gnus-gethash (or (gnus-group-group-name) "dummy.group")
3267 gnus-newsrc-hashtb) t)
3268 (gnus-sethash nname '(0 . 0) gnus-active-hashtb)
3270 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
3271 (gnus-group-insert-group-line-info nname)))
3273 (defun gnus-group-edit-group (group)
3274 (interactive (list (gnus-group-group-name)))
3276 (if group (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
3277 (error "No group on current line"))
3278 (setq gnus-winconf-edit-group (current-window-configuration))
3279 (pop-to-buffer (get-buffer-create gnus-group-edit-buffer))
3280 (gnus-add-current-to-buffer-list)
3282 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3283 (use-local-map (copy-keymap emacs-lisp-mode-map))
3284 (local-set-key "\C-c\C-c" 'gnus-group-edit-group-done)
3286 (insert ";; Type `C-c C-c' after you have edited the newsgroup entry.\n\n")
3287 (let ((cinfo (gnus-copy-sequence info))
3289 (if (not (setq marked (nth 3 cinfo)))
3292 (or (eq 'score (car (car marked)))
3293 (setcdr (car marked)
3294 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
3295 (setq marked (cdr marked))))
3296 (insert (pp-to-string (list 'gnus-group-set-info
3297 (list 'quote cinfo)))))))
3299 (defun gnus-group-edit-group-done ()
3301 (set-buffer (get-buffer-create gnus-group-edit-buffer))
3302 (eval-current-buffer)
3303 (kill-buffer (current-buffer))
3304 (and gnus-winconf-edit-group
3305 (set-window-configuration gnus-winconf-edit-group))
3306 (setq gnus-winconf-edit-group nil)
3307 (set-buffer gnus-group-buffer)
3308 (gnus-group-update-group (gnus-group-group-name))
3309 (gnus-group-position-cursor))
3311 (defun gnus-group-make-help-group ()
3312 "Create the (ding) Gnus documentation group."
3314 (and (gnus-gethash (gnus-group-prefixed-name "gnus-help" '(nndoc ""))
3316 (error "Documentation group already exists"))
3317 (let ((path load-path))
3319 (not (file-exists-p (concat (file-name-as-directory (car path))
3321 (setq path (cdr path)))
3322 (or path (error "Couldn't find doc group"))
3323 (gnus-group-make-group
3325 (concat (file-name-as-directory (car path)) "doc.txt"))
3326 (gnus-group-position-cursor)))
3328 (defun gnus-group-make-directory-group (dir)
3329 "Create an nndir group.
3330 The user will be prompted for a directory. The contents of this
3331 directory will be used as a newsgroup. The directory should contain
3332 mail messages or news articles in files that have numeric names."
3334 (list (read-file-name "Create group from directory: ")))
3335 (or (file-exists-p dir) (error "No such directory"))
3336 (or (file-directory-p dir) (error "Not a directory"))
3337 (gnus-group-make-group dir "nndir" dir)
3338 (gnus-group-position-cursor))
3340 (defun gnus-group-make-kiboze-group (group address scores)
3341 "Create an nnkiboze group.
3342 The user will be prompted for a name, a regexp to match groups, and
3343 score file entries for articles to include in the group."
3346 (read-string "nnkiboze group name: ")
3347 (read-string "Source groups (regexp): ")
3348 (let ((headers (mapcar (lambda (group) (list group))
3349 '("subject" "from" "number" "date" "message-id"
3350 "references" "chars" "lines" "xref")))
3351 scores header regexp regexps)
3352 (while (not (equal "" (setq header (completing-read
3353 "Match on header: " headers nil t))))
3355 (while (not (equal "" (setq regexp (read-string
3356 (format "Match on %s (string): "
3358 (setq regexps (cons (list regexp nil 1000 nil) regexps)))
3359 (setq scores (cons (cons header regexps) scores)))
3361 (gnus-group-make-group group "nnkiboze" address)
3363 (set-buffer (get-buffer-create " *gnus work*"))
3364 (buffer-disable-undo (current-buffer))
3365 (let (emacs-lisp-mode-hook)
3366 (pp (list 'setq 'gnus-score-alist
3367 (list 'quote (list scores)))
3369 (write-region (point-min) (point-max)
3370 (concat (or gnus-kill-files-directory "~/News")
3371 "nnkiboze:" group "." gnus-score-file-suffix))
3372 (kill-buffer (current-buffer)))
3373 (gnus-group-position-cursor))
3375 ;; Group sorting commands
3376 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
3378 (defun gnus-group-sort-groups ()
3379 "Sort the group buffer using `gnus-group-sort-function'."
3381 (setq gnus-newsrc-assoc
3382 (sort (cdr gnus-newsrc-assoc) gnus-group-sort-function))
3383 (gnus-make-hashtable-from-newsrc-alist)
3384 (gnus-get-unread-articles 6)
3385 (gnus-group-list-groups 5))
3387 (defun gnus-group-sort-by-alphabet (info1 info2)
3388 (string< (car info1) (car info2)))
3390 (defun gnus-group-sort-by-unread (info1 info2)
3391 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
3392 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
3393 (< (or (and (numberp n1) n1) 0)
3394 (or (and (numberp n2) n2) 0))))
3396 (defun gnus-group-sort-by-level (info1 info2)
3397 (< (nth 1 info1) (nth 1 info2)))
3399 ;; Group catching up.
3401 (defun gnus-group-catchup-current (n &optional all)
3402 "Mark all articles not marked as unread in current newsgroup as read.
3403 If prefix argument N is numeric, the ARG next newsgroups will be
3404 caught up. If ALL is non-nil, marked articles will also be marked as
3405 read. Cross references (Xref: header) of articles are ignored.
3406 The difference between N and actual number of newsgroups that were
3407 caught up is returned."
3409 (if (or (not gnus-interactive-catchup) ;Without confirmation?
3413 "Do you really want to mark all articles as read? "
3414 "Mark all unread articles as read? ")))
3420 (gnus-group-catchup (gnus-group-group-name) all)
3421 (gnus-group-update-group-line)
3423 (zerop (gnus-group-next-unread-group 1))))))
3426 (defun gnus-group-catchup-current-all (n)
3427 "Mark all articles in current newsgroup as read.
3428 Cross references (Xref: header) of articles are ignored."
3430 (gnus-group-catchup-current n 'all))
3432 (defun gnus-group-catchup (group &optional all)
3433 "Mark all articles in GROUP as read.
3434 If ALL is non-nil, all articles are marked as read.
3435 The return value is the number of articles that were marked as read,
3436 or nil if no action could be taken."
3437 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3439 (marked (nth 3 (nth 2 entry)))
3441 (if (not (numberp (car entry)))
3442 (message "Can't catch up; non-active group")
3443 ;; Do the updating only if the newsgroup isn't killed
3446 (setq ticked (if all nil (cdr (assq 'tick marked))))
3447 (gnus-update-read-articles group ticked nil ticked)
3448 (if (and all marked)
3449 (setcar (nthcdr 3 (nth 2 entry))
3450 (delq (assq 'dormant marked) marked))))))
3453 (defun gnus-group-expire-articles (newsgroup)
3454 "Expire all expirable articles in the current newsgroup."
3455 (interactive (list (gnus-group-group-name)))
3456 (if (not newsgroup) (error "No current newsgroup"))
3458 (assq 'expire (nth 3 (nth 2 (gnus-gethash newsgroup
3459 gnus-newsrc-hashtb))))))
3461 (gnus-check-backend-function 'request-expire-articles newsgroup)
3463 (gnus-request-expire-articles (cdr expirable) newsgroup)))))
3465 (defun gnus-group-expire-all-groups ()
3466 "Expire all expirable articles in all newsgroups."
3468 (message "Expiring...")
3469 (let ((newsrc (cdr gnus-newsrc-assoc)))
3471 (gnus-group-expire-articles (car (car newsrc)))
3472 (setq newsrc (cdr newsrc))))
3473 (message "Expiring...done"))
3475 (defun gnus-group-set-current-level (n)
3476 "Set the level of the current group to the numeric prefix."
3478 (setq n (or n (string-to-int
3481 (mapcar (lambda (n) (list (char-to-string n))) "123456789")
3483 (let ((group (gnus-group-group-name)))
3484 (if (not group) (error "No newsgroup on current line.")
3485 (if (and (numberp n) (>= n 1) (<= n 9))
3487 (message "Changed level of %s from %d to %d"
3488 group (gnus-group-group-level) n)
3489 (gnus-group-change-level group n (gnus-group-group-level))
3490 (gnus-group-update-group-line))
3491 (error "Illegal level: %s" n))))
3493 (gnus-group-position-cursor))
3495 (defun gnus-group-unsubscribe-current-group (arg)
3496 "Toggle subscribe from/to unsubscribe current group."
3498 (let ((group (gnus-group-group-name)))
3499 (or group (error "No newsgroup on current line"))
3500 (or arg (setq arg (if (<= (gnus-group-group-level) 5) 6 3)))
3501 (gnus-group-unsubscribe-group group arg)
3502 (gnus-group-next-group 1)))
3504 (defun gnus-group-unsubscribe-group (group &optional level)
3505 "Toggle subscribe from/to unsubscribe GROUP.
3506 New newsgroup is added to .newsrc automatically."
3508 (list (completing-read "Group: " gnus-active-hashtb nil
3509 gnus-have-read-active-file)))
3510 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3512 ;; Toggle subscription flag.
3513 (gnus-group-change-level
3514 newsrc (if level level (if (< (nth 1 (nth 2 newsrc)) 6) 6 4)))
3515 (gnus-group-update-group group))
3516 ((and (stringp group)
3517 (or (not gnus-have-read-active-file)
3518 (gnus-gethash group gnus-active-hashtb)))
3519 ;; Add new newsgroup.
3520 (gnus-group-change-level
3523 (or (and (member group gnus-zombie-list) 8) 9)
3524 (or (and (gnus-group-group-name)
3525 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb))
3526 (gnus-gethash (car (car gnus-newsrc-assoc))
3527 gnus-newsrc-hashtb)))
3528 (gnus-group-update-group group))
3529 (t (error "No such newsgroup: %s" group)))
3530 (gnus-group-position-cursor)))
3532 (defun gnus-group-transpose-groups (arg)
3533 "Exchange current newsgroup and previous newsgroup.
3534 With argument ARG, takes previous newsgroup and moves it past ARG newsgroup."
3536 ;; BUG: last newsgroup and the last but one cannot be transposed
3537 ;; since gnus-group-search-forward does not move forward beyond the
3538 ;; last. If we instead use forward-line, no problem, but I don't
3539 ;; want to use it for later extension.
3541 (gnus-group-search-forward t t)
3542 (gnus-group-kill-group 1)
3543 (gnus-group-search-forward nil t)
3544 (gnus-group-yank-group)
3545 (gnus-group-search-forward nil t)
3546 (setq arg (1- arg))))
3548 (defun gnus-group-kill-all-zombies ()
3549 "Kill all zombie newsgroups."
3551 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3552 (setq gnus-zombie-list nil)
3553 (funcall gnus-group-prepare-function 5 nil nil)
3554 (goto-char (point-min))
3555 (gnus-group-position-cursor))
3557 (defun gnus-group-kill-region (begin end)
3558 "Kill newsgroups in current region (excluding current point).
3559 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3562 ;; Exclude a line where current point is on.
3576 (beginning-of-line) ;Important when LINES < 1
3577 (gnus-group-kill-group lines)))
3579 (defun gnus-group-kill-group (n)
3580 "The the next N groups.
3581 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3582 However, only groups that were alive can be yanked; already killed
3583 groups or zombie groups can't be yanked.
3584 The return value is the name of the (last) newsgroup that was killed."
3586 (let ((buffer-read-only nil)
3588 (while (>= (setq n (1- n)) 0)
3589 (setq group (gnus-group-group-name))
3591 (signal 'end-of-buffer nil))
3592 (setq level (gnus-group-group-level))
3594 (delete-region (point) (progn (forward-line 1) (point)))
3595 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
3596 (setq gnus-list-of-killed-groups
3597 (cons (cons (car entry) (nth 2 entry))
3598 gnus-list-of-killed-groups)))
3599 (gnus-group-change-level (if entry entry group) 9 (if entry nil level)))
3602 (gnus-group-position-cursor)
3605 (defun gnus-group-yank-group (&optional arg)
3606 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
3607 inserting it before the current newsgroup. The numeric ARG specifies
3608 how many newsgroups are to be yanked. The name of the (last)
3609 newsgroup yanked is returned."
3611 (if (not arg) (setq arg 1))
3612 (let (info group prev)
3613 (while (>= (setq arg (1- arg)) 0)
3614 (if (not (setq info (car gnus-list-of-killed-groups)))
3615 (error "No more newsgroups to yank"))
3616 (setq group (nth 2 info))
3617 ;; Find which newsgroup to insert this one before - search
3618 ;; backward until something suitable is found. If there are no
3619 ;; other newsgroups in this buffer, just make this newsgroup the
3621 (while (and (not (setq prev (gnus-group-group-name)))
3622 (zerop (forward-line -1))))
3624 (setq prev (car (car gnus-newsrc-assoc))))
3625 (gnus-group-change-level
3627 (gnus-gethash prev gnus-newsrc-hashtb)
3629 (gnus-group-insert-group-line-info (nth 1 info))
3630 (setq gnus-list-of-killed-groups
3631 (cdr gnus-list-of-killed-groups)))
3633 (gnus-group-position-cursor)
3636 (defun gnus-group-list-all-groups (arg)
3637 "List all newsgroups with level ARG or lower.
3638 Default is 7, which lists all subscribed and most unsubscribed groups."
3640 (setq arg (or arg 7))
3641 (gnus-group-list-groups arg t))
3643 (defun gnus-group-list-killed ()
3644 "List all killed newsgroups in the group buffer."
3646 (if (not gnus-killed-list)
3647 (message "No killed groups")
3648 (funcall gnus-group-prepare-function 9 t 9)
3649 (goto-char (point-min)))
3650 (gnus-group-position-cursor))
3652 (defun gnus-group-list-zombies ()
3653 "List all zombie newsgroups in the group buffer."
3655 (if (not gnus-zombie-list)
3656 (message "No zombie groups")
3657 (funcall gnus-group-prepare-function 8 t 8)
3658 (goto-char (point-min)))
3659 (gnus-group-position-cursor))
3661 (defun gnus-group-get-new-news (&optional arg)
3662 "Get newly arrived articles.
3663 If ARG is non-nil, it should be a number between one and nine to
3664 specify which levels you are interested in re-scanning."
3666 (run-hooks 'gnus-get-new-news-hook)
3667 (if (and gnus-read-active-file (not arg))
3669 (gnus-read-active-file)
3670 (gnus-get-unread-articles (or arg 6)))
3671 (let ((gnus-read-active-file nil))
3672 (gnus-get-unread-articles (or arg 6))))
3673 (gnus-group-list-groups 5 gnus-have-all-newsgroups))
3675 (defun gnus-group-get-new-news-this-group (n)
3676 "Check for newly arrived news in the current group (and the N-1 next groups).
3677 The difference between N and the number of newsgroup checked is returned.
3678 If N is negative, this group and the N-1 previous groups will be checked."
3680 (let ((way (if (< n 0) -1 1))
3682 (w-p (window-start))
3686 (or (gnus-get-new-news-in-group
3687 (setq group (gnus-group-group-name)))
3690 (message "%s error: %s"
3691 group (gnus-status-message group))))
3693 (zerop (gnus-group-next-group way)))
3695 (if (/= 0 n) (message "No more newsgroups"))
3696 ;; !!! I don't know why the buffer scrolls forward when updating
3697 ;; the first line in the group buffer, but it does. So we set the
3698 ;; window start forcibly.
3699 (set-window-start (get-buffer-window (current-buffer)) w-p)
3702 (defun gnus-get-new-news-in-group (group)
3704 (gnus-activate-newsgroup group)
3706 (gnus-get-unread-articles-in-group
3707 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
3708 (gnus-gethash group gnus-active-hashtb))
3709 (gnus-group-update-group-line)
3712 (defun gnus-group-fetch-faq (group)
3713 "Fetch the FAQ for the current group."
3714 (interactive (list (gnus-group-group-name)))
3715 (or group (error "No group name given"))
3716 (let ((file (concat gnus-group-faq-directory group)))
3717 (if (not (file-exists-p file))
3718 (error "No such file: %s" file)
3721 (defun gnus-group-describe-group (force &optional group)
3722 "Display a description of the current newsgroup."
3724 (and force (setq gnus-description-hashtb nil))
3725 (let ((group (or group (gnus-group-group-name)))
3727 (or group (message "No group name given"))
3728 (and (or gnus-description-hashtb
3729 (setq desc (gnus-group-get-description group))
3730 (gnus-read-descriptions-file))
3732 (or desc (gnus-gethash group gnus-description-hashtb)
3733 "No description available")))))
3735 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3736 (defun gnus-group-describe-all-groups (force)
3737 "Pop up a buffer with descriptons of all newsgroups."
3739 (and force (setq gnus-description-hashtb nil))
3740 (if (not (or gnus-description-hashtb
3741 (gnus-read-descriptions-file)))
3742 (error "Couldn't request descriptions file"))
3743 (let ((buffer-read-only nil)
3749 (insert (format " *: %-20s %s\n" (symbol-name group)
3750 (symbol-value group)))
3751 (add-text-properties
3752 b (1+ b) (list 'gnus-group group
3753 'gnus-unread t 'gnus-marked nil 'gnus-level 6)))
3754 gnus-description-hashtb)
3755 (goto-char (point-min))
3756 (gnus-group-position-cursor)))
3758 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
3759 (defun gnus-group-apropos (regexp &optional search-description)
3760 "List all newsgroups that have names that match a regexp."
3761 (interactive "sGnus apropos (regexp): ")
3763 (obuf (current-buffer))
3765 ;; Go through all newsgroups that are known to Gnus.
3768 (and (string-match regexp (symbol-name group))
3769 (setq groups (cons (symbol-name group) groups))))
3771 ;; Go through all descriptions that are known to Gnus.
3772 (if search-description
3775 (and (string-match regexp (symbol-value group))
3776 (gnus-gethash (symbol-name group) gnus-active-hashtb)
3777 (setq groups (cons (symbol-name group) groups))))
3778 gnus-description-hashtb))
3780 (message "No groups matched \"%s\"." regexp)
3781 ;; Print out all the groups.
3783 (pop-to-buffer (get-buffer-create "*Gnus Help*"))
3784 (buffer-disable-undo (current-buffer))
3786 (setq groups (sort groups 'string<))
3788 ;; Groups may be entered twice into the list of groups.
3789 (if (not (string= (car groups) prev))
3791 (insert (setq prev (car groups)) "\n")
3792 (if (and gnus-description-hashtb
3793 (setq des (gnus-gethash (car groups)
3794 gnus-description-hashtb)))
3795 (insert " " des "\n"))))
3796 (setq groups (cdr groups)))
3798 (pop-to-buffer obuf)))
3800 (defun gnus-group-description-apropos (regexp)
3801 "List all newsgroups that have names or desccriptions that match a regexp."
3802 (interactive "sGnus description apropos (regexp): ")
3803 (if (not (or gnus-description-hashtb
3804 (gnus-read-descriptions-file)))
3805 (error "Couldn't request descriptions file"))
3806 (gnus-group-apropos regexp t))
3808 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3809 (defun gnus-group-list-matching (level regexp &optional all lowest)
3810 "List all groups with unread articles that match REGEXP.
3811 If the prefix LEVEL is non-nil, it should be a number that says which
3812 level to cut off listing groups.
3813 If ALL, also list groups with no unread articles.
3814 If LOWEST, don't list groups with level lower than LOWEST."
3815 (interactive "P\nsList newsgroups matching: ")
3816 (gnus-group-prepare-flat (or level 5) all (or lowest 1) regexp)
3817 (goto-char (point-min))
3818 (gnus-group-position-cursor))
3820 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3821 "List all groups that match REGEXP.
3822 If the prefix LEVEL is non-nil, it should be a number that says which
3823 level to cut off listing groups.
3824 If LOWEST, don't list groups with level lower than LOWEST."
3825 (interactive "P\nsList newsgroups matching: ")
3826 (gnus-group-list-matching (or level 9) regexp t lowest))
3828 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3829 (defun gnus-group-save-newsrc ()
3830 "Save the Gnus startup files."
3832 (gnus-save-newsrc-file))
3834 (defun gnus-group-restart (&optional arg)
3835 "Force Gnus to read the .newsrc file."
3837 (gnus-save-newsrc-file)
3838 (gnus-setup-news 'force)
3839 (gnus-group-list-groups (or arg 5) gnus-have-all-newsgroups))
3841 (defun gnus-group-read-init-file ()
3842 "Read the Gnus elisp init file."
3844 (gnus-read-init-file))
3846 (defun gnus-group-check-bogus-groups ()
3847 "Check bogus newsgroups."
3849 (gnus-check-bogus-newsgroups (not gnus-expert-user)) ;Require confirmation.
3850 (gnus-group-list-groups 5 gnus-have-all-newsgroups))
3852 (defun gnus-group-mail ()
3853 "Start composing a mail."
3857 (defun gnus-group-edit-global-kill (article &optional group)
3858 "Edit the global kill file.
3859 If GROUP, edit that local kill file instead."
3861 (setq gnus-current-kill-article article)
3862 (gnus-kill-file-edit-file group)
3864 (substitute-command-keys
3865 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
3867 (defun gnus-group-edit-local-kill (article group)
3868 "Edit a local kill file."
3869 (interactive (list nil (gnus-group-group-name)))
3870 (gnus-group-edit-global-kill article group))
3872 (defun gnus-group-force-update ()
3873 "Update `.newsrc' file."
3875 (gnus-save-newsrc-file))
3877 (defun gnus-group-suspend ()
3878 "Suspend the current Gnus session.
3879 In fact, cleanup buffers except for group mode buffer.
3880 The hook gnus-suspend-gnus-hook is called before actually suspending."
3882 (run-hooks 'gnus-suspend-gnus-hook)
3883 ;; Kill Gnus buffers except for group mode buffer.
3884 (let ((group-buf (get-buffer gnus-group-buffer)))
3885 (while gnus-buffer-list
3886 (and (not (eq (get-buffer (car gnus-buffer-list)) group-buf))
3887 (not (eq (get-buffer (car gnus-buffer-list)) gnus-dribble-buffer))
3888 (get-buffer (car gnus-buffer-list))
3889 (buffer-name (get-buffer (car gnus-buffer-list)))
3890 (kill-buffer (car gnus-buffer-list)))
3891 (setq gnus-buffer-list (cdr gnus-buffer-list)))
3892 (setq gnus-buffer-list (list group-buf))
3893 (bury-buffer group-buf)
3894 (delete-windows-on group-buf t)))
3896 (defun gnus-group-clear-dribble ()
3897 "Clear all information from the dribble buffer."
3899 (gnus-dribble-clear))
3901 (defun gnus-group-exit ()
3902 "Quit reading news after updating .newsrc.eld and .newsrc.
3903 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3905 (if (or noninteractive ;For gnus-batch-kill
3906 (zerop (buffer-size)) ;No news is good news.
3907 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
3908 (not gnus-interactive-exit) ;Without confirmation
3910 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3912 (run-hooks 'gnus-exit-gnus-hook)
3913 (gnus-save-newsrc-file)
3914 (gnus-close-backends)
3915 (gnus-clear-system))))
3917 (defun gnus-close-backends ()
3918 (let ((methods gnus-valid-select-methods)
3921 (if (fboundp (setq func (intern (concat (car (car methods))
3922 "-request-close"))))
3924 (setq methods (cdr methods)))))
3926 (defun gnus-group-quit ()
3927 "Quit reading news without updating .newsrc.eld or .newsrc.
3928 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3930 (if (or noninteractive ;For gnus-batch-kill
3931 (zerop (buffer-size))
3932 (not (gnus-server-opened gnus-select-method))
3934 (not gnus-current-startup-file)
3936 (format "Quit reading news without saving %s? "
3937 (file-name-nondirectory gnus-current-startup-file))))
3939 (run-hooks 'gnus-exit-gnus-hook)
3941 (gnus-close-backends)
3942 (gnus-clear-system))))
3944 (defun gnus-group-describe-briefly ()
3945 "Give a one line description of the group mode commands."
3948 (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")))
3950 (defun gnus-group-browse-foreign-server (method)
3951 "Browse a foreign news server.
3952 If called interactively, this function will ask for a select method
3953 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3954 If not, METHOD should be a list where the first element is the method
3955 and the second element is the address."
3957 (list (list (intern (completing-read
3959 gnus-valid-select-methods nil t "nntp"))
3960 ;; Suggested by mapjph@bath.ac.uk.
3963 (mapcar (lambda (server) (list server))
3964 gnus-secondary-servers)))))
3965 (gnus-browse-foreign-server method))
3969 ;;; Browse Server Mode
3972 (defvar gnus-browse-server-mode-hook nil)
3973 (defvar gnus-browse-server-mode-map nil)
3975 (if gnus-browse-server-mode-map
3977 (setq gnus-browse-server-mode-map (make-keymap))
3978 (suppress-keymap gnus-browse-server-mode-map)
3979 (define-key gnus-browse-server-mode-map " " 'gnus-browse-read-group)
3980 (define-key gnus-browse-server-mode-map "=" 'gnus-browse-read-group)
3981 (define-key gnus-browse-server-mode-map "n" 'gnus-browse-next-group)
3982 (define-key gnus-browse-server-mode-map "p" 'gnus-browse-prev-group)
3983 (define-key gnus-browse-server-mode-map "\177" 'gnus-browse-prev-group)
3984 (define-key gnus-browse-server-mode-map "N" 'gnus-browse-next-group)
3985 (define-key gnus-browse-server-mode-map "P" 'gnus-browse-prev-group)
3986 (define-key gnus-browse-server-mode-map "\M-n" 'gnus-browse-next-group)
3987 (define-key gnus-browse-server-mode-map "\M-p" 'gnus-browse-prev-group)
3988 (define-key gnus-browse-server-mode-map "\r" 'gnus-browse-read-group)
3989 (define-key gnus-browse-server-mode-map "u" 'gnus-browse-unsubscribe-current-group)
3990 (define-key gnus-browse-server-mode-map "q" 'gnus-browse-exit)
3991 (define-key gnus-browse-server-mode-map "Q" 'gnus-browse-exit)
3992 (define-key gnus-browse-server-mode-map "\C-c\C-c" 'gnus-browse-exit)
3993 (define-key gnus-browse-server-mode-map "?" 'gnus-browse-describe-briefly)
3994 (define-key gnus-browse-server-mode-map "\C-c\C-i" 'gnus-info-find-node)
3997 (defvar gnus-browse-current-method nil)
3999 (defun gnus-browse-foreign-server (method)
4000 (setq gnus-browse-current-method method)
4001 (let ((gnus-select-method method)
4003 (message "Connecting to %s..." (nth 1 method))
4004 (if (not (gnus-request-list method))
4005 (error "Unable to contact server: " (gnus-status-message method)))
4006 (set-buffer (get-buffer-create "*Gnus Browse Server*"))
4007 (gnus-add-current-to-buffer-list)
4008 (buffer-disable-undo (current-buffer))
4009 (let ((buffer-read-only nil))
4011 (gnus-browse-server-mode)
4012 (setq mode-line-buffer-identification
4014 "(ding) Browse Server {%s:%s}" (car method) (car (cdr method))))
4016 (set-buffer nntp-server-buffer)
4017 (let ((cur (current-buffer)))
4019 (delete-matching-lines gnus-ignored-newsgroups)
4020 (while (re-search-forward
4021 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
4022 (goto-char (match-end 1))
4023 (setq groups (cons (cons (buffer-substring (match-beginning 1)
4025 (- (read cur) (read cur)))
4027 (setq groups (sort groups
4029 (string< (car l1) (car l2)))))
4030 (let ((buffer-read-only nil))
4032 (setq group (car groups))
4034 (format "K%7d: %s\n" (cdr group) (car group)))
4035 (setq groups (cdr groups))))
4036 (switch-to-buffer (current-buffer))
4038 (gnus-group-position-cursor)))
4040 (defun gnus-browse-server-mode ()
4041 "Major mode for browsing a foreign server."
4043 (kill-all-local-variables)
4044 (setq mode-line-modified "-- ")
4045 (make-local-variable 'mode-line-format)
4046 (setq mode-line-format (copy-sequence mode-line-format))
4047 (and (equal (nth 3 mode-line-format) " ")
4048 (setcar (nthcdr 3 mode-line-format) ""))
4049 (setq major-mode 'gnus-browse-server-mode)
4050 (setq mode-name "Browse Server")
4051 (setq mode-line-process nil)
4052 (use-local-map gnus-browse-server-mode-map)
4053 (buffer-disable-undo (current-buffer))
4054 (setq truncate-lines t)
4055 (setq buffer-read-only t)
4056 (run-hooks 'gnus-browse-server-mode-hook))
4058 (defun gnus-browse-read-group ()
4059 "Not implemented, and will probably never be."
4061 (error "You can't read while browsing"))
4063 (defun gnus-browse-next-group (n)
4064 "Go to the next group."
4068 (gnus-group-position-cursor)))
4070 (defun gnus-browse-prev-group (n)
4071 "Go to the next group."
4073 (gnus-browse-next-group (- n)))
4075 (defun gnus-browse-unsubscribe-current-group (arg)
4076 "(Un)subscribe to the next ARG groups."
4079 (error "No group at current line."))
4080 (let ((ward (if (< arg 0) -1 1))
4082 (while (and (> arg 0)
4084 (gnus-browse-unsubscribe-group)
4085 (zerop (gnus-browse-next-group ward)))
4086 (setq arg (1- arg)))
4087 (gnus-group-position-cursor)
4088 (if (/= 0 arg) (message "No more newsgroups"))
4091 (defun gnus-browse-unsubscribe-group ()
4093 (buffer-read-only nil)
4097 (if (= (following-char) ?K) (setq sub t))
4098 (re-search-forward ": \\(.*\\)$" nil t)
4099 (setq group (gnus-group-prefixed-name
4100 (buffer-substring (match-beginning 1) (match-end 1))
4101 gnus-browse-current-method))
4106 (gnus-group-change-level
4107 (list t group 3 nil nil gnus-browse-current-method) 3 9
4108 (gnus-gethash (car (nth 1 gnus-newsrc-assoc)) gnus-newsrc-hashtb)
4111 (gnus-group-change-level group 9 3)
4115 (defun gnus-browse-exit ()
4116 "Quit browsing and return to the group buffer."
4118 (if (eq major-mode 'gnus-browse-server-mode)
4119 (kill-buffer (current-buffer)))
4120 (switch-to-buffer gnus-group-buffer)
4121 (gnus-group-list-groups 5))
4123 (defun gnus-browse-describe-briefly ()
4124 "Give a one line description of the group mode commands."
4127 (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")))
4131 ;;; Gnus summary mode
4134 (defvar gnus-summary-mode-map nil)
4135 (defvar gnus-summary-mark-map nil)
4136 (defvar gnus-summary-mscore-map nil)
4137 (defvar gnus-summary-send-map nil)
4138 (defvar gnus-summary-extract-map nil)
4139 (defvar gnus-summary-extract-view-map nil)
4140 (defvar gnus-summary-article-map nil)
4141 (defvar gnus-summary-thread-map nil)
4142 (defvar gnus-summary-goto-map nil)
4143 (defvar gnus-summary-exit-map nil)
4144 (defvar gnus-summary-various-map nil)
4145 (defvar gnus-summary-interest-map nil)
4146 (defvar gnus-summary-process-map nil)
4147 (defvar gnus-summary-score-map nil)
4148 (defvar gnus-summary-sort-map nil)
4149 (defvar gnus-summary-mgroup-map nil)
4150 (defvar gnus-summary-vsave-map nil)
4151 (defvar gnus-summary-increase-map nil)
4152 (defvar gnus-summary-inc-subject-map nil)
4153 (defvar gnus-summary-inc-author-map nil)
4154 (defvar gnus-summary-inc-id-map nil)
4155 (defvar gnus-summary-inc-xref-map nil)
4156 (defvar gnus-summary-inc-thread-map nil)
4157 (defvar gnus-summary-inc-fol-map nil)
4158 (defvar gnus-summary-lower-map nil)
4159 (defvar gnus-summary-low-subject-map nil)
4160 (defvar gnus-summary-low-author-map nil)
4161 (defvar gnus-summary-low-id-map nil)
4162 (defvar gnus-summary-low-xref-map nil)
4163 (defvar gnus-summary-low-thread-map nil)
4164 (defvar gnus-summary-low-fol-map nil)
4166 (if gnus-summary-mode-map
4168 (setq gnus-summary-mode-map (make-keymap))
4169 (suppress-keymap gnus-summary-mode-map)
4171 ;; Non-orthogonal keys
4173 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
4174 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
4175 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
4176 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
4177 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
4178 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
4179 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
4180 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
4181 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
4182 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
4183 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
4184 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
4185 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
4186 (define-key gnus-summary-mode-map "\M-s" 'gnus-summary-search-article-forward)
4187 (define-key gnus-summary-mode-map "\M-r" 'gnus-summary-search-article-backward)
4188 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
4189 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
4190 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
4191 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
4192 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
4193 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
4194 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
4195 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
4196 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
4197 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
4198 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
4199 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
4200 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
4201 (define-key gnus-summary-mode-map "k" 'gnus-summary-kill-same-subject-and-select)
4202 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
4203 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
4204 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
4205 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
4206 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
4207 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
4208 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
4209 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
4210 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
4211 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
4212 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
4213 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
4214 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
4215 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
4216 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
4217 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
4218 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
4219 (define-key gnus-summary-mode-map "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
4220 (define-key gnus-summary-mode-map "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
4221 (define-key gnus-summary-mode-map "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
4222 (define-key gnus-summary-mode-map "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
4223 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
4224 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
4225 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
4226 (define-key gnus-summary-mode-map "\C-x\C-s" 'gnus-summary-reselect-current-group)
4227 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
4228 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
4229 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
4230 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
4231 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
4232 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
4233 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
4234 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
4235 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
4236 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
4237 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
4238 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
4239 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
4240 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
4241 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
4242 (define-key gnus-summary-mode-map "V" 'gnus-version)
4243 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
4244 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
4245 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
4246 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
4247 (define-key gnus-summary-mode-map [mouse-2] 'gnus-mouse-pick-article)
4248 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
4249 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
4250 (define-key gnus-summary-mode-map "x" 'gnus-summary-delete-marked-as-read)
4251 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
4252 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
4253 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
4254 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
4255 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
4256 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
4257 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu)
4258 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
4261 ;; Sort of orthogonal keymap
4262 (define-prefix-command 'gnus-summary-mark-map)
4263 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
4264 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
4265 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
4266 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
4267 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
4268 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
4269 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
4270 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
4271 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
4272 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
4273 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
4274 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
4275 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
4276 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
4277 (define-key gnus-summary-mark-map "\M-r" 'gnus-summary-remove-lines-marked-as-read)
4278 (define-key gnus-summary-mark-map "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
4279 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
4280 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
4281 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
4282 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
4283 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
4284 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
4285 (define-key gnus-summary-mark-map "k" 'gnus-summary-kill-same-subject-and-select)
4286 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
4288 (define-prefix-command 'gnus-summary-mscore-map)
4289 (define-key gnus-summary-mark-map "s" 'gnus-summary-mscore-map)
4290 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
4291 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
4292 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
4293 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
4295 (define-prefix-command 'gnus-summary-process-map)
4296 (define-key gnus-summary-mark-map "p" 'gnus-summary-process-map)
4297 (define-key gnus-summary-process-map "p" 'gnus-summary-mark-as-processable)
4298 (define-key gnus-summary-process-map "u" 'gnus-summary-unmark-as-processable)
4299 (define-key gnus-summary-process-map "U" 'gnus-summary-unmark-all-processable)
4300 (define-key gnus-summary-process-map "s" 'gnus-uu-mark-series)
4301 (define-key gnus-summary-process-map "r" 'gnus-uu-mark-region)
4302 (define-key gnus-summary-process-map "R" 'gnus-uu-mark-by-regexp)
4303 (define-key gnus-summary-process-map "t" 'gnus-uu-mark-thread)
4304 (define-key gnus-summary-process-map "a" 'gnus-uu-mark-all)
4305 (define-key gnus-summary-process-map "S" 'gnus-uu-mark-sparse)
4308 (define-prefix-command 'gnus-summary-send-map)
4309 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
4310 (define-key gnus-summary-send-map "p" 'gnus-summary-post-news)
4311 (define-key gnus-summary-send-map "f" 'gnus-summary-followup)
4312 (define-key gnus-summary-send-map "F" 'gnus-summary-followup-with-original)
4313 (define-key gnus-summary-send-map "b" 'gnus-summary-followup-and-reply)
4314 (define-key gnus-summary-send-map "B" 'gnus-summary-followup-and-reply-with-original)
4315 (define-key gnus-summary-send-map "c" 'gnus-summary-cancel-article)
4316 (define-key gnus-summary-send-map "s" 'gnus-summary-supersede-article)
4317 (define-key gnus-summary-send-map "r" 'gnus-summary-reply)
4318 (define-key gnus-summary-send-map "R" 'gnus-summary-reply-with-original)
4319 (define-key gnus-summary-send-map "\C-f" 'gnus-summary-mail-forward)
4320 (define-key gnus-summary-send-map "m" 'gnus-summary-mail-other-window)
4321 (define-key gnus-summary-send-map "u" 'gnus-uu-post-news)
4322 (define-key gnus-summary-send-map "\M-f" 'gnus-uu-digest-and-forward)
4325 (define-prefix-command 'gnus-summary-goto-map)
4326 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
4327 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
4328 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
4329 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
4330 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
4331 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
4332 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
4333 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
4334 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
4335 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
4336 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
4337 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
4338 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
4339 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
4342 (define-prefix-command 'gnus-summary-thread-map)
4343 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
4344 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
4345 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
4346 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
4347 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
4348 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
4349 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
4350 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
4351 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
4352 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
4353 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
4354 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
4355 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
4356 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
4359 (define-prefix-command 'gnus-summary-exit-map)
4360 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
4361 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
4362 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
4363 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
4364 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
4365 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
4368 (define-prefix-command 'gnus-summary-article-map)
4369 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
4370 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
4371 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
4372 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
4373 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
4374 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
4375 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
4376 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
4377 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
4378 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
4379 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
4380 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
4381 (define-key gnus-summary-article-map "w" 'gnus-summary-stop-page-breaking)
4382 (define-key gnus-summary-article-map "c" 'gnus-summary-caesar-message)
4383 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
4384 (define-key gnus-summary-article-map "t" 'gnus-summary-toggle-header)
4385 (define-key gnus-summary-article-map "hh" 'gnus-article-hide-headers)
4386 (define-key gnus-summary-article-map "hs" 'gnus-article-hide-signature)
4387 (define-key gnus-summary-article-map "hc" 'gnus-article-hide-citation)
4388 (define-key gnus-summary-article-map "ho" 'gnus-article-treat-overstrike)
4389 (define-key gnus-summary-article-map "hw" 'gnus-article-word-wrap)
4390 (define-key gnus-summary-article-map "hd" 'gnus-article-remove-cr)
4391 (define-key gnus-summary-article-map "hq" 'gnus-article-de-quoted-unreadable)
4392 (define-key gnus-summary-article-map "m" 'gnus-summary-toggle-mime)
4393 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
4396 (define-prefix-command 'gnus-summary-extract-map)
4397 (define-key gnus-summary-mode-map "X" 'gnus-summary-extract-map)
4398 ; (define-key gnus-summary-extract-map "x" 'gnus-summary-extract-any)
4399 ; (define-key gnus-summary-extract-map "m" 'gnus-summary-extract-mime)
4400 (define-key gnus-summary-extract-map "u" 'gnus-uu-decode-uu)
4401 (define-key gnus-summary-extract-map "U" 'gnus-uu-decode-uu-and-save)
4402 (define-key gnus-summary-extract-map "s" 'gnus-uu-decode-unshar)
4403 (define-key gnus-summary-extract-map "S" 'gnus-uu-decode-unshar-and-save)
4404 (define-key gnus-summary-extract-map "o" 'gnus-uu-decode-save)
4405 (define-key gnus-summary-extract-map "O" 'gnus-uu-decode-save)
4406 (define-key gnus-summary-extract-map "b" 'gnus-uu-decode-binhex)
4407 (define-key gnus-summary-extract-map "B" 'gnus-uu-decode-binhex)
4409 (define-prefix-command 'gnus-summary-extract-view-map)
4410 (define-key gnus-summary-extract-map "v" 'gnus-summary-extract-view-map)
4411 (define-key gnus-summary-extract-view-map "u" 'gnus-uu-decode-uu-view)
4412 (define-key gnus-summary-extract-view-map "U" 'gnus-uu-decode-uu-and-save-view)
4413 (define-key gnus-summary-extract-view-map "s" 'gnus-uu-decode-unshar-view)
4414 (define-key gnus-summary-extract-view-map "S" 'gnus-uu-decode-unshar-and-save-view)
4415 (define-key gnus-summary-extract-view-map "o" 'gnus-uu-decode-save-view)
4416 (define-key gnus-summary-extract-view-map "O" 'gnus-uu-decode-save-view)
4417 (define-key gnus-summary-extract-view-map "b" 'gnus-uu-decode-binhex-view)
4418 (define-key gnus-summary-extract-view-map "B" 'gnus-uu-decode-binhex-view)
4421 (define-prefix-command 'gnus-summary-various-map)
4422 (define-key gnus-summary-mode-map "V" 'gnus-summary-various-map)
4423 (define-key gnus-summary-various-map "u" 'gnus-summary-universal-argument)
4424 (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
4425 (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
4426 (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
4427 (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
4428 (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
4429 (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
4430 (define-key gnus-summary-various-map "S" 'gnus-summary-reselect-current-group)
4431 (define-key gnus-summary-various-map "g" 'gnus-summary-rescan-group)
4432 (define-key gnus-summary-various-map "V" 'gnus-version)
4433 (define-key gnus-summary-various-map "f" 'gnus-summary-fetch-faq)
4434 (define-key gnus-summary-various-map "d" 'gnus-summary-describe-group)
4435 (define-key gnus-summary-various-map "?" 'gnus-summary-describe-briefly)
4436 (define-key gnus-summary-various-map "i" 'gnus-info-find-node)
4437 (define-key gnus-summary-various-map "D" 'gnus-summary-enter-digest-group)
4438 (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
4439 (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
4441 (define-prefix-command 'gnus-summary-vsave-map)
4442 (define-key gnus-summary-various-map "o" 'gnus-summary-vsave-map)
4443 (define-key gnus-summary-vsave-map "o" 'gnus-summary-save-article)
4444 (define-key gnus-summary-vsave-map "m" 'gnus-summary-save-article-mail)
4445 (define-key gnus-summary-vsave-map "r" 'gnus-summary-save-article-rmail)
4446 (define-key gnus-summary-vsave-map "f" 'gnus-summary-save-article-file)
4447 (define-key gnus-summary-vsave-map "h" 'gnus-summary-save-article-folder)
4448 (define-key gnus-summary-vsave-map "p" 'gnus-summary-pipe-output)
4450 (define-prefix-command 'gnus-summary-score-map)
4451 (define-key gnus-summary-various-map "S" 'gnus-summary-score-map)
4452 (define-key gnus-summary-score-map "s" 'gnus-summary-set-score)
4453 (define-key gnus-summary-score-map "c" 'gnus-score-change-score-file)
4454 (define-key gnus-summary-score-map "m" 'gnus-score-set-mark-below)
4455 (define-key gnus-summary-score-map "x" 'gnus-score-set-expunge-below)
4456 (define-key gnus-summary-score-map "e" 'gnus-score-edit-alist)
4457 (define-key gnus-summary-score-map "f" 'gnus-score-edit-file)
4459 (define-prefix-command 'gnus-summary-sort-map)
4460 (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
4461 (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
4462 (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
4463 (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
4464 (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
4465 (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
4467 (define-prefix-command 'gnus-summary-mgroup-map)
4468 (define-key gnus-summary-various-map "m" 'gnus-summary-mgroup-map)
4469 (define-key gnus-summary-mgroup-map "e" 'gnus-summary-expire-articles)
4470 (define-key gnus-summary-mgroup-map "\177" 'gnus-summary-delete-article)
4471 (define-key gnus-summary-mgroup-map "m" 'gnus-summary-move-article)
4472 (define-key gnus-summary-mgroup-map "r" 'gnus-summary-respool-article)
4473 (define-key gnus-summary-mgroup-map "w" 'gnus-summary-edit-article)
4474 (define-key gnus-summary-mgroup-map "c" 'gnus-summary-copy-article)
4477 (define-prefix-command 'gnus-summary-increase-map)
4478 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-map)
4479 (define-key gnus-summary-increase-map "i" 'gnus-summary-raise-same-subject-and-select)
4480 (define-key gnus-summary-increase-map "I" 'gnus-summary-raise-same-subject)
4481 (define-key gnus-summary-increase-map "\C-i" 'gnus-summary-raise-score)
4483 (define-prefix-command 'gnus-summary-inc-subject-map)
4484 (define-key gnus-summary-increase-map "s" 'gnus-summary-inc-subject-map)
4485 (define-key gnus-summary-increase-map "S" 'gnus-summary-temporarily-raise-by-subject)
4486 (define-key gnus-summary-inc-subject-map "s" 'gnus-summary-temporarily-raise-by-subject)
4487 (define-key gnus-summary-inc-subject-map "S" 'gnus-summary-raise-by-subject)
4488 (define-key gnus-summary-inc-subject-map "t" 'gnus-summary-temporarily-raise-by-subject)
4489 (define-key gnus-summary-inc-subject-map "p" 'gnus-summary-raise-by-subject)
4491 (define-prefix-command 'gnus-summary-inc-author-map)
4492 (define-key gnus-summary-increase-map "a" 'gnus-summary-inc-author-map)
4493 (define-key gnus-summary-increase-map "A" 'gnus-summary-temporarily-raise-by-author)
4494 (define-key gnus-summary-inc-author-map "a" 'gnus-summary-temporarily-raise-by-author)
4495 (define-key gnus-summary-inc-author-map "A" 'gnus-summary-raise-by-author)
4496 (define-key gnus-summary-inc-author-map "t" 'gnus-summary-temporarily-raise-by-author)
4497 (define-key gnus-summary-inc-author-map "p" 'gnus-summary-raise-by-author)
4499 (define-prefix-command 'gnus-summary-inc-id-map)
4500 (define-key gnus-summary-increase-map "i" 'gnus-summary-inc-id-map)
4501 (define-key gnus-summary-increase-map "I" 'gnus-summary-temporarily-raise-by-id)
4502 (define-key gnus-summary-inc-id-map "i" 'gnus-summary-temporarily-raise-by-id)
4503 (define-key gnus-summary-inc-id-map "I" 'gnus-summary-raise-by-id)
4504 (define-key gnus-summary-inc-id-map "t" 'gnus-summary-temporarily-raise-by-id)
4505 (define-key gnus-summary-inc-id-map "p" 'gnus-summary-raise-by-id)
4507 (define-prefix-command 'gnus-summary-inc-thread-map)
4508 (define-key gnus-summary-increase-map "t" 'gnus-summary-inc-thread-map)
4509 (define-key gnus-summary-increase-map "T" 'gnus-summary-temporarily-raise-by-thread)
4510 (define-key gnus-summary-inc-thread-map "t" 'gnus-summary-temporarily-raise-by-thread)
4511 (define-key gnus-summary-inc-thread-map "T" 'gnus-summary-raise-by-thread)
4512 (define-key gnus-summary-inc-thread-map "t" 'gnus-summary-temporarily-raise-by-thread)
4513 (define-key gnus-summary-inc-thread-map "p" 'gnus-summary-raise-by-thread)
4515 (define-prefix-command 'gnus-summary-inc-xref-map)
4516 (define-key gnus-summary-increase-map "x" 'gnus-summary-inc-xref-map)
4517 (define-key gnus-summary-increase-map "X" 'gnus-summary-temporarily-raise-by-xref)
4518 (define-key gnus-summary-inc-xref-map "x" 'gnus-summary-temporarily-raise-by-xref)
4519 (define-key gnus-summary-inc-xref-map "X" 'gnus-summary-raise-by-xref)
4520 (define-key gnus-summary-inc-xref-map "t" 'gnus-summary-temporarily-raise-by-xref)
4521 (define-key gnus-summary-inc-xref-map "p" 'gnus-summary-raise-by-xref)
4523 (define-prefix-command 'gnus-summary-inc-fol-map)
4524 (define-key gnus-summary-increase-map "f" 'gnus-summary-inc-fol-map)
4525 (define-key gnus-summary-increase-map "F" 'gnus-summary-raise-followups-to-author)
4526 (define-key gnus-summary-inc-fol-map "f" 'gnus-summary-raise-followups-to-author)
4527 (define-key gnus-summary-inc-fol-map "F" 'gnus-summary-raise-followups-to-author)
4528 (define-key gnus-summary-inc-fol-map "t" 'gnus-summary-raise-followups-to-author)
4529 (define-key gnus-summary-inc-fol-map "p" 'gnus-summary-raise-followups-to-author)
4531 (define-prefix-command 'gnus-summary-lower-map)
4532 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-map)
4533 (define-key gnus-summary-lower-map "l" 'gnus-summary-lower-same-subject-and-select)
4534 (define-key gnus-summary-lower-map "L" 'gnus-summary-lower-same-subject)
4535 (define-key gnus-summary-lower-map "\C-l" 'gnus-summary-lower-score)
4537 (define-prefix-command 'gnus-summary-low-subject-map)
4538 (define-key gnus-summary-lower-map "s" 'gnus-summary-low-subject-map)
4539 (define-key gnus-summary-lower-map "S" 'gnus-summary-temporarily-lower-by-subject)
4540 (define-key gnus-summary-low-subject-map "s" 'gnus-summary-temporarily-lower-by-subject)
4541 (define-key gnus-summary-low-subject-map "S" 'gnus-summary-lower-by-subject)
4542 (define-key gnus-summary-low-subject-map "t" 'gnus-summary-temporarily-lower-by-subject)
4543 (define-key gnus-summary-low-subject-map "p" 'gnus-summary-lower-by-subject)
4545 (define-prefix-command 'gnus-summary-low-author-map)
4546 (define-key gnus-summary-lower-map "a" 'gnus-summary-low-author-map)
4547 (define-key gnus-summary-lower-map "A" 'gnus-summary-temporarily-lower-by-author)
4548 (define-key gnus-summary-low-author-map "a" 'gnus-summary-temporarily-lower-by-author)
4549 (define-key gnus-summary-low-author-map "A" 'gnus-summary-lower-by-author)
4550 (define-key gnus-summary-low-author-map "t" 'gnus-summary-temporarily-lower-by-author)
4551 (define-key gnus-summary-low-author-map "p" 'gnus-summary-lower-by-author)
4553 (define-prefix-command 'gnus-summary-low-id-map)
4554 (define-key gnus-summary-lower-map "i" 'gnus-summary-low-id-map)
4555 (define-key gnus-summary-lower-map "I" 'gnus-summary-temporarily-lower-by-id)
4556 (define-key gnus-summary-low-id-map "i" 'gnus-summary-temporarily-lower-by-id)
4557 (define-key gnus-summary-low-id-map "I" 'gnus-summary-lower-by-id)
4558 (define-key gnus-summary-low-id-map "t" 'gnus-summary-temporarily-lower-by-id)
4559 (define-key gnus-summary-low-id-map "p" 'gnus-summary-lower-by-id)
4561 (define-prefix-command 'gnus-summary-low-thread-map)
4562 (define-key gnus-summary-lower-map "t" 'gnus-summary-low-thread-map)
4563 (define-key gnus-summary-lower-map "T" 'gnus-summary-temporarily-lower-by-thread)
4564 (define-key gnus-summary-low-thread-map "t" 'gnus-summary-temporarily-lower-by-thread)
4565 (define-key gnus-summary-low-thread-map "T" 'gnus-summary-lower-by-thread)
4566 (define-key gnus-summary-low-thread-map "t" 'gnus-summary-temporarily-lower-by-thread)
4567 (define-key gnus-summary-low-thread-map "p" 'gnus-summary-lower-by-thread)
4569 (define-prefix-command 'gnus-summary-low-xref-map)
4570 (define-key gnus-summary-lower-map "x" 'gnus-summary-low-xref-map)
4571 (define-key gnus-summary-lower-map "X" 'gnus-summary-temporarily-lower-by-xref)
4572 (define-key gnus-summary-low-xref-map "x" 'gnus-summary-temporarily-lower-by-xref)
4573 (define-key gnus-summary-low-xref-map "X" 'gnus-summary-lower-by-xref)
4574 (define-key gnus-summary-low-xref-map "t" 'gnus-summary-temporarily-lower-by-xref)
4575 (define-key gnus-summary-low-xref-map "p" 'gnus-summary-lower-by-xref)
4577 (define-prefix-command 'gnus-summary-low-fol-map)
4578 (define-key gnus-summary-lower-map "f" 'gnus-summary-low-fol-map)
4579 (define-key gnus-summary-lower-map "F" 'gnus-summary-lower-followups-to-author)
4580 (define-key gnus-summary-low-fol-map "f" 'gnus-summary-lower-followups-to-author)
4581 (define-key gnus-summary-low-fol-map "F" 'gnus-summary-lower-followups-to-author)
4582 (define-key gnus-summary-low-fol-map "t" 'gnus-summary-lower-followups-to-author)
4583 (define-key gnus-summary-low-fol-map "p" 'gnus-summary-lower-followups-to-author)
4589 (defun gnus-summary-mode ()
4590 "Major mode for reading articles.
4592 All normal editing commands are switched off.
4593 \\<gnus-summary-mode-map>
4594 Each line in this buffer represents one article. To read an
4595 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
4596 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
4599 You can also post articles and send mail from this buffer. To
4600 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
4601 of an article, type `\\[gnus-summary-reply]'.
4603 There are approx. one gazillion commands you can execute in this
4604 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
4606 The following commands are available:
4608 \\{gnus-summary-mode-map}"
4610 (if gnus-visual (gnus-summary-make-menu-bar))
4611 (kill-all-local-variables)
4612 (let ((locals gnus-summary-local-variables))
4614 (if (consp (car locals))
4616 (make-local-variable (car (car locals)))
4617 (set (car (car locals)) (eval (cdr (car locals)))))
4618 (make-local-variable (car locals))
4619 (set (car locals) nil))
4620 (setq locals (cdr locals))))
4621 (gnus-update-format-specifications)
4622 (setq mode-line-modified "-- ")
4623 (make-local-variable 'mode-line-format)
4624 (setq mode-line-format (copy-sequence mode-line-format))
4625 (and (equal (nth 3 mode-line-format) " ")
4626 (setcar (nthcdr 3 mode-line-format) ""))
4627 (setq major-mode 'gnus-summary-mode)
4628 (setq mode-name "Summary")
4629 (make-local-variable 'minor-mode-alist)
4630 (gnus-set-mode-line 'summary)
4631 (use-local-map gnus-summary-mode-map)
4632 (buffer-disable-undo (current-buffer))
4633 (setq buffer-read-only t) ;Disable modification
4634 (setq truncate-lines t)
4635 (setq selective-display t)
4636 (setq selective-display-ellipses t) ;Display `...'
4637 (run-hooks 'gnus-summary-mode-hook))
4639 (defun gnus-summary-clear-local-variables ()
4640 (let ((locals gnus-summary-local-variables))
4642 (if (consp (car locals))
4643 (set (car (car locals)) nil)
4644 (set (car locals) nil))
4645 (setq locals (cdr locals)))))
4647 (defun gnus-mouse-pick-article (e)
4650 (gnus-summary-next-page nil t))
4652 (defun gnus-summary-setup-buffer (group)
4653 "Initialize summary buffer."
4654 (let ((buffer (concat "*Summary " group "*")))
4655 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
4656 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
4657 (gnus-add-current-to-buffer-list)
4658 (gnus-summary-mode)))
4660 (defun gnus-set-global-variables ()
4661 ;; Set the global equivalents of the summary buffer-local variables
4662 ;; to the latest values they had. These reflect the summary buffer
4663 ;; that was in action when the last article was fetched.
4664 (if (eq major-mode 'gnus-summary-mode)
4666 (setq gnus-summary-buffer (current-buffer))
4667 (let ((name gnus-newsgroup-name)
4668 (marked gnus-newsgroup-marked)
4669 (unread gnus-newsgroup-unreads)
4670 (headers gnus-current-headers))
4672 (set-buffer gnus-group-buffer)
4673 (setq gnus-newsgroup-name name)
4674 (setq gnus-newsgroup-marked marked)
4675 (setq gnus-newsgroup-unreads unread)
4676 (setq gnus-current-headers headers))))))
4678 (defun gnus-summary-insert-dummy-line (sformat subject number)
4680 (setq sformat gnus-summary-dummy-line-format-spec))
4684 (insert (eval sformat))
4685 (add-text-properties
4687 (list 'gnus-subject (gnus-simplify-subject-re subject)
4692 (defun gnus-summary-insert-line
4693 (sformat header level current unread replied expirable subject-or-nil
4694 &optional dummy score)
4695 (or sformat (setq sformat gnus-summary-line-format-spec))
4697 (make-string (* level gnus-thread-indent-level) ? ))
4698 (lines (or (header-lines header) 0))
4699 (score (or score gnus-summary-default-score 0))
4700 (score-char (if (or (null gnus-summary-default-score)
4701 (= score gnus-summary-default-score)) ?
4702 (if (< score gnus-summary-default-score)
4703 gnus-score-below-mark gnus-score-over-mark)))
4704 (replied (if replied gnus-replied-mark ? ))
4705 (from (header-from header))
4706 (name-address (funcall gnus-extract-address-components from))
4707 (address (car (cdr name-address)))
4708 (name (or (car name-address) (car (cdr name-address))))
4709 (number (header-number header))
4710 (subject (header-subject header))
4711 (buffer-read-only nil)
4712 (opening-bracket (if dummy ?\< ?\[))
4713 (closing-bracket (if dummy ?\> ?\]))
4715 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
4716 (if (not (numberp lines)) (setq lines 0))
4719 (insert (eval sformat))
4720 (add-text-properties
4722 (list 'gnus-subject (gnus-simplify-subject-re subject)
4724 'gnus-mark (or unread gnus-unread-mark ? )
4725 'gnus-thread level))))
4727 (defun gnus-summary-update-line (&optional dont-update)
4728 ;; Update summary line after change.
4729 (or (not gnus-summary-default-score)
4730 gnus-summary-inhibit-highlight
4731 (let ((gnus-summary-inhibit-highlight t))
4734 (if (and gnus-summary-mark-below
4735 (< (gnus-summary-article-score)
4736 gnus-summary-mark-below))
4737 (and (not (memq (gnus-summary-article-number)
4738 gnus-newsgroup-marked))
4739 (gnus-summary-mark-article nil gnus-low-score-mark))
4740 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
4741 (gnus-summary-mark-article nil gnus-unread-mark))))
4743 (run-hooks 'gnus-visual-summary-update-hook))))))
4745 (defun gnus-summary-update-lines ()
4746 ;; Rehighlight summary buffer according to `gnus-summary-highlight'.
4747 (and (save-excursion
4748 (set-buffer gnus-summary-buffer)
4749 (goto-char (point-min))
4751 (gnus-summary-update-line)
4752 (forward-line 1)))))
4754 (defun gnus-summary-read-group (group &optional show-all no-article kill-buffer)
4755 "Start reading news in newsgroup GROUP.
4756 If SHOW-ALL is non-nil, already read articles are also listed.
4757 If NO-ARTICLE is non-nil, no article is selected initially."
4758 (message "Retrieving newsgroup: %s..." group)
4759 (gnus-summary-setup-buffer group)
4760 (if (gnus-select-newsgroup group show-all)
4762 ;; You can change the subjects in this hook.
4763 (run-hooks 'gnus-select-group-hook)
4764 ;; Do Score Processing.
4765 (gnus-score-headers)
4766 ;; Update the format specifiers.
4767 (gnus-update-format-specifications)
4768 (gnus-summary-prepare)
4769 (if (and (zerop (buffer-size))
4770 gnus-newsgroup-dormant)
4771 (gnus-summary-show-all-dormant))
4772 (gnus-set-global-variables)
4773 ;; Function `gnus-apply-kill-file' must be called in this hook.
4774 (run-hooks 'gnus-apply-kill-hook)
4775 (if (zerop (buffer-size))
4777 ;; This newsgroup is empty.
4778 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
4779 (message "No unread news"))
4782 (let ((gnus-summary-buffer kill-buffer))
4783 (gnus-configure-windows 'newsgroups t))))
4784 ;; Hide conversation thread subtrees. We cannot do this in
4785 ;; gnus-summary-prepare-hook since kill processing may not
4786 ;; work with hidden articles.
4787 (and gnus-show-threads
4788 gnus-thread-hide-subtree
4789 (gnus-summary-hide-all-threads))
4790 ;; Show first unread article if requested.
4791 (goto-char (point-min))
4792 (if (and (not no-article)
4793 gnus-auto-select-first
4794 (gnus-summary-first-unread-article))
4795 (gnus-configure-windows 'article)
4796 (gnus-configure-windows 'summary))
4797 (pop-to-buffer gnus-summary-buffer)
4798 (gnus-set-mode-line 'summary)
4799 (gnus-summary-position-cursor)
4800 (if (and kill-buffer
4801 (get-buffer kill-buffer)
4802 (buffer-name (get-buffer kill-buffer)))
4803 (kill-buffer kill-buffer))))
4804 ;; Cannot select newsgroup GROUP.
4805 (message "Couldn't select newsgroup")
4806 (and (eq major-mode 'gnus-summary-mode)
4807 (kill-buffer (current-buffer)))
4808 (switch-to-buffer gnus-group-buffer)))
4810 (defun gnus-summary-prepare ()
4811 "Prepare summary list of current newsgroup in summary buffer."
4812 (let ((buffer-read-only nil))
4814 (gnus-summary-prepare-threads
4815 (if gnus-show-threads
4816 (gnus-gather-threads
4818 (if gnus-summary-expunge-below
4819 (gnus-make-threads-and-expunge)
4820 (gnus-make-threads))))
4821 gnus-newsgroup-headers)
4823 ;; Erase header retrieval message.
4824 (gnus-summary-update-lines)
4826 ;; Call hooks for modifying summary buffer.
4827 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
4828 (goto-char (point-min))
4829 (run-hooks 'gnus-summary-prepare-hook)))
4831 (defun gnus-gather-threads (threads)
4832 "Gather threads that have lost their roots."
4833 (if (not gnus-summary-make-false-root)
4835 (let ((hashtb (gnus-make-hashtable 1023))
4838 thread subject hthread unre-subject whole-subject)
4840 (setq subject (header-subject (car (car threads)))
4841 whole-subject subject)
4842 (and gnus-summary-gather-subject-limit
4843 (> (length subject) gnus-summary-gather-subject-limit)
4845 (substring subject 0 gnus-summary-gather-subject-limit)))
4848 (setq unre-subject (gnus-simplify-subject-re subject))
4851 (or (stringp (car (car hthread)))
4852 (setcar hthread (list whole-subject (car hthread))))
4853 (setcdr (car hthread) (nconc (cdr (car hthread))
4854 (list (car threads))))
4855 (setcdr prev (cdr threads))
4856 (setq threads prev))
4857 (gnus-sethash unre-subject threads hashtb))
4859 (setq threads (cdr threads)))
4862 (defun gnus-make-threads ()
4863 ;; This function takes the dependencies already made by
4864 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
4865 ;; through the dependecies in the hash table and finds all the
4866 ;; roots. Roots do not refer back to any valid articles.
4868 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
4869 (gnus-build-old-threads))
4872 (if (not (car (symbol-value refs)))
4873 (setq roots (append (cdr (symbol-value refs)) roots))
4874 ;; Ok, these refer back to valid articles, but if
4875 ;; `gnus-thread-ignore-subject' is nil, we have to check that
4876 ;; the root has the same subject as its children. The children
4877 ;; that do not are made into roots and removed from the list
4879 (or gnus-thread-ignore-subject
4880 (let* ((prev (symbol-value refs))
4881 (subject (gnus-simplify-subject-re
4882 (header-subject (car prev))))
4883 (headers (cdr prev)))
4885 (if (not (string= subject
4886 (gnus-simplify-subject-re
4887 (header-subject (car headers)))))
4889 (setq roots (cons (car headers) roots))
4890 (setcdr prev (cdr headers)))
4891 (setq prev headers))
4892 (setq headers (cdr headers)))))))
4893 gnus-newsgroup-dependencies)
4895 (mapcar 'gnus-trim-thread
4897 (mapcar 'gnus-cut-thread
4898 (mapcar 'gnus-make-sub-thread roots))))))
4900 (defun gnus-make-threads-and-expunge ()
4901 ;; This function takes the dependencies already made by
4902 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
4903 ;; through the dependecies in the hash table and finds all the
4904 ;; roots. Roots do not refer back to any valid articles.
4906 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
4907 (gnus-build-old-threads))
4910 (if (not (car (symbol-value refs)))
4911 (if (and gnus-summary-expunge-below
4912 (not gnus-fetch-old-headers))
4913 (let ((headers (cdr (symbol-value refs))))
4915 (if (not (< (or (cdr (assq (header-number (car headers))
4916 gnus-newsgroup-scored))
4917 gnus-summary-default-score 0)
4918 gnus-summary-expunge-below))
4919 (setq roots (cons (car headers) roots))
4920 (setq gnus-newsgroup-unreads
4921 (delq (header-number (car headers))
4922 gnus-newsgroup-unreads)))
4923 (setq headers (cdr headers))))
4924 (setq roots (append (cdr (symbol-value refs)) roots)))
4925 ;; Ok, these refer back to valid articles, but if
4926 ;; `gnus-thread-ignore-subject' is nil, we have to check that
4927 ;; the root has the same subject as its children. The children
4928 ;; that do not are made into roots and removed from the list
4930 (or gnus-thread-ignore-subject
4931 (let* ((prev (symbol-value refs))
4932 (subject (gnus-simplify-subject-re
4933 (header-subject (car prev))))
4934 (headers (cdr prev)))
4936 (if (not (string= subject
4937 (gnus-simplify-subject-re
4938 (header-subject (car headers)))))
4940 (setq roots (cons (car headers) roots))
4941 (setcdr prev (cdr headers)))
4942 (setq prev headers))
4943 (setq headers (cdr headers)))))
4944 (and gnus-summary-expunge-below
4945 (not gnus-fetch-old-headers)
4946 (let* ((prev (symbol-value refs))
4947 (headers (cdr prev))
4950 (if (not (< (or (cdr (assq (header-number (car headers))
4951 gnus-newsgroup-scored))
4952 gnus-summary-default-score 0)
4953 gnus-summary-expunge-below))
4954 (setq prev (cdr prev))
4955 (setq gnus-newsgroup-unreads
4956 (delq (header-number (car headers))
4957 gnus-newsgroup-unreads))
4958 (setcdr prev (cdr headers))
4959 (setq id (gnus-gethash (header-id (car headers))
4960 gnus-newsgroup-dependencies))
4963 (if (not (< (or (cdr (assq (header-number (car h))
4964 gnus-newsgroup-scored))
4965 gnus-summary-default-score 0)
4966 gnus-summary-expunge-below))
4967 (setq roots (cons (car h) roots)))
4969 (setq headers (cdr headers)))))))
4970 gnus-newsgroup-dependencies)
4972 (mapcar 'gnus-trim-thread
4974 (mapcar 'gnus-cut-thread
4975 (mapcar 'gnus-make-sub-thread roots))))))
4977 (defun gnus-cut-thread (thread)
4978 ;; Remove leaf dormant or ancient articles from THREAD.
4979 (let ((head (car thread))
4980 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
4981 (if (and (null tail)
4982 (let ((number (header-number head)))
4983 (or (memq number gnus-newsgroup-ancient)
4984 (memq number gnus-newsgroup-dormant)
4985 (and gnus-summary-expunge-below
4986 (eq gnus-fetch-old-headers 'some)
4987 (< (or (cdr (assq number gnus-newsgroup-scored))
4988 gnus-summary-default-score 0)
4989 gnus-summary-expunge-below)
4991 (setq gnus-newsgroup-unreads
4992 (delq number gnus-newsgroup-unreads))
4995 (list (cons head tail)))))
4997 (defun gnus-trim-thread (thread)
4998 ;; Remove root ancient articles with only one child from THREAD.
4999 (if (and (eq gnus-fetch-old-headers 'some)
5000 (memq (header-number (car thread)) gnus-newsgroup-ancient)
5001 (= (length thread) 2))
5002 (gnus-trim-thread (nth 1 thread))
5005 (defun gnus-make-sub-thread (root)
5006 ;; This function makes a sub-tree for a node in the tree.
5007 (let ((children (reverse (cdr (gnus-gethash (downcase (header-id root))
5008 gnus-newsgroup-dependencies)))))
5009 (cons root (mapcar 'gnus-make-sub-thread children))))
5011 (defun gnus-build-old-threads ()
5012 ;; Look at all the articles that refer back to old articles, and
5013 ;; fetch the headers for the articles that aren't there. This will
5014 ;; build complete threads - if the roots haven't been expired by the
5019 (if (not (car (symbol-value refs)))
5021 (setq heads (cdr (symbol-value refs)))
5023 (if (not (memq (header-number (car heads))
5024 gnus-newsgroup-dormant))
5026 (setq id (symbol-name refs))
5027 (while (and (setq id (gnus-build-get-header id))
5028 (not (car (gnus-gethash
5029 id gnus-newsgroup-dependencies)))))
5031 (setq heads (cdr heads)))))))
5032 gnus-newsgroup-dependencies)))
5034 (defun gnus-build-get-header (id)
5035 ;; Look through the buffer of NOV lines and find the header to
5036 ;; ID. Enter this line into the dependencies hash table, and return
5037 ;; the id of the parent article (if any).
5038 (let ((deps gnus-newsgroup-dependencies)
5042 (set-buffer nntp-server-buffer)
5043 (goto-char (point-min))
5044 (while (and (not found) (search-forward id nil t))
5046 (setq found (looking-at (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
5047 (regexp-quote id))))
5048 (or found (beginning-of-line 2)))
5053 (setq header (gnus-nov-parse-line
5054 (read (current-buffer)) deps))
5055 (setq ref (header-references header))
5056 (string-match "\\(<[^>]+>\\) *$" ref)
5057 (substring ref (match-beginning 1) (match-end 1))))))
5059 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
5060 gnus-newsgroup-ancient (cons (header-number header)
5061 gnus-newsgroup-ancient))))))
5063 (defun gnus-sort-threads (threads)
5064 ;; Sort threads as specified in `gnus-thread-sort-functions'.
5065 (let ((fun gnus-thread-sort-functions))
5067 (setq threads (sort threads (car fun))
5071 (defun gnus-thread-header (thread)
5072 ;; Return header of first article in THREAD.
5074 (if (stringp (car thread))
5075 (car (car (cdr thread)))
5079 (defun gnus-thread-sort-by-number (h1 h2)
5080 "Sort threads by root article number."
5081 (let ((h1 (gnus-thread-header h1))
5082 (h2 (gnus-thread-header h2)))
5083 (< (header-number h1) (header-number h2))))
5085 (defun gnus-thread-sort-by-author (h1 h2)
5086 "Sort threads by root author."
5087 (let ((h1 (gnus-thread-header h1))
5088 (h2 (gnus-thread-header h2)))
5090 (let ((extract (funcall
5091 gnus-extract-address-components (header-from h1))))
5092 (or (car extract) (cdr extract)))
5093 (let ((extract (funcall
5094 gnus-extract-address-components (header-from h2))))
5095 (or (car extract) (cdr extract))))))
5097 (defun gnus-thread-sort-by-subject (h1 h2)
5098 "Sort threads by root subject."
5099 (let ((h1 (gnus-thread-header h1))
5100 (h2 (gnus-thread-header h2)))
5102 (downcase (gnus-simplify-subject (header-subject h1)))
5103 (downcase (gnus-simplify-subject (header-subject h2))))))
5105 (defun gnus-thread-sort-by-date (h1 h2)
5106 "Sort threads by root article date."
5107 (let ((h1 (gnus-thread-header h1))
5108 (h2 (gnus-thread-header h2)))
5110 (gnus-sortable-date (header-date h1))
5111 (gnus-sortable-date (header-date h2)))))
5113 (defun gnus-thread-sort-by-score (h1 h2)
5114 "Sort threads by root article score.
5115 Unscored articles will be counted as havin a score of zero."
5116 (let ((h1 (gnus-thread-header h1))
5117 (h2 (gnus-thread-header h2)))
5118 (let ((s1 (assq (header-number h1) gnus-newsgroup-scored))
5119 (s2 (assq (header-number h2) gnus-newsgroup-scored)))
5120 (> (or (cdr s1) gnus-summary-default-score 0)
5121 (or (cdr s2) gnus-summary-default-score 0)))))
5123 (defun gnus-thread-sort-by-total-score (h1 h2)
5124 "Sort threads by the sum of all scores in the thread.
5125 Unscored articles will be counted as havin a score of zero."
5126 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5128 (defun gnus-thread-total-score (thread)
5129 ;; This function find the total score of THREAD.
5131 (if (stringp (car thread))
5132 (apply gnus-thread-score-function 0
5133 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5134 (gnus-thread-total-score-1 thread))
5135 (gnus-thread-total-score-1 (list thread))))
5137 (defun gnus-thread-total-score-1 (root)
5138 ;; This function find the total score of the thread below ROOT.
5139 (setq root (car root))
5140 (apply gnus-thread-score-function
5141 (or (cdr (assq (header-number root) gnus-newsgroup-scored))
5142 gnus-summary-default-score 0)
5143 (mapcar 'gnus-thread-total-score
5144 (cdr (gnus-gethash (downcase (header-id root))
5145 gnus-newsgroup-dependencies)))))
5147 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5148 (defvar gnus-tmp-prev-subject "")
5150 ;; Basic ideas by Paul Dworkin <paul@media-lab.media.mit.edu>.
5151 (defun gnus-summary-prepare-threads
5152 (threads level &optional not-child no-subject cull)
5153 "Prepare summary buffer from THREADS and indentation LEVEL.
5154 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5155 or a straight list of headers."
5156 (let (thread header number subject clevel)
5158 (setq thread (car threads)
5159 threads (cdr threads))
5160 ;; If `thread' is a cons, hierarchical threads are used. If not,
5161 ;; `thread' is the header.
5163 (setq header (car thread))
5164 (setq header thread)
5166 (or (memq (setq number (header-number header))
5167 gnus-newsgroup-dormant)
5168 (and gnus-summary-expunge-below
5169 (< (or (cdr (assq number gnus-newsgroup-scored))
5170 gnus-summary-default-score 0)
5171 gnus-summary-expunge-below)))
5174 (setq gnus-newsgroup-unreads
5175 (delq number gnus-newsgroup-unreads)))))
5178 ;; The header is a dummy root.
5179 (cond ((eq gnus-summary-make-false-root 'adopt)
5180 ;; We let the first article adopt the rest.
5181 (gnus-summary-prepare-threads (list (car (cdr thread))) 0)
5182 (setq thread (cdr (cdr thread)))
5184 (gnus-summary-prepare-threads (list (car thread)) 1 t)
5185 (setq thread (cdr thread))))
5186 ((eq gnus-summary-make-false-root 'dummy)
5187 ;; We output a dummy root.
5188 (gnus-summary-insert-dummy-line
5189 nil header (header-number (car (car (cdr thread)))))
5191 ((eq gnus-summary-make-false-root 'empty)
5192 ;; We print the articles with empty subject fields.
5193 (gnus-summary-prepare-threads (list (car (cdr thread))) 0)
5194 (setq thread (cdr (cdr thread)))
5196 (gnus-summary-prepare-threads (list (car thread)) 0 nil t)
5197 (setq thread (cdr thread))))
5199 ;; We do not make a root for the gathered
5200 ;; sub-threads at all.
5202 ;; Print the sub-threads.
5203 (and (consp thread) (cdr thread)
5204 (gnus-summary-prepare-threads (cdr thread) clevel)))
5205 ;; The header is a real article.
5207 (setq number (header-number header)
5208 subject (header-subject header))
5209 (gnus-summary-insert-line
5210 nil header level nil
5211 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
5212 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
5213 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
5214 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
5215 (t gnus-ancient-mark))
5216 (memq number gnus-newsgroup-replied)
5217 (memq number gnus-newsgroup-expirable)
5218 (if no-subject gnus-summary-same-subject
5219 (if (or (zerop level)
5220 (and gnus-thread-ignore-subject
5222 (gnus-simplify-subject-re gnus-tmp-prev-subject)
5223 (gnus-simplify-subject-re subject)))))
5225 gnus-summary-same-subject))
5227 (cdr (assq number gnus-newsgroup-scored)))
5228 (setq gnus-tmp-prev-subject subject)
5229 ;; Recursively print subthreads.
5230 (and (consp thread) (cdr thread)
5231 (gnus-summary-prepare-threads (cdr thread) (1+ level))))))))
5233 (defun gnus-select-newsgroup (group &optional read-all)
5234 "Select newsgroup GROUP.
5235 If READ-ALL is non-nil, all articles in the group are selected."
5236 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5237 (info (nth 2 entry))
5238 articles header-marks)
5239 (and (eq (car entry) t)
5240 (or (gnus-activate-newsgroup (car info))
5242 (kill-buffer (current-buffer))
5243 (error "Couldn't request group %s: %s"
5244 group (gnus-status-message group)))))
5245 (setq gnus-current-select-method (or (nth 4 info) gnus-select-method))
5246 (gnus-check-news-server (nth 4 info))
5247 (or (gnus-request-group group t)
5249 (kill-buffer (current-buffer))
5250 (error "Couldn't request group %s: %s"
5251 group (gnus-status-message group))))
5253 (setq gnus-newsgroup-name group)
5254 (setq gnus-newsgroup-unselected nil)
5255 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5259 (gnus-adjust-marked-articles info)
5260 (setq gnus-newsgroup-marked
5261 (cdr (assq 'tick (setq marked (nth 3 info)))))
5262 (setq gnus-newsgroup-replied (cdr (assq 'reply marked)))
5263 (setq gnus-newsgroup-expirable (cdr (assq 'expire marked)))
5264 (setq gnus-newsgroup-killed (cdr (assq 'killed marked)))
5265 (setq gnus-newsgroup-bookmarks (cdr (assq 'bookmark marked)))
5266 (setq gnus-newsgroup-dormant (cdr (assq 'dormant marked)))
5267 (setq gnus-newsgroup-scored (cdr (assq 'score marked)))
5268 (setq gnus-newsgroup-processable nil)))
5270 (if (not (setq articles (gnus-articles-to-read group read-all)))
5272 ;; Init the dependencies hash table.
5273 (setq gnus-newsgroup-dependencies
5274 (gnus-make-hashtable (length articles)))
5275 ;; Retrieve the headers and read them in.
5276 (setq gnus-newsgroup-headers
5277 (if (eq 'nov (setq gnus-headers-retrieved-by
5278 (gnus-retrieve-headers
5279 (if gnus-fetch-old-headers
5280 (cons 1 articles) articles)
5281 gnus-newsgroup-name)))
5283 (gnus-get-newsgroup-headers-xover articles))
5284 (gnus-get-newsgroup-headers)))
5285 ;; If we were to fetch old headers, but the backend didn't
5286 ;; support XOVER, then it is possible we fetched one article
5287 ;; that we shouldn't have. If that's the case, we pop it off the
5289 (and (not (eq gnus-headers-retrieved-by 'nov))
5290 gnus-fetch-old-headers
5291 gnus-newsgroup-headers
5292 (/= (header-number (car gnus-newsgroup-headers)) (car articles))
5293 (setq gnus-newsgroup-headers (cdr gnus-newsgroup-headers)))
5294 ;; Remove cancelled articles from the list of unread articles.
5295 (setq gnus-newsgroup-unreads
5296 (gnus-set-sorted-intersection
5297 gnus-newsgroup-unreads
5298 (mapcar (lambda (headers) (header-number headers))
5299 gnus-newsgroup-headers)))
5300 ;; Check whether auto-expire is to be done in this group.
5301 (setq gnus-newsgroup-auto-expire
5302 (or (and (stringp gnus-auto-expirable-newsgroups)
5303 (string-match gnus-auto-expirable-newsgroups group))
5304 (memq 'auto-expire gnus-current-select-method)))
5305 ;; First and last article in this newsgroup.
5306 (and gnus-newsgroup-headers
5307 (setq gnus-newsgroup-begin
5308 (header-number (car gnus-newsgroup-headers)))
5309 (setq gnus-newsgroup-end
5310 (header-number (gnus-last-element gnus-newsgroup-headers))))
5311 (setq gnus-reffed-article-number -1)
5312 ;; GROUP is successfully selected.
5313 (or gnus-newsgroup-headers t))))
5315 (defun gnus-articles-to-read (group read-all)
5316 ;; Find out what articles the user wants to read.
5318 ;; Select all articles if `read-all' is non-nil, or if all the
5319 ;; unread articles are dormant articles.
5321 (= (length gnus-newsgroup-unreads)
5322 (length gnus-newsgroup-dormant)))
5323 (gnus-uncompress-range
5324 (gnus-gethash group gnus-active-hashtb))
5325 gnus-newsgroup-unreads))
5326 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5327 (scored (length scored-list))
5328 (number (length articles))
5329 (marked (+ (length gnus-newsgroup-marked)
5330 (length gnus-newsgroup-dormant)))
5333 (cond ((and (or (<= scored marked)
5335 (numberp gnus-large-newsgroup)
5336 (> number gnus-large-newsgroup))
5340 "How many articles from %s (default %d): "
5341 gnus-newsgroup-name number))))
5342 (if (string-equal input "")
5344 ((and (> scored marked) (< scored number))
5348 "%s %s (%d scored, %d total): "
5349 "How many articles from"
5350 group scored number))))
5351 (if (string-equal input "")
5356 (setq select (if (numberp select) select (string-to-number select)))
5359 (if (and (not (zerop scored)) (<= (abs select) scored))
5361 (setq articles (sort scored-list '<))
5362 (setq number (length articles)))
5363 (setq articles (copy-sequence articles)))
5365 (setq total-articles articles)
5367 (if (< (abs select) number)
5369 ;; Select the N oldest articles.
5370 (setcdr (nthcdr (1- (abs select)) articles) nil)
5371 ;; Select the N most recent articles.
5372 (setq articles (nthcdr (- number select) articles))))
5373 (setq gnus-newsgroup-unselected
5374 (gnus-sorted-intersection
5375 gnus-newsgroup-unselected
5376 (gnus-sorted-complement articles total-articles)))
5379 (defun gnus-killed-articles (killed articles)
5382 (if (inline (gnus-member-of-range (car articles) killed))
5383 (setq out (cons (car articles) out)))
5384 (setq articles (cdr articles)))
5387 (defun gnus-adjust-marked-articles (info &optional active)
5388 "Remove all marked articles that are no longer legal."
5389 (let ((marked-lists (nth 3 info))
5390 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
5392 ;; There are four types of marked articles - ticked, replied,
5393 ;; expirable and dormant.
5395 (setq m (cdr (setq prev (car marked-lists))))
5396 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
5397 ;; Make sure that all ticked articles are a subset of the
5398 ;; unread/unselected articles.
5400 (if (or (memq (car m) gnus-newsgroup-unreads)
5401 (memq (car m) gnus-newsgroup-unselected))
5403 (setcdr prev (cdr m)))
5405 ((eq 'score (car prev))
5406 ;; Scored articles should be a subset of
5407 ;; unread/unselected articles.
5409 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
5410 (memq (car (car m)) gnus-newsgroup-unreads))
5412 (setcdr prev (cdr m)))
5414 ((eq 'bookmark (car prev))
5415 ;; Bookmarks should be a subset of active articles.
5417 (if (< (car (car m)) (car active))
5418 (setcdr prev (cdr m))
5421 ((eq 'killed (car prev))
5422 ;; Articles that have been through the kill process are
5423 ;; to be a subset of active articles.
5424 (while (and m (< (cdr (car m)) (car active)))
5425 (setcdr prev (cdr m))
5427 (if (and m (< (car (car m)) (car active)))
5428 (setcar (car m) (car active))))
5429 ((or (eq 'reply (car marked)) (eq 'expire (car marked)))
5430 ;; The replied and expirable articles have to be articles
5433 (if (< (car m) (car active))
5434 (setcdr prev (cdr m))
5437 (setq marked-lists (cdr marked-lists)))
5438 ;; Remove all lists that are empty.
5439 (setq marked-lists (nth 3 info))
5442 (while (= 1 (length (car marked-lists)))
5443 (setq marked-lists (cdr marked-lists)))
5444 (setq m (cdr (setq prev marked-lists)))
5446 (if (= 1 (length (car m)))
5447 (setcdr prev (cdr m))
5450 (setcar (nthcdr 3 info) marked-lists)))
5451 ;; Finally, if there are no marked lists at all left, and if there
5452 ;; are no elements after the lists in the info list, we just chop
5453 ;; the info list off before the marked lists.
5454 (if (and (null marked-lists) (not (nthcdr 4 info)))
5455 (setcdr (nthcdr 2 info) nil)))
5458 (defun gnus-set-marked-articles
5459 (info ticked replied expirable killed dormant bookmark score)
5460 "Enter the various lists of marked articles into the newsgroup info list."
5462 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
5463 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
5464 (and expirable (setq newmarked (cons (cons 'expire expirable)
5466 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
5467 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
5468 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
5470 (and score (setq newmarked (cons (cons 'score score) newmarked)))
5473 (setcar (nthcdr 3 info) newmarked)
5474 (if (not (nthcdr 4 info))
5475 (setcdr (nthcdr 2 info) nil)
5476 (setcar (nthcdr 3 info) nil)))
5478 (setcdr (nthcdr 2 info) (cons newmarked nil))))))
5480 (defun gnus-add-marked-articles (group type articles &optional info force)
5481 ;; Add ARTICLES of TYPE to the info of GROUP.
5482 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
5483 ;; add, but replace marked articles of TYPE with ARTICLES.
5484 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
5487 (and (not (setq marked (nthcdr 3 info)))
5488 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
5489 (and (not (setq m (assq type (car marked))))
5490 (setcar marked (cons (cons type articles) (car marked))))
5493 (nconc m articles)))))
5495 (defun gnus-set-mode-line (where)
5496 "This function sets the mode line of the article or summary buffers.
5497 If WHERE is `summary', the summary mode line format will be used."
5498 (if (memq where gnus-updated-mode-lines)
5501 (set-buffer gnus-summary-buffer)
5502 (let* ((mformat (if (eq where 'article)
5503 gnus-article-mode-line-format-spec
5504 gnus-summary-mode-line-format-spec))
5505 (group-name gnus-newsgroup-name)
5506 (article-number (or gnus-current-article 0))
5507 (unread (- (length gnus-newsgroup-unreads)
5508 (length gnus-newsgroup-dormant)))
5509 (unread-and-unticked
5510 (- unread (length gnus-newsgroup-marked)))
5511 (unselected (length gnus-newsgroup-unselected))
5512 (unread-and-unselected
5513 (cond ((and (zerop unread-and-unticked)
5514 (zerop unselected)) "")
5516 (format "{%d more}" unread-and-unticked))
5517 (t (format "{%d(+%d) more}"
5518 unread-and-unticked unselected))))
5520 (if gnus-current-headers
5521 (header-subject gnus-current-headers) ""))
5522 (max-len (- (frame-width) gnus-mode-non-string-length)))
5523 (setq mode-string (eval mformat))
5524 (if (> (length mode-string) max-len)
5526 (concat (substring mode-string 0 (- max-len 3)) "...")))
5527 (setq mode-string (format (format "%%-%ds" max-len 5)
5529 (setq mode-line-buffer-identification mode-string)
5530 (set-buffer-modified-p t))))
5532 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5533 "Go through the HEADERS list and add all Xrefs to a hash table.
5534 The resulting hash table is returned, or nil if no Xrefs were found."
5535 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
5537 (gnus-group-foreign-p from-newsgroup)
5539 (assoc (symbol-name (car from-method))
5540 gnus-valid-select-methods))))
5541 (gnus-group-real-prefix from-newsgroup)))
5542 (xref-hashtb (make-vector 63 0))
5543 start group entry number xrefs header)
5545 (setq header (car headers))
5546 (if (and (setq xrefs (header-xref header))
5547 (not (memq (header-number header) unreads)))
5550 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
5551 (setq start (match-end 0))
5552 (setq group (concat prefix (substring xrefs (match-beginning 1)
5555 (string-to-int (substring xrefs (match-beginning 2)
5557 (if (setq entry (gnus-gethash group xref-hashtb))
5558 (setcdr entry (cons number (cdr entry)))
5559 (gnus-sethash group (cons number nil) xref-hashtb)))))
5560 (setq headers (cdr headers)))
5561 (if start xref-hashtb nil)))
5563 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
5564 "Look through all the headers and mark the Xrefs as read."
5565 (let ((virtual (memq 'virtual
5566 (assoc (symbol-name (car (gnus-find-method-for-group
5568 gnus-valid-select-methods)))
5569 name entry read info xref-hashtb idlist active num range exps method)
5571 (set-buffer gnus-group-buffer)
5572 (if (setq xref-hashtb
5573 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5576 (if (string= from-newsgroup (setq name (symbol-name group)))
5578 (setq idlist (symbol-value group))
5579 ;; Dead groups are not updated.
5580 (if (and (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5582 ;; Only do the xrefs if the group has the same
5583 ;; select method as the group we have just read.
5584 (or (gnus-methods-equal-p
5586 (gnus-find-method-for-group from-newsgroup))
5589 (setq method (gnus-find-method-for-group
5591 (and (equal (car (nth 4 info)) (car method))
5592 (equal (nth 1 (nth 4 info)) (nth 1 method))))
5593 gnus-use-cross-reference
5594 (or (not (eq gnus-use-cross-reference t))
5596 ;; Only do cross-references on subscribed
5597 ;; groups, if that is what is wanted.
5598 (<= (nth 1 info) 5)))
5601 ;; Set the new list of read articles in this group.
5602 (setq active (gnus-gethash name gnus-active-hashtb))
5603 ;; First peel off all illegal article numbers.
5606 (ticked (cdr (assq 'tick (nth 3 info))))
5607 (dormant (cdr (assq 'dormant (nth 3 info))))
5612 (if (or (> id (cdr active))
5616 (setq idlist (delq id idlist)))
5617 (and (memq id expirable)
5618 (setq exps (cons id exps)))
5619 (setq ids (cdr ids)))))
5620 ;; Update expirable articles.
5621 (gnus-add-marked-articles nil 'expirable exps info)
5622 (and (null (nth 2 info))
5624 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
5625 (setcar (nthcdr 2 info)
5629 (setq idlist (sort idlist '<)))))
5630 ;; Then we have to re-compute how many unread
5631 ;; articles there are in this group.
5634 (if (atom (cdr range))
5636 (setq num (- (1+ (cdr active))
5638 (setq num (- (cdr active) (- (1+ (cdr range))
5641 (setq num (+ num (- (1+ (or (and (numberp (car range)) (car range)) (cdr (car range))))
5642 (or (and (numberp (car range)) (car range)) (car (car range))))))
5643 (setq range (cdr range)))
5644 (setq num (- (cdr active) num)))
5645 ;; Update the number of unread articles.
5649 (length (cdr (assq 'tick (nth 3 info))))
5651 (cdr (assq 'dormant (nth 3 info)))))))
5652 ;; Update the group buffer.
5653 (gnus-group-update-group name t)))))))
5656 (defun gnus-methods-equal-p (m1 m2)
5657 (let ((m1 (or m1 gnus-select-method))
5658 (m2 (or m2 gnus-select-method)))
5660 (and (eq (car m1) (car m2))
5661 (or (not (memq 'address (assoc (symbol-name (car m1))
5662 gnus-valid-select-methods)))
5663 (equal (nth 1 m1) (nth 1 m2)))))))
5665 (defsubst gnus-header-value ()
5666 (buffer-substring (match-end 0) (save-excursion (end-of-line) (point))))
5668 (defun gnus-get-newsgroup-headers ()
5669 (setq gnus-article-internal-prepare-hook nil)
5670 (let ((cur nntp-server-buffer)
5671 (dependencies gnus-newsgroup-dependencies)
5673 headers char article id dep end)
5675 (set-buffer nntp-server-buffer)
5677 ;; Search to the beginning of the next header. Error messages
5678 ;; do not begin with 2 or 3.
5679 (while (re-search-forward "^[23][0-9]+ " nil t)
5680 (let ((header (make-vector 9 nil))
5681 (c (following-char))
5682 (case-fold-search t)
5684 from subject in-reply-to references ref)
5690 (header-set-number header (setq article (read cur)))
5691 ;; This implementation of this function, with nine
5692 ;; search-forwards instead of the one re-search-forward and
5693 ;; a case (which basically was the old function) is actually
5694 ;; about twice as fast, even though it looks messier. You
5695 ;; can't have everything, I guess. Speed and elegance
5696 ;; doesn't always come hand in hand.
5698 (narrow-to-region (point) (save-excursion
5699 (search-forward "\n.\n" nil t)))
5700 (if (search-forward "\nfrom: " nil t)
5701 (header-set-from header (gnus-header-value))
5702 (header-set-from header "(nobody)"))
5704 (if (search-forward "\nsubject: " nil t)
5705 (header-set-subject header (gnus-header-value))
5706 (header-set-subject header "(none)"))
5708 (and (search-forward "\nxref: " nil t)
5709 (header-set-xref header (gnus-header-value)))
5711 (and (search-forward "\nlines: " nil t)
5712 (header-set-lines header (read cur)))
5714 (and (search-forward "\ndate: " nil t)
5715 (header-set-date header (gnus-header-value)))
5717 (if (search-forward "\nmessage-id: " nil t)
5718 (header-set-id header (setq id (gnus-header-value)))
5719 ;; If there was no message-id, we just fake one to make
5720 ;; subsequent routines simpler.
5723 (setq id (concat "none+" (int-to-string
5724 (setq none-id (1+ none-id)))))))
5726 (if (search-forward "\nreferences: " nil t)
5728 (header-set-references header (gnus-header-value))
5729 (setq end (match-end 0))
5736 (search-backward ">" end t)
5739 (search-backward "<" end t)
5741 ;; Get the references from the in-reply-to header if there
5742 ;; ware no references and the in-reply-to header looks
5744 (if (and (search-forward "\nin-reply-to: " nil t)
5745 (setq in-reply-to (gnus-header-value))
5746 (string-match "<[^>]+>" in-reply-to))
5748 (header-set-references
5750 (setq ref (substring in-reply-to (match-beginning 0)
5752 (setq ref (downcase ref)))
5754 ;; We do some threading while we read the headers. The
5755 ;; message-id and the last reference are both entered into
5756 ;; the same hash table. Some tippy-toeing around has to be
5757 ;; done in case an article has arrived before the article
5758 ;; which it refers to.
5759 (if (boundp (setq dep (intern (downcase id) dependencies)))
5760 (if (car (symbol-value dep))
5761 ;; An article with this Message-ID has already
5762 ;; been seen, so we ignore this one, except we add
5763 ;; any additional Xrefs (in case the two articles
5764 ;; came from different servers.
5767 (car (symbol-value dep))
5768 (concat (or (header-xref (car (symbol-value dep))) "")
5769 (or (header-xref header) "")))
5771 (setcar (symbol-value dep) header))
5772 (set dep (list header)))
5775 (if (boundp (setq dep (intern ref dependencies)))
5776 (setcdr (symbol-value dep)
5777 (cons header (cdr (symbol-value dep))))
5778 (set dep (list nil header)))
5779 (setq headers (cons header headers))))
5780 (goto-char (point-max))))))
5781 (nreverse headers)))
5783 ;; The following macros and functions were written by Felix Lee
5784 ;; <flee@cse.psu.edu>.
5786 ;; This is almost 4x faster than (string-to-int (buffer-substring ... ))
5787 ;; primarily because of garbage collection. -jwz
5788 (defmacro gnus-read-integer (&optional point move-p)
5789 (` ((, (if move-p 'progn 'save-excursion))
5790 (,@ (if point (list (list 'goto-char point))))
5791 (if (and (<= (following-char) ?9)
5792 (>= (following-char) ?0))
5793 (read (current-buffer))
5796 (defmacro gnus-nov-skip-field ()
5797 '(search-forward "\t" eol 'end))
5799 (defmacro gnus-nov-field ()
5802 (progn (gnus-nov-skip-field) (1- (point)))))
5804 ;; Goes through the xover lines and returns a list of vectors
5805 (defun gnus-get-newsgroup-headers-xover (sequence)
5806 "Parse the news overview data in the server buffer, and return a
5807 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
5808 ;; Get the Xref when the users reads the articles since most/some
5809 ;; NNTP servers do not include Xrefs when using XOVER.
5810 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5811 (let ((cur nntp-server-buffer)
5812 (dependencies gnus-newsgroup-dependencies)
5814 number headers header)
5816 (set-buffer nntp-server-buffer)
5817 (goto-char (point-min))
5818 (while (and sequence (not (eobp)))
5819 (setq number (read cur))
5820 (while (and sequence (< (car sequence) number))
5821 (setq sequence (cdr sequence)))
5823 (eq number (car sequence))
5825 (setq sequence (cdr sequence))
5827 (inline (gnus-nov-parse-line number dependencies)))
5828 (setq headers (cons header headers)))))
5830 (setq headers (nreverse headers)))
5833 (defun gnus-nov-parse-line (number dependencies)
5834 "Point has to be after the number on the beginning of the line."
5836 header eol ref id dep)
5841 ;; overview: [num subject from date id refs chars lines misc]
5845 (gnus-nov-field) ; subject
5846 (gnus-nov-field) ; from
5847 (gnus-nov-field) ; date
5848 (setq id (gnus-nov-field)) ; id
5851 (let ((beg (point)))
5852 (search-forward "\t" eol)
5853 (if (search-backward ">" beg t)
5859 (search-backward "<" beg t)
5862 (gnus-nov-field)) ; refs
5863 (read (current-buffer)) ; chars
5864 (read (current-buffer)) ; lines
5865 (if (/= (following-char) ?\t)
5868 (gnus-nov-field)) ; misc
5870 ;; We build the thread tree.
5875 (or id (concat "none+"
5877 (setq none (1+ none))))))
5879 (if (car (symbol-value dep))
5880 ;; An article with this Message-ID has already been seen,
5881 ;; so we ignore this one, except we add any additional
5882 ;; Xrefs (in case the two articles came from different
5886 (car (symbol-value dep))
5887 (concat (or (header-xref (car (symbol-value dep))) "")
5888 (or (header-xref header) "")))
5890 (setcar (symbol-value dep) header))
5891 (set dep (list header)))
5894 (if (boundp (setq dep (intern (or ref "none")
5896 (setcdr (symbol-value dep)
5897 (cons header (cdr (symbol-value dep))))
5898 (set dep (list nil header)))))
5901 (defun gnus-article-get-xrefs ()
5902 "Fill in the Xref value in `gnus-current-headers', if necessary.
5903 This is meant to be called in `gnus-article-internal-prepare-hook'."
5904 (or (not gnus-use-cross-reference)
5905 (header-xref gnus-current-headers)
5906 (let ((case-fold-search t)
5909 (gnus-narrow-to-headers)
5910 (goto-char (point-min))
5911 (if (or (and (eq (downcase (following-char)) ?x)
5912 (looking-at "Xref:"))
5913 (search-forward "\nXref:" nil t))
5915 (goto-char (1+ (match-end 0)))
5916 (setq xref (buffer-substring (point)
5917 (progn (end-of-line) (point))))
5919 (set-buffer gnus-summary-buffer)
5920 (header-set-xref gnus-current-headers xref))))))))
5922 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
5923 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
5925 ;; Return a header specified by a NUMBER.
5926 (defun gnus-get-header-by-number (number)
5928 (set-buffer gnus-summary-buffer)
5929 (or gnus-newsgroup-headers-hashtb-by-number
5930 (gnus-make-headers-hashtable-by-number))
5931 (gnus-gethash (int-to-string number)
5932 gnus-newsgroup-headers-hashtb-by-number)))
5934 (defun gnus-make-headers-hashtable-by-number ()
5935 "Make hashtable for the variable gnus-newsgroup-headers by number."
5937 (set-buffer gnus-summary-buffer)
5938 (let ((headers gnus-newsgroup-headers)
5940 (setq gnus-newsgroup-headers-hashtb-by-number
5941 (gnus-make-hashtable (length headers)))
5943 (setq header (car headers))
5944 (gnus-sethash (int-to-string (header-number header))
5945 header gnus-newsgroup-headers-hashtb-by-number)
5946 (setq headers (cdr headers))))))
5948 (defun gnus-more-header-backward ()
5949 "Find new header backward."
5950 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5951 (artnum gnus-newsgroup-begin)
5953 (while (and (not header)
5955 (setq artnum (1- artnum))
5956 (setq header (gnus-read-header artnum)))
5959 (defun gnus-more-header-forward (&optional backward)
5960 "Find new header forward.
5961 If BACKWARD, find new header backward instead."
5963 (gnus-more-header-backward)
5964 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5965 (artnum gnus-newsgroup-end)
5967 (while (and (not header)
5969 (setq artnum (1+ artnum))
5970 (setq header (gnus-read-header artnum)))
5973 (defun gnus-extend-newsgroup (header &optional backward)
5974 "Extend newsgroup selection with HEADER.
5975 Optional argument BACKWARD means extend toward backward."
5977 (let ((artnum (header-number header)))
5978 (setq gnus-newsgroup-headers
5980 (cons header gnus-newsgroup-headers)
5981 (nconc gnus-newsgroup-headers (list header))))
5982 (setq gnus-newsgroup-unselected
5983 (delq artnum gnus-newsgroup-unselected))
5984 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
5985 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
5987 (defun gnus-summary-work-articles (n)
5988 "Return a list of articles to be worked upon. The prefix argument,
5989 the list of process marked articles, and the current article will be
5990 taken into consideration."
5992 (if (and n (numberp n))
5993 (let ((backward (< n 0))
5997 (setq articles (cons (gnus-summary-article-number)
5999 (gnus-summary-search-forward nil nil backward))
6001 (sort articles (function <)))
6002 (or (reverse gnus-newsgroup-processable)
6003 (list (gnus-summary-article-number))))))
6005 (defun gnus-summary-search-group (&optional backward use-level)
6006 "Search for next unread newsgroup.
6007 If optional argument BACKWARD is non-nil, search backward instead."
6009 (set-buffer gnus-group-buffer)
6011 ;; We don't want to alter current point of group mode buffer.
6012 (if (gnus-group-search-forward
6014 (if use-level (gnus-group-group-level) nil))
6015 (gnus-group-group-name)))))
6017 (defun gnus-summary-best-group ()
6018 "Find the name of the best unread group."
6020 (set-buffer gnus-group-buffer)
6022 (gnus-group-best-unread-group))))
6024 (defun gnus-summary-search-subject (&optional backward unread subject)
6025 "Search for article forward.
6026 If BACKWARD is non-nil, search backward.
6027 If UNREAD is non-nil, only unread articles are selected.
6028 If SUBJECT is non-nil, the article which has the same subject will be
6030 (let ((func (if backward 'previous-single-property-change
6031 'next-single-property-change))
6036 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
6037 (while (and (setq pos (funcall func (point) 'gnus-number))
6038 (goto-char (if backward (1- pos) pos))
6040 (not (and (or (not unread)
6041 (eq (get-text-property (point) 'gnus-mark)
6044 (equal (gnus-simplify-subject-re
6046 (gnus-simplify-subject-re
6049 'gnus-subject)))))))
6050 (if backward (if (bobp) nil (forward-char -1) t)
6051 (if (eobp) nil (forward-char 1) t))))
6053 (progn (goto-char beg) nil)
6055 (get-text-property (point) 'gnus-number)
6056 (gnus-summary-position-cursor)))))
6058 (defun gnus-summary-search-forward (&optional unread subject backward)
6059 "Search for article forward.
6060 If UNREAD is non-nil, only unread articles are selected.
6061 If SUBJECT is non-nil, the article which has the same subject will be
6063 If BACKWARD is non-nil, the search will be performed backwards instead."
6064 (gnus-summary-search-subject backward unread subject))
6066 (defun gnus-summary-search-backward (&optional unread subject)
6067 "Search for article backward.
6068 If 1st optional argument UNREAD is non-nil, only unread article is selected.
6069 If 2nd optional argument SUBJECT is non-nil, the article which has
6070 the same subject will be searched for."
6071 (gnus-summary-search-forward unread subject t))
6073 (defun gnus-summary-article-number (&optional number-or-nil)
6074 "The article number of the article on the current line.
6075 If there isn's an article number here, then we return the current
6077 (let ((number (get-text-property (save-excursion (beginning-of-line) (point))
6079 (if number-or-nil number (or number gnus-current-article))))
6081 (defun gnus-summary-thread-level ()
6082 "The thread level of the article on the current line."
6083 (or (get-text-property (save-excursion (beginning-of-line) (point))
6087 (defun gnus-summary-pseudo-article ()
6088 "The thread level of the article on the current line."
6089 (get-text-property (save-excursion (beginning-of-line) (point))
6092 (defun gnus-summary-article-mark ()
6093 "The mark on the current line."
6094 (get-text-property (save-excursion (beginning-of-line) (point))
6097 (defun gnus-summary-subject-string ()
6098 "Return current subject string or nil if nothing."
6099 (get-text-property (save-excursion (beginning-of-line) (point))
6102 (defalias 'gnus-summary-score 'gnus-summary-article-score)
6103 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
6104 (defun gnus-summary-article-score ()
6105 "Return current article score."
6106 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
6107 gnus-summary-default-score 0))
6109 (defun gnus-summary-recenter ()
6110 "Center point in the summary window.
6111 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6112 displayed, no centering will be performed."
6113 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6114 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6115 (let ((top (cond ((< (window-height) 4) 0)
6116 ((< (window-height) 6) 1)
6119 ;; The user has to want it,
6120 gnus-auto-center-summary
6121 ;; the article buffer must be displayed,
6122 (get-buffer-window gnus-article-buffer)
6123 ;; there must be lines left to scroll forward,
6124 (zerop (save-excursion (forward-line (- (window-height) 1 top))))
6127 (get-buffer-window (current-buffer))
6128 (save-excursion (forward-line (- top)) (point))))))
6130 (defun gnus-summary-jump-to-group (newsgroup)
6131 "Move point to NEWSGROUP in group mode buffer."
6132 ;; Keep update point of group mode buffer if visible.
6133 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6134 (save-window-excursion
6135 ;; Take care of tree window mode.
6136 (if (get-buffer-window gnus-group-buffer)
6137 (pop-to-buffer gnus-group-buffer))
6138 (gnus-group-jump-to-group newsgroup))
6140 ;; Take care of tree window mode.
6141 (if (get-buffer-window gnus-group-buffer)
6142 (pop-to-buffer gnus-group-buffer)
6143 (set-buffer gnus-group-buffer))
6144 (gnus-group-jump-to-group newsgroup))))
6146 ;; This function returns a list of article numbers based on the
6147 ;; difference between the ranges of read articles in this group and
6148 ;; the range of active articles.
6149 (defun gnus-list-of-unread-articles (group)
6150 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6151 (active (gnus-gethash group gnus-active-hashtb))
6153 unread first nlast unread)
6154 ;; If none are read, then all are unread.
6156 (setq first (car active))
6157 ;; If the range of read articles is a single range, then the
6158 ;; first unread article is the article after the last read
6159 ;; article. Sounds logical, doesn't it?
6160 (if (atom (car read))
6161 (setq first (1+ (cdr read)))
6162 ;; `read' is a list of ranges.
6165 (while (< first nlast)
6166 (setq unread (cons first unread))
6167 (setq first (1+ first))))
6168 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
6169 (setq nlast (if (atom (car (cdr read)))
6171 (car (car (cdr read)))))
6172 (setq read (cdr read)))))
6173 ;; And add the last unread articles.
6174 (while (<= first last)
6175 (setq unread (cons first unread))
6176 (setq first (1+ first)))
6177 ;; Return the list of unread articles.
6181 ;; Various summary commands
6183 (defun gnus-summary-universal-argument ()
6184 "Perform any operation on all articles marked with the process mark."
6186 (gnus-set-global-variables)
6187 (let ((articles (reverse gnus-newsgroup-processable))
6189 (or articles (error "No articles marked"))
6190 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
6191 (error "Undefined key"))
6193 (gnus-summary-goto-subject (car articles))
6194 (command-execute func)
6195 (gnus-summary-remove-process-mark (car articles))
6196 (setq articles (cdr articles)))))
6198 (defun gnus-summary-toggle-truncation (arg)
6199 "Toggle truncation of summary lines.
6200 With arg, turn line truncation on iff arg is positive."
6202 (setq truncate-lines
6203 (if (null arg) (not truncate-lines)
6204 (> (prefix-numeric-value arg) 0)))
6207 (defun gnus-summary-reselect-current-group (show-all)
6208 "Once exit and then reselect the current newsgroup.
6209 Prefix argument SHOW-ALL means to select all articles."
6211 (gnus-set-global-variables)
6212 (let ((current-subject (gnus-summary-article-number)))
6213 (gnus-summary-exit t)
6214 ;; We have to adjust the point of group mode buffer because the
6215 ;; current point was moved to the next unread newsgroup by
6217 (gnus-summary-jump-to-group gnus-newsgroup-name)
6218 (gnus-group-read-group show-all t)
6219 (gnus-summary-goto-subject current-subject)))
6221 (defun gnus-summary-rescan-group (all)
6222 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6224 (gnus-set-global-variables)
6225 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
6226 (let ((group gnus-newsgroup-name))
6227 (gnus-summary-exit t)
6228 (gnus-summary-jump-to-group group)
6230 (set-buffer gnus-group-buffer)
6231 (gnus-group-get-new-news-this-group 1))
6232 (gnus-summary-jump-to-group group)
6233 (gnus-group-read-group all)))
6235 (defun gnus-summary-exit (&optional temporary)
6236 "Exit reading current newsgroup, and then return to group selection mode.
6237 gnus-exit-group-hook is called with no arguments if that value is non-nil."
6239 (gnus-set-global-variables)
6240 (gnus-kill-save-kill-buffer)
6241 (let* ((group gnus-newsgroup-name)
6242 (quit-buffer (cdr (assoc 'quit-buffer (gnus-find-method-for-group
6243 gnus-newsgroup-name))))
6245 (method (car (gnus-find-method-for-group group)))
6246 (buf (current-buffer)))
6247 (if gnus-newsgroup-kill-headers
6248 (setq gnus-newsgroup-killed
6249 (gnus-compress-sequence
6251 (gnus-set-sorted-intersection
6252 (gnus-uncompress-range gnus-newsgroup-killed)
6253 (setq gnus-newsgroup-unselected
6254 (sort gnus-newsgroup-unselected '<)))
6255 (setq gnus-newsgroup-unreads
6256 (sort gnus-newsgroup-unreads '<))))))
6257 (or (listp (cdr gnus-newsgroup-killed))
6258 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6260 (headers gnus-newsgroup-headers))
6261 (gnus-close-group group)
6262 (run-hooks 'gnus-exit-group-hook)
6264 (gnus-update-read-articles
6265 group gnus-newsgroup-unreads gnus-newsgroup-unselected
6266 gnus-newsgroup-marked
6267 t gnus-newsgroup-replied gnus-newsgroup-expirable
6268 gnus-newsgroup-killed gnus-newsgroup-dormant
6269 gnus-newsgroup-bookmarks
6270 (and gnus-save-score gnus-newsgroup-scored))
6271 (and gnus-use-cross-reference
6272 (gnus-mark-xrefs-as-read
6273 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
6274 ;; Do not switch windows but change the buffer to work.
6275 (set-buffer gnus-group-buffer)
6276 (or (eq 'nndigest method)
6277 (gnus-group-update-group group)))
6278 ;; Make sure where I was, and go to next newsgroup.
6279 (if (eq method 'nndigest)
6281 (gnus-group-jump-to-group group)
6282 (gnus-group-next-unread-group 1))
6284 ;; If exiting temporary, caller should adjust group mode
6285 ;; buffer point by itself.
6287 ;; We set all buffer-local variables to nil. It is unclear why
6288 ;; this is needed, but if we don't, buffer-local variables are
6289 ;; not garbage-collected, it seems. This would the lead to en
6290 ;; ever-growing Emacs.
6292 (gnus-summary-clear-local-variables)
6293 ;; We clear the global counterparts of the buffer-local
6294 ;; variables as well, just to be on the safe side.
6295 (set-buffer gnus-group-buffer)
6296 (gnus-summary-clear-local-variables)
6297 (gnus-configure-windows 'newsgroups t)
6298 ;; Return to group mode buffer.
6299 (and (get-buffer buf)
6300 (eq mode 'gnus-summary-mode)
6302 (if (get-buffer gnus-article-buffer)
6303 (bury-buffer gnus-article-buffer))
6304 (setq gnus-current-select-method gnus-select-method)
6305 (pop-to-buffer gnus-group-buffer)
6306 (if (and quit-buffer (buffer-name quit-buffer))
6308 (switch-to-buffer quit-buffer)
6309 (gnus-set-global-variables)
6310 (gnus-configure-windows 'summary))))))
6312 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6313 (defun gnus-summary-exit-no-update (&optional no-questions)
6314 "Quit reading current newsgroup without updating read article info."
6316 (let* ((group gnus-newsgroup-name)
6317 (quit-buffer (cdr (assoc 'quit-buffer
6318 (gnus-find-method-for-group group)))))
6319 (if (or no-questions
6321 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
6323 (gnus-close-group group)
6324 (gnus-summary-clear-local-variables)
6325 (set-buffer gnus-group-buffer)
6326 (gnus-summary-clear-local-variables)
6327 ;; Return to group selection mode.
6328 (gnus-configure-windows 'newsgroups)
6329 (if (get-buffer gnus-summary-buffer)
6330 (kill-buffer gnus-summary-buffer))
6331 (if (get-buffer gnus-article-buffer)
6332 (bury-buffer gnus-article-buffer))
6333 (pop-to-buffer gnus-group-buffer)
6334 (gnus-group-jump-to-group group)
6335 (gnus-group-next-group 1)
6336 (if (and quit-buffer (buffer-name quit-buffer))
6338 (switch-to-buffer quit-buffer)
6339 (gnus-configure-windows 'summary)))))))
6341 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6342 (defun gnus-summary-fetch-faq (group)
6343 "Fetch the FAQ for the current group."
6344 (interactive (list gnus-newsgroup-name))
6345 (gnus-configure-windows 'article)
6346 (pop-to-buffer gnus-article-buffer)
6347 (find-file (concat gnus-group-faq-directory group)))
6349 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6350 (defun gnus-summary-describe-group (force)
6351 "Describe the current newsgroup."
6353 (gnus-group-describe-group force gnus-newsgroup-name))
6355 (defun gnus-summary-describe-briefly ()
6356 "Describe summary mode commands briefly."
6359 (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")))
6361 ;; Walking around group mode buffer from summary mode.
6363 (defun gnus-summary-next-group (&optional no-article group backward)
6364 "Exit current newsgroup and then select next unread newsgroup.
6365 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
6366 If BACKWARD, go to previous group instead."
6368 (gnus-set-global-variables)
6369 (let ((ingroup gnus-newsgroup-name)
6370 (sumbuf (current-buffer))
6372 (gnus-summary-exit t) ;Update all information.
6374 (or (and (numberp (setq num (car (gnus-gethash
6375 group gnus-newsrc-hashtb))))
6379 (gnus-group-jump-to-group group)
6381 (gnus-group-jump-to-group ingroup))
6382 (let ((group (or group (gnus-summary-search-group backward)))
6383 (buf gnus-summary-buffer))
6385 (gnus-summary-exit-no-update t)
6386 (message "Selecting %s..." group)
6387 ;; We are now in group mode buffer.
6388 ;; Make sure group mode buffer point is on GROUP.
6389 (gnus-group-jump-to-group group)
6391 (gnus-summary-read-group group nil no-article buf)
6392 (and (string= gnus-newsgroup-name ingroup)
6395 (gnus-summary-exit-no-update t))))))))
6397 (defun gnus-summary-prev-group (no-article)
6398 "Exit current newsgroup and then select previous unread newsgroup.
6399 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6401 (gnus-summary-next-group no-article nil t))
6403 ;; Walking around summary lines.
6405 (defun gnus-summary-first-subject (unread)
6406 "Go to the first unread subject.
6407 If UNREAD is non-nil, go to the first unread article.
6408 Returns nil if there are no unread articles."
6410 (let ((begin (point)))
6412 (if (not (gnus-goto-char
6413 (text-property-any (point-min) (point-max)
6414 'gnus-mark gnus-unread-mark)))
6416 ;; If there is no unread articles, stay where you are.
6418 (message "No more unread articles")
6421 (goto-char (point-min)))))
6423 (defun gnus-summary-next-subject (n &optional unread)
6424 "Go to next N'th summary line.
6425 If N is negative, go to the previous N'th subject line.
6426 If UNREAD is non-nil, only unread articles are selected.
6427 The difference between N and the actual number of steps taken is
6430 (let ((backward (< n 0))
6433 (gnus-summary-search-forward unread nil backward))
6435 (gnus-summary-recenter)
6436 (if (/= 0 n) (message "No more%s articles" (if unread " unread" "")))
6437 (gnus-summary-position-cursor)
6440 (defun gnus-summary-next-unread-subject (n)
6441 "Go to next N'th unread summary line."
6443 (gnus-summary-next-subject n t))
6445 (defun gnus-summary-prev-subject (n &optional unread)
6446 "Go to previous N'th summary line.
6447 If optional argument UNREAD is non-nil, only unread article is selected."
6449 (gnus-summary-next-subject (- n) unread))
6451 (defun gnus-summary-prev-unread-subject (n)
6452 "Go to previous N'th unread summary line."
6454 (gnus-summary-next-subject (- n) t))
6456 (defun gnus-summary-goto-subject (article)
6457 "Go the subject line of ARTICLE."
6461 (completing-read "Article number: "
6465 (int-to-string (header-number headers))))
6466 gnus-newsgroup-headers)
6467 nil 'require-match))))
6468 (or article (error "No article number"))
6469 (if (or (eq article (gnus-summary-article-number t))
6472 (point-min) (point-max) 'gnus-number article)))
6475 ;; Walking around summary lines with displaying articles.
6477 (defun gnus-summary-expand-window ()
6478 "Expand summary window to show headers full window."
6480 (gnus-set-global-variables)
6481 (gnus-configure-windows 'summary)
6482 (pop-to-buffer gnus-summary-buffer))
6484 (defun gnus-summary-display-article (article &optional all-header)
6485 "Display ARTICLE in article buffer."
6486 (gnus-set-global-variables)
6489 (gnus-article-prepare article all-header)
6490 (if (= (gnus-summary-article-mark) ?Z)
6493 (gnus-summary-position-cursor)))
6494 (run-hooks 'gnus-select-article-hook)
6495 (gnus-summary-recenter)
6496 ; (set-window-point (get-buffer-window (current-buffer)) (point-max))
6498 (gnus-summary-goto-subject article)
6499 ;; Successfully display article.
6500 (gnus-summary-update-line)
6503 (defun gnus-summary-select-article (&optional all-headers force pseudo)
6504 "Select the current article.
6505 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6506 non-nil, the article will be re-fetched even if it already present in
6507 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6509 (and (not pseudo) (gnus-summary-pseudo-article)
6510 (error "This is a pseudo-article."))
6511 (let ((article (gnus-summary-article-number))
6512 (all-headers (not (not all-headers)))) ;Must be T or NIL.
6513 (if (or (null gnus-current-article)
6514 (null gnus-article-current)
6515 (/= article (cdr gnus-article-current))
6516 (not (equal (car gnus-article-current) gnus-newsgroup-name))
6518 ;; The requested article is different from the current article.
6520 (gnus-summary-display-article article all-headers)
6522 (if all-headers (gnus-article-show-all-headers))
6523 (gnus-configure-windows 'article)
6524 (pop-to-buffer gnus-summary-buffer)
6527 (defun gnus-summary-set-current-mark (&optional current-mark)
6528 "Obsolete function."
6531 (defun gnus-summary-next-article (unread &optional subject backward)
6532 "Select the next article.
6533 If UNREAD, only unread articles are selected.
6534 If SUBJECT, only articles with SUBJECT are selected.
6535 If BACKWARD, the previous article is selected instead of the next."
6537 (let ((opoint (point))
6538 (method (car (gnus-find-method-for-group gnus-newsgroup-name)))
6541 ;; Is there such an article?
6542 ((gnus-summary-display-article
6543 (gnus-summary-search-forward unread subject backward))
6544 (gnus-summary-position-cursor))
6545 ;; If not, we try the first unread, if that is wanted.
6547 gnus-auto-select-same
6548 (gnus-summary-first-unread-article))
6549 (message "Wrapped"))
6550 ;; Try to get next/previous article not displayed in this group.
6551 ((and gnus-auto-extend-newsgroup
6552 (not unread) (not subject)
6553 (setq header (gnus-more-header-forward backward)))
6554 (gnus-extend-newsgroup header backward)
6555 (let ((buffer-read-only nil))
6556 (goto-char (if backward (point-min) (point-max)))
6557 (gnus-summary-prepare-threads (list header) 0))
6558 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
6559 gnus-newsgroup-end)))
6560 ;; Go to next/previous group.
6562 (gnus-summary-jump-to-group gnus-newsgroup-name)
6563 (let ((cmd (aref (this-command-keys) 0))
6565 (if (eq gnus-keep-same-level 'best) (gnus-summary-best-group)
6566 (gnus-summary-search-group backward gnus-keep-same-level))))
6567 ;; Keep just the event type of CMD.
6568 (and (listp cmd) (setq cmd (car cmd)))
6569 ;; Select next unread newsgroup automagically.
6571 ((not gnus-auto-select-next)
6572 (message "No more%s articles" (if unread " unread" "")))
6573 ((eq gnus-auto-select-next 'quietly)
6575 (if (eq method 'nndigest)
6577 (message "No more%s articles (%s)..."
6578 (if unread " unread" "")
6579 (if group (concat "selecting " group)
6581 (gnus-summary-next-group nil group backward)))
6583 (let ((keystrokes '(?\C-n ?\C-p))
6585 (while (or (null key) (memq key keystrokes))
6587 "No more%s articles%s" (if unread " unread" "")
6588 (if (and group (not (eq method 'nndigest)))
6589 (format " (Type %s for %s [%s])"
6590 (single-key-description cmd) group
6591 (car (gnus-gethash group gnus-newsrc-hashtb)))
6592 (format " (Type %s to exit %s)"
6593 (single-key-description cmd)
6594 gnus-newsgroup-name)))
6595 ;; Confirm auto selection.
6596 (let* ((event (read-event)))
6597 (setq key (if (listp event) (car event) event))
6598 (if (member key keystrokes)
6599 (let ((obuf (current-buffer)))
6600 (switch-to-buffer gnus-group-buffer)
6601 (gnus-group-jump-to-group group)
6602 (execute-kbd-macro (char-to-string key))
6603 (setq group (gnus-group-group-name))
6604 (switch-to-buffer obuf)))))
6606 (if (or (not group) (eq method 'nndigest))
6608 (gnus-summary-next-group nil group backward))
6609 (setq unread-command-events (list key)))))))))))
6611 (defun gnus-summary-next-unread-article ()
6612 "Select unread article after current one."
6614 (gnus-summary-next-article t (and gnus-auto-select-same
6615 (gnus-summary-subject-string))))
6617 (defun gnus-summary-prev-article (unread &optional subject)
6618 "Select the article after the current one.
6619 If UNREAD is non-nil, only unread articles are selected."
6621 (gnus-summary-next-article unread subject t))
6623 (defun gnus-summary-prev-unread-article ()
6624 "Select unred article before current one."
6626 (gnus-summary-prev-article t (and gnus-auto-select-same
6627 (gnus-summary-subject-string))))
6629 (defun gnus-summary-next-page (lines &optional circular)
6630 "Show next page of selected article.
6631 If end of article, select next article.
6632 Argument LINES specifies lines to be scrolled up.
6633 If CIRCULAR is non-nil, go to the start of the article instead of
6634 instead of selecting the next article when reaching the end of the
6637 (setq gnus-summary-buffer (current-buffer))
6638 (let ((article (gnus-summary-article-number))
6640 (if (or (null gnus-current-article)
6641 (null gnus-article-current)
6642 (/= article (cdr gnus-article-current))
6643 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6644 ;; Selected subject is different from current article's.
6645 (gnus-summary-display-article article)
6646 (gnus-configure-windows 'article)
6647 (pop-to-buffer gnus-summary-buffer)
6648 (gnus-eval-in-buffer-window
6650 (setq endp (gnus-article-next-page lines)))
6653 (gnus-summary-beginning-of-article))
6655 (message "End of message"))
6657 (gnus-summary-next-unread-article))))))
6658 (gnus-summary-position-cursor))
6660 (defun gnus-summary-prev-page (lines)
6661 "Show previous page of selected article.
6662 Argument LINES specifies lines to be scrolled down."
6664 (let ((article (gnus-summary-article-number)))
6665 (if (or (null gnus-current-article)
6666 (null gnus-article-current)
6667 (/= article (cdr gnus-article-current))
6668 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6669 ;; Selected subject is different from current article's.
6670 (gnus-summary-display-article article)
6671 (gnus-configure-windows 'article)
6672 (pop-to-buffer gnus-summary-buffer)
6673 (gnus-eval-in-buffer-window gnus-article-buffer
6674 (gnus-article-prev-page lines))))
6675 (gnus-summary-position-cursor))
6677 (defun gnus-summary-scroll-up (lines)
6678 "Scroll up (or down) one line current article.
6679 Argument LINES specifies lines to be scrolled up (or down if negative)."
6681 (or (gnus-summary-select-article nil nil 'pseudo)
6682 (gnus-eval-in-buffer-window
6685 (if (gnus-article-next-page lines)
6686 (message "End of message")))
6688 (gnus-article-prev-page (- lines))))))
6689 (gnus-summary-position-cursor))
6691 (defun gnus-summary-next-same-subject ()
6692 "Select next article which has the same subject as current one."
6694 (gnus-summary-next-article nil (gnus-summary-subject-string)))
6696 (defun gnus-summary-prev-same-subject ()
6697 "Select previous article which has the same subject as current one."
6699 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
6701 (defun gnus-summary-next-unread-same-subject ()
6702 "Select next unread article which has the same subject as current one."
6704 (gnus-summary-next-article t (gnus-summary-subject-string)))
6706 (defun gnus-summary-prev-unread-same-subject ()
6707 "Select previous unread article which has the same subject as current one."
6709 (gnus-summary-prev-article t (gnus-summary-subject-string)))
6711 (defun gnus-summary-first-unread-article ()
6712 "Select the first unread article.
6713 Return nil if there are no unread articles."
6716 (if (gnus-summary-first-subject t)
6717 (gnus-summary-display-article (gnus-summary-article-number)))
6718 (gnus-summary-position-cursor)))
6720 (defun gnus-summary-best-unread-article ()
6721 "Select the unread article with the highest score."
6723 (gnus-set-global-variables)
6724 (let ((scored gnus-newsgroup-scored)
6728 (or (> best (cdr (car scored)))
6729 (and (memq (setq art (car (car scored))) gnus-newsgroup-unreads)
6730 (not (memq art gnus-newsgroup-marked))
6731 (not (memq art gnus-newsgroup-dormant))
6732 (if (= best (cdr (car scored)))
6733 (setq article (min art article))
6735 (setq best (cdr (car scored))))))
6736 (setq scored (cdr scored)))
6738 (gnus-summary-goto-article article)
6739 (gnus-summary-first-unread-article))
6740 (gnus-summary-position-cursor)))
6742 (defun gnus-summary-goto-article (article &optional all-headers)
6743 "Fetch ARTICLE and display it if it exists.
6744 If ALL-HEADERS is non-nil, no header lines are hidden."
6750 (mapcar (lambda (headers) (list (int-to-string (header-number headers))))
6751 gnus-newsgroup-headers)
6752 nil 'require-match))))
6753 (if (gnus-summary-goto-subject article)
6754 (gnus-summary-display-article article all-headers))
6755 (gnus-summary-position-cursor))
6757 (defun gnus-summary-goto-last-article ()
6758 "Go to the last article."
6760 (if gnus-last-article
6761 (gnus-summary-goto-article gnus-last-article))
6762 (gnus-summary-position-cursor))
6764 (defun gnus-summary-pop-article (number)
6765 "Pop one article off the history and go to the previous.
6766 NUMBER articles will be popped off."
6769 (setq gnus-newsgroup-history
6770 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6772 (gnus-summary-goto-article (car to))
6773 (error "Article history empty")))
6774 (gnus-summary-position-cursor))
6776 ;; Summary article oriented commands
6778 (defun gnus-summary-refer-parent-article (n)
6779 "Refer parent article N times.
6780 The difference between N and the number of articles fetched is returned."
6782 (gnus-set-global-variables)
6786 (let ((ref (header-references (gnus-get-header-by-number
6787 (gnus-summary-article-number)))))
6788 (if (and ref (not (equal ref ""))
6789 (string-match "<[^<>]*>[ \t]*$" ref))
6790 (gnus-summary-refer-article
6791 (substring ref (match-beginning 0) (match-end 0))))))
6793 (or (zerop n) (message "No references in article or expired article."))
6794 (gnus-summary-position-cursor)
6797 (defun gnus-summary-refer-article (message-id)
6798 "Refer article specified by MESSAGE-ID.
6799 NOTE: This command only works with newsgroup that use NNTP."
6800 (interactive "sMessage-ID: ")
6801 (if (or (not (stringp message-id))
6802 (zerop (length message-id)))
6804 ;; Construct the correct Message-ID if necessary.
6805 ;; Suggested by tale@pawl.rpi.edu.
6806 (or (string-match "^<" message-id)
6807 (setq message-id (concat "<" message-id)))
6808 (or (string-match ">$" message-id)
6809 (setq message-id (concat message-id ">")))
6810 (let ((header (car (gnus-gethash (downcase message-id)
6811 gnus-newsgroup-dependencies))))
6813 (gnus-summary-goto-article (header-number header))
6814 (let ((gnus-override-method gnus-refer-article-method))
6815 (if (gnus-article-prepare
6816 message-id nil (gnus-read-header message-id))
6818 (gnus-summary-insert-line
6819 nil gnus-current-headers 0 nil gnus-read-mark nil nil
6820 (header-subject gnus-current-headers))
6822 (gnus-summary-position-cursor)
6823 (gnus-summary-update-line)
6825 (message "No such references")
6828 (defun gnus-summary-enter-digest-group ()
6829 "Enter a digest group based on the current article."
6831 (gnus-summary-select-article)
6832 (let ((name (format "%s/%d"
6833 (gnus-group-prefixed-name
6834 gnus-newsgroup-name (list 'nndigest ""))
6835 gnus-current-article))
6836 (buf (current-buffer)))
6837 (set-buffer gnus-group-buffer)
6840 (list t nil (list name 3 nil nil
6841 (list 'nndigest gnus-article-buffer
6842 (cons 'quit-buffer buf))))
6844 (gnus-group-read-group t nil name)))
6846 (defun gnus-summary-isearch-article ()
6847 "Do incremental search forward on current article."
6849 (gnus-summary-select-article)
6850 (gnus-eval-in-buffer-window gnus-article-buffer
6853 (defun gnus-summary-search-article-forward (regexp)
6854 "Search for an article containing REGEXP forward.
6855 gnus-select-article-hook is not called during the search."
6858 (concat "Search forward (regexp): "
6859 (if gnus-last-search-regexp
6860 (concat "(default " gnus-last-search-regexp ") "))))))
6861 (if (string-equal regexp "")
6862 (setq regexp (or gnus-last-search-regexp ""))
6863 (setq gnus-last-search-regexp regexp))
6864 (if (gnus-summary-search-article regexp nil)
6865 (gnus-eval-in-buffer-window
6868 (error "Search failed: \"%s\"" regexp)))
6870 (defun gnus-summary-search-article-backward (regexp)
6871 "Search for an article containing REGEXP backward.
6872 gnus-select-article-hook is not called during the search."
6875 (concat "Search backward (regexp): "
6876 (if gnus-last-search-regexp
6877 (concat "(default " gnus-last-search-regexp ") "))))))
6878 (if (string-equal regexp "")
6879 (setq regexp (or gnus-last-search-regexp ""))
6880 (setq gnus-last-search-regexp regexp))
6881 (if (gnus-summary-search-article regexp t)
6882 (gnus-eval-in-buffer-window
6885 (error "Search failed: \"%s\"" regexp)))
6887 (defun gnus-summary-search-article (regexp &optional backward)
6888 "Search for an article containing REGEXP.
6889 Optional argument BACKWARD means do search for backward.
6890 gnus-select-article-hook is not called during the search."
6891 (let ((gnus-select-article-hook nil) ;Disable hook.
6892 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6895 (function re-search-backward) (function re-search-forward)))
6898 ;; Hidden thread subtrees must be searched for ,too.
6899 (gnus-summary-show-all-threads)
6900 (if (eobp) (forward-line -1))
6901 ;; First of all, search current article.
6902 ;; We don't want to read article again from NNTP server nor reset
6904 (gnus-summary-select-article)
6905 (message "Searching article: %d..." gnus-current-article)
6906 (setq last gnus-current-article)
6907 (gnus-eval-in-buffer-window gnus-article-buffer
6910 ;; Begin search from current point.
6911 (setq found (funcall re-search regexp nil t))))
6912 ;; Then search next articles.
6913 (while (and (not found)
6914 (gnus-summary-display-article
6915 (gnus-summary-search-subject backward nil nil)))
6916 (message "Searching article: %d..." gnus-current-article)
6917 (gnus-eval-in-buffer-window gnus-article-buffer
6920 (goto-char (if backward (point-max) (point-min)))
6921 (setq found (funcall re-search regexp nil t)))))
6923 ;; Adjust article pointer.
6924 (or (eq last gnus-current-article)
6925 (setq gnus-last-article last))
6926 ;; Return T if found such article.
6929 (defun gnus-summary-execute-command (header regexp command &optional backward)
6930 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6931 If HEADER is an empty string (or nil), the match is done on the entire
6932 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6934 (list (let ((completion-ignore-case t))
6937 (mapcar (string) (list string)
6938 '("Number" "Subject" "From" "Lines" "Date"
6939 "Message-ID" "Xref" "References")
6940 nil 'require-match)))
6941 (read-string "Regexp: ")
6942 (read-key-sequence "Command: ")
6943 current-prefix-arg))
6944 ;; Hidden thread subtrees must be searched as well.
6945 (gnus-summary-show-all-threads)
6946 ;; We don't want to change current point nor window configuration.
6948 (save-window-excursion
6949 (message "Executing %s..." (key-description command))
6950 ;; We'd like to execute COMMAND interactively so as to give arguments.
6951 (gnus-execute header regexp
6953 (call-interactively '(, (key-binding command)))))
6955 (message "Executing %s... done" (key-description command)))))
6957 (defun gnus-summary-beginning-of-article ()
6958 "Scroll the article back to the beginning."
6960 (gnus-summary-select-article)
6961 (gnus-eval-in-buffer-window
6964 (goto-char (point-min))
6965 (and gnus-break-pages (gnus-narrow-to-page))))
6967 (defun gnus-summary-end-of-article ()
6968 "Scroll to the end of the article."
6970 (gnus-summary-select-article)
6971 (gnus-eval-in-buffer-window
6974 (goto-char (point-max))
6975 (and gnus-break-pages (gnus-narrow-to-page))))
6977 (defun gnus-summary-show-article ()
6978 "Force re-fetching of the current article."
6980 (gnus-summary-select-article gnus-have-all-headers t t))
6982 (defun gnus-summary-toggle-header (arg)
6983 "Show the headers if they are hidden, or hide them if they are shown.
6984 If ARG is a positive number, show the entire header.
6985 If ARG is a negative number, hide the unwanted header lines."
6987 (gnus-set-global-variables)
6989 (set-buffer gnus-article-buffer)
6990 (let ((buffer-read-only nil))
6992 (if (> arg 0) (remove-text-properties 1 (point-max) '(invisible t))
6993 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
6994 (if (text-property-any 1 (point-max) 'invisible t)
6995 (remove-text-properties 1 (point-max) '(invisible t))
6996 (let ((gnus-have-all-headers nil))
6997 (run-hooks 'gnus-article-display-hook)))))))
6999 (defun gnus-summary-show-all-headers ()
7000 "Make all header lines visible."
7002 (gnus-article-show-all-headers))
7004 (defun gnus-summary-toggle-mime (arg)
7005 "Toggle MIME processing.
7006 If ARG is a positive number, turn MIME processing on."
7008 (setq gnus-show-mime
7009 (if (null arg) (not gnus-show-mime)
7010 (> (prefix-numeric-value arg) 0)))
7011 (gnus-summary-select-article t 'force))
7013 (defun gnus-summary-caesar-message (rotnum)
7014 "Caesar rotates all letters of current message by 13/47 places.
7015 With prefix arg, specifies the number of places to rotate each letter forward.
7016 Caesar rotates Japanese letters by 47 places in any case."
7018 (gnus-summary-select-article)
7019 (let ((mail-header-separator "")) ; !!! Is this necessary?
7020 (gnus-overload-functions)
7021 (gnus-eval-in-buffer-window
7025 ;; We don't want to jump to the beginning of the message.
7026 ;; `save-excursion' does not do its job.
7027 (move-to-window-line 0)
7028 (let ((last (point)))
7029 (news-caesar-buffer-body rotnum)
7033 (defun gnus-summary-stop-page-breaking ()
7034 "Stop page breaking in the current article."
7036 (gnus-summary-select-article)
7037 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
7039 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
7041 (defun gnus-summary-move-article (n &optional to-newsgroup select-method)
7042 "Move the current article to a different newsgroup.
7043 If N is a positive number, move the N next articles.
7044 If N is a negative number, move the N previous articles.
7045 If N is nil and any articles have been marked with the process mark,
7046 move those articles instead.
7047 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7048 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
7049 re-spool using this method.
7050 For this function to work, both the current newsgroup and the
7051 newsgroup that you want to move to have to support the `request-move'
7052 and `request-accept' functions. (Ie. mail newsgroups at present.)"
7054 (gnus-set-global-variables)
7055 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
7056 (error "The current newsgroup does not support article moving"))
7057 (let ((articles (gnus-summary-work-articles n))
7059 (if (and (not to-newsgroup) (not select-method))
7062 (format "Where do you want to move %s? "
7063 (if (> (length articles) 1)
7064 (format "these %d articles" (length articles))
7066 gnus-active-hashtb nil t
7067 (gnus-group-real-prefix gnus-newsgroup-name))))
7068 (or (gnus-check-backend-function 'request-accept-article
7069 (or select-method to-newsgroup))
7070 (error "%s does not support article moving" to-newsgroup))
7071 (message "Moving to %s: %s..." (or select-method to-newsgroup) articles)
7074 (gnus-request-move-article
7075 (car articles) ; Article to move
7076 gnus-newsgroup-name ; From newsgrouo
7077 (nth 1 (gnus-find-method-for-group
7078 gnus-newsgroup-name)) ; Server
7079 (list 'gnus-request-accept-article
7081 (quote select-method)
7083 (not (cdr articles))) ; Accept form
7084 (not (cdr articles)))) ; Only save nov last time
7085 (let* ((buffer-read-only nil)
7088 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7090 (gnus-group-prefixed-name
7092 (if select-method (list select-method "")
7093 (gnus-find-method-for-group to-newsgroup)))
7094 gnus-newsrc-hashtb)))
7095 (info (nth 2 entry))
7096 (article (car articles))
7097 (marked (nth 3 info)))
7098 (gnus-summary-goto-subject article)
7099 (delete-region (progn (beginning-of-line) (point))
7100 (progn (forward-line 1) (point)))
7101 (if (not (memq article gnus-newsgroup-unreads))
7102 (setcar (cdr (cdr info))
7103 (gnus-add-to-range (nth 2 info)
7104 (list (cdr art-group)))))
7105 ;; Copy any marks over to the new group.
7106 (let ((marks '((tick . gnus-newsgroup-marked)
7107 (dormant . gnus-newsgroup-dormant)
7108 (expire . gnus-newsgroup-expirable)
7109 (bookmark . gnus-newsgroup-bookmarks)
7110 ; (score . gnus-newsgroup-scored)
7111 (reply . gnus-newsgroup-replied)))
7112 (to-article (cdr art-group)))
7114 (if (memq article (symbol-value (cdr (car marks))))
7115 (gnus-add-marked-articles
7116 (car info) (car (car marks)) (list to-article) info))
7117 (setq marks (cdr marks)))))
7118 (message "Couldn't move article %s" (car articles)))
7119 (gnus-summary-remove-process-mark (car articles))
7120 (setq articles (cdr articles)))))
7122 (defun gnus-summary-respool-article (n &optional respool-method)
7123 "Respool the current article.
7124 The article will be squeezed through the mail spooling process again,
7125 which means that it will be put in some mail newsgroup or other
7126 depending on `nnmail-split-methods'.
7127 If N is a positive number, respool the N next articles.
7128 If N is a negative number, respool the N previous articles.
7129 If N is nil and any articles have been marked with the process mark,
7130 respool those articles instead.
7131 For this function to work, both the current newsgroup and the
7132 newsgroup that you want to move to have to support the `request-move'
7133 and `request-accept' functions. (Ie. mail newsgroups at present.)"
7135 (gnus-set-global-variables)
7137 (setq respool-method
7139 "What method do you want to use when respooling? "
7140 (gnus-methods-using 'respool) nil t)))
7141 (gnus-summary-move-article n nil (intern respool-method)))
7143 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
7144 (defun gnus-summary-copy-article (n &optional to-newsgroup select-method)
7145 "Move the current article to a different newsgroup.
7146 If N is a positive number, move the N next articles.
7147 If N is a negative number, move the N previous articles.
7148 If N is nil and any articles have been marked with the process mark,
7149 move those articles instead.
7150 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7151 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
7152 re-spool using this method.
7153 For this function to work, the newsgroup that you want to move to have
7154 to support the `request-move' and `request-accept'
7155 functions. (Ie. mail newsgroups at present.)"
7157 (gnus-set-global-variables)
7158 (let ((articles (gnus-summary-work-articles n))
7159 (copy-buf (get-buffer-create "*copy work*"))
7161 (buffer-disable-undo copy-buf)
7162 (if (and (not to-newsgroup) (not select-method))
7165 (format "Where do you want to copy %s? "
7166 (if (> (length articles) 1)
7167 (format "these %d articles" (length articles))
7169 gnus-active-hashtb nil t
7170 (gnus-group-real-prefix gnus-newsgroup-name))))
7171 (or (gnus-check-backend-function 'request-accept-article
7172 (or select-method to-newsgroup))
7173 (error "%s does not support article copying" to-newsgroup))
7174 (message "Moving to %s: %s..." (or select-method to-newsgroup) articles)
7178 (set-buffer copy-buf)
7179 (gnus-request-article-this-buffer
7180 (car articles) gnus-newsgroup-name)
7181 (gnus-request-accept-article
7182 (if select-method (quote select-method) to-newsgroup)
7183 (not (cdr articles)))))
7186 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7188 (gnus-group-prefixed-name
7190 (if select-method (list select-method "")
7191 (gnus-find-method-for-group to-newsgroup)))
7192 gnus-newsrc-hashtb)))
7193 (info (nth 2 entry))
7194 (article (car articles))
7195 (marked (nth 3 info)))
7196 (if (not (memq article gnus-newsgroup-unreads))
7197 (setcar (cdr (cdr info))
7198 (gnus-add-to-range (nth 2 info)
7199 (list (cdr art-group)))))
7200 ;; Copy any marks over to the new group.
7201 (let ((marks '((tick . gnus-newsgroup-marked)
7202 (dormant . gnus-newsgroup-dormant)
7203 (expire . gnus-newsgroup-expirable)
7204 (bookmark . gnus-newsgroup-bookmarks)
7205 ; (score . gnus-newsgroup-scored)
7206 (reply . gnus-newsgroup-replied)))
7207 (to-article (cdr art-group)))
7209 (if (memq article (symbol-value (cdr (car marks))))
7210 (gnus-add-marked-articles
7211 (car info) (car (car marks)) (list to-article) info))
7212 (setq marks (cdr marks)))))
7213 (message "Couldn't copy article %s" (car articles)))
7214 (gnus-summary-remove-process-mark (car articles))
7215 (setq articles (cdr articles)))
7216 (kill-buffer copy-buf)))
7218 (defun gnus-summary-expire-articles ()
7219 "Expire all articles that are marked as expirable in the current group."
7221 (if (and gnus-newsgroup-expirable
7222 (gnus-check-backend-function
7223 'request-expire-articles gnus-newsgroup-name))
7224 (let ((expirable gnus-newsgroup-expirable))
7225 ;; The list of articles that weren't expired is returned.
7226 (setq gnus-newsgroup-expirable
7227 (gnus-request-expire-articles gnus-newsgroup-expirable
7228 gnus-newsgroup-name))
7229 ;; We go through the old list of expirable, and mark all
7230 ;; really expired articles as non-existant.
7232 (or (memq (car expirable) gnus-newsgroup-expirable)
7233 (gnus-summary-mark-as-read (car expirable) "%"))
7234 (setq expirable (cdr expirable))))))
7236 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7237 (defun gnus-summary-delete-article (n)
7238 "Delete the N next (mail) articles.
7239 This command actually deletes articles. This is not a marking
7240 command. The article will disappear forever from you life, never to
7242 If N is negative, delete backwards.
7243 If N is nil and articles have been marked with the process mark,
7244 delete these instead."
7246 (or (gnus-check-backend-function 'request-expire-articles
7247 gnus-newsgroup-name)
7248 (error "The current newsgroup does not support article deletion."))
7249 ;; Compute the list of articles to delete.
7250 (let ((articles (gnus-summary-work-articles n)))
7251 (if (and gnus-novice-user
7253 (format "Do you really want to delete %s forever? "
7254 (if (> (length articles) 1) "these articles"
7257 ;; Delete the articles.
7258 (setq gnus-newsgroup-expirable
7259 (gnus-request-expire-articles
7260 articles gnus-newsgroup-name 'force))
7262 (gnus-summary-remove-process-mark (car articles))
7263 ;; The backend might not have been able to delete the article
7265 (or (memq (car articles) gnus-newsgroup-expirable)
7266 (gnus-summary-mark-as-read (car articles) gnus-canceled-mark))
7267 (setq articles (cdr articles))))))
7269 (defun gnus-summary-edit-article ()
7270 "Enter into a buffer and edit the current article.
7271 This will have permanent effect only in mail groups."
7273 (or (gnus-check-backend-function
7274 'request-replace-article gnus-newsgroup-name)
7275 (error "The current newsgroup does not support article editing."))
7276 (gnus-summary-select-article t)
7278 (message "C-c C-c to end edits")
7279 (setq buffer-read-only nil)
7281 (use-local-map (copy-keymap (current-local-map)))
7282 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
7284 (search-forward "\n\n" nil t))
7286 (defun gnus-summary-edit-article-done ()
7287 "Make edits to the current article permanent."
7289 (if (not (gnus-request-replace-article
7290 (cdr gnus-article-current) (car gnus-article-current)
7292 (error "Couldn't replace article.")
7294 (use-local-map gnus-article-mode-map)
7295 (setq buffer-read-only t)
7296 (pop-to-buffer gnus-summary-buffer)))
7298 ;; Summary score commands.
7300 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
7302 (defun gnus-summary-raise-score (n)
7303 "Raise the score of the current article by N."
7305 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
7307 (defun gnus-summary-lower-score (n)
7308 "Lower the score of the current article by N."
7310 (gnus-summary-raise-score (- n)))
7312 (defun gnus-summary-set-score (n)
7313 "Set the score of the current article to N."
7315 ;; Skip dummy header line.
7317 (if (= (gnus-summary-article-mark) ?Z) (forward-line 1))
7318 (let ((buffer-read-only nil))
7320 (gnus-summary-update-mark
7321 (if (= n (or gnus-summary-default-score 0)) ?
7322 (if (< n (or gnus-summary-default-score 0))
7323 gnus-score-below-mark gnus-score-over-mark)) 'score))
7324 (let* ((article (gnus-summary-article-number))
7325 (score (assq article gnus-newsgroup-scored)))
7326 (if score (setcdr score n)
7327 (setq gnus-newsgroup-scored
7328 (cons (cons article n) gnus-newsgroup-scored))))
7329 (gnus-summary-update-line)))
7331 ;; Summary marking commands.
7333 (defun gnus-summary-raise-same-subject-and-select (score)
7334 "Raise articles which has the same subject with SCORE and select the next."
7336 (let ((subject (gnus-summary-subject-string)))
7337 (gnus-summary-raise-score score)
7338 (while (gnus-summary-search-subject nil nil subject)
7339 (gnus-summary-raise-score score))
7340 (gnus-summary-next-article t)))
7342 (defun gnus-summary-raise-same-subject (score)
7343 "Raise articles which has the same subject with SCORE."
7345 (let ((subject (gnus-summary-subject-string)))
7346 (gnus-summary-raise-score score)
7347 (while (gnus-summary-search-subject nil nil subject)
7348 (gnus-summary-raise-score score))
7349 (gnus-summary-next-subject 1 t)))
7351 (defun gnus-summary-raise-thread (score)
7352 "Raise articles under current thread with SCORE."
7356 (let ((level (gnus-summary-thread-level)))
7357 (gnus-summary-raise-score score)
7358 (while (and (zerop (gnus-summary-next-subject 1))
7359 (> (gnus-summary-thread-level) level))
7360 (gnus-summary-raise-score score))
7362 (or (zerop (gnus-summary-next-subject 1 t))
7364 (gnus-summary-position-cursor)
7365 (gnus-set-mode-line 'summary))
7367 (defun gnus-summary-lower-same-subject-and-select (score)
7368 "Raise articles which has the same subject with SCORE and select the next."
7370 (gnus-summary-raise-same-subject-and-select (- score)))
7372 (defun gnus-summary-lower-same-subject (score)
7373 "Raise articles which has the same subject with SCORE."
7375 (gnus-summary-raise-same-subject (- score)))
7377 (defun gnus-summary-lower-thread (score)
7378 "Raise articles under current thread with SCORE."
7380 (gnus-summary-raise-thread (- score)))
7382 (defun gnus-summary-kill-same-subject-and-select (unmark)
7383 "Mark articles which has the same subject as read, and then select the next.
7384 If UNMARK is positive, remove any kind of mark.
7385 If UNMARK is negative, tick articles."
7388 (setq unmark (prefix-numeric-value unmark)))
7390 (gnus-summary-mark-same-subject
7391 (gnus-summary-subject-string) unmark)))
7392 ;; Select next unread article. If auto-select-same mode, should
7393 ;; select the first unread article.
7394 (gnus-summary-next-article t (and gnus-auto-select-same
7395 (gnus-summary-subject-string)))
7396 (message "%d articles are marked as %s"
7397 count (if unmark "unread" "read"))))
7399 (defun gnus-summary-kill-same-subject (unmark)
7400 "Mark articles which has the same subject as read.
7401 If UNMARK is positive, remove any kind of mark.
7402 If UNMARK is negative, tick articles."
7405 (setq unmark (prefix-numeric-value unmark)))
7407 (gnus-summary-mark-same-subject
7408 (gnus-summary-subject-string) unmark)))
7409 ;; If marked as read, go to next unread subject.
7411 ;; Go to next unread subject.
7412 (gnus-summary-next-subject 1 t))
7413 (message "%d articles are marked as %s"
7414 count (if unmark "unread" "read"))))
7416 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7417 "Mark articles with same SUBJECT as read, and return marked number.
7418 If optional argument UNMARK is positive, remove any kinds of marks.
7419 If optional argument UNMARK is negative, mark articles as unread instead."
7422 (cond ((null unmark)
7423 (gnus-summary-mark-as-read nil gnus-killed-mark))
7425 (gnus-summary-tick-article nil t))
7427 (gnus-summary-tick-article)))
7429 (gnus-summary-search-forward nil subject))
7430 (cond ((null unmark)
7431 (gnus-summary-mark-as-read nil gnus-killed-mark))
7433 (gnus-summary-tick-article nil t))
7435 (gnus-summary-tick-article)))
7436 (setq count (1+ count))))
7437 ;; Hide killed thread subtrees. Does not work properly always.
7438 ;;(and (null unmark)
7439 ;; gnus-thread-hide-killed
7440 ;; (gnus-summary-hide-thread))
7441 ;; Return number of articles marked as read.
7444 (defun gnus-summary-mark-as-processable (n &optional unmark)
7445 "Set the process mark on the next N articles.
7446 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7447 the process mark instead. The difference between N and the actual
7448 number of articles marked is returned."
7450 (let ((backward (< n 0))
7455 (gnus-summary-remove-process-mark (gnus-summary-article-number))
7456 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7457 (zerop (gnus-summary-next-subject (if backward -1 1))))
7459 (if (/= 0 n) (message "No more articles"))
7462 (defun gnus-summary-unmark-as-processable (n)
7463 "Remove the process mark from the next N articles.
7464 If N is negative, mark backward instead. The difference between N and
7465 the actual number of articles marked is returned."
7467 (gnus-summary-mark-as-processable n t))
7469 (defun gnus-summary-unmark-all-processable ()
7470 "Remove the process mark from all articles."
7473 (while gnus-newsgroup-processable
7474 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7475 (gnus-summary-position-cursor))
7477 (defun gnus-summary-mark-as-expirable (n)
7478 "Mark N articles forward as expirable.
7479 If N is negative, mark backward instead. The difference between N and
7480 the actual number of articles marked is returned."
7482 (gnus-summary-mark-forward n gnus-expirable-mark))
7484 (defun gnus-summary-mark-article-as-replied (article)
7485 "Mark ARTICLE replied and update the summary line."
7486 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
7487 (let ((buffer-read-only nil))
7488 (if (gnus-summary-goto-subject article)
7490 (gnus-summary-update-mark gnus-replied-mark 'replied)
7493 (defun gnus-summary-set-bookmark (article)
7494 "Set a bookmark in current article."
7495 (interactive (list (gnus-summary-article-number)))
7496 (if (or (not (get-buffer gnus-article-buffer))
7497 (not gnus-current-article)
7498 (not gnus-article-current)
7499 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7500 (error "No current article selected"))
7501 ;; Remove old bookmark, if one exists.
7502 (let ((old (assq article gnus-newsgroup-bookmarks)))
7503 (if old (setq gnus-newsgroup-bookmarks
7504 (delq old gnus-newsgroup-bookmarks))))
7505 ;; Set the new bookmark, which is on the form
7506 ;; (article-number . line-number-in-body).
7507 (setq gnus-newsgroup-bookmarks
7511 (set-buffer gnus-article-buffer)
7516 (search-forward "\n\n" nil t)
7519 gnus-newsgroup-bookmarks))
7520 (message "A bookmark has been added to the current article."))
7522 (defun gnus-summary-remove-bookmark (article)
7523 "Remove the bookmark from the current article."
7524 (interactive (list (gnus-summary-article-number)))
7525 ;; Remove old bookmark, if one exists.
7526 (let ((old (assq article gnus-newsgroup-bookmarks)))
7529 (setq gnus-newsgroup-bookmarks
7530 (delq old gnus-newsgroup-bookmarks))
7531 (message "Removed bookmark."))
7532 (message "No bookmark in current article."))))
7534 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7535 (defun gnus-summary-mark-as-dormant (n)
7536 "Mark N articles forward as dormant.
7537 If N is negative, mark backward instead. The difference between N and
7538 the actual number of articles marked is returned."
7540 (gnus-summary-mark-forward n gnus-dormant-mark))
7542 (defun gnus-summary-set-process-mark (article)
7543 "Set the process mark on ARTICLE and update the summary line."
7544 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
7545 (let ((buffer-read-only nil))
7546 (if (gnus-summary-goto-subject article)
7548 (if (= (gnus-summary-article-mark) ?Z) (forward-line 1))
7549 (gnus-summary-update-mark gnus-process-mark 'replied)
7552 (defun gnus-summary-remove-process-mark (article)
7553 "Remove the process mark from ARTICLE and update the summary line."
7554 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7555 (let ((buffer-read-only nil))
7556 (if (gnus-summary-goto-subject article)
7558 (and (= (gnus-summary-article-mark) ?Z) (forward-line 1))
7559 (gnus-summary-update-mark ? 'replied)
7560 (if (memq article gnus-newsgroup-replied)
7561 (gnus-summary-update-mark gnus-replied-mark 'replied))
7564 (defun gnus-summary-mark-forward (n &optional mark)
7565 "Mark N articles as read forwards.
7566 If N is negative, mark backwards instead.
7567 Mark with MARK. If MARK is ? , ?! or ??, articles will be
7569 The difference between N and the actual number of articles marked is
7572 (gnus-set-global-variables)
7573 (let ((backward (< n 0))
7575 (mark (or mark gnus-dread-mark)))
7577 (gnus-summary-mark-article nil mark)
7578 (zerop (gnus-summary-next-subject
7579 (if backward -1 1) gnus-summary-goto-unread)))
7581 (if (/= 0 n) (message "No more %sarticles" (if mark "" "unread ")))
7582 (gnus-set-mode-line 'summary)
7585 (defun gnus-summary-mark-article (&optional article mark)
7586 "Mark ARTICLE with MARK.
7587 MARK can be any character.
7588 Five MARK strings are reserved: ? (unread),
7589 ?! (ticked), ?? (dormant), ?D (read), ?E (expirable).
7590 If MARK is nil, then the default character ?D is used.
7591 If ARTICLE is nil, then the article on the current line will be
7593 ;; If no mark is given, then we check auto-expiring.
7595 (and (numberp mark) (or (= mark gnus-killed-mark)
7596 (= mark gnus-dread-mark)
7597 (= mark gnus-catchup-mark)
7598 (= mark gnus-low-score-mark)
7599 (= mark gnus-read-mark))))
7600 gnus-newsgroup-auto-expire
7601 (setq mark gnus-expirable-mark))
7602 (let* ((buffer-read-only nil)
7603 (mark (or (and (stringp mark) (aref mark 0)) mark gnus-dread-mark))
7604 (article (or article (gnus-summary-article-number))))
7605 (if (or (= mark gnus-unread-mark)
7606 (= mark gnus-ticked-mark)
7607 (= mark gnus-dormant-mark))
7608 (gnus-mark-article-as-unread article mark)
7609 (gnus-mark-article-as-read article mark))
7610 (if (gnus-summary-goto-subject article)
7612 (gnus-summary-show-thread)
7614 (if (= (gnus-summary-article-mark) ?Z) (forward-line 1))
7616 (gnus-summary-update-mark mark 'unread)
7619 (defun gnus-summary-update-mark (mark type)
7621 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7625 (forward-char forward)
7626 (setq plist (text-properties-at (point)))
7628 (and (memq 'gnus-mark plist) (setcar (cdr (memq 'gnus-mark plist)) mark))
7630 (and plist (add-text-properties (1- (point)) (point) plist))
7631 (gnus-summary-update-line (eq mark gnus-unread-mark)))))
7633 (defun gnus-mark-article-as-read (article &optional mark)
7634 "Enter ARTICLE in the pertinent lists and remove it from others."
7635 ;; Make the article expirable.
7636 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-dread-mark)))
7637 (if (= mark gnus-expirable-mark)
7638 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
7639 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7640 ;; Remove from unread and marked lists.
7641 (setq gnus-newsgroup-unreads
7642 (delq article gnus-newsgroup-unreads))
7643 (setq gnus-newsgroup-marked
7644 (delq article gnus-newsgroup-marked))
7645 (setq gnus-newsgroup-dormant
7646 (delq article gnus-newsgroup-dormant))))
7648 (defun gnus-mark-article-as-unread (article &optional mark)
7649 "Enter ARTICLE in the pertinent lists and remove it from others."
7650 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-ticked-mark)))
7651 ;; Add to unread list.
7652 (or (memq article gnus-newsgroup-unreads)
7653 (setq gnus-newsgroup-unreads
7654 (cons article gnus-newsgroup-unreads)))
7655 ;; If CLEAR-MARK is non-nil, the article must be removed from marked
7656 ;; list. Otherwise, it must be added to the list.
7657 (setq gnus-newsgroup-marked
7658 (delq article gnus-newsgroup-marked))
7659 (setq gnus-newsgroup-dormant
7660 (delq article gnus-newsgroup-dormant))
7661 (setq gnus-newsgroup-expirable
7662 (delq article gnus-newsgroup-expirable))
7663 (if (= mark gnus-ticked-mark)
7664 (setq gnus-newsgroup-marked
7665 (cons article gnus-newsgroup-marked)))
7666 (if (= mark gnus-dormant-mark)
7667 (setq gnus-newsgroup-dormant
7668 (cons article gnus-newsgroup-dormant)))))
7670 (defalias 'gnus-summary-mark-as-unread-forward
7671 'gnus-summary-tick-article-forward)
7672 (make-obsolete 'gnus-summary-mark-as-unread-forward
7673 'gnus-summary-tick-article-forward)
7674 (defun gnus-summary-tick-article-forward (n)
7675 "Tick N articles forwards.
7676 If N is negative, tick backwards instead.
7677 The difference between N and the number of articles ticked is returned."
7679 (gnus-summary-mark-forward n gnus-ticked-mark))
7681 (defalias 'gnus-summary-mark-as-unread-backward
7682 'gnus-summary-tick-article-backward)
7683 (make-obsolete 'gnus-summary-mark-as-unread-backward
7684 'gnus-summary-tick-article-backward)
7685 (defun gnus-summary-tick-article-backward (n)
7686 "Tick N articles backwards.
7687 The difference between N and the number of articles ticked is returned."
7689 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7691 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7692 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7693 (defun gnus-summary-tick-article (&optional article clear-mark)
7694 "Mark current article as unread.
7695 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7696 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7697 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7700 (defun gnus-summary-mark-as-read-forward (n)
7701 "Mark N articles as read forwards.
7702 If N is negative, mark backwards instead.
7703 The difference between N and the actual number of articles marked is
7706 (gnus-summary-mark-forward n))
7708 (defun gnus-summary-mark-as-read-backward (n)
7709 "Mark the N articles as read backwards.
7710 The difference between N and the actual number of articles marked is
7713 (gnus-summary-mark-forward (- n)))
7715 (defun gnus-summary-mark-as-read (&optional article mark)
7716 "Mark current article as read.
7717 ARTICLE specifies the article to be marked as read.
7718 MARK specifies a string to be inserted at the beginning of the line.
7719 Any kind of string (length 1) except for a space and `-' is ok."
7720 (gnus-summary-mark-article article mark))
7722 (defun gnus-summary-clear-mark-forward (n)
7723 "Clear marks from N articles forward.
7724 If N is negative, clear backward instead.
7725 The difference between N and the number of marks cleared is returned."
7727 (gnus-summary-mark-forward n gnus-unread-mark))
7729 (defun gnus-summary-clear-mark-backward (n)
7730 "Clear marks from N articles backward.
7731 The difference between N and the number of marks cleared is returned."
7733 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7735 (defun gnus-summary-mark-unread-as-read ()
7736 "Intended to be used by `gnus-summary-mark-article-hook'."
7737 (or (memq gnus-current-article gnus-newsgroup-marked)
7738 (memq gnus-current-article gnus-newsgroup-dormant)
7739 (memq gnus-current-article gnus-newsgroup-expirable)
7740 (gnus-summary-mark-as-read gnus-current-article gnus-read-mark)))
7742 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
7743 (defalias 'gnus-summary-delete-marked-as-read
7744 'gnus-summary-remove-lines-marked-as-read)
7745 (make-obsolete 'gnus-summary-delete-marked-as-read
7746 'gnus-summary-remove-lines-marked-as-read)
7747 (defun gnus-summary-remove-lines-marked-as-read ()
7748 "Remove lines that are marked as read."
7750 (gnus-summary-remove-lines-marked-with
7752 (lambda (char) (char-to-string (symbol-value char)))
7753 '(gnus-dread-mark gnus-read-mark
7754 gnus-killed-mark gnus-kill-file-mark
7755 gnus-low-score-mark gnus-expirable-mark)
7758 (defalias 'gnus-summary-delete-marked-with
7759 'gnus-summary-remove-lines-marked-with)
7760 (make-obsolete 'gnus-summary-delete-marked-with
7761 'gnus-summary-remove-lines-marked-with)
7762 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
7763 (defun gnus-summary-remove-lines-marked-with (marks)
7764 "Remove lines that are marked with MARKS (e.g. \"DK\")."
7765 (interactive "sMarks: ")
7766 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
7768 (set-buffer gnus-summary-buffer)
7769 (let ((buffer-read-only nil)
7770 (marks (concat "^[" marks "]")))
7771 (goto-char (point-min))
7772 (while (search-forward-regexp marks (point-max) t)
7773 (delete-region (progn (beginning-of-line) (point))
7774 (progn (forward-line 1) (point)))))
7775 (or (zerop (buffer-size))
7777 (gnus-summary-prev-subject 1)
7778 (gnus-summary-position-cursor)))))
7780 (defun gnus-summary-expunge-below (score)
7781 "Remove articles with score less than SCORE."
7783 (setq score (if score
7784 (prefix-numeric-value score)
7785 (or gnus-summary-default-score 0)))
7787 (set-buffer gnus-summary-buffer)
7788 (goto-char (point-min))
7789 (let ((buffer-read-only nil)
7792 (if (< (gnus-summary-article-score) score)
7796 (delete-region beg (point)))
7799 (or (zerop (buffer-size))
7801 (gnus-summary-prev-subject 1)
7802 (gnus-summary-position-cursor))))))
7804 (defun gnus-summary-mark-below (score mark)
7805 "Mark articles with score less than SCORE with MARK."
7806 (interactive "P\ncMark: ")
7807 (setq score (if score
7808 (prefix-numeric-value score)
7809 (or gnus-summary-default-score 0)))
7811 (set-buffer gnus-summary-buffer)
7812 (goto-char (point-min))
7814 (and (< (gnus-summary-article-score) score)
7815 (gnus-summary-mark-article nil mark))
7818 (defun gnus-summary-kill-below (score)
7819 "Mark articles with score below SCORE as read."
7821 (gnus-summary-mark-below score gnus-killed-mark))
7823 (defun gnus-summary-clear-above (score)
7824 "Clear all marks from articles with score above SCORE."
7826 (gnus-summary-mark-above score gnus-unread-mark))
7828 (defun gnus-summary-tick-above (score)
7829 "Tick all articles with score above SCORE."
7831 (gnus-summary-mark-above score gnus-ticked-mark))
7833 (defun gnus-summary-mark-above (score mark)
7834 "Mark articles with score over SCORE with MARK."
7835 (interactive "P\ncMark: ")
7836 (setq score (if score
7837 (prefix-numeric-value score)
7838 (or gnus-summary-default-score 0)))
7840 (set-buffer gnus-summary-buffer)
7841 (goto-char (point-min))
7843 (if (> (gnus-summary-article-score) score)
7845 (gnus-summary-mark-article nil mark)
7847 (forward-line 1)))))
7849 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7850 (defun gnus-summary-show-all-expunged ()
7851 "Display all the hidden articles that were expunged for low scores."
7853 (let ((buffer-read-only nil))
7854 (let ((scored gnus-newsgroup-scored)
7857 (or (gnus-summary-goto-subject (car (car scored)))
7858 (and (setq h (gnus-get-header-by-number (car (car scored))))
7859 (< (cdr (car scored)) gnus-summary-expunge-below)
7860 (setq headers (cons h headers))))
7861 (setq scored (cdr scored)))
7862 (or headers (error "No expunged articles hidden."))
7863 (goto-char (point-min))
7865 (gnus-summary-prepare-threads (nreverse headers) 0)))
7866 (goto-char (point-min))
7867 (gnus-summary-position-cursor)))
7869 (defun gnus-summary-show-all-dormant ()
7870 "Display all the hidden articles that are marked as dormant."
7872 (let ((buffer-read-only nil))
7873 (goto-char (point-min))
7874 (let ((dormant gnus-newsgroup-dormant)
7877 (or (gnus-summary-goto-subject (car dormant))
7878 (and (setq h (gnus-get-header-by-number (car dormant)))
7879 (setq headers (cons h headers))))
7880 (setq dormant (cdr dormant)))
7881 (or headers (error "No dormant articles hidden."))
7882 (save-excursion (gnus-summary-prepare-threads (nreverse headers) 0)))
7883 (goto-char (point-min))
7884 (gnus-summary-position-cursor)))
7886 (defun gnus-summary-hide-all-dormant ()
7887 "Hide all dormant articles."
7889 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
7890 (gnus-summary-position-cursor))
7892 (defun gnus-summary-catchup (all &optional quietly to-here)
7893 "Mark all articles not marked as unread in this newsgroup as read.
7894 If prefix argument ALL is non-nil, all articles are marked as read.
7895 If QUIETLY is non-nil, no questions will be asked.
7896 If TO-HERE is non-nil, it should be a point in the buffer. All
7897 articles before this point will be marked as read.
7898 The number of articles marked as read is returned."
7902 (not gnus-interactive-catchup) ;Without confirmation?
7906 "Mark absolutely all articles as read? "
7907 "Mark all unread articles as read? ")))
7908 (let ((unreads (length gnus-newsgroup-unreads)))
7909 (if (gnus-summary-first-subject (not all))
7910 (while (and (gnus-summary-mark-as-read nil gnus-catchup-mark)
7911 (if to-here (< (point) to-here) t)
7912 (gnus-summary-search-subject nil (not all)))))
7913 (- unreads (length gnus-newsgroup-unreads))))
7914 (setq gnus-newsgroup-unreads gnus-newsgroup-marked)
7915 (gnus-summary-position-cursor)))
7917 (defun gnus-summary-catchup-to-here (&optional all)
7918 "Mark all unticked articles before the current one as read.
7919 If ALL is non-nil, also mark ticked and dormant articles as read."
7922 (gnus-summary-catchup all t (point))
7923 (gnus-summary-position-cursor))
7925 (defun gnus-summary-catchup-all (&optional quietly)
7926 "Mark all articles in this newsgroup as read."
7928 (gnus-summary-catchup t quietly))
7930 (defun gnus-summary-catchup-and-exit (all &optional quietly)
7931 "Mark all articles not marked as unread in this newsgroup as read, then exit.
7932 If prefix argument ALL is non-nil, all articles are marked as read."
7934 (gnus-summary-catchup all quietly)
7935 ;; Select next newsgroup or exit.
7936 (if (eq gnus-auto-select-next 'quietly)
7937 (gnus-summary-next-group nil)
7938 (gnus-summary-exit)))
7940 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
7941 "Mark all articles in this newsgroup as read, and then exit."
7943 (gnus-summary-catchup-and-exit t quietly))
7945 ;; Thread-based commands.
7947 (defun gnus-summary-toggle-threads (arg)
7948 "Toggle showing conversation threads.
7949 If ARG is positive number, turn showing conversation threads on."
7951 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
7952 (setq gnus-show-threads
7953 (if (null arg) (not gnus-show-threads)
7954 (> (prefix-numeric-value arg) 0)))
7955 (gnus-summary-prepare)
7956 (gnus-summary-goto-subject current)
7957 (gnus-summary-position-cursor)))
7959 (defun gnus-summary-show-all-threads ()
7963 (let ((buffer-read-only nil))
7964 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
7965 (gnus-summary-position-cursor))
7967 (defun gnus-summary-show-thread ()
7968 "Show thread subtrees.
7969 Returns nil if no thread was there to be shown."
7973 (let ((buffer-read-only nil)
7974 (beg (progn (beginning-of-line) (point)))
7975 (end (save-excursion (end-of-line) (point))))
7977 ;; Any hidden lines here?
7978 (search-forward "\r" end t)
7979 (subst-char-in-region beg end ?\^M ?\n t))))
7980 (gnus-summary-position-cursor)))
7982 (defun gnus-summary-hide-all-threads ()
7983 "Hide all thread subtrees."
7986 (goto-char (point-min))
7987 (gnus-summary-hide-thread)
7988 (while (and (not (eobp)) (zerop (forward-line 1)))
7989 (gnus-summary-hide-thread)))
7990 (gnus-summary-position-cursor))
7992 (defun gnus-summary-hide-thread ()
7993 "Hide thread subtrees.
7994 Returns nil if no threads were there to be hidden."
7996 (let ((buffer-read-only nil)
7998 (level (gnus-summary-thread-level))
8000 ;; Go forward until either the buffer ends or the subthread
8004 (while (and (zerop (forward-line 1))
8005 (> (gnus-summary-thread-level) level))
8010 (search-backward "\n" start t))
8011 (subst-char-in-region start end ?\n ?\^M t)
8012 (forward-line -1)))))
8014 (defun gnus-summary-go-to-next-thread (&optional previous)
8015 "Go to the same level (or less) next thread.
8016 If PREVIOUS is non-nil, go to previous thread instead.
8017 Return the article number moved to, or nil if moving was impossible."
8018 (let ((level (gnus-summary-thread-level))
8019 (article (gnus-summary-article-number)))
8021 (while (and (zerop (gnus-summary-prev-subject 1))
8022 (> (gnus-summary-thread-level) level)))
8023 (while (and (zerop (gnus-summary-next-subject 1))
8024 (> (gnus-summary-thread-level) level))))
8025 (let ((oart (gnus-summary-article-number)))
8026 (and (/= oart article) oart))))
8028 (defun gnus-summary-next-thread (n)
8029 "Go to the same level next N'th thread.
8030 If N is negative, search backward instead.
8031 Returns the difference between N and the number of skips actually
8034 (let ((backward (< n 0))
8037 (gnus-summary-go-to-next-thread backward))
8039 (gnus-summary-position-cursor)
8040 (if (/= 0 n) (message "No more threads"))
8043 (defun gnus-summary-prev-thread (n)
8044 "Go to the same level previous N'th thread.
8045 Returns the difference between N and the number of skips actually
8048 (gnus-summary-next-thread (- n)))
8050 (defun gnus-summary-go-down-thread (&optional same)
8051 "Go down one level in the current thread.
8052 If SAME is non-nil, also move to articles of the same level."
8053 (let ((level (gnus-summary-thread-level))
8055 (if (and (zerop (forward-line 1))
8056 (> (gnus-summary-thread-level) level))
8061 (defun gnus-summary-go-up-thread ()
8062 "Go up one level in the current thread."
8063 (let ((level (gnus-summary-thread-level))
8065 (while (and (zerop (forward-line -1))
8066 (>= (gnus-summary-thread-level) level)))
8067 (if (>= (gnus-summary-thread-level) level)
8073 (defun gnus-summary-down-thread (n)
8074 "Go down thread N steps.
8075 If N is negative, go up instead.
8076 Returns the difference between N and how many steps down that were
8082 (if up (gnus-summary-go-up-thread)
8083 (gnus-summary-go-down-thread)))
8085 (gnus-summary-position-cursor)
8086 (if (/= 0 n) (message "Can't go further"))
8089 (defun gnus-summary-up-thread (n)
8090 "Go up thread N steps.
8091 If N is negative, go up instead.
8092 Returns the difference between N and how many steps down that were
8095 (gnus-summary-down-thread (- n)))
8097 (defun gnus-summary-kill-thread (unmark)
8098 "Mark articles under current thread as read.
8099 If the prefix argument is positive, remove any kinds of marks.
8100 If the prefix argument is negative, tick articles instead."
8103 (setq unmark (prefix-numeric-value unmark)))
8105 (level (gnus-summary-thread-level)))
8108 ;; Mark the article...
8109 (cond ((null unmark) (gnus-summary-mark-as-read nil gnus-killed-mark))
8110 ((> unmark 0) (gnus-summary-tick-article nil t))
8111 (t (gnus-summary-tick-article)))
8112 ;; ...and go forward until either the buffer ends or the subtree
8114 (if (not (and (zerop (forward-line 1))
8115 (> (gnus-summary-thread-level) level)))
8116 (setq killing nil))))
8117 ;; Hide killed subtrees.
8119 gnus-thread-hide-killed
8120 (gnus-summary-hide-thread))
8121 ;; If marked as read, go to next unread subject.
8123 ;; Go to next unread subject.
8124 (gnus-summary-next-subject 1 t)))
8125 (gnus-set-mode-line 'summary))
8127 ;; Summary sorting commands
8129 (defun gnus-summary-sort-by-number (reverse)
8130 "Sort summary buffer by article number.
8131 Argument REVERSE means reverse order."
8134 (cons 'gnus-summary-article-number 'gnus-thread-sort-by-number) reverse))
8136 (defun gnus-summary-sort-by-author (reverse)
8137 "Sort summary buffer by author name alphabetically.
8138 If case-fold-search is non-nil, case of letters is ignored.
8139 Argument REVERSE means reverse order."
8144 (let ((extract (funcall
8145 gnus-extract-address-components
8146 (header-from (gnus-get-header-by-number
8147 (gnus-summary-article-number))))))
8148 (or (car extract) (cdr extract))))
8149 'gnus-thread-sort-by-author)
8152 (defun gnus-summary-sort-by-subject (reverse)
8153 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
8154 If case-fold-search is non-nil, case of letters is ignored.
8155 Argument REVERSE means reverse order."
8160 (downcase (gnus-simplify-subject (gnus-summary-subject-string))))
8161 'gnus-thread-sort-by-subject)
8164 (defun gnus-summary-sort-by-date (reverse)
8165 "Sort summary buffer by date.
8166 Argument REVERSE means reverse order."
8173 (gnus-get-header-by-number (gnus-summary-article-number)))))
8174 'gnus-thread-sort-by-date)
8177 (defun gnus-summary-sort-by-score (reverse)
8178 "Sort summary buffer by score.
8179 Argument REVERSE means reverse order."
8182 (cons 'gnus-summary-article-score 'gnus-thread-sort-by-score)
8185 (defun gnus-summary-sort (predicate reverse)
8186 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
8187 (let (buffer-read-only)
8188 (if (not gnus-show-threads)
8190 (goto-char (point-min))
8191 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
8192 (let ((gnus-thread-sort-functions (list (cdr predicate))))
8193 (gnus-summary-prepare)))))
8195 (defun gnus-sortable-date (date)
8196 "Make sortable string by string-lessp from DATE.
8197 Timezone package is used."
8198 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
8199 (year (aref date 0))
8200 (month (aref date 1))
8201 (day (aref date 2)))
8202 (timezone-make-sortable-date
8204 (timezone-make-time-string
8205 (aref date 3) (aref date 4) (aref date 5)))))
8208 ;; Summary saving commands.
8210 (defun gnus-summary-save-article (n)
8211 "Save the current article using the default saver function.
8212 If N is a positive number, save the N next articles.
8213 If N is a negative number, save the N previous articles.
8214 If N is nil and any articles have been marked with the process mark,
8215 save those articles instead.
8216 The variable `gnus-default-article-saver' specifies the saver function."
8218 (let (articles process)
8219 (if (and n (numberp n))
8220 (let ((backward (< n 0))
8224 (setq articles (cons (gnus-summary-article-number)
8226 (gnus-summary-search-forward nil nil backward))
8228 (setq articles (sort articles (function <))))
8229 (if gnus-newsgroup-processable
8231 (setq articles (setq gnus-newsgroup-processable
8232 (nreverse gnus-newsgroup-processable)))
8234 (setq articles (list (gnus-summary-article-number)))))
8236 (let ((header (gnus-gethash (int-to-string (car articles))
8237 gnus-newsgroup-headers-hashtb-by-number)))
8238 (if (vectorp header)
8240 (gnus-summary-display-article (car articles) t)
8241 (if (not gnus-save-all-headers)
8242 (gnus-article-hide-headers t))
8243 (if gnus-default-article-saver
8244 (funcall gnus-default-article-saver)
8245 (error "No default saver is defined.")))
8246 (if (assq 'name header)
8247 (gnus-copy-file (cdr (assq 'name header)))
8248 (message "Article %d is unsaveable" (car articles)))))
8250 (gnus-summary-remove-process-mark (car articles)))
8251 (setq articles (cdr articles)))
8252 (if process (setq gnus-newsgroup-processable
8253 (nreverse gnus-newsgroup-processable)))
8254 (gnus-summary-position-cursor)
8257 (defun gnus-summary-pipe-output (arg)
8258 "Pipe the current article to a subprocess.
8259 If N is a positive number, pipe the N next articles.
8260 If N is a negative number, pipe the N previous articles.
8261 If N is nil and any articles have been marked with the process mark,
8262 pipe those articles instead."
8264 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8265 (gnus-summary-save-article arg)))
8267 (defun gnus-summary-save-article-mail (arg)
8268 "Append the current article to an mail file.
8269 If N is a positive number, save the N next articles.
8270 If N is a negative number, save the N previous articles.
8271 If N is nil and any articles have been marked with the process mark,
8272 save those articles instead."
8274 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8275 (gnus-summary-save-article arg)))
8277 (defun gnus-summary-save-article-rmail (arg)
8278 "Append the current article to an rmail file.
8279 If N is a positive number, save the N next articles.
8280 If N is a negative number, save the N previous articles.
8281 If N is nil and any articles have been marked with the process mark,
8282 save those articles instead."
8284 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8285 (gnus-summary-save-article arg)))
8287 (defun gnus-summary-save-article-file (arg)
8288 "Append the current article to a file.
8289 If N is a positive number, save the N next articles.
8290 If N is a negative number, save the N previous articles.
8291 If N is nil and any articles have been marked with the process mark,
8292 save those articles instead."
8294 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8295 (gnus-summary-save-article arg)))
8297 (defun gnus-summary-save-article-folder (arg)
8298 "Append the current article to an mh folder.
8299 If N is a positive number, save the N next articles.
8300 If N is a negative number, save the N previous articles.
8301 If N is nil and any articles have been marked with the process mark,
8302 save those articles instead."
8304 (let ((gnus-default-article-saver 'gnus-summary-save-in-folder))
8305 (gnus-summary-save-article arg)))
8307 (defun gnus-summary-save-in-rmail (&optional filename)
8308 "Append this article to Rmail file.
8309 Optional argument FILENAME specifies file name.
8310 Directory to save to is default to `gnus-article-save-directory' which
8311 is initialized from the SAVEDIR environment variable."
8314 (funcall gnus-rmail-save-name gnus-newsgroup-name
8315 gnus-current-headers gnus-newsgroup-last-rmail)))
8319 (concat "Save article in rmail file: (default "
8320 (file-name-nondirectory default-name) ") ")
8321 (file-name-directory default-name)
8323 (gnus-make-directory (file-name-directory filename))
8324 (gnus-eval-in-buffer-window
8329 (gnus-output-to-rmail filename))))
8330 ;; Remember the directory name to save articles.
8331 (setq gnus-newsgroup-last-rmail filename)))
8333 (defun gnus-summary-save-in-mail (&optional filename)
8334 "Append this article to Unix mail file.
8335 Optional argument FILENAME specifies file name.
8336 Directory to save to is default to `gnus-article-save-directory' which
8337 is initialized from the SAVEDIR environment variable."
8340 (funcall gnus-mail-save-name gnus-newsgroup-name
8341 gnus-current-headers gnus-newsgroup-last-mail)))
8345 (concat "Save article in Unix mail file: (default "
8346 (file-name-nondirectory default-name) ") ")
8347 (file-name-directory default-name)
8350 (expand-file-name filename
8352 (file-name-directory default-name))))
8353 (gnus-make-directory (file-name-directory filename))
8354 (gnus-eval-in-buffer-window
8359 (if (and (file-readable-p filename) (rmail-file-p filename))
8360 (gnus-output-to-rmail filename)
8361 (rmail-output filename 1 t t)))))
8362 ;; Remember the directory name to save articles.
8363 (setq gnus-newsgroup-last-mail filename)))
8365 (defun gnus-summary-save-in-file (&optional filename)
8366 "Append this article to file.
8367 Optional argument FILENAME specifies file name.
8368 Directory to save to is default to `gnus-article-save-directory' which
8369 is initialized from the SAVEDIR environment variable."
8372 (funcall gnus-file-save-name gnus-newsgroup-name
8373 gnus-current-headers gnus-newsgroup-last-file)))
8377 (concat "Save article in file: (default "
8378 (file-name-nondirectory default-name) ") ")
8379 (file-name-directory default-name)
8381 (gnus-make-directory (file-name-directory filename))
8382 (gnus-eval-in-buffer-window
8387 (gnus-output-to-file filename))))
8388 ;; Remember the directory name to save articles.
8389 (setq gnus-newsgroup-last-file filename)))
8391 (defun gnus-summary-save-in-pipe (&optional command)
8392 "Pipe this article to subprocess."
8394 (let ((command (read-string "Shell command on article: "
8395 gnus-last-shell-command)))
8396 (if (string-equal command "")
8397 (setq command gnus-last-shell-command))
8398 (gnus-eval-in-buffer-window
8402 (shell-command-on-region (point-min) (point-max) command nil)))
8403 (setq gnus-last-shell-command command)))
8405 ;; Summary extract commands
8407 (defun gnus-summary-insert-pseudos (pslist)
8408 (let ((buffer-read-only nil)
8409 (article (gnus-summary-article-number))
8411 (or (gnus-summary-goto-subject article)
8412 (error (format "No such article: %d" article)))
8413 (gnus-summary-position-cursor)
8414 (if gnus-view-pseudos
8416 (and (assq 'execute (car pslist))
8417 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8418 (eq gnus-view-pseudos 'not-confirm)))
8419 (setq pslist (cdr pslist)))
8422 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
8423 (gnus-summary-article-number)))
8426 (insert " " (file-name-nondirectory
8427 (cdr (assq 'name (car pslist))))
8428 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8429 (add-text-properties
8430 b (1+ b) (list 'gnus-subject (cdr (assq 'name (car pslist)))
8431 'gnus-number gnus-reffed-article-number
8432 'gnus-mark gnus-unread-mark
8433 'gnus-pseudo (car pslist)
8435 (gnus-sethash (int-to-string gnus-reffed-article-number)
8436 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
8437 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8438 (setq pslist (cdr pslist)))))))
8440 (defun gnus-request-pseudo-article (props)
8441 (cond ((assq 'execute props)
8442 (gnus-execute-command (cdr (assq 'execute props)))))
8443 (let ((gnus-current-article (gnus-summary-article-number)))
8444 (run-hooks 'gnus-mark-article-hook)))
8446 (defun gnus-execute-command (command &optional automatic)
8448 (gnus-article-setup-buffer)
8449 (set-buffer gnus-article-buffer)
8450 (let ((command (if automatic command (read-string "Command: " command)))
8451 (buffer-read-only nil))
8453 (insert "$ " command "\n\n")
8454 (if gnus-view-pseudo-asynchronously
8455 (start-process "gnus-execute" nil "sh" "-c" command)
8456 (call-process "sh" nil t nil "-c" command)))))
8458 (defun gnus-copy-file (file &optional to)
8461 (list (read-file-name "Copy file: " default-directory)
8462 (read-file-name "Copy file to: " default-directory)))
8463 (or to (setq to (read-file-name "Copy file to: " default-directory)))
8464 (and (file-directory-p to)
8465 (setq to (concat (file-name-as-directory to)
8466 (file-name-nondirectory file))))
8467 (copy-file file to))
8469 ;; Summary score file commands
8471 ;; Much modification of the kill (ahem, score) code and lots of the
8472 ;; functions are written by Per Abrahamsen <amanda@iesd.auc.dk>.
8474 (defun gnus-summary-header (header)
8475 ;; Return HEADER for current articles, or error.
8476 (let ((article (gnus-summary-article-number)))
8478 (aref (gnus-get-header-by-number article)
8479 (nth 1 (assoc header gnus-header-index)))
8480 (error "No article on current line"))))
8482 (defun gnus-summary-score-entry (header match type score date &optional prompt)
8483 "Enter score file entry.
8484 HEADER is the header being scored.
8485 MATCH is the string we are looking for.
8486 TYPE is a flag indicating if it is a regexp or substring.
8487 SCORE is the score to add.
8488 DATE is the expire date."
8490 (list (completing-read "Header: "
8492 (lambda (x) (fboundp (nth 2 x)))
8494 (read-string "Match: ")
8495 (y-or-n-p "Use regexp match? ")
8496 (prefix-numeric-value current-prefix-arg)
8497 (if (y-or-n-p "Expire kill? ")
8498 (current-time-string)
8500 (and prompt (setq match (read-string "Match: " match)))
8501 (let ((score (gnus-score-default score)))
8502 (gnus-summary-score-effect header match type score)
8503 (and (= score gnus-score-interactive-default-score)
8505 (let ((new (cond (type
8506 (list match score (and date (gnus-day-number date)) type))
8508 (list match score (gnus-day-number date)))
8513 (old (gnus-score-get header)))
8516 (if old (cons new old) (list new))))
8517 (gnus-score-set 'touched '(t))))
8519 (defun gnus-summary-score-effect (header match type score)
8520 "Simulate the effect of a score file entry.
8521 HEADER is the header being scored.
8522 MATCH is the string we are looking for.
8523 TYPE is a flag indicating if it is a regexp or substring.
8524 SCORE is the score to add."
8525 (interactive (list (completing-read "Header: "
8527 (lambda (x) (fboundp (nth 2 x)))
8529 (read-string "Match: ")
8530 (y-or-n-p "Use regexp match? ")
8531 (prefix-numeric-value current-prefix-arg)))
8533 (or (and (stringp match) (> (length match) 0))
8535 (goto-char (point-min))
8536 (let ((regexp (if type
8538 (concat "\\`.*" (regexp-quote match) ".*\\'"))))
8540 (let ((content (gnus-summary-header header))
8541 (case-fold-search t))
8543 (if (string-match regexp content)
8544 (gnus-summary-raise-score score))))
8545 (beginning-of-line 2)))))
8547 (defun gnus-summary-score-crossposting (score date)
8548 ;; Enter score file entry for current crossposting.
8549 ;; SCORE is the score to add.
8550 ;; DATE is the expire date.
8551 (let ((xref (gnus-summary-header "xref"))
8554 (or xref (error "This article is not crossposted"))
8555 (while (string-match " \\([^ \t]+\\):" xref start)
8556 (setq start (match-end 0))
8559 (substring xref (match-beginning 1) (match-end 1)))
8560 gnus-newsgroup-name))
8561 (gnus-summary-score-entry
8562 "xref" (concat " " group ":") nil score date t)))))
8564 (defun gnus-summary-temporarily-lower-by-subject (level)
8565 "Temporarily lower score by LEVEL for current subject.
8566 See `gnus-score-expiry-days'."
8568 (gnus-summary-score-entry
8569 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
8570 nil (- (gnus-score-default level))
8571 (current-time-string) t))
8573 (defun gnus-summary-temporarily-lower-by-author (level)
8574 "Temporarily lower score by LEVEL for current author.
8575 See `gnus-score-expiry-days'."
8577 (gnus-summary-score-entry
8578 "from" (gnus-summary-header "from") nil (- (gnus-score-default level))
8579 (current-time-string) t))
8581 (defun gnus-summary-temporarily-lower-by-id (level)
8582 "Temporarily lower score by LEVEL for current message-id.
8583 See `gnus-score-expiry-days'."
8585 (gnus-summary-score-entry
8586 "message-id" (gnus-summary-header "message-id")
8587 nil (- (gnus-score-default level))
8588 (current-time-string)))
8590 (defun gnus-summary-temporarily-lower-by-xref (level)
8591 "Temporarily lower score by LEVEL for current xref.
8592 See `gnus-score-expiry-days'."
8594 (gnus-summary-score-crossposting
8595 (- (gnus-score-default level)) (current-time-string)))
8597 (defun gnus-summary-temporarily-lower-by-thread (level)
8598 "Temporarily lower score by LEVEL for current thread.
8599 See `gnus-score-expiry-days'."
8601 (gnus-summary-score-entry
8602 "references" (gnus-summary-header "message-id")
8603 nil (- (gnus-score-default level)) (current-time-string)))
8605 (defun gnus-summary-lower-by-subject (level)
8606 "Lower score by LEVEL for current subject."
8608 (gnus-summary-score-entry
8609 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
8610 nil (- (gnus-score-default level))
8613 (defun gnus-summary-lower-by-author (level)
8614 "Lower score by LEVEL for current author."
8616 (gnus-summary-score-entry
8617 "from" (gnus-summary-header "from") nil
8618 (- (gnus-score-default level)) nil t))
8620 (defun gnus-summary-lower-by-id (level)
8621 "Lower score by LEVEL for current message-id."
8623 (gnus-summary-score-entry
8624 "message-id" (gnus-summary-header "message-id") nil
8625 (- (gnus-score-default level)) nil))
8627 (defun gnus-summary-lower-by-xref (level)
8628 "Lower score by LEVEL for current xref."
8630 (gnus-summary-score-crossposting (- (gnus-score-default level)) nil))
8632 (defun gnus-summary-lower-followups-to-author (level)
8633 "Lower score by LEVEL for all followups to the current author."
8635 (gnus-summary-raise-followups-to-author
8636 (- (gnus-score-default level))))
8638 (defun gnus-summary-temporarily-raise-by-subject (level)
8639 "Temporarily raise score by LEVEL for current subject.
8640 See `gnus-score-expiry-days'."
8642 (gnus-summary-score-entry
8643 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
8644 nil level (current-time-string) t))
8646 (defun gnus-summary-temporarily-raise-by-author (level)
8647 "Temporarily raise score by LEVEL for current author.
8648 See `gnus-score-expiry-days'."
8650 (gnus-summary-score-entry
8651 "from" (gnus-summary-header "from") nil level (current-time-string) t))
8653 (defun gnus-summary-temporarily-raise-by-id (level)
8654 "Temporarily raise score by LEVEL for current message-id.
8655 See `gnus-score-expiry-days'."
8657 (gnus-summary-score-entry
8658 "message-id" (gnus-summary-header "message-id")
8659 nil level (current-time-string)))
8661 (defun gnus-summary-temporarily-raise-by-xref (level)
8662 "Temporarily raise score by LEVEL for current xref.
8663 See `gnus-score-expiry-days'."
8665 (gnus-summary-score-crossposting level (current-time-string)))
8667 (defun gnus-summary-temporarily-raise-by-thread (level)
8668 "Temporarily raise score by LEVEL for current thread.
8669 See `gnus-score-expiry-days'."
8671 (gnus-summary-score-entry
8672 "references" (gnus-summary-header "message-id")
8673 nil level (current-time-string)))
8675 (defun gnus-summary-raise-by-subject (level)
8676 "Raise score by LEVEL for current subject."
8678 (gnus-summary-score-entry
8679 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
8682 (defun gnus-summary-raise-by-author (level)
8683 "Raise score by LEVEL for current author."
8685 (gnus-summary-score-entry
8686 "from" (gnus-summary-header "from") nil level nil t))
8688 (defun gnus-summary-raise-by-id (level)
8689 "Raise score by LEVEL for current message-id."
8691 (gnus-summary-score-entry
8692 "message-id" (gnus-summary-header "message-id") nil level nil))
8694 (defun gnus-summary-raise-by-xref (level)
8695 "Raise score by LEVEL for current xref."
8697 (gnus-summary-score-crossposting level nil))
8699 (defun gnus-summary-raise-followups-to-author (level)
8700 "Raise score by LEVEL for all followups to the current author."
8702 (let ((article (gnus-summary-article-number)))
8703 (if article (setq gnus-current-headers (gnus-get-header-by-number article))
8704 (error "No article on current line")))
8705 (gnus-kill-file-raise-followups-to-author
8706 (gnus-score-default level)))
8708 ;; Summary kill commands.
8710 (defun gnus-summary-edit-global-kill (article)
8711 "Edit the global score file."
8712 (interactive (list (gnus-summary-article-number)))
8713 (gnus-group-edit-global-kill article))
8715 (defun gnus-summary-edit-local-kill ()
8716 "Edit a local score file applied to the current newsgroup."
8718 (setq gnus-current-headers
8720 (int-to-string (gnus-summary-article-number))
8721 gnus-newsgroup-headers-hashtb-by-number))
8722 (gnus-set-global-variables)
8723 (gnus-group-edit-local-kill
8724 (gnus-summary-article-number) gnus-newsgroup-name))
8728 ;;; Gnus article mode
8731 (if gnus-article-mode-map
8733 (setq gnus-article-mode-map (make-keymap))
8734 (suppress-keymap gnus-article-mode-map)
8735 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
8736 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
8737 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
8738 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
8739 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
8740 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
8741 (define-key gnus-article-mode-map "\C-c\C-M" 'gnus-article-mail-with-original)
8742 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
8744 ;; Duplicate almost all summary keystrokes in the article mode map.
8746 (list "#" "\M-#" "\C-c\M-#" "\r" "n" "p"
8747 "N" "P" "\M-\C-n" "\M-\C-p" "." "\M-s" "\M-r"
8748 "<" ">" "l" "j" "^" "\M-^" "-" "u" "U" "d" "D"
8749 "\M-u" "\M-U" "k" "\C-k" "\M-\C-k" "c" "x" "X"
8750 "\M-\C-x" "\M-\177" "b" "B" "$" "w" "\C-c\C-r"
8751 "t" "\M-t" "a" "f" "F" "C" "S" "r" "R" "\C-c\C-f"
8752 "m" "o" "\C-o" "|" "\M-m" "\M-\C-m" "\M-k" "m" "M"
8753 "V" "\C-c\C-d" "q" "Q")))
8755 (define-key gnus-article-mode-map (car commands)
8756 'gnus-article-summary-command)
8757 (setq commands (cdr commands)))))
8760 (defun gnus-article-mode ()
8761 "Major mode for displaying an article.
8763 All normal editing commands are switched off.
8765 The following commands are available:
8767 \\<gnus-article-mode-map>
8768 \\[gnus-article-next-page]\t Scroll the article one page forwards
8769 \\[gnus-article-prev-page]\t Scroll the article one page backwards
8770 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
8771 \\[gnus-article-show-summary]\t Display the summary buffer
8772 \\[gnus-article-mail]\t Send a reply to the address near point
8773 \\[gnus-article-mail-with-original]\t Send a reply to the address near point; include the original article
8774 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
8775 \\[gnus-info-find-node]\t Go to the Gnus info node"
8777 (if gnus-visual (gnus-article-make-menu-bar))
8778 (kill-all-local-variables)
8779 (setq mode-line-modified "-- ")
8780 (make-local-variable 'mode-line-format)
8781 (setq mode-line-format (copy-sequence mode-line-format))
8782 (and (equal (nth 3 mode-line-format) " ")
8783 (setcar (nthcdr 3 mode-line-format) ""))
8784 (setq mode-name "Article")
8785 (setq major-mode 'gnus-article-mode)
8786 (make-local-variable 'minor-mode-alist)
8787 (or (assq 'gnus-show-mime minor-mode-alist)
8788 (setq minor-mode-alist
8789 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
8790 (use-local-map gnus-article-mode-map)
8791 (make-local-variable 'page-delimiter)
8792 (setq page-delimiter gnus-page-delimiter)
8793 (buffer-disable-undo (current-buffer))
8794 (setq buffer-read-only t) ;Disable modification
8795 (run-hooks 'gnus-article-mode-hook))
8797 (defun gnus-article-setup-buffer ()
8798 "Initialize article mode buffer."
8799 (or (get-buffer gnus-article-buffer)
8801 (set-buffer (get-buffer-create gnus-article-buffer))
8802 (gnus-add-current-to-buffer-list)
8803 (gnus-article-mode))))
8805 (defun gnus-request-article-this-buffer (article &optional group)
8806 "Get an article and insert it into this buffer."
8807 (setq group (or group gnus-newsgroup-name))
8808 ;; Using `gnus-request-article' directly will insert the article into
8809 ;; `nntp-server-buffer' - so we'll save some time by not having to
8810 ;; copy it from the server buffer into the article buffer.
8812 ;; We only request an article by message-id when we do not have the
8813 ;; headers for it, so we'll have to get those.
8814 (and (stringp article)
8815 (let ((gnus-override-method gnus-refer-article-method))
8816 (gnus-read-header article)))
8818 ;; If the article number is negative, that means that this article
8819 ;; doesn't belong in this newsgroup (possibly), so we find its
8820 ;; message-id and request it by id instead of number.
8821 (if (and (numberp article) (< article 0))
8823 (set-buffer gnus-summary-buffer)
8824 (let ((header (gnus-gethash (int-to-string article)
8825 gnus-newsgroup-headers-hashtb-by-number)))
8826 (if (vectorp header)
8827 ;; It's a real article.
8828 (setq article (header-id header))
8829 ;; It is an extracted pseudo-article.
8831 (gnus-request-pseudo-article header)))))
8832 ;; Get the article and into the article buffer.
8836 (let ((gnus-override-method
8837 (and (stringp article) gnus-refer-article-method)))
8838 (and (gnus-request-article article group (current-buffer))
8842 (defun gnus-read-header (id)
8843 "Read the headers of article ID and enter them into the Gnus system."
8844 (or gnus-newsgroup-headers-hashtb-by-number
8845 (gnus-make-headers-hashtable-by-number))
8847 (if (not (setq header
8848 (car (if (let ((gnus-nov-is-evil t))
8849 (gnus-retrieve-headers
8850 (list id) gnus-newsgroup-name))
8851 (gnus-get-newsgroup-headers)))))
8854 (header-set-number header gnus-reffed-article-number))
8855 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
8856 (gnus-sethash (int-to-string (header-number header)) header
8857 gnus-newsgroup-headers-hashtb-by-number)
8859 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
8860 (setq gnus-current-headers header)
8863 (defun gnus-article-prepare (article &optional all-headers header)
8864 "Prepare ARTICLE in article mode buffer.
8865 ARTICLE should either be an article number or a Message-ID.
8866 If ARTICLE is an id, HEADER should be the article headers.
8867 If ALL-HEADERS is non-nil, no headers are hidden."
8869 ;; Make sure we start in a summary buffer.
8870 (or (eq major-mode 'gnus-summary-mode)
8871 (set-buffer gnus-summary-buffer))
8872 (setq gnus-summary-buffer (current-buffer))
8873 ;; Make sure the connection to the server is alive.
8874 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
8876 (gnus-check-news-server
8877 (gnus-find-method-for-group gnus-newsgroup-name))
8878 (gnus-request-group gnus-newsgroup-name t)))
8879 (or gnus-newsgroup-headers-hashtb-by-number
8880 (gnus-make-headers-hashtable-by-number))
8881 (let* ((article (if header (header-number header) article))
8882 (summary-buffer (current-buffer))
8883 (internal-hook gnus-article-internal-prepare-hook)
8884 (bookmark (cdr (assq article gnus-newsgroup-bookmarks)))
8885 (group gnus-newsgroup-name)
8888 (gnus-article-setup-buffer)
8889 (set-buffer gnus-article-buffer)
8890 (let ((buffer-read-only nil))
8891 (if (not (setq result (gnus-request-article-this-buffer
8893 ;; There is no such article.
8896 (set-buffer gnus-summary-buffer)
8897 (setq gnus-current-article 0)
8898 (and (numberp article)
8899 (gnus-summary-mark-as-read article gnus-canceled-mark))
8900 (message "No such article (may be canceled)")
8902 (setq gnus-article-current nil)
8904 (if (not (eq result 'article))
8907 (set-buffer summary-buffer)
8908 (setq gnus-last-article gnus-current-article
8909 gnus-newsgroup-history (cons gnus-current-article
8910 gnus-newsgroup-history)
8911 gnus-current-article 0
8912 gnus-current-headers nil
8913 gnus-article-current nil)
8914 (gnus-configure-windows 'article)
8915 (gnus-set-global-variables))
8916 (gnus-set-mode-line 'article))
8917 ;; The result from the `request' was an actual article -
8918 ;; or at least some text that is now displayed in the
8920 (if (and (numberp article)
8921 (not (eq article gnus-current-article)))
8922 ;; Seems like a new article has been selected.
8923 ;; `gnus-current-article' must be an article number.
8925 (set-buffer summary-buffer)
8926 (setq gnus-last-article gnus-current-article
8927 gnus-newsgroup-history (cons gnus-current-article
8928 gnus-newsgroup-history)
8929 gnus-current-article article
8930 gnus-current-headers
8931 (gnus-get-header-by-number gnus-current-article)
8932 gnus-article-current
8933 (cons gnus-newsgroup-name gnus-current-article))
8934 (run-hooks 'gnus-mark-article-hook)
8935 (gnus-set-mode-line 'summary)
8937 (run-hooks 'gnus-visual-mark-article-hook))
8938 ;; Set the global newsgroup variables here.
8939 ;; Suggested by Jim Sisolak
8940 ;; <sisolak@trans4.neep.wisc.edu>.
8941 (gnus-set-global-variables)))
8942 ;; gnus-have-all-headers must be either T or NIL.
8943 (setq gnus-have-all-headers
8944 (not (not (or all-headers gnus-show-all-headers))))
8945 ;; Hooks for getting information from the article.
8946 ;; This hook must be called before being narrowed.
8947 (run-hooks 'internal-hook)
8948 (run-hooks 'gnus-article-prepare-hook)
8949 ;; Decode MIME message.
8950 (if (and gnus-show-mime
8951 (gnus-fetch-field "Mime-Version"))
8952 (funcall gnus-show-mime-method))
8953 ;; Perform the article display hooks.
8954 (let ((buffer-read-only nil))
8955 (run-hooks 'gnus-article-display-hook))
8957 (goto-char (point-min))
8958 (and gnus-break-pages (gnus-narrow-to-page))
8959 (gnus-set-mode-line 'article)
8960 (gnus-configure-windows 'article)
8963 (get-buffer-window gnus-article-buffer) (point-min))
8966 (message "Moved to bookmark")
8967 (search-forward "\n\n" nil t)
8968 (forward-line bookmark)))
8971 (defun gnus-article-show-all-headers ()
8972 "Show all article headers in article mode buffer."
8974 (setq gnus-have-all-headers t)
8975 (gnus-article-setup-buffer)
8976 (set-buffer gnus-article-buffer)
8977 (let ((buffer-read-only nil))
8978 (remove-text-properties 1 (point-max) '(invisible t)))))
8980 (defun gnus-article-hide-headers-if-wanted ()
8981 "Hide unwanted headers if `gnus-have-all-headers' is nil.
8982 Provided for backwards compatability."
8983 (or gnus-have-all-headers
8984 (gnus-article-hide-headers)))
8986 (defun gnus-article-hide-headers (&optional delete)
8987 "Hide unwanted headers and possibly sort them as well."
8990 (set-buffer gnus-article-buffer)
8992 (let ((sorted gnus-sorted-header-list)
8993 (buffer-read-only nil)
8994 want want-list beg want-l)
8995 ;; First we narrow to just the headers.
8998 ;; Hide any "From " lines at the beginning of (mail) articles.
8999 (while (looking-at rmail-unix-mail-delimiter)
9002 (add-text-properties 1 (point) '(invisible t)))
9003 ;; Then treat the rest of the header lines.
9006 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
9007 ;; Then we use the two regular expressions
9008 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
9009 ;; select which header lines is to remain visible in the
9012 (while (re-search-forward "^[^ \t]*:" nil t)
9014 ;; We add the headers we want to keep to a list and delete
9015 ;; them from the buffer.
9016 (if (or (and (stringp gnus-visible-headers)
9017 (looking-at gnus-visible-headers))
9018 (and (not (stringp gnus-visible-headers))
9019 (stringp gnus-ignored-headers)
9020 (not (looking-at gnus-ignored-headers))))
9024 ;; Be sure to get multi-line headers...
9025 (re-search-forward "^[^ \t]*:" nil t)
9028 (cons (buffer-substring beg (point)) want-list))
9029 (delete-region beg (point))
9032 ;; Next we perform the sorting by looking at
9033 ;; `gnus-sorted-header-list'.
9035 (while (and sorted want-list)
9036 (setq want-l want-list)
9038 (not (string-match (car sorted) (car want-l))))
9039 (setq want-l (cdr want-l)))
9042 (insert (car want-l))
9043 (setq want-list (delq (car want-l) want-list))))
9044 (setq sorted (cdr sorted)))
9045 ;; Any headers that were not matched by the sorted list we
9046 ;; just tack on the end of the visible header list.
9048 (insert (car want-list))
9049 (setq want-list (cdr want-list)))
9050 ;; And finally we make the unwanted headers invisible.
9052 (delete-region (point) (point-max))
9053 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
9054 (add-text-properties (point) (point-max) '(invisible t)))))))
9056 (defun gnus-article-hide-signature ()
9057 "Hides the signature in an article.
9058 It does this by hiding everyting after \"^-- *$\", which is what all
9059 signatures should be preceded by. Note that this may mean that parts
9060 of an article may disappear if the article has such a line in the
9061 middle of the text."
9064 (set-buffer gnus-article-buffer)
9065 (let ((buffer-read-only nil))
9066 (goto-char (point-max))
9067 (if (re-search-backward "^-- *$" nil t)
9069 (add-text-properties (point) (point-max) '(invisible t)))))))
9071 (defun gnus-article-hide-citation ()
9072 "Hide all cited text.
9073 This function uses the famous, extremely intelligent \"shoot in foot\"
9074 algorithm - which is simply deleting all lines that start with
9075 \">\". Your mileage may vary. If you come up with anything better,
9076 please do mail it to me."
9079 (set-buffer gnus-article-buffer)
9080 (let ((buffer-read-only nil))
9082 (search-forward "\n\n" nil t)
9084 (if (looking-at ">")
9085 (add-text-properties
9086 (point) (save-excursion (forward-line 1) (point))
9088 (forward-line 1)))))
9090 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
9091 (defun gnus-article-treat-overstrike ()
9092 ;; Prepare article for overstrike commands.
9095 (set-buffer gnus-article-buffer)
9096 (let ((buffer-read-only nil))
9097 (while (search-forward "\b" nil t)
9098 (let ((next (following-char))
9099 (previous (char-after (- (point) 2))))
9100 (cond ((eq next previous)
9101 (delete-region (- (point) 2) (point))
9102 (put-text-property (point) (1+ (point))
9105 (delete-region (1- (point)) (1+ (point)))
9106 (put-text-property (1- (point)) (point)
9109 (delete-region (- (point) 2) (point))
9110 (put-text-property (point) (1+ (point))
9111 'face 'underline))))))))
9113 (defun gnus-article-word-wrap ()
9114 "Format too long lines."
9117 (set-buffer gnus-article-buffer)
9118 (let ((buffer-read-only nil))
9120 (search-forward "\n\n" nil t)
9122 (let ((paragraph-start "^\\W"))
9124 (and (>= (current-column) (window-width))
9125 (/= (preceding-char) ?:)
9126 (fill-paragraph nil))
9127 (end-of-line 2))))))
9129 (defun gnus-article-remove-cr ()
9132 (set-buffer gnus-article-buffer)
9133 (let ((buffer-read-only nil))
9134 (goto-char (point-min))
9135 (while (search-forward "\r" nil t)
9136 (replace-match "")))))
9138 (defun gnus-article-de-quoted-unreadable ()
9142 (set-buffer gnus-article-buffer)
9143 (let ((buffer-read-only nil))
9145 (goto-char (point-min))
9146 (while (re-search-forward "=[0-9A-F][0-9A-F]" nil t)
9150 (* 16 (gnus-hex-char-to-integer
9151 (char-after (1+ (match-beginning 0)))))
9152 (gnus-hex-char-to-integer
9153 (char-after (1- (match-end 0))))))))))))
9155 ;; Taken from hexl.el.
9156 (defun gnus-hex-char-to-integer (character)
9157 "Take a char and return its value as if it was a hex digit."
9158 (if (and (>= character ?0) (<= character ?9))
9160 (let ((ch (logior character 32)))
9161 (if (and (>= ch ?a) (<= ch ?f))
9163 (error (format "Invalid hex digit `%c'." ch))))))
9167 (defun gnus-output-to-rmail (file-name)
9168 "Append the current article to an Rmail file named FILE-NAME."
9170 ;; Most of these codes are borrowed from rmailout.el.
9171 (setq file-name (expand-file-name file-name))
9172 (setq rmail-default-rmail-file file-name)
9173 (let ((artbuf (current-buffer))
9174 (tmpbuf (get-buffer-create " *Gnus-output*")))
9176 (or (get-file-buffer file-name)
9177 (file-exists-p file-name)
9178 (if (gnus-yes-or-no-p
9179 (concat "\"" file-name "\" does not exist, create it? "))
9180 (let ((file-buffer (create-file-buffer file-name)))
9182 (set-buffer file-buffer)
9183 (rmail-insert-rmail-file-header)
9184 (let ((require-final-newline nil))
9185 (write-region (point-min) (point-max) file-name t 1)))
9186 (kill-buffer file-buffer))
9187 (error "Output file does not exist")))
9189 (buffer-disable-undo (current-buffer))
9191 (insert-buffer-substring artbuf)
9192 (gnus-convert-article-to-rmail)
9193 ;; Decide whether to append to a file or to an Emacs buffer.
9194 (let ((outbuf (get-file-buffer file-name)))
9196 (append-to-file (point-min) (point-max) file-name)
9197 ;; File has been visited, in buffer OUTBUF.
9199 (let ((buffer-read-only nil)
9200 (msg (and (boundp 'rmail-current-message)
9201 rmail-current-message)))
9202 ;; If MSG is non-nil, buffer is in RMAIL mode.
9205 (narrow-to-region (point-max) (point-max))))
9206 (insert-buffer-substring tmpbuf)
9209 (goto-char (point-min))
9211 (search-backward "\^_")
9212 (narrow-to-region (point) (point-max))
9213 (goto-char (1+ (point-min)))
9214 (rmail-count-new-messages t)
9215 (rmail-show-message msg)))))))
9216 (kill-buffer tmpbuf)))
9218 (defun gnus-output-to-file (file-name)
9219 "Append the current article to a file named FILE-NAME."
9220 (setq file-name (expand-file-name file-name))
9221 (let ((artbuf (current-buffer))
9222 (tmpbuf (get-buffer-create " *Gnus-output*")))
9225 (buffer-disable-undo (current-buffer))
9227 (insert-buffer-substring artbuf)
9228 ;; Append newline at end of the buffer as separator, and then
9230 (goto-char (point-max))
9232 (append-to-file (point-min) (point-max) file-name))
9233 (kill-buffer tmpbuf)))
9235 (defun gnus-convert-article-to-rmail ()
9236 "Convert article in current buffer to Rmail message format."
9237 (let ((buffer-read-only nil))
9238 ;; Convert article directly into Babyl format.
9239 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
9240 (goto-char (point-min))
9241 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
9242 (while (search-forward "\n\^_" nil t) ;single char
9243 (replace-match "\n^_")) ;2 chars: "^" and "_"
9244 (goto-char (point-max))
9247 (defun gnus-narrow-to-page (&optional arg)
9248 "Make text outside current page invisible except for page delimiter.
9249 A numeric arg specifies to move forward or backward by that many pages,
9250 thus showing a page other than the one point was originally in."
9252 (setq arg (if arg (prefix-numeric-value arg) 0))
9254 (forward-page -1) ;Beginning of current page.
9259 (forward-page (1- arg))))
9260 ;; Find the end of the page.
9262 ;; If we stopped due to end of buffer, stay there.
9263 ;; If we stopped after a page delimiter, put end of restriction
9264 ;; at the beginning of that line.
9265 ;; These are commented out.
9266 ;; (if (save-excursion (beginning-of-line)
9267 ;; (looking-at page-delimiter))
9268 ;; (beginning-of-line))
9269 (narrow-to-region (point)
9271 ;; Find the top of the page.
9273 ;; If we found beginning of buffer, stay there.
9274 ;; If extra text follows page delimiter on same line,
9276 ;; Otherwise, show text starting with following line.
9277 (if (and (eolp) (not (bobp)))
9281 (defun gnus-gmt-to-local ()
9282 "Rewrite Date header described in GMT to local in current buffer.
9283 Intended to be used with gnus-article-prepare-hook."
9287 (goto-char (point-min))
9288 (narrow-to-region (point-min)
9289 (progn (search-forward "\n\n" nil 'move) (point)))
9290 (goto-char (point-min))
9291 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
9292 (let ((buffer-read-only nil)
9293 (date (buffer-substring (match-beginning 1) (match-end 1))))
9294 (delete-region (match-beginning 1) (match-end 1))
9296 (timezone-make-date-arpa-standard
9297 date nil (current-time-zone))))))))
9300 ;; Article mode commands
9302 (defun gnus-article-next-page (lines)
9303 "Show next page of current article.
9304 If end of article, return non-nil. Otherwise return nil.
9305 Argument LINES specifies lines to be scrolled up."
9307 (move-to-window-line -1)
9308 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
9311 (and (pos-visible-in-window-p) ;Not continuation line.
9313 ;; Nothing in this page.
9314 (if (or (not gnus-break-pages)
9317 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
9319 (gnus-narrow-to-page 1) ;Go to next page.
9321 ;; More in this page.
9325 ;; Long lines may cause an end-of-buffer error.
9326 (goto-char (point-max))))
9329 (defun gnus-article-prev-page (lines)
9330 "Show previous page of current article.
9331 Argument LINES specifies lines to be scrolled down."
9333 (move-to-window-line 0)
9334 (if (and gnus-break-pages
9336 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
9338 (gnus-narrow-to-page -1) ;Go to previous page.
9339 (goto-char (point-max))
9341 (scroll-down lines)))
9343 (defun gnus-article-refer-article ()
9344 "Read article specified by message-id around point."
9346 (search-forward ">" nil t) ;Move point to end of "<....>".
9347 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
9349 (buffer-substring (match-beginning 1) (match-end 1))))
9350 (set-buffer gnus-summary-buffer)
9351 (gnus-summary-refer-article message-id))
9352 (error "No references around point")))
9354 (defun gnus-article-mail (yank)
9355 "Send a reply to the address near point.
9356 If YANK is non-nil, include the original article."
9360 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
9361 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
9364 (switch-to-buffer gnus-summary-buffer)
9365 (funcall gnus-mail-reply-method yank address)))))
9367 (defun gnus-article-mail-with-original ()
9368 "Send a reply to the address near point and include the original article."
9370 (gnus-article-mail 'yank))
9372 (defun gnus-article-show-summary ()
9373 "Reconfigure windows to show summary buffer."
9375 (gnus-configure-windows 'article)
9376 (pop-to-buffer gnus-summary-buffer)
9377 (gnus-summary-goto-subject gnus-current-article))
9379 (defun gnus-article-describe-briefly ()
9380 "Describe article mode commands briefly."
9383 (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")))
9385 (defun gnus-article-summary-command ()
9386 "Execute the last keystroke in the summary buffer."
9389 (let ((obuf (current-buffer))
9390 (owin (current-window-configuration)))
9391 (switch-to-buffer gnus-summary-buffer 'norecord)
9392 (execute-kbd-macro (this-command-keys))
9394 (let ((npoint (point)))
9395 (set-window-configuration owin)
9396 (set-window-start (get-buffer-window (current-buffer)) (point)))))
9398 ;; caesar-region written by phr@prep.ai.mit.edu Nov 86
9399 ;; Modified by tower@prep Nov 86
9400 ;; Modified by umerin@flab.flab.Fujitsu.JUNET for ROT47.
9402 (defun gnus-caesar-region (&optional n)
9403 "Caesar rotation of region by N, default 13, for decrypting netnews.
9404 ROT47 will be performed for Japanese text in any case."
9405 (interactive (if current-prefix-arg ; Was there a prefix arg?
9406 (list (prefix-numeric-value current-prefix-arg))
9408 (cond ((not (numberp n)) (setq n 13))
9409 (t (setq n (mod n 26)))) ;canonicalize N
9410 (if (not (zerop n)) ; no action needed for a rot of 0
9412 (if (or (not (boundp 'caesar-translate-table))
9413 (not caesar-translate-table)
9414 (/= (aref caesar-translate-table ?a) (+ ?a n)))
9415 (let ((i 0) (lower "abcdefghijklmnopqrstuvwxyz") upper)
9416 (message "Building caesar-translate-table...")
9417 (setq caesar-translate-table (make-vector 256 0))
9419 (aset caesar-translate-table i i)
9421 (setq lower (concat lower lower) upper (upcase lower) i 0)
9423 (aset caesar-translate-table (+ ?a i) (aref lower (+ i n)))
9424 (aset caesar-translate-table (+ ?A i) (aref upper (+ i n)))
9426 ;; ROT47 for Japanese text.
9427 ;; Thanks to ichikawa@flab.fujitsu.junet.
9429 (let ((t1 (logior ?O 128))
9430 (t2 (logior ?! 128))
9431 (t3 (logior ?~ 128)))
9433 (aset caesar-translate-table i
9434 (let ((v (aref caesar-translate-table i)))
9435 (if (<= v t1) (if (< v t2) v (+ v 47))
9436 (if (<= v t3) (- v 47) v))))
9438 (message "Building caesar-translate-table... done")))
9439 (let ((from (region-beginning))
9442 (setq str (buffer-substring from to))
9443 (setq len (length str))
9445 (aset str i (aref caesar-translate-table (aref str i)))
9448 (delete-region from to)
9452 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
9455 (defalias 'gnus-batch-kill 'gnus-batch-score)
9457 (defun gnus-batch-score ()
9458 "Run batched scoring.
9459 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
9460 Newsgroups is a list of strings in Bnews format. If you want to score
9461 the comp hierarchy, you'd say \"comp.all\". If you would not like to
9462 score the alt hierarchy, you'd say \"!alt.all\"."
9465 (gnus-parse-n-options
9466 (apply (function concat)
9467 (mapcar (lambda (g) (concat g " "))
9468 command-line-args-left))))
9469 (gnus-expert-user t)
9470 (nnmail-spool-file nil)
9471 (gnus-use-dribble-file nil)
9472 (yes (car yes-and-no))
9473 (no (cdr yes-and-no))
9474 group subscribed newsrc entry
9475 ;; Disable verbose message.
9476 gnus-novice-user gnus-large-newsgroup)
9477 ;; Eat all arguments.
9478 (setq command-line-args-left nil)
9481 ;; Apply kills to specified newsgroups in command line arguments.
9482 (setq newsrc (cdr gnus-newsrc-assoc))
9484 (setq group (car (car newsrc)))
9485 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
9486 (if (and (<= (nth 1 (car newsrc)) 5)
9488 (or (eq (car entry) t)
9489 (not (zerop (car entry)))))
9490 (if yes (string-match yes group) t)
9491 (or (null no) (not (string-match no group))))
9493 (gnus-summary-read-group group nil t)
9494 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
9495 (gnus-summary-exit))))
9496 (setq newsrc (cdr newsrc)))
9498 (switch-to-buffer gnus-group-buffer)
9499 (gnus-group-save-newsrc)))
9501 (defun gnus-apply-kill-file ()
9502 "Apply a kill file to the current newsgroup.
9503 Returns the number of articles marked as read."
9504 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
9505 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
9506 (gnus-apply-kill-file-internal)
9509 (defun gnus-kill-save-kill-buffer ()
9511 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
9512 (if (get-file-buffer file)
9514 (set-buffer (get-file-buffer file))
9515 (and (buffer-modified-p) (save-buffer))
9516 (kill-buffer (current-buffer)))))))
9518 (defvar gnus-kill-file-name "KILL"
9519 "Suffix of the kill files.")
9521 (defun gnus-newsgroup-kill-file (newsgroup)
9522 "Return the name of a kill file name for NEWSGROUP.
9523 If NEWSGROUP is nil, return the global kill file name instead."
9524 (cond ((or (null newsgroup)
9525 (string-equal newsgroup ""))
9526 ;; The global KILL file is placed at top of the directory.
9527 (expand-file-name gnus-kill-file-name
9528 (or gnus-kill-files-directory "~/News")))
9529 (gnus-use-long-file-name
9530 ;; Append ".KILL" to newsgroup name.
9531 (expand-file-name (concat newsgroup "." gnus-kill-file-name)
9532 (or gnus-kill-files-directory "~/News")))
9534 ;; Place "KILL" under the hierarchical directory.
9535 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
9536 "/" gnus-kill-file-name)
9537 (or gnus-kill-files-directory "~/News")))))
9541 ;;; Gnus Score Files
9544 ;; All score code written by Per Abrahamsen <abraham@iesd.auc.dk>.
9546 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9547 (defun gnus-score-set-mark-below (score)
9548 "Automatically mark articles with score below SCORE as read."
9550 (list (or (and current-prefix-arg (prefix-numeric-value current-prefix-arg))
9551 (string-to-int (read-string "Mark below: ")))))
9552 (setq score (or score gnus-summary-default-score 0))
9553 (gnus-score-set 'mark (list score))
9554 (gnus-score-set 'touched '(t))
9555 (setq gnus-summary-mark-below score)
9556 (gnus-summary-update-lines))
9558 (defun gnus-score-set-expunge-below (score)
9559 "Automatically expunge articles with score below SCORE."
9561 (list (or (and current-prefix-arg (prefix-numeric-value current-prefix-arg))
9562 (string-to-int (read-string "Expunge below: ")))))
9563 (setq score (or score gnus-summary-default-score 0))
9564 (gnus-score-set 'expunge (list score))
9565 (gnus-score-set 'touched '(t)))
9567 (defun gnus-score-default (level)
9568 (if level (prefix-numeric-value level)
9569 gnus-score-interactive-default-score))
9571 (defun gnus-score-set (symbol value &optional alist)
9572 ;; Set SYMBOL to VALUE in ALIST.
9577 (gnus-score-load (gnus-score-file-name gnus-newsgroup-name))
9579 (entry (assoc symbol alist)))
9580 (cond ((gnus-score-get 'read-only alist)
9581 ;; This is a read-only score file, so we do nothing.
9584 (setcdr entry value))
9586 (error "Empty alist"))
9589 (cons (cons symbol value) (cdr alist)))))))
9591 (defun gnus-score-get (symbol &optional alist)
9592 ;; Get SYMBOL's definition in ALIST.
9598 (gnus-score-file-name gnus-newsgroup-name))
9599 gnus-score-alist)))))
9601 (defun gnus-score-change-score-file (file)
9602 "Change current score alist."
9604 (list (completing-read "Score file: " gnus-score-cache)))
9605 (setq gnus-current-score-file file)
9606 (gnus-score-load-file file))
9608 (defun gnus-score-edit-alist (file)
9609 "Edit the current score alist."
9610 (interactive (list gnus-current-score-file))
9611 (and (buffer-name gnus-summary-buffer) (gnus-score-save))
9612 (setq gnus-winconf-edit-score (current-window-configuration))
9613 (gnus-configure-windows 'article)
9614 (pop-to-buffer (find-file-noselect file))
9615 (message (substitute-command-keys
9616 "\\<gnus-score-mode-map>\\[gnus-score-edit-done] to save edits"))
9619 (defun gnus-score-edit-file (file)
9620 "Edit a score file."
9622 (list (read-file-name "Edit score file: " gnus-kill-files-directory)))
9623 (and (buffer-name gnus-summary-buffer) (gnus-score-save))
9624 (setq gnus-winconf-edit-score (current-window-configuration))
9625 (gnus-configure-windows 'article)
9626 (pop-to-buffer (find-file-noselect file))
9627 (message (substitute-command-keys
9628 "\\<gnus-score-mode-map>\\[gnus-score-edit-done] to save edits"))
9631 (defun gnus-score-load-file (file)
9632 ;; Load score file FILE. Returns a list a retrieved score-alists.
9633 (let* ((file (expand-file-name (or (and (string-match "^/" file) file)
9634 (concat gnus-kill-files-directory file))))
9635 (cached (assoc file gnus-score-cache))
9636 (global (member file gnus-internal-global-score-files))
9639 ;; The score file was already loaded.
9640 (setq gnus-score-alist (cdr cached))
9641 ;; We load the score file.
9642 (setq gnus-score-alist nil)
9643 (setq alist (gnus-score-load-score-alist file))
9644 ;; We add '(touched) to the alist to signify that it hasn't been
9646 (if (not (assq 'touched gnus-score-alist))
9647 (setq gnus-score-alist
9648 (cons (list 'touched nil) gnus-score-alist)))
9649 ;; If it is a global score file, we make it read-only.
9651 (not (assq 'read-only gnus-score-alist))
9652 (setq gnus-score-alist
9653 (cons (list 'read-only t) gnus-score-alist)))
9655 (setq gnus-score-cache
9656 (cons (cons file gnus-score-alist) gnus-score-cache)))
9657 ;; If there are actual scores in the alist, we add it to the
9658 ;; return value of this function.
9659 (if (memq t (mapcar (lambda (e) (stringp (car e))) gnus-score-alist))
9660 (setq lists (list gnus-score-alist)))
9661 ;; Treat the other possible atoms in the score alist.
9662 (let ((mark (car (gnus-score-get 'mark gnus-score-alist)))
9663 (expunge (car (gnus-score-get 'expunge gnus-score-alist)))
9665 (car (gnus-score-get 'mark-and-expunge gnus-score-alist)))
9666 (read-only (gnus-score-get 'read-only gnus-score-alist))
9667 (files (gnus-score-get 'files gnus-score-alist))
9668 (eval (gnus-score-get 'eval gnus-score-alist)))
9669 ;; We do not respect eval and files atoms from global score
9671 (and files (not global)
9672 (setq lists (apply 'append lists
9673 (mapcar (lambda (file)
9674 (gnus-score-load-file file))
9676 (and eval (not global) (eval eval))
9677 (setq gnus-summary-mark-below (or mark mark-and-expunge))
9678 (setq gnus-summary-expunge-below (or expunge mark-and-expunge)))
9679 (setq gnus-current-score-file file)
9680 (setq gnus-score-alist alist)
9683 (defun gnus-score-load (file)
9685 (let ((cache (assoc file gnus-score-cache)))
9687 (setq gnus-score-alist (cdr cache))
9688 (setq gnus-score-alist nil)
9689 (gnus-score-load-score-alist file)
9690 (or gnus-score-alist
9691 (setq gnus-score-alist (copy-alist '((touched . nil)))))
9692 (setq gnus-score-cache
9693 (cons (cons file gnus-score-alist) gnus-score-cache)))))
9695 (defun gnus-score-remove-from-cache (file)
9696 (setq gnus-score-cache (delq (assoc file gnus-score-cache)
9699 (defun gnus-score-load-score-alist (file)
9701 (if (file-readable-p file)
9704 (set-buffer (get-buffer-create " *gnus work*"))
9705 (buffer-disable-undo (current-buffer))
9707 (insert-file-contents file)
9708 (goto-char (point-min))
9711 (read (current-buffer))
9714 (message "Problem with score file %s" file)
9717 (if (eq (car alist) 'setq)
9718 (setq gnus-score-alist
9719 (gnus-score-transform-old-to-new alist))
9720 (setq gnus-score-alist alist))))))
9722 (defun gnus-score-transform-old-to-new (alist)
9723 (let* ((alist (nth 2 alist))
9725 (if (eq (car alist) 'quote)
9726 (setq alist (nth 1 alist)))
9728 (setq entry (car alist))
9729 (if (stringp (car entry))
9730 (let ((scor (cdr entry)))
9731 (setq out (cons entry out))
9734 (list (car (car scor)) (nth 2 (car scor))
9735 (and (nth 3 (car scor))
9736 (gnus-day-number (nth 3 (car scor))))
9737 (if (nth 1 (car scor)) 'r 's)))
9738 (setq scor (cdr scor))))
9739 (setq out (cons (list (car entry) (cdr entry)) out)))
9740 (setq alist (cdr alist)))
9741 (cons (list 'touched t) (nreverse out))))
9743 (defun gnus-score-save ()
9744 ;; Save all SCORE information.
9747 (set-buffer gnus-summary-buffer)
9748 (setq cache gnus-score-cache
9749 gnus-score-cache nil))
9751 (setq gnus-score-alist nil)
9752 (set-buffer (get-buffer-create "*Score*"))
9753 (buffer-disable-undo (current-buffer))
9754 (let (entry score file)
9756 (setq entry (car cache)
9760 (if (or (not (equal (gnus-score-get 'touched score) '(t)))
9761 (gnus-score-get 'read-only score)
9762 (not (file-writable-p file)))
9764 (setq score (delq (assq 'touched score) score))
9766 (let (emacs-lisp-mode-hook)
9767 (pp score (current-buffer)))
9768 (make-directory (file-name-directory file) t)
9769 (write-region (point-min) (point-max) file nil 'silent))))
9770 (kill-buffer (current-buffer)))))
9772 (defun gnus-score-headers ()
9773 ;; Score `gnus-newsgroup-headers'.
9774 (let ((score-files (and (symbolp gnus-score-find-score-files-function)
9775 (fboundp gnus-score-find-score-files-function)
9776 (funcall gnus-score-find-score-files-function
9777 gnus-newsgroup-name)))
9779 ;; Load the SCORE files.
9781 (setq scores (nconc (gnus-score-load-file (car score-files)) scores))
9782 (setq score-files (cdr score-files)))
9783 (if (not (and gnus-summary-default-score
9785 (> (length gnus-newsgroup-headers)
9786 (length gnus-newsgroup-scored))))
9788 (let* ((entries gnus-header-index)
9789 (now (gnus-day-number (current-time-string)))
9790 (expire (- now gnus-score-expiry-days))
9791 (headers gnus-newsgroup-headers)
9793 (message "Scoring...")
9794 ;; Create articles, an alist of the form `(HEADER . SCORE)'.
9796 (setq header (car headers)
9797 headers (cdr headers))
9798 ;; WARNING: The assq makes the function O(N*S) while it could
9799 ;; be written as O(N+S), where N is (length gnus-newsgroup-headers)
9800 ;; and S is (length gnus-newsgroup-scored).
9801 (or (assq (header-number header) gnus-newsgroup-scored)
9802 (setq gnus-scores-articles ;Total of 2 * N cons-cells used.
9803 (cons (cons header (or gnus-summary-default-score 0))
9804 gnus-scores-articles))))
9807 (set-buffer (get-buffer-create "*Headers*"))
9808 (buffer-disable-undo (current-buffer))
9809 ;; Run each header through the score process.
9811 (setq entry (car entries)
9812 header (nth 0 entry)
9813 entries (cdr entries))
9814 (setq gnus-score-index (nth 1 (assoc header gnus-header-index)))
9815 (if (< 0 (apply 'max (mapcar
9817 (length (gnus-score-get header score)))
9819 (funcall (nth 2 entry) scores header now expire)))
9820 ;; Remove the buffer.
9821 (kill-buffer (current-buffer)))
9823 ;; Add articles to `gnus-newsgroup-scored'.
9824 (while gnus-scores-articles
9825 (or (= gnus-summary-default-score (cdr (car gnus-scores-articles)))
9826 (setq gnus-newsgroup-scored
9827 (cons (cons (header-number
9828 (car (car gnus-scores-articles)))
9829 (cdr (car gnus-scores-articles)))
9830 gnus-newsgroup-scored)))
9831 (setq gnus-scores-articles (cdr gnus-scores-articles)))
9833 (message "Scoring...done")))))
9835 ;;(defun gnus-score-integer (scores header now expire)
9838 ;;(defun gnus-score-date (scores header now expire)
9841 (defun gnus-score-string (scores header now expire)
9842 ;; Score ARTICLES according to HEADER in SCORES.
9843 ;; Update matches entries to NOW and remove unmatched entried older
9846 ;; Insert the unique article headers in the buffer.
9847 (let ((gnus-score-index (nth 1 (assoc header gnus-header-index)))
9848 ;; gnus-score-index is used as a free variable.
9849 alike last this art entries alist articles)
9851 ;; Sorting the articles costs os O(N*log N) but will allow us to
9852 ;; only match with each unique header. Thus the actual matching
9853 ;; will be O(M*U) where M is the number of strings to match with,
9854 ;; and U is the number of unique headers. It is assumed (but
9855 ;; untested) this will be a net win because of the large constant
9856 ;; factor involved with string matching.
9857 (setq gnus-scores-articles (sort gnus-scores-articles 'gnus-score-string<)
9858 articles gnus-scores-articles)
9862 (setq art (car articles)
9863 this (aref (car art) gnus-score-index)
9864 articles (cdr articles))
9865 (if (equal last this)
9866 ;; O(N*H) cons-cells used here, where H is the number of
9868 (setq alike (cons art alike))
9871 ;; Insert the line, with a text property on the
9872 ;; terminating newline refering to the articles with
9875 (put-text-property (1- (point)) (point) 'articles alike)))
9876 (setq alike (list art)
9878 (and last ; Bwadr, duplicate code.
9881 (put-text-property (1- (point)) (point) 'articles alike)))
9885 (setq alist (car scores)
9887 entries (assoc header alist))
9888 (while (cdr entries) ;First entry is the header index.
9889 (let* ((rest (cdr entries))
9891 (match (nth 0 kill))
9892 (type (or (nth 3 kill) 's))
9893 (score (or (nth 1 kill) gnus-score-interactive-default-score))
9896 (case-fold-search t)
9898 (goto-char (point-min))
9899 (while (cond ((eq type 'r)
9900 (re-search-forward match nil t))
9902 (search-forward match nil t)))
9905 arts (get-text-property (point) 'articles))
9906 ;; Found a match, update scores.
9908 (setq art (car arts)
9910 (setcdr art (+ score (cdr art)))))
9911 ;; Update expire date
9912 (cond ((null date)) ;Permanent entry.
9913 (found ;Match, update date.
9914 (gnus-score-set 'touched '(t) alist)
9915 (setcar (nthcdr 2 kill) now))
9916 ((< date expire) ;Old entry, remove.
9917 (gnus-score-set 'touched '(t) alist)
9918 (setcdr entries (cdr rest))
9919 (setq rest entries)))
9920 (setq entries rest))))))
9922 (defun gnus-score-string< (a1 a2)
9923 ;; Compare headers in articles A2 and A2.
9924 ;; The header index used is the free variable `gnus-score-index'.
9925 (string-lessp (aref (car a1) gnus-score-index)
9926 (aref (car a2) gnus-score-index)))
9928 (defun gnus-score-build-cons (article)
9929 ;; Build a `gnus-newsgroup-scored' type cons from ARTICLE.
9930 (cons (header-number (car article)) (cdr article)))
9932 (defconst gnus-header-index
9933 ;; Name to index alist.
9934 '(("number" 0 gnus-score-integer)
9935 ("subject" 1 gnus-score-string)
9936 ("from" 2 gnus-score-string)
9937 ("date" 3 gnus-score-date)
9938 ("message-id" 4 gnus-score-string)
9939 ("references" 5 gnus-score-string)
9940 ("chars" 6 gnus-score-integer)
9941 ("lines" 7 gnus-score-integer)
9942 ("xref" 8 gnus-score-string)))
9944 (defun gnus-score-file-name (newsgroup)
9945 "Return the name of a score file for NEWSGROUP."
9946 (cond ((or (null newsgroup)
9947 (string-equal newsgroup ""))
9948 ;; The global score file is placed at top of the directory.
9949 (expand-file-name gnus-score-file-suffix
9950 (or gnus-kill-files-directory "~/News")))
9951 (gnus-use-long-file-name
9952 ;; Append ".SCORE" to newsgroup name.
9953 (expand-file-name (concat newsgroup "." gnus-score-file-suffix)
9954 (or gnus-kill-files-directory "~/News")))
9956 ;; Place "SCORE" under the hierarchical directory.
9957 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
9958 "/" gnus-score-file-suffix)
9959 (or gnus-kill-files-directory "~/News")))))
9961 (defun gnus-score-score-files (group)
9962 "Return a list of all possible score files."
9963 (and gnus-global-score-files
9964 (or gnus-internal-global-score-files
9965 (gnus-score-search-global-directories gnus-global-score-files)))
9966 (setq gnus-kill-files-directory
9967 (file-name-as-directory
9968 (or gnus-kill-files-directory "~/News/")))
9969 (if (not (file-readable-p gnus-kill-files-directory))
9970 (setq gnus-score-file-list nil)
9971 (if gnus-use-long-file-name
9972 (if (or (not gnus-score-file-list)
9973 (gnus-file-newer-than gnus-kill-files-directory
9974 (car gnus-score-file-list)))
9975 (setq gnus-score-file-list
9976 (cons (nth 5 (file-attributes gnus-kill-files-directory))
9979 gnus-kill-files-directory t
9980 (concat gnus-score-file-suffix "$"))))))
9981 (let ((dir (expand-file-name
9982 (concat gnus-kill-files-directory
9983 (gnus-replace-chars-in-string group ?. ?/))))
9984 (mdir (length (expand-file-name gnus-kill-files-directory)))
9986 (if (file-exists-p (concat dir "/" gnus-score-file-suffix))
9987 (setq files (list (concat dir "/" gnus-score-file-suffix))))
9988 (while (>= (1+ (length dir)) mdir)
9989 (and (file-exists-p (concat dir "/all/" gnus-score-file-suffix))
9990 (setq files (cons (concat dir "/all/" gnus-score-file-suffix)
9992 (string-match "/[^/]*$" dir)
9993 (setq dir (substring dir 0 (match-beginning 0))))
9994 (setq gnus-score-file-list
9995 (cons nil (nreverse files)))))
9996 (cdr gnus-score-file-list)))
9998 (defun gnus-score-find-single (group)
9999 "Return list containing the score file for GROUP."
10000 (list (gnus-score-file-name group)))
10002 (defun gnus-score-find-hierarchical (group)
10003 "Return list of score files for GROUP.
10004 This includes the score file for the group and all its parents."
10005 (let ((all (copy-sequence '(nil)))
10007 (while (string-match "\\." group (1+ start))
10008 (setq start (match-beginning 0))
10009 (setq all (cons (substring group 0 start) all)))
10010 (setq all (cons group all))
10011 (mapcar 'gnus-score-file-name (nreverse all))))
10013 (defun gnus-score-find-bnews (group)
10014 "Return a list of score files for GROUP.
10015 The score files are those files in the ~/News directory which matches
10016 GROUP using BNews sys file syntax."
10017 (let* ((sfiles (append (gnus-score-score-files group)
10018 gnus-internal-global-score-files))
10019 (kill-dir (file-name-as-directory
10020 (expand-file-name gnus-kill-files-directory)))
10021 (klen (length kill-dir))
10022 ofiles not-match regexp)
10024 (set-buffer (get-buffer-create "*gnus score files*"))
10025 (buffer-disable-undo (current-buffer))
10026 ;; Go through all score file names and create regexp with them
10030 (insert (car sfiles))
10032 ;; First remove the suffix itself.
10033 (re-search-forward (concat "." gnus-score-file-suffix "$"))
10036 (if (looking-at (regexp-quote kill-dir))
10037 ;; If the file name was just "SCORE", `klen' is one character
10039 (delete-char (min (1- (point-max)) klen))
10040 (goto-char (point-max))
10041 (search-backward "/")
10042 (delete-region (1+ (point)) (point-min)))
10043 ;; Translate "all" to ".*".
10044 (while (search-forward "all" nil t)
10045 (replace-match ".*"))
10047 ;; Deal with "not."s.
10048 (if (looking-at "not.")
10051 (setq regexp (buffer-substring 5 (point-max))))
10052 (setq regexp (buffer-substring 1 (point-max)))
10053 (setq not-match nil))
10054 ;; Finally - if this resulting regexp matches the group name,
10055 ;; we add this score file to the list of score files
10056 ;; applicable to this group.
10057 (if (or (and not-match
10058 (not (string-match regexp group)))
10059 (and (not not-match)
10060 (string-match regexp group)))
10061 (setq ofiles (cons (car sfiles) ofiles)))
10062 (setq sfiles (cdr sfiles)))
10063 (kill-buffer (current-buffer))
10064 ;; Slight kludge here - the last score file returned should be
10065 ;; the local score file, whether it exists or not. This is so
10066 ;; that any score commands the user enters will go to the right
10067 ;; file, and not end up in some global score file.
10070 (if gnus-use-long-file-name
10071 (concat gnus-kill-files-directory group "."
10072 gnus-score-file-suffix)
10073 (concat gnus-kill-files-directory
10074 (gnus-replace-chars-in-string group ?. ?/)
10075 "/" gnus-score-file-suffix)))))
10076 (and (member localscore ofiles)
10077 (delete localscore ofiles))
10078 (setq ofiles (cons localscore ofiles)))
10079 (nreverse ofiles))))
10081 (defun gnus-score-search-global-directories (files)
10082 "Scan all global score directories for score files."
10083 ;; Set the variable `gnus-internal-global-score-files' to all
10084 ;; available global score files.
10085 (interactive (list gnus-global-score-files))
10088 (if (string-match "/$" (car files))
10089 (setq out (nconc (directory-files
10091 (concat gnus-score-file-suffix "$"))))
10092 (setq out (cons (car files) out)))
10093 (setq files (cdr files)))
10094 (setq gnus-internal-global-score-files out)))
10100 (defvar gnus-score-mode-map nil)
10101 (defvar gnus-score-mode-hook nil)
10103 (if gnus-score-mode-map
10105 (setq gnus-score-mode-map (copy-keymap emacs-lisp-mode-map))
10106 (define-key gnus-score-mode-map "\C-c\C-c" 'gnus-score-edit-done)
10107 (define-key gnus-score-mode-map "\C-c\C-d" 'gnus-score-edit-insert-date))
10109 (defun gnus-score-mode ()
10110 "Mode for editing score files.
10111 This mode is an extended emacs-lisp mode.
10113 \\{gnus-score-mode-map}"
10115 (kill-all-local-variables)
10116 (use-local-map gnus-score-mode-map)
10117 (set-syntax-table emacs-lisp-mode-syntax-table)
10118 (setq major-mode 'gnus-score-mode)
10119 (setq mode-name "Score")
10120 (lisp-mode-variables nil)
10121 (run-hooks 'emacs-lisp-mode-hook 'gnus-score-mode-hook))
10123 (defun gnus-score-edit-insert-date ()
10124 "Insert date in numerical format."
10126 (insert (int-to-string (gnus-day-number (current-time-string)))))
10128 (defun gnus-score-edit-done ()
10129 "Save the score file and return to the summary buffer."
10131 (let ((bufnam (buffer-file-name (current-buffer))))
10133 (kill-buffer (current-buffer))
10134 (and gnus-winconf-edit-score
10135 (set-window-configuration gnus-winconf-edit-score))
10136 (gnus-score-remove-from-cache bufnam)
10137 (gnus-score-load-file bufnam)))
10141 ;;; Gnus Posting Functions
10144 (defvar gnus-organization-file "/usr/lib/news/organization"
10145 "*Local news organization file.")
10147 (defvar gnus-post-news-buffer "*post-news*")
10148 (defvar gnus-winconf-post-news nil)
10150 ;;; Post news commands of Gnus group mode and summary mode
10152 (defun gnus-group-post-news ()
10155 (gnus-set-global-variables)
10156 ;; Save window configuration.
10157 (setq gnus-winconf-post-news (current-window-configuration))
10158 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
10159 (or gnus-newsgroup-name (setq gnus-newsgroup-name (gnus-group-group-name)))
10161 (gnus-post-news 'post)
10162 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
10163 (not (zerop (buffer-size))))
10164 ;; Restore last window configuration.
10165 (and gnus-winconf-post-news
10166 (set-window-configuration gnus-winconf-post-news))))
10167 ;; We don't want to return to summary buffer nor article buffer later.
10168 (setq gnus-winconf-post-news nil)
10169 (if (get-buffer gnus-summary-buffer)
10170 (bury-buffer gnus-summary-buffer))
10171 (if (get-buffer gnus-article-buffer)
10172 (bury-buffer gnus-article-buffer)))
10174 (defun gnus-summary-post-news ()
10177 (gnus-set-global-variables)
10178 ;; Save window configuration.
10179 (setq gnus-winconf-post-news (current-window-configuration))
10181 (gnus-post-news 'post gnus-newsgroup-name)
10182 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
10183 (not (zerop (buffer-size))))
10184 ;; Restore last window configuration.
10185 (and gnus-winconf-post-news
10186 (set-window-configuration gnus-winconf-post-news))))
10187 ;; We don't want to return to article buffer later.
10188 (if (get-buffer gnus-article-buffer)
10189 (bury-buffer gnus-article-buffer)))
10191 (defun gnus-summary-followup (yank)
10192 "Compose a followup to an article.
10193 If prefix argument YANK is non-nil, original article is yanked automatically."
10195 (gnus-set-global-variables)
10196 (save-window-excursion
10197 (gnus-summary-select-article t))
10198 (let ((headers gnus-current-headers)
10199 (gnus-newsgroup-name gnus-newsgroup-name))
10200 ;; Check Followup-To: poster.
10201 (set-buffer gnus-article-buffer)
10202 (if (and gnus-use-followup-to
10203 (string-equal "poster" (gnus-fetch-field "followup-to"))
10204 (or (not (eq gnus-use-followup-to t))
10205 (not (gnus-y-or-n-p
10206 "Do you want to ignore `Followup-To: poster'? "))))
10207 ;; Mail to the poster. Gnus is now RFC1036 compliant.
10208 (gnus-summary-reply yank)
10209 ;; Save window configuration.
10210 (setq gnus-winconf-post-news (current-window-configuration))
10212 (gnus-post-news nil gnus-newsgroup-name
10213 headers gnus-article-buffer yank)
10214 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
10215 (not (zerop (buffer-size))))
10216 ;; Restore last window configuration.
10217 (and gnus-winconf-post-news
10218 (set-window-configuration gnus-winconf-post-news))))
10219 ;; We don't want to return to article buffer later.
10220 (bury-buffer gnus-article-buffer))))
10222 (defun gnus-summary-followup-with-original ()
10223 "Compose a followup to an article and include the original article."
10225 (gnus-summary-followup t))
10227 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10228 (defun gnus-summary-followup-and-reply (yank)
10229 "Compose a followup and do an auto mail to author."
10231 (let ((gnus-auto-mail-to-author t))
10232 (gnus-summary-followup yank)))
10234 (defun gnus-summary-followup-and-reply-with-original ()
10235 "Compose a followup, include the original, and do an auto mail to author."
10237 (gnus-summary-followup-and-reply t))
10239 (defun gnus-summary-cancel-article ()
10240 "Cancel an article you posted."
10242 (gnus-set-global-variables)
10243 (gnus-summary-select-article t)
10244 (gnus-eval-in-buffer-window gnus-article-buffer
10245 (gnus-cancel-news)))
10247 (defun gnus-summary-supersede-article ()
10248 "Compose an article that will supersede a previous article.
10249 This is done simply by taking the old article and adding a Supersedes
10250 header line with the old Message-ID."
10252 (gnus-set-global-variables)
10255 (downcase (mail-strip-quoted-names
10256 (header-from gnus-current-headers)))
10257 (downcase (mail-strip-quoted-names (gnus-inews-user-name)))))
10258 (error "This article is not yours."))
10259 (gnus-summary-select-article t)
10261 (set-buffer gnus-article-buffer)
10262 (let ((buffer-read-only nil))
10263 (goto-char (point-min))
10264 (search-forward "\n\n" nil t)
10265 (if (not (re-search-backward "^Message-ID: " nil t))
10266 (error "No Message-ID in this article"))))
10267 (if (gnus-post-news 'post gnus-newsgroup-name)
10270 (insert-buffer gnus-article-buffer)
10271 (goto-char (point-min))
10272 (search-forward "\n\n" nil t)
10273 (if (not (re-search-backward "^Message-ID: " nil t))
10274 (error "No Message-ID in this article")
10275 (replace-match "Supersedes: "))
10276 (search-forward "\n\n")
10278 (insert mail-header-separator))))
10282 (fset 'sendnews 'gnus-post-news)
10285 (fset 'postnews 'gnus-post-news)
10287 (defun gnus-post-news (post &optional group header article-buffer yank)
10288 "Begin editing a new USENET news article to be posted.
10289 Type \\[describe-mode] in the buffer to get a list of commands."
10290 (interactive (list t))
10291 (if (or (not gnus-novice-user)
10295 (format "%s" (car (gnus-find-method-for-group
10296 gnus-newsgroup-name)))
10297 gnus-valid-select-methods))))
10298 (assq 'to-address (gnus-find-method-for-group gnus-newsgroup-name))
10299 (gnus-y-or-n-p "Are you sure you want to post to all of USENET? "))
10300 (let ((sumart (if (not post)
10302 (set-buffer gnus-summary-buffer)
10303 (cons (current-buffer) gnus-current-article))))
10304 (from (and header (header-from header)))
10305 subject follow-to real-group)
10306 (and gnus-interactive-post
10307 (not gnus-expert-user)
10311 (completing-read "Group: " gnus-active-hashtb nil t))
10312 (setq subject (read-string "Subject: "))))
10313 (setq mail-reply-buffer article-buffer)
10315 (setq real-group (gnus-group-real-name group))
10316 (setq gnus-post-news-buffer
10317 (gnus-request-post-buffer
10318 post real-group subject header article-buffer
10319 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
10320 (if (and (boundp 'gnus-followup-to-function)
10321 gnus-followup-to-function)
10324 (set-buffer article-buffer)
10325 (funcall gnus-followup-to-function group))))
10326 (eq gnus-use-followup-to t)))
10329 (gnus-configure-windows '(1 0 0))
10330 (switch-to-buffer gnus-post-news-buffer))
10331 (gnus-configure-windows '(0 1 0))
10334 (switch-to-buffer article-buffer)
10335 (pop-to-buffer gnus-post-news-buffer))
10336 (switch-to-buffer gnus-post-news-buffer)))
10337 (gnus-overload-functions)
10338 (make-local-variable 'gnus-article-reply)
10339 (make-local-variable 'gnus-article-check-size)
10340 (setq gnus-article-reply sumart)
10341 ;; Handle `gnus-auto-mail-to-author'.
10342 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10343 (let ((to (if (eq gnus-auto-mail-to-author 'ask)
10344 (and (y-or-n-p "Also send mail to author? ") from)
10345 (and gnus-auto-mail-to-author from))))
10348 (if (mail-fetch-field "To")
10350 (beginning-of-line)
10351 (insert "Cc: " to "\n"))
10352 (mail-position-on-field "To")
10354 ;; Handle author copy using BCC field.
10355 (if (and gnus-mail-self-blind
10356 (not (mail-fetch-field "bcc")))
10358 (mail-position-on-field "Bcc")
10359 (insert (if (stringp gnus-mail-self-blind)
10360 gnus-mail-self-blind
10361 (user-login-name)))))
10362 ;; Handle author copy using FCC field.
10363 (if gnus-author-copy
10365 (mail-position-on-field "Fcc")
10366 (insert gnus-author-copy)))
10367 (goto-char (point-min))
10370 (re-search-forward "^Newsgroup:" nil t)
10373 (re-search-forward "^Subject:" nil t)
10376 (search-forward (concat "\n" mail-header-separator "\n"))))
10377 (search-forward (concat "\n" mail-header-separator "\n"))
10380 (run-hooks 'news-reply-header-hook)
10381 (mail-yank-original nil)))
10382 (if gnus-post-prepare-function
10383 (funcall gnus-post-prepare-function group)))))
10384 (setq gnus-article-check-size (cons (buffer-size) (gnus-article-checksum)))
10388 (defun gnus-inews-news (&optional use-group-method)
10389 "Send a news message.
10390 If given a prefix, and the group is a foreign group, this function
10391 will attempt to use the foreign server to post the article."
10393 ;; Check whether the article is a good Net Citizen.
10394 (if (and gnus-article-check-size (not (gnus-inews-check-post)))
10397 ;; Looks ok, so we do the nasty.
10398 (let* ((case-fold-search nil)
10399 (server-running (gnus-server-opened gnus-select-method))
10400 (reply gnus-article-reply))
10402 ;; Connect to default NNTP server if necessary.
10403 ;; Suggested by yuki@flab.fujitsu.junet.
10404 (gnus-start-news-server) ;Use default server.
10405 ;; NNTP server must be opened before current buffer is modified.
10407 (goto-char (point-min))
10408 (run-hooks 'news-inews-hook)
10413 (goto-char (point-min))
10414 (search-forward (concat "\n" mail-header-separator "\n"))
10417 ;; Correct newsgroups field: change sequence of spaces to comma and
10418 ;; eliminate spaces around commas. Eliminate imbedded line breaks.
10419 (goto-char (point-min))
10420 (if (search-forward-regexp "^Newsgroups: +" nil t)
10424 (if (re-search-forward "^[^ \t]" nil 'end)
10425 (match-beginning 0)
10427 (goto-char (point-min))
10428 (replace-regexp "\n[ \t]+" " ") ;No line breaks (too confusing)
10429 (goto-char (point-min))
10430 (replace-regexp "[ \t\n]*,[ \t\n]*\\|[ \t]+" ",")))
10432 ;; Added by Per Abrahamsen <abraham@iesd.auc.dk>.
10433 ;; Help save the the world!
10436 (let ((newsgroups (mail-fetch-field "newsgroups"))
10437 (followup-to (mail-fetch-field "followup-to"))
10439 (if (and (string-match "," newsgroups) (not followup-to))
10441 (while (string-match "," newsgroups)
10443 (cons (list (substring newsgroups
10444 0 (match-beginning 0)))
10446 (setq newsgroups (substring newsgroups (match-end 0))))
10447 (setq groups (nreverse (cons (list newsgroups) groups)))
10450 (completing-read "Followups to: (default all groups) "
10452 (if (> (length to) 0)
10454 (goto-char (point-min))
10455 (insert "Followup-To: " to "\n")))))))
10457 ;; Cleanup Followup-To.
10458 (goto-char (point-min))
10459 (if (search-forward-regexp "^Followup-To: +" nil t)
10463 (if (re-search-forward "^[^ \t]" nil 'end)
10464 (match-beginning 0)
10466 (goto-char (point-min))
10467 (replace-regexp "\n[ \t]+" " ") ;No line breaks (too confusing)
10468 (goto-char (point-min))
10469 (replace-regexp "[ \t\n]*,[ \t\n]*\\|[ \t]+" ",")))
10471 ;; Mail the message too if To:, Bcc:. or Cc: exists.
10472 (if (or (mail-fetch-field "to" nil t)
10473 (mail-fetch-field "bcc" nil t)
10474 (mail-fetch-field "cc" nil t))
10475 (if gnus-mail-send-method
10479 (message "Sending via mail...")
10481 (if gnus-mail-courtesy-message
10483 ;; Insert "courtesy" mail message.
10485 (re-search-forward mail-header-separator)
10487 (insert gnus-mail-courtesy-message)
10488 (funcall gnus-mail-send-method)
10490 (search-forward gnus-mail-courtesy-message)
10491 (replace-match ""))
10492 (funcall gnus-mail-send-method))
10494 (message "Sending via mail... done")
10498 1 (re-search-forward mail-header-separator))
10500 (delete-matching-lines "BCC:.*")))
10502 (message "No mailer defined. To: and/or Cc: fields ignored.")
10505 ;; Send to NNTP server.
10506 (message "Posting to USENET...")
10507 (if (gnus-inews-article use-group-method)
10509 (message "Posting to USENET... done")
10511 (get-buffer (car reply))
10512 (buffer-name (car reply)))
10515 (set-buffer gnus-summary-buffer)
10516 (gnus-summary-mark-article-as-replied
10518 ;; We cannot signal an error.
10519 (ding) (message "Article rejected: %s"
10520 (gnus-status-message gnus-select-method)))
10521 (set-buffer-modified-p nil))
10522 ;; If NNTP server is opened by gnus-inews-news, close it by myself.
10524 (gnus-close-server (gnus-find-method-for-group gnus-newsgroup-name)))
10525 (and (fboundp 'bury-buffer) (bury-buffer))
10526 ;; Restore last window configuration.
10527 (and gnus-winconf-post-news
10528 (set-window-configuration gnus-winconf-post-news))
10529 (setq gnus-winconf-post-news nil))))
10531 (defun gnus-inews-check-post ()
10532 "Check whether the post looks ok."
10534 ;; Check excessive size.
10535 (if (> (buffer-size) 60000)
10536 (gnus-y-or-n-p (format "The article is %d octets long. Really post? "
10539 ;; Check for commands in Subject.
10542 (goto-char (point-min))
10543 (narrow-to-region (point) (search-forward mail-header-separator))
10544 (if (string-match "^cmsg " (mail-fetch-field "subject"))
10546 "The control code \"cmsg \" is in the subject. Really post? ")
10548 ;; Check for control characters.
10550 (if (re-search-forward "[\000-\007\013\015-\037\200-\237]" nil t)
10552 "The article contains control characters. Really post? ")
10554 ;; Check for multiple identical headers.
10558 (goto-char (point-min))
10559 (narrow-to-region (point) (search-forward mail-header-separator))
10560 (goto-char (point-min))
10561 (while (and (not found) (re-search-forward "^[^ \t:]+: " nil t))
10563 (or (re-search-forward
10564 (concat "^" (setq found
10565 (buffer-substring (match-beginning 0)
10568 (setq found nil))))
10571 (format "Multiple %s headers. Really post? " found))
10573 ;; Check for version and sendsys.
10576 (goto-char (point-min))
10577 (narrow-to-region (point) (search-forward mail-header-separator))
10578 (if (re-search-backward "^Sendsys:\\|^Version:" nil t)
10580 (format "The article contains a %s command. Really post? "
10581 (buffer-substring (match-beginning 0) (match-end 0))))
10585 (goto-char (point-min))
10586 (narrow-to-region (point) (search-forward mail-header-separator))
10587 (let* ((case-fold-search t)
10588 (from (mail-fetch-field "from")))
10590 (string-match "@" from)
10591 (not (string-match "@[^\\.]*\\." from)))
10593 (format "The domain looks strange: \"%s\". Really post? "
10596 ;; Use the (size . checksum) variable to see whether the
10597 ;; article is empty or has only quoted text.
10598 (if (and (= (buffer-size) (car gnus-article-check-size))
10599 (= (gnus-article-checksum) (cdr gnus-article-check-size)))
10601 "It looks like there's no new text in your article. Really post? ")
10604 (defun gnus-article-checksum ()
10607 (while (not (eobp))
10608 (setq sum (logxor sum (following-char)))
10612 (defun gnus-cancel-news ()
10613 "Cancel an article you posted."
10615 (if (gnus-yes-or-no-p "Do you really want to cancel this article? ")
10619 (distribution nil))
10621 ;; Get header info. from original article.
10623 (gnus-article-show-all-headers)
10624 (goto-char (point-min))
10625 (search-forward "\n\n" nil 'move)
10626 (narrow-to-region (point-min) (point))
10627 (setq from (mail-fetch-field "from"))
10628 (setq newsgroups (mail-fetch-field "newsgroups"))
10629 (setq message-id (mail-fetch-field "message-id"))
10630 (setq distribution (mail-fetch-field "distribution")))
10631 ;; Verify if the article is absolutely user's by comparing
10632 ;; user id with value of its From: field.
10635 (downcase (mail-strip-quoted-names from))
10636 (downcase (mail-strip-quoted-names (gnus-inews-user-name)))))
10638 (ding) (message "This article is not yours."))
10639 ;; Make control article.
10640 (set-buffer (get-buffer-create " *Gnus-canceling*"))
10641 (buffer-disable-undo (current-buffer))
10643 (insert "Newsgroups: " newsgroups "\n"
10644 "Subject: cancel " message-id "\n"
10645 "Control: cancel " message-id "\n"
10646 mail-header-separator "\n"
10647 "This is a cancel message from " from ".\n")
10648 ;; Send the control article to NNTP server.
10649 (message "Canceling your article...")
10650 (if (gnus-inews-article)
10651 (message "Canceling your article... done")
10652 (ding) (message "Failed to cancel your article"))
10653 ;; Kill the article buffer.
10654 (kill-buffer (current-buffer)))))))
10657 ;;; Lowlevel inews interface
10659 (defun gnus-inews-article (&optional use-group-method)
10660 "Post an article in current buffer using NNTP protocol."
10661 (let ((artbuf (current-buffer))
10662 (tmpbuf (get-buffer-create " *Gnus-posting*")))
10664 (goto-char (point-max))
10665 ;; require a newline at the end for inews to append .signature to
10666 (or (= (preceding-char) ?\n)
10668 ;; Prepare article headers. All message body such as signature
10669 ;; must be inserted before Lines: field is prepared.
10671 (goto-char (point-min))
10675 (search-forward (concat "\n" mail-header-separator "\n"))
10678 (gnus-inews-insert-headers)
10679 (run-hooks gnus-inews-article-header-hook)
10682 (set-buffer tmpbuf)
10683 (buffer-disable-undo (current-buffer))
10685 (insert-buffer-substring artbuf)
10686 ;; Remove the header separator.
10687 (goto-char (point-min))
10688 (search-forward (concat "\n" mail-header-separator "\n"))
10689 (replace-match "\n\n")
10690 ;; This hook may insert a signature.
10691 (run-hooks 'gnus-prepare-article-hook)
10692 ;; Run final inews hooks. This hook may do FCC.
10693 ;; The article must be saved before being posted because
10694 ;; `gnus-request-post' modifies the buffer.
10695 (run-hooks 'gnus-inews-article-hook)
10696 ;; Post an article to NNTP server.
10697 ;; Return NIL if post failed.
10700 (if use-group-method
10701 (gnus-find-method-for-group gnus-newsgroup-name)
10702 gnus-select-method) use-group-method)
10703 (kill-buffer (current-buffer))))))
10705 (defun gnus-inews-insert-headers ()
10706 "Prepare article headers.
10707 Headers already prepared in the buffer are not modified.
10708 Headers in `gnus-required-headers' will be generated."
10709 (let ((Date (gnus-inews-date))
10710 (Message-ID (gnus-inews-message-id))
10711 (Organization (gnus-inews-organization))
10712 (From (gnus-inews-user-name))
10713 (Path (gnus-inews-path))
10717 (Lines (gnus-inews-lines))
10718 (X-Newsreader gnus-version)
10719 (headers gnus-required-headers)
10720 (case-fold-search t)
10722 ;; First we remove any old Message-IDs. This might be slightly
10723 ;; fascist, but if the user really wants to generate Message-IDs
10724 ;; by herself, she should remove it from the `gnus-required-list'.
10725 (goto-char (point-min))
10726 (and (memq 'Message-ID headers)
10727 (re-search-forward "^Message-ID:" nil t)
10728 (delete-region (progn (beginning-of-line) (point))
10729 (progn (forward-line 1) (point))))
10730 ;; Remove NNTP-posting-host.
10731 (goto-char (point-min))
10732 (and (re-search-forward "nntp-posting-host^:" nil t)
10733 (delete-region (progn (beginning-of-line) (point))
10734 (progn (forward-line 1) (point))))
10735 ;; Insert new Sender if the From is strange.
10736 (let ((from (mail-fetch-field "from")))
10737 (if (and from (not (string= (downcase from) (downcase From))))
10739 (goto-char (point-min))
10740 (and (re-search-forward "^Sender:" nil t)
10741 (delete-region (progn (beginning-of-line) (point))
10742 (progn (forward-line 1) (point))))
10743 (insert "Sender: " From "\n"))))
10744 ;; If there are References, and no "Re: ", then the thread has
10745 ;; changed name. See Son-of-1036.
10746 (if (and (mail-fetch-field "references")
10747 (get-buffer gnus-article-buffer))
10748 (let ((psubject (gnus-simplify-subject-re
10749 (mail-fetch-field "subject")))
10752 (set-buffer (get-buffer gnus-article-buffer))
10754 (gnus-narrow-to-headers)
10755 (if (setq subject (mail-fetch-field "subject"))
10757 (and gnus-summary-gather-subject-limit
10758 (> (length subject) gnus-summary-gather-subject-limit)
10760 (substring subject 0
10761 gnus-summary-gather-subject-limit)))
10762 (setq subject (gnus-simplify-subject-re subject))))))
10763 (or (and psubject subject (string= subject psubject))
10765 (string-match "@" Message-ID)
10767 (concat (substring Message-ID 0 (match-beginning 0))
10769 (substring Message-ID (match-beginning 0))))))))
10770 ;; Go through all the required headers and see if they are in the
10771 ;; articles already. If they are not, or are empty, they are
10772 ;; inserted automatically - except for Subject, Newsgroups and
10775 (goto-char (point-min))
10776 (setq header (car headers))
10777 (if (or (not (re-search-forward
10778 (concat "^" (downcase (symbol-name header)) ":") nil t))
10780 (if (= (following-char) ? ) (forward-char 1) (insert " "))
10781 (looking-at "[ \t]*$")))
10783 (setq value (or (and (boundp header) (symbol-value header))
10784 (read-from-minibuffer
10785 (format "Empty header for %s; enter value: "
10789 (goto-char (point-max))
10790 (insert (symbol-name header) ": " value "\n"))
10791 (replace-match value))))
10792 (setq headers (cdr headers)))))
10794 (defun gnus-inews-insert-signature ()
10795 "Insert a signature file.
10796 If `gnus-signature-function' is bound and returns a string, this
10797 string is used instead of the variable `gnus-signature-file'.
10798 In either case, if the string is a file name, this file is
10799 inserted. If the string is not a file name, the string itself is
10801 If you never want any signature inserted, set both those variables to
10805 (or (and gnus-signature-function
10806 (fboundp gnus-signature-function)
10807 (funcall gnus-signature-function gnus-newsgroup-name))
10808 gnus-signature-file))
10811 (or (file-exists-p signature)
10812 (string-match " " signature)
10814 "^/[^/]+/" (expand-file-name signature)))))
10816 (goto-char (point-max))
10817 ;; Delete any previous signatures.
10818 (if (and mail-signature (search-backward "\n-- \n" nil t))
10819 (delete-region (1+ (point)) (point-max)))
10821 (and (< 4 (setq b (count-lines
10824 (if (file-exists-p signature)
10825 (insert-file-contents signature)
10826 (insert signature))
10827 (goto-char (point-max))
10828 (or (bolp) (insert "\n"))
10830 (not gnus-expert-user)
10834 "Your .sig is %d lines; it should be max 4. Really post? "
10836 (if (file-exists-p signature)
10837 (error (format "Edit %s." signature))
10838 (error "Trim your signature."))))))))
10840 (defun gnus-inews-do-fcc ()
10841 "Process FCC: fields in current article buffer.
10842 Unless the first character of the field is `|', the article is saved
10843 to the specified file using the function specified by the variable
10844 gnus-author-copy-saver. The default function rmail-output saves in
10845 Unix mailbox format.
10846 If the first character is `|', the contents of the article is send to
10847 a program specified by the rest of the value."
10848 (let ((fcc-list nil)
10850 (case-fold-search t)) ;Should ignore case.
10853 (goto-char (point-min))
10854 (search-forward "\n\n")
10855 (narrow-to-region (point-min) (point))
10856 (goto-char (point-min))
10857 (while (re-search-forward "^FCC:[ \t]*" nil t)
10859 (cons (buffer-substring
10863 (skip-chars-backward " \t")
10866 (delete-region (match-beginning 0)
10867 (progn (forward-line 1) (point))))
10868 ;; Process FCC operations.
10871 (setq fcc-file (car fcc-list))
10872 (setq fcc-list (cdr fcc-list))
10873 (cond ((string-match "^[ \t]*|[ \t]*\\(.*\\)[ \t]*$" fcc-file)
10874 (let ((program (substring fcc-file
10875 (match-beginning 1) (match-end 1))))
10876 ;; Suggested by yuki@flab.fujitsu.junet.
10877 ;; Send article to named program.
10878 (call-process-region (point-min) (point-max) shell-file-name
10879 nil nil nil "-c" program)))
10881 ;; Suggested by hyoko@flab.fujitsu.junet.
10882 ;; Save article in Unix mail format by default.
10883 (if (and gnus-author-copy-saver
10884 (not (eq gnus-author-copy-saver 'rmail-output)))
10885 (funcall gnus-author-copy-saver fcc-file)
10886 (if (and (file-readable-p fcc-file) (rmail-file-p fcc-file))
10887 (gnus-output-to-rmail fcc-file)
10888 (rmail-output fcc-file 1 t t))))))))))
10890 (defun gnus-inews-path ()
10891 "Return uucp path."
10892 (let ((login-name (gnus-inews-login-name)))
10893 (cond ((null gnus-use-generic-path)
10894 (concat (nth 1 gnus-select-method) "!" login-name))
10895 ((stringp gnus-use-generic-path)
10896 ;; Support GENERICPATH. Suggested by vixie@decwrl.dec.com.
10897 (concat gnus-use-generic-path "!" login-name))
10900 (defun gnus-inews-user-name ()
10901 "Return user's network address as \"NAME@DOMAIN (FULL-NAME)\"."
10902 (let ((full-name (gnus-inews-full-name)))
10903 (concat (if (or gnus-user-login-name gnus-use-generic-from
10904 gnus-local-domain (getenv "DOMAINNAME"))
10905 (concat (gnus-inews-login-name) "@"
10906 (gnus-inews-domain-name gnus-use-generic-from))
10908 ;; User's full name.
10909 (cond ((string-equal full-name "") "")
10910 ((string-equal full-name "&") ;Unix hack.
10911 (concat " (" (user-login-name) ")"))
10913 (concat " (" full-name ")"))))))
10915 (defun gnus-inews-login-name ()
10916 "Return login name."
10917 (or gnus-user-login-name (getenv "LOGNAME") (user-login-name)))
10919 (defun gnus-inews-full-name ()
10920 "Return full user name."
10921 (or gnus-user-full-name (getenv "NAME") (user-full-name)))
10923 (defun gnus-inews-domain-name (&optional genericfrom)
10924 "Return user's domain name.
10925 If optional argument GENERICFROM is a string, use it as the domain
10926 name; if it is non-nil, strip off local host name from the domain name.
10927 If the function `system-name' returns full internet name and the
10928 domain is undefined, the domain name is got from it."
10929 (if (or genericfrom gnus-local-domain (getenv "DOMAINNAME"))
10930 (let* ((system-name (system-name))
10932 (or (if (stringp genericfrom) genericfrom)
10933 (getenv "DOMAINNAME")
10935 ;; Function `system-name' may return full internet name.
10936 ;; Suggested by Mike DeCorte <mrd@sun.soe.clarkson.edu>.
10937 (if (string-match "\\." system-name)
10938 (substring system-name (match-end 0)))
10939 (read-string "Domain name (no host): ")))
10940 (host (or (if (string-match "\\." system-name)
10941 (substring system-name 0 (match-beginning 0)))
10943 (if (string-equal "." (substring domain 0 1))
10944 (setq domain (substring domain 1)))
10945 ;; Support GENERICFROM as same as standard Bnews system.
10946 ;; Suggested by ohm@kaba.junet and vixie@decwrl.dec.com.
10947 (cond ((null genericfrom)
10948 (concat host "." domain))
10949 ;;((stringp genericfrom) genericfrom)
10951 (if (string-match "\\." (system-name))
10953 (substring user-mail-address
10954 (1+ (string-match "@" user-mail-address))))))
10956 (defun gnus-inews-full-address ()
10957 (let ((domain (gnus-inews-domain-name))
10958 (system (system-name))
10959 (case-fold-search t))
10960 (if (string-match "\\." system) system
10961 (if (string-match (concat "^" (regexp-quote system)) domain) domain
10962 (concat system "." domain)))))
10964 (defun gnus-inews-message-id ()
10965 "Generate unique Message-ID for user."
10966 ;; Message-ID should not contain a slash and should be terminated by
10967 ;; a number. I don't know the reason why it is so.
10968 (concat "<" (gnus-inews-unique-id) "@" (gnus-inews-full-address) ">"))
10970 (defun gnus-inews-unique-id ()
10971 "Generate unique ID from user name and current time."
10972 (concat (downcase (gnus-inews-login-name))
10974 (lambda (num) (gnus-number-base-x num 3 31))
10975 (current-time) "")))
10977 (defun gnus-inews-date ()
10978 "Current time string."
10979 (timezone-make-date-arpa-standard
10980 (current-time-string) (current-time-zone)))
10982 (defun gnus-inews-organization ()
10983 "Return user's organization.
10984 The ORGANIZATION environment variable is used if defined.
10985 If not, the variable `gnus-local-organization' is used instead.
10986 If it is a function, the function will be called with the current
10987 newsgroup name as the argument.
10988 If this is a file name, the contents of this file will be used as the
10990 (let* ((organization
10991 (or (getenv "ORGANIZATION")
10992 (if gnus-local-organization
10993 (if (and (symbolp gnus-local-organization)
10994 (fboundp gnus-local-organization))
10995 (funcall gnus-local-organization gnus-newsgroup-name)
10996 gnus-local-organization))
10997 gnus-organization-file
10998 "~/.organization")))
10999 (and (stringp organization)
11000 (> (length organization) 0)
11001 (or (file-exists-p organization)
11002 (string-match " " organization)
11003 (not (string-match "^/[^/]+/" (expand-file-name organization))))
11005 (set-buffer (get-buffer-create " *Gnus organization*"))
11006 (buffer-disable-undo (current-buffer))
11008 (if (file-exists-p organization)
11009 (insert-file-contents organization)
11010 (insert organization))
11011 (goto-char (point-min))
11012 (while (re-search-forward " *\n *" nil t)
11013 (replace-match " "))
11014 (buffer-substring (point-min) (point-max))))))
11016 (defun gnus-inews-lines ()
11017 "Count the number of lines and return numeric string."
11021 (goto-char (point-min))
11022 (search-forward "\n\n" nil 'move)
11023 (int-to-string (count-lines (point) (point-max))))))
11027 ;;; Gnus Mail Functions
11030 ;;; Mail reply commands of Gnus summary mode
11032 (defun gnus-summary-reply (yank)
11033 "Reply mail to news author.
11034 If prefix argument YANK is non-nil, original article is yanked automatically.
11035 Customize the variable gnus-mail-reply-method to use another mailer."
11037 ;; Bug fix by jbw@bigbird.bu.edu (Joe Wells)
11038 ;; Stripping headers should be specified with mail-yank-ignored-headers.
11039 (gnus-summary-select-article t)
11040 (setq gnus-winconf-post-news (current-window-configuration))
11041 (let ((gnus-newsgroup-name gnus-newsgroup-name))
11042 (bury-buffer gnus-article-buffer)
11043 (funcall gnus-mail-reply-method yank)))
11045 (defun gnus-summary-reply-with-original ()
11046 "Reply mail to news author with original article.
11047 Customize the variable gnus-mail-reply-method to use another mailer."
11049 (gnus-summary-reply t))
11051 (defun gnus-summary-mail-forward ()
11052 "Forward the current message to another user.
11053 Customize the variable gnus-mail-forward-method to use another mailer."
11055 (gnus-summary-select-article t)
11056 (setq gnus-winconf-post-news (current-window-configuration))
11057 (set-buffer gnus-article-buffer)
11058 (let ((gnus-newsgroup-name gnus-newsgroup-name))
11059 (funcall gnus-mail-forward-method)))
11061 (defun gnus-summary-mail-other-window ()
11062 "Compose mail in other window.
11063 Customize the variable `gnus-mail-other-window-method' to use another
11066 (setq gnus-winconf-post-news (current-window-configuration))
11067 (let ((gnus-newsgroup-name gnus-newsgroup-name))
11068 (funcall gnus-mail-other-window-method)))
11070 (defun gnus-mail-reply-using-mail (&optional yank to-address)
11072 (set-buffer gnus-summary-buffer)
11073 (let ((info (nth 2 (gnus-gethash gnus-newsgroup-name gnus-newsrc-hashtb)))
11074 (group (gnus-group-real-name gnus-newsgroup-name))
11075 (cur (cons (current-buffer) (cdr gnus-article-current)))
11076 from subject date to reply-to message-of
11077 references message-id sender follow-to cc)
11078 (set-buffer (get-buffer-create "*mail*"))
11080 (make-local-variable 'gnus-article-reply)
11081 (setq gnus-article-reply cur)
11082 (use-local-map (copy-keymap mail-mode-map))
11083 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
11084 (if (and (buffer-modified-p)
11085 (> (buffer-size) 0)
11086 (not (gnus-y-or-n-p
11087 "Unsent article being composed; erase it? ")))
11091 (set-buffer gnus-article-buffer)
11092 (let ((buffer-read-only nil))
11093 (goto-char (point-min))
11094 (narrow-to-region (point-min)
11095 (progn (search-forward "\n\n") (point)))
11096 (add-text-properties (point-min) (point-max) '(invisible nil)))
11097 (if (and (boundp 'gnus-reply-to-function)
11098 gnus-reply-to-function)
11101 (gnus-narrow-to-headers)
11102 (setq follow-to (funcall gnus-reply-to-function group)))))
11103 (setq from (mail-fetch-field "from"))
11104 (setq date (mail-fetch-field "date"))
11107 (string-match " *at \\| *@ \\| *(\\| *<" from)))
11109 (concat (if stop-pos (substring from 0 stop-pos) from)
11110 "'s message of " date))))
11111 (setq sender (mail-fetch-field "sender"))
11112 (setq subject (or (mail-fetch-field "subject")
11114 (or (string-match "^[Rr][Ee]:" subject)
11115 (setq subject (concat "Re: " subject)))
11116 (setq cc (mail-fetch-field "cc"))
11117 (setq reply-to (mail-fetch-field "reply-to"))
11118 (setq references (mail-fetch-field "references"))
11119 (setq message-id (mail-fetch-field "message-id"))
11121 (setq news-reply-yank-from from)
11122 (setq news-reply-yank-message-id message-id)
11123 (mail-setup (or to-address follow-to reply-to from sender "")
11124 subject message-of nil gnus-article-buffer nil)
11125 ;; Fold long references line to follow RFC1036.
11126 (mail-position-on-field "References")
11127 (let ((begin (- (point) (length "References: ")))
11129 (fill-prefix "\t"))
11130 (if references (insert references))
11131 (if (and references message-id) (insert " "))
11132 (if message-id (insert message-id))
11133 ;; The region must end with a newline to fill the region
11134 ;; without inserting extra newline.
11135 (fill-region-as-paragraph begin (1+ (point))))
11136 (goto-char (point-min))
11137 (search-forward (concat "\n" mail-header-separator "\n"))
11139 (let ((last (point)))
11140 (run-hooks 'news-reply-header-hook)
11141 (mail-yank-original nil)
11142 (goto-char last))))
11144 (let ((mail (current-buffer)))
11145 (gnus-configure-windows '(0 0 1))
11146 (switch-to-buffer-other-window mail))
11147 (gnus-configure-windows '(0 1 0))
11148 (switch-to-buffer (current-buffer))))))
11150 (defun gnus-mail-yank-original ()
11152 (run-hooks 'news-reply-header-hook)
11153 (mail-yank-original nil))
11155 (defun gnus-mail-send-and-exit ()
11157 (let ((cbuf (current-buffer)))
11158 (mail-send-and-exit nil)
11159 (if (get-buffer gnus-group-buffer)
11163 (let ((reply gnus-article-reply))
11165 (get-buffer (car reply))
11166 (buffer-name (car reply)))
11168 (set-buffer (car reply))
11170 (gnus-summary-mark-article-as-replied
11172 (and gnus-winconf-post-news
11173 (set-window-configuration gnus-winconf-post-news))
11174 (setq gnus-winconf-post-news nil)))))
11176 (defun gnus-mail-forward-using-mail ()
11177 "Forward the current message to another user using mail."
11178 ;; This is almost a carbon copy of rmail-forward in rmail.el.
11179 (let ((forward-buffer (current-buffer))
11181 (concat "[" gnus-newsgroup-name "] "
11182 (or (gnus-fetch-field "Subject") "")))
11184 ;; If only one window, use it for the mail buffer.
11185 ;; Otherwise, use another window for the mail buffer
11186 ;; so that the Rmail buffer remains visible
11187 ;; and sending the mail will get back to it.
11188 (if (if (one-window-p t)
11189 (mail nil nil subject)
11190 (mail-other-window nil nil subject))
11192 (use-local-map (copy-keymap emacs-lisp-mode-map))
11193 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
11194 (setq beg (goto-char (point-max)))
11195 (insert "------- Start of forwarded message -------\n")
11196 (insert-buffer forward-buffer)
11197 (goto-char (point-max))
11198 (insert "------- End of forwarded message -------\n")
11199 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
11201 (while (setq beg (next-single-property-change (point) 'invisible))
11203 (delete-region beg (or (next-single-property-change
11204 (point) 'invisible)
11206 ;; You have a chance to arrange the message.
11207 (run-hooks 'gnus-mail-forward-hook)))))
11209 (defun gnus-mail-other-window-using-mail ()
11210 "Compose mail other window using mail."
11211 (mail-other-window nil nil nil nil nil nil (get-buffer gnus-article-buffer))
11212 (use-local-map (copy-keymap emacs-lisp-mode-map))
11213 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit))
11220 (defvar gnus-dribble-ignore nil)
11222 (defun gnus-dribble-file-name ()
11223 (concat gnus-startup-file "-dribble"))
11225 (defun gnus-dribble-open ()
11228 (setq gnus-dribble-buffer (find-file-noselect (gnus-dribble-file-name))))
11229 (buffer-disable-undo (current-buffer))
11230 (bury-buffer gnus-dribble-buffer)
11232 (goto-char (point-max))))
11234 (defun gnus-dribble-enter (string)
11235 (if (and (not gnus-dribble-ignore)
11236 gnus-dribble-buffer
11237 (buffer-name gnus-dribble-buffer))
11238 (let ((obuf (current-buffer)))
11239 (set-buffer gnus-dribble-buffer)
11240 (insert string "\n")
11241 (set-window-point (get-buffer-window (current-buffer)) (point-max))
11242 (set-buffer obuf))))
11244 (defun gnus-dribble-read-file ()
11245 (let ((dribble-file (gnus-dribble-file-name)))
11247 (set-buffer (setq gnus-dribble-buffer
11249 (file-name-nondirectory dribble-file))))
11250 (gnus-add-current-to-buffer-list)
11252 (set-visited-file-name dribble-file)
11253 (buffer-disable-undo (current-buffer))
11254 (bury-buffer (current-buffer))
11255 (set-buffer-modified-p nil)
11256 (let ((auto (make-auto-save-file-name))
11257 (gnus-dribble-ignore t))
11258 (if (or (file-exists-p auto) (file-exists-p dribble-file))
11260 (if (file-newer-than-file-p auto dribble-file)
11261 (setq dribble-file auto))
11262 (insert-file-contents dribble-file)
11263 (if (not (zerop (buffer-size)))
11264 (set-buffer-modified-p t))
11266 "Auto-save file exists. Do you want to read it? ")
11268 (message "Reading %s..." dribble-file)
11269 (eval-current-buffer)
11270 (message "Reading %s...done" dribble-file)))))))))
11272 (defun gnus-dribble-delete-file ()
11273 (if (file-exists-p (gnus-dribble-file-name))
11274 (delete-file (gnus-dribble-file-name)))
11275 (if gnus-dribble-buffer
11277 (set-buffer gnus-dribble-buffer)
11278 (let ((auto (make-auto-save-file-name)))
11279 (if (file-exists-p auto)
11280 (delete-file auto))
11282 (set-buffer-modified-p nil)))))
11284 (defun gnus-dribble-save ()
11285 (if (and gnus-dribble-buffer
11286 (buffer-name gnus-dribble-buffer))
11288 (set-buffer gnus-dribble-buffer)
11291 (defun gnus-dribble-clear ()
11293 (if (and gnus-dribble-buffer
11294 (buffer-name (get-buffer gnus-dribble-buffer)))
11296 (set-buffer gnus-dribble-buffer)
11298 (set-buffer-modified-p nil)
11299 (setq buffer-saved-size (buffer-size))))))
11302 ;;; Server Communication
11305 ;; All the Gnus backends have the same interface, and should return
11306 ;; data in a similar format. Below is an overview of what functions
11307 ;; these packages must supply and what results they should return.
11311 ;; `nntp-server-buffer' - All data should be returned to Gnus in this
11314 ;; Functions for the imaginary backend `choke':
11316 ;; `choke-retrieve-headers ARTICLES &optional GROUP SERVER'
11317 ;; Should return all headers for all ARTICLES, or return NOV lines for
11320 ;; `choke-request-group GROUP &optional SERVER DISCARD'
11321 ;; Switch to GROUP. If DISCARD is nil, active information on the group
11322 ;; must be returned.
11324 ;; `choke-close-group GROUP &optional SERVER'
11325 ;; Close group. Most backends won't have to do anything with this
11326 ;; call, but it is an opportunity to clean up, if that is needed. It
11327 ;; is called when Gnus exits a group.
11329 ;; `choke-request-article ARTICLE &optional GROUP SERVER'
11330 ;; Return ARTICLE, which is either an article number or
11331 ;; message-id. Note that not all backends can return articles based on
11334 ;; `choke-request-list SERVER'
11335 ;; Return a list of all newsgroups on SERVER.
11337 ;; `choke-request-list-newsgroups SERVER'
11338 ;; Return a list of descriptions of all newsgroups on SERVER.
11340 ;; `choke-request-newgroups DATE &optional SERVER'
11341 ;; Return a list of all groups that have arrived after DATE on
11342 ;; SERVER. Note that the date doesn't have to be respected - Gnus will
11343 ;; always check whether the groups are old or not. Backends that do
11344 ;; not store date information may just return the entire list of
11345 ;; groups, although this might not be a good idea in general.
11347 ;; `choke-request-post-buffer METHOD HEADER ARTICLE-BUFFER GROUP INFO'
11348 ;; Should return a buffer that is suitable for "posting". nnspool and
11349 ;; nntp return a `*post-buffer*', and nnmail return a `*mail*'
11350 ;; buffer. This function should fill out the appropriate headers.
11352 ;; `choke-request-post &optional SERVER'
11353 ;; Function that will be called from a buffer to be posted.
11355 ;; `choke-open-server SERVER &optional ARGUMENT'
11356 ;; Open a connection to SERVER.
11358 ;; `choke-close-server &optional SERVER'
11359 ;; Close the connection to SERVER.
11361 ;; `choke-server-opened &optional SERVER'
11362 ;; Whether the conenction to SERVER is opened or not.
11364 ;; `choke-server-status &optional SERVER'
11365 ;; Should return a status string (not in the nntp buffer, but as the
11366 ;; result of the function).
11368 ;; The following functions are optional and apply only to backends
11369 ;; that are able to control the contents of their groups totally
11370 ;; (ie. mail backends.) Backends that aren't able to do that
11371 ;; shouldn't define these functions at all. Gnus will check for their
11372 ;; presence before attempting to call them.
11374 ;; `choke-request-expire-articles ARTICLES &optional NEWSGROUP SERVER'
11375 ;; Should expire (according to some aging scheme) all ARTICLES. Most
11376 ;; backends will not be able to expire articles. Should return a list
11377 ;; of all articles that were not expired.
11379 ;; `choke-request-move-article ARTICLE GROUP SERVER ACCEPT-FORM &optional LAST'
11380 ;; Should move ARTICLE from GROUP on SERVER by using ACCEPT-FORM.
11381 ;; Removes any information it has added to the article (extra headers,
11382 ;; whatever - make it as clean as possible), and then passes the
11383 ;; article on by evaling ACCEPT-FORM, which is normally a call to the
11384 ;; function described below. If the ACCEPT-FORM returns a non-nil
11385 ;; value, the article should then be deleted. If LAST is nil, that
11386 ;; means that there will be further calls to this function. This might
11387 ;; be taken as an advice not to save buffers/internal variables just
11388 ;; yet, but wait until the last call to speed things up.
11390 ;; `choke-request-accept-article GROUP &optional LAST'
11391 ;; The contents of the current buffer will be put into GROUP. There
11392 ;; should, of course, be an article in the current buffer. This
11393 ;; function is normally only called by the function described above,
11394 ;; and LAST works the same way as in that function.
11396 ;; `choke-request-replace-article ARTICLE GROUP BUFFER'
11397 ;; Replace ARTICLE in GROUP with the contents of BUFFER.
11398 ;; This provides an easy interface for allowing editing of
11399 ;; articles. Note that even headers may be edited, so the backend has
11400 ;; to update any tables (nov buffers, etc) that it maintains after
11401 ;; replacing the article.
11403 ;; All these functions must return nil if they couldn't service the
11404 ;; request. If the optional arguments are not supplied, some "current"
11405 ;; or "default" values should be used. In short, one should emulate an
11406 ;; NNTP server, in a way.
11408 ;; If you want to write a new backend, you just have to supply the
11409 ;; functions listed above. In addition, you must enter the new backend
11410 ;; into the list of valid select methods:
11411 ;; (setq gnus-valid-select-methods
11412 ;; (cons '("choke" mail) gnus-valid-select-methods))
11413 ;; The first element in this list is the name of the backend. Other
11414 ;; elemnets may be `mail' (for mail groups), `post' (for news
11415 ;; groups), `none' (neither), `respool' (for groups that can control
11416 ;; their contents).
11418 (defun gnus-start-news-server (&optional confirm)
11419 "Open a method for getting news.
11420 If CONFIRM is non-nil, the user will be asked for an NNTP server."
11422 (if gnus-current-select-method
11423 ;; Stream is already opened.
11425 ;; Open NNTP server.
11426 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
11429 ;; Read server name with completion.
11430 (setq gnus-nntp-server
11431 (completing-read "NNTP server: "
11432 (mapcar (lambda (server) (list server))
11433 (cons (list gnus-nntp-server)
11434 gnus-secondary-servers))
11435 nil nil gnus-nntp-server))))
11437 (if (and gnus-nntp-server
11438 (stringp gnus-nntp-server)
11439 (not (string= gnus-nntp-server "")))
11440 (setq gnus-select-method
11441 (cond ((or (string= gnus-nntp-server "")
11442 (string= gnus-nntp-server "::"))
11443 (list 'nnspool (system-name)))
11444 ((string-match ":" gnus-nntp-server)
11445 (list 'nnmh gnus-nntp-server))
11447 (list 'nntp gnus-nntp-server)))))
11449 (setq how (car gnus-select-method))
11450 (setq where (car (cdr gnus-select-method)))
11451 (cond ((eq how 'nnspool)
11453 (message "Looking up local news spool..."))
11456 (message "Looking up mh spool..."))
11459 (setq gnus-current-select-method gnus-select-method)
11460 (run-hooks 'gnus-open-server-hook)
11462 ;; gnus-open-server-hook might have opened it
11463 (gnus-server-opened gnus-select-method)
11464 (gnus-open-server gnus-select-method)
11465 (error "%s" (gnus-nntp-message
11466 (format "Cannot open NNTP server on %s"
11468 gnus-select-method)))
11470 (defun gnus-check-news-server (method)
11471 "If the news server is down, start it up again."
11472 (let ((method (if method method gnus-select-method)))
11473 (if (gnus-server-opened method)
11474 ;; Stream is already opened.
11477 (message "Opening server %s on %s..." (car method) (nth 1 method))
11478 (run-hooks 'gnus-open-server-hook)
11479 (or (gnus-server-opened method)
11480 (gnus-open-server method))
11483 (defun gnus-nntp-message (&optional message)
11484 "Check the status of the NNTP server.
11485 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
11486 is returned insted of the status string."
11487 (let ((status (gnus-status-message (gnus-find-method-for-group
11488 gnus-newsgroup-name)))
11489 (message (or message "")))
11490 (if (and (stringp status) (> (length status) 0))
11493 (defun gnus-get-function (method function)
11494 (let ((func (intern (format "%s-%s" (car method) function))))
11495 (if (not (fboundp func))
11497 (require (car method))
11498 (if (not (fboundp func))
11499 (error "No such function: %s" func))))
11502 ;; Specifying port number suggested by Stephane Laveau <laveau@corse.inria.fr>.
11503 (defun gnus-open-server (method)
11504 (apply (gnus-get-function method 'open-server) (cdr method)))
11506 (defun gnus-close-server (method)
11507 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
11509 (defun gnus-request-list (method)
11510 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
11512 (defun gnus-request-list-newsgroups (method)
11513 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
11515 (defun gnus-request-newgroups (date method)
11516 (funcall (gnus-get-function method 'request-newgroups)
11517 date (nth 1 method)))
11519 (defun gnus-server-opened (method)
11520 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
11522 (defun gnus-status-message (method)
11523 (let ((method (if (stringp method) (gnus-find-method-for-group method)
11525 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
11527 (defun gnus-request-group (group &optional dont-check)
11528 (let ((method (gnus-find-method-for-group group)))
11529 (funcall (gnus-get-function method 'request-group)
11530 (gnus-group-real-name group) (nth 1 method) dont-check)))
11532 (defun gnus-request-group-description (group)
11533 (let ((method (gnus-find-method-for-group group))
11534 (func 'request-group-description))
11535 (and (gnus-check-backend-function func group)
11536 (funcall (gnus-get-function method func)
11537 (gnus-group-real-name group) (nth 1 method)))))
11539 (defun gnus-close-group (group)
11540 (let ((method (gnus-find-method-for-group group)))
11541 (funcall (gnus-get-function method 'close-group)
11542 (gnus-group-real-name group) (nth 1 method))))
11544 (defun gnus-retrieve-headers (articles group)
11545 (let ((method (gnus-find-method-for-group group)))
11546 (funcall (gnus-get-function method 'retrieve-headers)
11547 articles (gnus-group-real-name group) (nth 1 method))))
11549 (defun gnus-request-article (article group buffer)
11550 (let ((method (gnus-find-method-for-group group)))
11551 (funcall (gnus-get-function method 'request-article)
11552 article (gnus-group-real-name group) (nth 1 method) buffer)))
11554 (defun gnus-request-head (article group)
11555 (let ((method (gnus-find-method-for-group group)))
11556 (funcall (gnus-get-function method 'request-head)
11557 article (gnus-group-real-name group) (nth 1 method))))
11559 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11560 (defun gnus-request-post-buffer (post group subject header artbuf
11561 info follow-to respect-poster)
11562 (let* ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
11564 (if (and gnus-post-method
11565 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11567 (format "%s" (car (gnus-find-method-for-group
11568 gnus-newsgroup-name)))
11569 gnus-valid-select-methods)))
11571 (gnus-find-method-for-group gnus-newsgroup-name))))
11572 (let ((mail-self-blind nil)
11573 (mail-archive-file-name nil))
11574 (funcall (gnus-get-function method 'request-post-buffer)
11575 post group subject header artbuf info follow-to
11578 (defun gnus-request-post (method &optional force)
11579 (and (not force) gnus-post-method
11580 (memq 'post (assoc (format "%s" (car method))
11581 gnus-valid-select-methods))
11582 (setq method gnus-post-method))
11583 (funcall (gnus-get-function method 'request-post)
11586 (defun gnus-request-expire-articles (articles group &optional force)
11587 (let ((method (gnus-find-method-for-group group)))
11588 (funcall (gnus-get-function method 'request-expire-articles)
11589 articles (gnus-group-real-name group) (nth 1 method)
11592 (defun gnus-request-move-article
11593 (article group server accept-function &optional last)
11594 (let ((method (gnus-find-method-for-group group)))
11595 (funcall (gnus-get-function method 'request-move-article)
11596 article (gnus-group-real-name group)
11597 (nth 1 method) accept-function last)))
11599 (defun gnus-request-accept-article (group &optional last)
11600 (let ((func (if (symbolp group) group
11601 (car (gnus-find-method-for-group group)))))
11602 (funcall (intern (format "%s-request-accept-article" func))
11603 (if (stringp group) (gnus-group-real-name group) group)
11606 (defun gnus-request-replace-article (article group buffer)
11607 (let ((func (car (gnus-find-method-for-group group))))
11608 (funcall (intern (format "%s-request-replace-article" func))
11609 article (gnus-group-real-name group) buffer)))
11611 (defun gnus-find-method-for-group (group)
11612 (or gnus-override-method
11614 gnus-select-method)
11615 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
11617 (not (nth 4 info)))
11621 (defun gnus-check-backend-function (func group)
11622 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
11624 (fboundp (intern (format "%s-%s" method func)))))
11626 (defun gnus-methods-using (method)
11627 (let ((valids gnus-valid-select-methods)
11630 (if (memq method (car valids))
11631 (setq outs (cons (car valids) outs)))
11632 (setq valids (cdr valids)))
11636 ;;; Active & Newsrc File Handling
11639 ;; Newsrc related functions.
11640 ;; Gnus internal format of gnus-newsrc-assoc:
11641 ;; (("alt.general" 3 (1 . 1))
11642 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
11643 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
11644 ;; The first item is the group name; the second is the subscription
11645 ;; level; the third is either a range of a list of ranges of read
11646 ;; articles, the optional fourth element is a list of marked articles,
11647 ;; the optional fifth element is the select method.
11649 ;; Gnus internal format of gnus-newsrc-hashtb:
11650 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
11651 ;; This is the entry for "alt.misc". The first element is the number
11652 ;; of unread articles in "alt.misc". The cdr of this entry is the
11653 ;; element *before* "alt.misc" in gnus-newsrc-assoc, which makes is
11654 ;; trivial to remove or add new elements into gnus-newsrc-assoc
11655 ;; without scanning the entire list. So, to get the actual information
11656 ;; of "alt.misc", you'd say something like
11657 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
11659 ;; Gnus internal format of gnus-active-hashtb:
11663 ;; The only element in each entry in this hash table is a range of
11664 ;; (possibly) available articles. (Articles in this range may have
11665 ;; been expired or cancelled.)
11667 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
11668 ;; ("alt.misc" "alt.test" "alt.general" ...)
11670 (defun gnus-setup-news (&optional rawfile level)
11671 "Setup news information.
11672 If RAWFILE is non-nil, the .newsrc file will also be read.
11673 If LEVEL is non-nil, the news will be set up at level LEVEL."
11674 (let ((init (not (and gnus-newsrc-assoc gnus-active-hashtb (not rawfile)))))
11675 ;; Clear some variables to re-initialize news information.
11676 (if init (setq gnus-newsrc-assoc nil gnus-active-hashtb nil))
11677 ;; Read the active file and create `gnus-active-hashtb'.
11678 ;; If `gnus-read-active-file' is nil, then we just create an empty
11679 ;; hash table. The partial filling out of the hash table will be
11680 ;; done in `gnus-get-unread-articles'.
11681 (if (and gnus-read-active-file (not level))
11682 (gnus-read-active-file)
11683 (setq gnus-active-hashtb (make-vector 4095 0)))
11685 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
11686 (if init (gnus-read-newsrc-file rawfile))
11687 ;; Find the number of unread articles in each non-dead group.
11688 (gnus-get-unread-articles (or level 6))
11689 ;; Find new newsgroups and treat them.
11690 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level))
11691 (gnus-find-new-newsgroups))
11692 (if (and init gnus-check-bogus-newsgroups
11693 gnus-read-active-file (not level))
11694 (gnus-check-bogus-newsgroups))))
11696 (defun gnus-find-new-newsgroups ()
11697 "Search for new newsgroups and add them.
11698 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
11699 The `-n' option line from .newsrc is respected."
11701 (or (gnus-check-first-time-used)
11702 (if (or (consp gnus-check-new-newsgroups)
11703 (eq gnus-check-new-newsgroups 'ask-server))
11704 (gnus-ask-server-for-new-groups)
11706 group new-newsgroups)
11707 (or gnus-have-read-active-file (gnus-read-active-file))
11708 (setq gnus-newsrc-last-checked-date (current-time-string))
11709 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
11710 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
11711 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
11714 (setq group (symbol-name sym))
11715 (if (or (gnus-gethash group gnus-killed-hashtb)
11716 (gnus-gethash group gnus-newsrc-hashtb))
11718 (if (and gnus-newsrc-options-n-yes
11719 (string-match gnus-newsrc-options-n-yes group))
11721 (setq groups (1+ groups))
11722 (gnus-sethash group group gnus-killed-hashtb)
11723 (funcall gnus-subscribe-options-newsgroup-method group))
11724 (if (or (null gnus-newsrc-options-n-no)
11725 (not (string-match gnus-newsrc-options-n-no group)))
11728 (setq groups (1+ groups))
11729 (gnus-sethash group group gnus-killed-hashtb)
11730 (if gnus-subscribe-hierarchical-interactive
11731 (setq new-newsgroups (cons group new-newsgroups))
11732 (funcall gnus-subscribe-newsgroup-method group)))))))
11733 gnus-active-hashtb)
11735 (gnus-subscribe-hierarchical-interactive new-newsgroups))
11736 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
11738 (message "%d new newsgroup%s arrived."
11739 groups (if (> groups 1) "s have" " has")))))))
11741 (defun gnus-ask-server-for-new-groups ()
11742 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
11743 (methods (cons gnus-select-method
11745 (and (consp gnus-check-new-newsgroups)
11746 gnus-check-new-newsgroups)
11747 gnus-secondary-select-methods)))
11749 (new-date (current-time-string))
11750 hashtb group new-newsgroups got-new)
11751 ;; Go thorugh both primary and secondary select methods and
11752 ;; request new newsgroups.
11754 (if (gnus-request-newgroups date (car methods))
11757 (or hashtb (setq hashtb (gnus-make-hashtable
11758 (count-lines (point-min) (point-max)))))
11759 (set-buffer nntp-server-buffer)
11760 ;; Enter all the new groups in a hashtable.
11761 (gnus-active-to-gnus-format (car methods) hashtb)))
11762 (setq methods (cdr methods)))
11763 (and got-new (setq gnus-newsrc-last-checked-date new-date))
11764 ;; Now all new groups from all select methods are in `hashtb'.
11766 (lambda (group-sym)
11767 (setq group (symbol-name group-sym))
11768 (if (or (gnus-gethash group gnus-newsrc-hashtb)
11769 (member group gnus-zombie-list)
11770 (member group gnus-killed-list))
11771 ;; The group is already known.
11773 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb)
11774 (if (and gnus-newsrc-options-n-yes
11775 (string-match gnus-newsrc-options-n-yes group))
11777 (setq groups (1+ groups))
11778 (funcall gnus-subscribe-options-newsgroup-method group))
11779 (if (or (null gnus-newsrc-options-n-no)
11780 (not (string-match gnus-newsrc-options-n-no group)))
11783 (setq groups (1+ groups))
11784 (if gnus-subscribe-hierarchical-interactive
11785 (setq new-newsgroups (cons group new-newsgroups))
11786 (funcall gnus-subscribe-newsgroup-method group)))))))
11789 (gnus-subscribe-hierarchical-interactive new-newsgroups))
11790 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
11792 (message "%d new newsgroup%s arrived."
11793 groups (if (> groups 1) "s have" " has")))
11796 (defun gnus-check-first-time-used ()
11797 (if (or (> (length gnus-newsrc-assoc) 1)
11798 (file-exists-p gnus-startup-file)
11799 (file-exists-p (concat gnus-startup-file ".el"))
11800 (file-exists-p (concat gnus-startup-file ".eld")))
11802 (message "First time user; subscribing you to default groups")
11803 (or gnus-have-read-active-file (gnus-read-active-file))
11804 (setq gnus-newsrc-last-checked-date (current-time-string))
11805 (let ((groups gnus-default-subscribed-newsgroups)
11809 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
11812 (setq group (symbol-name sym))
11813 (if (and gnus-newsrc-options-n-yes
11814 (string-match gnus-newsrc-options-n-yes group))
11815 (funcall gnus-subscribe-options-newsgroup-method group)
11816 (and (or (null gnus-newsrc-options-n-no)
11817 (not (string-match gnus-newsrc-options-n-no group)))
11818 (setq gnus-killed-list (cons group gnus-killed-list)))))
11819 gnus-active-hashtb)
11821 (if (gnus-gethash (car groups) gnus-active-hashtb)
11822 (gnus-group-change-level (car groups) 3 9))
11823 (setq groups (cdr groups)))
11824 (gnus-group-make-help-group)
11825 (and gnus-novice-user
11826 (message (substitute-command-keys "\\<gnus-group-mode-map>\\[gnus-group-list-killed] to list killed groups")))))))
11828 ;; `gnus-group-change-level' is the fundamental function for changing
11829 ;; subscription levels of newsgroups. This might mean just changing
11830 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
11831 ;; again, which subscribes/unsubscribes a group, which is equally
11832 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
11833 ;; from 8-9 to 1-7 means that you remove the group from the list of
11834 ;; killed (or zombie) groups and add them to the (kinda) subscribed
11835 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
11836 ;; which is trivial.
11837 ;; ENTRY can either be a string (newsgroup name) or a list (if
11838 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
11839 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
11841 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
11842 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
11844 (defun gnus-group-change-level (entry level &optional oldlevel
11845 previous fromkilled)
11846 (let ((pinfo entry)
11847 group info active num)
11848 ;; Glean what info we can from the arguments
11850 (if fromkilled (setq group (nth 1 entry))
11851 (setq group (car (nth 2 entry))))
11852 (setq group entry))
11853 (if (and (stringp entry)
11856 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
11857 (if (and (not oldlevel)
11859 (setq oldlevel (car (cdr (nth 2 entry)))))
11860 (if (stringp previous)
11861 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
11863 (gnus-dribble-enter
11864 (format "(gnus-group-change-level %S %S %S %S %S)"
11865 group level oldlevel (car (nth 2 previous)) fromkilled))
11867 ;; Then we remove the newgroup from any old structures, if needed.
11868 ;; If the group was killed, we remove it from the killed or zombie
11869 ;; list. If not, and it is in fact going to be killed, we remove
11870 ;; it from the newsrc hash table and assoc.
11871 (cond ((>= oldlevel 8)
11873 (setq gnus-zombie-list (delete group gnus-zombie-list))
11874 (setq gnus-killed-list (delete group gnus-killed-list))))
11878 (gnus-sethash (car (nth 2 entry))
11879 nil gnus-newsrc-hashtb)
11881 (setcdr (gnus-gethash (car (nth 3 entry))
11882 gnus-newsrc-hashtb)
11884 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
11886 ;; Finally we enter (if needed) the list where it is supposed to
11887 ;; go, and change the subscription level. If it is to be killed,
11888 ;; we enter it into the killed or zombie list.
11889 (cond ((>= level 8)
11891 (setq gnus-zombie-list (cons group gnus-zombie-list))
11892 (setq gnus-killed-list (cons group gnus-killed-list))))
11894 ;; If the list is to be entered into the newsrc assoc, and
11895 ;; it was killed, we have to create an entry in the newsrc
11896 ;; hashtb format and fix the pointers in the newsrc assoc.
11897 (if (>= oldlevel 8)
11901 (setq info (cdr entry))
11902 (setq num (car entry)))
11903 (setq active (gnus-gethash group gnus-active-hashtb))
11904 (setq num (if active (- (1+ (cdr active)) (car active)) t))
11905 ;; Check whether the group is foreign. If so, the
11906 ;; foreign select method has to be entered into the
11908 (let ((method (gnus-group-method-name group)))
11909 (if (eq method gnus-select-method)
11910 (setq info (list group level nil))
11911 (setq info (list group level nil nil method)))))
11912 (setq entry (cons info (if previous (cdr (cdr previous))
11913 (cdr gnus-newsrc-assoc))))
11914 (setcdr (if previous (cdr previous) gnus-newsrc-assoc)
11916 (gnus-sethash group (cons num (if previous (cdr previous)
11917 gnus-newsrc-assoc))
11918 gnus-newsrc-hashtb)
11920 (setcdr (gnus-gethash (car (car (cdr entry)))
11921 gnus-newsrc-hashtb)
11923 ;; It was alive, and it is going to stay alive, so we
11924 ;; just change the level and don't change any pointers or
11925 ;; hash table entries.
11926 (setcar (cdr (car (cdr (cdr entry)))) level))))))
11928 (defun gnus-kill-newsgroup (newsgroup)
11929 "Obsolete function. Kills a newsgroup."
11930 (gnus-group-change-level (gnus-gethash newsgroup gnus-newsrc-hashtb) 9))
11932 (defun gnus-check-bogus-newsgroups (&optional confirm)
11933 "Remove bogus newsgroups.
11934 If CONFIRM is non-nil, the user has to confirm the deletion of every
11936 (let ((newsrc (cdr gnus-newsrc-assoc))
11938 (message "Checking bogus newsgroups...")
11939 (or gnus-have-read-active-file (gnus-read-active-file))
11940 ;; Find all bogus newsgroup that are subscribed.
11942 (setq group (car (car newsrc)))
11943 (if (or (gnus-gethash group gnus-active-hashtb)
11944 (nth 4 (car newsrc))
11946 (not (gnus-y-or-n-p
11947 (format "Remove bogus newsgroup: %s " group)))))
11948 ;; Active newsgroup.
11950 ;; Found a bogus newsgroup.
11951 (setq bogus (cons group bogus)))
11952 (setq newsrc (cdr newsrc)))
11953 ;; Remove all bogus subscribed groups by first killing them, and
11954 ;; then removing them from the list of killed groups.
11956 (gnus-group-change-level
11957 (gnus-gethash (car bogus) gnus-newsrc-hashtb) 9)
11958 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))
11959 (setq bogus (cdr bogus)))
11960 ;; Then we remove all bogus groups from the list of killed and
11961 ;; zombie groups. They are are removed without confirmation.
11962 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
11965 (setq killed (symbol-value (car dead-lists)))
11967 (setq group (car killed))
11968 (or (gnus-gethash group gnus-active-hashtb)
11969 ;; The group is bogus.
11970 (set (car dead-lists)
11971 (delete group (symbol-value (car dead-lists)))))
11972 (setq killed (cdr killed)))
11973 (setq dead-lists (cdr dead-lists))))
11974 (message "Checking bogus newsgroups... done")))
11976 (defun gnus-check-duplicate-killed-groups ()
11977 "Remove duplicates from the list of killed groups."
11979 (let ((killed gnus-killed-list))
11981 (message "%d" (length killed))
11982 (setcdr killed (delete (car killed) (cdr killed)))
11983 (setq killed (cdr killed)))))
11985 ;; Go though `gnus-newsrc-assoc' and compare with `gnus-active-hashtb'
11986 ;; and compute how many unread articles there are in each group.
11987 (defun gnus-get-unread-articles (&optional level)
11988 (let ((newsrc (cdr gnus-newsrc-assoc))
11989 (level (or level 6))
11990 info group active virtuals)
11991 (message "Checking new news...")
11993 (setq info (car newsrc))
11994 (setq group (car info))
11995 (setq active (gnus-gethash group gnus-active-hashtb))
11997 ;; Check newsgroups. If the user doesn't want to check them, or
11998 ;; they can't be checked (for instance, if the news server can't
11999 ;; be reached) we just set the number of unread articles in this
12000 ;; newsgroup to t. This means that Gnus thinks that there are
12001 ;; unread articles, but it has no idea how many.
12003 (if (or (and gnus-activate-foreign-newsgroups
12004 (not (numberp gnus-activate-foreign-newsgroups)))
12005 (and (numberp gnus-activate-foreign-newsgroups)
12006 (<= (nth 1 info) gnus-activate-foreign-newsgroups)
12007 (<= (nth 1 info) level)))
12008 (if (eq (car (nth 4 info)) 'nnvirtual)
12009 (setq virtuals (cons info virtuals))
12010 (setq active (gnus-activate-newsgroup (car info)))))
12011 (if (and (not gnus-read-active-file)
12012 (<= (nth 1 info) level))
12014 (setq active (gnus-activate-newsgroup (car info))))))
12016 (or active (progn (gnus-sethash group nil gnus-active-hashtb)
12017 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
12018 (and active (gnus-get-unread-articles-in-group info active))
12019 (setq newsrc (cdr newsrc)))
12021 ;; Activate the virtual groups. This has to be done after all the
12023 ;; !!! If one virtual group contains another virtual group, even
12024 ;; doing it this way might cause problems.
12026 (gnus-activate-newsgroup (car (car virtuals)))
12027 (setq virtuals (cdr virtuals)))
12029 (message "Checking new news... done")))
12031 ;; Create a hash table out of the newsrc alist. The `car's of the
12032 ;; alist elements are used as keys.
12033 (defun gnus-make-hashtable-from-newsrc-alist ()
12034 (let ((alist gnus-newsrc-assoc)
12036 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
12038 (setq prev (setq gnus-newsrc-assoc
12039 (cons (list "dummy.group" 0 nil) alist))))
12041 (gnus-sethash (car (car alist)) (cons nil prev) gnus-newsrc-hashtb)
12043 (setq alist (cdr alist)))))
12045 (defun gnus-make-hashtable-from-killed ()
12046 "Create a hash table from the killed and zombie lists."
12047 (let ((lists '(gnus-killed-list gnus-zombie-list))
12049 (setq gnus-killed-hashtb
12050 (gnus-make-hashtable
12051 (+ (length gnus-killed-list) (length gnus-zombie-list))))
12053 (setq list (symbol-value (car lists)))
12054 (setq lists (cdr lists))
12056 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
12057 (setq list (cdr list))))))
12059 (defun gnus-get-unread-articles-in-group (info active)
12060 (let* ((range (nth 2 info))
12062 (marked (nth 3 info))
12063 srange lowest group highest)
12064 ;; Modify the list of read articles according to what articles
12065 ;; are available; then tally the unread articles and add the
12066 ;; number to the group hash table entry.
12067 (cond ((zerop (cdr active))
12070 (setq num (- (1+ (cdr active)) (car active))))
12071 ((atom (car range))
12072 ;; Fix a single (num . num) range according to the
12073 ;; active hash table.
12074 (and (< (cdr range) (car active)) (setcdr range (car active)))
12075 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
12076 ;; Compute number of unread articles.
12077 (setq num (max 0 (- (cdr active)
12078 (- (1+ (cdr range)) (car range))))))
12080 ;; The read list is a list of ranges. Fix them according to
12081 ;; the active hash table.
12082 ;; First peel off any elements that are below the lower
12084 (while (and (cdr range)
12086 (or (and (atom (car (cdr range))) (car (cdr range)))
12087 (car (car (cdr range))))))
12088 (setcdr (car range) (cdr (car (cdr range))))
12089 (setcdr range (cdr (cdr range))))
12090 ;; Adjust the first element to be the same as the lower limit.
12091 (if (and (not (atom (car range)))
12092 (< (cdr (car range)) (car active)))
12093 (setcdr (car range) (car active)))
12094 ;; Then we want to peel off any elements that are higher
12095 ;; than the upper active limit.
12096 (let ((srange range))
12097 ;; Go past all legal elements.
12098 (while (and (cdr srange)
12099 (<= (or (and (atom (car (cdr srange)))
12100 (car (cdr srange)))
12101 (car (car (cdr srange)))) (cdr active)))
12102 (setq srange (cdr srange)))
12104 ;; Nuke all remaining illegal elements.
12105 (setcdr srange nil))
12107 ;; Adjust the final element.
12108 (if (and (not (atom (car srange)))
12109 (> (cdr (car srange)) (cdr active)))
12110 (setcdr (car srange) (cdr active))))
12111 ;; Compute the number of unread articles.
12113 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
12114 (cdr (car range))))
12115 (or (and (atom (car range)) (car range))
12116 (car (car range))))))
12117 (setq range (cdr range)))
12118 (setq num (max 0 (- (cdr active) num)))))
12121 (and (assq 'tick marked)
12122 (inline (gnus-remove-illegal-marked-articles
12123 (assq 'tick marked) (nth 2 info))))
12124 (and (assq 'dormant marked)
12125 (inline (gnus-remove-illegal-marked-articles
12126 (assq 'dormant marked) (nth 2 info))))
12128 (gnus-gethash (car info) gnus-newsrc-hashtb)
12129 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
12130 (length (cdr (assq 'dormant marked)))))))))
12133 (defun gnus-remove-illegal-marked-articles (marked ranges)
12134 (let ((m (cdr marked)))
12135 ;; Make sure that all ticked articles are a subset of the unread
12138 (if (gnus-member-of-range (car m) ranges)
12139 (setcdr marked (cdr m))
12141 (setq m (cdr m)))))
12143 (defun gnus-activate-newsgroup (group)
12144 (let ((method (gnus-find-method-for-group group))
12146 (and (or (gnus-server-opened method) (gnus-open-server method))
12147 (gnus-request-group group)
12149 (set-buffer nntp-server-buffer)
12151 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
12153 (goto-char (match-beginning 1))
12155 group (setq active (cons (read (current-buffer))
12156 (read (current-buffer))))
12157 gnus-active-hashtb))
12160 (defun gnus-update-read-articles
12161 (group unread unselected ticked &optional domarks replied expirable killed
12162 dormant bookmark score)
12163 "Update the list of read and ticked articles in GROUP using the
12164 UNREAD and TICKED lists.
12165 Note: UNSELECTED has to be sorted over `<'.
12166 Returns whether the updating was successful."
12167 (let* ((active (gnus-gethash group gnus-active-hashtb))
12168 (entry (gnus-gethash group gnus-newsrc-hashtb))
12169 (number (car entry))
12170 (info (nth 2 entry))
12171 (marked (nth 3 info))
12173 (unread (sort (copy-sequence unread) (function <)))
12175 (if (or (not info) (not active))
12176 ;; There is no info on this group if it was, in fact,
12177 ;; killed. Gnus stores no information on killed groups, so
12178 ;; there's nothing to be done.
12179 ;; One could store the information somewhere temporarily,
12180 ;; perhaps... Hmmm...
12182 ;; Remove any negative articles numbers.
12183 (while (and unread (< (car unread) 0))
12184 (setq unread (cdr unread)))
12185 (setq unread (sort (append unselected unread) '<))
12186 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12187 (setcar entry (max 0 (- (length unread) (length ticked)
12188 (length dormant))))
12189 ;; Compute the ranges of read articles by looking at the list of
12190 ;; unread articles.
12192 (if (/= (car unread) prev)
12193 (setq read (cons (if (= prev (1- (car unread))) prev
12194 (cons prev (1- (car unread)))) read)))
12195 (setq prev (1+ (car unread)))
12196 (setq unread (cdr unread)))
12197 (if (<= prev (cdr active))
12198 (setq read (cons (cons prev (cdr active)) read)))
12199 ;; Enter this list into the group info.
12200 (setcar (cdr (cdr info))
12201 (if (> (length read) 1) (nreverse read) (car read)))
12202 ;; Enter the list of ticked articles.
12203 (gnus-set-marked-articles
12205 (if domarks replied (cdr (assq 'reply marked)))
12206 (if domarks expirable (cdr (assq 'expire marked)))
12207 (if domarks killed (cdr (assq 'killed marked)))
12208 (if domarks dormant (cdr (assq 'dormant marked)))
12209 (if domarks bookmark (cdr (assq 'bookmark marked)))
12210 (if domarks score (cdr (assq 'score marked))))
12213 (defun gnus-make-articles-unread (group articles)
12214 "Mark ARTICLES in GROUP as unread."
12215 (let ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
12216 (gnus-gethash (gnus-group-real-name group)
12217 gnus-newsrc-hashtb)))))
12218 (setcar (nthcdr 2 info)
12219 (gnus-remove-from-range (nth 2 info) articles))
12220 (gnus-group-update-group group t)))
12222 (defun gnus-read-active-file ()
12223 "Get active file from NNTP server."
12224 (gnus-group-set-mode-line)
12225 (let ((methods (cons gnus-select-method gnus-secondary-select-methods)))
12226 (setq gnus-have-read-active-file nil)
12228 (let* ((where (nth 1 (car methods)))
12229 (mesg (format "Reading active file%s via %s..."
12230 (if (and where (not (zerop (length where))))
12231 (concat " from " where) "")
12232 (car (car methods)))))
12234 (if (gnus-request-list (car methods)) ; Get active
12236 (set-buffer nntp-server-buffer)
12237 (gnus-active-to-gnus-format
12238 (and gnus-have-read-active-file (car methods)))
12239 (setq gnus-have-read-active-file t)
12240 (message "%s...done" mesg))
12241 (message "Cannot read active file from %s server."
12242 (car (car methods)))
12244 (setq methods (cdr methods)))))
12246 ;; rewritten by jwz based on ideas from Rick Sladkey <jrs@world.std.com>
12247 ;; Further rewrites by lmi.
12248 (defun gnus-active-to-gnus-format (method &optional hashtb)
12249 "Convert active file format to internal format.
12250 Lines matching `gnus-ignored-newsgroups' are ignored."
12251 (let ((cur (current-buffer))
12255 (setq gnus-active-hashtb
12256 (gnus-make-hashtable
12257 (count-lines (point-min) (point-max))))))))
12258 ;; Delete unnecessary lines.
12259 (goto-char (point-min))
12260 (delete-matching-lines gnus-ignored-newsgroups)
12261 (and method (not (eq method gnus-select-method))
12262 (let ((prefix (gnus-group-prefixed-name "" method)))
12263 (goto-char (point-min))
12264 (while (and (not (eobp))
12265 (null (insert prefix))
12266 (zerop (forward-line 1))))))
12267 (goto-char (point-min))
12268 ;; Store active file in hashtable.
12270 (if (or (re-search-forward "\n.\r?$" nil t)
12271 (goto-char (point-max)))
12273 (beginning-of-line)
12274 (narrow-to-region (point-min) (point))))
12275 (goto-char (point-min))
12276 (if (string-match "%[oO]" gnus-group-line-format)
12277 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
12278 ;; If we want information on moderated groups, we use this
12281 (let ((mod-hashtb (make-vector 7 0))
12283 (while (not (eobp))
12284 (setq group (let ((obarray hashtb))
12286 (setq max (read cur))
12287 (set group (cons (read cur) max))
12288 ;; Enter moderated groups into a list.
12290 (symbol-name (let ((obarray mod-hashtb)) (read cur)))
12292 (setq gnus-moderated-list
12293 (cons (symbol-name group) gnus-moderated-list)))
12296 (progn (ding) (message "Possible error in active file."))))
12297 ;; And if we do not care about moderation, we use this loop,
12298 ;; which is faster.
12301 (while (not (eobp))
12302 ;; group gets set to a symbol interned in the hash table
12304 (setq group (let ((obarray hashtb)) (read cur)))
12305 (setq max (read cur))
12306 (set group (cons (read cur) max))
12309 (progn (ding) (message "Possible error in active file."))))))))
12311 (defun gnus-read-newsrc-file (&optional force)
12312 "Read startup file.
12313 If FORCE is non-nil, the .newsrc file is read."
12314 (setq gnus-current-startup-file (gnus-make-newsrc-file gnus-startup-file))
12315 ;; Reset variables that might be defined in the .newsrc.eld file.
12316 (let ((variables gnus-variable-list))
12318 (set (car variables) nil)
12319 (setq variables (cdr variables))))
12320 (let* ((newsrc-file gnus-current-startup-file)
12321 (quick-file (concat newsrc-file ".el")))
12323 ;; We always load the .newsrc.eld file. If always contains
12324 ;; much information that can not be gotten from the .newsrc
12325 ;; file (ticked articles, killed groups, foreign methods, etc.)
12326 (gnus-read-newsrc-el-file quick-file)
12329 (and (file-newer-than-file-p newsrc-file quick-file)
12330 (file-newer-than-file-p newsrc-file
12331 (concat quick-file "d")))
12332 (not gnus-newsrc-assoc))
12333 ;; We read the .newsrc file. Note that if there if a
12334 ;; .newsrc.eld file exists, it has already been read, and
12335 ;; the `gnus-newsrc-hashtb' has been created. While reading
12336 ;; the .newsrc file, Gnus will only use the information it
12337 ;; can find there for changing the data already read -
12338 ;; ie. reading the .newsrc file will not trash the data
12339 ;; already read (except for read articles).
12341 (message "Reading %s..." newsrc-file)
12342 (set-buffer (find-file-noselect newsrc-file))
12343 (buffer-disable-undo (current-buffer))
12344 (gnus-newsrc-to-gnus-format)
12345 (kill-buffer (current-buffer))
12346 (message "Reading %s... done" newsrc-file)))
12347 (and gnus-use-dribble-file (gnus-dribble-read-file)))))
12349 (defun gnus-read-newsrc-el-file (file)
12350 (let ((ding-file (concat file "d")))
12351 ;; We always, always read the .eld file.
12352 (message "Reading %s..." ding-file)
12353 (condition-case nil
12354 (load ding-file t t t)
12356 (gnus-uncompress-newsrc-assoc)
12357 (gnus-make-hashtable-from-newsrc-alist)
12358 (if (not (file-newer-than-file-p file ding-file))
12360 ;; Old format quick file
12361 (message "Reading %s..." file)
12362 ;; The .el file is newer than the .eld file, so we read that one
12364 (gnus-read-old-newsrc-el-file file))))
12366 ;; Parse the old-style quick startup file
12367 (defun gnus-read-old-newsrc-el-file (file)
12368 (let (newsrc killed marked group g m len info)
12370 (let (gnus-killed-assoc gnus-marked-assoc gnus-newsrc-assoc)
12372 (condition-case nil
12375 (setq newsrc gnus-newsrc-assoc
12376 killed gnus-killed-assoc
12377 marked gnus-marked-assoc)))
12378 (setq gnus-newsrc-assoc nil)
12380 (setq group (car newsrc))
12381 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
12384 (setcar (nthcdr 2 info) (cdr (cdr group)))
12385 (setcar (cdr info) (if (nth 1 group) 3 6))
12386 (setq gnus-newsrc-assoc (cons info gnus-newsrc-assoc)))
12387 (setq gnus-newsrc-assoc
12391 (if (nth 1 group) 3 6) (cdr (cdr group))))
12392 gnus-newsrc-assoc)))
12393 (if (setq m (assoc (car group) marked))
12394 (setcdr (cdr (cdr info)) (cons (list (cons 'tick (cdr m))) nil))))
12395 (setq newsrc (cdr newsrc)))
12396 (setq newsrc killed)
12398 (setcar newsrc (car (car newsrc)))
12399 (setq newsrc (cdr newsrc)))
12400 (setq gnus-killed-list killed))
12401 (setq gnus-newsrc-assoc (nreverse gnus-newsrc-assoc))
12402 (gnus-make-hashtable-from-newsrc-alist)))
12404 (defun gnus-make-newsrc-file (file)
12405 "Make server dependent file name by catenating FILE and server host name."
12406 (let* ((file (expand-file-name file nil))
12407 (real-file (concat file "-" (nth 1 gnus-select-method))))
12408 (if (file-exists-p real-file)
12411 (defun gnus-uncompress-newsrc-assoc ()
12412 ;; Uncompress all lists of marked articles in the newsrc assoc.
12413 (let ((newsrc gnus-newsrc-assoc)
12416 (if (not (setq marked (nth 3 (car newsrc))))
12419 (or (eq 'score (car (car marked)))
12420 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
12421 (setq marked (cdr marked))))
12422 (setq newsrc (cdr newsrc)))))
12424 (defun gnus-compress-newsrc-assoc ()
12425 ;; Compress all lists of marked articles in the newsrc assoc.
12426 (let ((newsrc gnus-newsrc-assoc)
12429 (if (not (setq marked (nth 3 (car newsrc))))
12432 (or (eq 'score (car (car marked)))
12433 (setcdr (car marked)
12434 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
12435 (setq marked (cdr marked))))
12436 (setq newsrc (cdr newsrc)))))
12438 ;; jwz: rewrote this function to be much more efficient, and not be
12439 ;; subject to regexp overflow errors when it encounters very long
12440 ;; lines -- the old behavior was to blow off the rest of the *file*
12441 ;; when a line was encountered that was too long to match!! Now it
12442 ;; uses only simple looking-at calls, and doesn't create as many
12443 ;; temporary strings. It also now handles multiple consecutive
12444 ;; options lines (before it only handled the first.)
12445 ;; Tiny rewrite by lmi.
12446 (defun gnus-newsrc-to-gnus-format ()
12447 "Parse current buffer as .newsrc file."
12448 ;; We have to re-initialize these variables (except for
12449 ;; gnus-killed-list) because the quick startup file may contain bogus
12451 (setq gnus-newsrc-options nil)
12452 (setq gnus-newsrc-options-n-yes nil)
12453 (setq gnus-newsrc-options-n-no nil)
12454 (gnus-parse-options-lines)
12455 (gnus-parse-newsrc-body))
12457 (defun gnus-parse-options-lines ()
12458 ;; newsrc.5 seems to indicate that the options line can come anywhere
12459 ;; in the file, and that there can be any number of them:
12461 ;; An options line starts with the word options (left-
12462 ;; justified). Then there are the list of options just as
12463 ;; they would be on the readnews command line. For instance:
12465 ;; options -n all !net.sf-lovers !mod.human-nets -r
12468 ;; A string of lines beginning with a space or tab after the
12469 ;; initial options line will be considered continuation
12472 ;; For now, we only accept it at the beginning of the file.
12474 (goto-char (point-min))
12475 (skip-chars-forward " \t\n")
12476 (setq gnus-newsrc-options nil)
12477 (while (looking-at "^options[ \t]*\\(.*\\)\n")
12478 ;; handle consecutive options lines
12479 (setq gnus-newsrc-options (concat gnus-newsrc-options
12480 (if gnus-newsrc-options "\n\t")
12481 (buffer-substring (match-beginning 1)
12484 (while (looking-at "[ \t]+\\(.*\\)\n")
12485 ;; handle subsequent continuation lines of this options line
12486 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n\t"
12487 (buffer-substring (match-beginning 1)
12490 ;; Gather all "-n" options lines.
12493 (if gnus-newsrc-options
12494 (while (and (string-match "^[ \t]*-n\\([^\n]*\\)$"
12495 gnus-newsrc-options
12497 (setq start (match-end 0)))
12498 (setq result (concat result
12500 (substring gnus-newsrc-options
12501 (match-beginning 1)
12503 (let ((yes-and-no (and result (gnus-parse-n-options result))))
12504 (and (or gnus-options-subscribe (car yes-and-no))
12505 (setq gnus-newsrc-options-n-yes
12506 (concat (or gnus-options-subscribe "")
12507 (or (car yes-and-no) ""))))
12508 (and (or gnus-options-not-subscribe (cdr yes-and-no))
12509 (setq gnus-newsrc-options-n-no
12510 (concat (or gnus-options-not-subscribe "")
12511 (or (cdr yes-and-no) "")))))
12514 (defun gnus-parse-newsrc-body ()
12515 ;; Point has been positioned after the options lines. We shouldn't
12516 ;; see any more in here.
12518 (let ((subscribe nil)
12520 (line (1+ (count-lines (point-min) (point))))
12524 (skip-chars-forward " \t")
12525 (while (not (eobp))
12527 ((= (following-char) ?\n)
12528 ;; skip blank lines
12532 (skip-chars-forward "^:!\n")
12533 (if (= (following-char) ?\n)
12534 (error "line %d is unparsable in %s" line (buffer-name)))
12536 (skip-chars-backward " \t")
12538 ;; #### note: we could avoid consing a string here by binding obarray
12539 ;; and reading the newsgroup directly into the gnus-newsrc-hashtb,
12540 ;; then setq'ing newsgroup to symbol-name of that, like we do in
12541 ;; gnus-active-to-gnus-format.
12542 (setq newsgroup (buffer-substring p (point)))
12545 (setq subscribe (= (following-char) ?:))
12546 (setq read-list nil)
12548 (forward-char 1) ; after : or !
12549 (skip-chars-forward " \t")
12550 (while (not (= (following-char) ?\n))
12551 (skip-chars-forward " \t")
12554 ((looking-at "\\([0-9]+\\)-\\([0-9]+\\)") ; a range
12559 ;; faster that buffer-substring/string-to-int
12560 (narrow-to-region (point-min) (match-end 1))
12561 (read (current-buffer)))
12563 (narrow-to-region (point-min) (match-end 2))
12564 (forward-char) ; skip over "-"
12566 (read (current-buffer))
12570 ((looking-at "[0-9]+")
12571 ;; faster that buffer-substring/string-to-int
12572 (narrow-to-region (point-min) (match-end 0))
12573 (setq p (read (current-buffer)))
12575 (setq read-list (cons (cons p p) read-list))
12578 ;; bogus chars in ranges
12581 (goto-char (match-end 0))
12582 (skip-chars-forward " \t")
12583 (cond ((= (following-char) ?,)
12586 ((= (following-char) ?\n)
12589 ;; bogus char after range
12591 ;; if we get here, the parse failed
12593 (end-of-line) ; give up on this line
12595 (message "Ignoring bogus line %d for %s in %s"
12596 line newsgroup (buffer-name))
12598 ;; We have already read .newsrc.eld, so we gently update the
12599 ;; data in the hash table with the information we have just
12601 (let ((info (nth 2 (gnus-gethash newsgroup gnus-newsrc-hashtb))))
12604 (setcar (nthcdr 2 info) (nreverse read-list))
12605 (setcar (cdr info) (if subscribe 3 (if read-list 6 7))))
12606 (setq gnus-newsrc-assoc
12607 (cons (list newsgroup (if subscribe 3 (if read-list 6 7))
12608 (nreverse read-list))
12609 gnus-newsrc-assoc))))))
12610 (setq line (1+ line))
12611 (forward-line 1))))
12612 (setq gnus-newsrc-assoc (cdr gnus-newsrc-assoc))
12613 (gnus-make-hashtable-from-newsrc-alist)
12616 (defun gnus-parse-n-options (options)
12617 "Parse -n NEWSGROUPS options and return a cons of YES and NO regexps."
12620 (yes-or-no nil) ;`!' or not.
12622 ;; Parse each newsgroup description such as "comp.all". Commas
12623 ;; and white spaces can be a newsgroup separator.
12625 (string-match "^[ \t\n,]*\\(!?\\)\\([^- \t\n,][^ \t\n,]*\\)" options)
12627 (substring options (match-beginning 1) (match-end 1)))
12631 (match-beginning 2) (match-end 2))))
12632 (setq options (substring options (match-end 2)))
12633 ;; Rewrite "all" to ".+" not ".*". ".+" requires at least one
12635 (while (string-match "\\(^\\|\\\\[.]\\)all\\(\\\\[.]\\|$\\)" newsgroup)
12637 (concat (substring newsgroup 0 (match-end 1))
12639 (substring newsgroup (match-beginning 2)))))
12640 ;; It is yes or no.
12641 (cond ((string-equal yes-or-no "!")
12642 (setq no (cons newsgroup no)))
12643 ((string-equal newsgroup ".+")) ;Ignore `all'.
12645 (setq yes (cons newsgroup yes)))))
12646 ;; Make a cons of regexps from parsing result.
12647 ;; We have to append \(\.\|$\) to prevent matching substring of
12648 ;; newsgroup. For example, "jp.net" should not match with
12650 ;; Fixes for large regexp problems are from yonezu@nak.math.keio.ac.jp.
12653 (apply (function concat)
12655 (lambda (newsgroup)
12656 (concat newsgroup "\\|"))
12658 (car yes) "\\)\\(\\.\\|$\\)"))
12661 (apply (function concat)
12663 (lambda (newsgroup)
12664 (concat newsgroup "\\|"))
12666 (car no) "\\)\\(\\.\\|$\\)")))))
12668 (defun gnus-save-newsrc-file ()
12669 "Save .newsrc file."
12670 ;; Note: We cannot save .newsrc file if all newsgroups are removed
12671 ;; from the variable gnus-newsrc-assoc.
12672 (and (or gnus-newsrc-assoc gnus-killed-list)
12673 gnus-current-startup-file
12675 (if (or (not gnus-dribble-buffer)
12676 (not (buffer-name gnus-dribble-buffer))
12677 (zerop (save-excursion
12678 (set-buffer gnus-dribble-buffer)
12680 (message "(No changes need to be saved)")
12681 (if gnus-save-newsrc-file
12682 (let ((make-backup-files t)
12683 (version-control nil)
12684 (require-final-newline t)) ;Don't ask even if requested.
12685 (message "Saving %s..." gnus-current-startup-file)
12686 ;; Make backup file of master newsrc.
12687 ;; You can stop or change version control of backup file.
12688 ;; Suggested by jason@violet.berkeley.edu.
12689 (run-hooks 'gnus-save-newsrc-hook)
12690 (gnus-gnus-to-newsrc-format)
12691 (message "Saving %s... done" gnus-current-startup-file)))
12692 ;; Quickly loadable .newsrc.
12693 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
12694 (gnus-add-current-to-buffer-list)
12695 (buffer-disable-undo (current-buffer))
12697 (message "Saving %s.eld..." gnus-current-startup-file)
12698 (gnus-gnus-to-quick-newsrc-format)
12699 (let ((make-backup-files nil)
12700 (version-control nil)
12701 (require-final-newline t)) ;Don't ask even if requested.
12702 (write-region 1 (point-max)
12703 (concat gnus-current-startup-file ".eld")
12705 (kill-buffer (current-buffer))
12706 (message "Saving %s.eld... done" gnus-current-startup-file)
12707 (gnus-dribble-delete-file)))))
12709 (defun gnus-gnus-to-quick-newsrc-format ()
12710 "Insert Gnus variables such as gnus-newsrc-assoc in lisp format."
12711 (insert ";; (ding) Gnus startup file.\n")
12712 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
12713 (insert ";; to read .newsrc.\n")
12714 (let ((variables gnus-variable-list)
12715 (gnus-newsrc-assoc (cdr gnus-newsrc-assoc))
12717 ;; insert lisp expressions.
12718 (gnus-compress-newsrc-assoc)
12720 (setq variable (car variables))
12721 (and (boundp variable)
12722 (symbol-value variable)
12723 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
12724 (insert "(setq " (symbol-name variable) " '"
12725 (prin1-to-string (symbol-value variable))
12727 (setq variables (cdr variables)))
12728 (gnus-uncompress-newsrc-assoc)))
12731 (defun gnus-gnus-to-newsrc-format ()
12732 ;; Generate and save the .newsrc file.
12733 (let ((newsrc (cdr gnus-newsrc-assoc))
12736 (set-buffer (create-file-buffer gnus-startup-file))
12737 (buffer-disable-undo (current-buffer))
12740 (if gnus-newsrc-options (insert "options " gnus-newsrc-options "\n"))
12741 ;; Write subscribed and unsubscribed.
12743 (setq info (car newsrc))
12744 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
12746 (insert (car info) (if (>= (nth 1 info) 6) "!" ":"))
12747 (if (setq ranges (nth 2 info))
12750 (if (not (listp (cdr ranges)))
12751 (if (= (car ranges) (cdr ranges))
12752 (insert (int-to-string (car ranges)))
12753 (insert (int-to-string (car ranges)) "-"
12754 (int-to-string (cdr ranges))))
12756 (setq range (car ranges)
12757 ranges (cdr ranges))
12758 (if (or (atom range) (= (car range) (cdr range)))
12759 (insert (int-to-string
12760 (or (and (atom range) range)
12762 (insert (int-to-string (car range)) "-"
12763 (int-to-string (cdr range))))
12764 (if ranges (insert ","))))))
12766 (setq newsrc (cdr newsrc)))
12767 (write-region 1 (point-max) gnus-current-startup-file nil 'nomesg)
12768 (kill-buffer (current-buffer)))))
12770 (defun gnus-read-descriptions-file ()
12771 (message "Reading descriptions file...")
12772 (if (not (gnus-request-list-newsgroups gnus-select-method))
12774 (message "Couldn't read newsgroups descriptions")
12777 (setq gnus-description-hashtb
12778 (gnus-make-hashtable (length gnus-active-hashtb)))
12781 (set-buffer nntp-server-buffer)
12782 (goto-char (point-min))
12783 (delete-non-matching-lines "^[-\\._+A-Za-z0-9]+[ \t]")
12784 (goto-char (point-min))
12785 (if (or (search-forward "\n.\n" nil t)
12786 (goto-char (point-max)))
12788 (beginning-of-line)
12789 (narrow-to-region (point-min) (point))))
12790 (goto-char (point-min))
12791 (while (not (eobp))
12792 (setq group (let ((obarray gnus-description-hashtb))
12793 (read (current-buffer))))
12794 (skip-chars-forward " \t")
12795 (set group (buffer-substring
12796 (point) (save-excursion (end-of-line) (point))))
12797 (forward-line 1))))
12798 (message "Reading descriptions file...done")
12801 (defun gnus-group-get-description (group)
12802 ;; Get the description of a group by sending XGTITLE to the server.
12803 (and (gnus-request-group-description group)
12805 (set-buffer nntp-server-buffer)
12806 (goto-char (point-min))
12807 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
12808 (buffer-substring (match-beginning 1) (match-end 1))))))
12812 ;;; gnus.el ends here