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.44"
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))
2362 (if (not (listp (cdr numbers)))
2365 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2366 ((= (1+ last) (car numbers)) ;Still in sequence
2367 (setq last (car numbers)))
2368 (t ;End of one sequence
2370 (cons (if (= first last) first (cons first last)) result))
2371 (setq first (car numbers))
2372 (setq last (car numbers))))
2373 (setq numbers (cdr numbers)))
2374 (if (and (not always-list) (null result))
2375 (if (= first last) first (cons first last))
2376 (nreverse (cons (if (= first last) first (cons first last))
2379 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2380 (defun gnus-uncompress-range (ranges)
2381 "Expand a list of ranges into a list of numbers.
2382 RANGES is either a single range on the form `(num . num)' or a list of
2384 (let (first last result)
2388 ((not (listp (cdr ranges)))
2389 (setq first (car ranges))
2390 (setq last (cdr ranges))
2391 (while (<= first last)
2392 (setq result (cons first result))
2393 (setq first (1+ first)))
2397 (if (atom (car ranges))
2398 (if (numberp (car ranges))
2399 (setq result (cons (car ranges) result)))
2400 (setq first (car (car ranges)))
2401 (setq last (cdr (car ranges)))
2402 (while (<= first last)
2403 (setq result (cons first result))
2404 (setq first (1+ first))))
2405 (setq ranges (cdr ranges)))
2406 (nreverse result)))))
2408 (defun gnus-add-to-range (ranges list)
2409 "Return a list of ranges that has all articles from both RANGES and LIST.
2410 Note: LIST has to be sorted over `<'."
2412 (gnus-compress-sequence list t)
2413 (setq list (copy-sequence list))
2414 (or (listp (cdr ranges))
2415 (setq ranges (list ranges)))
2417 ilist lowest highest temp)
2418 (while (and ranges list)
2420 (setq lowest (or (and (atom (car ranges)) (car ranges))
2421 (car (car ranges))))
2422 (while (and list (cdr list) (< (car (cdr list)) lowest))
2423 (setq list (cdr list)))
2424 (if (< (car ilist) lowest)
2427 (setq list (cdr list))
2429 (setq out (nconc (gnus-compress-sequence ilist t) out))))
2430 (setq highest (or (and (atom (car ranges)) (car ranges))
2431 (cdr (car ranges))))
2432 (while (and list (<= (car list) highest))
2433 (setq list (cdr list)))
2434 (setq ranges (cdr ranges)))
2436 (setq out (nconc (gnus-compress-sequence list t) out)))
2437 (setq out (sort out (lambda (r1 r2)
2438 (< (or (and (atom r1) r1) (car r1))
2439 (or (and (atom r2) r2) (car r2))))))
2442 (if (atom (car ranges))
2444 (if (atom (car (cdr ranges)))
2445 (if (= (1+ (car ranges)) (car (cdr ranges)))
2447 (setcar ranges (cons (car ranges)
2448 (car (cdr ranges))))
2449 (setcdr ranges (cdr (cdr ranges)))))
2450 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
2452 (setcar (car (cdr ranges)) (car ranges))
2453 (setcar ranges (car (cdr ranges)))
2454 (setcdr ranges (cdr (cdr ranges)))))))
2456 (if (atom (car (cdr ranges)))
2457 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
2459 (setcdr (car ranges) (car (cdr ranges)))
2460 (setcdr ranges (cdr (cdr ranges)))))
2461 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
2463 (setcdr (car ranges) (cdr (car (cdr ranges))))
2464 (setcdr ranges (cdr (cdr ranges))))))))
2465 (setq ranges (cdr ranges)))
2468 (defun gnus-add-to-range-new (ranges list)
2469 (gnus-compress-sequence
2470 (sort (nconc (gnus-uncompress-range ranges) list) '<)))
2472 (defun gnus-add-to-range-old (ranges list)
2473 "Return a list of ranges that has all articles from both RANGES and LIST.
2474 Note: LIST has to be sorted over `<'."
2475 (let* ((ranges (if (and ranges (not (listp (cdr ranges))))
2476 (list ranges) ranges))
2479 range nranges first last)
2483 (gnus-compress-sequence list t)
2485 (> (car (car ranges)) 1)
2488 (setq inrange (setq ranges (cons (cons 1 1) ranges)))))
2489 (while (and ranges list)
2490 (setq range (car ranges))
2491 (while (and list (>= (car list) (car range))
2492 (<= (car list) (cdr range)))
2493 (setq list (cdr list)))
2494 (while (and list (= (1- (car list)) (cdr range)))
2495 (setcdr range (car list))
2496 (setq list (cdr list)))
2497 (if (and list (and (> (car list) (cdr range))
2499 (< (car list) (car (car (cdr ranges))))))
2500 (setcdr ranges (cons (cons (car list) (car list)) (cdr ranges))))
2501 (setq ranges (cdr ranges)))
2502 (if (and list (not ranges))
2503 (setq inrange (nconc inrange (gnus-compress-sequence list t))))
2505 (if (eq (cdr (car inrange)) 1)
2506 (setq inrange (cdr inrange))
2507 (setcar (car inrange) 2)))
2508 (setq ranges inrange)
2510 (if (and (cdr ranges) (>= (1+ (cdr (car ranges)))
2511 (car (car (cdr ranges)))))
2513 (setcdr (car ranges) (cdr (car (cdr ranges))))
2514 (setcdr ranges (cdr (cdr ranges))))
2515 (setq ranges (cdr ranges))))
2516 (if (not (cdr inrange))
2520 (defun gnus-remove-from-range (ranges list)
2521 "Return a list of ranges that has all articles from LIST removed from RANGES.
2522 Note: LIST has to be sorted over `<'."
2523 ;; !!! This function shouldn't look like this, but I've got a headache.
2524 (gnus-compress-sequence
2525 (gnus-sorted-complement
2526 (gnus-uncompress-range ranges) list)))
2528 (defun gnus-member-of-range (number ranges)
2529 (if (not (listp (cdr ranges)))
2530 (and (>= number (car ranges))
2531 (<= number (cdr ranges)))
2534 (if (numberp (car ranges))
2535 (>= number (car ranges))
2536 (>= number (car (car ranges))))
2538 (if (if (numberp (car ranges))
2539 (= number (car ranges))
2540 (and (>= number (car (car ranges)))
2541 (<= number (cdr (car ranges)))))
2542 (setq not-stop nil))
2543 (setq ranges (cdr ranges)))
2551 (defvar gnus-group-mode-map nil)
2552 (defvar gnus-group-make-map nil)
2553 (defvar gnus-group-list-map nil)
2555 (if gnus-group-mode-map
2557 (setq gnus-group-mode-map (make-keymap))
2558 (suppress-keymap gnus-group-mode-map)
2559 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
2560 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
2561 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
2562 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
2563 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
2564 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
2565 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
2566 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
2567 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
2568 (define-key gnus-group-mode-map "\M-n" 'gnus-group-next-unread-group-same-level)
2569 (define-key gnus-group-mode-map "\M-p" 'gnus-group-prev-unread-group-same-level)
2570 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
2571 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
2572 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
2573 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
2574 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
2575 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
2576 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
2577 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
2578 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
2579 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
2580 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
2581 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
2582 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
2583 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
2584 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
2585 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
2586 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
2587 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
2588 (define-key gnus-group-mode-map "\C-c\M-C-a" 'gnus-group-description-apropos)
2589 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
2590 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
2591 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
2592 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
2593 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
2594 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
2595 (define-key gnus-group-mode-map "\M-z" 'gnus-group-kill-all-zombies)
2596 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
2597 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
2598 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
2599 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
2600 (define-key gnus-group-mode-map "V" 'gnus-version)
2601 (define-key gnus-group-mode-map "S" 'gnus-group-set-current-level)
2602 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
2603 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
2604 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
2605 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
2606 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
2607 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
2608 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
2609 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
2610 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group)
2611 (define-key gnus-group-mode-map [mouse-2] 'gnus-mouse-pick-group)
2613 (define-prefix-command 'gnus-group-make-map)
2614 (define-key gnus-group-mode-map "M" 'gnus-group-make-map)
2615 (define-key gnus-group-make-map "d" 'gnus-group-make-directory-group)
2616 (define-key gnus-group-make-map "h" 'gnus-group-make-help-group)
2617 (define-key gnus-group-make-map "k" 'gnus-group-make-kiboze-group)
2618 (define-key gnus-group-make-map "m" 'gnus-group-make-group)
2619 (define-key gnus-group-make-map "e" 'gnus-group-edit-group)
2621 (define-prefix-command 'gnus-group-list-map)
2622 (define-key gnus-group-mode-map "G" 'gnus-group-list-map)
2623 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
2624 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
2625 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
2626 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
2627 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
2628 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
2629 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
2630 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
2633 (defun gnus-group-mode ()
2634 "Major mode for reading news.
2636 All normal editing commands are switched off.
2637 \\<gnus-group-mode-map>
2638 The group buffer lists (some of) the groups available. For instance,
2639 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
2640 lists all zombie groups.
2642 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
2643 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
2645 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
2647 The following commands are available:
2649 \\{gnus-group-mode-map}"
2651 (if gnus-visual (gnus-group-make-menu-bar))
2652 (kill-all-local-variables)
2653 (setq mode-line-modified "-- ")
2654 (make-local-variable 'mode-line-format)
2655 (setq mode-line-format (copy-sequence mode-line-format))
2656 (and (equal (nth 3 mode-line-format) " ")
2657 (setcar (nthcdr 3 mode-line-format) ""))
2658 (setq major-mode 'gnus-group-mode)
2659 (setq mode-name "Group")
2660 (gnus-group-set-mode-line)
2661 (setq mode-line-process nil)
2662 (use-local-map gnus-group-mode-map)
2663 (buffer-disable-undo (current-buffer))
2664 (setq truncate-lines t)
2665 (setq buffer-read-only t)
2666 (run-hooks 'gnus-group-mode-hook))
2668 (defun gnus-mouse-pick-group (e)
2671 (gnus-group-read-group nil))
2674 (defun gnus-no-server (&optional arg)
2676 If ARG is a positive number, Gnus will use that as the
2677 startup level. If ARG is nil, Gnus will be started at level 2.
2678 If ARG is non-nil and not a positive number, Gnus will
2679 prompt the user for the name of an NNTP server to use.
2680 As opposed to `gnus', this command will not connect to the local server."
2682 (gnus (or arg 2) t))
2684 (defalias '\(ding\) 'gnus)
2687 (defun gnus (&optional arg dont-connect)
2689 If ARG is non-nil and a positive number, Gnus will use that as the
2690 startup level. If ARG is non-nil and not a positive number, Gnus will
2691 prompt the user for the name of an NNTP server to use."
2693 (if (get-buffer gnus-group-buffer)
2695 (switch-to-buffer gnus-group-buffer)
2696 (gnus-group-get-new-news))
2698 (gnus-read-init-file)
2699 (let ((level (and arg (numberp arg) (> arg 0) arg)))
2702 (switch-to-buffer (get-buffer-create gnus-group-buffer))
2703 (gnus-add-current-to-buffer-list)
2705 (or dont-connect (gnus-start-news-server (and arg (not level)))))
2706 (if (and (not dont-connect)
2707 (not (gnus-server-opened gnus-select-method)))
2709 (run-hooks 'gnus-startup-hook)
2710 ;; NNTP server is successfully open.
2711 (gnus-update-format-specifications)
2712 (let ((buffer-read-only nil))
2714 (if (not gnus-inhibit-startup-message)
2716 (gnus-group-startup-message)
2718 (gnus-setup-news nil level)
2719 (and gnus-use-dribble-file (gnus-dribble-open))
2720 (or t (not gnus-novice-user)
2722 (gnus-group-describe-briefly)) ;Show brief help message.
2723 (gnus-group-list-groups (or level 5)))))))
2725 (defun gnus-group-startup-message (&optional x y)
2726 "Insert startup message in current buffer."
2727 ;; Insert the message.
2744 ;; And then hack it.
2745 ;; 18 is the longest line.
2746 (indent-rigidly (point-min) (point-max)
2747 (/ (max (- (window-width) (or x 28)) 0) 2))
2748 (goto-char (point-min))
2749 ;; +4 is fuzzy factor.
2750 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2)))
2752 (defun gnus-group-setup-buffer ()
2753 (or (get-buffer gnus-group-buffer)
2755 (switch-to-buffer (get-buffer-create gnus-group-buffer))
2756 (gnus-add-current-to-buffer-list)
2757 (gnus-group-mode))))
2759 (defun gnus-group-list-groups (level &optional unread)
2760 "List newsgroups with level LEVEL or lower that have unread alticles.
2761 Default is 5, which lists all subscribed groups.
2762 If argument UNREAD is non-nil, groups with no unread articles are also listed."
2764 (setq level (or level 5))
2765 (gnus-group-setup-buffer) ;May call from out of group buffer
2766 (let ((case-fold-search nil)
2767 (group (gnus-group-group-name)))
2768 (funcall gnus-group-prepare-function level unread nil)
2769 (if (zerop (buffer-size))
2770 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
2771 (message "No news is horrible news")
2772 (goto-char (point-min))
2774 ;; Go to the first group with unread articles.
2775 (gnus-group-search-forward nil nil nil t)
2776 ;; Find the right group to put point on. If the current group
2777 ;; has disapeared in the new listing, try to find the next
2778 ;; one. If no next one can be found, just leave point at the
2779 ;; first newsgroup in the buffer.
2780 (if (not (gnus-goto-char
2781 (text-property-any (point-min) (point-max)
2782 'gnus-group (intern group))))
2783 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
2785 (not (gnus-goto-char
2787 (point-min) (point-max) 'gnus-group
2789 (setq newsrc (cdr newsrc))))))
2790 ;; Adjust cursor point.
2791 (gnus-group-position-cursor))))
2793 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
2794 "List all newsgroups with unread articles of level LEVEL or lower.
2795 If ALL is non-nil, list groups that have no unread articles.
2796 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
2797 If REGEXP, only list groups matching REGEXP."
2798 (set-buffer gnus-group-buffer)
2799 (let ((buffer-read-only nil)
2800 (newsrc (cdr gnus-newsrc-assoc))
2801 (lowest (or lowest 1))
2802 info clevel unread group)
2805 ;; List living groups.
2807 (setq info (car newsrc)
2810 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
2811 (and unread ; This group might be bogus
2813 (string-match regexp group))
2814 (<= (setq clevel (car (cdr info))) level)
2816 (or all ; We list all groups?
2817 (eq unread t) ; We list unactivated groups
2818 (> unread 0) ; We list groups with unread articles
2819 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
2820 (gnus-group-insert-group-line
2821 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
2823 ;; List dead groups.
2824 (and (>= level 8) (<= lowest 8)
2825 (gnus-group-prepare-flat-list-dead
2826 (setq gnus-zombie-list (sort gnus-zombie-list 'string<)) 8 ?Z
2828 (and (>= level 9) (<= lowest 9)
2829 (gnus-group-prepare-flat-list-dead
2830 (setq gnus-killed-list (sort gnus-killed-list 'string<)) 9 ?K
2833 (gnus-group-set-mode-line)
2834 (setq gnus-have-all-newsgroups all)
2835 (run-hooks 'gnus-group-prepare-hook)))
2837 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
2838 ;; List zombies and killed lists somehwat faster, which was
2839 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
2840 ;; this by ignoring the group format specification altogether.
2843 (setq group (car groups)
2844 groups (cdr groups))
2845 (if (or (not regexp)
2846 (string-match regexp group))
2849 (insert (format " %c *: %s\n" mark group))
2850 (add-text-properties
2852 (list 'gnus-group (intern group)
2854 'gnus-level level)))))))
2856 (defun gnus-group-real-name (group)
2857 "Find the real name of a foreign newsgroup."
2858 (if (string-match "^[^:]+:" group)
2859 (substring group (match-end 0))
2862 (defun gnus-group-prefixed-name (group method)
2863 "Return the whole name from GROUP and METHOD."
2864 (concat (format "%s" (car method))
2865 (if (assoc (format "%s" (car method)) (gnus-methods-using 'address))
2866 (concat "+" (nth 1 method)))
2869 (defun gnus-group-real-prefix (group)
2870 "Return the prefix of the current group name."
2871 (if (string-match "^[^:]+:" group)
2872 (substring group 0 (match-end 0))
2875 (defun gnus-group-method-name (group)
2876 "Return the method used for selecting GROUP."
2877 (let ((prefix (gnus-group-real-prefix group)))
2878 (if (equal prefix "")
2880 (if (string-match "^[^\\+]+\\+" prefix)
2881 (list (intern (substring prefix 0 (1- (match-end 0))))
2882 (substring prefix (match-end 0) (1- (length prefix))))
2883 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
2885 (defun gnus-group-foreign-p (group)
2886 "Return nil if GROUP is native, non-nil if it is foreign."
2887 (string-match ":" group))
2889 (defun gnus-group-set-info (info)
2890 (let ((entry (gnus-gethash (car info) gnus-newsrc-hashtb)))
2892 (if (not (setq marked (nth 3 info)))
2895 (or (eq 'score (car (car marked)))
2896 (eq 'bookmark (car (car marked)))
2897 (not (or (atom (cdr (cdr (car marked))))
2898 (not (atom (car (cdr (car marked)))))))
2899 (setcdr (car marked)
2900 (gnus-uncompress-range (cdr (car marked)))))
2901 (setq marked (cdr marked)))))
2905 (set-buffer gnus-group-buffer)
2907 (gnus-group-make-group
2908 (gnus-group-real-name (car info))
2909 (prin1-to-string (car (nth 4 info)))
2910 (nth 1 (nth 4 info)))
2911 (gnus-group-make-group
2913 (prin1-to-string (car gnus-select-method))
2914 (nth 1 gnus-select-method)))
2915 (message "Note: New group created")
2917 (gnus-gethash (gnus-group-prefixed-name
2918 (gnus-group-real-name (car info))
2919 (or (nth 4 info) gnus-select-method))
2920 gnus-newsrc-hashtb))))
2923 (setcar (nthcdr 2 entry) info)
2924 (if (and (not (eq (car entry) t))
2925 (gnus-gethash (car info) gnus-active-hashtb))
2926 (let ((marked (nth 3 info)))
2928 (max 0 (- (length (gnus-list-of-unread-articles
2930 (length (cdr (assq 'tick marked)))
2931 (length (cdr (assq 'dormant marked)))))))))
2932 (error "No such group: %s" (car info)))))
2934 (defun gnus-group-update-group-line ()
2935 "This function updates the current line in the newsgroup buffer and
2936 moves the point to the colon."
2937 (let* ((buffer-read-only nil)
2938 (group (gnus-group-group-name))
2939 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
2942 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
2945 (delete-region (point) (save-excursion (forward-line 1) (point)))
2946 (gnus-group-insert-group-line-info group)
2948 (gnus-group-position-cursor)))
2950 (defun gnus-group-insert-group-line-info (group)
2951 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
2955 (setq info (nth 2 entry))
2956 (gnus-group-insert-group-line
2957 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
2958 (setq active (gnus-gethash group gnus-active-hashtb))
2959 (gnus-group-insert-group-line
2960 nil group (if (member group gnus-zombie-list) 8 9)
2961 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
2963 (defun gnus-group-insert-group-line (gformat group level marked number method)
2964 (let* ((gformat (or gformat gnus-group-line-format-spec))
2965 (active (gnus-gethash group gnus-active-hashtb))
2966 (number-total (if active (1+ (- (cdr active) (car active))) 0))
2967 (number-of-dormant (length (cdr (assq 'dormant marked))))
2968 (number-of-ticked (length (cdr (assq 'tick marked))))
2969 (number-of-ticked-and-dormant
2970 (+ number-of-ticked number-of-dormant))
2971 (number-of-unread-unticked
2972 (if (numberp number) (int-to-string (max 0 number))
2975 (if (numberp number)
2976 (max 0 (- number-total number))
2978 (subscribed (cond ((< level 6) ? )
2982 (qualified-group (gnus-group-real-name group))
2983 (newsgroup-description
2984 (if gnus-description-hashtb
2985 (or (gnus-gethash group gnus-description-hashtb) "")
2987 (moderated (if (member group gnus-moderated-list) ?m ? ))
2988 (moderated-string (if (eq moderated ?m) "(m)" ""))
2989 (news-server (or (car (cdr method)) ""))
2990 (news-method (or (car method) ""))
2992 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
2996 (> number-of-ticked 0))
2998 (number (if (eq number t) "*" (+ number number-of-dormant
3000 (buffer-read-only nil)
3005 (insert (eval gformat))
3007 (add-text-properties
3008 b (1+ b) (list 'gnus-group (intern group)
3009 'gnus-unread (if (numberp number)
3010 (string-to-int number-of-unread-unticked)
3013 'gnus-level level))))
3015 (defun gnus-group-update-group (group &optional visible-only)
3016 "Update newsgroup info of GROUP.
3017 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3019 (set-buffer gnus-group-buffer)
3020 (let ((buffer-read-only nil)
3022 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3025 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3027 ;; Buffer may be narrowed.
3030 ;; Search a line to modify. If the buffer is large, the search
3031 ;; takes long time. In most cases, current point is on the line
3032 ;; we are looking for. So, first of all, check current line.
3035 (eq (get-text-property (point) 'gnus-group)
3040 (point-min) (point-max) 'gnus-group (intern group)))))
3041 ;; GROUP is listed in current buffer. So, delete old line.
3045 (delete-region (point) (progn (forward-line 1) (point))))
3046 ;; No such line in the buffer, find out where it's supposed to
3047 ;; go, and insert it there (or at the end of the buffer).
3048 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3050 (let ((entry (cdr (gnus-gethash group gnus-newsrc-hashtb))))
3055 (point-min) (point-max)
3056 'gnus-group (intern (car (car entry)))))))
3057 (setq entry (cdr entry)))
3058 (or entry (goto-char (point-max)))))))
3059 (if (or visible (not visible-only))
3060 (gnus-group-insert-group-line-info group))
3061 (gnus-group-set-mode-line))))
3063 (defun gnus-group-set-mode-line ()
3064 (if (memq 'group gnus-updated-mode-lines)
3065 (let* ((gformat (or gnus-group-mode-line-format-spec
3066 (setq gnus-group-mode-line-format-spec
3068 gnus-group-mode-line-format
3069 gnus-group-mode-line-format-alist))))
3070 (news-server (car (cdr gnus-select-method)))
3071 (news-method (car gnus-select-method))
3072 (mode-string (eval gformat))
3074 (if (> (length mode-string) max-len)
3075 (setq mode-string (substring mode-string 0 (- max-len 4))))
3076 (setq mode-line-buffer-identification mode-string)
3077 (set-buffer-modified-p t))))
3079 (defun gnus-group-group-name ()
3080 "Get the name of the newsgroup on the current line."
3081 (let ((group (get-text-property
3082 (save-excursion (beginning-of-line) (point)) 'gnus-group)))
3083 (and group (symbol-name group))))
3085 (defun gnus-group-group-level ()
3086 "Get the level of the newsgroup on the current line."
3087 (get-text-property (save-excursion (beginning-of-line) (point)) 'gnus-level))
3089 (defun gnus-group-search-forward (&optional backward all level first-too)
3090 "Find the next newsgroup with unread articles.
3091 If BACKWARD is non-nil, find the previous newsgroup instead.
3092 If ALL is non-nil, just find any newsgroup.
3093 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3095 If FIRST-TOO, the current line is also eligeble as a target."
3096 (let ((way (if backward -1 1))
3100 (or first-too (forward-line way))
3108 (get-text-property (point) 'gnus-unread)))
3109 (or (eq unread t) (and unread (> unread 0))))
3110 (< (get-text-property (point) 'gnus-level) 6)))
3112 (let ((lev (get-text-property (point) 'gnus-level)))
3118 (setq pos (point))))
3120 (zerop (forward-line way))))
3122 (progn (gnus-group-position-cursor) t)
3123 (if pos (goto-char pos) (goto-char beg))
3126 ;; Gnus group mode commands
3128 (defun gnus-group-read-group (all &optional no-article group)
3129 "Read news in this newsgroup.
3130 If argument ALL is non-nil, already read articles become readable.
3131 If optional argument NO-ARTICLE is non-nil, no article body is displayed."
3133 (let ((group (or group (gnus-group-group-name)))
3134 number active marked entry)
3135 (or group (error "No group on current line"))
3137 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3138 ;; This group might be a dead group. In that case we have to get
3139 ;; the number of unread articles from `gnus-active-hashtb'.
3141 (setq number (car entry))
3142 (if (setq active (gnus-gethash group gnus-active-hashtb))
3143 (setq number (- (1+ (cdr active)) (car active)))))
3144 (gnus-summary-read-group
3145 group (or all (and (numberp number)
3146 (zerop (+ number (length (cdr (assq 'tick marked)))
3147 (length (cdr (assq 'dormant marked)))))))
3150 (defun gnus-group-select-group (all)
3151 "Select this newsgroup.
3152 No article is selected automatically.
3153 If argument ALL is non-nil, already read articles become readable."
3155 (gnus-group-read-group all t))
3157 (defun gnus-group-jump-to-group (group)
3158 "Jump to newsgroup GROUP."
3161 (completing-read "Group: " gnus-active-hashtb nil t)))
3163 ;; Either go to the line in the group buffer...
3164 (or (and (setq b (text-property-any (point-min) (point-max)
3165 'gnus-group (intern group)))
3167 ;; ... or insert the line.
3168 (progn (gnus-group-update-group group)
3169 (goto-char (text-property-any (point-min) (point-max)
3170 'gnus-group (intern group))))))
3171 ;; Adjust cursor point.
3172 (gnus-group-position-cursor))
3174 (defun gnus-group-next-group (n)
3175 "Go to next N'th newsgroup.
3176 If N is negative, search backward instead.
3177 Returns the difference between N and the number of skips actually
3180 (gnus-group-next-unread-group n t))
3182 (defun gnus-group-next-unread-group (n &optional all level)
3183 "Go to next N'th unread newsgroup.
3184 If N is negative, search backward instead.
3185 If ALL is non-nil, choose any newsgroup, unread or not.
3186 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
3187 such group can be found, the next group with a level higher than
3189 Returns the difference between N and the number of skips actually
3192 (let ((backward (< n 0))
3195 (gnus-group-search-forward backward all level))
3197 (if (/= 0 n) (message "No more%s newsgroups%s" (if all "" " unread")
3198 (if level " on this level or higher" "")))
3201 (defun gnus-group-prev-group (n)
3202 "Go to previous N'th newsgroup.
3203 Returns the difference between N and the number of skips actually
3206 (gnus-group-next-unread-group (- n) t))
3208 (defun gnus-group-prev-unread-group (n)
3209 "Go to previous N'th unread newsgroup.
3210 Returns the difference between N and the number of skips actually
3213 (gnus-group-next-unread-group (- n)))
3215 (defun gnus-group-next-unread-group-same-level (n)
3216 "Go to next N'th unread newsgroup on the same level.
3217 If N is negative, search backward instead.
3218 Returns the difference between N and the number of skips actually
3221 (gnus-group-next-unread-group n t (gnus-group-group-level))
3222 (gnus-group-position-cursor))
3224 (defun gnus-group-prev-unread-group-same-level (n)
3225 "Go to next N'th unread newsgroup on the same level.
3226 Returns the difference between N and the number of skips actually
3229 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
3230 (gnus-group-position-cursor))
3232 (defun gnus-group-best-unread-group ()
3233 "Go to the group with the highest level."
3235 (goto-char (point-min))
3238 (while (setq unread (get-text-property (point) 'gnus-unread))
3239 (if (and (numberp unread) (> unread 0))
3241 (or best-point (setq best-point (point)))
3242 (if (< (get-text-property (point) 'gnus-level) best)
3244 (setq best (get-text-property (point) 'gnus-level))
3245 (setq best-point (point))))))
3247 (if best-point (goto-char best-point))
3248 (gnus-summary-position-cursor)
3249 (and best-point (gnus-group-group-name))))
3251 (defun gnus-group-make-group (name method address)
3252 "Add a new newsgroup.
3253 The user will be prompted for a NAME, for a select METHOD, and an
3257 (read-string "Group name: ")
3260 "Method: " gnus-valid-select-methods nil t)))
3262 (if (memq 'prompt-address
3263 (assoc method gnus-valid-select-methods))
3264 (read-string "Address: ")
3266 (let ((nname (gnus-group-prefixed-name name (list (intern method) address)))
3268 (gnus-group-change-level
3269 (setq info (list t nname 3 nil nil (list (intern method) address)))
3270 3 9 (gnus-gethash (or (gnus-group-group-name) "dummy.group")
3271 gnus-newsrc-hashtb) t)
3272 (gnus-sethash nname '(0 . 0) gnus-active-hashtb)
3274 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
3275 (gnus-group-insert-group-line-info nname)))
3277 (defun gnus-group-edit-group (group)
3278 (interactive (list (gnus-group-group-name)))
3280 (if group (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
3281 (error "No group on current line"))
3282 (setq gnus-winconf-edit-group (current-window-configuration))
3283 (pop-to-buffer (get-buffer-create gnus-group-edit-buffer))
3284 (gnus-add-current-to-buffer-list)
3286 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3287 (use-local-map (copy-keymap emacs-lisp-mode-map))
3288 (local-set-key "\C-c\C-c" 'gnus-group-edit-group-done)
3290 (insert ";; Type `C-c C-c' after you have edited the newsgroup entry.\n\n")
3291 (let ((cinfo (gnus-copy-sequence info))
3293 (if (not (setq marked (nth 3 cinfo)))
3296 (or (eq 'score (car (car marked)))
3297 (eq 'bookmark (car (car marked)))
3298 (setcdr (car marked)
3299 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
3300 (setq marked (cdr marked))))
3301 (insert (pp-to-string (list 'gnus-group-set-info
3302 (list 'quote cinfo)))))))
3304 (defun gnus-group-edit-group-done ()
3306 (set-buffer (get-buffer-create gnus-group-edit-buffer))
3307 (eval-current-buffer)
3308 (kill-buffer (current-buffer))
3309 (and gnus-winconf-edit-group
3310 (set-window-configuration gnus-winconf-edit-group))
3311 (setq gnus-winconf-edit-group nil)
3312 (set-buffer gnus-group-buffer)
3313 (gnus-group-update-group (gnus-group-group-name))
3314 (gnus-group-position-cursor))
3316 (defun gnus-group-make-help-group ()
3317 "Create the (ding) Gnus documentation group."
3319 (and (gnus-gethash (gnus-group-prefixed-name "gnus-help" '(nndoc ""))
3321 (error "Documentation group already exists"))
3322 (let ((path load-path))
3324 (not (file-exists-p (concat (file-name-as-directory (car path))
3326 (setq path (cdr path)))
3327 (or path (error "Couldn't find doc group"))
3328 (gnus-group-make-group
3330 (concat (file-name-as-directory (car path)) "doc.txt"))
3331 (gnus-group-position-cursor)))
3333 (defun gnus-group-make-directory-group (dir)
3334 "Create an nndir group.
3335 The user will be prompted for a directory. The contents of this
3336 directory will be used as a newsgroup. The directory should contain
3337 mail messages or news articles in files that have numeric names."
3339 (list (read-file-name "Create group from directory: ")))
3340 (or (file-exists-p dir) (error "No such directory"))
3341 (or (file-directory-p dir) (error "Not a directory"))
3342 (gnus-group-make-group dir "nndir" dir)
3343 (gnus-group-position-cursor))
3345 (defun gnus-group-make-kiboze-group (group address scores)
3346 "Create an nnkiboze group.
3347 The user will be prompted for a name, a regexp to match groups, and
3348 score file entries for articles to include in the group."
3351 (read-string "nnkiboze group name: ")
3352 (read-string "Source groups (regexp): ")
3353 (let ((headers (mapcar (lambda (group) (list group))
3354 '("subject" "from" "number" "date" "message-id"
3355 "references" "chars" "lines" "xref")))
3356 scores header regexp regexps)
3357 (while (not (equal "" (setq header (completing-read
3358 "Match on header: " headers nil t))))
3360 (while (not (equal "" (setq regexp (read-string
3361 (format "Match on %s (string): "
3363 (setq regexps (cons (list regexp nil 1000 nil) regexps)))
3364 (setq scores (cons (cons header regexps) scores)))
3366 (gnus-group-make-group group "nnkiboze" address)
3368 (set-buffer (get-buffer-create " *gnus work*"))
3369 (buffer-disable-undo (current-buffer))
3370 (let (emacs-lisp-mode-hook)
3371 (pp (list 'setq 'gnus-score-alist
3372 (list 'quote (list scores)))
3374 (write-region (point-min) (point-max)
3375 (concat (or gnus-kill-files-directory "~/News")
3376 "nnkiboze:" group "." gnus-score-file-suffix))
3377 (kill-buffer (current-buffer)))
3378 (gnus-group-position-cursor))
3380 ;; Group sorting commands
3381 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
3383 (defun gnus-group-sort-groups ()
3384 "Sort the group buffer using `gnus-group-sort-function'."
3386 (setq gnus-newsrc-assoc
3387 (sort (cdr gnus-newsrc-assoc) gnus-group-sort-function))
3388 (gnus-make-hashtable-from-newsrc-alist)
3389 (gnus-get-unread-articles 6)
3390 (gnus-group-list-groups 5))
3392 (defun gnus-group-sort-by-alphabet (info1 info2)
3393 (string< (car info1) (car info2)))
3395 (defun gnus-group-sort-by-unread (info1 info2)
3396 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
3397 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
3398 (< (or (and (numberp n1) n1) 0)
3399 (or (and (numberp n2) n2) 0))))
3401 (defun gnus-group-sort-by-level (info1 info2)
3402 (< (nth 1 info1) (nth 1 info2)))
3404 ;; Group catching up.
3406 (defun gnus-group-catchup-current (n &optional all)
3407 "Mark all articles not marked as unread in current newsgroup as read.
3408 If prefix argument N is numeric, the ARG next newsgroups will be
3409 caught up. If ALL is non-nil, marked articles will also be marked as
3410 read. Cross references (Xref: header) of articles are ignored.
3411 The difference between N and actual number of newsgroups that were
3412 caught up is returned."
3414 (if (or (not gnus-interactive-catchup) ;Without confirmation?
3418 "Do you really want to mark all articles as read? "
3419 "Mark all unread articles as read? ")))
3425 (gnus-group-catchup (gnus-group-group-name) all)
3426 (gnus-group-update-group-line)
3428 (zerop (gnus-group-next-unread-group 1))))))
3431 (defun gnus-group-catchup-current-all (n)
3432 "Mark all articles in current newsgroup as read.
3433 Cross references (Xref: header) of articles are ignored."
3435 (gnus-group-catchup-current n 'all))
3437 (defun gnus-group-catchup (group &optional all)
3438 "Mark all articles in GROUP as read.
3439 If ALL is non-nil, all articles are marked as read.
3440 The return value is the number of articles that were marked as read,
3441 or nil if no action could be taken."
3442 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3444 (marked (nth 3 (nth 2 entry)))
3446 (if (not (numberp (car entry)))
3447 (message "Can't catch up; non-active group")
3448 ;; Do the updating only if the newsgroup isn't killed
3451 (setq ticked (if all nil (cdr (assq 'tick marked))))
3452 (gnus-update-read-articles group ticked nil ticked)
3453 (if (and all marked)
3454 (setcar (nthcdr 3 (nth 2 entry))
3455 (delq (assq 'dormant marked) marked))))))
3458 (defun gnus-group-expire-articles (newsgroup)
3459 "Expire all expirable articles in the current newsgroup."
3460 (interactive (list (gnus-group-group-name)))
3461 (if (not newsgroup) (error "No current newsgroup"))
3463 (assq 'expire (nth 3 (nth 2 (gnus-gethash newsgroup
3464 gnus-newsrc-hashtb))))))
3466 (gnus-check-backend-function 'request-expire-articles newsgroup)
3468 (gnus-request-expire-articles (cdr expirable) newsgroup)))))
3470 (defun gnus-group-expire-all-groups ()
3471 "Expire all expirable articles in all newsgroups."
3473 (message "Expiring...")
3474 (let ((newsrc (cdr gnus-newsrc-assoc)))
3476 (gnus-group-expire-articles (car (car newsrc)))
3477 (setq newsrc (cdr newsrc))))
3478 (message "Expiring...done"))
3480 (defun gnus-group-set-current-level (n)
3481 "Set the level of the current group to the numeric prefix."
3483 (setq n (or n (string-to-int
3486 (mapcar (lambda (n) (list (char-to-string n))) "123456789")
3488 (let ((group (gnus-group-group-name)))
3489 (if (not group) (error "No newsgroup on current line.")
3490 (if (and (numberp n) (>= n 1) (<= n 9))
3492 (message "Changed level of %s from %d to %d"
3493 group (gnus-group-group-level) n)
3494 (gnus-group-change-level group n (gnus-group-group-level))
3495 (gnus-group-update-group-line))
3496 (error "Illegal level: %s" n))))
3498 (gnus-group-position-cursor))
3500 (defun gnus-group-unsubscribe-current-group (arg)
3501 "Toggle subscribe from/to unsubscribe current group."
3503 (let ((group (gnus-group-group-name)))
3504 (or group (error "No newsgroup on current line"))
3505 (or arg (setq arg (if (<= (gnus-group-group-level) 5) 6 3)))
3506 (gnus-group-unsubscribe-group group arg)
3507 (gnus-group-next-group 1)))
3509 (defun gnus-group-unsubscribe-group (group &optional level)
3510 "Toggle subscribe from/to unsubscribe GROUP.
3511 New newsgroup is added to .newsrc automatically."
3513 (list (completing-read "Group: " gnus-active-hashtb nil
3514 gnus-have-read-active-file)))
3515 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3517 ;; Toggle subscription flag.
3518 (gnus-group-change-level
3519 newsrc (if level level (if (< (nth 1 (nth 2 newsrc)) 6) 6 4)))
3520 (gnus-group-update-group group))
3521 ((and (stringp group)
3522 (or (not gnus-have-read-active-file)
3523 (gnus-gethash group gnus-active-hashtb)))
3524 ;; Add new newsgroup.
3525 (gnus-group-change-level
3528 (or (and (member group gnus-zombie-list) 8) 9)
3529 (or (and (gnus-group-group-name)
3530 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb))
3531 (gnus-gethash (car (car gnus-newsrc-assoc))
3532 gnus-newsrc-hashtb)))
3533 (gnus-group-update-group group))
3534 (t (error "No such newsgroup: %s" group)))
3535 (gnus-group-position-cursor)))
3537 (defun gnus-group-transpose-groups (arg)
3538 "Exchange current newsgroup and previous newsgroup.
3539 With argument ARG, takes previous newsgroup and moves it past ARG newsgroup."
3541 ;; BUG: last newsgroup and the last but one cannot be transposed
3542 ;; since gnus-group-search-forward does not move forward beyond the
3543 ;; last. If we instead use forward-line, no problem, but I don't
3544 ;; want to use it for later extension.
3546 (gnus-group-search-forward t t)
3547 (gnus-group-kill-group 1)
3548 (gnus-group-search-forward nil t)
3549 (gnus-group-yank-group)
3550 (gnus-group-search-forward nil t)
3551 (setq arg (1- arg))))
3553 (defun gnus-group-kill-all-zombies ()
3554 "Kill all zombie newsgroups."
3556 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3557 (setq gnus-zombie-list nil)
3558 (funcall gnus-group-prepare-function 5 nil nil)
3559 (goto-char (point-min))
3560 (gnus-group-position-cursor))
3562 (defun gnus-group-kill-region (begin end)
3563 "Kill newsgroups in current region (excluding current point).
3564 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3567 ;; Exclude a line where current point is on.
3581 (beginning-of-line) ;Important when LINES < 1
3582 (gnus-group-kill-group lines)))
3584 (defun gnus-group-kill-group (n)
3585 "The the next N groups.
3586 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3587 However, only groups that were alive can be yanked; already killed
3588 groups or zombie groups can't be yanked.
3589 The return value is the name of the (last) newsgroup that was killed."
3591 (let ((buffer-read-only nil)
3593 (while (>= (setq n (1- n)) 0)
3594 (setq group (gnus-group-group-name))
3596 (signal 'end-of-buffer nil))
3597 (setq level (gnus-group-group-level))
3599 (delete-region (point) (progn (forward-line 1) (point)))
3600 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
3601 (setq gnus-list-of-killed-groups
3602 (cons (cons (car entry) (nth 2 entry))
3603 gnus-list-of-killed-groups)))
3604 (gnus-group-change-level (if entry entry group) 9 (if entry nil level)))
3607 (gnus-group-position-cursor)
3610 (defun gnus-group-yank-group (&optional arg)
3611 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
3612 inserting it before the current newsgroup. The numeric ARG specifies
3613 how many newsgroups are to be yanked. The name of the (last)
3614 newsgroup yanked is returned."
3616 (if (not arg) (setq arg 1))
3617 (let (info group prev)
3618 (while (>= (setq arg (1- arg)) 0)
3619 (if (not (setq info (car gnus-list-of-killed-groups)))
3620 (error "No more newsgroups to yank"))
3621 (setq group (nth 2 info))
3622 ;; Find which newsgroup to insert this one before - search
3623 ;; backward until something suitable is found. If there are no
3624 ;; other newsgroups in this buffer, just make this newsgroup the
3626 (while (and (not (setq prev (gnus-group-group-name)))
3627 (zerop (forward-line -1))))
3629 (setq prev (car (car gnus-newsrc-assoc))))
3630 (gnus-group-change-level
3632 (gnus-gethash prev gnus-newsrc-hashtb)
3634 (gnus-group-insert-group-line-info (nth 1 info))
3635 (setq gnus-list-of-killed-groups
3636 (cdr gnus-list-of-killed-groups)))
3638 (gnus-group-position-cursor)
3641 (defun gnus-group-list-all-groups (arg)
3642 "List all newsgroups with level ARG or lower.
3643 Default is 7, which lists all subscribed and most unsubscribed groups."
3645 (setq arg (or arg 7))
3646 (gnus-group-list-groups arg t))
3648 (defun gnus-group-list-killed ()
3649 "List all killed newsgroups in the group buffer."
3651 (if (not gnus-killed-list)
3652 (message "No killed groups")
3653 (funcall gnus-group-prepare-function 9 t 9)
3654 (goto-char (point-min)))
3655 (gnus-group-position-cursor))
3657 (defun gnus-group-list-zombies ()
3658 "List all zombie newsgroups in the group buffer."
3660 (if (not gnus-zombie-list)
3661 (message "No zombie groups")
3662 (funcall gnus-group-prepare-function 8 t 8)
3663 (goto-char (point-min)))
3664 (gnus-group-position-cursor))
3666 (defun gnus-group-get-new-news (&optional arg)
3667 "Get newly arrived articles.
3668 If ARG is non-nil, it should be a number between one and nine to
3669 specify which levels you are interested in re-scanning."
3671 (run-hooks 'gnus-get-new-news-hook)
3672 (if (and gnus-read-active-file (not arg))
3674 (gnus-read-active-file)
3675 (gnus-get-unread-articles (or arg 6)))
3676 (let ((gnus-read-active-file nil))
3677 (gnus-get-unread-articles (or arg 6))))
3678 (gnus-group-list-groups 5 gnus-have-all-newsgroups))
3680 (defun gnus-group-get-new-news-this-group (n)
3681 "Check for newly arrived news in the current group (and the N-1 next groups).
3682 The difference between N and the number of newsgroup checked is returned.
3683 If N is negative, this group and the N-1 previous groups will be checked."
3685 (let ((way (if (< n 0) -1 1))
3687 (w-p (window-start))
3691 (or (gnus-get-new-news-in-group
3692 (setq group (gnus-group-group-name)))
3695 (message "%s error: %s"
3696 group (gnus-status-message group))))
3698 (zerop (gnus-group-next-group way)))
3700 (if (/= 0 n) (message "No more newsgroups"))
3701 ;; !!! I don't know why the buffer scrolls forward when updating
3702 ;; the first line in the group buffer, but it does. So we set the
3703 ;; window start forcibly.
3704 (set-window-start (get-buffer-window (current-buffer)) w-p)
3707 (defun gnus-get-new-news-in-group (group)
3709 (gnus-activate-newsgroup group)
3711 (gnus-get-unread-articles-in-group
3712 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
3713 (gnus-gethash group gnus-active-hashtb))
3714 (gnus-group-update-group-line)
3717 (defun gnus-group-fetch-faq (group)
3718 "Fetch the FAQ for the current group."
3719 (interactive (list (gnus-group-group-name)))
3720 (or group (error "No group name given"))
3721 (let ((file (concat gnus-group-faq-directory group)))
3722 (if (not (file-exists-p file))
3723 (error "No such file: %s" file)
3726 (defun gnus-group-describe-group (force &optional group)
3727 "Display a description of the current newsgroup."
3729 (and force (setq gnus-description-hashtb nil))
3730 (let ((group (or group (gnus-group-group-name)))
3732 (or group (message "No group name given"))
3733 (and (or gnus-description-hashtb
3734 (setq desc (gnus-group-get-description group))
3735 (gnus-read-descriptions-file))
3737 (or desc (gnus-gethash group gnus-description-hashtb)
3738 "No description available")))))
3740 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3741 (defun gnus-group-describe-all-groups (force)
3742 "Pop up a buffer with descriptons of all newsgroups."
3744 (and force (setq gnus-description-hashtb nil))
3745 (if (not (or gnus-description-hashtb
3746 (gnus-read-descriptions-file)))
3747 (error "Couldn't request descriptions file"))
3748 (let ((buffer-read-only nil)
3754 (insert (format " *: %-20s %s\n" (symbol-name group)
3755 (symbol-value group)))
3756 (add-text-properties
3757 b (1+ b) (list 'gnus-group group
3758 'gnus-unread t 'gnus-marked nil 'gnus-level 6)))
3759 gnus-description-hashtb)
3760 (goto-char (point-min))
3761 (gnus-group-position-cursor)))
3763 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
3764 (defun gnus-group-apropos (regexp &optional search-description)
3765 "List all newsgroups that have names that match a regexp."
3766 (interactive "sGnus apropos (regexp): ")
3768 (obuf (current-buffer))
3770 ;; Go through all newsgroups that are known to Gnus.
3773 (and (string-match regexp (symbol-name group))
3774 (setq groups (cons (symbol-name group) groups))))
3776 ;; Go through all descriptions that are known to Gnus.
3777 (if search-description
3780 (and (string-match regexp (symbol-value group))
3781 (gnus-gethash (symbol-name group) gnus-active-hashtb)
3782 (setq groups (cons (symbol-name group) groups))))
3783 gnus-description-hashtb))
3785 (message "No groups matched \"%s\"." regexp)
3786 ;; Print out all the groups.
3788 (pop-to-buffer (get-buffer-create "*Gnus Help*"))
3789 (buffer-disable-undo (current-buffer))
3791 (setq groups (sort groups 'string<))
3793 ;; Groups may be entered twice into the list of groups.
3794 (if (not (string= (car groups) prev))
3796 (insert (setq prev (car groups)) "\n")
3797 (if (and gnus-description-hashtb
3798 (setq des (gnus-gethash (car groups)
3799 gnus-description-hashtb)))
3800 (insert " " des "\n"))))
3801 (setq groups (cdr groups)))
3803 (pop-to-buffer obuf)))
3805 (defun gnus-group-description-apropos (regexp)
3806 "List all newsgroups that have names or desccriptions that match a regexp."
3807 (interactive "sGnus description apropos (regexp): ")
3808 (if (not (or gnus-description-hashtb
3809 (gnus-read-descriptions-file)))
3810 (error "Couldn't request descriptions file"))
3811 (gnus-group-apropos regexp t))
3813 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3814 (defun gnus-group-list-matching (level regexp &optional all lowest)
3815 "List all groups with unread articles that match REGEXP.
3816 If the prefix LEVEL is non-nil, it should be a number that says which
3817 level to cut off listing groups.
3818 If ALL, also list groups with no unread articles.
3819 If LOWEST, don't list groups with level lower than LOWEST."
3820 (interactive "P\nsList newsgroups matching: ")
3821 (gnus-group-prepare-flat (or level 5) all (or lowest 1) regexp)
3822 (goto-char (point-min))
3823 (gnus-group-position-cursor))
3825 (defun gnus-group-list-all-matching (level regexp &optional lowest)
3826 "List all groups that match REGEXP.
3827 If the prefix LEVEL is non-nil, it should be a number that says which
3828 level to cut off listing groups.
3829 If LOWEST, don't list groups with level lower than LOWEST."
3830 (interactive "P\nsList newsgroups matching: ")
3831 (gnus-group-list-matching (or level 9) regexp t lowest))
3833 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
3834 (defun gnus-group-save-newsrc ()
3835 "Save the Gnus startup files."
3837 (gnus-save-newsrc-file))
3839 (defun gnus-group-restart (&optional arg)
3840 "Force Gnus to read the .newsrc file."
3842 (gnus-save-newsrc-file)
3843 (gnus-setup-news 'force)
3844 (gnus-group-list-groups (or arg 5) gnus-have-all-newsgroups))
3846 (defun gnus-group-read-init-file ()
3847 "Read the Gnus elisp init file."
3849 (gnus-read-init-file))
3851 (defun gnus-group-check-bogus-groups ()
3852 "Check bogus newsgroups."
3854 (gnus-check-bogus-newsgroups (not gnus-expert-user)) ;Require confirmation.
3855 (gnus-group-list-groups 5 gnus-have-all-newsgroups))
3857 (defun gnus-group-mail ()
3858 "Start composing a mail."
3862 (defun gnus-group-edit-global-kill (article &optional group)
3863 "Edit the global kill file.
3864 If GROUP, edit that local kill file instead."
3866 (setq gnus-current-kill-article article)
3867 (gnus-kill-file-edit-file group)
3869 (substitute-command-keys
3870 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
3872 (defun gnus-group-edit-local-kill (article group)
3873 "Edit a local kill file."
3874 (interactive (list nil (gnus-group-group-name)))
3875 (gnus-group-edit-global-kill article group))
3877 (defun gnus-group-force-update ()
3878 "Update `.newsrc' file."
3880 (gnus-save-newsrc-file))
3882 (defun gnus-group-suspend ()
3883 "Suspend the current Gnus session.
3884 In fact, cleanup buffers except for group mode buffer.
3885 The hook gnus-suspend-gnus-hook is called before actually suspending."
3887 (run-hooks 'gnus-suspend-gnus-hook)
3888 ;; Kill Gnus buffers except for group mode buffer.
3889 (let ((group-buf (get-buffer gnus-group-buffer)))
3890 (while gnus-buffer-list
3891 (and (not (eq (get-buffer (car gnus-buffer-list)) group-buf))
3892 (not (eq (get-buffer (car gnus-buffer-list)) gnus-dribble-buffer))
3893 (get-buffer (car gnus-buffer-list))
3894 (buffer-name (get-buffer (car gnus-buffer-list)))
3895 (kill-buffer (car gnus-buffer-list)))
3896 (setq gnus-buffer-list (cdr gnus-buffer-list)))
3897 (setq gnus-buffer-list (list group-buf))
3898 (bury-buffer group-buf)
3899 (delete-windows-on group-buf t)))
3901 (defun gnus-group-clear-dribble ()
3902 "Clear all information from the dribble buffer."
3904 (gnus-dribble-clear))
3906 (defun gnus-group-exit ()
3907 "Quit reading news after updating .newsrc.eld and .newsrc.
3908 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3910 (if (or noninteractive ;For gnus-batch-kill
3911 (zerop (buffer-size)) ;No news is good news.
3912 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
3913 (not gnus-interactive-exit) ;Without confirmation
3915 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
3917 (run-hooks 'gnus-exit-gnus-hook)
3918 (gnus-save-newsrc-file)
3919 (gnus-close-backends)
3920 (gnus-clear-system))))
3922 (defun gnus-close-backends ()
3923 (let ((methods gnus-valid-select-methods)
3926 (if (fboundp (setq func (intern (concat (car (car methods))
3927 "-request-close"))))
3929 (setq methods (cdr methods)))))
3931 (defun gnus-group-quit ()
3932 "Quit reading news without updating .newsrc.eld or .newsrc.
3933 The hook `gnus-exit-gnus-hook' is called before actually exiting."
3935 (if (or noninteractive ;For gnus-batch-kill
3936 (zerop (buffer-size))
3937 (not (gnus-server-opened gnus-select-method))
3939 (not gnus-current-startup-file)
3941 (format "Quit reading news without saving %s? "
3942 (file-name-nondirectory gnus-current-startup-file))))
3944 (run-hooks 'gnus-exit-gnus-hook)
3946 (gnus-close-backends)
3947 (gnus-clear-system))))
3949 (defun gnus-group-describe-briefly ()
3950 "Give a one line description of the group mode commands."
3953 (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")))
3955 (defun gnus-group-browse-foreign-server (method)
3956 "Browse a foreign news server.
3957 If called interactively, this function will ask for a select method
3958 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
3959 If not, METHOD should be a list where the first element is the method
3960 and the second element is the address."
3962 (list (list (intern (completing-read
3964 gnus-valid-select-methods nil t "nntp"))
3965 ;; Suggested by mapjph@bath.ac.uk.
3968 (mapcar (lambda (server) (list server))
3969 gnus-secondary-servers)))))
3970 (gnus-browse-foreign-server method))
3974 ;;; Browse Server Mode
3977 (defvar gnus-browse-server-mode-hook nil)
3978 (defvar gnus-browse-server-mode-map nil)
3980 (if gnus-browse-server-mode-map
3982 (setq gnus-browse-server-mode-map (make-keymap))
3983 (suppress-keymap gnus-browse-server-mode-map)
3984 (define-key gnus-browse-server-mode-map " " 'gnus-browse-read-group)
3985 (define-key gnus-browse-server-mode-map "=" 'gnus-browse-read-group)
3986 (define-key gnus-browse-server-mode-map "n" 'gnus-browse-next-group)
3987 (define-key gnus-browse-server-mode-map "p" 'gnus-browse-prev-group)
3988 (define-key gnus-browse-server-mode-map "\177" 'gnus-browse-prev-group)
3989 (define-key gnus-browse-server-mode-map "N" 'gnus-browse-next-group)
3990 (define-key gnus-browse-server-mode-map "P" 'gnus-browse-prev-group)
3991 (define-key gnus-browse-server-mode-map "\M-n" 'gnus-browse-next-group)
3992 (define-key gnus-browse-server-mode-map "\M-p" 'gnus-browse-prev-group)
3993 (define-key gnus-browse-server-mode-map "\r" 'gnus-browse-read-group)
3994 (define-key gnus-browse-server-mode-map "u" 'gnus-browse-unsubscribe-current-group)
3995 (define-key gnus-browse-server-mode-map "q" 'gnus-browse-exit)
3996 (define-key gnus-browse-server-mode-map "Q" 'gnus-browse-exit)
3997 (define-key gnus-browse-server-mode-map "\C-c\C-c" 'gnus-browse-exit)
3998 (define-key gnus-browse-server-mode-map "?" 'gnus-browse-describe-briefly)
3999 (define-key gnus-browse-server-mode-map "\C-c\C-i" 'gnus-info-find-node)
4002 (defvar gnus-browse-current-method nil)
4004 (defun gnus-browse-foreign-server (method)
4005 (setq gnus-browse-current-method method)
4006 (let ((gnus-select-method method)
4008 (message "Connecting to %s..." (nth 1 method))
4009 (if (not (gnus-request-list method))
4010 (error "Unable to contact server: " (gnus-status-message method)))
4011 (set-buffer (get-buffer-create "*Gnus Browse Server*"))
4012 (gnus-add-current-to-buffer-list)
4013 (buffer-disable-undo (current-buffer))
4014 (let ((buffer-read-only nil))
4016 (gnus-browse-server-mode)
4017 (setq mode-line-buffer-identification
4019 "(ding) Browse Server {%s:%s}" (car method) (car (cdr method))))
4021 (set-buffer nntp-server-buffer)
4022 (let ((cur (current-buffer)))
4024 (delete-matching-lines gnus-ignored-newsgroups)
4025 (while (re-search-forward
4026 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
4027 (goto-char (match-end 1))
4028 (setq groups (cons (cons (buffer-substring (match-beginning 1)
4030 (- (read cur) (read cur)))
4032 (setq groups (sort groups
4034 (string< (car l1) (car l2)))))
4035 (let ((buffer-read-only nil))
4037 (setq group (car groups))
4039 (format "K%7d: %s\n" (cdr group) (car group)))
4040 (setq groups (cdr groups))))
4041 (switch-to-buffer (current-buffer))
4043 (gnus-group-position-cursor)))
4045 (defun gnus-browse-server-mode ()
4046 "Major mode for browsing a foreign server."
4048 (kill-all-local-variables)
4049 (setq mode-line-modified "-- ")
4050 (make-local-variable 'mode-line-format)
4051 (setq mode-line-format (copy-sequence mode-line-format))
4052 (and (equal (nth 3 mode-line-format) " ")
4053 (setcar (nthcdr 3 mode-line-format) ""))
4054 (setq major-mode 'gnus-browse-server-mode)
4055 (setq mode-name "Browse Server")
4056 (setq mode-line-process nil)
4057 (use-local-map gnus-browse-server-mode-map)
4058 (buffer-disable-undo (current-buffer))
4059 (setq truncate-lines t)
4060 (setq buffer-read-only t)
4061 (run-hooks 'gnus-browse-server-mode-hook))
4063 (defun gnus-browse-read-group ()
4064 "Not implemented, and will probably never be."
4066 (error "You can't read while browsing"))
4068 (defun gnus-browse-next-group (n)
4069 "Go to the next group."
4073 (gnus-group-position-cursor)))
4075 (defun gnus-browse-prev-group (n)
4076 "Go to the next group."
4078 (gnus-browse-next-group (- n)))
4080 (defun gnus-browse-unsubscribe-current-group (arg)
4081 "(Un)subscribe to the next ARG groups."
4084 (error "No group at current line."))
4085 (let ((ward (if (< arg 0) -1 1))
4087 (while (and (> arg 0)
4089 (gnus-browse-unsubscribe-group)
4090 (zerop (gnus-browse-next-group ward)))
4091 (setq arg (1- arg)))
4092 (gnus-group-position-cursor)
4093 (if (/= 0 arg) (message "No more newsgroups"))
4096 (defun gnus-browse-unsubscribe-group ()
4098 (buffer-read-only nil)
4102 (if (= (following-char) ?K) (setq sub t))
4103 (re-search-forward ": \\(.*\\)$" nil t)
4104 (setq group (gnus-group-prefixed-name
4105 (buffer-substring (match-beginning 1) (match-end 1))
4106 gnus-browse-current-method))
4111 (gnus-group-change-level
4112 (list t group 3 nil nil gnus-browse-current-method) 3 9
4113 (gnus-gethash (car (nth 1 gnus-newsrc-assoc)) gnus-newsrc-hashtb)
4116 (gnus-group-change-level group 9 3)
4120 (defun gnus-browse-exit ()
4121 "Quit browsing and return to the group buffer."
4123 (if (eq major-mode 'gnus-browse-server-mode)
4124 (kill-buffer (current-buffer)))
4125 (switch-to-buffer gnus-group-buffer)
4126 (gnus-group-list-groups 5))
4128 (defun gnus-browse-describe-briefly ()
4129 "Give a one line description of the group mode commands."
4132 (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")))
4136 ;;; Gnus summary mode
4139 (defvar gnus-summary-mode-map nil)
4140 (defvar gnus-summary-mark-map nil)
4141 (defvar gnus-summary-mscore-map nil)
4142 (defvar gnus-summary-send-map nil)
4143 (defvar gnus-summary-extract-map nil)
4144 (defvar gnus-summary-extract-view-map nil)
4145 (defvar gnus-summary-article-map nil)
4146 (defvar gnus-summary-thread-map nil)
4147 (defvar gnus-summary-goto-map nil)
4148 (defvar gnus-summary-exit-map nil)
4149 (defvar gnus-summary-various-map nil)
4150 (defvar gnus-summary-interest-map nil)
4151 (defvar gnus-summary-process-map nil)
4152 (defvar gnus-summary-score-map nil)
4153 (defvar gnus-summary-sort-map nil)
4154 (defvar gnus-summary-mgroup-map nil)
4155 (defvar gnus-summary-vsave-map nil)
4156 (defvar gnus-summary-increase-map nil)
4157 (defvar gnus-summary-inc-subject-map nil)
4158 (defvar gnus-summary-inc-author-map nil)
4159 (defvar gnus-summary-inc-id-map nil)
4160 (defvar gnus-summary-inc-xref-map nil)
4161 (defvar gnus-summary-inc-thread-map nil)
4162 (defvar gnus-summary-inc-fol-map nil)
4163 (defvar gnus-summary-lower-map nil)
4164 (defvar gnus-summary-low-subject-map nil)
4165 (defvar gnus-summary-low-author-map nil)
4166 (defvar gnus-summary-low-id-map nil)
4167 (defvar gnus-summary-low-xref-map nil)
4168 (defvar gnus-summary-low-thread-map nil)
4169 (defvar gnus-summary-low-fol-map nil)
4171 (if gnus-summary-mode-map
4173 (setq gnus-summary-mode-map (make-keymap))
4174 (suppress-keymap gnus-summary-mode-map)
4176 ;; Non-orthogonal keys
4178 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
4179 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
4180 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
4181 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
4182 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
4183 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
4184 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
4185 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
4186 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
4187 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
4188 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
4189 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
4190 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
4191 (define-key gnus-summary-mode-map "\M-s" 'gnus-summary-search-article-forward)
4192 (define-key gnus-summary-mode-map "\M-r" 'gnus-summary-search-article-backward)
4193 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
4194 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
4195 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
4196 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
4197 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
4198 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
4199 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
4200 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
4201 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
4202 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
4203 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
4204 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
4205 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
4206 (define-key gnus-summary-mode-map "k" 'gnus-summary-kill-same-subject-and-select)
4207 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
4208 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
4209 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
4210 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
4211 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
4212 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
4213 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
4214 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
4215 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
4216 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
4217 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
4218 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
4219 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
4220 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
4221 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
4222 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
4223 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
4224 (define-key gnus-summary-mode-map "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
4225 (define-key gnus-summary-mode-map "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
4226 (define-key gnus-summary-mode-map "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
4227 (define-key gnus-summary-mode-map "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
4228 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
4229 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
4230 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
4231 (define-key gnus-summary-mode-map "\C-x\C-s" 'gnus-summary-reselect-current-group)
4232 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
4233 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
4234 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
4235 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
4236 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
4237 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
4238 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
4239 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
4240 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
4241 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
4242 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
4243 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
4244 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
4245 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
4246 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
4247 (define-key gnus-summary-mode-map "V" 'gnus-version)
4248 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
4249 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
4250 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
4251 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
4252 (define-key gnus-summary-mode-map [mouse-2] 'gnus-mouse-pick-article)
4253 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
4254 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
4255 (define-key gnus-summary-mode-map "x" 'gnus-summary-delete-marked-as-read)
4256 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
4257 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
4258 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
4259 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
4260 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
4261 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
4262 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu)
4263 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
4266 ;; Sort of orthogonal keymap
4267 (define-prefix-command 'gnus-summary-mark-map)
4268 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
4269 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
4270 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
4271 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
4272 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
4273 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
4274 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
4275 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
4276 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
4277 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
4278 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
4279 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
4280 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
4281 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
4282 (define-key gnus-summary-mark-map "\M-r" 'gnus-summary-remove-lines-marked-as-read)
4283 (define-key gnus-summary-mark-map "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
4284 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
4285 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
4286 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
4287 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
4288 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
4289 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
4290 (define-key gnus-summary-mark-map "k" 'gnus-summary-kill-same-subject-and-select)
4291 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
4293 (define-prefix-command 'gnus-summary-mscore-map)
4294 (define-key gnus-summary-mark-map "s" 'gnus-summary-mscore-map)
4295 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
4296 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
4297 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
4298 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
4300 (define-prefix-command 'gnus-summary-process-map)
4301 (define-key gnus-summary-mark-map "p" 'gnus-summary-process-map)
4302 (define-key gnus-summary-process-map "p" 'gnus-summary-mark-as-processable)
4303 (define-key gnus-summary-process-map "u" 'gnus-summary-unmark-as-processable)
4304 (define-key gnus-summary-process-map "U" 'gnus-summary-unmark-all-processable)
4305 (define-key gnus-summary-process-map "s" 'gnus-uu-mark-series)
4306 (define-key gnus-summary-process-map "r" 'gnus-uu-mark-region)
4307 (define-key gnus-summary-process-map "R" 'gnus-uu-mark-by-regexp)
4308 (define-key gnus-summary-process-map "t" 'gnus-uu-mark-thread)
4309 (define-key gnus-summary-process-map "a" 'gnus-uu-mark-all)
4310 (define-key gnus-summary-process-map "S" 'gnus-uu-mark-sparse)
4313 (define-prefix-command 'gnus-summary-send-map)
4314 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
4315 (define-key gnus-summary-send-map "p" 'gnus-summary-post-news)
4316 (define-key gnus-summary-send-map "f" 'gnus-summary-followup)
4317 (define-key gnus-summary-send-map "F" 'gnus-summary-followup-with-original)
4318 (define-key gnus-summary-send-map "b" 'gnus-summary-followup-and-reply)
4319 (define-key gnus-summary-send-map "B" 'gnus-summary-followup-and-reply-with-original)
4320 (define-key gnus-summary-send-map "c" 'gnus-summary-cancel-article)
4321 (define-key gnus-summary-send-map "s" 'gnus-summary-supersede-article)
4322 (define-key gnus-summary-send-map "r" 'gnus-summary-reply)
4323 (define-key gnus-summary-send-map "R" 'gnus-summary-reply-with-original)
4324 (define-key gnus-summary-send-map "\C-f" 'gnus-summary-mail-forward)
4325 (define-key gnus-summary-send-map "m" 'gnus-summary-mail-other-window)
4326 (define-key gnus-summary-send-map "u" 'gnus-uu-post-news)
4327 (define-key gnus-summary-send-map "\M-f" 'gnus-uu-digest-and-forward)
4330 (define-prefix-command 'gnus-summary-goto-map)
4331 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
4332 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
4333 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
4334 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
4335 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
4336 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
4337 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
4338 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
4339 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
4340 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
4341 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
4342 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
4343 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
4344 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
4347 (define-prefix-command 'gnus-summary-thread-map)
4348 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
4349 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
4350 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
4351 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
4352 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
4353 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
4354 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
4355 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
4356 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
4357 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
4358 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
4359 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
4360 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
4361 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
4364 (define-prefix-command 'gnus-summary-exit-map)
4365 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
4366 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
4367 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
4368 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
4369 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
4370 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
4373 (define-prefix-command 'gnus-summary-article-map)
4374 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
4375 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
4376 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
4377 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
4378 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
4379 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
4380 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
4381 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
4382 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
4383 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
4384 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
4385 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
4386 (define-key gnus-summary-article-map "w" 'gnus-summary-stop-page-breaking)
4387 (define-key gnus-summary-article-map "c" 'gnus-summary-caesar-message)
4388 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
4389 (define-key gnus-summary-article-map "t" 'gnus-summary-toggle-header)
4390 (define-key gnus-summary-article-map "hh" 'gnus-article-hide-headers)
4391 (define-key gnus-summary-article-map "hs" 'gnus-article-hide-signature)
4392 (define-key gnus-summary-article-map "hc" 'gnus-article-hide-citation)
4393 (define-key gnus-summary-article-map "ho" 'gnus-article-treat-overstrike)
4394 (define-key gnus-summary-article-map "hw" 'gnus-article-word-wrap)
4395 (define-key gnus-summary-article-map "hd" 'gnus-article-remove-cr)
4396 (define-key gnus-summary-article-map "hq" 'gnus-article-de-quoted-unreadable)
4397 (define-key gnus-summary-article-map "m" 'gnus-summary-toggle-mime)
4398 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
4401 (define-prefix-command 'gnus-summary-extract-map)
4402 (define-key gnus-summary-mode-map "X" 'gnus-summary-extract-map)
4403 ; (define-key gnus-summary-extract-map "x" 'gnus-summary-extract-any)
4404 ; (define-key gnus-summary-extract-map "m" 'gnus-summary-extract-mime)
4405 (define-key gnus-summary-extract-map "u" 'gnus-uu-decode-uu)
4406 (define-key gnus-summary-extract-map "U" 'gnus-uu-decode-uu-and-save)
4407 (define-key gnus-summary-extract-map "s" 'gnus-uu-decode-unshar)
4408 (define-key gnus-summary-extract-map "S" 'gnus-uu-decode-unshar-and-save)
4409 (define-key gnus-summary-extract-map "o" 'gnus-uu-decode-save)
4410 (define-key gnus-summary-extract-map "O" 'gnus-uu-decode-save)
4411 (define-key gnus-summary-extract-map "b" 'gnus-uu-decode-binhex)
4412 (define-key gnus-summary-extract-map "B" 'gnus-uu-decode-binhex)
4414 (define-prefix-command 'gnus-summary-extract-view-map)
4415 (define-key gnus-summary-extract-map "v" 'gnus-summary-extract-view-map)
4416 (define-key gnus-summary-extract-view-map "u" 'gnus-uu-decode-uu-view)
4417 (define-key gnus-summary-extract-view-map "U" 'gnus-uu-decode-uu-and-save-view)
4418 (define-key gnus-summary-extract-view-map "s" 'gnus-uu-decode-unshar-view)
4419 (define-key gnus-summary-extract-view-map "S" 'gnus-uu-decode-unshar-and-save-view)
4420 (define-key gnus-summary-extract-view-map "o" 'gnus-uu-decode-save-view)
4421 (define-key gnus-summary-extract-view-map "O" 'gnus-uu-decode-save-view)
4422 (define-key gnus-summary-extract-view-map "b" 'gnus-uu-decode-binhex-view)
4423 (define-key gnus-summary-extract-view-map "B" 'gnus-uu-decode-binhex-view)
4426 (define-prefix-command 'gnus-summary-various-map)
4427 (define-key gnus-summary-mode-map "V" 'gnus-summary-various-map)
4428 (define-key gnus-summary-various-map "u" 'gnus-summary-universal-argument)
4429 (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
4430 (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
4431 (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
4432 (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
4433 (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
4434 (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
4435 (define-key gnus-summary-various-map "S" 'gnus-summary-reselect-current-group)
4436 (define-key gnus-summary-various-map "g" 'gnus-summary-rescan-group)
4437 (define-key gnus-summary-various-map "V" 'gnus-version)
4438 (define-key gnus-summary-various-map "f" 'gnus-summary-fetch-faq)
4439 (define-key gnus-summary-various-map "d" 'gnus-summary-describe-group)
4440 (define-key gnus-summary-various-map "?" 'gnus-summary-describe-briefly)
4441 (define-key gnus-summary-various-map "i" 'gnus-info-find-node)
4442 (define-key gnus-summary-various-map "D" 'gnus-summary-enter-digest-group)
4443 (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
4444 (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
4446 (define-prefix-command 'gnus-summary-vsave-map)
4447 (define-key gnus-summary-various-map "o" 'gnus-summary-vsave-map)
4448 (define-key gnus-summary-vsave-map "o" 'gnus-summary-save-article)
4449 (define-key gnus-summary-vsave-map "m" 'gnus-summary-save-article-mail)
4450 (define-key gnus-summary-vsave-map "r" 'gnus-summary-save-article-rmail)
4451 (define-key gnus-summary-vsave-map "f" 'gnus-summary-save-article-file)
4452 (define-key gnus-summary-vsave-map "h" 'gnus-summary-save-article-folder)
4453 (define-key gnus-summary-vsave-map "p" 'gnus-summary-pipe-output)
4455 (define-prefix-command 'gnus-summary-score-map)
4456 (define-key gnus-summary-various-map "S" 'gnus-summary-score-map)
4457 (define-key gnus-summary-score-map "s" 'gnus-summary-set-score)
4458 (define-key gnus-summary-score-map "c" 'gnus-score-change-score-file)
4459 (define-key gnus-summary-score-map "m" 'gnus-score-set-mark-below)
4460 (define-key gnus-summary-score-map "x" 'gnus-score-set-expunge-below)
4461 (define-key gnus-summary-score-map "e" 'gnus-score-edit-alist)
4462 (define-key gnus-summary-score-map "f" 'gnus-score-edit-file)
4464 (define-prefix-command 'gnus-summary-sort-map)
4465 (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
4466 (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
4467 (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
4468 (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
4469 (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
4470 (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
4472 (define-prefix-command 'gnus-summary-mgroup-map)
4473 (define-key gnus-summary-various-map "m" 'gnus-summary-mgroup-map)
4474 (define-key gnus-summary-mgroup-map "e" 'gnus-summary-expire-articles)
4475 (define-key gnus-summary-mgroup-map "\177" 'gnus-summary-delete-article)
4476 (define-key gnus-summary-mgroup-map "m" 'gnus-summary-move-article)
4477 (define-key gnus-summary-mgroup-map "r" 'gnus-summary-respool-article)
4478 (define-key gnus-summary-mgroup-map "w" 'gnus-summary-edit-article)
4479 (define-key gnus-summary-mgroup-map "c" 'gnus-summary-copy-article)
4482 (define-prefix-command 'gnus-summary-increase-map)
4483 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-map)
4484 (define-key gnus-summary-increase-map "i" 'gnus-summary-raise-same-subject-and-select)
4485 (define-key gnus-summary-increase-map "I" 'gnus-summary-raise-same-subject)
4486 (define-key gnus-summary-increase-map "\C-i" 'gnus-summary-raise-score)
4488 (define-prefix-command 'gnus-summary-inc-subject-map)
4489 (define-key gnus-summary-increase-map "s" 'gnus-summary-inc-subject-map)
4490 (define-key gnus-summary-increase-map "S" 'gnus-summary-temporarily-raise-by-subject)
4491 (define-key gnus-summary-inc-subject-map "s" 'gnus-summary-temporarily-raise-by-subject)
4492 (define-key gnus-summary-inc-subject-map "S" 'gnus-summary-raise-by-subject)
4493 (define-key gnus-summary-inc-subject-map "t" 'gnus-summary-temporarily-raise-by-subject)
4494 (define-key gnus-summary-inc-subject-map "p" 'gnus-summary-raise-by-subject)
4496 (define-prefix-command 'gnus-summary-inc-author-map)
4497 (define-key gnus-summary-increase-map "a" 'gnus-summary-inc-author-map)
4498 (define-key gnus-summary-increase-map "A" 'gnus-summary-temporarily-raise-by-author)
4499 (define-key gnus-summary-inc-author-map "a" 'gnus-summary-temporarily-raise-by-author)
4500 (define-key gnus-summary-inc-author-map "A" 'gnus-summary-raise-by-author)
4501 (define-key gnus-summary-inc-author-map "t" 'gnus-summary-temporarily-raise-by-author)
4502 (define-key gnus-summary-inc-author-map "p" 'gnus-summary-raise-by-author)
4504 (define-prefix-command 'gnus-summary-inc-id-map)
4505 (define-key gnus-summary-increase-map "i" 'gnus-summary-inc-id-map)
4506 (define-key gnus-summary-increase-map "I" 'gnus-summary-temporarily-raise-by-id)
4507 (define-key gnus-summary-inc-id-map "i" 'gnus-summary-temporarily-raise-by-id)
4508 (define-key gnus-summary-inc-id-map "I" 'gnus-summary-raise-by-id)
4509 (define-key gnus-summary-inc-id-map "t" 'gnus-summary-temporarily-raise-by-id)
4510 (define-key gnus-summary-inc-id-map "p" 'gnus-summary-raise-by-id)
4512 (define-prefix-command 'gnus-summary-inc-thread-map)
4513 (define-key gnus-summary-increase-map "t" 'gnus-summary-inc-thread-map)
4514 (define-key gnus-summary-increase-map "T" 'gnus-summary-temporarily-raise-by-thread)
4515 (define-key gnus-summary-inc-thread-map "t" 'gnus-summary-temporarily-raise-by-thread)
4516 (define-key gnus-summary-inc-thread-map "T" 'gnus-summary-raise-by-thread)
4517 (define-key gnus-summary-inc-thread-map "t" 'gnus-summary-temporarily-raise-by-thread)
4518 (define-key gnus-summary-inc-thread-map "p" 'gnus-summary-raise-by-thread)
4520 (define-prefix-command 'gnus-summary-inc-xref-map)
4521 (define-key gnus-summary-increase-map "x" 'gnus-summary-inc-xref-map)
4522 (define-key gnus-summary-increase-map "X" 'gnus-summary-temporarily-raise-by-xref)
4523 (define-key gnus-summary-inc-xref-map "x" 'gnus-summary-temporarily-raise-by-xref)
4524 (define-key gnus-summary-inc-xref-map "X" 'gnus-summary-raise-by-xref)
4525 (define-key gnus-summary-inc-xref-map "t" 'gnus-summary-temporarily-raise-by-xref)
4526 (define-key gnus-summary-inc-xref-map "p" 'gnus-summary-raise-by-xref)
4528 (define-prefix-command 'gnus-summary-inc-fol-map)
4529 (define-key gnus-summary-increase-map "f" 'gnus-summary-inc-fol-map)
4530 (define-key gnus-summary-increase-map "F" 'gnus-summary-raise-followups-to-author)
4531 (define-key gnus-summary-inc-fol-map "f" 'gnus-summary-raise-followups-to-author)
4532 (define-key gnus-summary-inc-fol-map "F" 'gnus-summary-raise-followups-to-author)
4533 (define-key gnus-summary-inc-fol-map "t" 'gnus-summary-raise-followups-to-author)
4534 (define-key gnus-summary-inc-fol-map "p" 'gnus-summary-raise-followups-to-author)
4536 (define-prefix-command 'gnus-summary-lower-map)
4537 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-map)
4538 (define-key gnus-summary-lower-map "l" 'gnus-summary-lower-same-subject-and-select)
4539 (define-key gnus-summary-lower-map "L" 'gnus-summary-lower-same-subject)
4540 (define-key gnus-summary-lower-map "\C-l" 'gnus-summary-lower-score)
4542 (define-prefix-command 'gnus-summary-low-subject-map)
4543 (define-key gnus-summary-lower-map "s" 'gnus-summary-low-subject-map)
4544 (define-key gnus-summary-lower-map "S" 'gnus-summary-temporarily-lower-by-subject)
4545 (define-key gnus-summary-low-subject-map "s" 'gnus-summary-temporarily-lower-by-subject)
4546 (define-key gnus-summary-low-subject-map "S" 'gnus-summary-lower-by-subject)
4547 (define-key gnus-summary-low-subject-map "t" 'gnus-summary-temporarily-lower-by-subject)
4548 (define-key gnus-summary-low-subject-map "p" 'gnus-summary-lower-by-subject)
4550 (define-prefix-command 'gnus-summary-low-author-map)
4551 (define-key gnus-summary-lower-map "a" 'gnus-summary-low-author-map)
4552 (define-key gnus-summary-lower-map "A" 'gnus-summary-temporarily-lower-by-author)
4553 (define-key gnus-summary-low-author-map "a" 'gnus-summary-temporarily-lower-by-author)
4554 (define-key gnus-summary-low-author-map "A" 'gnus-summary-lower-by-author)
4555 (define-key gnus-summary-low-author-map "t" 'gnus-summary-temporarily-lower-by-author)
4556 (define-key gnus-summary-low-author-map "p" 'gnus-summary-lower-by-author)
4558 (define-prefix-command 'gnus-summary-low-id-map)
4559 (define-key gnus-summary-lower-map "i" 'gnus-summary-low-id-map)
4560 (define-key gnus-summary-lower-map "I" 'gnus-summary-temporarily-lower-by-id)
4561 (define-key gnus-summary-low-id-map "i" 'gnus-summary-temporarily-lower-by-id)
4562 (define-key gnus-summary-low-id-map "I" 'gnus-summary-lower-by-id)
4563 (define-key gnus-summary-low-id-map "t" 'gnus-summary-temporarily-lower-by-id)
4564 (define-key gnus-summary-low-id-map "p" 'gnus-summary-lower-by-id)
4566 (define-prefix-command 'gnus-summary-low-thread-map)
4567 (define-key gnus-summary-lower-map "t" 'gnus-summary-low-thread-map)
4568 (define-key gnus-summary-lower-map "T" 'gnus-summary-temporarily-lower-by-thread)
4569 (define-key gnus-summary-low-thread-map "t" 'gnus-summary-temporarily-lower-by-thread)
4570 (define-key gnus-summary-low-thread-map "T" 'gnus-summary-lower-by-thread)
4571 (define-key gnus-summary-low-thread-map "t" 'gnus-summary-temporarily-lower-by-thread)
4572 (define-key gnus-summary-low-thread-map "p" 'gnus-summary-lower-by-thread)
4574 (define-prefix-command 'gnus-summary-low-xref-map)
4575 (define-key gnus-summary-lower-map "x" 'gnus-summary-low-xref-map)
4576 (define-key gnus-summary-lower-map "X" 'gnus-summary-temporarily-lower-by-xref)
4577 (define-key gnus-summary-low-xref-map "x" 'gnus-summary-temporarily-lower-by-xref)
4578 (define-key gnus-summary-low-xref-map "X" 'gnus-summary-lower-by-xref)
4579 (define-key gnus-summary-low-xref-map "t" 'gnus-summary-temporarily-lower-by-xref)
4580 (define-key gnus-summary-low-xref-map "p" 'gnus-summary-lower-by-xref)
4582 (define-prefix-command 'gnus-summary-low-fol-map)
4583 (define-key gnus-summary-lower-map "f" 'gnus-summary-low-fol-map)
4584 (define-key gnus-summary-lower-map "F" 'gnus-summary-lower-followups-to-author)
4585 (define-key gnus-summary-low-fol-map "f" 'gnus-summary-lower-followups-to-author)
4586 (define-key gnus-summary-low-fol-map "F" 'gnus-summary-lower-followups-to-author)
4587 (define-key gnus-summary-low-fol-map "t" 'gnus-summary-lower-followups-to-author)
4588 (define-key gnus-summary-low-fol-map "p" 'gnus-summary-lower-followups-to-author)
4594 (defun gnus-summary-mode ()
4595 "Major mode for reading articles.
4597 All normal editing commands are switched off.
4598 \\<gnus-summary-mode-map>
4599 Each line in this buffer represents one article. To read an
4600 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
4601 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
4604 You can also post articles and send mail from this buffer. To
4605 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
4606 of an article, type `\\[gnus-summary-reply]'.
4608 There are approx. one gazillion commands you can execute in this
4609 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
4611 The following commands are available:
4613 \\{gnus-summary-mode-map}"
4615 (if gnus-visual (gnus-summary-make-menu-bar))
4616 (kill-all-local-variables)
4617 (let ((locals gnus-summary-local-variables))
4619 (if (consp (car locals))
4621 (make-local-variable (car (car locals)))
4622 (set (car (car locals)) (eval (cdr (car locals)))))
4623 (make-local-variable (car locals))
4624 (set (car locals) nil))
4625 (setq locals (cdr locals))))
4626 (gnus-update-format-specifications)
4627 (setq mode-line-modified "-- ")
4628 (make-local-variable 'mode-line-format)
4629 (setq mode-line-format (copy-sequence mode-line-format))
4630 (and (equal (nth 3 mode-line-format) " ")
4631 (setcar (nthcdr 3 mode-line-format) ""))
4632 (setq major-mode 'gnus-summary-mode)
4633 (setq mode-name "Summary")
4634 (make-local-variable 'minor-mode-alist)
4635 (gnus-set-mode-line 'summary)
4636 (use-local-map gnus-summary-mode-map)
4637 (buffer-disable-undo (current-buffer))
4638 (setq buffer-read-only t) ;Disable modification
4639 (setq truncate-lines t)
4640 (setq selective-display t)
4641 (setq selective-display-ellipses t) ;Display `...'
4642 (run-hooks 'gnus-summary-mode-hook))
4644 (defun gnus-summary-clear-local-variables ()
4645 (let ((locals gnus-summary-local-variables))
4647 (if (consp (car locals))
4648 (set (car (car locals)) nil)
4649 (set (car locals) nil))
4650 (setq locals (cdr locals)))))
4652 (defun gnus-mouse-pick-article (e)
4655 (gnus-summary-next-page nil t))
4657 (defun gnus-summary-setup-buffer (group)
4658 "Initialize summary buffer."
4659 (let ((buffer (concat "*Summary " group "*")))
4660 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
4661 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
4662 (gnus-add-current-to-buffer-list)
4663 (gnus-summary-mode)))
4665 (defun gnus-set-global-variables ()
4666 ;; Set the global equivalents of the summary buffer-local variables
4667 ;; to the latest values they had. These reflect the summary buffer
4668 ;; that was in action when the last article was fetched.
4669 (if (eq major-mode 'gnus-summary-mode)
4671 (setq gnus-summary-buffer (current-buffer))
4672 (let ((name gnus-newsgroup-name)
4673 (marked gnus-newsgroup-marked)
4674 (unread gnus-newsgroup-unreads)
4675 (headers gnus-current-headers))
4677 (set-buffer gnus-group-buffer)
4678 (setq gnus-newsgroup-name name)
4679 (setq gnus-newsgroup-marked marked)
4680 (setq gnus-newsgroup-unreads unread)
4681 (setq gnus-current-headers headers))))))
4683 (defun gnus-summary-insert-dummy-line (sformat subject number)
4685 (setq sformat gnus-summary-dummy-line-format-spec))
4689 (insert (eval sformat))
4690 (add-text-properties
4692 (list 'gnus-subject (gnus-simplify-subject-re subject)
4697 (defun gnus-summary-insert-line
4698 (sformat header level current unread replied expirable subject-or-nil
4699 &optional dummy score)
4700 (or sformat (setq sformat gnus-summary-line-format-spec))
4702 (make-string (* level gnus-thread-indent-level) ? ))
4703 (lines (or (header-lines header) 0))
4704 (score (or score gnus-summary-default-score 0))
4705 (score-char (if (or (null gnus-summary-default-score)
4706 (= score gnus-summary-default-score)) ?
4707 (if (< score gnus-summary-default-score)
4708 gnus-score-below-mark gnus-score-over-mark)))
4709 (replied (if replied gnus-replied-mark ? ))
4710 (from (header-from header))
4711 (name-address (funcall gnus-extract-address-components from))
4712 (address (car (cdr name-address)))
4713 (name (or (car name-address) (car (cdr name-address))))
4714 (number (header-number header))
4715 (subject (header-subject header))
4716 (buffer-read-only nil)
4717 (opening-bracket (if dummy ?\< ?\[))
4718 (closing-bracket (if dummy ?\> ?\]))
4720 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
4721 (if (not (numberp lines)) (setq lines 0))
4724 (insert (eval sformat))
4725 (add-text-properties
4727 (list 'gnus-subject (gnus-simplify-subject-re subject)
4729 'gnus-mark (or unread gnus-unread-mark ? )
4730 'gnus-thread level))))
4732 (defun gnus-summary-update-line (&optional dont-update)
4733 ;; Update summary line after change.
4734 (or (not gnus-summary-default-score)
4735 gnus-summary-inhibit-highlight
4736 (let ((gnus-summary-inhibit-highlight t))
4739 (if (and gnus-summary-mark-below
4740 (< (gnus-summary-article-score)
4741 gnus-summary-mark-below))
4742 (and (not (memq (gnus-summary-article-number)
4743 gnus-newsgroup-marked))
4744 (gnus-summary-mark-article nil gnus-low-score-mark))
4745 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
4746 (gnus-summary-mark-article nil gnus-unread-mark))))
4748 (run-hooks 'gnus-visual-summary-update-hook))))))
4750 (defun gnus-summary-update-lines ()
4751 ;; Rehighlight summary buffer according to `gnus-summary-highlight'.
4752 (and (save-excursion
4753 (set-buffer gnus-summary-buffer)
4754 (goto-char (point-min))
4756 (gnus-summary-update-line)
4757 (forward-line 1)))))
4759 (defun gnus-summary-read-group (group &optional show-all no-article kill-buffer)
4760 "Start reading news in newsgroup GROUP.
4761 If SHOW-ALL is non-nil, already read articles are also listed.
4762 If NO-ARTICLE is non-nil, no article is selected initially."
4763 (message "Retrieving newsgroup: %s..." group)
4764 (gnus-summary-setup-buffer group)
4765 (if (gnus-select-newsgroup group show-all)
4767 ;; You can change the subjects in this hook.
4768 (run-hooks 'gnus-select-group-hook)
4769 ;; Do Score Processing.
4770 (gnus-score-headers)
4771 ;; Update the format specifiers.
4772 (gnus-update-format-specifications)
4773 (gnus-summary-prepare)
4774 (if (and (zerop (buffer-size))
4775 gnus-newsgroup-dormant)
4776 (gnus-summary-show-all-dormant))
4777 (gnus-set-global-variables)
4778 ;; Function `gnus-apply-kill-file' must be called in this hook.
4779 (run-hooks 'gnus-apply-kill-hook)
4780 (if (zerop (buffer-size))
4782 ;; This newsgroup is empty.
4783 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
4784 (message "No unread news"))
4787 (let ((gnus-summary-buffer kill-buffer))
4788 (gnus-configure-windows 'newsgroups t))))
4789 ;; Hide conversation thread subtrees. We cannot do this in
4790 ;; gnus-summary-prepare-hook since kill processing may not
4791 ;; work with hidden articles.
4792 (and gnus-show-threads
4793 gnus-thread-hide-subtree
4794 (gnus-summary-hide-all-threads))
4795 ;; Show first unread article if requested.
4796 (goto-char (point-min))
4797 (if (and (not no-article)
4798 gnus-auto-select-first
4799 (gnus-summary-first-unread-article))
4800 (gnus-configure-windows 'article)
4801 (gnus-configure-windows 'summary))
4802 (pop-to-buffer gnus-summary-buffer)
4803 (gnus-set-mode-line 'summary)
4804 (gnus-summary-position-cursor)
4805 (if (and kill-buffer
4806 (get-buffer kill-buffer)
4807 (buffer-name (get-buffer kill-buffer)))
4808 (kill-buffer kill-buffer))))
4809 ;; Cannot select newsgroup GROUP.
4810 (message "Couldn't select newsgroup")
4811 (and (eq major-mode 'gnus-summary-mode)
4812 (kill-buffer (current-buffer)))
4813 (switch-to-buffer gnus-group-buffer)))
4815 (defun gnus-summary-prepare ()
4816 "Prepare summary list of current newsgroup in summary buffer."
4817 (let ((buffer-read-only nil))
4819 (gnus-summary-prepare-threads
4820 (if gnus-show-threads
4821 (gnus-gather-threads
4823 (if gnus-summary-expunge-below
4824 (gnus-make-threads-and-expunge)
4825 (gnus-make-threads))))
4826 gnus-newsgroup-headers)
4828 ;; Erase header retrieval message.
4829 (gnus-summary-update-lines)
4831 ;; Call hooks for modifying summary buffer.
4832 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
4833 (goto-char (point-min))
4834 (run-hooks 'gnus-summary-prepare-hook)))
4836 (defun gnus-gather-threads (threads)
4837 "Gather threads that have lost their roots."
4838 (if (not gnus-summary-make-false-root)
4840 (let ((hashtb (gnus-make-hashtable 1023))
4843 thread subject hthread unre-subject whole-subject)
4845 (setq subject (header-subject (car (car threads)))
4846 whole-subject subject)
4847 (and gnus-summary-gather-subject-limit
4848 (> (length subject) gnus-summary-gather-subject-limit)
4850 (substring subject 0 gnus-summary-gather-subject-limit)))
4853 (setq unre-subject (gnus-simplify-subject-re subject))
4856 (or (stringp (car (car hthread)))
4857 (setcar hthread (list whole-subject (car hthread))))
4858 (setcdr (car hthread) (nconc (cdr (car hthread))
4859 (list (car threads))))
4860 (setcdr prev (cdr threads))
4861 (setq threads prev))
4862 (gnus-sethash unre-subject threads hashtb))
4864 (setq threads (cdr threads)))
4867 (defun gnus-make-threads ()
4868 ;; This function takes the dependencies already made by
4869 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
4870 ;; through the dependecies in the hash table and finds all the
4871 ;; roots. Roots do not refer back to any valid articles.
4873 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
4874 (gnus-build-old-threads))
4877 (if (not (car (symbol-value refs)))
4878 (setq roots (append (cdr (symbol-value refs)) roots))
4879 ;; Ok, these refer back to valid articles, but if
4880 ;; `gnus-thread-ignore-subject' is nil, we have to check that
4881 ;; the root has the same subject as its children. The children
4882 ;; that do not are made into roots and removed from the list
4884 (or gnus-thread-ignore-subject
4885 (let* ((prev (symbol-value refs))
4886 (subject (gnus-simplify-subject-re
4887 (header-subject (car prev))))
4888 (headers (cdr prev)))
4890 (if (not (string= subject
4891 (gnus-simplify-subject-re
4892 (header-subject (car headers)))))
4894 (setq roots (cons (car headers) roots))
4895 (setcdr prev (cdr headers)))
4896 (setq prev headers))
4897 (setq headers (cdr headers)))))))
4898 gnus-newsgroup-dependencies)
4900 (mapcar 'gnus-trim-thread
4902 (mapcar 'gnus-cut-thread
4903 (mapcar 'gnus-make-sub-thread roots))))))
4905 (defun gnus-make-threads-and-expunge ()
4906 ;; This function takes the dependencies already made by
4907 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
4908 ;; through the dependecies in the hash table and finds all the
4909 ;; roots. Roots do not refer back to any valid articles.
4911 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
4912 (gnus-build-old-threads))
4915 (if (not (car (symbol-value refs)))
4916 (if (and gnus-summary-expunge-below
4917 (not gnus-fetch-old-headers))
4918 (let ((headers (cdr (symbol-value refs))))
4920 (if (not (< (or (cdr (assq (header-number (car headers))
4921 gnus-newsgroup-scored))
4922 gnus-summary-default-score 0)
4923 gnus-summary-expunge-below))
4924 (setq roots (cons (car headers) roots))
4925 (setq gnus-newsgroup-unreads
4926 (delq (header-number (car headers))
4927 gnus-newsgroup-unreads)))
4928 (setq headers (cdr headers))))
4929 (setq roots (append (cdr (symbol-value refs)) roots)))
4930 ;; Ok, these refer back to valid articles, but if
4931 ;; `gnus-thread-ignore-subject' is nil, we have to check that
4932 ;; the root has the same subject as its children. The children
4933 ;; that do not are made into roots and removed from the list
4935 (or gnus-thread-ignore-subject
4936 (let* ((prev (symbol-value refs))
4937 (subject (gnus-simplify-subject-re
4938 (header-subject (car prev))))
4939 (headers (cdr prev)))
4941 (if (not (string= subject
4942 (gnus-simplify-subject-re
4943 (header-subject (car headers)))))
4945 (setq roots (cons (car headers) roots))
4946 (setcdr prev (cdr headers)))
4947 (setq prev headers))
4948 (setq headers (cdr headers)))))
4949 (and gnus-summary-expunge-below
4950 (not gnus-fetch-old-headers)
4951 (let* ((prev (symbol-value refs))
4952 (headers (cdr prev))
4955 (if (not (< (or (cdr (assq (header-number (car headers))
4956 gnus-newsgroup-scored))
4957 gnus-summary-default-score 0)
4958 gnus-summary-expunge-below))
4959 (setq prev (cdr prev))
4960 (setq gnus-newsgroup-unreads
4961 (delq (header-number (car headers))
4962 gnus-newsgroup-unreads))
4963 (setcdr prev (cdr headers))
4964 (setq id (gnus-gethash (header-id (car headers))
4965 gnus-newsgroup-dependencies))
4968 (if (not (< (or (cdr (assq (header-number (car h))
4969 gnus-newsgroup-scored))
4970 gnus-summary-default-score 0)
4971 gnus-summary-expunge-below))
4972 (setq roots (cons (car h) roots)))
4974 (setq headers (cdr headers)))))))
4975 gnus-newsgroup-dependencies)
4977 (mapcar 'gnus-trim-thread
4979 (mapcar 'gnus-cut-thread
4980 (mapcar 'gnus-make-sub-thread roots))))))
4982 (defun gnus-cut-thread (thread)
4983 ;; Remove leaf dormant or ancient articles from THREAD.
4984 (let ((head (car thread))
4985 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
4986 (if (and (null tail)
4987 (let ((number (header-number head)))
4988 (or (memq number gnus-newsgroup-ancient)
4989 (memq number gnus-newsgroup-dormant)
4990 (and gnus-summary-expunge-below
4991 (eq gnus-fetch-old-headers 'some)
4992 (< (or (cdr (assq number gnus-newsgroup-scored))
4993 gnus-summary-default-score 0)
4994 gnus-summary-expunge-below)
4996 (setq gnus-newsgroup-unreads
4997 (delq number gnus-newsgroup-unreads))
5000 (list (cons head tail)))))
5002 (defun gnus-trim-thread (thread)
5003 ;; Remove root ancient articles with only one child from THREAD.
5004 (if (and (eq gnus-fetch-old-headers 'some)
5005 (memq (header-number (car thread)) gnus-newsgroup-ancient)
5006 (= (length thread) 2))
5007 (gnus-trim-thread (nth 1 thread))
5010 (defun gnus-make-sub-thread (root)
5011 ;; This function makes a sub-tree for a node in the tree.
5012 (let ((children (reverse (cdr (gnus-gethash (downcase (header-id root))
5013 gnus-newsgroup-dependencies)))))
5014 (cons root (mapcar 'gnus-make-sub-thread children))))
5016 (defun gnus-build-old-threads ()
5017 ;; Look at all the articles that refer back to old articles, and
5018 ;; fetch the headers for the articles that aren't there. This will
5019 ;; build complete threads - if the roots haven't been expired by the
5024 (if (not (car (symbol-value refs)))
5026 (setq heads (cdr (symbol-value refs)))
5028 (if (not (memq (header-number (car heads))
5029 gnus-newsgroup-dormant))
5031 (setq id (symbol-name refs))
5032 (while (and (setq id (gnus-build-get-header id))
5033 (not (car (gnus-gethash
5034 id gnus-newsgroup-dependencies)))))
5036 (setq heads (cdr heads)))))))
5037 gnus-newsgroup-dependencies)))
5039 (defun gnus-build-get-header (id)
5040 ;; Look through the buffer of NOV lines and find the header to
5041 ;; ID. Enter this line into the dependencies hash table, and return
5042 ;; the id of the parent article (if any).
5043 (let ((deps gnus-newsgroup-dependencies)
5047 (set-buffer nntp-server-buffer)
5048 (goto-char (point-min))
5049 (while (and (not found) (search-forward id nil t))
5051 (setq found (looking-at (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
5052 (regexp-quote id))))
5053 (or found (beginning-of-line 2)))
5058 (setq header (gnus-nov-parse-line
5059 (read (current-buffer)) deps))
5060 (setq ref (header-references header))
5061 (string-match "\\(<[^>]+>\\) *$" ref)
5062 (substring ref (match-beginning 1) (match-end 1))))))
5064 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
5065 gnus-newsgroup-ancient (cons (header-number header)
5066 gnus-newsgroup-ancient))))))
5068 (defun gnus-sort-threads (threads)
5069 ;; Sort threads as specified in `gnus-thread-sort-functions'.
5070 (let ((fun gnus-thread-sort-functions))
5072 (setq threads (sort threads (car fun))
5076 (defun gnus-thread-header (thread)
5077 ;; Return header of first article in THREAD.
5079 (if (stringp (car thread))
5080 (car (car (cdr thread)))
5084 (defun gnus-thread-sort-by-number (h1 h2)
5085 "Sort threads by root article number."
5086 (let ((h1 (gnus-thread-header h1))
5087 (h2 (gnus-thread-header h2)))
5088 (< (header-number h1) (header-number h2))))
5090 (defun gnus-thread-sort-by-author (h1 h2)
5091 "Sort threads by root author."
5092 (let ((h1 (gnus-thread-header h1))
5093 (h2 (gnus-thread-header h2)))
5095 (let ((extract (funcall
5096 gnus-extract-address-components (header-from h1))))
5097 (or (car extract) (cdr extract)))
5098 (let ((extract (funcall
5099 gnus-extract-address-components (header-from h2))))
5100 (or (car extract) (cdr extract))))))
5102 (defun gnus-thread-sort-by-subject (h1 h2)
5103 "Sort threads by root subject."
5104 (let ((h1 (gnus-thread-header h1))
5105 (h2 (gnus-thread-header h2)))
5107 (downcase (gnus-simplify-subject (header-subject h1)))
5108 (downcase (gnus-simplify-subject (header-subject h2))))))
5110 (defun gnus-thread-sort-by-date (h1 h2)
5111 "Sort threads by root article date."
5112 (let ((h1 (gnus-thread-header h1))
5113 (h2 (gnus-thread-header h2)))
5115 (gnus-sortable-date (header-date h1))
5116 (gnus-sortable-date (header-date h2)))))
5118 (defun gnus-thread-sort-by-score (h1 h2)
5119 "Sort threads by root article score.
5120 Unscored articles will be counted as havin a score of zero."
5121 (let ((h1 (gnus-thread-header h1))
5122 (h2 (gnus-thread-header h2)))
5123 (let ((s1 (assq (header-number h1) gnus-newsgroup-scored))
5124 (s2 (assq (header-number h2) gnus-newsgroup-scored)))
5125 (> (or (cdr s1) gnus-summary-default-score 0)
5126 (or (cdr s2) gnus-summary-default-score 0)))))
5128 (defun gnus-thread-sort-by-total-score (h1 h2)
5129 "Sort threads by the sum of all scores in the thread.
5130 Unscored articles will be counted as havin a score of zero."
5131 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5133 (defun gnus-thread-total-score (thread)
5134 ;; This function find the total score of THREAD.
5136 (if (stringp (car thread))
5137 (apply gnus-thread-score-function 0
5138 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5139 (gnus-thread-total-score-1 thread))
5140 (gnus-thread-total-score-1 (list thread))))
5142 (defun gnus-thread-total-score-1 (root)
5143 ;; This function find the total score of the thread below ROOT.
5144 (setq root (car root))
5145 (apply gnus-thread-score-function
5146 (or (cdr (assq (header-number root) gnus-newsgroup-scored))
5147 gnus-summary-default-score 0)
5148 (mapcar 'gnus-thread-total-score
5149 (cdr (gnus-gethash (downcase (header-id root))
5150 gnus-newsgroup-dependencies)))))
5152 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5153 (defvar gnus-tmp-prev-subject "")
5155 ;; Basic ideas by Paul Dworkin <paul@media-lab.media.mit.edu>.
5156 (defun gnus-summary-prepare-threads
5157 (threads level &optional not-child no-subject cull)
5158 "Prepare summary buffer from THREADS and indentation LEVEL.
5159 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5160 or a straight list of headers."
5161 (let (thread header number subject clevel)
5163 (setq thread (car threads)
5164 threads (cdr threads))
5165 ;; If `thread' is a cons, hierarchical threads are used. If not,
5166 ;; `thread' is the header.
5168 (setq header (car thread))
5169 (setq header thread)
5171 (or (memq (setq number (header-number header))
5172 gnus-newsgroup-dormant)
5173 (and gnus-summary-expunge-below
5174 (< (or (cdr (assq number gnus-newsgroup-scored))
5175 gnus-summary-default-score 0)
5176 gnus-summary-expunge-below)))
5179 (setq gnus-newsgroup-unreads
5180 (delq number gnus-newsgroup-unreads)))))
5183 ;; The header is a dummy root.
5184 (cond ((eq gnus-summary-make-false-root 'adopt)
5185 ;; We let the first article adopt the rest.
5186 (gnus-summary-prepare-threads (list (car (cdr thread))) 0)
5187 (setq thread (cdr (cdr thread)))
5189 (gnus-summary-prepare-threads (list (car thread)) 1 t)
5190 (setq thread (cdr thread))))
5191 ((eq gnus-summary-make-false-root 'dummy)
5192 ;; We output a dummy root.
5193 (gnus-summary-insert-dummy-line
5194 nil header (header-number (car (car (cdr thread)))))
5196 ((eq gnus-summary-make-false-root 'empty)
5197 ;; We print the articles with empty subject fields.
5198 (gnus-summary-prepare-threads (list (car (cdr thread))) 0)
5199 (setq thread (cdr (cdr thread)))
5201 (gnus-summary-prepare-threads (list (car thread)) 0 nil t)
5202 (setq thread (cdr thread))))
5204 ;; We do not make a root for the gathered
5205 ;; sub-threads at all.
5207 ;; Print the sub-threads.
5208 (and (consp thread) (cdr thread)
5209 (gnus-summary-prepare-threads (cdr thread) clevel)))
5210 ;; The header is a real article.
5212 (setq number (header-number header)
5213 subject (header-subject header))
5214 (gnus-summary-insert-line
5215 nil header level nil
5216 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
5217 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
5218 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
5219 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
5220 (t gnus-ancient-mark))
5221 (memq number gnus-newsgroup-replied)
5222 (memq number gnus-newsgroup-expirable)
5223 (if no-subject gnus-summary-same-subject
5224 (if (or (zerop level)
5225 (and gnus-thread-ignore-subject
5227 (gnus-simplify-subject-re gnus-tmp-prev-subject)
5228 (gnus-simplify-subject-re subject)))))
5230 gnus-summary-same-subject))
5232 (cdr (assq number gnus-newsgroup-scored)))
5233 (setq gnus-tmp-prev-subject subject)
5234 ;; Recursively print subthreads.
5235 (and (consp thread) (cdr thread)
5236 (gnus-summary-prepare-threads (cdr thread) (1+ level))))))))
5238 (defun gnus-select-newsgroup (group &optional read-all)
5239 "Select newsgroup GROUP.
5240 If READ-ALL is non-nil, all articles in the group are selected."
5241 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5242 (info (nth 2 entry))
5243 articles header-marks)
5244 (and (eq (car entry) t)
5245 (or (gnus-activate-newsgroup (car info))
5247 (kill-buffer (current-buffer))
5248 (error "Couldn't request group %s: %s"
5249 group (gnus-status-message group)))))
5250 (setq gnus-current-select-method (or (nth 4 info) gnus-select-method))
5251 (gnus-check-news-server (nth 4 info))
5252 (or (gnus-request-group group t)
5254 (kill-buffer (current-buffer))
5255 (error "Couldn't request group %s: %s"
5256 group (gnus-status-message group))))
5258 (setq gnus-newsgroup-name group)
5259 (setq gnus-newsgroup-unselected nil)
5260 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5264 (gnus-adjust-marked-articles info)
5265 (setq gnus-newsgroup-marked
5266 (cdr (assq 'tick (setq marked (nth 3 info)))))
5267 (setq gnus-newsgroup-replied (cdr (assq 'reply marked)))
5268 (setq gnus-newsgroup-expirable (cdr (assq 'expire marked)))
5269 (setq gnus-newsgroup-killed (cdr (assq 'killed marked)))
5270 (setq gnus-newsgroup-bookmarks (cdr (assq 'bookmark marked)))
5271 (setq gnus-newsgroup-dormant (cdr (assq 'dormant marked)))
5272 (setq gnus-newsgroup-scored (cdr (assq 'score marked)))
5273 (setq gnus-newsgroup-processable nil)))
5275 (if (not (setq articles (gnus-articles-to-read group read-all)))
5277 ;; Init the dependencies hash table.
5278 (setq gnus-newsgroup-dependencies
5279 (gnus-make-hashtable (length articles)))
5280 ;; Retrieve the headers and read them in.
5281 (setq gnus-newsgroup-headers
5282 (if (eq 'nov (setq gnus-headers-retrieved-by
5283 (gnus-retrieve-headers
5284 (if gnus-fetch-old-headers
5285 (cons 1 articles) articles)
5286 gnus-newsgroup-name)))
5288 (gnus-get-newsgroup-headers-xover articles))
5289 (gnus-get-newsgroup-headers)))
5290 ;; If we were to fetch old headers, but the backend didn't
5291 ;; support XOVER, then it is possible we fetched one article
5292 ;; that we shouldn't have. If that's the case, we pop it off the
5294 (and (not (eq gnus-headers-retrieved-by 'nov))
5295 gnus-fetch-old-headers
5296 gnus-newsgroup-headers
5297 (/= (header-number (car gnus-newsgroup-headers)) (car articles))
5298 (setq gnus-newsgroup-headers (cdr gnus-newsgroup-headers)))
5299 ;; Remove cancelled articles from the list of unread articles.
5300 (setq gnus-newsgroup-unreads
5301 (gnus-set-sorted-intersection
5302 gnus-newsgroup-unreads
5303 (mapcar (lambda (headers) (header-number headers))
5304 gnus-newsgroup-headers)))
5305 ;; Check whether auto-expire is to be done in this group.
5306 (setq gnus-newsgroup-auto-expire
5307 (or (and (stringp gnus-auto-expirable-newsgroups)
5308 (string-match gnus-auto-expirable-newsgroups group))
5309 (memq 'auto-expire gnus-current-select-method)))
5310 ;; First and last article in this newsgroup.
5311 (and gnus-newsgroup-headers
5312 (setq gnus-newsgroup-begin
5313 (header-number (car gnus-newsgroup-headers)))
5314 (setq gnus-newsgroup-end
5315 (header-number (gnus-last-element gnus-newsgroup-headers))))
5316 (setq gnus-reffed-article-number -1)
5317 ;; GROUP is successfully selected.
5318 (or gnus-newsgroup-headers t))))
5320 (defun gnus-articles-to-read (group read-all)
5321 ;; Find out what articles the user wants to read.
5323 ;; Select all articles if `read-all' is non-nil, or if all the
5324 ;; unread articles are dormant articles.
5326 (= (length gnus-newsgroup-unreads)
5327 (length gnus-newsgroup-dormant)))
5328 (gnus-uncompress-range
5329 (gnus-gethash group gnus-active-hashtb))
5330 gnus-newsgroup-unreads))
5331 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5332 (scored (length scored-list))
5333 (number (length articles))
5334 (marked (+ (length gnus-newsgroup-marked)
5335 (length gnus-newsgroup-dormant)))
5338 (cond ((and (or (<= scored marked)
5340 (numberp gnus-large-newsgroup)
5341 (> number gnus-large-newsgroup))
5345 "How many articles from %s (default %d): "
5346 gnus-newsgroup-name number))))
5347 (if (string-equal input "")
5349 ((and (> scored marked) (< scored number))
5353 "%s %s (%d scored, %d total): "
5354 "How many articles from"
5355 group scored number))))
5356 (if (string-equal input "")
5361 (setq select (if (numberp select) select (string-to-number select)))
5364 (if (and (not (zerop scored)) (<= (abs select) scored))
5366 (setq articles (sort scored-list '<))
5367 (setq number (length articles)))
5368 (setq articles (copy-sequence articles)))
5370 (setq total-articles articles)
5372 (if (< (abs select) number)
5374 ;; Select the N oldest articles.
5375 (setcdr (nthcdr (1- (abs select)) articles) nil)
5376 ;; Select the N most recent articles.
5377 (setq articles (nthcdr (- number select) articles))))
5378 (setq gnus-newsgroup-unselected
5379 (gnus-sorted-intersection
5380 gnus-newsgroup-unselected
5381 (gnus-sorted-complement articles total-articles)))
5384 (defun gnus-killed-articles (killed articles)
5387 (if (inline (gnus-member-of-range (car articles) killed))
5388 (setq out (cons (car articles) out)))
5389 (setq articles (cdr articles)))
5392 (defun gnus-adjust-marked-articles (info &optional active)
5393 "Remove all marked articles that are no longer legal."
5394 (let ((marked-lists (nth 3 info))
5395 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
5397 ;; There are four types of marked articles - ticked, replied,
5398 ;; expirable and dormant.
5400 (setq m (cdr (setq prev (car marked-lists))))
5401 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
5402 ;; Make sure that all ticked articles are a subset of the
5403 ;; unread/unselected articles.
5405 (if (or (memq (car m) gnus-newsgroup-unreads)
5406 (memq (car m) gnus-newsgroup-unselected))
5408 (setcdr prev (cdr m)))
5410 ((eq 'score (car prev))
5411 ;; Scored articles should be a subset of
5412 ;; unread/unselected articles.
5414 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
5415 (memq (car (car m)) gnus-newsgroup-unreads))
5417 (setcdr prev (cdr m)))
5419 ((eq 'bookmark (car prev))
5420 ;; Bookmarks should be a subset of active articles.
5422 (if (< (car (car m)) (car active))
5423 (setcdr prev (cdr m))
5426 ((eq 'killed (car prev))
5427 ;; Articles that have been through the kill process are
5428 ;; to be a subset of active articles.
5429 (while (and m (< (or (and (numberp (car m)) (car m))
5432 (setcdr prev (cdr m))
5434 (if (and m (< (or (and (numberp (car m)) (car m))
5437 (setcar (and (numberp (car m)) m (car m)) (car active))))
5438 ((or (eq 'reply (car marked)) (eq 'expire (car marked)))
5439 ;; The replied and expirable articles have to be articles
5442 (if (< (car m) (car active))
5443 (setcdr prev (cdr m))
5446 (setq marked-lists (cdr marked-lists)))
5447 ;; Remove all lists that are empty.
5448 (setq marked-lists (nth 3 info))
5451 (while (= 1 (length (car marked-lists)))
5452 (setq marked-lists (cdr marked-lists)))
5453 (setq m (cdr (setq prev marked-lists)))
5455 (if (= 1 (length (car m)))
5456 (setcdr prev (cdr m))
5459 (setcar (nthcdr 3 info) marked-lists)))
5460 ;; Finally, if there are no marked lists at all left, and if there
5461 ;; are no elements after the lists in the info list, we just chop
5462 ;; the info list off before the marked lists.
5463 (if (and (null marked-lists) (not (nthcdr 4 info)))
5464 (setcdr (nthcdr 2 info) nil)))
5467 (defun gnus-set-marked-articles
5468 (info ticked replied expirable killed dormant bookmark score)
5469 "Enter the various lists of marked articles into the newsgroup info list."
5471 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
5472 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
5473 (and expirable (setq newmarked (cons (cons 'expire expirable)
5475 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
5476 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
5477 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
5479 (and score (setq newmarked (cons (cons 'score score) newmarked)))
5482 (setcar (nthcdr 3 info) newmarked)
5483 (if (not (nthcdr 4 info))
5484 (setcdr (nthcdr 2 info) nil)
5485 (setcar (nthcdr 3 info) nil)))
5487 (setcdr (nthcdr 2 info) (cons newmarked nil))))))
5489 (defun gnus-add-marked-articles (group type articles &optional info force)
5490 ;; Add ARTICLES of TYPE to the info of GROUP.
5491 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
5492 ;; add, but replace marked articles of TYPE with ARTICLES.
5493 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
5496 (and (not (setq marked (nthcdr 3 info)))
5497 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
5498 (and (not (setq m (assq type (car marked))))
5499 (setcar marked (cons (cons type articles) (car marked))))
5502 (nconc m articles)))))
5504 (defun gnus-set-mode-line (where)
5505 "This function sets the mode line of the article or summary buffers.
5506 If WHERE is `summary', the summary mode line format will be used."
5507 (if (memq where gnus-updated-mode-lines)
5510 (set-buffer gnus-summary-buffer)
5511 (let* ((mformat (if (eq where 'article)
5512 gnus-article-mode-line-format-spec
5513 gnus-summary-mode-line-format-spec))
5514 (group-name gnus-newsgroup-name)
5515 (article-number (or gnus-current-article 0))
5516 (unread (- (length gnus-newsgroup-unreads)
5517 (length gnus-newsgroup-dormant)))
5518 (unread-and-unticked
5519 (- unread (length gnus-newsgroup-marked)))
5520 (unselected (length gnus-newsgroup-unselected))
5521 (unread-and-unselected
5522 (cond ((and (zerop unread-and-unticked)
5523 (zerop unselected)) "")
5525 (format "{%d more}" unread-and-unticked))
5526 (t (format "{%d(+%d) more}"
5527 unread-and-unticked unselected))))
5529 (if gnus-current-headers
5530 (header-subject gnus-current-headers) ""))
5531 (max-len (- (frame-width) gnus-mode-non-string-length)))
5532 (setq mode-string (eval mformat))
5533 (if (> (length mode-string) max-len)
5535 (concat (substring mode-string 0 (- max-len 3)) "...")))
5536 (setq mode-string (format (format "%%-%ds" max-len 5)
5538 (setq mode-line-buffer-identification mode-string)
5539 (set-buffer-modified-p t))))
5541 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5542 "Go through the HEADERS list and add all Xrefs to a hash table.
5543 The resulting hash table is returned, or nil if no Xrefs were found."
5544 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
5546 (gnus-group-foreign-p from-newsgroup)
5548 (assoc (symbol-name (car from-method))
5549 gnus-valid-select-methods))))
5550 (gnus-group-real-prefix from-newsgroup)))
5551 (xref-hashtb (make-vector 63 0))
5552 start group entry number xrefs header)
5554 (setq header (car headers))
5555 (if (and (setq xrefs (header-xref header))
5556 (not (memq (header-number header) unreads)))
5559 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
5560 (setq start (match-end 0))
5561 (setq group (concat prefix (substring xrefs (match-beginning 1)
5564 (string-to-int (substring xrefs (match-beginning 2)
5566 (if (setq entry (gnus-gethash group xref-hashtb))
5567 (setcdr entry (cons number (cdr entry)))
5568 (gnus-sethash group (cons number nil) xref-hashtb)))))
5569 (setq headers (cdr headers)))
5570 (if start xref-hashtb nil)))
5572 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
5573 "Look through all the headers and mark the Xrefs as read."
5574 (let ((virtual (memq 'virtual
5575 (assoc (symbol-name (car (gnus-find-method-for-group
5577 gnus-valid-select-methods)))
5578 name entry read info xref-hashtb idlist active num range exps method)
5580 (set-buffer gnus-group-buffer)
5581 (if (setq xref-hashtb
5582 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5585 (if (string= from-newsgroup (setq name (symbol-name group)))
5587 (setq idlist (symbol-value group))
5588 ;; Dead groups are not updated.
5589 (if (and (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5591 ;; Only do the xrefs if the group has the same
5592 ;; select method as the group we have just read.
5593 (or (gnus-methods-equal-p
5595 (gnus-find-method-for-group from-newsgroup))
5598 (setq method (gnus-find-method-for-group
5600 (and (equal (car (nth 4 info)) (car method))
5601 (equal (nth 1 (nth 4 info)) (nth 1 method))))
5602 gnus-use-cross-reference
5603 (or (not (eq gnus-use-cross-reference t))
5605 ;; Only do cross-references on subscribed
5606 ;; groups, if that is what is wanted.
5607 (<= (nth 1 info) 5)))
5610 ;; Set the new list of read articles in this group.
5611 (setq active (gnus-gethash name gnus-active-hashtb))
5612 ;; First peel off all illegal article numbers.
5615 (ticked (cdr (assq 'tick (nth 3 info))))
5616 (dormant (cdr (assq 'dormant (nth 3 info))))
5621 (if (or (> id (cdr active))
5625 (setq idlist (delq id idlist)))
5626 (and (memq id expirable)
5627 (setq exps (cons id exps)))
5628 (setq ids (cdr ids)))))
5629 ;; Update expirable articles.
5630 (gnus-add-marked-articles nil 'expirable exps info)
5631 (and (null (nth 2 info))
5633 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
5634 (setcar (nthcdr 2 info)
5638 (setq idlist (sort idlist '<)))))
5639 ;; Then we have to re-compute how many unread
5640 ;; articles there are in this group.
5645 (setq num (- (1+ (cdr active)) (car active))))
5646 ((not (listp (cdr range)))
5647 (setq num (- (cdr active) (- (1+ (cdr range))
5651 (if (numberp (car range))
5653 (setq num (+ num (- (1+ (cdr (car range)))
5654 (car (car range))))))
5655 (setq range (cdr range)))
5656 (setq num (- (cdr active) num))))
5657 ;; Update the number of unread articles.
5661 (length (cdr (assq 'tick (nth 3 info))))
5663 (cdr (assq 'dormant (nth 3 info)))))))
5664 ;; Update the group buffer.
5665 (gnus-group-update-group name t)))))))
5668 (defun gnus-methods-equal-p (m1 m2)
5669 (let ((m1 (or m1 gnus-select-method))
5670 (m2 (or m2 gnus-select-method)))
5672 (and (eq (car m1) (car m2))
5673 (or (not (memq 'address (assoc (symbol-name (car m1))
5674 gnus-valid-select-methods)))
5675 (equal (nth 1 m1) (nth 1 m2)))))))
5677 (defsubst gnus-header-value ()
5678 (buffer-substring (match-end 0) (save-excursion (end-of-line) (point))))
5680 (defun gnus-get-newsgroup-headers ()
5681 (setq gnus-article-internal-prepare-hook nil)
5682 (let ((cur nntp-server-buffer)
5683 (dependencies gnus-newsgroup-dependencies)
5685 headers char article id dep end)
5687 (set-buffer nntp-server-buffer)
5689 ;; Search to the beginning of the next header. Error messages
5690 ;; do not begin with 2 or 3.
5691 (while (re-search-forward "^[23][0-9]+ " nil t)
5692 (let ((header (make-vector 9 nil))
5693 (c (following-char))
5694 (case-fold-search t)
5696 from subject in-reply-to references ref)
5702 (header-set-number header (setq article (read cur)))
5703 ;; This implementation of this function, with nine
5704 ;; search-forwards instead of the one re-search-forward and
5705 ;; a case (which basically was the old function) is actually
5706 ;; about twice as fast, even though it looks messier. You
5707 ;; can't have everything, I guess. Speed and elegance
5708 ;; doesn't always come hand in hand.
5710 (narrow-to-region (point) (save-excursion
5711 (search-forward "\n.\n" nil t)))
5712 (if (search-forward "\nfrom: " nil t)
5713 (header-set-from header (gnus-header-value))
5714 (header-set-from header "(nobody)"))
5716 (if (search-forward "\nsubject: " nil t)
5717 (header-set-subject header (gnus-header-value))
5718 (header-set-subject header "(none)"))
5720 (and (search-forward "\nxref: " nil t)
5721 (header-set-xref header (gnus-header-value)))
5723 (and (search-forward "\nlines: " nil t)
5724 (header-set-lines header (read cur)))
5726 (and (search-forward "\ndate: " nil t)
5727 (header-set-date header (gnus-header-value)))
5729 (if (search-forward "\nmessage-id: " nil t)
5730 (header-set-id header (setq id (gnus-header-value)))
5731 ;; If there was no message-id, we just fake one to make
5732 ;; subsequent routines simpler.
5735 (setq id (concat "none+" (int-to-string
5736 (setq none-id (1+ none-id)))))))
5738 (if (search-forward "\nreferences: " nil t)
5740 (header-set-references header (gnus-header-value))
5741 (setq end (match-end 0))
5748 (search-backward ">" end t)
5751 (search-backward "<" end t)
5753 ;; Get the references from the in-reply-to header if there
5754 ;; ware no references and the in-reply-to header looks
5756 (if (and (search-forward "\nin-reply-to: " nil t)
5757 (setq in-reply-to (gnus-header-value))
5758 (string-match "<[^>]+>" in-reply-to))
5760 (header-set-references
5762 (setq ref (substring in-reply-to (match-beginning 0)
5764 (setq ref (downcase ref)))
5766 ;; We do some threading while we read the headers. The
5767 ;; message-id and the last reference are both entered into
5768 ;; the same hash table. Some tippy-toeing around has to be
5769 ;; done in case an article has arrived before the article
5770 ;; which it refers to.
5771 (if (boundp (setq dep (intern (downcase id) dependencies)))
5772 (if (car (symbol-value dep))
5773 ;; An article with this Message-ID has already
5774 ;; been seen, so we ignore this one, except we add
5775 ;; any additional Xrefs (in case the two articles
5776 ;; came from different servers.
5779 (car (symbol-value dep))
5780 (concat (or (header-xref (car (symbol-value dep))) "")
5781 (or (header-xref header) "")))
5783 (setcar (symbol-value dep) header))
5784 (set dep (list header)))
5787 (if (boundp (setq dep (intern ref dependencies)))
5788 (setcdr (symbol-value dep)
5789 (cons header (cdr (symbol-value dep))))
5790 (set dep (list nil header)))
5791 (setq headers (cons header headers))))
5792 (goto-char (point-max))))))
5793 (nreverse headers)))
5795 ;; The following macros and functions were written by Felix Lee
5796 ;; <flee@cse.psu.edu>.
5798 ;; This is almost 4x faster than (string-to-int (buffer-substring ... ))
5799 ;; primarily because of garbage collection. -jwz
5800 (defmacro gnus-read-integer (&optional point move-p)
5801 (` ((, (if move-p 'progn 'save-excursion))
5802 (,@ (if point (list (list 'goto-char point))))
5803 (if (and (<= (following-char) ?9)
5804 (>= (following-char) ?0))
5805 (read (current-buffer))
5808 (defmacro gnus-nov-skip-field ()
5809 '(search-forward "\t" eol 'end))
5811 (defmacro gnus-nov-field ()
5814 (progn (gnus-nov-skip-field) (1- (point)))))
5816 ;; Goes through the xover lines and returns a list of vectors
5817 (defun gnus-get-newsgroup-headers-xover (sequence)
5818 "Parse the news overview data in the server buffer, and return a
5819 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
5820 ;; Get the Xref when the users reads the articles since most/some
5821 ;; NNTP servers do not include Xrefs when using XOVER.
5822 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5823 (let ((cur nntp-server-buffer)
5824 (dependencies gnus-newsgroup-dependencies)
5826 number headers header)
5828 (set-buffer nntp-server-buffer)
5829 (goto-char (point-min))
5830 (while (and sequence (not (eobp)))
5831 (setq number (read cur))
5832 (while (and sequence (< (car sequence) number))
5833 (setq sequence (cdr sequence)))
5835 (eq number (car sequence))
5837 (setq sequence (cdr sequence))
5839 (inline (gnus-nov-parse-line number dependencies)))
5840 (setq headers (cons header headers)))))
5842 (setq headers (nreverse headers)))
5845 (defun gnus-nov-parse-line (number dependencies)
5846 "Point has to be after the number on the beginning of the line."
5848 header eol ref id dep)
5853 ;; overview: [num subject from date id refs chars lines misc]
5857 (gnus-nov-field) ; subject
5858 (gnus-nov-field) ; from
5859 (gnus-nov-field) ; date
5860 (setq id (gnus-nov-field)) ; id
5863 (let ((beg (point)))
5864 (search-forward "\t" eol)
5865 (if (search-backward ">" beg t)
5871 (search-backward "<" beg t)
5874 (gnus-nov-field)) ; refs
5875 (read (current-buffer)) ; chars
5876 (read (current-buffer)) ; lines
5877 (if (/= (following-char) ?\t)
5880 (gnus-nov-field)) ; misc
5882 ;; We build the thread tree.
5887 (or id (concat "none+"
5889 (setq none (1+ none))))))
5891 (if (car (symbol-value dep))
5892 ;; An article with this Message-ID has already been seen,
5893 ;; so we ignore this one, except we add any additional
5894 ;; Xrefs (in case the two articles came from different
5898 (car (symbol-value dep))
5899 (concat (or (header-xref (car (symbol-value dep))) "")
5900 (or (header-xref header) "")))
5902 (setcar (symbol-value dep) header))
5903 (set dep (list header)))
5906 (if (boundp (setq dep (intern (or ref "none")
5908 (setcdr (symbol-value dep)
5909 (cons header (cdr (symbol-value dep))))
5910 (set dep (list nil header)))))
5913 (defun gnus-article-get-xrefs ()
5914 "Fill in the Xref value in `gnus-current-headers', if necessary.
5915 This is meant to be called in `gnus-article-internal-prepare-hook'."
5916 (or (not gnus-use-cross-reference)
5917 (header-xref gnus-current-headers)
5918 (let ((case-fold-search t)
5921 (gnus-narrow-to-headers)
5922 (goto-char (point-min))
5923 (if (or (and (eq (downcase (following-char)) ?x)
5924 (looking-at "Xref:"))
5925 (search-forward "\nXref:" nil t))
5927 (goto-char (1+ (match-end 0)))
5928 (setq xref (buffer-substring (point)
5929 (progn (end-of-line) (point))))
5931 (set-buffer gnus-summary-buffer)
5932 (header-set-xref gnus-current-headers xref))))))))
5934 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
5935 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
5937 ;; Return a header specified by a NUMBER.
5938 (defun gnus-get-header-by-number (number)
5940 (set-buffer gnus-summary-buffer)
5941 (or gnus-newsgroup-headers-hashtb-by-number
5942 (gnus-make-headers-hashtable-by-number))
5943 (gnus-gethash (int-to-string number)
5944 gnus-newsgroup-headers-hashtb-by-number)))
5946 (defun gnus-make-headers-hashtable-by-number ()
5947 "Make hashtable for the variable gnus-newsgroup-headers by number."
5949 (set-buffer gnus-summary-buffer)
5950 (let ((headers gnus-newsgroup-headers)
5952 (setq gnus-newsgroup-headers-hashtb-by-number
5953 (gnus-make-hashtable (length headers)))
5955 (setq header (car headers))
5956 (gnus-sethash (int-to-string (header-number header))
5957 header gnus-newsgroup-headers-hashtb-by-number)
5958 (setq headers (cdr headers))))))
5960 (defun gnus-more-header-backward ()
5961 "Find new header backward."
5962 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5963 (artnum gnus-newsgroup-begin)
5965 (while (and (not header)
5967 (setq artnum (1- artnum))
5968 (setq header (gnus-read-header artnum)))
5971 (defun gnus-more-header-forward (&optional backward)
5972 "Find new header forward.
5973 If BACKWARD, find new header backward instead."
5975 (gnus-more-header-backward)
5976 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5977 (artnum gnus-newsgroup-end)
5979 (while (and (not header)
5981 (setq artnum (1+ artnum))
5982 (setq header (gnus-read-header artnum)))
5985 (defun gnus-extend-newsgroup (header &optional backward)
5986 "Extend newsgroup selection with HEADER.
5987 Optional argument BACKWARD means extend toward backward."
5989 (let ((artnum (header-number header)))
5990 (setq gnus-newsgroup-headers
5992 (cons header gnus-newsgroup-headers)
5993 (nconc gnus-newsgroup-headers (list header))))
5994 (setq gnus-newsgroup-unselected
5995 (delq artnum gnus-newsgroup-unselected))
5996 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
5997 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
5999 (defun gnus-summary-work-articles (n)
6000 "Return a list of articles to be worked upon. The prefix argument,
6001 the list of process marked articles, and the current article will be
6002 taken into consideration."
6004 (if (and n (numberp n))
6005 (let ((backward (< n 0))
6009 (setq articles (cons (gnus-summary-article-number)
6011 (gnus-summary-search-forward nil nil backward))
6013 (sort articles (function <)))
6014 (or (reverse gnus-newsgroup-processable)
6015 (list (gnus-summary-article-number))))))
6017 (defun gnus-summary-search-group (&optional backward use-level)
6018 "Search for next unread newsgroup.
6019 If optional argument BACKWARD is non-nil, search backward instead."
6021 (set-buffer gnus-group-buffer)
6023 ;; We don't want to alter current point of group mode buffer.
6024 (if (gnus-group-search-forward
6026 (if use-level (gnus-group-group-level) nil))
6027 (gnus-group-group-name)))))
6029 (defun gnus-summary-best-group ()
6030 "Find the name of the best unread group."
6032 (set-buffer gnus-group-buffer)
6034 (gnus-group-best-unread-group))))
6036 (defun gnus-summary-search-subject (&optional backward unread subject)
6037 "Search for article forward.
6038 If BACKWARD is non-nil, search backward.
6039 If UNREAD is non-nil, only unread articles are selected.
6040 If SUBJECT is non-nil, the article which has the same subject will be
6042 (let ((func (if backward 'previous-single-property-change
6043 'next-single-property-change))
6048 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
6049 (while (and (setq pos (funcall func (point) 'gnus-number))
6050 (goto-char (if backward (1- pos) pos))
6052 (not (and (or (not unread)
6053 (eq (get-text-property (point) 'gnus-mark)
6056 (equal (gnus-simplify-subject-re
6058 (gnus-simplify-subject-re
6061 'gnus-subject)))))))
6062 (if backward (if (bobp) nil (forward-char -1) t)
6063 (if (eobp) nil (forward-char 1) t))))
6065 (progn (goto-char beg) nil)
6067 (get-text-property (point) 'gnus-number)
6068 (gnus-summary-position-cursor)))))
6070 (defun gnus-summary-search-forward (&optional unread subject backward)
6071 "Search for article forward.
6072 If UNREAD is non-nil, only unread articles are selected.
6073 If SUBJECT is non-nil, the article which has the same subject will be
6075 If BACKWARD is non-nil, the search will be performed backwards instead."
6076 (gnus-summary-search-subject backward unread subject))
6078 (defun gnus-summary-search-backward (&optional unread subject)
6079 "Search for article backward.
6080 If 1st optional argument UNREAD is non-nil, only unread article is selected.
6081 If 2nd optional argument SUBJECT is non-nil, the article which has
6082 the same subject will be searched for."
6083 (gnus-summary-search-forward unread subject t))
6085 (defun gnus-summary-article-number (&optional number-or-nil)
6086 "The article number of the article on the current line.
6087 If there isn's an article number here, then we return the current
6089 (let ((number (get-text-property (save-excursion (beginning-of-line) (point))
6091 (if number-or-nil number (or number gnus-current-article))))
6093 (defun gnus-summary-thread-level ()
6094 "The thread level of the article on the current line."
6095 (or (get-text-property (save-excursion (beginning-of-line) (point))
6099 (defun gnus-summary-pseudo-article ()
6100 "The thread level of the article on the current line."
6101 (get-text-property (save-excursion (beginning-of-line) (point))
6104 (defun gnus-summary-article-mark ()
6105 "The mark on the current line."
6106 (get-text-property (save-excursion (beginning-of-line) (point))
6109 (defun gnus-summary-subject-string ()
6110 "Return current subject string or nil if nothing."
6111 (get-text-property (save-excursion (beginning-of-line) (point))
6114 (defalias 'gnus-summary-score 'gnus-summary-article-score)
6115 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
6116 (defun gnus-summary-article-score ()
6117 "Return current article score."
6118 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
6119 gnus-summary-default-score 0))
6121 (defun gnus-summary-recenter ()
6122 "Center point in the summary window.
6123 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6124 displayed, no centering will be performed."
6125 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6126 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6127 (let ((top (cond ((< (window-height) 4) 0)
6128 ((< (window-height) 6) 1)
6131 ;; The user has to want it,
6132 gnus-auto-center-summary
6133 ;; the article buffer must be displayed,
6134 (get-buffer-window gnus-article-buffer)
6135 ;; there must be lines left to scroll forward,
6136 (zerop (save-excursion (forward-line (- (window-height) 1 top))))
6139 (get-buffer-window (current-buffer))
6140 (save-excursion (forward-line (- top)) (point))))))
6142 (defun gnus-summary-jump-to-group (newsgroup)
6143 "Move point to NEWSGROUP in group mode buffer."
6144 ;; Keep update point of group mode buffer if visible.
6145 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6146 (save-window-excursion
6147 ;; Take care of tree window mode.
6148 (if (get-buffer-window gnus-group-buffer)
6149 (pop-to-buffer gnus-group-buffer))
6150 (gnus-group-jump-to-group newsgroup))
6152 ;; Take care of tree window mode.
6153 (if (get-buffer-window gnus-group-buffer)
6154 (pop-to-buffer gnus-group-buffer)
6155 (set-buffer gnus-group-buffer))
6156 (gnus-group-jump-to-group newsgroup))))
6158 ;; This function returns a list of article numbers based on the
6159 ;; difference between the ranges of read articles in this group and
6160 ;; the range of active articles.
6161 (defun gnus-list-of-unread-articles (group)
6162 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6163 (active (gnus-gethash group gnus-active-hashtb))
6165 unread first nlast unread)
6166 ;; If none are read, then all are unread.
6168 (setq first (car active))
6169 ;; If the range of read articles is a single range, then the
6170 ;; first unread article is the article after the last read
6171 ;; article. Sounds logical, doesn't it?
6172 (if (not (listp (cdr read)))
6173 (setq first (1+ (cdr read)))
6174 ;; `read' is a list of ranges.
6177 (while (< first nlast)
6178 (setq unread (cons first unread))
6179 (setq first (1+ first))))
6180 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
6181 (setq nlast (if (atom (car (cdr read)))
6183 (car (car (cdr read)))))
6184 (setq read (cdr read)))))
6185 ;; And add the last unread articles.
6186 (while (<= first last)
6187 (setq unread (cons first unread))
6188 (setq first (1+ first)))
6189 ;; Return the list of unread articles.
6193 ;; Various summary commands
6195 (defun gnus-summary-universal-argument ()
6196 "Perform any operation on all articles marked with the process mark."
6198 (gnus-set-global-variables)
6199 (let ((articles (reverse gnus-newsgroup-processable))
6201 (or articles (error "No articles marked"))
6202 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
6203 (error "Undefined key"))
6205 (gnus-summary-goto-subject (car articles))
6206 (command-execute func)
6207 (gnus-summary-remove-process-mark (car articles))
6208 (setq articles (cdr articles)))))
6210 (defun gnus-summary-toggle-truncation (arg)
6211 "Toggle truncation of summary lines.
6212 With arg, turn line truncation on iff arg is positive."
6214 (setq truncate-lines
6215 (if (null arg) (not truncate-lines)
6216 (> (prefix-numeric-value arg) 0)))
6219 (defun gnus-summary-reselect-current-group (show-all)
6220 "Once exit and then reselect the current newsgroup.
6221 Prefix argument SHOW-ALL means to select all articles."
6223 (gnus-set-global-variables)
6224 (let ((current-subject (gnus-summary-article-number)))
6225 (gnus-summary-exit t)
6226 ;; We have to adjust the point of group mode buffer because the
6227 ;; current point was moved to the next unread newsgroup by
6229 (gnus-summary-jump-to-group gnus-newsgroup-name)
6230 (gnus-group-read-group show-all t)
6231 (gnus-summary-goto-subject current-subject)))
6233 (defun gnus-summary-rescan-group (all)
6234 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6236 (gnus-set-global-variables)
6237 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
6238 (let ((group gnus-newsgroup-name))
6239 (gnus-summary-exit t)
6240 (gnus-summary-jump-to-group group)
6242 (set-buffer gnus-group-buffer)
6243 (gnus-group-get-new-news-this-group 1))
6244 (gnus-summary-jump-to-group group)
6245 (gnus-group-read-group all)))
6247 (defun gnus-summary-exit (&optional temporary)
6248 "Exit reading current newsgroup, and then return to group selection mode.
6249 gnus-exit-group-hook is called with no arguments if that value is non-nil."
6251 (gnus-set-global-variables)
6252 (gnus-kill-save-kill-buffer)
6253 (let* ((group gnus-newsgroup-name)
6254 (quit-buffer (cdr (assoc 'quit-buffer (gnus-find-method-for-group
6255 gnus-newsgroup-name))))
6257 (method (car (gnus-find-method-for-group group)))
6258 (buf (current-buffer)))
6259 (if gnus-newsgroup-kill-headers
6260 (setq gnus-newsgroup-killed
6261 (gnus-compress-sequence
6263 (gnus-set-sorted-intersection
6264 (gnus-uncompress-range gnus-newsgroup-killed)
6265 (setq gnus-newsgroup-unselected
6266 (sort gnus-newsgroup-unselected '<)))
6267 (setq gnus-newsgroup-unreads
6268 (sort gnus-newsgroup-unreads '<))) t)))
6269 (or (listp (cdr gnus-newsgroup-killed))
6270 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6272 (headers gnus-newsgroup-headers))
6273 (gnus-close-group group)
6274 (run-hooks 'gnus-exit-group-hook)
6276 (gnus-update-read-articles
6277 group gnus-newsgroup-unreads gnus-newsgroup-unselected
6278 gnus-newsgroup-marked
6279 t gnus-newsgroup-replied gnus-newsgroup-expirable
6280 gnus-newsgroup-killed gnus-newsgroup-dormant
6281 gnus-newsgroup-bookmarks
6282 (and gnus-save-score gnus-newsgroup-scored))
6283 (and gnus-use-cross-reference
6284 (gnus-mark-xrefs-as-read
6285 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
6286 ;; Do not switch windows but change the buffer to work.
6287 (set-buffer gnus-group-buffer)
6288 (or (eq 'nndigest method)
6289 (gnus-group-update-group group)))
6290 ;; Make sure where I was, and go to next newsgroup.
6291 (if (eq method 'nndigest)
6293 (gnus-group-jump-to-group group)
6294 (gnus-group-next-unread-group 1))
6296 ;; If exiting temporary, caller should adjust group mode
6297 ;; buffer point by itself.
6299 ;; We set all buffer-local variables to nil. It is unclear why
6300 ;; this is needed, but if we don't, buffer-local variables are
6301 ;; not garbage-collected, it seems. This would the lead to en
6302 ;; ever-growing Emacs.
6304 (gnus-summary-clear-local-variables)
6305 ;; We clear the global counterparts of the buffer-local
6306 ;; variables as well, just to be on the safe side.
6307 (set-buffer gnus-group-buffer)
6308 (gnus-summary-clear-local-variables)
6309 (gnus-configure-windows 'newsgroups t)
6310 ;; Return to group mode buffer.
6311 (and (get-buffer buf)
6312 (eq mode 'gnus-summary-mode)
6314 (if (get-buffer gnus-article-buffer)
6315 (bury-buffer gnus-article-buffer))
6316 (setq gnus-current-select-method gnus-select-method)
6317 (pop-to-buffer gnus-group-buffer)
6318 (if (and quit-buffer (buffer-name quit-buffer))
6320 (switch-to-buffer quit-buffer)
6321 (gnus-set-global-variables)
6322 (gnus-configure-windows 'summary))))))
6324 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6325 (defun gnus-summary-exit-no-update (&optional no-questions)
6326 "Quit reading current newsgroup without updating read article info."
6328 (let* ((group gnus-newsgroup-name)
6329 (quit-buffer (cdr (assoc 'quit-buffer
6330 (gnus-find-method-for-group group)))))
6331 (if (or no-questions
6333 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
6335 (gnus-close-group group)
6336 (gnus-summary-clear-local-variables)
6337 (set-buffer gnus-group-buffer)
6338 (gnus-summary-clear-local-variables)
6339 ;; Return to group selection mode.
6340 (gnus-configure-windows 'newsgroups)
6341 (if (get-buffer gnus-summary-buffer)
6342 (kill-buffer gnus-summary-buffer))
6343 (if (get-buffer gnus-article-buffer)
6344 (bury-buffer gnus-article-buffer))
6345 (pop-to-buffer gnus-group-buffer)
6346 (gnus-group-jump-to-group group)
6347 (gnus-group-next-group 1)
6348 (if (and quit-buffer (buffer-name quit-buffer))
6350 (switch-to-buffer quit-buffer)
6351 (gnus-configure-windows 'summary)))))))
6353 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6354 (defun gnus-summary-fetch-faq (group)
6355 "Fetch the FAQ for the current group."
6356 (interactive (list gnus-newsgroup-name))
6357 (gnus-configure-windows 'article)
6358 (pop-to-buffer gnus-article-buffer)
6359 (find-file (concat gnus-group-faq-directory group)))
6361 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6362 (defun gnus-summary-describe-group (force)
6363 "Describe the current newsgroup."
6365 (gnus-group-describe-group force gnus-newsgroup-name))
6367 (defun gnus-summary-describe-briefly ()
6368 "Describe summary mode commands briefly."
6371 (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")))
6373 ;; Walking around group mode buffer from summary mode.
6375 (defun gnus-summary-next-group (&optional no-article group backward)
6376 "Exit current newsgroup and then select next unread newsgroup.
6377 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
6378 If BACKWARD, go to previous group instead."
6380 (gnus-set-global-variables)
6381 (let ((ingroup gnus-newsgroup-name)
6382 (sumbuf (current-buffer))
6384 (gnus-summary-exit t) ;Update all information.
6386 (or (and (numberp (setq num (car (gnus-gethash
6387 group gnus-newsrc-hashtb))))
6391 (gnus-group-jump-to-group group)
6393 (gnus-group-jump-to-group ingroup))
6394 (let ((group (or group (gnus-summary-search-group backward)))
6395 (buf gnus-summary-buffer))
6397 (gnus-summary-exit-no-update t)
6398 (message "Selecting %s..." group)
6399 ;; We are now in group mode buffer.
6400 ;; Make sure group mode buffer point is on GROUP.
6401 (gnus-group-jump-to-group group)
6403 (gnus-summary-read-group group nil no-article buf)
6404 (and (string= gnus-newsgroup-name ingroup)
6407 (gnus-summary-exit-no-update t))))))))
6409 (defun gnus-summary-prev-group (no-article)
6410 "Exit current newsgroup and then select previous unread newsgroup.
6411 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6413 (gnus-summary-next-group no-article nil t))
6415 ;; Walking around summary lines.
6417 (defun gnus-summary-first-subject (unread)
6418 "Go to the first unread subject.
6419 If UNREAD is non-nil, go to the first unread article.
6420 Returns nil if there are no unread articles."
6422 (let ((begin (point)))
6424 (if (not (gnus-goto-char
6425 (text-property-any (point-min) (point-max)
6426 'gnus-mark gnus-unread-mark)))
6428 ;; If there is no unread articles, stay where you are.
6430 (message "No more unread articles")
6433 (goto-char (point-min)))))
6435 (defun gnus-summary-next-subject (n &optional unread)
6436 "Go to next N'th summary line.
6437 If N is negative, go to the previous N'th subject line.
6438 If UNREAD is non-nil, only unread articles are selected.
6439 The difference between N and the actual number of steps taken is
6442 (let ((backward (< n 0))
6445 (gnus-summary-search-forward unread nil backward))
6447 (gnus-summary-recenter)
6448 (if (/= 0 n) (message "No more%s articles" (if unread " unread" "")))
6449 (gnus-summary-position-cursor)
6452 (defun gnus-summary-next-unread-subject (n)
6453 "Go to next N'th unread summary line."
6455 (gnus-summary-next-subject n t))
6457 (defun gnus-summary-prev-subject (n &optional unread)
6458 "Go to previous N'th summary line.
6459 If optional argument UNREAD is non-nil, only unread article is selected."
6461 (gnus-summary-next-subject (- n) unread))
6463 (defun gnus-summary-prev-unread-subject (n)
6464 "Go to previous N'th unread summary line."
6466 (gnus-summary-next-subject (- n) t))
6468 (defun gnus-summary-goto-subject (article)
6469 "Go the subject line of ARTICLE."
6473 (completing-read "Article number: "
6477 (int-to-string (header-number headers))))
6478 gnus-newsgroup-headers)
6479 nil 'require-match))))
6480 (or article (error "No article number"))
6481 (if (or (eq article (gnus-summary-article-number t))
6484 (point-min) (point-max) 'gnus-number article)))
6487 ;; Walking around summary lines with displaying articles.
6489 (defun gnus-summary-expand-window ()
6490 "Expand summary window to show headers full window."
6492 (gnus-set-global-variables)
6493 (gnus-configure-windows 'summary)
6494 (pop-to-buffer gnus-summary-buffer))
6496 (defun gnus-summary-display-article (article &optional all-header)
6497 "Display ARTICLE in article buffer."
6498 (gnus-set-global-variables)
6501 (gnus-article-prepare article all-header)
6502 (if (= (gnus-summary-article-mark) ?Z)
6505 (gnus-summary-position-cursor)))
6506 (run-hooks 'gnus-select-article-hook)
6507 (gnus-summary-recenter)
6508 ; (set-window-point (get-buffer-window (current-buffer)) (point-max))
6510 (gnus-summary-goto-subject article)
6511 ;; Successfully display article.
6512 (gnus-summary-update-line)
6515 (defun gnus-summary-select-article (&optional all-headers force pseudo)
6516 "Select the current article.
6517 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6518 non-nil, the article will be re-fetched even if it already present in
6519 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6521 (and (not pseudo) (gnus-summary-pseudo-article)
6522 (error "This is a pseudo-article."))
6523 (let ((article (gnus-summary-article-number))
6524 (all-headers (not (not all-headers)))) ;Must be T or NIL.
6525 (if (or (null gnus-current-article)
6526 (null gnus-article-current)
6527 (/= article (cdr gnus-article-current))
6528 (not (equal (car gnus-article-current) gnus-newsgroup-name))
6530 ;; The requested article is different from the current article.
6532 (gnus-summary-display-article article all-headers)
6534 (if all-headers (gnus-article-show-all-headers))
6535 (gnus-configure-windows 'article)
6536 (pop-to-buffer gnus-summary-buffer)
6539 (defun gnus-summary-set-current-mark (&optional current-mark)
6540 "Obsolete function."
6543 (defun gnus-summary-next-article (unread &optional subject backward)
6544 "Select the next article.
6545 If UNREAD, only unread articles are selected.
6546 If SUBJECT, only articles with SUBJECT are selected.
6547 If BACKWARD, the previous article is selected instead of the next."
6549 (let ((opoint (point))
6550 (method (car (gnus-find-method-for-group gnus-newsgroup-name)))
6553 ;; Is there such an article?
6554 ((gnus-summary-display-article
6555 (gnus-summary-search-forward unread subject backward))
6556 (gnus-summary-position-cursor))
6557 ;; If not, we try the first unread, if that is wanted.
6559 gnus-auto-select-same
6560 (gnus-summary-first-unread-article))
6561 (message "Wrapped"))
6562 ;; Try to get next/previous article not displayed in this group.
6563 ((and gnus-auto-extend-newsgroup
6564 (not unread) (not subject)
6565 (setq header (gnus-more-header-forward backward)))
6566 (gnus-extend-newsgroup header backward)
6567 (let ((buffer-read-only nil))
6568 (goto-char (if backward (point-min) (point-max)))
6569 (gnus-summary-prepare-threads (list header) 0))
6570 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
6571 gnus-newsgroup-end)))
6572 ;; Go to next/previous group.
6574 (gnus-summary-jump-to-group gnus-newsgroup-name)
6575 (let ((cmd (aref (this-command-keys) 0))
6577 (if (eq gnus-keep-same-level 'best) (gnus-summary-best-group)
6578 (gnus-summary-search-group backward gnus-keep-same-level))))
6579 ;; Keep just the event type of CMD.
6580 (and (listp cmd) (setq cmd (car cmd)))
6581 ;; Select next unread newsgroup automagically.
6583 ((not gnus-auto-select-next)
6584 (message "No more%s articles" (if unread " unread" "")))
6585 ((eq gnus-auto-select-next 'quietly)
6587 (if (eq method 'nndigest)
6589 (message "No more%s articles (%s)..."
6590 (if unread " unread" "")
6591 (if group (concat "selecting " group)
6593 (gnus-summary-next-group nil group backward)))
6595 (let ((keystrokes '(?\C-n ?\C-p))
6597 (while (or (null key) (memq key keystrokes))
6599 "No more%s articles%s" (if unread " unread" "")
6600 (if (and group (not (eq method 'nndigest)))
6601 (format " (Type %s for %s [%s])"
6602 (single-key-description cmd) group
6603 (car (gnus-gethash group gnus-newsrc-hashtb)))
6604 (format " (Type %s to exit %s)"
6605 (single-key-description cmd)
6606 gnus-newsgroup-name)))
6607 ;; Confirm auto selection.
6608 (let* ((event (read-event)))
6609 (setq key (if (listp event) (car event) event))
6610 (if (member key keystrokes)
6611 (let ((obuf (current-buffer)))
6612 (switch-to-buffer gnus-group-buffer)
6613 (gnus-group-jump-to-group group)
6614 (execute-kbd-macro (char-to-string key))
6615 (setq group (gnus-group-group-name))
6616 (switch-to-buffer obuf)))))
6618 (if (or (not group) (eq method 'nndigest))
6620 (gnus-summary-next-group nil group backward))
6621 (setq unread-command-events (list key)))))))))))
6623 (defun gnus-summary-next-unread-article ()
6624 "Select unread article after current one."
6626 (gnus-summary-next-article t (and gnus-auto-select-same
6627 (gnus-summary-subject-string))))
6629 (defun gnus-summary-prev-article (unread &optional subject)
6630 "Select the article after the current one.
6631 If UNREAD is non-nil, only unread articles are selected."
6633 (gnus-summary-next-article unread subject t))
6635 (defun gnus-summary-prev-unread-article ()
6636 "Select unred article before current one."
6638 (gnus-summary-prev-article t (and gnus-auto-select-same
6639 (gnus-summary-subject-string))))
6641 (defun gnus-summary-next-page (lines &optional circular)
6642 "Show next page of selected article.
6643 If end of article, select next article.
6644 Argument LINES specifies lines to be scrolled up.
6645 If CIRCULAR is non-nil, go to the start of the article instead of
6646 instead of selecting the next article when reaching the end of the
6649 (setq gnus-summary-buffer (current-buffer))
6650 (let ((article (gnus-summary-article-number))
6652 (if (or (null gnus-current-article)
6653 (null gnus-article-current)
6654 (/= article (cdr gnus-article-current))
6655 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6656 ;; Selected subject is different from current article's.
6657 (gnus-summary-display-article article)
6658 (gnus-configure-windows 'article)
6659 (pop-to-buffer gnus-summary-buffer)
6660 (gnus-eval-in-buffer-window
6662 (setq endp (gnus-article-next-page lines)))
6665 (gnus-summary-beginning-of-article))
6667 (message "End of message"))
6669 (gnus-summary-next-unread-article))))))
6670 (gnus-summary-position-cursor))
6672 (defun gnus-summary-prev-page (lines)
6673 "Show previous page of selected article.
6674 Argument LINES specifies lines to be scrolled down."
6676 (let ((article (gnus-summary-article-number)))
6677 (if (or (null gnus-current-article)
6678 (null gnus-article-current)
6679 (/= article (cdr gnus-article-current))
6680 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6681 ;; Selected subject is different from current article's.
6682 (gnus-summary-display-article article)
6683 (gnus-configure-windows 'article)
6684 (pop-to-buffer gnus-summary-buffer)
6685 (gnus-eval-in-buffer-window gnus-article-buffer
6686 (gnus-article-prev-page lines))))
6687 (gnus-summary-position-cursor))
6689 (defun gnus-summary-scroll-up (lines)
6690 "Scroll up (or down) one line current article.
6691 Argument LINES specifies lines to be scrolled up (or down if negative)."
6693 (or (gnus-summary-select-article nil nil 'pseudo)
6694 (gnus-eval-in-buffer-window
6697 (if (gnus-article-next-page lines)
6698 (message "End of message")))
6700 (gnus-article-prev-page (- lines))))))
6701 (gnus-summary-position-cursor))
6703 (defun gnus-summary-next-same-subject ()
6704 "Select next article which has the same subject as current one."
6706 (gnus-summary-next-article nil (gnus-summary-subject-string)))
6708 (defun gnus-summary-prev-same-subject ()
6709 "Select previous article which has the same subject as current one."
6711 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
6713 (defun gnus-summary-next-unread-same-subject ()
6714 "Select next unread article which has the same subject as current one."
6716 (gnus-summary-next-article t (gnus-summary-subject-string)))
6718 (defun gnus-summary-prev-unread-same-subject ()
6719 "Select previous unread article which has the same subject as current one."
6721 (gnus-summary-prev-article t (gnus-summary-subject-string)))
6723 (defun gnus-summary-first-unread-article ()
6724 "Select the first unread article.
6725 Return nil if there are no unread articles."
6728 (if (gnus-summary-first-subject t)
6729 (gnus-summary-display-article (gnus-summary-article-number)))
6730 (gnus-summary-position-cursor)))
6732 (defun gnus-summary-best-unread-article ()
6733 "Select the unread article with the highest score."
6735 (gnus-set-global-variables)
6736 (let ((scored gnus-newsgroup-scored)
6740 (or (> best (cdr (car scored)))
6741 (and (memq (setq art (car (car scored))) gnus-newsgroup-unreads)
6742 (not (memq art gnus-newsgroup-marked))
6743 (not (memq art gnus-newsgroup-dormant))
6744 (if (= best (cdr (car scored)))
6745 (setq article (min art article))
6747 (setq best (cdr (car scored))))))
6748 (setq scored (cdr scored)))
6750 (gnus-summary-goto-article article)
6751 (gnus-summary-first-unread-article))
6752 (gnus-summary-position-cursor)))
6754 (defun gnus-summary-goto-article (article &optional all-headers)
6755 "Fetch ARTICLE and display it if it exists.
6756 If ALL-HEADERS is non-nil, no header lines are hidden."
6762 (mapcar (lambda (headers) (list (int-to-string (header-number headers))))
6763 gnus-newsgroup-headers)
6764 nil 'require-match))))
6765 (if (gnus-summary-goto-subject article)
6766 (gnus-summary-display-article article all-headers))
6767 (gnus-summary-position-cursor))
6769 (defun gnus-summary-goto-last-article ()
6770 "Go to the last article."
6772 (if gnus-last-article
6773 (gnus-summary-goto-article gnus-last-article))
6774 (gnus-summary-position-cursor))
6776 (defun gnus-summary-pop-article (number)
6777 "Pop one article off the history and go to the previous.
6778 NUMBER articles will be popped off."
6781 (setq gnus-newsgroup-history
6782 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6784 (gnus-summary-goto-article (car to))
6785 (error "Article history empty")))
6786 (gnus-summary-position-cursor))
6788 ;; Summary article oriented commands
6790 (defun gnus-summary-refer-parent-article (n)
6791 "Refer parent article N times.
6792 The difference between N and the number of articles fetched is returned."
6794 (gnus-set-global-variables)
6798 (let ((ref (header-references (gnus-get-header-by-number
6799 (gnus-summary-article-number)))))
6800 (if (and ref (not (equal ref ""))
6801 (string-match "<[^<>]*>[ \t]*$" ref))
6802 (gnus-summary-refer-article
6803 (substring ref (match-beginning 0) (match-end 0))))))
6805 (or (zerop n) (message "No references in article or expired article."))
6806 (gnus-summary-position-cursor)
6809 (defun gnus-summary-refer-article (message-id)
6810 "Refer article specified by MESSAGE-ID.
6811 NOTE: This command only works with newsgroup that use NNTP."
6812 (interactive "sMessage-ID: ")
6813 (if (or (not (stringp message-id))
6814 (zerop (length message-id)))
6816 ;; Construct the correct Message-ID if necessary.
6817 ;; Suggested by tale@pawl.rpi.edu.
6818 (or (string-match "^<" message-id)
6819 (setq message-id (concat "<" message-id)))
6820 (or (string-match ">$" message-id)
6821 (setq message-id (concat message-id ">")))
6822 (let ((header (car (gnus-gethash (downcase message-id)
6823 gnus-newsgroup-dependencies))))
6825 (gnus-summary-goto-article (header-number header))
6826 (let ((gnus-override-method gnus-refer-article-method))
6827 (if (gnus-article-prepare
6828 message-id nil (gnus-read-header message-id))
6830 (gnus-summary-insert-line
6831 nil gnus-current-headers 0 nil gnus-read-mark nil nil
6832 (header-subject gnus-current-headers))
6834 (gnus-summary-position-cursor)
6835 (gnus-summary-update-line)
6837 (message "No such references")
6840 (defun gnus-summary-enter-digest-group ()
6841 "Enter a digest group based on the current article."
6843 (gnus-summary-select-article)
6844 (let ((name (format "%s/%d"
6845 (gnus-group-prefixed-name
6846 gnus-newsgroup-name (list 'nndigest ""))
6847 gnus-current-article))
6848 (buf (current-buffer)))
6849 (set-buffer gnus-group-buffer)
6852 (list t nil (list name 3 nil nil
6853 (list 'nndigest gnus-article-buffer
6854 (cons 'quit-buffer buf))))
6856 (gnus-group-read-group t nil name)))
6858 (defun gnus-summary-isearch-article ()
6859 "Do incremental search forward on current article."
6861 (gnus-summary-select-article)
6862 (gnus-eval-in-buffer-window gnus-article-buffer
6865 (defun gnus-summary-search-article-forward (regexp)
6866 "Search for an article containing REGEXP forward.
6867 gnus-select-article-hook is not called during the search."
6870 (concat "Search forward (regexp): "
6871 (if gnus-last-search-regexp
6872 (concat "(default " gnus-last-search-regexp ") "))))))
6873 (if (string-equal regexp "")
6874 (setq regexp (or gnus-last-search-regexp ""))
6875 (setq gnus-last-search-regexp regexp))
6876 (if (gnus-summary-search-article regexp nil)
6877 (gnus-eval-in-buffer-window
6880 (error "Search failed: \"%s\"" regexp)))
6882 (defun gnus-summary-search-article-backward (regexp)
6883 "Search for an article containing REGEXP backward.
6884 gnus-select-article-hook is not called during the search."
6887 (concat "Search backward (regexp): "
6888 (if gnus-last-search-regexp
6889 (concat "(default " gnus-last-search-regexp ") "))))))
6890 (if (string-equal regexp "")
6891 (setq regexp (or gnus-last-search-regexp ""))
6892 (setq gnus-last-search-regexp regexp))
6893 (if (gnus-summary-search-article regexp t)
6894 (gnus-eval-in-buffer-window
6897 (error "Search failed: \"%s\"" regexp)))
6899 (defun gnus-summary-search-article (regexp &optional backward)
6900 "Search for an article containing REGEXP.
6901 Optional argument BACKWARD means do search for backward.
6902 gnus-select-article-hook is not called during the search."
6903 (let ((gnus-select-article-hook nil) ;Disable hook.
6904 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6907 (function re-search-backward) (function re-search-forward)))
6910 ;; Hidden thread subtrees must be searched for ,too.
6911 (gnus-summary-show-all-threads)
6912 (if (eobp) (forward-line -1))
6913 ;; First of all, search current article.
6914 ;; We don't want to read article again from NNTP server nor reset
6916 (gnus-summary-select-article)
6917 (message "Searching article: %d..." gnus-current-article)
6918 (setq last gnus-current-article)
6919 (gnus-eval-in-buffer-window gnus-article-buffer
6922 ;; Begin search from current point.
6923 (setq found (funcall re-search regexp nil t))))
6924 ;; Then search next articles.
6925 (while (and (not found)
6926 (gnus-summary-display-article
6927 (gnus-summary-search-subject backward nil nil)))
6928 (message "Searching article: %d..." gnus-current-article)
6929 (gnus-eval-in-buffer-window gnus-article-buffer
6932 (goto-char (if backward (point-max) (point-min)))
6933 (setq found (funcall re-search regexp nil t)))))
6935 ;; Adjust article pointer.
6936 (or (eq last gnus-current-article)
6937 (setq gnus-last-article last))
6938 ;; Return T if found such article.
6941 (defun gnus-summary-execute-command (header regexp command &optional backward)
6942 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6943 If HEADER is an empty string (or nil), the match is done on the entire
6944 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6946 (list (let ((completion-ignore-case t))
6949 (mapcar (string) (list string)
6950 '("Number" "Subject" "From" "Lines" "Date"
6951 "Message-ID" "Xref" "References")
6952 nil 'require-match)))
6953 (read-string "Regexp: ")
6954 (read-key-sequence "Command: ")
6955 current-prefix-arg))
6956 ;; Hidden thread subtrees must be searched as well.
6957 (gnus-summary-show-all-threads)
6958 ;; We don't want to change current point nor window configuration.
6960 (save-window-excursion
6961 (message "Executing %s..." (key-description command))
6962 ;; We'd like to execute COMMAND interactively so as to give arguments.
6963 (gnus-execute header regexp
6965 (call-interactively '(, (key-binding command)))))
6967 (message "Executing %s... done" (key-description command)))))
6969 (defun gnus-summary-beginning-of-article ()
6970 "Scroll the article back to the beginning."
6972 (gnus-summary-select-article)
6973 (gnus-eval-in-buffer-window
6976 (goto-char (point-min))
6977 (and gnus-break-pages (gnus-narrow-to-page))))
6979 (defun gnus-summary-end-of-article ()
6980 "Scroll to the end of the article."
6982 (gnus-summary-select-article)
6983 (gnus-eval-in-buffer-window
6986 (goto-char (point-max))
6987 (and gnus-break-pages (gnus-narrow-to-page))))
6989 (defun gnus-summary-show-article ()
6990 "Force re-fetching of the current article."
6992 (gnus-summary-select-article gnus-have-all-headers t t))
6994 (defun gnus-summary-toggle-header (arg)
6995 "Show the headers if they are hidden, or hide them if they are shown.
6996 If ARG is a positive number, show the entire header.
6997 If ARG is a negative number, hide the unwanted header lines."
6999 (gnus-set-global-variables)
7001 (set-buffer gnus-article-buffer)
7002 (let ((buffer-read-only nil))
7004 (if (> arg 0) (remove-text-properties 1 (point-max) '(invisible t))
7005 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
7006 (if (text-property-any 1 (point-max) 'invisible t)
7007 (remove-text-properties 1 (point-max) '(invisible t))
7008 (let ((gnus-have-all-headers nil))
7009 (run-hooks 'gnus-article-display-hook)))))))
7011 (defun gnus-summary-show-all-headers ()
7012 "Make all header lines visible."
7014 (gnus-article-show-all-headers))
7016 (defun gnus-summary-toggle-mime (arg)
7017 "Toggle MIME processing.
7018 If ARG is a positive number, turn MIME processing on."
7020 (setq gnus-show-mime
7021 (if (null arg) (not gnus-show-mime)
7022 (> (prefix-numeric-value arg) 0)))
7023 (gnus-summary-select-article t 'force))
7025 (defun gnus-summary-caesar-message (rotnum)
7026 "Caesar rotates all letters of current message by 13/47 places.
7027 With prefix arg, specifies the number of places to rotate each letter forward.
7028 Caesar rotates Japanese letters by 47 places in any case."
7030 (gnus-summary-select-article)
7031 (let ((mail-header-separator "")) ; !!! Is this necessary?
7032 (gnus-overload-functions)
7033 (gnus-eval-in-buffer-window
7037 ;; We don't want to jump to the beginning of the message.
7038 ;; `save-excursion' does not do its job.
7039 (move-to-window-line 0)
7040 (let ((last (point)))
7041 (news-caesar-buffer-body rotnum)
7045 (defun gnus-summary-stop-page-breaking ()
7046 "Stop page breaking in the current article."
7048 (gnus-summary-select-article)
7049 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
7051 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
7053 (defun gnus-summary-move-article (n &optional to-newsgroup select-method)
7054 "Move the current article to a different newsgroup.
7055 If N is a positive number, move the N next articles.
7056 If N is a negative number, move the N previous articles.
7057 If N is nil and any articles have been marked with the process mark,
7058 move those articles instead.
7059 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7060 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
7061 re-spool using this method.
7062 For this function to work, both the current newsgroup and the
7063 newsgroup that you want to move to have to support the `request-move'
7064 and `request-accept' functions. (Ie. mail newsgroups at present.)"
7066 (gnus-set-global-variables)
7067 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
7068 (error "The current newsgroup does not support article moving"))
7069 (let ((articles (gnus-summary-work-articles n))
7071 (if (and (not to-newsgroup) (not select-method))
7074 (format "Where do you want to move %s? "
7075 (if (> (length articles) 1)
7076 (format "these %d articles" (length articles))
7078 gnus-active-hashtb nil t
7079 (gnus-group-real-prefix gnus-newsgroup-name))))
7080 (or (gnus-check-backend-function 'request-accept-article
7081 (or select-method to-newsgroup))
7082 (error "%s does not support article moving" to-newsgroup))
7083 (message "Moving to %s: %s..." (or select-method to-newsgroup) articles)
7086 (gnus-request-move-article
7087 (car articles) ; Article to move
7088 gnus-newsgroup-name ; From newsgrouo
7089 (nth 1 (gnus-find-method-for-group
7090 gnus-newsgroup-name)) ; Server
7091 (list 'gnus-request-accept-article
7093 (quote select-method)
7095 (not (cdr articles))) ; Accept form
7096 (not (cdr articles)))) ; Only save nov last time
7097 (let* ((buffer-read-only nil)
7100 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7102 (gnus-group-prefixed-name
7104 (if select-method (list select-method "")
7105 (gnus-find-method-for-group to-newsgroup)))
7106 gnus-newsrc-hashtb)))
7107 (info (nth 2 entry))
7108 (article (car articles))
7109 (marked (nth 3 info)))
7110 (gnus-summary-goto-subject article)
7111 (delete-region (progn (beginning-of-line) (point))
7112 (progn (forward-line 1) (point)))
7113 (if (not (memq article gnus-newsgroup-unreads))
7114 (setcar (cdr (cdr info))
7115 (gnus-add-to-range (nth 2 info)
7116 (list (cdr art-group)))))
7117 ;; Copy any marks over to the new group.
7118 (let ((marks '((tick . gnus-newsgroup-marked)
7119 (dormant . gnus-newsgroup-dormant)
7120 (expire . gnus-newsgroup-expirable)
7121 (bookmark . gnus-newsgroup-bookmarks)
7122 ; (score . gnus-newsgroup-scored)
7123 (reply . gnus-newsgroup-replied)))
7124 (to-article (cdr art-group)))
7126 (if (memq article (symbol-value (cdr (car marks))))
7127 (gnus-add-marked-articles
7128 (car info) (car (car marks)) (list to-article) info))
7129 (setq marks (cdr marks)))))
7130 (message "Couldn't move article %s" (car articles)))
7131 (gnus-summary-remove-process-mark (car articles))
7132 (setq articles (cdr articles)))))
7134 (defun gnus-summary-respool-article (n &optional respool-method)
7135 "Respool the current article.
7136 The article will be squeezed through the mail spooling process again,
7137 which means that it will be put in some mail newsgroup or other
7138 depending on `nnmail-split-methods'.
7139 If N is a positive number, respool the N next articles.
7140 If N is a negative number, respool the N previous articles.
7141 If N is nil and any articles have been marked with the process mark,
7142 respool those articles instead.
7143 For this function to work, both the current newsgroup and the
7144 newsgroup that you want to move to have to support the `request-move'
7145 and `request-accept' functions. (Ie. mail newsgroups at present.)"
7147 (gnus-set-global-variables)
7149 (setq respool-method
7151 "What method do you want to use when respooling? "
7152 (gnus-methods-using 'respool) nil t)))
7153 (gnus-summary-move-article n nil (intern respool-method)))
7155 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
7156 (defun gnus-summary-copy-article (n &optional to-newsgroup select-method)
7157 "Move the current article to a different newsgroup.
7158 If N is a positive number, move the N next articles.
7159 If N is a negative number, move the N previous articles.
7160 If N is nil and any articles have been marked with the process mark,
7161 move those articles instead.
7162 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7163 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
7164 re-spool using this method.
7165 For this function to work, the newsgroup that you want to move to have
7166 to support the `request-move' and `request-accept'
7167 functions. (Ie. mail newsgroups at present.)"
7169 (gnus-set-global-variables)
7170 (let ((articles (gnus-summary-work-articles n))
7171 (copy-buf (get-buffer-create "*copy work*"))
7173 (buffer-disable-undo copy-buf)
7174 (if (and (not to-newsgroup) (not select-method))
7177 (format "Where do you want to copy %s? "
7178 (if (> (length articles) 1)
7179 (format "these %d articles" (length articles))
7181 gnus-active-hashtb nil t
7182 (gnus-group-real-prefix gnus-newsgroup-name))))
7183 (or (gnus-check-backend-function 'request-accept-article
7184 (or select-method to-newsgroup))
7185 (error "%s does not support article copying" to-newsgroup))
7186 (message "Moving to %s: %s..." (or select-method to-newsgroup) articles)
7190 (set-buffer copy-buf)
7191 (gnus-request-article-this-buffer
7192 (car articles) gnus-newsgroup-name)
7193 (gnus-request-accept-article
7194 (if select-method (quote select-method) to-newsgroup)
7195 (not (cdr articles)))))
7198 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7200 (gnus-group-prefixed-name
7202 (if select-method (list select-method "")
7203 (gnus-find-method-for-group to-newsgroup)))
7204 gnus-newsrc-hashtb)))
7205 (info (nth 2 entry))
7206 (article (car articles))
7207 (marked (nth 3 info)))
7208 (if (not (memq article gnus-newsgroup-unreads))
7209 (setcar (cdr (cdr info))
7210 (gnus-add-to-range (nth 2 info)
7211 (list (cdr art-group)))))
7212 ;; Copy any marks over to the new group.
7213 (let ((marks '((tick . gnus-newsgroup-marked)
7214 (dormant . gnus-newsgroup-dormant)
7215 (expire . gnus-newsgroup-expirable)
7216 (bookmark . gnus-newsgroup-bookmarks)
7217 ; (score . gnus-newsgroup-scored)
7218 (reply . gnus-newsgroup-replied)))
7219 (to-article (cdr art-group)))
7221 (if (memq article (symbol-value (cdr (car marks))))
7222 (gnus-add-marked-articles
7223 (car info) (car (car marks)) (list to-article) info))
7224 (setq marks (cdr marks)))))
7225 (message "Couldn't copy article %s" (car articles)))
7226 (gnus-summary-remove-process-mark (car articles))
7227 (setq articles (cdr articles)))
7228 (kill-buffer copy-buf)))
7230 (defun gnus-summary-expire-articles ()
7231 "Expire all articles that are marked as expirable in the current group."
7233 (if (and gnus-newsgroup-expirable
7234 (gnus-check-backend-function
7235 'request-expire-articles gnus-newsgroup-name))
7236 (let ((expirable gnus-newsgroup-expirable))
7237 ;; The list of articles that weren't expired is returned.
7238 (setq gnus-newsgroup-expirable
7239 (gnus-request-expire-articles gnus-newsgroup-expirable
7240 gnus-newsgroup-name))
7241 ;; We go through the old list of expirable, and mark all
7242 ;; really expired articles as non-existant.
7244 (or (memq (car expirable) gnus-newsgroup-expirable)
7245 (gnus-summary-mark-as-read (car expirable) "%"))
7246 (setq expirable (cdr expirable))))))
7248 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7249 (defun gnus-summary-delete-article (n)
7250 "Delete the N next (mail) articles.
7251 This command actually deletes articles. This is not a marking
7252 command. The article will disappear forever from you life, never to
7254 If N is negative, delete backwards.
7255 If N is nil and articles have been marked with the process mark,
7256 delete these instead."
7258 (or (gnus-check-backend-function 'request-expire-articles
7259 gnus-newsgroup-name)
7260 (error "The current newsgroup does not support article deletion."))
7261 ;; Compute the list of articles to delete.
7262 (let ((articles (gnus-summary-work-articles n)))
7263 (if (and gnus-novice-user
7265 (format "Do you really want to delete %s forever? "
7266 (if (> (length articles) 1) "these articles"
7269 ;; Delete the articles.
7270 (setq gnus-newsgroup-expirable
7271 (gnus-request-expire-articles
7272 articles gnus-newsgroup-name 'force))
7274 (gnus-summary-remove-process-mark (car articles))
7275 ;; The backend might not have been able to delete the article
7277 (or (memq (car articles) gnus-newsgroup-expirable)
7278 (gnus-summary-mark-as-read (car articles) gnus-canceled-mark))
7279 (setq articles (cdr articles))))))
7281 (defun gnus-summary-edit-article ()
7282 "Enter into a buffer and edit the current article.
7283 This will have permanent effect only in mail groups."
7285 (or (gnus-check-backend-function
7286 'request-replace-article gnus-newsgroup-name)
7287 (error "The current newsgroup does not support article editing."))
7288 (gnus-summary-select-article t)
7290 (message "C-c C-c to end edits")
7291 (setq buffer-read-only nil)
7293 (use-local-map (copy-keymap (current-local-map)))
7294 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
7296 (search-forward "\n\n" nil t))
7298 (defun gnus-summary-edit-article-done ()
7299 "Make edits to the current article permanent."
7301 (if (not (gnus-request-replace-article
7302 (cdr gnus-article-current) (car gnus-article-current)
7304 (error "Couldn't replace article.")
7306 (use-local-map gnus-article-mode-map)
7307 (setq buffer-read-only t)
7308 (pop-to-buffer gnus-summary-buffer)))
7310 ;; Summary score commands.
7312 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
7314 (defun gnus-summary-raise-score (n)
7315 "Raise the score of the current article by N."
7317 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
7319 (defun gnus-summary-lower-score (n)
7320 "Lower the score of the current article by N."
7322 (gnus-summary-raise-score (- n)))
7324 (defun gnus-summary-set-score (n)
7325 "Set the score of the current article to N."
7327 ;; Skip dummy header line.
7329 (if (= (gnus-summary-article-mark) ?Z) (forward-line 1))
7330 (let ((buffer-read-only nil))
7332 (gnus-summary-update-mark
7333 (if (= n (or gnus-summary-default-score 0)) ?
7334 (if (< n (or gnus-summary-default-score 0))
7335 gnus-score-below-mark gnus-score-over-mark)) 'score))
7336 (let* ((article (gnus-summary-article-number))
7337 (score (assq article gnus-newsgroup-scored)))
7338 (if score (setcdr score n)
7339 (setq gnus-newsgroup-scored
7340 (cons (cons article n) gnus-newsgroup-scored))))
7341 (gnus-summary-update-line)))
7343 ;; Summary marking commands.
7345 (defun gnus-summary-raise-same-subject-and-select (score)
7346 "Raise articles which has the same subject with SCORE and select the next."
7348 (let ((subject (gnus-summary-subject-string)))
7349 (gnus-summary-raise-score score)
7350 (while (gnus-summary-search-subject nil nil subject)
7351 (gnus-summary-raise-score score))
7352 (gnus-summary-next-article t)))
7354 (defun gnus-summary-raise-same-subject (score)
7355 "Raise articles which has the same subject with SCORE."
7357 (let ((subject (gnus-summary-subject-string)))
7358 (gnus-summary-raise-score score)
7359 (while (gnus-summary-search-subject nil nil subject)
7360 (gnus-summary-raise-score score))
7361 (gnus-summary-next-subject 1 t)))
7363 (defun gnus-summary-raise-thread (score)
7364 "Raise articles under current thread with SCORE."
7368 (let ((level (gnus-summary-thread-level)))
7369 (gnus-summary-raise-score score)
7370 (while (and (zerop (gnus-summary-next-subject 1))
7371 (> (gnus-summary-thread-level) level))
7372 (gnus-summary-raise-score score))
7374 (or (zerop (gnus-summary-next-subject 1 t))
7376 (gnus-summary-position-cursor)
7377 (gnus-set-mode-line 'summary))
7379 (defun gnus-summary-lower-same-subject-and-select (score)
7380 "Raise articles which has the same subject with SCORE and select the next."
7382 (gnus-summary-raise-same-subject-and-select (- score)))
7384 (defun gnus-summary-lower-same-subject (score)
7385 "Raise articles which has the same subject with SCORE."
7387 (gnus-summary-raise-same-subject (- score)))
7389 (defun gnus-summary-lower-thread (score)
7390 "Raise articles under current thread with SCORE."
7392 (gnus-summary-raise-thread (- score)))
7394 (defun gnus-summary-kill-same-subject-and-select (unmark)
7395 "Mark articles which has the same subject as read, and then select the next.
7396 If UNMARK is positive, remove any kind of mark.
7397 If UNMARK is negative, tick articles."
7400 (setq unmark (prefix-numeric-value unmark)))
7402 (gnus-summary-mark-same-subject
7403 (gnus-summary-subject-string) unmark)))
7404 ;; Select next unread article. If auto-select-same mode, should
7405 ;; select the first unread article.
7406 (gnus-summary-next-article t (and gnus-auto-select-same
7407 (gnus-summary-subject-string)))
7408 (message "%d articles are marked as %s"
7409 count (if unmark "unread" "read"))))
7411 (defun gnus-summary-kill-same-subject (unmark)
7412 "Mark articles which has the same subject as read.
7413 If UNMARK is positive, remove any kind of mark.
7414 If UNMARK is negative, tick articles."
7417 (setq unmark (prefix-numeric-value unmark)))
7419 (gnus-summary-mark-same-subject
7420 (gnus-summary-subject-string) unmark)))
7421 ;; If marked as read, go to next unread subject.
7423 ;; Go to next unread subject.
7424 (gnus-summary-next-subject 1 t))
7425 (message "%d articles are marked as %s"
7426 count (if unmark "unread" "read"))))
7428 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7429 "Mark articles with same SUBJECT as read, and return marked number.
7430 If optional argument UNMARK is positive, remove any kinds of marks.
7431 If optional argument UNMARK is negative, mark articles as unread instead."
7434 (cond ((null unmark)
7435 (gnus-summary-mark-as-read nil gnus-killed-mark))
7437 (gnus-summary-tick-article nil t))
7439 (gnus-summary-tick-article)))
7441 (gnus-summary-search-forward nil subject))
7442 (cond ((null unmark)
7443 (gnus-summary-mark-as-read nil gnus-killed-mark))
7445 (gnus-summary-tick-article nil t))
7447 (gnus-summary-tick-article)))
7448 (setq count (1+ count))))
7449 ;; Hide killed thread subtrees. Does not work properly always.
7450 ;;(and (null unmark)
7451 ;; gnus-thread-hide-killed
7452 ;; (gnus-summary-hide-thread))
7453 ;; Return number of articles marked as read.
7456 (defun gnus-summary-mark-as-processable (n &optional unmark)
7457 "Set the process mark on the next N articles.
7458 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7459 the process mark instead. The difference between N and the actual
7460 number of articles marked is returned."
7462 (let ((backward (< n 0))
7467 (gnus-summary-remove-process-mark (gnus-summary-article-number))
7468 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7469 (zerop (gnus-summary-next-subject (if backward -1 1))))
7471 (if (/= 0 n) (message "No more articles"))
7474 (defun gnus-summary-unmark-as-processable (n)
7475 "Remove the process mark from the next N articles.
7476 If N is negative, mark backward instead. The difference between N and
7477 the actual number of articles marked is returned."
7479 (gnus-summary-mark-as-processable n t))
7481 (defun gnus-summary-unmark-all-processable ()
7482 "Remove the process mark from all articles."
7485 (while gnus-newsgroup-processable
7486 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7487 (gnus-summary-position-cursor))
7489 (defun gnus-summary-mark-as-expirable (n)
7490 "Mark N articles forward as expirable.
7491 If N is negative, mark backward instead. The difference between N and
7492 the actual number of articles marked is returned."
7494 (gnus-summary-mark-forward n gnus-expirable-mark))
7496 (defun gnus-summary-mark-article-as-replied (article)
7497 "Mark ARTICLE replied and update the summary line."
7498 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
7499 (let ((buffer-read-only nil))
7500 (if (gnus-summary-goto-subject article)
7502 (gnus-summary-update-mark gnus-replied-mark 'replied)
7505 (defun gnus-summary-set-bookmark (article)
7506 "Set a bookmark in current article."
7507 (interactive (list (gnus-summary-article-number)))
7508 (if (or (not (get-buffer gnus-article-buffer))
7509 (not gnus-current-article)
7510 (not gnus-article-current)
7511 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7512 (error "No current article selected"))
7513 ;; Remove old bookmark, if one exists.
7514 (let ((old (assq article gnus-newsgroup-bookmarks)))
7515 (if old (setq gnus-newsgroup-bookmarks
7516 (delq old gnus-newsgroup-bookmarks))))
7517 ;; Set the new bookmark, which is on the form
7518 ;; (article-number . line-number-in-body).
7519 (setq gnus-newsgroup-bookmarks
7523 (set-buffer gnus-article-buffer)
7528 (search-forward "\n\n" nil t)
7531 gnus-newsgroup-bookmarks))
7532 (message "A bookmark has been added to the current article."))
7534 (defun gnus-summary-remove-bookmark (article)
7535 "Remove the bookmark from the current article."
7536 (interactive (list (gnus-summary-article-number)))
7537 ;; Remove old bookmark, if one exists.
7538 (let ((old (assq article gnus-newsgroup-bookmarks)))
7541 (setq gnus-newsgroup-bookmarks
7542 (delq old gnus-newsgroup-bookmarks))
7543 (message "Removed bookmark."))
7544 (message "No bookmark in current article."))))
7546 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7547 (defun gnus-summary-mark-as-dormant (n)
7548 "Mark N articles forward as dormant.
7549 If N is negative, mark backward instead. The difference between N and
7550 the actual number of articles marked is returned."
7552 (gnus-summary-mark-forward n gnus-dormant-mark))
7554 (defun gnus-summary-set-process-mark (article)
7555 "Set the process mark on ARTICLE and update the summary line."
7556 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
7557 (let ((buffer-read-only nil))
7558 (if (gnus-summary-goto-subject article)
7560 (if (= (gnus-summary-article-mark) ?Z) (forward-line 1))
7561 (gnus-summary-update-mark gnus-process-mark 'replied)
7564 (defun gnus-summary-remove-process-mark (article)
7565 "Remove the process mark from ARTICLE and update the summary line."
7566 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7567 (let ((buffer-read-only nil))
7568 (if (gnus-summary-goto-subject article)
7570 (and (= (gnus-summary-article-mark) ?Z) (forward-line 1))
7571 (gnus-summary-update-mark ? 'replied)
7572 (if (memq article gnus-newsgroup-replied)
7573 (gnus-summary-update-mark gnus-replied-mark 'replied))
7576 (defun gnus-summary-mark-forward (n &optional mark)
7577 "Mark N articles as read forwards.
7578 If N is negative, mark backwards instead.
7579 Mark with MARK. If MARK is ? , ?! or ??, articles will be
7581 The difference between N and the actual number of articles marked is
7584 (gnus-set-global-variables)
7585 (let ((backward (< n 0))
7587 (mark (or mark gnus-dread-mark)))
7589 (gnus-summary-mark-article nil mark)
7590 (zerop (gnus-summary-next-subject
7591 (if backward -1 1) gnus-summary-goto-unread)))
7593 (if (/= 0 n) (message "No more %sarticles" (if mark "" "unread ")))
7594 (gnus-set-mode-line 'summary)
7597 (defun gnus-summary-mark-article (&optional article mark)
7598 "Mark ARTICLE with MARK.
7599 MARK can be any character.
7600 Five MARK strings are reserved: ? (unread),
7601 ?! (ticked), ?? (dormant), ?D (read), ?E (expirable).
7602 If MARK is nil, then the default character ?D is used.
7603 If ARTICLE is nil, then the article on the current line will be
7605 ;; If no mark is given, then we check auto-expiring.
7607 (and (numberp mark) (or (= mark gnus-killed-mark)
7608 (= mark gnus-dread-mark)
7609 (= mark gnus-catchup-mark)
7610 (= mark gnus-low-score-mark)
7611 (= mark gnus-read-mark))))
7612 gnus-newsgroup-auto-expire
7613 (setq mark gnus-expirable-mark))
7614 (let* ((buffer-read-only nil)
7615 (mark (or (and (stringp mark) (aref mark 0)) mark gnus-dread-mark))
7616 (article (or article (gnus-summary-article-number))))
7617 (if (or (= mark gnus-unread-mark)
7618 (= mark gnus-ticked-mark)
7619 (= mark gnus-dormant-mark))
7620 (gnus-mark-article-as-unread article mark)
7621 (gnus-mark-article-as-read article mark))
7622 (if (gnus-summary-goto-subject article)
7624 (gnus-summary-show-thread)
7626 (if (= (gnus-summary-article-mark) ?Z) (forward-line 1))
7628 (gnus-summary-update-mark mark 'unread)
7631 (defun gnus-summary-update-mark (mark type)
7633 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7637 (forward-char forward)
7638 (setq plist (text-properties-at (point)))
7640 (and (memq 'gnus-mark plist) (setcar (cdr (memq 'gnus-mark plist)) mark))
7642 (and plist (add-text-properties (1- (point)) (point) plist))
7643 (gnus-summary-update-line (eq mark gnus-unread-mark)))))
7645 (defun gnus-mark-article-as-read (article &optional mark)
7646 "Enter ARTICLE in the pertinent lists and remove it from others."
7647 ;; Make the article expirable.
7648 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-dread-mark)))
7649 (if (= mark gnus-expirable-mark)
7650 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
7651 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7652 ;; Remove from unread and marked lists.
7653 (setq gnus-newsgroup-unreads
7654 (delq article gnus-newsgroup-unreads))
7655 (setq gnus-newsgroup-marked
7656 (delq article gnus-newsgroup-marked))
7657 (setq gnus-newsgroup-dormant
7658 (delq article gnus-newsgroup-dormant))))
7660 (defun gnus-mark-article-as-unread (article &optional mark)
7661 "Enter ARTICLE in the pertinent lists and remove it from others."
7662 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-ticked-mark)))
7663 ;; Add to unread list.
7664 (or (memq article gnus-newsgroup-unreads)
7665 (setq gnus-newsgroup-unreads
7666 (cons article gnus-newsgroup-unreads)))
7667 ;; If CLEAR-MARK is non-nil, the article must be removed from marked
7668 ;; list. Otherwise, it must be added to the list.
7669 (setq gnus-newsgroup-marked
7670 (delq article gnus-newsgroup-marked))
7671 (setq gnus-newsgroup-dormant
7672 (delq article gnus-newsgroup-dormant))
7673 (setq gnus-newsgroup-expirable
7674 (delq article gnus-newsgroup-expirable))
7675 (if (= mark gnus-ticked-mark)
7676 (setq gnus-newsgroup-marked
7677 (cons article gnus-newsgroup-marked)))
7678 (if (= mark gnus-dormant-mark)
7679 (setq gnus-newsgroup-dormant
7680 (cons article gnus-newsgroup-dormant)))))
7682 (defalias 'gnus-summary-mark-as-unread-forward
7683 'gnus-summary-tick-article-forward)
7684 (make-obsolete 'gnus-summary-mark-as-unread-forward
7685 'gnus-summary-tick-article-forward)
7686 (defun gnus-summary-tick-article-forward (n)
7687 "Tick N articles forwards.
7688 If N is negative, tick backwards instead.
7689 The difference between N and the number of articles ticked is returned."
7691 (gnus-summary-mark-forward n gnus-ticked-mark))
7693 (defalias 'gnus-summary-mark-as-unread-backward
7694 'gnus-summary-tick-article-backward)
7695 (make-obsolete 'gnus-summary-mark-as-unread-backward
7696 'gnus-summary-tick-article-backward)
7697 (defun gnus-summary-tick-article-backward (n)
7698 "Tick N articles backwards.
7699 The difference between N and the number of articles ticked is returned."
7701 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
7703 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7704 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
7705 (defun gnus-summary-tick-article (&optional article clear-mark)
7706 "Mark current article as unread.
7707 Optional 1st argument ARTICLE specifies article number to be marked as unread.
7708 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
7709 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
7712 (defun gnus-summary-mark-as-read-forward (n)
7713 "Mark N articles as read forwards.
7714 If N is negative, mark backwards instead.
7715 The difference between N and the actual number of articles marked is
7718 (gnus-summary-mark-forward n))
7720 (defun gnus-summary-mark-as-read-backward (n)
7721 "Mark the N articles as read backwards.
7722 The difference between N and the actual number of articles marked is
7725 (gnus-summary-mark-forward (- n)))
7727 (defun gnus-summary-mark-as-read (&optional article mark)
7728 "Mark current article as read.
7729 ARTICLE specifies the article to be marked as read.
7730 MARK specifies a string to be inserted at the beginning of the line.
7731 Any kind of string (length 1) except for a space and `-' is ok."
7732 (gnus-summary-mark-article article mark))
7734 (defun gnus-summary-clear-mark-forward (n)
7735 "Clear marks from N articles forward.
7736 If N is negative, clear backward instead.
7737 The difference between N and the number of marks cleared is returned."
7739 (gnus-summary-mark-forward n gnus-unread-mark))
7741 (defun gnus-summary-clear-mark-backward (n)
7742 "Clear marks from N articles backward.
7743 The difference between N and the number of marks cleared is returned."
7745 (gnus-summary-mark-forward (- n) gnus-unread-mark))
7747 (defun gnus-summary-mark-unread-as-read ()
7748 "Intended to be used by `gnus-summary-mark-article-hook'."
7749 (or (memq gnus-current-article gnus-newsgroup-marked)
7750 (memq gnus-current-article gnus-newsgroup-dormant)
7751 (memq gnus-current-article gnus-newsgroup-expirable)
7752 (gnus-summary-mark-as-read gnus-current-article gnus-read-mark)))
7754 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
7755 (defalias 'gnus-summary-delete-marked-as-read
7756 'gnus-summary-remove-lines-marked-as-read)
7757 (make-obsolete 'gnus-summary-delete-marked-as-read
7758 'gnus-summary-remove-lines-marked-as-read)
7759 (defun gnus-summary-remove-lines-marked-as-read ()
7760 "Remove lines that are marked as read."
7762 (gnus-summary-remove-lines-marked-with
7764 (lambda (char) (char-to-string (symbol-value char)))
7765 '(gnus-dread-mark gnus-read-mark
7766 gnus-killed-mark gnus-kill-file-mark
7767 gnus-low-score-mark gnus-expirable-mark)
7770 (defalias 'gnus-summary-delete-marked-with
7771 'gnus-summary-remove-lines-marked-with)
7772 (make-obsolete 'gnus-summary-delete-marked-with
7773 'gnus-summary-remove-lines-marked-with)
7774 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
7775 (defun gnus-summary-remove-lines-marked-with (marks)
7776 "Remove lines that are marked with MARKS (e.g. \"DK\")."
7777 (interactive "sMarks: ")
7778 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
7780 (set-buffer gnus-summary-buffer)
7781 (let ((buffer-read-only nil)
7782 (marks (concat "^[" marks "]")))
7783 (goto-char (point-min))
7784 (while (search-forward-regexp marks (point-max) t)
7785 (delete-region (progn (beginning-of-line) (point))
7786 (progn (forward-line 1) (point)))))
7787 (or (zerop (buffer-size))
7789 (gnus-summary-prev-subject 1)
7790 (gnus-summary-position-cursor)))))
7792 (defun gnus-summary-expunge-below (score)
7793 "Remove articles with score less than SCORE."
7795 (setq score (if score
7796 (prefix-numeric-value score)
7797 (or gnus-summary-default-score 0)))
7799 (set-buffer gnus-summary-buffer)
7800 (goto-char (point-min))
7801 (let ((buffer-read-only nil)
7804 (if (< (gnus-summary-article-score) score)
7808 (delete-region beg (point)))
7811 (or (zerop (buffer-size))
7813 (gnus-summary-prev-subject 1)
7814 (gnus-summary-position-cursor))))))
7816 (defun gnus-summary-mark-below (score mark)
7817 "Mark articles with score less than SCORE with MARK."
7818 (interactive "P\ncMark: ")
7819 (setq score (if score
7820 (prefix-numeric-value score)
7821 (or gnus-summary-default-score 0)))
7823 (set-buffer gnus-summary-buffer)
7824 (goto-char (point-min))
7826 (and (< (gnus-summary-article-score) score)
7827 (gnus-summary-mark-article nil mark))
7830 (defun gnus-summary-kill-below (score)
7831 "Mark articles with score below SCORE as read."
7833 (gnus-summary-mark-below score gnus-killed-mark))
7835 (defun gnus-summary-clear-above (score)
7836 "Clear all marks from articles with score above SCORE."
7838 (gnus-summary-mark-above score gnus-unread-mark))
7840 (defun gnus-summary-tick-above (score)
7841 "Tick all articles with score above SCORE."
7843 (gnus-summary-mark-above score gnus-ticked-mark))
7845 (defun gnus-summary-mark-above (score mark)
7846 "Mark articles with score over SCORE with MARK."
7847 (interactive "P\ncMark: ")
7848 (setq score (if score
7849 (prefix-numeric-value score)
7850 (or gnus-summary-default-score 0)))
7852 (set-buffer gnus-summary-buffer)
7853 (goto-char (point-min))
7855 (if (> (gnus-summary-article-score) score)
7857 (gnus-summary-mark-article nil mark)
7859 (forward-line 1)))))
7861 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7862 (defun gnus-summary-show-all-expunged ()
7863 "Display all the hidden articles that were expunged for low scores."
7865 (let ((buffer-read-only nil))
7866 (let ((scored gnus-newsgroup-scored)
7869 (or (gnus-summary-goto-subject (car (car scored)))
7870 (and (setq h (gnus-get-header-by-number (car (car scored))))
7871 (< (cdr (car scored)) gnus-summary-expunge-below)
7872 (setq headers (cons h headers))))
7873 (setq scored (cdr scored)))
7874 (or headers (error "No expunged articles hidden."))
7875 (goto-char (point-min))
7877 (gnus-summary-prepare-threads (nreverse headers) 0)))
7878 (goto-char (point-min))
7879 (gnus-summary-position-cursor)))
7881 (defun gnus-summary-show-all-dormant ()
7882 "Display all the hidden articles that are marked as dormant."
7884 (let ((buffer-read-only nil))
7885 (goto-char (point-min))
7886 (let ((dormant gnus-newsgroup-dormant)
7889 (or (gnus-summary-goto-subject (car dormant))
7890 (and (setq h (gnus-get-header-by-number (car dormant)))
7891 (setq headers (cons h headers))))
7892 (setq dormant (cdr dormant)))
7893 (or headers (error "No dormant articles hidden."))
7894 (save-excursion (gnus-summary-prepare-threads (nreverse headers) 0)))
7895 (goto-char (point-min))
7896 (gnus-summary-position-cursor)))
7898 (defun gnus-summary-hide-all-dormant ()
7899 "Hide all dormant articles."
7901 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
7902 (gnus-summary-position-cursor))
7904 (defun gnus-summary-catchup (all &optional quietly to-here)
7905 "Mark all articles not marked as unread in this newsgroup as read.
7906 If prefix argument ALL is non-nil, all articles are marked as read.
7907 If QUIETLY is non-nil, no questions will be asked.
7908 If TO-HERE is non-nil, it should be a point in the buffer. All
7909 articles before this point will be marked as read.
7910 The number of articles marked as read is returned."
7914 (not gnus-interactive-catchup) ;Without confirmation?
7918 "Mark absolutely all articles as read? "
7919 "Mark all unread articles as read? ")))
7920 (let ((unreads (length gnus-newsgroup-unreads)))
7921 (if (gnus-summary-first-subject (not all))
7922 (while (and (gnus-summary-mark-as-read nil gnus-catchup-mark)
7923 (if to-here (< (point) to-here) t)
7924 (gnus-summary-search-subject nil (not all)))))
7925 (- unreads (length gnus-newsgroup-unreads))))
7926 (setq gnus-newsgroup-unreads gnus-newsgroup-marked)
7927 (gnus-summary-position-cursor)))
7929 (defun gnus-summary-catchup-to-here (&optional all)
7930 "Mark all unticked articles before the current one as read.
7931 If ALL is non-nil, also mark ticked and dormant articles as read."
7934 (gnus-summary-catchup all t (point))
7935 (gnus-summary-position-cursor))
7937 (defun gnus-summary-catchup-all (&optional quietly)
7938 "Mark all articles in this newsgroup as read."
7940 (gnus-summary-catchup t quietly))
7942 (defun gnus-summary-catchup-and-exit (all &optional quietly)
7943 "Mark all articles not marked as unread in this newsgroup as read, then exit.
7944 If prefix argument ALL is non-nil, all articles are marked as read."
7946 (gnus-summary-catchup all quietly)
7947 ;; Select next newsgroup or exit.
7948 (if (eq gnus-auto-select-next 'quietly)
7949 (gnus-summary-next-group nil)
7950 (gnus-summary-exit)))
7952 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
7953 "Mark all articles in this newsgroup as read, and then exit."
7955 (gnus-summary-catchup-and-exit t quietly))
7957 ;; Thread-based commands.
7959 (defun gnus-summary-toggle-threads (arg)
7960 "Toggle showing conversation threads.
7961 If ARG is positive number, turn showing conversation threads on."
7963 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
7964 (setq gnus-show-threads
7965 (if (null arg) (not gnus-show-threads)
7966 (> (prefix-numeric-value arg) 0)))
7967 (gnus-summary-prepare)
7968 (gnus-summary-goto-subject current)
7969 (gnus-summary-position-cursor)))
7971 (defun gnus-summary-show-all-threads ()
7975 (let ((buffer-read-only nil))
7976 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
7977 (gnus-summary-position-cursor))
7979 (defun gnus-summary-show-thread ()
7980 "Show thread subtrees.
7981 Returns nil if no thread was there to be shown."
7985 (let ((buffer-read-only nil)
7986 (beg (progn (beginning-of-line) (point)))
7987 (end (save-excursion (end-of-line) (point))))
7989 ;; Any hidden lines here?
7990 (search-forward "\r" end t)
7991 (subst-char-in-region beg end ?\^M ?\n t))))
7992 (gnus-summary-position-cursor)))
7994 (defun gnus-summary-hide-all-threads ()
7995 "Hide all thread subtrees."
7998 (goto-char (point-min))
7999 (gnus-summary-hide-thread)
8000 (while (and (not (eobp)) (zerop (forward-line 1)))
8001 (gnus-summary-hide-thread)))
8002 (gnus-summary-position-cursor))
8004 (defun gnus-summary-hide-thread ()
8005 "Hide thread subtrees.
8006 Returns nil if no threads were there to be hidden."
8008 (let ((buffer-read-only nil)
8010 (level (gnus-summary-thread-level))
8012 ;; Go forward until either the buffer ends or the subthread
8016 (while (and (zerop (forward-line 1))
8017 (> (gnus-summary-thread-level) level))
8022 (search-backward "\n" start t))
8023 (subst-char-in-region start end ?\n ?\^M t)
8024 (forward-line -1)))))
8026 (defun gnus-summary-go-to-next-thread (&optional previous)
8027 "Go to the same level (or less) next thread.
8028 If PREVIOUS is non-nil, go to previous thread instead.
8029 Return the article number moved to, or nil if moving was impossible."
8030 (let ((level (gnus-summary-thread-level))
8031 (article (gnus-summary-article-number)))
8033 (while (and (zerop (gnus-summary-prev-subject 1))
8034 (> (gnus-summary-thread-level) level)))
8035 (while (and (zerop (gnus-summary-next-subject 1))
8036 (> (gnus-summary-thread-level) level))))
8037 (let ((oart (gnus-summary-article-number)))
8038 (and (/= oart article) oart))))
8040 (defun gnus-summary-next-thread (n)
8041 "Go to the same level next N'th thread.
8042 If N is negative, search backward instead.
8043 Returns the difference between N and the number of skips actually
8046 (let ((backward (< n 0))
8049 (gnus-summary-go-to-next-thread backward))
8051 (gnus-summary-position-cursor)
8052 (if (/= 0 n) (message "No more threads"))
8055 (defun gnus-summary-prev-thread (n)
8056 "Go to the same level previous N'th thread.
8057 Returns the difference between N and the number of skips actually
8060 (gnus-summary-next-thread (- n)))
8062 (defun gnus-summary-go-down-thread (&optional same)
8063 "Go down one level in the current thread.
8064 If SAME is non-nil, also move to articles of the same level."
8065 (let ((level (gnus-summary-thread-level))
8067 (if (and (zerop (forward-line 1))
8068 (> (gnus-summary-thread-level) level))
8073 (defun gnus-summary-go-up-thread ()
8074 "Go up one level in the current thread."
8075 (let ((level (gnus-summary-thread-level))
8077 (while (and (zerop (forward-line -1))
8078 (>= (gnus-summary-thread-level) level)))
8079 (if (>= (gnus-summary-thread-level) level)
8085 (defun gnus-summary-down-thread (n)
8086 "Go down thread N steps.
8087 If N is negative, go up instead.
8088 Returns the difference between N and how many steps down that were
8094 (if up (gnus-summary-go-up-thread)
8095 (gnus-summary-go-down-thread)))
8097 (gnus-summary-position-cursor)
8098 (if (/= 0 n) (message "Can't go further"))
8101 (defun gnus-summary-up-thread (n)
8102 "Go up thread N steps.
8103 If N is negative, go up instead.
8104 Returns the difference between N and how many steps down that were
8107 (gnus-summary-down-thread (- n)))
8109 (defun gnus-summary-kill-thread (unmark)
8110 "Mark articles under current thread as read.
8111 If the prefix argument is positive, remove any kinds of marks.
8112 If the prefix argument is negative, tick articles instead."
8115 (setq unmark (prefix-numeric-value unmark)))
8117 (level (gnus-summary-thread-level)))
8120 ;; Mark the article...
8121 (cond ((null unmark) (gnus-summary-mark-as-read nil gnus-killed-mark))
8122 ((> unmark 0) (gnus-summary-tick-article nil t))
8123 (t (gnus-summary-tick-article)))
8124 ;; ...and go forward until either the buffer ends or the subtree
8126 (if (not (and (zerop (forward-line 1))
8127 (> (gnus-summary-thread-level) level)))
8128 (setq killing nil))))
8129 ;; Hide killed subtrees.
8131 gnus-thread-hide-killed
8132 (gnus-summary-hide-thread))
8133 ;; If marked as read, go to next unread subject.
8135 ;; Go to next unread subject.
8136 (gnus-summary-next-subject 1 t)))
8137 (gnus-set-mode-line 'summary))
8139 ;; Summary sorting commands
8141 (defun gnus-summary-sort-by-number (reverse)
8142 "Sort summary buffer by article number.
8143 Argument REVERSE means reverse order."
8146 (cons 'gnus-summary-article-number 'gnus-thread-sort-by-number) reverse))
8148 (defun gnus-summary-sort-by-author (reverse)
8149 "Sort summary buffer by author name alphabetically.
8150 If case-fold-search is non-nil, case of letters is ignored.
8151 Argument REVERSE means reverse order."
8156 (let ((extract (funcall
8157 gnus-extract-address-components
8158 (header-from (gnus-get-header-by-number
8159 (gnus-summary-article-number))))))
8160 (or (car extract) (cdr extract))))
8161 'gnus-thread-sort-by-author)
8164 (defun gnus-summary-sort-by-subject (reverse)
8165 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
8166 If case-fold-search is non-nil, case of letters is ignored.
8167 Argument REVERSE means reverse order."
8172 (downcase (gnus-simplify-subject (gnus-summary-subject-string))))
8173 'gnus-thread-sort-by-subject)
8176 (defun gnus-summary-sort-by-date (reverse)
8177 "Sort summary buffer by date.
8178 Argument REVERSE means reverse order."
8185 (gnus-get-header-by-number (gnus-summary-article-number)))))
8186 'gnus-thread-sort-by-date)
8189 (defun gnus-summary-sort-by-score (reverse)
8190 "Sort summary buffer by score.
8191 Argument REVERSE means reverse order."
8194 (cons 'gnus-summary-article-score 'gnus-thread-sort-by-score)
8197 (defun gnus-summary-sort (predicate reverse)
8198 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
8199 (let (buffer-read-only)
8200 (if (not gnus-show-threads)
8202 (goto-char (point-min))
8203 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
8204 (let ((gnus-thread-sort-functions (list (cdr predicate))))
8205 (gnus-summary-prepare)))))
8207 (defun gnus-sortable-date (date)
8208 "Make sortable string by string-lessp from DATE.
8209 Timezone package is used."
8210 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
8211 (year (aref date 0))
8212 (month (aref date 1))
8213 (day (aref date 2)))
8214 (timezone-make-sortable-date
8216 (timezone-make-time-string
8217 (aref date 3) (aref date 4) (aref date 5)))))
8220 ;; Summary saving commands.
8222 (defun gnus-summary-save-article (n)
8223 "Save the current article using the default saver function.
8224 If N is a positive number, save the N next articles.
8225 If N is a negative number, save the N previous articles.
8226 If N is nil and any articles have been marked with the process mark,
8227 save those articles instead.
8228 The variable `gnus-default-article-saver' specifies the saver function."
8230 (let (articles process)
8231 (if (and n (numberp n))
8232 (let ((backward (< n 0))
8236 (setq articles (cons (gnus-summary-article-number)
8238 (gnus-summary-search-forward nil nil backward))
8240 (setq articles (sort articles (function <))))
8241 (if gnus-newsgroup-processable
8243 (setq articles (setq gnus-newsgroup-processable
8244 (nreverse gnus-newsgroup-processable)))
8246 (setq articles (list (gnus-summary-article-number)))))
8248 (let ((header (gnus-gethash (int-to-string (car articles))
8249 gnus-newsgroup-headers-hashtb-by-number)))
8250 (if (vectorp header)
8252 (gnus-summary-display-article (car articles) t)
8253 (if (not gnus-save-all-headers)
8254 (gnus-article-hide-headers t))
8255 (if gnus-default-article-saver
8256 (funcall gnus-default-article-saver)
8257 (error "No default saver is defined.")))
8258 (if (assq 'name header)
8259 (gnus-copy-file (cdr (assq 'name header)))
8260 (message "Article %d is unsaveable" (car articles)))))
8262 (gnus-summary-remove-process-mark (car articles)))
8263 (setq articles (cdr articles)))
8264 (if process (setq gnus-newsgroup-processable
8265 (nreverse gnus-newsgroup-processable)))
8266 (gnus-summary-position-cursor)
8269 (defun gnus-summary-pipe-output (arg)
8270 "Pipe the current article to a subprocess.
8271 If N is a positive number, pipe the N next articles.
8272 If N is a negative number, pipe the N previous articles.
8273 If N is nil and any articles have been marked with the process mark,
8274 pipe those articles instead."
8276 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8277 (gnus-summary-save-article arg)))
8279 (defun gnus-summary-save-article-mail (arg)
8280 "Append the current article to an mail file.
8281 If N is a positive number, save the N next articles.
8282 If N is a negative number, save the N previous articles.
8283 If N is nil and any articles have been marked with the process mark,
8284 save those articles instead."
8286 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8287 (gnus-summary-save-article arg)))
8289 (defun gnus-summary-save-article-rmail (arg)
8290 "Append the current article to an rmail file.
8291 If N is a positive number, save the N next articles.
8292 If N is a negative number, save the N previous articles.
8293 If N is nil and any articles have been marked with the process mark,
8294 save those articles instead."
8296 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8297 (gnus-summary-save-article arg)))
8299 (defun gnus-summary-save-article-file (arg)
8300 "Append the current article to a file.
8301 If N is a positive number, save the N next articles.
8302 If N is a negative number, save the N previous articles.
8303 If N is nil and any articles have been marked with the process mark,
8304 save those articles instead."
8306 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8307 (gnus-summary-save-article arg)))
8309 (defun gnus-summary-save-article-folder (arg)
8310 "Append the current article to an mh folder.
8311 If N is a positive number, save the N next articles.
8312 If N is a negative number, save the N previous articles.
8313 If N is nil and any articles have been marked with the process mark,
8314 save those articles instead."
8316 (let ((gnus-default-article-saver 'gnus-summary-save-in-folder))
8317 (gnus-summary-save-article arg)))
8319 (defun gnus-summary-save-in-rmail (&optional filename)
8320 "Append this article to Rmail file.
8321 Optional argument FILENAME specifies file name.
8322 Directory to save to is default to `gnus-article-save-directory' which
8323 is initialized from the SAVEDIR environment variable."
8326 (funcall gnus-rmail-save-name gnus-newsgroup-name
8327 gnus-current-headers gnus-newsgroup-last-rmail)))
8331 (concat "Save article in rmail file: (default "
8332 (file-name-nondirectory default-name) ") ")
8333 (file-name-directory default-name)
8335 (gnus-make-directory (file-name-directory filename))
8336 (gnus-eval-in-buffer-window
8341 (gnus-output-to-rmail filename))))
8342 ;; Remember the directory name to save articles.
8343 (setq gnus-newsgroup-last-rmail filename)))
8345 (defun gnus-summary-save-in-mail (&optional filename)
8346 "Append this article to Unix mail file.
8347 Optional argument FILENAME specifies file name.
8348 Directory to save to is default to `gnus-article-save-directory' which
8349 is initialized from the SAVEDIR environment variable."
8352 (funcall gnus-mail-save-name gnus-newsgroup-name
8353 gnus-current-headers gnus-newsgroup-last-mail)))
8357 (concat "Save article in Unix mail file: (default "
8358 (file-name-nondirectory default-name) ") ")
8359 (file-name-directory default-name)
8362 (expand-file-name filename
8364 (file-name-directory default-name))))
8365 (gnus-make-directory (file-name-directory filename))
8366 (gnus-eval-in-buffer-window
8371 (if (and (file-readable-p filename) (rmail-file-p filename))
8372 (gnus-output-to-rmail filename)
8373 (rmail-output filename 1 t t)))))
8374 ;; Remember the directory name to save articles.
8375 (setq gnus-newsgroup-last-mail filename)))
8377 (defun gnus-summary-save-in-file (&optional filename)
8378 "Append this article to file.
8379 Optional argument FILENAME specifies file name.
8380 Directory to save to is default to `gnus-article-save-directory' which
8381 is initialized from the SAVEDIR environment variable."
8384 (funcall gnus-file-save-name gnus-newsgroup-name
8385 gnus-current-headers gnus-newsgroup-last-file)))
8389 (concat "Save article in file: (default "
8390 (file-name-nondirectory default-name) ") ")
8391 (file-name-directory default-name)
8393 (gnus-make-directory (file-name-directory filename))
8394 (gnus-eval-in-buffer-window
8399 (gnus-output-to-file filename))))
8400 ;; Remember the directory name to save articles.
8401 (setq gnus-newsgroup-last-file filename)))
8403 (defun gnus-summary-save-in-pipe (&optional command)
8404 "Pipe this article to subprocess."
8406 (let ((command (read-string "Shell command on article: "
8407 gnus-last-shell-command)))
8408 (if (string-equal command "")
8409 (setq command gnus-last-shell-command))
8410 (gnus-eval-in-buffer-window
8414 (shell-command-on-region (point-min) (point-max) command nil)))
8415 (setq gnus-last-shell-command command)))
8417 ;; Summary extract commands
8419 (defun gnus-summary-insert-pseudos (pslist)
8420 (let ((buffer-read-only nil)
8421 (article (gnus-summary-article-number))
8423 (or (gnus-summary-goto-subject article)
8424 (error (format "No such article: %d" article)))
8425 (gnus-summary-position-cursor)
8426 (if gnus-view-pseudos
8428 (and (assq 'execute (car pslist))
8429 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8430 (eq gnus-view-pseudos 'not-confirm)))
8431 (setq pslist (cdr pslist)))
8434 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
8435 (gnus-summary-article-number)))
8438 (insert " " (file-name-nondirectory
8439 (cdr (assq 'name (car pslist))))
8440 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8441 (add-text-properties
8442 b (1+ b) (list 'gnus-subject (cdr (assq 'name (car pslist)))
8443 'gnus-number gnus-reffed-article-number
8444 'gnus-mark gnus-unread-mark
8445 'gnus-pseudo (car pslist)
8447 (gnus-sethash (int-to-string gnus-reffed-article-number)
8448 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
8449 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8450 (setq pslist (cdr pslist)))))))
8452 (defun gnus-request-pseudo-article (props)
8453 (cond ((assq 'execute props)
8454 (gnus-execute-command (cdr (assq 'execute props)))))
8455 (let ((gnus-current-article (gnus-summary-article-number)))
8456 (run-hooks 'gnus-mark-article-hook)))
8458 (defun gnus-execute-command (command &optional automatic)
8460 (gnus-article-setup-buffer)
8461 (set-buffer gnus-article-buffer)
8462 (let ((command (if automatic command (read-string "Command: " command)))
8463 (buffer-read-only nil))
8465 (insert "$ " command "\n\n")
8466 (if gnus-view-pseudo-asynchronously
8467 (start-process "gnus-execute" nil "sh" "-c" command)
8468 (call-process "sh" nil t nil "-c" command)))))
8470 (defun gnus-copy-file (file &optional to)
8473 (list (read-file-name "Copy file: " default-directory)
8474 (read-file-name "Copy file to: " default-directory)))
8475 (or to (setq to (read-file-name "Copy file to: " default-directory)))
8476 (and (file-directory-p to)
8477 (setq to (concat (file-name-as-directory to)
8478 (file-name-nondirectory file))))
8479 (copy-file file to))
8481 ;; Summary score file commands
8483 ;; Much modification of the kill (ahem, score) code and lots of the
8484 ;; functions are written by Per Abrahamsen <amanda@iesd.auc.dk>.
8486 (defun gnus-summary-header (header)
8487 ;; Return HEADER for current articles, or error.
8488 (let ((article (gnus-summary-article-number)))
8490 (aref (gnus-get-header-by-number article)
8491 (nth 1 (assoc header gnus-header-index)))
8492 (error "No article on current line"))))
8494 (defun gnus-summary-score-entry (header match type score date &optional prompt)
8495 "Enter score file entry.
8496 HEADER is the header being scored.
8497 MATCH is the string we are looking for.
8498 TYPE is a flag indicating if it is a regexp or substring.
8499 SCORE is the score to add.
8500 DATE is the expire date."
8502 (list (completing-read "Header: "
8504 (lambda (x) (fboundp (nth 2 x)))
8506 (read-string "Match: ")
8507 (y-or-n-p "Use regexp match? ")
8508 (prefix-numeric-value current-prefix-arg)
8509 (if (y-or-n-p "Expire kill? ")
8510 (current-time-string)
8512 (and prompt (setq match (read-string "Match: " match)))
8513 (let ((score (gnus-score-default score)))
8514 (gnus-summary-score-effect header match type score)
8515 (and (= score gnus-score-interactive-default-score)
8517 (let ((new (cond (type
8518 (list match score (and date (gnus-day-number date)) type))
8520 (list match score (gnus-day-number date)))
8525 (old (gnus-score-get header)))
8528 (if old (cons new old) (list new))))
8529 (gnus-score-set 'touched '(t))))
8531 (defun gnus-summary-score-effect (header match type score)
8532 "Simulate the effect of a score file entry.
8533 HEADER is the header being scored.
8534 MATCH is the string we are looking for.
8535 TYPE is a flag indicating if it is a regexp or substring.
8536 SCORE is the score to add."
8537 (interactive (list (completing-read "Header: "
8539 (lambda (x) (fboundp (nth 2 x)))
8541 (read-string "Match: ")
8542 (y-or-n-p "Use regexp match? ")
8543 (prefix-numeric-value current-prefix-arg)))
8545 (or (and (stringp match) (> (length match) 0))
8547 (goto-char (point-min))
8548 (let ((regexp (if type
8550 (concat "\\`.*" (regexp-quote match) ".*\\'"))))
8552 (let ((content (gnus-summary-header header))
8553 (case-fold-search t))
8555 (if (string-match regexp content)
8556 (gnus-summary-raise-score score))))
8557 (beginning-of-line 2)))))
8559 (defun gnus-summary-score-crossposting (score date)
8560 ;; Enter score file entry for current crossposting.
8561 ;; SCORE is the score to add.
8562 ;; DATE is the expire date.
8563 (let ((xref (gnus-summary-header "xref"))
8566 (or xref (error "This article is not crossposted"))
8567 (while (string-match " \\([^ \t]+\\):" xref start)
8568 (setq start (match-end 0))
8571 (substring xref (match-beginning 1) (match-end 1)))
8572 gnus-newsgroup-name))
8573 (gnus-summary-score-entry
8574 "xref" (concat " " group ":") nil score date t)))))
8576 (defun gnus-summary-temporarily-lower-by-subject (level)
8577 "Temporarily lower score by LEVEL for current subject.
8578 See `gnus-score-expiry-days'."
8580 (gnus-summary-score-entry
8581 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
8582 nil (- (gnus-score-default level))
8583 (current-time-string) t))
8585 (defun gnus-summary-temporarily-lower-by-author (level)
8586 "Temporarily lower score by LEVEL for current author.
8587 See `gnus-score-expiry-days'."
8589 (gnus-summary-score-entry
8590 "from" (gnus-summary-header "from") nil (- (gnus-score-default level))
8591 (current-time-string) t))
8593 (defun gnus-summary-temporarily-lower-by-id (level)
8594 "Temporarily lower score by LEVEL for current message-id.
8595 See `gnus-score-expiry-days'."
8597 (gnus-summary-score-entry
8598 "message-id" (gnus-summary-header "message-id")
8599 nil (- (gnus-score-default level))
8600 (current-time-string)))
8602 (defun gnus-summary-temporarily-lower-by-xref (level)
8603 "Temporarily lower score by LEVEL for current xref.
8604 See `gnus-score-expiry-days'."
8606 (gnus-summary-score-crossposting
8607 (- (gnus-score-default level)) (current-time-string)))
8609 (defun gnus-summary-temporarily-lower-by-thread (level)
8610 "Temporarily lower score by LEVEL for current thread.
8611 See `gnus-score-expiry-days'."
8613 (gnus-summary-score-entry
8614 "references" (gnus-summary-header "message-id")
8615 nil (- (gnus-score-default level)) (current-time-string)))
8617 (defun gnus-summary-lower-by-subject (level)
8618 "Lower score by LEVEL for current subject."
8620 (gnus-summary-score-entry
8621 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
8622 nil (- (gnus-score-default level))
8625 (defun gnus-summary-lower-by-author (level)
8626 "Lower score by LEVEL for current author."
8628 (gnus-summary-score-entry
8629 "from" (gnus-summary-header "from") nil
8630 (- (gnus-score-default level)) nil t))
8632 (defun gnus-summary-lower-by-id (level)
8633 "Lower score by LEVEL for current message-id."
8635 (gnus-summary-score-entry
8636 "message-id" (gnus-summary-header "message-id") nil
8637 (- (gnus-score-default level)) nil))
8639 (defun gnus-summary-lower-by-xref (level)
8640 "Lower score by LEVEL for current xref."
8642 (gnus-summary-score-crossposting (- (gnus-score-default level)) nil))
8644 (defun gnus-summary-lower-followups-to-author (level)
8645 "Lower score by LEVEL for all followups to the current author."
8647 (gnus-summary-raise-followups-to-author
8648 (- (gnus-score-default level))))
8650 (defun gnus-summary-temporarily-raise-by-subject (level)
8651 "Temporarily raise score by LEVEL for current subject.
8652 See `gnus-score-expiry-days'."
8654 (gnus-summary-score-entry
8655 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
8656 nil level (current-time-string) t))
8658 (defun gnus-summary-temporarily-raise-by-author (level)
8659 "Temporarily raise score by LEVEL for current author.
8660 See `gnus-score-expiry-days'."
8662 (gnus-summary-score-entry
8663 "from" (gnus-summary-header "from") nil level (current-time-string) t))
8665 (defun gnus-summary-temporarily-raise-by-id (level)
8666 "Temporarily raise score by LEVEL for current message-id.
8667 See `gnus-score-expiry-days'."
8669 (gnus-summary-score-entry
8670 "message-id" (gnus-summary-header "message-id")
8671 nil level (current-time-string)))
8673 (defun gnus-summary-temporarily-raise-by-xref (level)
8674 "Temporarily raise score by LEVEL for current xref.
8675 See `gnus-score-expiry-days'."
8677 (gnus-summary-score-crossposting level (current-time-string)))
8679 (defun gnus-summary-temporarily-raise-by-thread (level)
8680 "Temporarily raise score by LEVEL for current thread.
8681 See `gnus-score-expiry-days'."
8683 (gnus-summary-score-entry
8684 "references" (gnus-summary-header "message-id")
8685 nil level (current-time-string)))
8687 (defun gnus-summary-raise-by-subject (level)
8688 "Raise score by LEVEL for current subject."
8690 (gnus-summary-score-entry
8691 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
8694 (defun gnus-summary-raise-by-author (level)
8695 "Raise score by LEVEL for current author."
8697 (gnus-summary-score-entry
8698 "from" (gnus-summary-header "from") nil level nil t))
8700 (defun gnus-summary-raise-by-id (level)
8701 "Raise score by LEVEL for current message-id."
8703 (gnus-summary-score-entry
8704 "message-id" (gnus-summary-header "message-id") nil level nil))
8706 (defun gnus-summary-raise-by-xref (level)
8707 "Raise score by LEVEL for current xref."
8709 (gnus-summary-score-crossposting level nil))
8711 (defun gnus-summary-raise-followups-to-author (level)
8712 "Raise score by LEVEL for all followups to the current author."
8714 (let ((article (gnus-summary-article-number)))
8715 (if article (setq gnus-current-headers (gnus-get-header-by-number article))
8716 (error "No article on current line")))
8717 (gnus-kill-file-raise-followups-to-author
8718 (gnus-score-default level)))
8720 ;; Summary kill commands.
8722 (defun gnus-summary-edit-global-kill (article)
8723 "Edit the global score file."
8724 (interactive (list (gnus-summary-article-number)))
8725 (gnus-group-edit-global-kill article))
8727 (defun gnus-summary-edit-local-kill ()
8728 "Edit a local score file applied to the current newsgroup."
8730 (setq gnus-current-headers
8732 (int-to-string (gnus-summary-article-number))
8733 gnus-newsgroup-headers-hashtb-by-number))
8734 (gnus-set-global-variables)
8735 (gnus-group-edit-local-kill
8736 (gnus-summary-article-number) gnus-newsgroup-name))
8740 ;;; Gnus article mode
8743 (if gnus-article-mode-map
8745 (setq gnus-article-mode-map (make-keymap))
8746 (suppress-keymap gnus-article-mode-map)
8747 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
8748 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
8749 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
8750 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
8751 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
8752 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
8753 (define-key gnus-article-mode-map "\C-c\C-M" 'gnus-article-mail-with-original)
8754 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
8756 ;; Duplicate almost all summary keystrokes in the article mode map.
8758 (list "#" "\M-#" "\C-c\M-#" "\r" "n" "p"
8759 "N" "P" "\M-\C-n" "\M-\C-p" "." "\M-s" "\M-r"
8760 "<" ">" "l" "j" "^" "\M-^" "-" "u" "U" "d" "D"
8761 "\M-u" "\M-U" "k" "\C-k" "\M-\C-k" "c" "x" "X"
8762 "\M-\C-x" "\M-\177" "b" "B" "$" "w" "\C-c\C-r"
8763 "t" "\M-t" "a" "f" "F" "C" "S" "r" "R" "\C-c\C-f"
8764 "m" "o" "\C-o" "|" "\M-m" "\M-\C-m" "\M-k" "m" "M"
8765 "V" "\C-c\C-d" "q" "Q")))
8767 (define-key gnus-article-mode-map (car commands)
8768 'gnus-article-summary-command)
8769 (setq commands (cdr commands)))))
8772 (defun gnus-article-mode ()
8773 "Major mode for displaying an article.
8775 All normal editing commands are switched off.
8777 The following commands are available:
8779 \\<gnus-article-mode-map>
8780 \\[gnus-article-next-page]\t Scroll the article one page forwards
8781 \\[gnus-article-prev-page]\t Scroll the article one page backwards
8782 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
8783 \\[gnus-article-show-summary]\t Display the summary buffer
8784 \\[gnus-article-mail]\t Send a reply to the address near point
8785 \\[gnus-article-mail-with-original]\t Send a reply to the address near point; include the original article
8786 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
8787 \\[gnus-info-find-node]\t Go to the Gnus info node"
8789 (if gnus-visual (gnus-article-make-menu-bar))
8790 (kill-all-local-variables)
8791 (setq mode-line-modified "-- ")
8792 (make-local-variable 'mode-line-format)
8793 (setq mode-line-format (copy-sequence mode-line-format))
8794 (and (equal (nth 3 mode-line-format) " ")
8795 (setcar (nthcdr 3 mode-line-format) ""))
8796 (setq mode-name "Article")
8797 (setq major-mode 'gnus-article-mode)
8798 (make-local-variable 'minor-mode-alist)
8799 (or (assq 'gnus-show-mime minor-mode-alist)
8800 (setq minor-mode-alist
8801 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
8802 (use-local-map gnus-article-mode-map)
8803 (make-local-variable 'page-delimiter)
8804 (setq page-delimiter gnus-page-delimiter)
8805 (buffer-disable-undo (current-buffer))
8806 (setq buffer-read-only t) ;Disable modification
8807 (run-hooks 'gnus-article-mode-hook))
8809 (defun gnus-article-setup-buffer ()
8810 "Initialize article mode buffer."
8811 (or (get-buffer gnus-article-buffer)
8813 (set-buffer (get-buffer-create gnus-article-buffer))
8814 (gnus-add-current-to-buffer-list)
8815 (gnus-article-mode))))
8817 (defun gnus-request-article-this-buffer (article &optional group)
8818 "Get an article and insert it into this buffer."
8819 (setq group (or group gnus-newsgroup-name))
8820 ;; Using `gnus-request-article' directly will insert the article into
8821 ;; `nntp-server-buffer' - so we'll save some time by not having to
8822 ;; copy it from the server buffer into the article buffer.
8824 ;; We only request an article by message-id when we do not have the
8825 ;; headers for it, so we'll have to get those.
8826 (and (stringp article)
8827 (let ((gnus-override-method gnus-refer-article-method))
8828 (gnus-read-header article)))
8830 ;; If the article number is negative, that means that this article
8831 ;; doesn't belong in this newsgroup (possibly), so we find its
8832 ;; message-id and request it by id instead of number.
8833 (if (and (numberp article) (< article 0))
8835 (set-buffer gnus-summary-buffer)
8836 (let ((header (gnus-gethash (int-to-string article)
8837 gnus-newsgroup-headers-hashtb-by-number)))
8838 (if (vectorp header)
8839 ;; It's a real article.
8840 (setq article (header-id header))
8841 ;; It is an extracted pseudo-article.
8843 (gnus-request-pseudo-article header)))))
8844 ;; Get the article and into the article buffer.
8848 (let ((gnus-override-method
8849 (and (stringp article) gnus-refer-article-method)))
8850 (and (gnus-request-article article group (current-buffer))
8854 (defun gnus-read-header (id)
8855 "Read the headers of article ID and enter them into the Gnus system."
8856 (or gnus-newsgroup-headers-hashtb-by-number
8857 (gnus-make-headers-hashtable-by-number))
8859 (if (not (setq header
8860 (car (if (let ((gnus-nov-is-evil t))
8861 (gnus-retrieve-headers
8862 (list id) gnus-newsgroup-name))
8863 (gnus-get-newsgroup-headers)))))
8866 (header-set-number header gnus-reffed-article-number))
8867 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
8868 (gnus-sethash (int-to-string (header-number header)) header
8869 gnus-newsgroup-headers-hashtb-by-number)
8871 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
8872 (setq gnus-current-headers header)
8875 (defun gnus-article-prepare (article &optional all-headers header)
8876 "Prepare ARTICLE in article mode buffer.
8877 ARTICLE should either be an article number or a Message-ID.
8878 If ARTICLE is an id, HEADER should be the article headers.
8879 If ALL-HEADERS is non-nil, no headers are hidden."
8881 ;; Make sure we start in a summary buffer.
8882 (or (eq major-mode 'gnus-summary-mode)
8883 (set-buffer gnus-summary-buffer))
8884 (setq gnus-summary-buffer (current-buffer))
8885 ;; Make sure the connection to the server is alive.
8886 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
8888 (gnus-check-news-server
8889 (gnus-find-method-for-group gnus-newsgroup-name))
8890 (gnus-request-group gnus-newsgroup-name t)))
8891 (or gnus-newsgroup-headers-hashtb-by-number
8892 (gnus-make-headers-hashtable-by-number))
8893 (let* ((article (if header (header-number header) article))
8894 (summary-buffer (current-buffer))
8895 (internal-hook gnus-article-internal-prepare-hook)
8896 (bookmark (cdr (assq article gnus-newsgroup-bookmarks)))
8897 (group gnus-newsgroup-name)
8900 (gnus-article-setup-buffer)
8901 (set-buffer gnus-article-buffer)
8902 (let ((buffer-read-only nil))
8903 (if (not (setq result (gnus-request-article-this-buffer
8905 ;; There is no such article.
8908 (set-buffer gnus-summary-buffer)
8909 (setq gnus-current-article 0)
8910 (and (numberp article)
8911 (gnus-summary-mark-as-read article gnus-canceled-mark))
8912 (message "No such article (may be canceled)")
8914 (setq gnus-article-current nil)
8916 (if (not (eq result 'article))
8919 (set-buffer summary-buffer)
8920 (setq gnus-last-article gnus-current-article
8921 gnus-newsgroup-history (cons gnus-current-article
8922 gnus-newsgroup-history)
8923 gnus-current-article 0
8924 gnus-current-headers nil
8925 gnus-article-current nil)
8926 (gnus-configure-windows 'article)
8927 (gnus-set-global-variables))
8928 (gnus-set-mode-line 'article))
8929 ;; The result from the `request' was an actual article -
8930 ;; or at least some text that is now displayed in the
8932 (if (and (numberp article)
8933 (not (eq article gnus-current-article)))
8934 ;; Seems like a new article has been selected.
8935 ;; `gnus-current-article' must be an article number.
8937 (set-buffer summary-buffer)
8938 (setq gnus-last-article gnus-current-article
8939 gnus-newsgroup-history (cons gnus-current-article
8940 gnus-newsgroup-history)
8941 gnus-current-article article
8942 gnus-current-headers
8943 (gnus-get-header-by-number gnus-current-article)
8944 gnus-article-current
8945 (cons gnus-newsgroup-name gnus-current-article))
8946 (run-hooks 'gnus-mark-article-hook)
8947 (gnus-set-mode-line 'summary)
8949 (run-hooks 'gnus-visual-mark-article-hook))
8950 ;; Set the global newsgroup variables here.
8951 ;; Suggested by Jim Sisolak
8952 ;; <sisolak@trans4.neep.wisc.edu>.
8953 (gnus-set-global-variables)))
8954 ;; gnus-have-all-headers must be either T or NIL.
8955 (setq gnus-have-all-headers
8956 (not (not (or all-headers gnus-show-all-headers))))
8957 ;; Hooks for getting information from the article.
8958 ;; This hook must be called before being narrowed.
8959 (run-hooks 'internal-hook)
8960 (run-hooks 'gnus-article-prepare-hook)
8961 ;; Decode MIME message.
8962 (if (and gnus-show-mime
8963 (gnus-fetch-field "Mime-Version"))
8964 (funcall gnus-show-mime-method))
8965 ;; Perform the article display hooks.
8966 (let ((buffer-read-only nil))
8967 (run-hooks 'gnus-article-display-hook))
8969 (goto-char (point-min))
8970 (and gnus-break-pages (gnus-narrow-to-page))
8971 (gnus-set-mode-line 'article)
8972 (gnus-configure-windows 'article)
8975 (get-buffer-window gnus-article-buffer) (point-min))
8978 (message "Moved to bookmark")
8979 (search-forward "\n\n" nil t)
8980 (forward-line bookmark)))
8983 (defun gnus-article-show-all-headers ()
8984 "Show all article headers in article mode buffer."
8986 (setq gnus-have-all-headers t)
8987 (gnus-article-setup-buffer)
8988 (set-buffer gnus-article-buffer)
8989 (let ((buffer-read-only nil))
8990 (remove-text-properties 1 (point-max) '(invisible t)))))
8992 (defun gnus-article-hide-headers-if-wanted ()
8993 "Hide unwanted headers if `gnus-have-all-headers' is nil.
8994 Provided for backwards compatability."
8995 (or gnus-have-all-headers
8996 (gnus-article-hide-headers)))
8998 (defun gnus-article-hide-headers (&optional delete)
8999 "Hide unwanted headers and possibly sort them as well."
9002 (set-buffer gnus-article-buffer)
9004 (let ((sorted gnus-sorted-header-list)
9005 (buffer-read-only nil)
9006 want want-list beg want-l)
9007 ;; First we narrow to just the headers.
9010 ;; Hide any "From " lines at the beginning of (mail) articles.
9011 (while (looking-at rmail-unix-mail-delimiter)
9014 (add-text-properties 1 (point) '(invisible t)))
9015 ;; Then treat the rest of the header lines.
9018 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
9019 ;; Then we use the two regular expressions
9020 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
9021 ;; select which header lines is to remain visible in the
9024 (while (re-search-forward "^[^ \t]*:" nil t)
9026 ;; We add the headers we want to keep to a list and delete
9027 ;; them from the buffer.
9028 (if (or (and (stringp gnus-visible-headers)
9029 (looking-at gnus-visible-headers))
9030 (and (not (stringp gnus-visible-headers))
9031 (stringp gnus-ignored-headers)
9032 (not (looking-at gnus-ignored-headers))))
9036 ;; Be sure to get multi-line headers...
9037 (re-search-forward "^[^ \t]*:" nil t)
9040 (cons (buffer-substring beg (point)) want-list))
9041 (delete-region beg (point))
9044 ;; Next we perform the sorting by looking at
9045 ;; `gnus-sorted-header-list'.
9047 (while (and sorted want-list)
9048 (setq want-l want-list)
9050 (not (string-match (car sorted) (car want-l))))
9051 (setq want-l (cdr want-l)))
9054 (insert (car want-l))
9055 (setq want-list (delq (car want-l) want-list))))
9056 (setq sorted (cdr sorted)))
9057 ;; Any headers that were not matched by the sorted list we
9058 ;; just tack on the end of the visible header list.
9060 (insert (car want-list))
9061 (setq want-list (cdr want-list)))
9062 ;; And finally we make the unwanted headers invisible.
9064 (delete-region (point) (point-max))
9065 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
9066 (add-text-properties (point) (point-max) '(invisible t)))))))
9068 (defun gnus-article-hide-signature ()
9069 "Hides the signature in an article.
9070 It does this by hiding everyting after \"^-- *$\", which is what all
9071 signatures should be preceded by. Note that this may mean that parts
9072 of an article may disappear if the article has such a line in the
9073 middle of the text."
9076 (set-buffer gnus-article-buffer)
9077 (let ((buffer-read-only nil))
9078 (goto-char (point-max))
9079 (if (re-search-backward "^-- *$" nil t)
9081 (add-text-properties (point) (point-max) '(invisible t)))))))
9083 (defun gnus-article-hide-citation ()
9084 "Hide all cited text.
9085 This function uses the famous, extremely intelligent \"shoot in foot\"
9086 algorithm - which is simply deleting all lines that start with
9087 \">\". Your mileage may vary. If you come up with anything better,
9088 please do mail it to me."
9091 (set-buffer gnus-article-buffer)
9092 (let ((buffer-read-only nil))
9094 (search-forward "\n\n" nil t)
9096 (if (looking-at ">")
9097 (add-text-properties
9098 (point) (save-excursion (forward-line 1) (point))
9100 (forward-line 1)))))
9102 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
9103 (defun gnus-article-treat-overstrike ()
9104 ;; Prepare article for overstrike commands.
9107 (set-buffer gnus-article-buffer)
9108 (let ((buffer-read-only nil))
9109 (while (search-forward "\b" nil t)
9110 (let ((next (following-char))
9111 (previous (char-after (- (point) 2))))
9112 (cond ((eq next previous)
9113 (delete-region (- (point) 2) (point))
9114 (put-text-property (point) (1+ (point))
9117 (delete-region (1- (point)) (1+ (point)))
9118 (put-text-property (1- (point)) (point)
9121 (delete-region (- (point) 2) (point))
9122 (put-text-property (point) (1+ (point))
9123 'face 'underline))))))))
9125 (defun gnus-article-word-wrap ()
9126 "Format too long lines."
9129 (set-buffer gnus-article-buffer)
9130 (let ((buffer-read-only nil))
9132 (search-forward "\n\n" nil t)
9134 (let ((paragraph-start "^\\W"))
9136 (and (>= (current-column) (window-width))
9137 (/= (preceding-char) ?:)
9138 (fill-paragraph nil))
9139 (end-of-line 2))))))
9141 (defun gnus-article-remove-cr ()
9144 (set-buffer gnus-article-buffer)
9145 (let ((buffer-read-only nil))
9146 (goto-char (point-min))
9147 (while (search-forward "\r" nil t)
9148 (replace-match "")))))
9150 (defun gnus-article-de-quoted-unreadable ()
9154 (set-buffer gnus-article-buffer)
9155 (let ((buffer-read-only nil))
9157 (goto-char (point-min))
9158 (while (re-search-forward "=[0-9A-F][0-9A-F]" nil t)
9162 (* 16 (gnus-hex-char-to-integer
9163 (char-after (1+ (match-beginning 0)))))
9164 (gnus-hex-char-to-integer
9165 (char-after (1- (match-end 0))))))))))))
9167 ;; Taken from hexl.el.
9168 (defun gnus-hex-char-to-integer (character)
9169 "Take a char and return its value as if it was a hex digit."
9170 (if (and (>= character ?0) (<= character ?9))
9172 (let ((ch (logior character 32)))
9173 (if (and (>= ch ?a) (<= ch ?f))
9175 (error (format "Invalid hex digit `%c'." ch))))))
9179 (defun gnus-output-to-rmail (file-name)
9180 "Append the current article to an Rmail file named FILE-NAME."
9182 ;; Most of these codes are borrowed from rmailout.el.
9183 (setq file-name (expand-file-name file-name))
9184 (setq rmail-default-rmail-file file-name)
9185 (let ((artbuf (current-buffer))
9186 (tmpbuf (get-buffer-create " *Gnus-output*")))
9188 (or (get-file-buffer file-name)
9189 (file-exists-p file-name)
9190 (if (gnus-yes-or-no-p
9191 (concat "\"" file-name "\" does not exist, create it? "))
9192 (let ((file-buffer (create-file-buffer file-name)))
9194 (set-buffer file-buffer)
9195 (rmail-insert-rmail-file-header)
9196 (let ((require-final-newline nil))
9197 (write-region (point-min) (point-max) file-name t 1)))
9198 (kill-buffer file-buffer))
9199 (error "Output file does not exist")))
9201 (buffer-disable-undo (current-buffer))
9203 (insert-buffer-substring artbuf)
9204 (gnus-convert-article-to-rmail)
9205 ;; Decide whether to append to a file or to an Emacs buffer.
9206 (let ((outbuf (get-file-buffer file-name)))
9208 (append-to-file (point-min) (point-max) file-name)
9209 ;; File has been visited, in buffer OUTBUF.
9211 (let ((buffer-read-only nil)
9212 (msg (and (boundp 'rmail-current-message)
9213 rmail-current-message)))
9214 ;; If MSG is non-nil, buffer is in RMAIL mode.
9217 (narrow-to-region (point-max) (point-max))))
9218 (insert-buffer-substring tmpbuf)
9221 (goto-char (point-min))
9223 (search-backward "\^_")
9224 (narrow-to-region (point) (point-max))
9225 (goto-char (1+ (point-min)))
9226 (rmail-count-new-messages t)
9227 (rmail-show-message msg)))))))
9228 (kill-buffer tmpbuf)))
9230 (defun gnus-output-to-file (file-name)
9231 "Append the current article to a file named FILE-NAME."
9232 (setq file-name (expand-file-name file-name))
9233 (let ((artbuf (current-buffer))
9234 (tmpbuf (get-buffer-create " *Gnus-output*")))
9237 (buffer-disable-undo (current-buffer))
9239 (insert-buffer-substring artbuf)
9240 ;; Append newline at end of the buffer as separator, and then
9242 (goto-char (point-max))
9244 (append-to-file (point-min) (point-max) file-name))
9245 (kill-buffer tmpbuf)))
9247 (defun gnus-convert-article-to-rmail ()
9248 "Convert article in current buffer to Rmail message format."
9249 (let ((buffer-read-only nil))
9250 ;; Convert article directly into Babyl format.
9251 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
9252 (goto-char (point-min))
9253 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
9254 (while (search-forward "\n\^_" nil t) ;single char
9255 (replace-match "\n^_")) ;2 chars: "^" and "_"
9256 (goto-char (point-max))
9259 (defun gnus-narrow-to-page (&optional arg)
9260 "Make text outside current page invisible except for page delimiter.
9261 A numeric arg specifies to move forward or backward by that many pages,
9262 thus showing a page other than the one point was originally in."
9264 (setq arg (if arg (prefix-numeric-value arg) 0))
9266 (forward-page -1) ;Beginning of current page.
9271 (forward-page (1- arg))))
9272 ;; Find the end of the page.
9274 ;; If we stopped due to end of buffer, stay there.
9275 ;; If we stopped after a page delimiter, put end of restriction
9276 ;; at the beginning of that line.
9277 ;; These are commented out.
9278 ;; (if (save-excursion (beginning-of-line)
9279 ;; (looking-at page-delimiter))
9280 ;; (beginning-of-line))
9281 (narrow-to-region (point)
9283 ;; Find the top of the page.
9285 ;; If we found beginning of buffer, stay there.
9286 ;; If extra text follows page delimiter on same line,
9288 ;; Otherwise, show text starting with following line.
9289 (if (and (eolp) (not (bobp)))
9293 (defun gnus-gmt-to-local ()
9294 "Rewrite Date header described in GMT to local in current buffer.
9295 Intended to be used with gnus-article-prepare-hook."
9299 (goto-char (point-min))
9300 (narrow-to-region (point-min)
9301 (progn (search-forward "\n\n" nil 'move) (point)))
9302 (goto-char (point-min))
9303 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
9304 (let ((buffer-read-only nil)
9305 (date (buffer-substring (match-beginning 1) (match-end 1))))
9306 (delete-region (match-beginning 1) (match-end 1))
9308 (timezone-make-date-arpa-standard
9309 date nil (current-time-zone))))))))
9312 ;; Article mode commands
9314 (defun gnus-article-next-page (lines)
9315 "Show next page of current article.
9316 If end of article, return non-nil. Otherwise return nil.
9317 Argument LINES specifies lines to be scrolled up."
9319 (move-to-window-line -1)
9320 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
9323 (and (pos-visible-in-window-p) ;Not continuation line.
9325 ;; Nothing in this page.
9326 (if (or (not gnus-break-pages)
9329 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
9331 (gnus-narrow-to-page 1) ;Go to next page.
9333 ;; More in this page.
9337 ;; Long lines may cause an end-of-buffer error.
9338 (goto-char (point-max))))
9341 (defun gnus-article-prev-page (lines)
9342 "Show previous page of current article.
9343 Argument LINES specifies lines to be scrolled down."
9345 (move-to-window-line 0)
9346 (if (and gnus-break-pages
9348 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
9350 (gnus-narrow-to-page -1) ;Go to previous page.
9351 (goto-char (point-max))
9353 (scroll-down lines)))
9355 (defun gnus-article-refer-article ()
9356 "Read article specified by message-id around point."
9358 (search-forward ">" nil t) ;Move point to end of "<....>".
9359 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
9361 (buffer-substring (match-beginning 1) (match-end 1))))
9362 (set-buffer gnus-summary-buffer)
9363 (gnus-summary-refer-article message-id))
9364 (error "No references around point")))
9366 (defun gnus-article-mail (yank)
9367 "Send a reply to the address near point.
9368 If YANK is non-nil, include the original article."
9372 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
9373 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
9376 (switch-to-buffer gnus-summary-buffer)
9377 (funcall gnus-mail-reply-method yank address)))))
9379 (defun gnus-article-mail-with-original ()
9380 "Send a reply to the address near point and include the original article."
9382 (gnus-article-mail 'yank))
9384 (defun gnus-article-show-summary ()
9385 "Reconfigure windows to show summary buffer."
9387 (gnus-configure-windows 'article)
9388 (pop-to-buffer gnus-summary-buffer)
9389 (gnus-summary-goto-subject gnus-current-article))
9391 (defun gnus-article-describe-briefly ()
9392 "Describe article mode commands briefly."
9395 (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")))
9397 (defun gnus-article-summary-command ()
9398 "Execute the last keystroke in the summary buffer."
9401 (let ((obuf (current-buffer))
9402 (owin (current-window-configuration)))
9403 (switch-to-buffer gnus-summary-buffer 'norecord)
9404 (execute-kbd-macro (this-command-keys))
9406 (let ((npoint (point)))
9407 (set-window-configuration owin)
9408 (set-window-start (get-buffer-window (current-buffer)) (point)))))
9410 ;; caesar-region written by phr@prep.ai.mit.edu Nov 86
9411 ;; Modified by tower@prep Nov 86
9412 ;; Modified by umerin@flab.flab.Fujitsu.JUNET for ROT47.
9414 (defun gnus-caesar-region (&optional n)
9415 "Caesar rotation of region by N, default 13, for decrypting netnews.
9416 ROT47 will be performed for Japanese text in any case."
9417 (interactive (if current-prefix-arg ; Was there a prefix arg?
9418 (list (prefix-numeric-value current-prefix-arg))
9420 (cond ((not (numberp n)) (setq n 13))
9421 (t (setq n (mod n 26)))) ;canonicalize N
9422 (if (not (zerop n)) ; no action needed for a rot of 0
9424 (if (or (not (boundp 'caesar-translate-table))
9425 (not caesar-translate-table)
9426 (/= (aref caesar-translate-table ?a) (+ ?a n)))
9427 (let ((i 0) (lower "abcdefghijklmnopqrstuvwxyz") upper)
9428 (message "Building caesar-translate-table...")
9429 (setq caesar-translate-table (make-vector 256 0))
9431 (aset caesar-translate-table i i)
9433 (setq lower (concat lower lower) upper (upcase lower) i 0)
9435 (aset caesar-translate-table (+ ?a i) (aref lower (+ i n)))
9436 (aset caesar-translate-table (+ ?A i) (aref upper (+ i n)))
9438 ;; ROT47 for Japanese text.
9439 ;; Thanks to ichikawa@flab.fujitsu.junet.
9441 (let ((t1 (logior ?O 128))
9442 (t2 (logior ?! 128))
9443 (t3 (logior ?~ 128)))
9445 (aset caesar-translate-table i
9446 (let ((v (aref caesar-translate-table i)))
9447 (if (<= v t1) (if (< v t2) v (+ v 47))
9448 (if (<= v t3) (- v 47) v))))
9450 (message "Building caesar-translate-table... done")))
9451 (let ((from (region-beginning))
9454 (setq str (buffer-substring from to))
9455 (setq len (length str))
9457 (aset str i (aref caesar-translate-table (aref str i)))
9460 (delete-region from to)
9464 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
9467 (defalias 'gnus-batch-kill 'gnus-batch-score)
9469 (defun gnus-batch-score ()
9470 "Run batched scoring.
9471 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
9472 Newsgroups is a list of strings in Bnews format. If you want to score
9473 the comp hierarchy, you'd say \"comp.all\". If you would not like to
9474 score the alt hierarchy, you'd say \"!alt.all\"."
9477 (gnus-parse-n-options
9478 (apply (function concat)
9479 (mapcar (lambda (g) (concat g " "))
9480 command-line-args-left))))
9481 (gnus-expert-user t)
9482 (nnmail-spool-file nil)
9483 (gnus-use-dribble-file nil)
9484 (yes (car yes-and-no))
9485 (no (cdr yes-and-no))
9486 group subscribed newsrc entry
9487 ;; Disable verbose message.
9488 gnus-novice-user gnus-large-newsgroup)
9489 ;; Eat all arguments.
9490 (setq command-line-args-left nil)
9493 ;; Apply kills to specified newsgroups in command line arguments.
9494 (setq newsrc (cdr gnus-newsrc-assoc))
9496 (setq group (car (car newsrc)))
9497 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
9498 (if (and (<= (nth 1 (car newsrc)) 5)
9500 (or (eq (car entry) t)
9501 (not (zerop (car entry)))))
9502 (if yes (string-match yes group) t)
9503 (or (null no) (not (string-match no group))))
9505 (gnus-summary-read-group group nil t)
9506 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
9507 (gnus-summary-exit))))
9508 (setq newsrc (cdr newsrc)))
9510 (switch-to-buffer gnus-group-buffer)
9511 (gnus-group-save-newsrc)))
9513 (defun gnus-apply-kill-file ()
9514 "Apply a kill file to the current newsgroup.
9515 Returns the number of articles marked as read."
9516 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
9517 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
9518 (gnus-apply-kill-file-internal)
9521 (defun gnus-kill-save-kill-buffer ()
9523 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
9524 (if (get-file-buffer file)
9526 (set-buffer (get-file-buffer file))
9527 (and (buffer-modified-p) (save-buffer))
9528 (kill-buffer (current-buffer)))))))
9530 (defvar gnus-kill-file-name "KILL"
9531 "Suffix of the kill files.")
9533 (defun gnus-newsgroup-kill-file (newsgroup)
9534 "Return the name of a kill file name for NEWSGROUP.
9535 If NEWSGROUP is nil, return the global kill file name instead."
9536 (cond ((or (null newsgroup)
9537 (string-equal newsgroup ""))
9538 ;; The global KILL file is placed at top of the directory.
9539 (expand-file-name gnus-kill-file-name
9540 (or gnus-kill-files-directory "~/News")))
9541 (gnus-use-long-file-name
9542 ;; Append ".KILL" to newsgroup name.
9543 (expand-file-name (concat newsgroup "." gnus-kill-file-name)
9544 (or gnus-kill-files-directory "~/News")))
9546 ;; Place "KILL" under the hierarchical directory.
9547 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
9548 "/" gnus-kill-file-name)
9549 (or gnus-kill-files-directory "~/News")))))
9553 ;;; Gnus Score Files
9556 ;; All score code written by Per Abrahamsen <abraham@iesd.auc.dk>.
9558 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9559 (defun gnus-score-set-mark-below (score)
9560 "Automatically mark articles with score below SCORE as read."
9562 (list (or (and current-prefix-arg (prefix-numeric-value current-prefix-arg))
9563 (string-to-int (read-string "Mark below: ")))))
9564 (setq score (or score gnus-summary-default-score 0))
9565 (gnus-score-set 'mark (list score))
9566 (gnus-score-set 'touched '(t))
9567 (setq gnus-summary-mark-below score)
9568 (gnus-summary-update-lines))
9570 (defun gnus-score-set-expunge-below (score)
9571 "Automatically expunge articles with score below SCORE."
9573 (list (or (and current-prefix-arg (prefix-numeric-value current-prefix-arg))
9574 (string-to-int (read-string "Expunge below: ")))))
9575 (setq score (or score gnus-summary-default-score 0))
9576 (gnus-score-set 'expunge (list score))
9577 (gnus-score-set 'touched '(t)))
9579 (defun gnus-score-default (level)
9580 (if level (prefix-numeric-value level)
9581 gnus-score-interactive-default-score))
9583 (defun gnus-score-set (symbol value &optional alist)
9584 ;; Set SYMBOL to VALUE in ALIST.
9589 (gnus-score-load (gnus-score-file-name gnus-newsgroup-name))
9591 (entry (assoc symbol alist)))
9592 (cond ((gnus-score-get 'read-only alist)
9593 ;; This is a read-only score file, so we do nothing.
9596 (setcdr entry value))
9598 (error "Empty alist"))
9601 (cons (cons symbol value) (cdr alist)))))))
9603 (defun gnus-score-get (symbol &optional alist)
9604 ;; Get SYMBOL's definition in ALIST.
9610 (gnus-score-file-name gnus-newsgroup-name))
9611 gnus-score-alist)))))
9613 (defun gnus-score-change-score-file (file)
9614 "Change current score alist."
9616 (list (completing-read "Score file: " gnus-score-cache)))
9617 (setq gnus-current-score-file file)
9618 (gnus-score-load-file file))
9620 (defun gnus-score-edit-alist (file)
9621 "Edit the current score alist."
9622 (interactive (list gnus-current-score-file))
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-edit-file (file)
9632 "Edit a score file."
9634 (list (read-file-name "Edit score file: " gnus-kill-files-directory)))
9635 (and (buffer-name gnus-summary-buffer) (gnus-score-save))
9636 (setq gnus-winconf-edit-score (current-window-configuration))
9637 (gnus-configure-windows 'article)
9638 (pop-to-buffer (find-file-noselect file))
9639 (message (substitute-command-keys
9640 "\\<gnus-score-mode-map>\\[gnus-score-edit-done] to save edits"))
9643 (defun gnus-score-load-file (file)
9644 ;; Load score file FILE. Returns a list a retrieved score-alists.
9645 (let* ((file (expand-file-name (or (and (string-match "^/" file) file)
9646 (concat gnus-kill-files-directory file))))
9647 (cached (assoc file gnus-score-cache))
9648 (global (member file gnus-internal-global-score-files))
9651 ;; The score file was already loaded.
9652 (setq gnus-score-alist (cdr cached))
9653 ;; We load the score file.
9654 (setq gnus-score-alist nil)
9655 (setq alist (gnus-score-load-score-alist file))
9656 ;; We add '(touched) to the alist to signify that it hasn't been
9658 (if (not (assq 'touched gnus-score-alist))
9659 (setq gnus-score-alist
9660 (cons (list 'touched nil) gnus-score-alist)))
9661 ;; If it is a global score file, we make it read-only.
9663 (not (assq 'read-only gnus-score-alist))
9664 (setq gnus-score-alist
9665 (cons (list 'read-only t) gnus-score-alist)))
9667 (setq gnus-score-cache
9668 (cons (cons file gnus-score-alist) gnus-score-cache)))
9669 ;; If there are actual scores in the alist, we add it to the
9670 ;; return value of this function.
9671 (if (memq t (mapcar (lambda (e) (stringp (car e))) gnus-score-alist))
9672 (setq lists (list gnus-score-alist)))
9673 ;; Treat the other possible atoms in the score alist.
9674 (let ((mark (car (gnus-score-get 'mark gnus-score-alist)))
9675 (expunge (car (gnus-score-get 'expunge gnus-score-alist)))
9677 (car (gnus-score-get 'mark-and-expunge gnus-score-alist)))
9678 (read-only (gnus-score-get 'read-only gnus-score-alist))
9679 (files (gnus-score-get 'files gnus-score-alist))
9680 (eval (gnus-score-get 'eval gnus-score-alist)))
9681 ;; We do not respect eval and files atoms from global score
9683 (and files (not global)
9684 (setq lists (apply 'append lists
9685 (mapcar (lambda (file)
9686 (gnus-score-load-file file))
9688 (and eval (not global) (eval eval))
9689 (setq gnus-summary-mark-below (or mark mark-and-expunge))
9690 (setq gnus-summary-expunge-below (or expunge mark-and-expunge)))
9691 (setq gnus-current-score-file file)
9692 (setq gnus-score-alist alist)
9695 (defun gnus-score-load (file)
9697 (let ((cache (assoc file gnus-score-cache)))
9699 (setq gnus-score-alist (cdr cache))
9700 (setq gnus-score-alist nil)
9701 (gnus-score-load-score-alist file)
9702 (or gnus-score-alist
9703 (setq gnus-score-alist (copy-alist '((touched . nil)))))
9704 (setq gnus-score-cache
9705 (cons (cons file gnus-score-alist) gnus-score-cache)))))
9707 (defun gnus-score-remove-from-cache (file)
9708 (setq gnus-score-cache (delq (assoc file gnus-score-cache)
9711 (defun gnus-score-load-score-alist (file)
9713 (if (file-readable-p file)
9716 (set-buffer (get-buffer-create " *gnus work*"))
9717 (buffer-disable-undo (current-buffer))
9719 (insert-file-contents file)
9720 (goto-char (point-min))
9723 (read (current-buffer))
9726 (message "Problem with score file %s" file)
9729 (if (eq (car alist) 'setq)
9730 (setq gnus-score-alist
9731 (gnus-score-transform-old-to-new alist))
9732 (setq gnus-score-alist alist))))))
9734 (defun gnus-score-transform-old-to-new (alist)
9735 (let* ((alist (nth 2 alist))
9737 (if (eq (car alist) 'quote)
9738 (setq alist (nth 1 alist)))
9740 (setq entry (car alist))
9741 (if (stringp (car entry))
9742 (let ((scor (cdr entry)))
9743 (setq out (cons entry out))
9746 (list (car (car scor)) (nth 2 (car scor))
9747 (and (nth 3 (car scor))
9748 (gnus-day-number (nth 3 (car scor))))
9749 (if (nth 1 (car scor)) 'r 's)))
9750 (setq scor (cdr scor))))
9751 (setq out (cons (list (car entry) (cdr entry)) out)))
9752 (setq alist (cdr alist)))
9753 (cons (list 'touched t) (nreverse out))))
9755 (defun gnus-score-save ()
9756 ;; Save all SCORE information.
9759 (set-buffer gnus-summary-buffer)
9760 (setq cache gnus-score-cache
9761 gnus-score-cache nil))
9763 (setq gnus-score-alist nil)
9764 (set-buffer (get-buffer-create "*Score*"))
9765 (buffer-disable-undo (current-buffer))
9766 (let (entry score file)
9768 (setq entry (car cache)
9772 (if (or (not (equal (gnus-score-get 'touched score) '(t)))
9773 (gnus-score-get 'read-only score)
9774 (not (file-writable-p file)))
9776 (setq score (delq (assq 'touched score) score))
9778 (let (emacs-lisp-mode-hook)
9779 (pp score (current-buffer)))
9780 (make-directory (file-name-directory file) t)
9781 (write-region (point-min) (point-max) file nil 'silent))))
9782 (kill-buffer (current-buffer)))))
9784 (defun gnus-score-headers ()
9785 ;; Score `gnus-newsgroup-headers'.
9786 (let ((score-files (and (symbolp gnus-score-find-score-files-function)
9787 (fboundp gnus-score-find-score-files-function)
9788 (funcall gnus-score-find-score-files-function
9789 gnus-newsgroup-name)))
9791 ;; Load the SCORE files.
9793 (setq scores (nconc (gnus-score-load-file (car score-files)) scores))
9794 (setq score-files (cdr score-files)))
9795 (if (not (and gnus-summary-default-score
9797 (> (length gnus-newsgroup-headers)
9798 (length gnus-newsgroup-scored))))
9800 (let* ((entries gnus-header-index)
9801 (now (gnus-day-number (current-time-string)))
9802 (expire (- now gnus-score-expiry-days))
9803 (headers gnus-newsgroup-headers)
9805 (message "Scoring...")
9806 ;; Create articles, an alist of the form `(HEADER . SCORE)'.
9808 (setq header (car headers)
9809 headers (cdr headers))
9810 ;; WARNING: The assq makes the function O(N*S) while it could
9811 ;; be written as O(N+S), where N is (length gnus-newsgroup-headers)
9812 ;; and S is (length gnus-newsgroup-scored).
9813 (or (assq (header-number header) gnus-newsgroup-scored)
9814 (setq gnus-scores-articles ;Total of 2 * N cons-cells used.
9815 (cons (cons header (or gnus-summary-default-score 0))
9816 gnus-scores-articles))))
9819 (set-buffer (get-buffer-create "*Headers*"))
9820 (buffer-disable-undo (current-buffer))
9821 ;; Run each header through the score process.
9823 (setq entry (car entries)
9824 header (nth 0 entry)
9825 entries (cdr entries))
9826 (setq gnus-score-index (nth 1 (assoc header gnus-header-index)))
9827 (if (< 0 (apply 'max (mapcar
9829 (length (gnus-score-get header score)))
9831 (funcall (nth 2 entry) scores header now expire)))
9832 ;; Remove the buffer.
9833 (kill-buffer (current-buffer)))
9835 ;; Add articles to `gnus-newsgroup-scored'.
9836 (while gnus-scores-articles
9837 (or (= gnus-summary-default-score (cdr (car gnus-scores-articles)))
9838 (setq gnus-newsgroup-scored
9839 (cons (cons (header-number
9840 (car (car gnus-scores-articles)))
9841 (cdr (car gnus-scores-articles)))
9842 gnus-newsgroup-scored)))
9843 (setq gnus-scores-articles (cdr gnus-scores-articles)))
9845 (message "Scoring...done")))))
9847 ;;(defun gnus-score-integer (scores header now expire)
9850 ;;(defun gnus-score-date (scores header now expire)
9853 (defun gnus-score-string (scores header now expire)
9854 ;; Score ARTICLES according to HEADER in SCORES.
9855 ;; Update matches entries to NOW and remove unmatched entried older
9858 ;; Insert the unique article headers in the buffer.
9859 (let ((gnus-score-index (nth 1 (assoc header gnus-header-index)))
9860 ;; gnus-score-index is used as a free variable.
9861 alike last this art entries alist articles)
9863 ;; Sorting the articles costs os O(N*log N) but will allow us to
9864 ;; only match with each unique header. Thus the actual matching
9865 ;; will be O(M*U) where M is the number of strings to match with,
9866 ;; and U is the number of unique headers. It is assumed (but
9867 ;; untested) this will be a net win because of the large constant
9868 ;; factor involved with string matching.
9869 (setq gnus-scores-articles (sort gnus-scores-articles 'gnus-score-string<)
9870 articles gnus-scores-articles)
9874 (setq art (car articles)
9875 this (aref (car art) gnus-score-index)
9876 articles (cdr articles))
9877 (if (equal last this)
9878 ;; O(N*H) cons-cells used here, where H is the number of
9880 (setq alike (cons art alike))
9883 ;; Insert the line, with a text property on the
9884 ;; terminating newline refering to the articles with
9887 (put-text-property (1- (point)) (point) 'articles alike)))
9888 (setq alike (list art)
9890 (and last ; Bwadr, duplicate code.
9893 (put-text-property (1- (point)) (point) 'articles alike)))
9897 (setq alist (car scores)
9899 entries (assoc header alist))
9900 (while (cdr entries) ;First entry is the header index.
9901 (let* ((rest (cdr entries))
9903 (match (nth 0 kill))
9904 (type (or (nth 3 kill) 's))
9905 (score (or (nth 1 kill) gnus-score-interactive-default-score))
9908 (case-fold-search t)
9910 (goto-char (point-min))
9911 (while (cond ((eq type 'r)
9912 (re-search-forward match nil t))
9914 (search-forward match nil t)))
9917 arts (get-text-property (point) 'articles))
9918 ;; Found a match, update scores.
9920 (setq art (car arts)
9922 (setcdr art (+ score (cdr art)))))
9923 ;; Update expire date
9924 (cond ((null date)) ;Permanent entry.
9925 (found ;Match, update date.
9926 (gnus-score-set 'touched '(t) alist)
9927 (setcar (nthcdr 2 kill) now))
9928 ((< date expire) ;Old entry, remove.
9929 (gnus-score-set 'touched '(t) alist)
9930 (setcdr entries (cdr rest))
9931 (setq rest entries)))
9932 (setq entries rest))))))
9934 (defun gnus-score-string< (a1 a2)
9935 ;; Compare headers in articles A2 and A2.
9936 ;; The header index used is the free variable `gnus-score-index'.
9937 (string-lessp (aref (car a1) gnus-score-index)
9938 (aref (car a2) gnus-score-index)))
9940 (defun gnus-score-build-cons (article)
9941 ;; Build a `gnus-newsgroup-scored' type cons from ARTICLE.
9942 (cons (header-number (car article)) (cdr article)))
9944 (defconst gnus-header-index
9945 ;; Name to index alist.
9946 '(("number" 0 gnus-score-integer)
9947 ("subject" 1 gnus-score-string)
9948 ("from" 2 gnus-score-string)
9949 ("date" 3 gnus-score-date)
9950 ("message-id" 4 gnus-score-string)
9951 ("references" 5 gnus-score-string)
9952 ("chars" 6 gnus-score-integer)
9953 ("lines" 7 gnus-score-integer)
9954 ("xref" 8 gnus-score-string)))
9956 (defun gnus-score-file-name (newsgroup)
9957 "Return the name of a score file for NEWSGROUP."
9958 (cond ((or (null newsgroup)
9959 (string-equal newsgroup ""))
9960 ;; The global score file is placed at top of the directory.
9961 (expand-file-name gnus-score-file-suffix
9962 (or gnus-kill-files-directory "~/News")))
9963 (gnus-use-long-file-name
9964 ;; Append ".SCORE" to newsgroup name.
9965 (expand-file-name (concat newsgroup "." gnus-score-file-suffix)
9966 (or gnus-kill-files-directory "~/News")))
9968 ;; Place "SCORE" under the hierarchical directory.
9969 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
9970 "/" gnus-score-file-suffix)
9971 (or gnus-kill-files-directory "~/News")))))
9973 (defun gnus-score-score-files (group)
9974 "Return a list of all possible score files."
9975 (and gnus-global-score-files
9976 (or gnus-internal-global-score-files
9977 (gnus-score-search-global-directories gnus-global-score-files)))
9978 (setq gnus-kill-files-directory
9979 (file-name-as-directory
9980 (or gnus-kill-files-directory "~/News/")))
9981 (if (not (file-readable-p gnus-kill-files-directory))
9982 (setq gnus-score-file-list nil)
9983 (if gnus-use-long-file-name
9984 (if (or (not gnus-score-file-list)
9985 (gnus-file-newer-than gnus-kill-files-directory
9986 (car gnus-score-file-list)))
9987 (setq gnus-score-file-list
9988 (cons (nth 5 (file-attributes gnus-kill-files-directory))
9991 gnus-kill-files-directory t
9992 (concat gnus-score-file-suffix "$"))))))
9993 (let ((dir (expand-file-name
9994 (concat gnus-kill-files-directory
9995 (gnus-replace-chars-in-string group ?. ?/))))
9996 (mdir (length (expand-file-name gnus-kill-files-directory)))
9998 (if (file-exists-p (concat dir "/" gnus-score-file-suffix))
9999 (setq files (list (concat dir "/" gnus-score-file-suffix))))
10000 (while (>= (1+ (length dir)) mdir)
10001 (and (file-exists-p (concat dir "/all/" gnus-score-file-suffix))
10002 (setq files (cons (concat dir "/all/" gnus-score-file-suffix)
10004 (string-match "/[^/]*$" dir)
10005 (setq dir (substring dir 0 (match-beginning 0))))
10006 (setq gnus-score-file-list
10007 (cons nil (nreverse files)))))
10008 (cdr gnus-score-file-list)))
10010 (defun gnus-score-find-single (group)
10011 "Return list containing the score file for GROUP."
10012 (list (gnus-score-file-name group)))
10014 (defun gnus-score-find-hierarchical (group)
10015 "Return list of score files for GROUP.
10016 This includes the score file for the group and all its parents."
10017 (let ((all (copy-sequence '(nil)))
10019 (while (string-match "\\." group (1+ start))
10020 (setq start (match-beginning 0))
10021 (setq all (cons (substring group 0 start) all)))
10022 (setq all (cons group all))
10023 (mapcar 'gnus-score-file-name (nreverse all))))
10025 (defun gnus-score-find-bnews (group)
10026 "Return a list of score files for GROUP.
10027 The score files are those files in the ~/News directory which matches
10028 GROUP using BNews sys file syntax."
10029 (let* ((sfiles (append (gnus-score-score-files group)
10030 gnus-internal-global-score-files))
10031 (kill-dir (file-name-as-directory
10032 (expand-file-name gnus-kill-files-directory)))
10033 (klen (length kill-dir))
10034 ofiles not-match regexp)
10036 (set-buffer (get-buffer-create "*gnus score files*"))
10037 (buffer-disable-undo (current-buffer))
10038 ;; Go through all score file names and create regexp with them
10042 (insert (car sfiles))
10044 ;; First remove the suffix itself.
10045 (re-search-forward (concat "." gnus-score-file-suffix "$"))
10048 (if (looking-at (regexp-quote kill-dir))
10049 ;; If the file name was just "SCORE", `klen' is one character
10051 (delete-char (min (1- (point-max)) klen))
10052 (goto-char (point-max))
10053 (search-backward "/")
10054 (delete-region (1+ (point)) (point-min)))
10055 ;; Translate "all" to ".*".
10056 (while (search-forward "all" nil t)
10057 (replace-match ".*"))
10059 ;; Deal with "not."s.
10060 (if (looking-at "not.")
10063 (setq regexp (buffer-substring 5 (point-max))))
10064 (setq regexp (buffer-substring 1 (point-max)))
10065 (setq not-match nil))
10066 ;; Finally - if this resulting regexp matches the group name,
10067 ;; we add this score file to the list of score files
10068 ;; applicable to this group.
10069 (if (or (and not-match
10070 (not (string-match regexp group)))
10071 (and (not not-match)
10072 (string-match regexp group)))
10073 (setq ofiles (cons (car sfiles) ofiles)))
10074 (setq sfiles (cdr sfiles)))
10075 (kill-buffer (current-buffer))
10076 ;; Slight kludge here - the last score file returned should be
10077 ;; the local score file, whether it exists or not. This is so
10078 ;; that any score commands the user enters will go to the right
10079 ;; file, and not end up in some global score file.
10082 (if gnus-use-long-file-name
10083 (concat gnus-kill-files-directory group "."
10084 gnus-score-file-suffix)
10085 (concat gnus-kill-files-directory
10086 (gnus-replace-chars-in-string group ?. ?/)
10087 "/" gnus-score-file-suffix)))))
10088 (and (member localscore ofiles)
10089 (delete localscore ofiles))
10090 (setq ofiles (cons localscore ofiles)))
10091 (nreverse ofiles))))
10093 (defun gnus-score-search-global-directories (files)
10094 "Scan all global score directories for score files."
10095 ;; Set the variable `gnus-internal-global-score-files' to all
10096 ;; available global score files.
10097 (interactive (list gnus-global-score-files))
10100 (if (string-match "/$" (car files))
10101 (setq out (nconc (directory-files
10103 (concat gnus-score-file-suffix "$"))))
10104 (setq out (cons (car files) out)))
10105 (setq files (cdr files)))
10106 (setq gnus-internal-global-score-files out)))
10112 (defvar gnus-score-mode-map nil)
10113 (defvar gnus-score-mode-hook nil)
10115 (if gnus-score-mode-map
10117 (setq gnus-score-mode-map (copy-keymap emacs-lisp-mode-map))
10118 (define-key gnus-score-mode-map "\C-c\C-c" 'gnus-score-edit-done)
10119 (define-key gnus-score-mode-map "\C-c\C-d" 'gnus-score-edit-insert-date))
10121 (defun gnus-score-mode ()
10122 "Mode for editing score files.
10123 This mode is an extended emacs-lisp mode.
10125 \\{gnus-score-mode-map}"
10127 (kill-all-local-variables)
10128 (use-local-map gnus-score-mode-map)
10129 (set-syntax-table emacs-lisp-mode-syntax-table)
10130 (setq major-mode 'gnus-score-mode)
10131 (setq mode-name "Score")
10132 (lisp-mode-variables nil)
10133 (run-hooks 'emacs-lisp-mode-hook 'gnus-score-mode-hook))
10135 (defun gnus-score-edit-insert-date ()
10136 "Insert date in numerical format."
10138 (insert (int-to-string (gnus-day-number (current-time-string)))))
10140 (defun gnus-score-edit-done ()
10141 "Save the score file and return to the summary buffer."
10143 (let ((bufnam (buffer-file-name (current-buffer))))
10145 (kill-buffer (current-buffer))
10146 (and gnus-winconf-edit-score
10147 (set-window-configuration gnus-winconf-edit-score))
10148 (gnus-score-remove-from-cache bufnam)
10149 (gnus-score-load-file bufnam)))
10153 ;;; Gnus Posting Functions
10156 (defvar gnus-organization-file "/usr/lib/news/organization"
10157 "*Local news organization file.")
10159 (defvar gnus-post-news-buffer "*post-news*")
10160 (defvar gnus-winconf-post-news nil)
10162 ;;; Post news commands of Gnus group mode and summary mode
10164 (defun gnus-group-post-news ()
10167 (gnus-set-global-variables)
10168 ;; Save window configuration.
10169 (setq gnus-winconf-post-news (current-window-configuration))
10170 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
10171 (or gnus-newsgroup-name (setq gnus-newsgroup-name (gnus-group-group-name)))
10173 (gnus-post-news 'post)
10174 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
10175 (not (zerop (buffer-size))))
10176 ;; Restore last window configuration.
10177 (and gnus-winconf-post-news
10178 (set-window-configuration gnus-winconf-post-news))))
10179 ;; We don't want to return to summary buffer nor article buffer later.
10180 (setq gnus-winconf-post-news nil)
10181 (if (get-buffer gnus-summary-buffer)
10182 (bury-buffer gnus-summary-buffer))
10183 (if (get-buffer gnus-article-buffer)
10184 (bury-buffer gnus-article-buffer)))
10186 (defun gnus-summary-post-news ()
10189 (gnus-set-global-variables)
10190 ;; Save window configuration.
10191 (setq gnus-winconf-post-news (current-window-configuration))
10193 (gnus-post-news 'post gnus-newsgroup-name)
10194 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
10195 (not (zerop (buffer-size))))
10196 ;; Restore last window configuration.
10197 (and gnus-winconf-post-news
10198 (set-window-configuration gnus-winconf-post-news))))
10199 ;; We don't want to return to article buffer later.
10200 (if (get-buffer gnus-article-buffer)
10201 (bury-buffer gnus-article-buffer)))
10203 (defun gnus-summary-followup (yank)
10204 "Compose a followup to an article.
10205 If prefix argument YANK is non-nil, original article is yanked automatically."
10207 (gnus-set-global-variables)
10208 (save-window-excursion
10209 (gnus-summary-select-article t))
10210 (let ((headers gnus-current-headers)
10211 (gnus-newsgroup-name gnus-newsgroup-name))
10212 ;; Check Followup-To: poster.
10213 (set-buffer gnus-article-buffer)
10214 (if (and gnus-use-followup-to
10215 (string-equal "poster" (gnus-fetch-field "followup-to"))
10216 (or (not (eq gnus-use-followup-to t))
10217 (not (gnus-y-or-n-p
10218 "Do you want to ignore `Followup-To: poster'? "))))
10219 ;; Mail to the poster. Gnus is now RFC1036 compliant.
10220 (gnus-summary-reply yank)
10221 ;; Save window configuration.
10222 (setq gnus-winconf-post-news (current-window-configuration))
10224 (gnus-post-news nil gnus-newsgroup-name
10225 headers gnus-article-buffer yank)
10226 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
10227 (not (zerop (buffer-size))))
10228 ;; Restore last window configuration.
10229 (and gnus-winconf-post-news
10230 (set-window-configuration gnus-winconf-post-news))))
10231 ;; We don't want to return to article buffer later.
10232 (bury-buffer gnus-article-buffer))))
10234 (defun gnus-summary-followup-with-original ()
10235 "Compose a followup to an article and include the original article."
10237 (gnus-summary-followup t))
10239 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10240 (defun gnus-summary-followup-and-reply (yank)
10241 "Compose a followup and do an auto mail to author."
10243 (let ((gnus-auto-mail-to-author t))
10244 (gnus-summary-followup yank)))
10246 (defun gnus-summary-followup-and-reply-with-original ()
10247 "Compose a followup, include the original, and do an auto mail to author."
10249 (gnus-summary-followup-and-reply t))
10251 (defun gnus-summary-cancel-article ()
10252 "Cancel an article you posted."
10254 (gnus-set-global-variables)
10255 (gnus-summary-select-article t)
10256 (gnus-eval-in-buffer-window gnus-article-buffer
10257 (gnus-cancel-news)))
10259 (defun gnus-summary-supersede-article ()
10260 "Compose an article that will supersede a previous article.
10261 This is done simply by taking the old article and adding a Supersedes
10262 header line with the old Message-ID."
10264 (gnus-set-global-variables)
10267 (downcase (mail-strip-quoted-names
10268 (header-from gnus-current-headers)))
10269 (downcase (mail-strip-quoted-names (gnus-inews-user-name)))))
10270 (error "This article is not yours."))
10271 (gnus-summary-select-article t)
10273 (set-buffer gnus-article-buffer)
10274 (let ((buffer-read-only nil))
10275 (goto-char (point-min))
10276 (search-forward "\n\n" nil t)
10277 (if (not (re-search-backward "^Message-ID: " nil t))
10278 (error "No Message-ID in this article"))))
10279 (if (gnus-post-news 'post gnus-newsgroup-name)
10282 (insert-buffer gnus-article-buffer)
10283 (goto-char (point-min))
10284 (search-forward "\n\n" nil t)
10285 (if (not (re-search-backward "^Message-ID: " nil t))
10286 (error "No Message-ID in this article")
10287 (replace-match "Supersedes: "))
10288 (search-forward "\n\n")
10290 (insert mail-header-separator))))
10294 (fset 'sendnews 'gnus-post-news)
10297 (fset 'postnews 'gnus-post-news)
10299 (defun gnus-post-news (post &optional group header article-buffer yank)
10300 "Begin editing a new USENET news article to be posted.
10301 Type \\[describe-mode] in the buffer to get a list of commands."
10302 (interactive (list t))
10303 (if (or (not gnus-novice-user)
10307 (format "%s" (car (gnus-find-method-for-group
10308 gnus-newsgroup-name)))
10309 gnus-valid-select-methods))))
10310 (assq 'to-address (gnus-find-method-for-group gnus-newsgroup-name))
10311 (gnus-y-or-n-p "Are you sure you want to post to all of USENET? "))
10312 (let ((sumart (if (not post)
10314 (set-buffer gnus-summary-buffer)
10315 (cons (current-buffer) gnus-current-article))))
10316 (from (and header (header-from header)))
10317 subject follow-to real-group)
10318 (and gnus-interactive-post
10319 (not gnus-expert-user)
10323 (completing-read "Group: " gnus-active-hashtb nil t))
10324 (setq subject (read-string "Subject: "))))
10325 (setq mail-reply-buffer article-buffer)
10327 (setq real-group (gnus-group-real-name group))
10328 (setq gnus-post-news-buffer
10329 (gnus-request-post-buffer
10330 post real-group subject header article-buffer
10331 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
10332 (if (and (boundp 'gnus-followup-to-function)
10333 gnus-followup-to-function)
10336 (set-buffer article-buffer)
10337 (funcall gnus-followup-to-function group))))
10338 (eq gnus-use-followup-to t)))
10341 (gnus-configure-windows '(1 0 0))
10342 (switch-to-buffer gnus-post-news-buffer))
10343 (gnus-configure-windows '(0 1 0))
10346 (switch-to-buffer article-buffer)
10347 (pop-to-buffer gnus-post-news-buffer))
10348 (switch-to-buffer gnus-post-news-buffer)))
10349 (gnus-overload-functions)
10350 (make-local-variable 'gnus-article-reply)
10351 (make-local-variable 'gnus-article-check-size)
10352 (setq gnus-article-reply sumart)
10353 ;; Handle `gnus-auto-mail-to-author'.
10354 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10355 (let ((to (if (eq gnus-auto-mail-to-author 'ask)
10356 (and (y-or-n-p "Also send mail to author? ") from)
10357 (and gnus-auto-mail-to-author from))))
10360 (if (mail-fetch-field "To")
10362 (beginning-of-line)
10363 (insert "Cc: " to "\n"))
10364 (mail-position-on-field "To")
10366 ;; Handle author copy using BCC field.
10367 (if (and gnus-mail-self-blind
10368 (not (mail-fetch-field "bcc")))
10370 (mail-position-on-field "Bcc")
10371 (insert (if (stringp gnus-mail-self-blind)
10372 gnus-mail-self-blind
10373 (user-login-name)))))
10374 ;; Handle author copy using FCC field.
10375 (if gnus-author-copy
10377 (mail-position-on-field "Fcc")
10378 (insert gnus-author-copy)))
10379 (goto-char (point-min))
10382 (re-search-forward "^Newsgroup:" nil t)
10385 (re-search-forward "^Subject:" nil t)
10388 (search-forward (concat "\n" mail-header-separator "\n"))))
10389 (search-forward (concat "\n" mail-header-separator "\n"))
10392 (run-hooks 'news-reply-header-hook)
10393 (mail-yank-original nil)))
10394 (if gnus-post-prepare-function
10395 (funcall gnus-post-prepare-function group)))))
10396 (setq gnus-article-check-size (cons (buffer-size) (gnus-article-checksum)))
10400 (defun gnus-inews-news (&optional use-group-method)
10401 "Send a news message.
10402 If given a prefix, and the group is a foreign group, this function
10403 will attempt to use the foreign server to post the article."
10405 ;; Check whether the article is a good Net Citizen.
10406 (if (and gnus-article-check-size (not (gnus-inews-check-post)))
10409 ;; Looks ok, so we do the nasty.
10410 (let* ((case-fold-search nil)
10411 (server-running (gnus-server-opened gnus-select-method))
10412 (reply gnus-article-reply))
10414 ;; Connect to default NNTP server if necessary.
10415 ;; Suggested by yuki@flab.fujitsu.junet.
10416 (gnus-start-news-server) ;Use default server.
10417 ;; NNTP server must be opened before current buffer is modified.
10419 (goto-char (point-min))
10420 (run-hooks 'news-inews-hook)
10425 (goto-char (point-min))
10426 (search-forward (concat "\n" mail-header-separator "\n"))
10429 ;; Correct newsgroups field: change sequence of spaces to comma and
10430 ;; eliminate spaces around commas. Eliminate imbedded line breaks.
10431 (goto-char (point-min))
10432 (if (search-forward-regexp "^Newsgroups: +" nil t)
10436 (if (re-search-forward "^[^ \t]" nil 'end)
10437 (match-beginning 0)
10439 (goto-char (point-min))
10440 (replace-regexp "\n[ \t]+" " ") ;No line breaks (too confusing)
10441 (goto-char (point-min))
10442 (replace-regexp "[ \t\n]*,[ \t\n]*\\|[ \t]+" ",")))
10444 ;; Added by Per Abrahamsen <abraham@iesd.auc.dk>.
10445 ;; Help save the the world!
10448 (let ((newsgroups (mail-fetch-field "newsgroups"))
10449 (followup-to (mail-fetch-field "followup-to"))
10451 (if (and (string-match "," newsgroups) (not followup-to))
10453 (while (string-match "," newsgroups)
10455 (cons (list (substring newsgroups
10456 0 (match-beginning 0)))
10458 (setq newsgroups (substring newsgroups (match-end 0))))
10459 (setq groups (nreverse (cons (list newsgroups) groups)))
10462 (completing-read "Followups to: (default all groups) "
10464 (if (> (length to) 0)
10466 (goto-char (point-min))
10467 (insert "Followup-To: " to "\n")))))))
10469 ;; Cleanup Followup-To.
10470 (goto-char (point-min))
10471 (if (search-forward-regexp "^Followup-To: +" nil t)
10475 (if (re-search-forward "^[^ \t]" nil 'end)
10476 (match-beginning 0)
10478 (goto-char (point-min))
10479 (replace-regexp "\n[ \t]+" " ") ;No line breaks (too confusing)
10480 (goto-char (point-min))
10481 (replace-regexp "[ \t\n]*,[ \t\n]*\\|[ \t]+" ",")))
10483 ;; Mail the message too if To:, Bcc:. or Cc: exists.
10484 (if (or (mail-fetch-field "to" nil t)
10485 (mail-fetch-field "bcc" nil t)
10486 (mail-fetch-field "cc" nil t))
10487 (if gnus-mail-send-method
10491 (message "Sending via mail...")
10493 (if gnus-mail-courtesy-message
10495 ;; Insert "courtesy" mail message.
10497 (re-search-forward mail-header-separator)
10499 (insert gnus-mail-courtesy-message)
10500 (funcall gnus-mail-send-method)
10502 (search-forward gnus-mail-courtesy-message)
10503 (replace-match ""))
10504 (funcall gnus-mail-send-method))
10506 (message "Sending via mail... done")
10510 1 (re-search-forward mail-header-separator))
10512 (delete-matching-lines "BCC:.*")))
10514 (message "No mailer defined. To: and/or Cc: fields ignored.")
10517 ;; Send to NNTP server.
10518 (message "Posting to USENET...")
10519 (if (gnus-inews-article use-group-method)
10521 (message "Posting to USENET... done")
10523 (get-buffer (car reply))
10524 (buffer-name (car reply)))
10527 (set-buffer gnus-summary-buffer)
10528 (gnus-summary-mark-article-as-replied
10530 ;; We cannot signal an error.
10531 (ding) (message "Article rejected: %s"
10532 (gnus-status-message gnus-select-method)))
10533 (set-buffer-modified-p nil))
10534 ;; If NNTP server is opened by gnus-inews-news, close it by myself.
10536 (gnus-close-server (gnus-find-method-for-group gnus-newsgroup-name)))
10537 (and (fboundp 'bury-buffer) (bury-buffer))
10538 ;; Restore last window configuration.
10539 (and gnus-winconf-post-news
10540 (set-window-configuration gnus-winconf-post-news))
10541 (setq gnus-winconf-post-news nil))))
10543 (defun gnus-inews-check-post ()
10544 "Check whether the post looks ok."
10546 ;; Check excessive size.
10547 (if (> (buffer-size) 60000)
10548 (gnus-y-or-n-p (format "The article is %d octets long. Really post? "
10551 ;; Check for commands in Subject.
10554 (goto-char (point-min))
10555 (narrow-to-region (point) (search-forward mail-header-separator))
10556 (if (string-match "^cmsg " (mail-fetch-field "subject"))
10558 "The control code \"cmsg \" is in the subject. Really post? ")
10560 ;; Check for control characters.
10562 (if (re-search-forward "[\000-\007\013\015-\037\200-\237]" nil t)
10564 "The article contains control characters. Really post? ")
10566 ;; Check for multiple identical headers.
10570 (goto-char (point-min))
10571 (narrow-to-region (point) (search-forward mail-header-separator))
10572 (goto-char (point-min))
10573 (while (and (not found) (re-search-forward "^[^ \t:]+: " nil t))
10575 (or (re-search-forward
10576 (concat "^" (setq found
10577 (buffer-substring (match-beginning 0)
10580 (setq found nil))))
10583 (format "Multiple %s headers. Really post? " found))
10585 ;; Check for version and sendsys.
10588 (goto-char (point-min))
10589 (narrow-to-region (point) (search-forward mail-header-separator))
10590 (if (re-search-backward "^Sendsys:\\|^Version:" nil t)
10592 (format "The article contains a %s command. Really post? "
10593 (buffer-substring (match-beginning 0) (match-end 0))))
10597 (goto-char (point-min))
10598 (narrow-to-region (point) (search-forward mail-header-separator))
10599 (let* ((case-fold-search t)
10600 (from (mail-fetch-field "from")))
10602 (string-match "@" from)
10603 (not (string-match "@[^\\.]*\\." from)))
10605 (format "The domain looks strange: \"%s\". Really post? "
10608 ;; Use the (size . checksum) variable to see whether the
10609 ;; article is empty or has only quoted text.
10610 (if (and (= (buffer-size) (car gnus-article-check-size))
10611 (= (gnus-article-checksum) (cdr gnus-article-check-size)))
10613 "It looks like there's no new text in your article. Really post? ")
10616 (defun gnus-article-checksum ()
10619 (while (not (eobp))
10620 (setq sum (logxor sum (following-char)))
10624 (defun gnus-cancel-news ()
10625 "Cancel an article you posted."
10627 (if (gnus-yes-or-no-p "Do you really want to cancel this article? ")
10631 (distribution nil))
10633 ;; Get header info. from original article.
10635 (gnus-article-show-all-headers)
10636 (goto-char (point-min))
10637 (search-forward "\n\n" nil 'move)
10638 (narrow-to-region (point-min) (point))
10639 (setq from (mail-fetch-field "from"))
10640 (setq newsgroups (mail-fetch-field "newsgroups"))
10641 (setq message-id (mail-fetch-field "message-id"))
10642 (setq distribution (mail-fetch-field "distribution")))
10643 ;; Verify if the article is absolutely user's by comparing
10644 ;; user id with value of its From: field.
10647 (downcase (mail-strip-quoted-names from))
10648 (downcase (mail-strip-quoted-names (gnus-inews-user-name)))))
10650 (ding) (message "This article is not yours."))
10651 ;; Make control article.
10652 (set-buffer (get-buffer-create " *Gnus-canceling*"))
10653 (buffer-disable-undo (current-buffer))
10655 (insert "Newsgroups: " newsgroups "\n"
10656 "Subject: cancel " message-id "\n"
10657 "Control: cancel " message-id "\n"
10658 mail-header-separator "\n"
10659 "This is a cancel message from " from ".\n")
10660 ;; Send the control article to NNTP server.
10661 (message "Canceling your article...")
10662 (if (gnus-inews-article)
10663 (message "Canceling your article... done")
10664 (ding) (message "Failed to cancel your article"))
10665 ;; Kill the article buffer.
10666 (kill-buffer (current-buffer)))))))
10669 ;;; Lowlevel inews interface
10671 (defun gnus-inews-article (&optional use-group-method)
10672 "Post an article in current buffer using NNTP protocol."
10673 (let ((artbuf (current-buffer))
10674 (tmpbuf (get-buffer-create " *Gnus-posting*")))
10676 (goto-char (point-max))
10677 ;; require a newline at the end for inews to append .signature to
10678 (or (= (preceding-char) ?\n)
10680 ;; Prepare article headers. All message body such as signature
10681 ;; must be inserted before Lines: field is prepared.
10683 (goto-char (point-min))
10687 (search-forward (concat "\n" mail-header-separator "\n"))
10690 (gnus-inews-insert-headers)
10691 (run-hooks gnus-inews-article-header-hook)
10694 (set-buffer tmpbuf)
10695 (buffer-disable-undo (current-buffer))
10697 (insert-buffer-substring artbuf)
10698 ;; Remove the header separator.
10699 (goto-char (point-min))
10700 (search-forward (concat "\n" mail-header-separator "\n"))
10701 (replace-match "\n\n")
10702 ;; This hook may insert a signature.
10703 (run-hooks 'gnus-prepare-article-hook)
10704 ;; Run final inews hooks. This hook may do FCC.
10705 ;; The article must be saved before being posted because
10706 ;; `gnus-request-post' modifies the buffer.
10707 (run-hooks 'gnus-inews-article-hook)
10708 ;; Post an article to NNTP server.
10709 ;; Return NIL if post failed.
10712 (if use-group-method
10713 (gnus-find-method-for-group gnus-newsgroup-name)
10714 gnus-select-method) use-group-method)
10715 (kill-buffer (current-buffer))))))
10717 (defun gnus-inews-insert-headers ()
10718 "Prepare article headers.
10719 Headers already prepared in the buffer are not modified.
10720 Headers in `gnus-required-headers' will be generated."
10721 (let ((Date (gnus-inews-date))
10722 (Message-ID (gnus-inews-message-id))
10723 (Organization (gnus-inews-organization))
10724 (From (gnus-inews-user-name))
10725 (Path (gnus-inews-path))
10729 (Lines (gnus-inews-lines))
10730 (X-Newsreader gnus-version)
10731 (headers gnus-required-headers)
10732 (case-fold-search t)
10734 ;; First we remove any old Message-IDs. This might be slightly
10735 ;; fascist, but if the user really wants to generate Message-IDs
10736 ;; by herself, she should remove it from the `gnus-required-list'.
10737 (goto-char (point-min))
10738 (and (memq 'Message-ID headers)
10739 (re-search-forward "^Message-ID:" nil t)
10740 (delete-region (progn (beginning-of-line) (point))
10741 (progn (forward-line 1) (point))))
10742 ;; Remove NNTP-posting-host.
10743 (goto-char (point-min))
10744 (and (re-search-forward "nntp-posting-host^:" nil t)
10745 (delete-region (progn (beginning-of-line) (point))
10746 (progn (forward-line 1) (point))))
10747 ;; Insert new Sender if the From is strange.
10748 (let ((from (mail-fetch-field "from")))
10749 (if (and from (not (string= (downcase from) (downcase From))))
10751 (goto-char (point-min))
10752 (and (re-search-forward "^Sender:" nil t)
10753 (delete-region (progn (beginning-of-line) (point))
10754 (progn (forward-line 1) (point))))
10755 (insert "Sender: " From "\n"))))
10756 ;; If there are References, and no "Re: ", then the thread has
10757 ;; changed name. See Son-of-1036.
10758 (if (and (mail-fetch-field "references")
10759 (get-buffer gnus-article-buffer))
10760 (let ((psubject (gnus-simplify-subject-re
10761 (mail-fetch-field "subject")))
10764 (set-buffer (get-buffer gnus-article-buffer))
10766 (gnus-narrow-to-headers)
10767 (if (setq subject (mail-fetch-field "subject"))
10769 (and gnus-summary-gather-subject-limit
10770 (> (length subject) gnus-summary-gather-subject-limit)
10772 (substring subject 0
10773 gnus-summary-gather-subject-limit)))
10774 (setq subject (gnus-simplify-subject-re subject))))))
10775 (or (and psubject subject (string= subject psubject))
10777 (string-match "@" Message-ID)
10779 (concat (substring Message-ID 0 (match-beginning 0))
10781 (substring Message-ID (match-beginning 0))))))))
10782 ;; Go through all the required headers and see if they are in the
10783 ;; articles already. If they are not, or are empty, they are
10784 ;; inserted automatically - except for Subject, Newsgroups and
10787 (goto-char (point-min))
10788 (setq header (car headers))
10789 (if (or (not (re-search-forward
10790 (concat "^" (downcase (symbol-name header)) ":") nil t))
10792 (if (= (following-char) ? ) (forward-char 1) (insert " "))
10793 (looking-at "[ \t]*$")))
10795 (setq value (or (and (boundp header) (symbol-value header))
10796 (read-from-minibuffer
10797 (format "Empty header for %s; enter value: "
10801 (goto-char (point-max))
10802 (insert (symbol-name header) ": " value "\n"))
10803 (replace-match value))))
10804 (setq headers (cdr headers)))))
10806 (defun gnus-inews-insert-signature ()
10807 "Insert a signature file.
10808 If `gnus-signature-function' is bound and returns a string, this
10809 string is used instead of the variable `gnus-signature-file'.
10810 In either case, if the string is a file name, this file is
10811 inserted. If the string is not a file name, the string itself is
10813 If you never want any signature inserted, set both those variables to
10817 (or (and gnus-signature-function
10818 (fboundp gnus-signature-function)
10819 (funcall gnus-signature-function gnus-newsgroup-name))
10820 gnus-signature-file))
10823 (or (file-exists-p signature)
10824 (string-match " " signature)
10826 "^/[^/]+/" (expand-file-name signature)))))
10828 (goto-char (point-max))
10829 ;; Delete any previous signatures.
10830 (if (and mail-signature (search-backward "\n-- \n" nil t))
10831 (delete-region (1+ (point)) (point-max)))
10833 (and (< 4 (setq b (count-lines
10836 (if (file-exists-p signature)
10837 (insert-file-contents signature)
10838 (insert signature))
10839 (goto-char (point-max))
10840 (or (bolp) (insert "\n"))
10842 (not gnus-expert-user)
10846 "Your .sig is %d lines; it should be max 4. Really post? "
10848 (if (file-exists-p signature)
10849 (error (format "Edit %s." signature))
10850 (error "Trim your signature."))))))))
10852 (defun gnus-inews-do-fcc ()
10853 "Process FCC: fields in current article buffer.
10854 Unless the first character of the field is `|', the article is saved
10855 to the specified file using the function specified by the variable
10856 gnus-author-copy-saver. The default function rmail-output saves in
10857 Unix mailbox format.
10858 If the first character is `|', the contents of the article is send to
10859 a program specified by the rest of the value."
10860 (let ((fcc-list nil)
10862 (case-fold-search t)) ;Should ignore case.
10865 (goto-char (point-min))
10866 (search-forward "\n\n")
10867 (narrow-to-region (point-min) (point))
10868 (goto-char (point-min))
10869 (while (re-search-forward "^FCC:[ \t]*" nil t)
10871 (cons (buffer-substring
10875 (skip-chars-backward " \t")
10878 (delete-region (match-beginning 0)
10879 (progn (forward-line 1) (point))))
10880 ;; Process FCC operations.
10883 (setq fcc-file (car fcc-list))
10884 (setq fcc-list (cdr fcc-list))
10885 (cond ((string-match "^[ \t]*|[ \t]*\\(.*\\)[ \t]*$" fcc-file)
10886 (let ((program (substring fcc-file
10887 (match-beginning 1) (match-end 1))))
10888 ;; Suggested by yuki@flab.fujitsu.junet.
10889 ;; Send article to named program.
10890 (call-process-region (point-min) (point-max) shell-file-name
10891 nil nil nil "-c" program)))
10893 ;; Suggested by hyoko@flab.fujitsu.junet.
10894 ;; Save article in Unix mail format by default.
10895 (if (and gnus-author-copy-saver
10896 (not (eq gnus-author-copy-saver 'rmail-output)))
10897 (funcall gnus-author-copy-saver fcc-file)
10898 (if (and (file-readable-p fcc-file) (rmail-file-p fcc-file))
10899 (gnus-output-to-rmail fcc-file)
10900 (rmail-output fcc-file 1 t t))))))))))
10902 (defun gnus-inews-path ()
10903 "Return uucp path."
10904 (let ((login-name (gnus-inews-login-name)))
10905 (cond ((null gnus-use-generic-path)
10906 (concat (nth 1 gnus-select-method) "!" login-name))
10907 ((stringp gnus-use-generic-path)
10908 ;; Support GENERICPATH. Suggested by vixie@decwrl.dec.com.
10909 (concat gnus-use-generic-path "!" login-name))
10912 (defun gnus-inews-user-name ()
10913 "Return user's network address as \"NAME@DOMAIN (FULL-NAME)\"."
10914 (let ((full-name (gnus-inews-full-name)))
10915 (concat (if (or gnus-user-login-name gnus-use-generic-from
10916 gnus-local-domain (getenv "DOMAINNAME"))
10917 (concat (gnus-inews-login-name) "@"
10918 (gnus-inews-domain-name gnus-use-generic-from))
10920 ;; User's full name.
10921 (cond ((string-equal full-name "") "")
10922 ((string-equal full-name "&") ;Unix hack.
10923 (concat " (" (user-login-name) ")"))
10925 (concat " (" full-name ")"))))))
10927 (defun gnus-inews-login-name ()
10928 "Return login name."
10929 (or gnus-user-login-name (getenv "LOGNAME") (user-login-name)))
10931 (defun gnus-inews-full-name ()
10932 "Return full user name."
10933 (or gnus-user-full-name (getenv "NAME") (user-full-name)))
10935 (defun gnus-inews-domain-name (&optional genericfrom)
10936 "Return user's domain name.
10937 If optional argument GENERICFROM is a string, use it as the domain
10938 name; if it is non-nil, strip off local host name from the domain name.
10939 If the function `system-name' returns full internet name and the
10940 domain is undefined, the domain name is got from it."
10941 (if (or genericfrom gnus-local-domain (getenv "DOMAINNAME"))
10942 (let* ((system-name (system-name))
10944 (or (if (stringp genericfrom) genericfrom)
10945 (getenv "DOMAINNAME")
10947 ;; Function `system-name' may return full internet name.
10948 ;; Suggested by Mike DeCorte <mrd@sun.soe.clarkson.edu>.
10949 (if (string-match "\\." system-name)
10950 (substring system-name (match-end 0)))
10951 (read-string "Domain name (no host): ")))
10952 (host (or (if (string-match "\\." system-name)
10953 (substring system-name 0 (match-beginning 0)))
10955 (if (string-equal "." (substring domain 0 1))
10956 (setq domain (substring domain 1)))
10957 ;; Support GENERICFROM as same as standard Bnews system.
10958 ;; Suggested by ohm@kaba.junet and vixie@decwrl.dec.com.
10959 (cond ((null genericfrom)
10960 (concat host "." domain))
10961 ;;((stringp genericfrom) genericfrom)
10963 (if (string-match "\\." (system-name))
10965 (substring user-mail-address
10966 (1+ (string-match "@" user-mail-address))))))
10968 (defun gnus-inews-full-address ()
10969 (let ((domain (gnus-inews-domain-name))
10970 (system (system-name))
10971 (case-fold-search t))
10972 (if (string-match "\\." system) system
10973 (if (string-match (concat "^" (regexp-quote system)) domain) domain
10974 (concat system "." domain)))))
10976 (defun gnus-inews-message-id ()
10977 "Generate unique Message-ID for user."
10978 ;; Message-ID should not contain a slash and should be terminated by
10979 ;; a number. I don't know the reason why it is so.
10980 (concat "<" (gnus-inews-unique-id) "@" (gnus-inews-full-address) ">"))
10982 (defun gnus-inews-unique-id ()
10983 "Generate unique ID from user name and current time."
10984 (concat (downcase (gnus-inews-login-name))
10986 (lambda (num) (gnus-number-base-x num 3 31))
10987 (current-time) "")))
10989 (defun gnus-inews-date ()
10990 "Current time string."
10991 (timezone-make-date-arpa-standard
10992 (current-time-string) (current-time-zone)))
10994 (defun gnus-inews-organization ()
10995 "Return user's organization.
10996 The ORGANIZATION environment variable is used if defined.
10997 If not, the variable `gnus-local-organization' is used instead.
10998 If it is a function, the function will be called with the current
10999 newsgroup name as the argument.
11000 If this is a file name, the contents of this file will be used as the
11002 (let* ((organization
11003 (or (getenv "ORGANIZATION")
11004 (if gnus-local-organization
11005 (if (and (symbolp gnus-local-organization)
11006 (fboundp gnus-local-organization))
11007 (funcall gnus-local-organization gnus-newsgroup-name)
11008 gnus-local-organization))
11009 gnus-organization-file
11010 "~/.organization")))
11011 (and (stringp organization)
11012 (> (length organization) 0)
11013 (or (file-exists-p organization)
11014 (string-match " " organization)
11015 (not (string-match "^/[^/]+/" (expand-file-name organization))))
11017 (set-buffer (get-buffer-create " *Gnus organization*"))
11018 (buffer-disable-undo (current-buffer))
11020 (if (file-exists-p organization)
11021 (insert-file-contents organization)
11022 (insert organization))
11023 (goto-char (point-min))
11024 (while (re-search-forward " *\n *" nil t)
11025 (replace-match " "))
11026 (buffer-substring (point-min) (point-max))))))
11028 (defun gnus-inews-lines ()
11029 "Count the number of lines and return numeric string."
11033 (goto-char (point-min))
11034 (search-forward "\n\n" nil 'move)
11035 (int-to-string (count-lines (point) (point-max))))))
11039 ;;; Gnus Mail Functions
11042 ;;; Mail reply commands of Gnus summary mode
11044 (defun gnus-summary-reply (yank)
11045 "Reply mail to news author.
11046 If prefix argument YANK is non-nil, original article is yanked automatically.
11047 Customize the variable gnus-mail-reply-method to use another mailer."
11049 ;; Bug fix by jbw@bigbird.bu.edu (Joe Wells)
11050 ;; Stripping headers should be specified with mail-yank-ignored-headers.
11051 (gnus-summary-select-article t)
11052 (setq gnus-winconf-post-news (current-window-configuration))
11053 (let ((gnus-newsgroup-name gnus-newsgroup-name))
11054 (bury-buffer gnus-article-buffer)
11055 (funcall gnus-mail-reply-method yank)))
11057 (defun gnus-summary-reply-with-original ()
11058 "Reply mail to news author with original article.
11059 Customize the variable gnus-mail-reply-method to use another mailer."
11061 (gnus-summary-reply t))
11063 (defun gnus-summary-mail-forward ()
11064 "Forward the current message to another user.
11065 Customize the variable gnus-mail-forward-method to use another mailer."
11067 (gnus-summary-select-article t)
11068 (setq gnus-winconf-post-news (current-window-configuration))
11069 (set-buffer gnus-article-buffer)
11070 (let ((gnus-newsgroup-name gnus-newsgroup-name))
11071 (funcall gnus-mail-forward-method)))
11073 (defun gnus-summary-mail-other-window ()
11074 "Compose mail in other window.
11075 Customize the variable `gnus-mail-other-window-method' to use another
11078 (setq gnus-winconf-post-news (current-window-configuration))
11079 (let ((gnus-newsgroup-name gnus-newsgroup-name))
11080 (funcall gnus-mail-other-window-method)))
11082 (defun gnus-mail-reply-using-mail (&optional yank to-address)
11084 (set-buffer gnus-summary-buffer)
11085 (let ((info (nth 2 (gnus-gethash gnus-newsgroup-name gnus-newsrc-hashtb)))
11086 (group (gnus-group-real-name gnus-newsgroup-name))
11087 (cur (cons (current-buffer) (cdr gnus-article-current)))
11088 from subject date to reply-to message-of
11089 references message-id sender follow-to cc)
11090 (set-buffer (get-buffer-create "*mail*"))
11092 (make-local-variable 'gnus-article-reply)
11093 (setq gnus-article-reply cur)
11094 (use-local-map (copy-keymap mail-mode-map))
11095 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
11096 (if (and (buffer-modified-p)
11097 (> (buffer-size) 0)
11098 (not (gnus-y-or-n-p
11099 "Unsent article being composed; erase it? ")))
11103 (set-buffer gnus-article-buffer)
11104 (let ((buffer-read-only nil))
11105 (goto-char (point-min))
11106 (narrow-to-region (point-min)
11107 (progn (search-forward "\n\n") (point)))
11108 (add-text-properties (point-min) (point-max) '(invisible nil)))
11109 (if (and (boundp 'gnus-reply-to-function)
11110 gnus-reply-to-function)
11113 (gnus-narrow-to-headers)
11114 (setq follow-to (funcall gnus-reply-to-function group)))))
11115 (setq from (mail-fetch-field "from"))
11116 (setq date (mail-fetch-field "date"))
11119 (string-match " *at \\| *@ \\| *(\\| *<" from)))
11121 (concat (if stop-pos (substring from 0 stop-pos) from)
11122 "'s message of " date))))
11123 (setq sender (mail-fetch-field "sender"))
11124 (setq subject (or (mail-fetch-field "subject")
11126 (or (string-match "^[Rr][Ee]:" subject)
11127 (setq subject (concat "Re: " subject)))
11128 (setq cc (mail-fetch-field "cc"))
11129 (setq reply-to (mail-fetch-field "reply-to"))
11130 (setq references (mail-fetch-field "references"))
11131 (setq message-id (mail-fetch-field "message-id"))
11133 (setq news-reply-yank-from from)
11134 (setq news-reply-yank-message-id message-id)
11135 (mail-setup (or to-address follow-to reply-to from sender "")
11136 subject message-of nil gnus-article-buffer nil)
11137 ;; Fold long references line to follow RFC1036.
11138 (mail-position-on-field "References")
11139 (let ((begin (- (point) (length "References: ")))
11141 (fill-prefix "\t"))
11142 (if references (insert references))
11143 (if (and references message-id) (insert " "))
11144 (if message-id (insert message-id))
11145 ;; The region must end with a newline to fill the region
11146 ;; without inserting extra newline.
11147 (fill-region-as-paragraph begin (1+ (point))))
11148 (goto-char (point-min))
11149 (search-forward (concat "\n" mail-header-separator "\n"))
11151 (let ((last (point)))
11152 (run-hooks 'news-reply-header-hook)
11153 (mail-yank-original nil)
11154 (goto-char last))))
11156 (let ((mail (current-buffer)))
11157 (gnus-configure-windows '(0 0 1))
11158 (switch-to-buffer-other-window mail))
11159 (gnus-configure-windows '(0 1 0))
11160 (switch-to-buffer (current-buffer))))))
11162 (defun gnus-mail-yank-original ()
11164 (run-hooks 'news-reply-header-hook)
11165 (mail-yank-original nil))
11167 (defun gnus-mail-send-and-exit ()
11169 (let ((cbuf (current-buffer)))
11170 (mail-send-and-exit nil)
11171 (if (get-buffer gnus-group-buffer)
11175 (let ((reply gnus-article-reply))
11177 (get-buffer (car reply))
11178 (buffer-name (car reply)))
11180 (set-buffer (car reply))
11182 (gnus-summary-mark-article-as-replied
11184 (and gnus-winconf-post-news
11185 (set-window-configuration gnus-winconf-post-news))
11186 (setq gnus-winconf-post-news nil)))))
11188 (defun gnus-mail-forward-using-mail ()
11189 "Forward the current message to another user using mail."
11190 ;; This is almost a carbon copy of rmail-forward in rmail.el.
11191 (let ((forward-buffer (current-buffer))
11193 (concat "[" gnus-newsgroup-name "] "
11194 (or (gnus-fetch-field "Subject") "")))
11196 ;; If only one window, use it for the mail buffer.
11197 ;; Otherwise, use another window for the mail buffer
11198 ;; so that the Rmail buffer remains visible
11199 ;; and sending the mail will get back to it.
11200 (if (if (one-window-p t)
11201 (mail nil nil subject)
11202 (mail-other-window nil nil subject))
11204 (use-local-map (copy-keymap emacs-lisp-mode-map))
11205 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
11206 (setq beg (goto-char (point-max)))
11207 (insert "------- Start of forwarded message -------\n")
11208 (insert-buffer forward-buffer)
11209 (goto-char (point-max))
11210 (insert "------- End of forwarded message -------\n")
11211 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
11213 (while (setq beg (next-single-property-change (point) 'invisible))
11215 (delete-region beg (or (next-single-property-change
11216 (point) 'invisible)
11218 ;; You have a chance to arrange the message.
11219 (run-hooks 'gnus-mail-forward-hook)))))
11221 (defun gnus-mail-other-window-using-mail ()
11222 "Compose mail other window using mail."
11223 (mail-other-window nil nil nil nil nil nil (get-buffer gnus-article-buffer))
11224 (use-local-map (copy-keymap emacs-lisp-mode-map))
11225 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit))
11232 (defvar gnus-dribble-ignore nil)
11234 (defun gnus-dribble-file-name ()
11235 (concat gnus-startup-file "-dribble"))
11237 (defun gnus-dribble-open ()
11240 (setq gnus-dribble-buffer (find-file-noselect (gnus-dribble-file-name))))
11241 (buffer-disable-undo (current-buffer))
11242 (bury-buffer gnus-dribble-buffer)
11244 (goto-char (point-max))))
11246 (defun gnus-dribble-enter (string)
11247 (if (and (not gnus-dribble-ignore)
11248 gnus-dribble-buffer
11249 (buffer-name gnus-dribble-buffer))
11250 (let ((obuf (current-buffer)))
11251 (set-buffer gnus-dribble-buffer)
11252 (insert string "\n")
11253 (set-window-point (get-buffer-window (current-buffer)) (point-max))
11254 (set-buffer obuf))))
11256 (defun gnus-dribble-read-file ()
11257 (let ((dribble-file (gnus-dribble-file-name)))
11259 (set-buffer (setq gnus-dribble-buffer
11261 (file-name-nondirectory dribble-file))))
11262 (gnus-add-current-to-buffer-list)
11264 (set-visited-file-name dribble-file)
11265 (buffer-disable-undo (current-buffer))
11266 (bury-buffer (current-buffer))
11267 (set-buffer-modified-p nil)
11268 (let ((auto (make-auto-save-file-name))
11269 (gnus-dribble-ignore t))
11270 (if (or (file-exists-p auto) (file-exists-p dribble-file))
11272 (if (file-newer-than-file-p auto dribble-file)
11273 (setq dribble-file auto))
11274 (insert-file-contents dribble-file)
11275 (if (not (zerop (buffer-size)))
11276 (set-buffer-modified-p t))
11278 "Auto-save file exists. Do you want to read it? ")
11280 (message "Reading %s..." dribble-file)
11281 (eval-current-buffer)
11282 (message "Reading %s...done" dribble-file)))))))))
11284 (defun gnus-dribble-delete-file ()
11285 (if (file-exists-p (gnus-dribble-file-name))
11286 (delete-file (gnus-dribble-file-name)))
11287 (if gnus-dribble-buffer
11289 (set-buffer gnus-dribble-buffer)
11290 (let ((auto (make-auto-save-file-name)))
11291 (if (file-exists-p auto)
11292 (delete-file auto))
11294 (set-buffer-modified-p nil)))))
11296 (defun gnus-dribble-save ()
11297 (if (and gnus-dribble-buffer
11298 (buffer-name gnus-dribble-buffer))
11300 (set-buffer gnus-dribble-buffer)
11303 (defun gnus-dribble-clear ()
11305 (if (and gnus-dribble-buffer
11306 (buffer-name (get-buffer gnus-dribble-buffer)))
11308 (set-buffer gnus-dribble-buffer)
11310 (set-buffer-modified-p nil)
11311 (setq buffer-saved-size (buffer-size))))))
11314 ;;; Server Communication
11317 ;; All the Gnus backends have the same interface, and should return
11318 ;; data in a similar format. Below is an overview of what functions
11319 ;; these packages must supply and what results they should return.
11323 ;; `nntp-server-buffer' - All data should be returned to Gnus in this
11326 ;; Functions for the imaginary backend `choke':
11328 ;; `choke-retrieve-headers ARTICLES &optional GROUP SERVER'
11329 ;; Should return all headers for all ARTICLES, or return NOV lines for
11332 ;; `choke-request-group GROUP &optional SERVER DISCARD'
11333 ;; Switch to GROUP. If DISCARD is nil, active information on the group
11334 ;; must be returned.
11336 ;; `choke-close-group GROUP &optional SERVER'
11337 ;; Close group. Most backends won't have to do anything with this
11338 ;; call, but it is an opportunity to clean up, if that is needed. It
11339 ;; is called when Gnus exits a group.
11341 ;; `choke-request-article ARTICLE &optional GROUP SERVER'
11342 ;; Return ARTICLE, which is either an article number or
11343 ;; message-id. Note that not all backends can return articles based on
11346 ;; `choke-request-list SERVER'
11347 ;; Return a list of all newsgroups on SERVER.
11349 ;; `choke-request-list-newsgroups SERVER'
11350 ;; Return a list of descriptions of all newsgroups on SERVER.
11352 ;; `choke-request-newgroups DATE &optional SERVER'
11353 ;; Return a list of all groups that have arrived after DATE on
11354 ;; SERVER. Note that the date doesn't have to be respected - Gnus will
11355 ;; always check whether the groups are old or not. Backends that do
11356 ;; not store date information may just return the entire list of
11357 ;; groups, although this might not be a good idea in general.
11359 ;; `choke-request-post-buffer METHOD HEADER ARTICLE-BUFFER GROUP INFO'
11360 ;; Should return a buffer that is suitable for "posting". nnspool and
11361 ;; nntp return a `*post-buffer*', and nnmail return a `*mail*'
11362 ;; buffer. This function should fill out the appropriate headers.
11364 ;; `choke-request-post &optional SERVER'
11365 ;; Function that will be called from a buffer to be posted.
11367 ;; `choke-open-server SERVER &optional ARGUMENT'
11368 ;; Open a connection to SERVER.
11370 ;; `choke-close-server &optional SERVER'
11371 ;; Close the connection to SERVER.
11373 ;; `choke-server-opened &optional SERVER'
11374 ;; Whether the conenction to SERVER is opened or not.
11376 ;; `choke-server-status &optional SERVER'
11377 ;; Should return a status string (not in the nntp buffer, but as the
11378 ;; result of the function).
11380 ;; The following functions are optional and apply only to backends
11381 ;; that are able to control the contents of their groups totally
11382 ;; (ie. mail backends.) Backends that aren't able to do that
11383 ;; shouldn't define these functions at all. Gnus will check for their
11384 ;; presence before attempting to call them.
11386 ;; `choke-request-expire-articles ARTICLES &optional NEWSGROUP SERVER'
11387 ;; Should expire (according to some aging scheme) all ARTICLES. Most
11388 ;; backends will not be able to expire articles. Should return a list
11389 ;; of all articles that were not expired.
11391 ;; `choke-request-move-article ARTICLE GROUP SERVER ACCEPT-FORM &optional LAST'
11392 ;; Should move ARTICLE from GROUP on SERVER by using ACCEPT-FORM.
11393 ;; Removes any information it has added to the article (extra headers,
11394 ;; whatever - make it as clean as possible), and then passes the
11395 ;; article on by evaling ACCEPT-FORM, which is normally a call to the
11396 ;; function described below. If the ACCEPT-FORM returns a non-nil
11397 ;; value, the article should then be deleted. If LAST is nil, that
11398 ;; means that there will be further calls to this function. This might
11399 ;; be taken as an advice not to save buffers/internal variables just
11400 ;; yet, but wait until the last call to speed things up.
11402 ;; `choke-request-accept-article GROUP &optional LAST'
11403 ;; The contents of the current buffer will be put into GROUP. There
11404 ;; should, of course, be an article in the current buffer. This
11405 ;; function is normally only called by the function described above,
11406 ;; and LAST works the same way as in that function.
11408 ;; `choke-request-replace-article ARTICLE GROUP BUFFER'
11409 ;; Replace ARTICLE in GROUP with the contents of BUFFER.
11410 ;; This provides an easy interface for allowing editing of
11411 ;; articles. Note that even headers may be edited, so the backend has
11412 ;; to update any tables (nov buffers, etc) that it maintains after
11413 ;; replacing the article.
11415 ;; All these functions must return nil if they couldn't service the
11416 ;; request. If the optional arguments are not supplied, some "current"
11417 ;; or "default" values should be used. In short, one should emulate an
11418 ;; NNTP server, in a way.
11420 ;; If you want to write a new backend, you just have to supply the
11421 ;; functions listed above. In addition, you must enter the new backend
11422 ;; into the list of valid select methods:
11423 ;; (setq gnus-valid-select-methods
11424 ;; (cons '("choke" mail) gnus-valid-select-methods))
11425 ;; The first element in this list is the name of the backend. Other
11426 ;; elemnets may be `mail' (for mail groups), `post' (for news
11427 ;; groups), `none' (neither), `respool' (for groups that can control
11428 ;; their contents).
11430 (defun gnus-start-news-server (&optional confirm)
11431 "Open a method for getting news.
11432 If CONFIRM is non-nil, the user will be asked for an NNTP server."
11434 (if gnus-current-select-method
11435 ;; Stream is already opened.
11437 ;; Open NNTP server.
11438 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
11441 ;; Read server name with completion.
11442 (setq gnus-nntp-server
11443 (completing-read "NNTP server: "
11444 (mapcar (lambda (server) (list server))
11445 (cons (list gnus-nntp-server)
11446 gnus-secondary-servers))
11447 nil nil gnus-nntp-server))))
11449 (if (and gnus-nntp-server
11450 (stringp gnus-nntp-server)
11451 (not (string= gnus-nntp-server "")))
11452 (setq gnus-select-method
11453 (cond ((or (string= gnus-nntp-server "")
11454 (string= gnus-nntp-server "::"))
11455 (list 'nnspool (system-name)))
11456 ((string-match ":" gnus-nntp-server)
11457 (list 'nnmh gnus-nntp-server))
11459 (list 'nntp gnus-nntp-server)))))
11461 (setq how (car gnus-select-method))
11462 (setq where (car (cdr gnus-select-method)))
11463 (cond ((eq how 'nnspool)
11465 (message "Looking up local news spool..."))
11468 (message "Looking up mh spool..."))
11471 (setq gnus-current-select-method gnus-select-method)
11472 (run-hooks 'gnus-open-server-hook)
11474 ;; gnus-open-server-hook might have opened it
11475 (gnus-server-opened gnus-select-method)
11476 (gnus-open-server gnus-select-method)
11477 (error "%s" (gnus-nntp-message
11478 (format "Cannot open NNTP server on %s"
11480 gnus-select-method)))
11482 (defun gnus-check-news-server (method)
11483 "If the news server is down, start it up again."
11484 (let ((method (if method method gnus-select-method)))
11485 (if (gnus-server-opened method)
11486 ;; Stream is already opened.
11489 (message "Opening server %s on %s..." (car method) (nth 1 method))
11490 (run-hooks 'gnus-open-server-hook)
11491 (or (gnus-server-opened method)
11492 (gnus-open-server method))
11495 (defun gnus-nntp-message (&optional message)
11496 "Check the status of the NNTP server.
11497 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
11498 is returned insted of the status string."
11499 (let ((status (gnus-status-message (gnus-find-method-for-group
11500 gnus-newsgroup-name)))
11501 (message (or message "")))
11502 (if (and (stringp status) (> (length status) 0))
11505 (defun gnus-get-function (method function)
11506 (let ((func (intern (format "%s-%s" (car method) function))))
11507 (if (not (fboundp func))
11509 (require (car method))
11510 (if (not (fboundp func))
11511 (error "No such function: %s" func))))
11514 ;; Specifying port number suggested by Stephane Laveau <laveau@corse.inria.fr>.
11515 (defun gnus-open-server (method)
11516 (apply (gnus-get-function method 'open-server) (cdr method)))
11518 (defun gnus-close-server (method)
11519 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
11521 (defun gnus-request-list (method)
11522 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
11524 (defun gnus-request-list-newsgroups (method)
11525 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
11527 (defun gnus-request-newgroups (date method)
11528 (funcall (gnus-get-function method 'request-newgroups)
11529 date (nth 1 method)))
11531 (defun gnus-server-opened (method)
11532 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
11534 (defun gnus-status-message (method)
11535 (let ((method (if (stringp method) (gnus-find-method-for-group method)
11537 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
11539 (defun gnus-request-group (group &optional dont-check)
11540 (let ((method (gnus-find-method-for-group group)))
11541 (funcall (gnus-get-function method 'request-group)
11542 (gnus-group-real-name group) (nth 1 method) dont-check)))
11544 (defun gnus-request-group-description (group)
11545 (let ((method (gnus-find-method-for-group group))
11546 (func 'request-group-description))
11547 (and (gnus-check-backend-function func group)
11548 (funcall (gnus-get-function method func)
11549 (gnus-group-real-name group) (nth 1 method)))))
11551 (defun gnus-close-group (group)
11552 (let ((method (gnus-find-method-for-group group)))
11553 (funcall (gnus-get-function method 'close-group)
11554 (gnus-group-real-name group) (nth 1 method))))
11556 (defun gnus-retrieve-headers (articles group)
11557 (let ((method (gnus-find-method-for-group group)))
11558 (funcall (gnus-get-function method 'retrieve-headers)
11559 articles (gnus-group-real-name group) (nth 1 method))))
11561 (defun gnus-request-article (article group buffer)
11562 (let ((method (gnus-find-method-for-group group)))
11563 (funcall (gnus-get-function method 'request-article)
11564 article (gnus-group-real-name group) (nth 1 method) buffer)))
11566 (defun gnus-request-head (article group)
11567 (let ((method (gnus-find-method-for-group group)))
11568 (funcall (gnus-get-function method 'request-head)
11569 article (gnus-group-real-name group) (nth 1 method))))
11571 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11572 (defun gnus-request-post-buffer (post group subject header artbuf
11573 info follow-to respect-poster)
11574 (let* ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
11576 (if (and gnus-post-method
11577 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
11579 (format "%s" (car (gnus-find-method-for-group
11580 gnus-newsgroup-name)))
11581 gnus-valid-select-methods)))
11583 (gnus-find-method-for-group gnus-newsgroup-name))))
11584 (let ((mail-self-blind nil)
11585 (mail-archive-file-name nil))
11586 (funcall (gnus-get-function method 'request-post-buffer)
11587 post group subject header artbuf info follow-to
11590 (defun gnus-request-post (method &optional force)
11591 (and (not force) gnus-post-method
11592 (memq 'post (assoc (format "%s" (car method))
11593 gnus-valid-select-methods))
11594 (setq method gnus-post-method))
11595 (funcall (gnus-get-function method 'request-post)
11598 (defun gnus-request-expire-articles (articles group &optional force)
11599 (let ((method (gnus-find-method-for-group group)))
11600 (funcall (gnus-get-function method 'request-expire-articles)
11601 articles (gnus-group-real-name group) (nth 1 method)
11604 (defun gnus-request-move-article
11605 (article group server accept-function &optional last)
11606 (let ((method (gnus-find-method-for-group group)))
11607 (funcall (gnus-get-function method 'request-move-article)
11608 article (gnus-group-real-name group)
11609 (nth 1 method) accept-function last)))
11611 (defun gnus-request-accept-article (group &optional last)
11612 (let ((func (if (symbolp group) group
11613 (car (gnus-find-method-for-group group)))))
11614 (funcall (intern (format "%s-request-accept-article" func))
11615 (if (stringp group) (gnus-group-real-name group) group)
11618 (defun gnus-request-replace-article (article group buffer)
11619 (let ((func (car (gnus-find-method-for-group group))))
11620 (funcall (intern (format "%s-request-replace-article" func))
11621 article (gnus-group-real-name group) buffer)))
11623 (defun gnus-find-method-for-group (group)
11624 (or gnus-override-method
11626 gnus-select-method)
11627 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
11629 (not (nth 4 info)))
11633 (defun gnus-check-backend-function (func group)
11634 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
11636 (fboundp (intern (format "%s-%s" method func)))))
11638 (defun gnus-methods-using (method)
11639 (let ((valids gnus-valid-select-methods)
11642 (if (memq method (car valids))
11643 (setq outs (cons (car valids) outs)))
11644 (setq valids (cdr valids)))
11648 ;;; Active & Newsrc File Handling
11651 ;; Newsrc related functions.
11652 ;; Gnus internal format of gnus-newsrc-assoc:
11653 ;; (("alt.general" 3 (1 . 1))
11654 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
11655 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
11656 ;; The first item is the group name; the second is the subscription
11657 ;; level; the third is either a range of a list of ranges of read
11658 ;; articles, the optional fourth element is a list of marked articles,
11659 ;; the optional fifth element is the select method.
11661 ;; Gnus internal format of gnus-newsrc-hashtb:
11662 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
11663 ;; This is the entry for "alt.misc". The first element is the number
11664 ;; of unread articles in "alt.misc". The cdr of this entry is the
11665 ;; element *before* "alt.misc" in gnus-newsrc-assoc, which makes is
11666 ;; trivial to remove or add new elements into gnus-newsrc-assoc
11667 ;; without scanning the entire list. So, to get the actual information
11668 ;; of "alt.misc", you'd say something like
11669 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
11671 ;; Gnus internal format of gnus-active-hashtb:
11675 ;; The only element in each entry in this hash table is a range of
11676 ;; (possibly) available articles. (Articles in this range may have
11677 ;; been expired or cancelled.)
11679 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
11680 ;; ("alt.misc" "alt.test" "alt.general" ...)
11682 (defun gnus-setup-news (&optional rawfile level)
11683 "Setup news information.
11684 If RAWFILE is non-nil, the .newsrc file will also be read.
11685 If LEVEL is non-nil, the news will be set up at level LEVEL."
11686 (let ((init (not (and gnus-newsrc-assoc gnus-active-hashtb (not rawfile)))))
11687 ;; Clear some variables to re-initialize news information.
11688 (if init (setq gnus-newsrc-assoc nil gnus-active-hashtb nil))
11689 ;; Read the active file and create `gnus-active-hashtb'.
11690 ;; If `gnus-read-active-file' is nil, then we just create an empty
11691 ;; hash table. The partial filling out of the hash table will be
11692 ;; done in `gnus-get-unread-articles'.
11693 (if (and gnus-read-active-file (not level))
11694 (gnus-read-active-file)
11695 (setq gnus-active-hashtb (make-vector 4095 0)))
11697 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
11698 (if init (gnus-read-newsrc-file rawfile))
11699 ;; Find the number of unread articles in each non-dead group.
11700 (gnus-get-unread-articles (or level 6))
11701 ;; Find new newsgroups and treat them.
11702 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level))
11703 (gnus-find-new-newsgroups))
11704 (if (and init gnus-check-bogus-newsgroups
11705 gnus-read-active-file (not level))
11706 (gnus-check-bogus-newsgroups))))
11708 (defun gnus-find-new-newsgroups ()
11709 "Search for new newsgroups and add them.
11710 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
11711 The `-n' option line from .newsrc is respected."
11713 (or (gnus-check-first-time-used)
11714 (if (or (consp gnus-check-new-newsgroups)
11715 (eq gnus-check-new-newsgroups 'ask-server))
11716 (gnus-ask-server-for-new-groups)
11718 group new-newsgroups)
11719 (or gnus-have-read-active-file (gnus-read-active-file))
11720 (setq gnus-newsrc-last-checked-date (current-time-string))
11721 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
11722 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
11723 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
11726 (setq group (symbol-name sym))
11727 (if (or (gnus-gethash group gnus-killed-hashtb)
11728 (gnus-gethash group gnus-newsrc-hashtb))
11730 (if (and gnus-newsrc-options-n-yes
11731 (string-match gnus-newsrc-options-n-yes group))
11733 (setq groups (1+ groups))
11734 (gnus-sethash group group gnus-killed-hashtb)
11735 (funcall gnus-subscribe-options-newsgroup-method group))
11736 (if (or (null gnus-newsrc-options-n-no)
11737 (not (string-match gnus-newsrc-options-n-no group)))
11740 (setq groups (1+ groups))
11741 (gnus-sethash group group gnus-killed-hashtb)
11742 (if gnus-subscribe-hierarchical-interactive
11743 (setq new-newsgroups (cons group new-newsgroups))
11744 (funcall gnus-subscribe-newsgroup-method group)))))))
11745 gnus-active-hashtb)
11747 (gnus-subscribe-hierarchical-interactive new-newsgroups))
11748 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
11750 (message "%d new newsgroup%s arrived."
11751 groups (if (> groups 1) "s have" " has")))))))
11753 (defun gnus-ask-server-for-new-groups ()
11754 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
11755 (methods (cons gnus-select-method
11757 (and (consp gnus-check-new-newsgroups)
11758 gnus-check-new-newsgroups)
11759 gnus-secondary-select-methods)))
11761 (new-date (current-time-string))
11762 hashtb group new-newsgroups got-new)
11763 ;; Go thorugh both primary and secondary select methods and
11764 ;; request new newsgroups.
11766 (if (gnus-request-newgroups date (car methods))
11769 (or hashtb (setq hashtb (gnus-make-hashtable
11770 (count-lines (point-min) (point-max)))))
11771 (set-buffer nntp-server-buffer)
11772 ;; Enter all the new groups in a hashtable.
11773 (gnus-active-to-gnus-format (car methods) hashtb)))
11774 (setq methods (cdr methods)))
11775 (and got-new (setq gnus-newsrc-last-checked-date new-date))
11776 ;; Now all new groups from all select methods are in `hashtb'.
11778 (lambda (group-sym)
11779 (setq group (symbol-name group-sym))
11780 (if (or (gnus-gethash group gnus-newsrc-hashtb)
11781 (member group gnus-zombie-list)
11782 (member group gnus-killed-list))
11783 ;; The group is already known.
11785 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb)
11786 (if (and gnus-newsrc-options-n-yes
11787 (string-match gnus-newsrc-options-n-yes group))
11789 (setq groups (1+ groups))
11790 (funcall gnus-subscribe-options-newsgroup-method group))
11791 (if (or (null gnus-newsrc-options-n-no)
11792 (not (string-match gnus-newsrc-options-n-no group)))
11795 (setq groups (1+ groups))
11796 (if gnus-subscribe-hierarchical-interactive
11797 (setq new-newsgroups (cons group new-newsgroups))
11798 (funcall gnus-subscribe-newsgroup-method group)))))))
11801 (gnus-subscribe-hierarchical-interactive new-newsgroups))
11802 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
11804 (message "%d new newsgroup%s arrived."
11805 groups (if (> groups 1) "s have" " has")))
11808 (defun gnus-check-first-time-used ()
11809 (if (or (> (length gnus-newsrc-assoc) 1)
11810 (file-exists-p gnus-startup-file)
11811 (file-exists-p (concat gnus-startup-file ".el"))
11812 (file-exists-p (concat gnus-startup-file ".eld")))
11814 (message "First time user; subscribing you to default groups")
11815 (or gnus-have-read-active-file (gnus-read-active-file))
11816 (setq gnus-newsrc-last-checked-date (current-time-string))
11817 (let ((groups gnus-default-subscribed-newsgroups)
11821 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
11824 (setq group (symbol-name sym))
11825 (if (and gnus-newsrc-options-n-yes
11826 (string-match gnus-newsrc-options-n-yes group))
11827 (funcall gnus-subscribe-options-newsgroup-method group)
11828 (and (or (null gnus-newsrc-options-n-no)
11829 (not (string-match gnus-newsrc-options-n-no group)))
11830 (setq gnus-killed-list (cons group gnus-killed-list)))))
11831 gnus-active-hashtb)
11833 (if (gnus-gethash (car groups) gnus-active-hashtb)
11834 (gnus-group-change-level (car groups) 3 9))
11835 (setq groups (cdr groups)))
11836 (gnus-group-make-help-group)
11837 (and gnus-novice-user
11838 (message (substitute-command-keys "\\<gnus-group-mode-map>\\[gnus-group-list-killed] to list killed groups")))))))
11840 ;; `gnus-group-change-level' is the fundamental function for changing
11841 ;; subscription levels of newsgroups. This might mean just changing
11842 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
11843 ;; again, which subscribes/unsubscribes a group, which is equally
11844 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
11845 ;; from 8-9 to 1-7 means that you remove the group from the list of
11846 ;; killed (or zombie) groups and add them to the (kinda) subscribed
11847 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
11848 ;; which is trivial.
11849 ;; ENTRY can either be a string (newsgroup name) or a list (if
11850 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
11851 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
11853 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
11854 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
11856 (defun gnus-group-change-level (entry level &optional oldlevel
11857 previous fromkilled)
11858 (let ((pinfo entry)
11859 group info active num)
11860 ;; Glean what info we can from the arguments
11862 (if fromkilled (setq group (nth 1 entry))
11863 (setq group (car (nth 2 entry))))
11864 (setq group entry))
11865 (if (and (stringp entry)
11868 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
11869 (if (and (not oldlevel)
11871 (setq oldlevel (car (cdr (nth 2 entry)))))
11872 (if (stringp previous)
11873 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
11875 (gnus-dribble-enter
11876 (format "(gnus-group-change-level %S %S %S %S %S)"
11877 group level oldlevel (car (nth 2 previous)) fromkilled))
11879 ;; Then we remove the newgroup from any old structures, if needed.
11880 ;; If the group was killed, we remove it from the killed or zombie
11881 ;; list. If not, and it is in fact going to be killed, we remove
11882 ;; it from the newsrc hash table and assoc.
11883 (cond ((>= oldlevel 8)
11885 (setq gnus-zombie-list (delete group gnus-zombie-list))
11886 (setq gnus-killed-list (delete group gnus-killed-list))))
11890 (gnus-sethash (car (nth 2 entry))
11891 nil gnus-newsrc-hashtb)
11893 (setcdr (gnus-gethash (car (nth 3 entry))
11894 gnus-newsrc-hashtb)
11896 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
11898 ;; Finally we enter (if needed) the list where it is supposed to
11899 ;; go, and change the subscription level. If it is to be killed,
11900 ;; we enter it into the killed or zombie list.
11901 (cond ((>= level 8)
11903 (setq gnus-zombie-list (cons group gnus-zombie-list))
11904 (setq gnus-killed-list (cons group gnus-killed-list))))
11906 ;; If the list is to be entered into the newsrc assoc, and
11907 ;; it was killed, we have to create an entry in the newsrc
11908 ;; hashtb format and fix the pointers in the newsrc assoc.
11909 (if (>= oldlevel 8)
11913 (setq info (cdr entry))
11914 (setq num (car entry)))
11915 (setq active (gnus-gethash group gnus-active-hashtb))
11916 (setq num (if active (- (1+ (cdr active)) (car active)) t))
11917 ;; Check whether the group is foreign. If so, the
11918 ;; foreign select method has to be entered into the
11920 (let ((method (gnus-group-method-name group)))
11921 (if (eq method gnus-select-method)
11922 (setq info (list group level nil))
11923 (setq info (list group level nil nil method)))))
11924 (setq entry (cons info (if previous (cdr (cdr previous))
11925 (cdr gnus-newsrc-assoc))))
11926 (setcdr (if previous (cdr previous) gnus-newsrc-assoc)
11928 (gnus-sethash group (cons num (if previous (cdr previous)
11929 gnus-newsrc-assoc))
11930 gnus-newsrc-hashtb)
11932 (setcdr (gnus-gethash (car (car (cdr entry)))
11933 gnus-newsrc-hashtb)
11935 ;; It was alive, and it is going to stay alive, so we
11936 ;; just change the level and don't change any pointers or
11937 ;; hash table entries.
11938 (setcar (cdr (car (cdr (cdr entry)))) level))))))
11940 (defun gnus-kill-newsgroup (newsgroup)
11941 "Obsolete function. Kills a newsgroup."
11942 (gnus-group-change-level (gnus-gethash newsgroup gnus-newsrc-hashtb) 9))
11944 (defun gnus-check-bogus-newsgroups (&optional confirm)
11945 "Remove bogus newsgroups.
11946 If CONFIRM is non-nil, the user has to confirm the deletion of every
11948 (let ((newsrc (cdr gnus-newsrc-assoc))
11950 (message "Checking bogus newsgroups...")
11951 (or gnus-have-read-active-file (gnus-read-active-file))
11952 ;; Find all bogus newsgroup that are subscribed.
11954 (setq group (car (car newsrc)))
11955 (if (or (gnus-gethash group gnus-active-hashtb)
11956 (nth 4 (car newsrc))
11958 (not (gnus-y-or-n-p
11959 (format "Remove bogus newsgroup: %s " group)))))
11960 ;; Active newsgroup.
11962 ;; Found a bogus newsgroup.
11963 (setq bogus (cons group bogus)))
11964 (setq newsrc (cdr newsrc)))
11965 ;; Remove all bogus subscribed groups by first killing them, and
11966 ;; then removing them from the list of killed groups.
11968 (gnus-group-change-level
11969 (gnus-gethash (car bogus) gnus-newsrc-hashtb) 9)
11970 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))
11971 (setq bogus (cdr bogus)))
11972 ;; Then we remove all bogus groups from the list of killed and
11973 ;; zombie groups. They are are removed without confirmation.
11974 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
11977 (setq killed (symbol-value (car dead-lists)))
11979 (setq group (car killed))
11980 (or (gnus-gethash group gnus-active-hashtb)
11981 ;; The group is bogus.
11982 (set (car dead-lists)
11983 (delete group (symbol-value (car dead-lists)))))
11984 (setq killed (cdr killed)))
11985 (setq dead-lists (cdr dead-lists))))
11986 (message "Checking bogus newsgroups... done")))
11988 (defun gnus-check-duplicate-killed-groups ()
11989 "Remove duplicates from the list of killed groups."
11991 (let ((killed gnus-killed-list))
11993 (message "%d" (length killed))
11994 (setcdr killed (delete (car killed) (cdr killed)))
11995 (setq killed (cdr killed)))))
11997 ;; Go though `gnus-newsrc-assoc' and compare with `gnus-active-hashtb'
11998 ;; and compute how many unread articles there are in each group.
11999 (defun gnus-get-unread-articles (&optional level)
12000 (let ((newsrc (cdr gnus-newsrc-assoc))
12001 (level (or level 6))
12002 info group active virtuals)
12003 (message "Checking new news...")
12005 (setq info (car newsrc))
12006 (setq group (car info))
12007 (setq active (gnus-gethash group gnus-active-hashtb))
12009 ;; Check newsgroups. If the user doesn't want to check them, or
12010 ;; they can't be checked (for instance, if the news server can't
12011 ;; be reached) we just set the number of unread articles in this
12012 ;; newsgroup to t. This means that Gnus thinks that there are
12013 ;; unread articles, but it has no idea how many.
12015 (if (or (and gnus-activate-foreign-newsgroups
12016 (not (numberp gnus-activate-foreign-newsgroups)))
12017 (and (numberp gnus-activate-foreign-newsgroups)
12018 (<= (nth 1 info) gnus-activate-foreign-newsgroups)
12019 (<= (nth 1 info) level)))
12020 (if (eq (car (nth 4 info)) 'nnvirtual)
12021 (setq virtuals (cons info virtuals))
12022 (setq active (gnus-activate-newsgroup (car info)))))
12023 (if (and (not gnus-read-active-file)
12024 (<= (nth 1 info) level))
12026 (setq active (gnus-activate-newsgroup (car info))))))
12028 (or active (progn (gnus-sethash group nil gnus-active-hashtb)
12029 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
12030 (and active (gnus-get-unread-articles-in-group info active))
12031 (setq newsrc (cdr newsrc)))
12033 ;; Activate the virtual groups. This has to be done after all the
12035 ;; !!! If one virtual group contains another virtual group, even
12036 ;; doing it this way might cause problems.
12038 (gnus-activate-newsgroup (car (car virtuals)))
12039 (setq virtuals (cdr virtuals)))
12041 (message "Checking new news... done")))
12043 ;; Create a hash table out of the newsrc alist. The `car's of the
12044 ;; alist elements are used as keys.
12045 (defun gnus-make-hashtable-from-newsrc-alist ()
12046 (let ((alist gnus-newsrc-assoc)
12048 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
12050 (setq prev (setq gnus-newsrc-assoc
12051 (cons (list "dummy.group" 0 nil) alist))))
12053 (gnus-sethash (car (car alist)) (cons nil prev) gnus-newsrc-hashtb)
12055 (setq alist (cdr alist)))))
12057 (defun gnus-make-hashtable-from-killed ()
12058 "Create a hash table from the killed and zombie lists."
12059 (let ((lists '(gnus-killed-list gnus-zombie-list))
12061 (setq gnus-killed-hashtb
12062 (gnus-make-hashtable
12063 (+ (length gnus-killed-list) (length gnus-zombie-list))))
12065 (setq list (symbol-value (car lists)))
12066 (setq lists (cdr lists))
12068 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
12069 (setq list (cdr list))))))
12071 (defun gnus-get-unread-articles-in-group (info active)
12072 (let* ((range (nth 2 info))
12074 (marked (nth 3 info))
12075 srange lowest group highest)
12076 ;; Modify the list of read articles according to what articles
12077 ;; are available; then tally the unread articles and add the
12078 ;; number to the group hash table entry.
12079 (cond ((zerop (cdr active))
12082 (setq num (- (1+ (cdr active)) (car active))))
12083 ((not (listp (cdr range)))
12084 ;; Fix a single (num . num) range according to the
12085 ;; active hash table.
12086 (and (< (cdr range) (car active)) (setcdr range (car active)))
12087 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
12088 ;; Compute number of unread articles.
12089 (setq num (max 0 (- (cdr active)
12090 (- (1+ (cdr range)) (car range))))))
12092 ;; The read list is a list of ranges. Fix them according to
12093 ;; the active hash table.
12094 ;; First peel off any elements that are below the lower
12096 (while (and (cdr range)
12098 (or (and (atom (car (cdr range))) (car (cdr range)))
12099 (car (car (cdr range))))))
12100 (if (numberp (car range))
12103 (or (and (numberp (car (cdr range)))
12105 (cdr (car (cdr range))))))
12106 (setcdr (car range)
12107 (or (and (numberp (nth 1 range)) (nth 1 range))
12108 (cdr (car (cdr range))))))
12109 (setcdr range (cdr (cdr range))))
12110 ;; Adjust the first element to be the same as the lower limit.
12111 (if (and (not (atom (car range)))
12112 (< (cdr (car range)) (car active)))
12113 (setcdr (car range) (car active)))
12114 ;; Then we want to peel off any elements that are higher
12115 ;; than the upper active limit.
12116 (let ((srange range))
12117 ;; Go past all legal elements.
12118 (while (and (cdr srange)
12119 (<= (or (and (atom (car (cdr srange)))
12120 (car (cdr srange)))
12121 (car (car (cdr srange)))) (cdr active)))
12122 (setq srange (cdr srange)))
12124 ;; Nuke all remaining illegal elements.
12125 (setcdr srange nil))
12127 ;; Adjust the final element.
12128 (if (and (not (atom (car srange)))
12129 (> (cdr (car srange)) (cdr active)))
12130 (setcdr (car srange) (cdr active))))
12131 ;; Compute the number of unread articles.
12133 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
12134 (cdr (car range))))
12135 (or (and (atom (car range)) (car range))
12136 (car (car range))))))
12137 (setq range (cdr range)))
12138 (setq num (max 0 (- (cdr active) num)))))
12141 (and (assq 'tick marked)
12142 (inline (gnus-remove-illegal-marked-articles
12143 (assq 'tick marked) (nth 2 info))))
12144 (and (assq 'dormant marked)
12145 (inline (gnus-remove-illegal-marked-articles
12146 (assq 'dormant marked) (nth 2 info))))
12148 (gnus-gethash (car info) gnus-newsrc-hashtb)
12149 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
12150 (length (cdr (assq 'dormant marked)))))))))
12153 (defun gnus-remove-illegal-marked-articles (marked ranges)
12154 (let ((m (cdr marked)))
12155 ;; Make sure that all ticked articles are a subset of the unread
12158 (if (gnus-member-of-range (car m) ranges)
12159 (setcdr marked (cdr m))
12161 (setq m (cdr m)))))
12163 (defun gnus-activate-newsgroup (group)
12164 (let ((method (gnus-find-method-for-group group))
12166 (and (or (gnus-server-opened method) (gnus-open-server method))
12167 (gnus-request-group group)
12169 (set-buffer nntp-server-buffer)
12171 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
12173 (goto-char (match-beginning 1))
12175 group (setq active (cons (read (current-buffer))
12176 (read (current-buffer))))
12177 gnus-active-hashtb))
12180 (defun gnus-update-read-articles
12181 (group unread unselected ticked &optional domarks replied expirable killed
12182 dormant bookmark score)
12183 "Update the list of read and ticked articles in GROUP using the
12184 UNREAD and TICKED lists.
12185 Note: UNSELECTED has to be sorted over `<'.
12186 Returns whether the updating was successful."
12187 (let* ((active (gnus-gethash group gnus-active-hashtb))
12188 (entry (gnus-gethash group gnus-newsrc-hashtb))
12189 (number (car entry))
12190 (info (nth 2 entry))
12191 (marked (nth 3 info))
12193 (unread (sort (copy-sequence unread) (function <)))
12195 (if (or (not info) (not active))
12196 ;; There is no info on this group if it was, in fact,
12197 ;; killed. Gnus stores no information on killed groups, so
12198 ;; there's nothing to be done.
12199 ;; One could store the information somewhere temporarily,
12200 ;; perhaps... Hmmm...
12202 ;; Remove any negative articles numbers.
12203 (while (and unread (< (car unread) 0))
12204 (setq unread (cdr unread)))
12205 (setq unread (sort (append unselected unread) '<))
12206 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12207 (setcar entry (max 0 (- (length unread) (length ticked)
12208 (length dormant))))
12209 ;; Compute the ranges of read articles by looking at the list of
12210 ;; unread articles.
12212 (if (/= (car unread) prev)
12213 (setq read (cons (if (= prev (1- (car unread))) prev
12214 (cons prev (1- (car unread)))) read)))
12215 (setq prev (1+ (car unread)))
12216 (setq unread (cdr unread)))
12217 (if (<= prev (cdr active))
12218 (setq read (cons (cons prev (cdr active)) read)))
12219 ;; Enter this list into the group info.
12220 (setcar (cdr (cdr info))
12221 (if (> (length read) 1) (nreverse read) (car read)))
12222 ;; Enter the list of ticked articles.
12223 (gnus-set-marked-articles
12225 (if domarks replied (cdr (assq 'reply marked)))
12226 (if domarks expirable (cdr (assq 'expire marked)))
12227 (if domarks killed (cdr (assq 'killed marked)))
12228 (if domarks dormant (cdr (assq 'dormant marked)))
12229 (if domarks bookmark (cdr (assq 'bookmark marked)))
12230 (if domarks score (cdr (assq 'score marked))))
12233 (defun gnus-make-articles-unread (group articles)
12234 "Mark ARTICLES in GROUP as unread."
12235 (let ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
12236 (gnus-gethash (gnus-group-real-name group)
12237 gnus-newsrc-hashtb)))))
12238 (setcar (nthcdr 2 info)
12239 (gnus-remove-from-range (nth 2 info) articles))
12240 (gnus-group-update-group group t)))
12242 (defun gnus-read-active-file ()
12243 "Get active file from NNTP server."
12244 (gnus-group-set-mode-line)
12245 (let ((methods (cons gnus-select-method gnus-secondary-select-methods)))
12246 (setq gnus-have-read-active-file nil)
12248 (let* ((where (nth 1 (car methods)))
12249 (mesg (format "Reading active file%s via %s..."
12250 (if (and where (not (zerop (length where))))
12251 (concat " from " where) "")
12252 (car (car methods)))))
12254 (if (gnus-request-list (car methods)) ; Get active
12256 (set-buffer nntp-server-buffer)
12257 (gnus-active-to-gnus-format
12258 (and gnus-have-read-active-file (car methods)))
12259 (setq gnus-have-read-active-file t)
12260 (message "%s...done" mesg))
12261 (message "Cannot read active file from %s server."
12262 (car (car methods)))
12264 (setq methods (cdr methods)))))
12266 ;; rewritten by jwz based on ideas from Rick Sladkey <jrs@world.std.com>
12267 ;; Further rewrites by lmi.
12268 (defun gnus-active-to-gnus-format (method &optional hashtb)
12269 "Convert active file format to internal format.
12270 Lines matching `gnus-ignored-newsgroups' are ignored."
12271 (let ((cur (current-buffer))
12275 (setq gnus-active-hashtb
12276 (gnus-make-hashtable
12277 (count-lines (point-min) (point-max))))))))
12278 ;; Delete unnecessary lines.
12279 (goto-char (point-min))
12280 (delete-matching-lines gnus-ignored-newsgroups)
12281 (and method (not (eq method gnus-select-method))
12282 (let ((prefix (gnus-group-prefixed-name "" method)))
12283 (goto-char (point-min))
12284 (while (and (not (eobp))
12285 (null (insert prefix))
12286 (zerop (forward-line 1))))))
12287 (goto-char (point-min))
12288 ;; Store active file in hashtable.
12290 (if (or (re-search-forward "\n.\r?$" nil t)
12291 (goto-char (point-max)))
12293 (beginning-of-line)
12294 (narrow-to-region (point-min) (point))))
12295 (goto-char (point-min))
12296 (if (string-match "%[oO]" gnus-group-line-format)
12297 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
12298 ;; If we want information on moderated groups, we use this
12301 (let ((mod-hashtb (make-vector 7 0))
12303 (while (not (eobp))
12304 (setq group (let ((obarray hashtb))
12306 (setq max (read cur))
12307 (set group (cons (read cur) max))
12308 ;; Enter moderated groups into a list.
12310 (symbol-name (let ((obarray mod-hashtb)) (read cur)))
12312 (setq gnus-moderated-list
12313 (cons (symbol-name group) gnus-moderated-list)))
12316 (progn (ding) (message "Possible error in active file."))))
12317 ;; And if we do not care about moderation, we use this loop,
12318 ;; which is faster.
12321 (while (not (eobp))
12322 ;; group gets set to a symbol interned in the hash table
12324 (setq group (let ((obarray hashtb)) (read cur)))
12325 (setq max (read cur))
12326 (set group (cons (read cur) max))
12329 (progn (ding) (message "Possible error in active file."))))))))
12331 (defun gnus-read-newsrc-file (&optional force)
12332 "Read startup file.
12333 If FORCE is non-nil, the .newsrc file is read."
12334 (setq gnus-current-startup-file (gnus-make-newsrc-file gnus-startup-file))
12335 ;; Reset variables that might be defined in the .newsrc.eld file.
12336 (let ((variables gnus-variable-list))
12338 (set (car variables) nil)
12339 (setq variables (cdr variables))))
12340 (let* ((newsrc-file gnus-current-startup-file)
12341 (quick-file (concat newsrc-file ".el")))
12343 ;; We always load the .newsrc.eld file. If always contains
12344 ;; much information that can not be gotten from the .newsrc
12345 ;; file (ticked articles, killed groups, foreign methods, etc.)
12346 (gnus-read-newsrc-el-file quick-file)
12349 (and (file-newer-than-file-p newsrc-file quick-file)
12350 (file-newer-than-file-p newsrc-file
12351 (concat quick-file "d")))
12352 (not gnus-newsrc-assoc))
12353 ;; We read the .newsrc file. Note that if there if a
12354 ;; .newsrc.eld file exists, it has already been read, and
12355 ;; the `gnus-newsrc-hashtb' has been created. While reading
12356 ;; the .newsrc file, Gnus will only use the information it
12357 ;; can find there for changing the data already read -
12358 ;; ie. reading the .newsrc file will not trash the data
12359 ;; already read (except for read articles).
12361 (message "Reading %s..." newsrc-file)
12362 (set-buffer (find-file-noselect newsrc-file))
12363 (buffer-disable-undo (current-buffer))
12364 (gnus-newsrc-to-gnus-format)
12365 (kill-buffer (current-buffer))
12366 (message "Reading %s... done" newsrc-file)))
12367 (and gnus-use-dribble-file (gnus-dribble-read-file)))))
12369 (defun gnus-read-newsrc-el-file (file)
12370 (let ((ding-file (concat file "d")))
12371 ;; We always, always read the .eld file.
12372 (message "Reading %s..." ding-file)
12373 (condition-case nil
12374 (load ding-file t t t)
12376 (gnus-uncompress-newsrc-assoc)
12377 (gnus-make-hashtable-from-newsrc-alist)
12378 (if (not (file-newer-than-file-p file ding-file))
12380 ;; Old format quick file
12381 (message "Reading %s..." file)
12382 ;; The .el file is newer than the .eld file, so we read that one
12384 (gnus-read-old-newsrc-el-file file))))
12386 ;; Parse the old-style quick startup file
12387 (defun gnus-read-old-newsrc-el-file (file)
12388 (let (newsrc killed marked group g m len info)
12390 (let (gnus-killed-assoc gnus-marked-assoc gnus-newsrc-assoc)
12392 (condition-case nil
12395 (setq newsrc gnus-newsrc-assoc
12396 killed gnus-killed-assoc
12397 marked gnus-marked-assoc)))
12398 (setq gnus-newsrc-assoc nil)
12400 (setq group (car newsrc))
12401 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
12404 (setcar (nthcdr 2 info) (cdr (cdr group)))
12405 (setcar (cdr info) (if (nth 1 group) 3 6))
12406 (setq gnus-newsrc-assoc (cons info gnus-newsrc-assoc)))
12407 (setq gnus-newsrc-assoc
12411 (if (nth 1 group) 3 6) (cdr (cdr group))))
12412 gnus-newsrc-assoc)))
12413 (if (setq m (assoc (car group) marked))
12414 (setcdr (cdr (cdr info)) (cons (list (cons 'tick (cdr m))) nil))))
12415 (setq newsrc (cdr newsrc)))
12416 (setq newsrc killed)
12418 (setcar newsrc (car (car newsrc)))
12419 (setq newsrc (cdr newsrc)))
12420 (setq gnus-killed-list killed))
12421 (setq gnus-newsrc-assoc (nreverse gnus-newsrc-assoc))
12422 (gnus-make-hashtable-from-newsrc-alist)))
12424 (defun gnus-make-newsrc-file (file)
12425 "Make server dependent file name by catenating FILE and server host name."
12426 (let* ((file (expand-file-name file nil))
12427 (real-file (concat file "-" (nth 1 gnus-select-method))))
12428 (if (file-exists-p real-file)
12431 (defun gnus-uncompress-newsrc-assoc ()
12432 ;; Uncompress all lists of marked articles in the newsrc assoc.
12433 (let ((newsrc gnus-newsrc-assoc)
12436 (if (not (setq marked (nth 3 (car newsrc))))
12439 (or (eq 'score (car (car marked)))
12440 (eq 'bookmark (car (car marked)))
12441 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
12442 (setq marked (cdr marked))))
12443 (setq newsrc (cdr newsrc)))))
12445 (defun gnus-compress-newsrc-assoc ()
12446 ;; Compress all lists of marked articles in the newsrc assoc.
12447 (let ((newsrc gnus-newsrc-assoc)
12450 (if (not (setq marked (nth 3 (car newsrc))))
12453 (or (eq 'score (car (car marked)))
12454 (eq 'bookmark (car (car marked)))
12455 (setcdr (car marked)
12456 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
12457 (setq marked (cdr marked))))
12458 (setq newsrc (cdr newsrc)))))
12460 ;; jwz: rewrote this function to be much more efficient, and not be
12461 ;; subject to regexp overflow errors when it encounters very long
12462 ;; lines -- the old behavior was to blow off the rest of the *file*
12463 ;; when a line was encountered that was too long to match!! Now it
12464 ;; uses only simple looking-at calls, and doesn't create as many
12465 ;; temporary strings. It also now handles multiple consecutive
12466 ;; options lines (before it only handled the first.)
12467 ;; Tiny rewrite by lmi.
12468 (defun gnus-newsrc-to-gnus-format ()
12469 "Parse current buffer as .newsrc file."
12470 ;; We have to re-initialize these variables (except for
12471 ;; gnus-killed-list) because the quick startup file may contain bogus
12473 (setq gnus-newsrc-options nil)
12474 (setq gnus-newsrc-options-n-yes nil)
12475 (setq gnus-newsrc-options-n-no nil)
12476 (gnus-parse-options-lines)
12477 (gnus-parse-newsrc-body))
12479 (defun gnus-parse-options-lines ()
12480 ;; newsrc.5 seems to indicate that the options line can come anywhere
12481 ;; in the file, and that there can be any number of them:
12483 ;; An options line starts with the word options (left-
12484 ;; justified). Then there are the list of options just as
12485 ;; they would be on the readnews command line. For instance:
12487 ;; options -n all !net.sf-lovers !mod.human-nets -r
12490 ;; A string of lines beginning with a space or tab after the
12491 ;; initial options line will be considered continuation
12494 ;; For now, we only accept it at the beginning of the file.
12496 (goto-char (point-min))
12497 (skip-chars-forward " \t\n")
12498 (setq gnus-newsrc-options nil)
12499 (while (looking-at "^options[ \t]*\\(.*\\)\n")
12500 ;; handle consecutive options lines
12501 (setq gnus-newsrc-options (concat gnus-newsrc-options
12502 (if gnus-newsrc-options "\n\t")
12503 (buffer-substring (match-beginning 1)
12506 (while (looking-at "[ \t]+\\(.*\\)\n")
12507 ;; handle subsequent continuation lines of this options line
12508 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n\t"
12509 (buffer-substring (match-beginning 1)
12512 ;; Gather all "-n" options lines.
12515 (if gnus-newsrc-options
12516 (while (and (string-match "^[ \t]*-n\\([^\n]*\\)$"
12517 gnus-newsrc-options
12519 (setq start (match-end 0)))
12520 (setq result (concat result
12522 (substring gnus-newsrc-options
12523 (match-beginning 1)
12525 (let ((yes-and-no (and result (gnus-parse-n-options result))))
12526 (and (or gnus-options-subscribe (car yes-and-no))
12527 (setq gnus-newsrc-options-n-yes
12528 (concat (or gnus-options-subscribe "")
12529 (or (car yes-and-no) ""))))
12530 (and (or gnus-options-not-subscribe (cdr yes-and-no))
12531 (setq gnus-newsrc-options-n-no
12532 (concat (or gnus-options-not-subscribe "")
12533 (or (cdr yes-and-no) "")))))
12536 (defun gnus-parse-newsrc-body ()
12537 ;; Point has been positioned after the options lines. We shouldn't
12538 ;; see any more in here.
12540 (let ((subscribe nil)
12542 (line (1+ (count-lines (point-min) (point))))
12546 (skip-chars-forward " \t")
12547 (while (not (eobp))
12549 ((= (following-char) ?\n)
12550 ;; skip blank lines
12554 (skip-chars-forward "^:!\n")
12555 (if (= (following-char) ?\n)
12556 (error "line %d is unparsable in %s" line (buffer-name)))
12558 (skip-chars-backward " \t")
12560 ;; #### note: we could avoid consing a string here by binding obarray
12561 ;; and reading the newsgroup directly into the gnus-newsrc-hashtb,
12562 ;; then setq'ing newsgroup to symbol-name of that, like we do in
12563 ;; gnus-active-to-gnus-format.
12564 (setq newsgroup (buffer-substring p (point)))
12567 (setq subscribe (= (following-char) ?:))
12568 (setq read-list nil)
12570 (forward-char 1) ; after : or !
12571 (skip-chars-forward " \t")
12572 (while (not (= (following-char) ?\n))
12573 (skip-chars-forward " \t")
12576 ((looking-at "\\([0-9]+\\)-\\([0-9]+\\)") ; a range
12581 ;; faster that buffer-substring/string-to-int
12582 (narrow-to-region (point-min) (match-end 1))
12583 (read (current-buffer)))
12585 (narrow-to-region (point-min) (match-end 2))
12586 (forward-char) ; skip over "-"
12588 (read (current-buffer))
12592 ((looking-at "[0-9]+")
12593 ;; faster that buffer-substring/string-to-int
12594 (narrow-to-region (point-min) (match-end 0))
12595 (setq p (read (current-buffer)))
12597 (setq read-list (cons (cons p p) read-list))
12600 ;; bogus chars in ranges
12603 (goto-char (match-end 0))
12604 (skip-chars-forward " \t")
12605 (cond ((= (following-char) ?,)
12608 ((= (following-char) ?\n)
12611 ;; bogus char after range
12613 ;; if we get here, the parse failed
12615 (end-of-line) ; give up on this line
12617 (message "Ignoring bogus line %d for %s in %s"
12618 line newsgroup (buffer-name))
12620 ;; We have already read .newsrc.eld, so we gently update the
12621 ;; data in the hash table with the information we have just
12623 (let ((info (nth 2 (gnus-gethash newsgroup gnus-newsrc-hashtb))))
12626 (setcar (nthcdr 2 info) (nreverse read-list))
12627 (setcar (cdr info) (if subscribe 3 (if read-list 6 7))))
12628 (setq gnus-newsrc-assoc
12629 (cons (list newsgroup (if subscribe 3 (if read-list 6 7))
12630 (nreverse read-list))
12631 gnus-newsrc-assoc))))))
12632 (setq line (1+ line))
12633 (forward-line 1))))
12634 (setq gnus-newsrc-assoc (cdr gnus-newsrc-assoc))
12635 (gnus-make-hashtable-from-newsrc-alist)
12638 (defun gnus-parse-n-options (options)
12639 "Parse -n NEWSGROUPS options and return a cons of YES and NO regexps."
12642 (yes-or-no nil) ;`!' or not.
12644 ;; Parse each newsgroup description such as "comp.all". Commas
12645 ;; and white spaces can be a newsgroup separator.
12647 (string-match "^[ \t\n,]*\\(!?\\)\\([^- \t\n,][^ \t\n,]*\\)" options)
12649 (substring options (match-beginning 1) (match-end 1)))
12653 (match-beginning 2) (match-end 2))))
12654 (setq options (substring options (match-end 2)))
12655 ;; Rewrite "all" to ".+" not ".*". ".+" requires at least one
12657 (while (string-match "\\(^\\|\\\\[.]\\)all\\(\\\\[.]\\|$\\)" newsgroup)
12659 (concat (substring newsgroup 0 (match-end 1))
12661 (substring newsgroup (match-beginning 2)))))
12662 ;; It is yes or no.
12663 (cond ((string-equal yes-or-no "!")
12664 (setq no (cons newsgroup no)))
12665 ((string-equal newsgroup ".+")) ;Ignore `all'.
12667 (setq yes (cons newsgroup yes)))))
12668 ;; Make a cons of regexps from parsing result.
12669 ;; We have to append \(\.\|$\) to prevent matching substring of
12670 ;; newsgroup. For example, "jp.net" should not match with
12672 ;; Fixes for large regexp problems are from yonezu@nak.math.keio.ac.jp.
12675 (apply (function concat)
12677 (lambda (newsgroup)
12678 (concat newsgroup "\\|"))
12680 (car yes) "\\)\\(\\.\\|$\\)"))
12683 (apply (function concat)
12685 (lambda (newsgroup)
12686 (concat newsgroup "\\|"))
12688 (car no) "\\)\\(\\.\\|$\\)")))))
12690 (defun gnus-save-newsrc-file ()
12691 "Save .newsrc file."
12692 ;; Note: We cannot save .newsrc file if all newsgroups are removed
12693 ;; from the variable gnus-newsrc-assoc.
12694 (and (or gnus-newsrc-assoc gnus-killed-list)
12695 gnus-current-startup-file
12697 (if (or (not gnus-dribble-buffer)
12698 (not (buffer-name gnus-dribble-buffer))
12699 (zerop (save-excursion
12700 (set-buffer gnus-dribble-buffer)
12702 (message "(No changes need to be saved)")
12703 (if gnus-save-newsrc-file
12704 (let ((make-backup-files t)
12705 (version-control nil)
12706 (require-final-newline t)) ;Don't ask even if requested.
12707 (message "Saving %s..." gnus-current-startup-file)
12708 ;; Make backup file of master newsrc.
12709 ;; You can stop or change version control of backup file.
12710 ;; Suggested by jason@violet.berkeley.edu.
12711 (run-hooks 'gnus-save-newsrc-hook)
12712 (gnus-gnus-to-newsrc-format)
12713 (message "Saving %s... done" gnus-current-startup-file)))
12714 ;; Quickly loadable .newsrc.
12715 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
12716 (gnus-add-current-to-buffer-list)
12717 (buffer-disable-undo (current-buffer))
12719 (message "Saving %s.eld..." gnus-current-startup-file)
12720 (gnus-gnus-to-quick-newsrc-format)
12721 (let ((make-backup-files nil)
12722 (version-control nil)
12723 (require-final-newline t)) ;Don't ask even if requested.
12724 (write-region 1 (point-max)
12725 (concat gnus-current-startup-file ".eld")
12727 (kill-buffer (current-buffer))
12728 (message "Saving %s.eld... done" gnus-current-startup-file)
12729 (gnus-dribble-delete-file)))))
12731 (defun gnus-gnus-to-quick-newsrc-format ()
12732 "Insert Gnus variables such as gnus-newsrc-assoc in lisp format."
12733 (insert ";; (ding) Gnus startup file.\n")
12734 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
12735 (insert ";; to read .newsrc.\n")
12736 (let ((variables gnus-variable-list)
12737 (gnus-newsrc-assoc (cdr gnus-newsrc-assoc))
12739 ;; insert lisp expressions.
12740 (gnus-compress-newsrc-assoc)
12742 (setq variable (car variables))
12743 (and (boundp variable)
12744 (symbol-value variable)
12745 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
12746 (insert "(setq " (symbol-name variable) " '"
12747 (prin1-to-string (symbol-value variable))
12749 (setq variables (cdr variables)))
12750 (gnus-uncompress-newsrc-assoc)))
12753 (defun gnus-gnus-to-newsrc-format ()
12754 ;; Generate and save the .newsrc file.
12755 (let ((newsrc (cdr gnus-newsrc-assoc))
12758 (set-buffer (create-file-buffer gnus-startup-file))
12759 (buffer-disable-undo (current-buffer))
12762 (if gnus-newsrc-options (insert "options " gnus-newsrc-options "\n"))
12763 ;; Write subscribed and unsubscribed.
12765 (setq info (car newsrc))
12766 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
12768 (insert (car info) (if (>= (nth 1 info) 6) "!" ":"))
12769 (if (setq ranges (nth 2 info))
12772 (if (not (listp (cdr ranges)))
12773 (if (= (car ranges) (cdr ranges))
12774 (insert (int-to-string (car ranges)))
12775 (insert (int-to-string (car ranges)) "-"
12776 (int-to-string (cdr ranges))))
12778 (setq range (car ranges)
12779 ranges (cdr ranges))
12780 (if (or (atom range) (= (car range) (cdr range)))
12781 (insert (int-to-string
12782 (or (and (atom range) range)
12784 (insert (int-to-string (car range)) "-"
12785 (int-to-string (cdr range))))
12786 (if ranges (insert ","))))))
12788 (setq newsrc (cdr newsrc)))
12789 (write-region 1 (point-max) gnus-current-startup-file nil 'nomesg)
12790 (kill-buffer (current-buffer)))))
12792 (defun gnus-read-descriptions-file ()
12793 (message "Reading descriptions file...")
12794 (if (not (gnus-request-list-newsgroups gnus-select-method))
12796 (message "Couldn't read newsgroups descriptions")
12799 (setq gnus-description-hashtb
12800 (gnus-make-hashtable (length gnus-active-hashtb)))
12803 (set-buffer nntp-server-buffer)
12804 (goto-char (point-min))
12805 (delete-non-matching-lines "^[-\\._+A-Za-z0-9]+[ \t]")
12806 (goto-char (point-min))
12807 (if (or (search-forward "\n.\n" nil t)
12808 (goto-char (point-max)))
12810 (beginning-of-line)
12811 (narrow-to-region (point-min) (point))))
12812 (goto-char (point-min))
12813 (while (not (eobp))
12814 (setq group (let ((obarray gnus-description-hashtb))
12815 (read (current-buffer))))
12816 (skip-chars-forward " \t")
12817 (set group (buffer-substring
12818 (point) (save-excursion (end-of-line) (point))))
12819 (forward-line 1))))
12820 (message "Reading descriptions file...done")
12823 (defun gnus-group-get-description (group)
12824 ;; Get the description of a group by sending XGTITLE to the server.
12825 (and (gnus-request-group-description group)
12827 (set-buffer nntp-server-buffer)
12828 (goto-char (point-min))
12829 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
12830 (buffer-substring (match-beginning 1) (match-end 1))))))
12834 ;;; gnus.el ends here