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)
51 "*Default method for selecting a newsgroup.
52 This variable should be a list, where the first element is how the
53 news is to be fetched, the second is the address.
55 For instance, if you want to get your news via NNTP from
56 \"flab.flab.edu\", you could say:
58 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
60 If you want to use your local spool, say:
62 (setq gnus-select-method (list 'nnspool (system-name)))
64 If you use this variable, you must set `gnus-nntp-server' to nil.
66 There is a lot more to know about select methods and virtual servers -
67 see the manual for details.")
69 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
70 (defvar gnus-post-method nil
71 "*Preferred method for posting USENET news.
72 If this variable is nil, Gnus will use the current method to decide
73 which method to use when posting. If it is non-nil, it will override
74 the current method. This method will not be used in mail groups and
75 the like, only in \"real\" newsgroups.
77 The value must be a valid method as discussed in the documentation of
78 `gnus-select-method'.")
80 (defvar gnus-refer-article-method nil
81 "*Preferred method for fetching an article by Message-ID.
82 If you are reading news from the local spool (with nnspool), fetching
83 articles by Message-ID is painfully slow. By setting this method to an
84 nntp method, you might get acceptable results.
86 The value of this variable must be a valid select method as discussed
87 in the documentation of `gnus-select-method'")
89 (defvar gnus-secondary-select-methods nil
90 "*A list of secondary methods that will be used for reading news.
91 This is a list where each element is a complete select methdod (see
92 `gnus-select-method').
94 If, for instance, you want to read your mail with the nnml backend,
95 you could set this variable:
97 (setq gnus-secondary-select-methods '((nnml \"\"))")
99 (defvar gnus-secondary-servers nil
100 "*List of NNTP servers that the user can choose between interactively.
101 To make Gnus query you for a server, you have to give `gnus' a
102 non-numeric prefix - `C-u M-x gnus', in short.")
104 (defvar gnus-nntp-server nil
105 "*The name of the host running the NNTP server.
106 This variable is semi-obsolete. Use the `gnus-select-method'
109 (defvar gnus-nntp-service "nntp"
110 "*NNTP service name (\"nntp\" or 119).
111 This is an obsolete variable, which is scarcely used. If you use an
112 nntp server for your newsgroup and want to change the port number
113 used to 899, you would say something along these lines:
115 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
117 (defvar gnus-startup-file "~/.newsrc"
118 "*Your `.newsrc' file.
119 `.newsrc-SERVER' will be used instead if that exists.")
121 (defvar gnus-signature-file "~/.signature"
122 "*Your signature file.
123 If the variable is a string that doesn't correspond to a file, the
124 string itself is inserted.")
126 (defvar gnus-signature-function nil
127 "*A function that should return a signature file name.
128 The function will be called with the name of the newsgroup being
130 If the function returns a string that doesn't correspond to a file, the
131 string itself is inserted.
132 If the function returns nil, the `gnus-signature-file' variable will
135 (defvar gnus-init-file "~/.gnus"
136 "*Your Gnus elisp startup file.
137 If a file with the .el or .elc suffixes exist, it will be read
140 (defvar gnus-group-faq-directory
141 "/anonymous@rtfm.mit.edu:/pub/usenet-by-group/"
142 "*Directory where the group FAQs are stored.
143 This will most commonly be on a remote machine, and the file will be
144 fetched by ange-ftp.")
146 (defvar gnus-group-archive-directory
147 "/ftp@sina.tcamc.uh.edu:/pub/emacs/ding-list/"
148 "*The address of the (ding) archives.")
150 (defvar gnus-default-subscribed-newsgroups nil
151 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
152 It should be a list of strings.
153 If it is `t', Gnus will not do anything special the first time it is
154 started; it'll just use the normal newsgroups subscription methods.")
156 (defvar gnus-post-prepare-function nil
157 "*Function that is run after a post buffer has been prepared.
158 It is called with the name of the newsgroup that is posted to. It
159 might be used, for instance, for inserting signatures based on the
160 newsgroup name. (In that case, `gnus-signature-file' and
161 `mail-signature' should both be set to nil).")
163 (defvar gnus-use-cross-reference t
164 "*Non-nil means that cross referenced articles will be marked as read.
165 If nil, ignore cross references. If t, mark articles as read in
166 subscribed newsgroups. If neither t nor nil, mark as read in all
169 (defvar gnus-use-dribble-file t
170 "*Non-nil means that Gnus will use a dribble file to store user updates.
171 If Emacs should crash without saving the .newsrc files, complete
172 information can be restored from the dribble file.")
174 (defvar gnus-use-followup-to 'use
175 "*Specifies what to do with Followup-To header.
176 If nil, ignore the header. If it is t, use its value, but ignore
177 `poster'. If it is neither nil nor t, which is the default, always use
180 (defvar gnus-followup-to-function nil
181 "*A variable that contains a function that returns a followup address.
182 The function will be called in the buffer of the article that is being
183 followed up. The buffer will be narrowed to the headers of the
184 article. To pick header headers, one might use `mail-fetch-field'. The
185 function will be called with the name of the current newsgroup as the
188 Here's an example `gnus-followup-to-function':
190 (setq gnus-followup-to-function
192 (cond ((string= group \"mail.list\")
193 (or (mail-fetch-field \"sender\")
194 (mail-fetch-field \"from\")))
196 (or (mail-fetch-field \"reply-to\")
197 (mail-fetch-field \"from\"))))))")
199 (defvar gnus-reply-to-function nil
200 "*A variable that contains a function that returns a reply address.
201 See the `gnus-followup-to-function' variable for an explanation of how
202 this variable is used.
204 This function should return a string that will be used to fill in the
205 header. This function may also return a list. In that case, every
206 list element should be a cons where the first car should be a string
207 with the header name, and the cdr should be a string with the header
210 (defvar gnus-large-newsgroup 200
211 "*The number of articles which indicates a large newsgroup.
212 If the number of articles in a newsgroup is greater than this value,
213 confirmation is required for selecting the newsgroup.")
215 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
216 (defvar gnus-no-groups-message "No news is horrible news"
217 "*Message displayed by Gnus when no groups are available.")
219 (defvar gnus-author-copy (getenv "AUTHORCOPY")
220 "*Save outgoing articles in this file.
221 Initialized from the AUTHORCOPY environment variable.
223 If this variable begins with the character \"|\", outgoing articles
224 will be piped to the named program. It is possible to save an article
225 in an MH folder as follows:
227 \(setq gnus-author-copy \"|/usr/local/lib/mh/rcvstore +Article\")
229 If the first character is not a pipe, articles are saved using the
230 function specified by the `gnus-author-copy-saver' variable.")
232 (defvar gnus-mail-self-blind nil
233 "*Non-nil means insert a BCC header in all outgoing articles.
234 This will result in having a copy of the article mailed to yourself.
235 The BCC header is inserted when the post buffer is initialized, so you
236 can remove or alter the BCC header to override the default.")
238 (defvar gnus-author-copy-saver (function rmail-output)
239 "*A function called to save outgoing articles.
240 This function will be called with the same of the file to store the
241 article in. The default function is `rmail-output' which saves in Unix
244 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
245 "*Non-nil means that the default name of a file to save articles in is the group name.
246 If it's nil, the directory form of the group name is used instead.
248 If this variable is a list, and the list contains the element
249 `not-score', long file names will not be used for score files; if it
250 contains the element `not-save', long file names will not be used for
251 saving; and if it contains the element `not-kill', long file names
252 will not be used for kill files.")
254 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
255 "*Name of the directory articles will be saved in (default \"~/News\").
256 Initialized from the SAVEDIR environment variable.")
258 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
259 "*Name of the directory where kill files will be stored (default \"~/News\").
260 Initialized from the SAVEDIR environment variable.")
262 (defvar gnus-score-expiry-days 7
263 "*Number of days before unused score file entries are expired.")
265 (defvar gnus-default-article-saver (function gnus-summary-save-in-rmail)
266 "*A function to save articles in your favorite format.
267 The function must be interactively callable (in other words, it must
268 be an Emacs command).
270 Gnus provides the following functions:
272 * gnus-summary-save-in-rmail (Rmail format)
273 * gnus-summary-save-in-mail (Unix mail format)
274 * gnus-summary-save-in-folder (MH folder)
275 * gnus-summary-save-in-file (article format).")
277 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
278 "*A function generating a file name to save articles in Rmail format.
279 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
281 (defvar gnus-mail-save-name (function gnus-plain-save-name)
282 "*A function generating a file name to save articles in Unix mail format.
283 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
285 (defvar gnus-folder-save-name (function gnus-folder-save-name)
286 "*A function generating a file name to save articles in MH folder.
287 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
289 (defvar gnus-file-save-name (function gnus-numeric-save-name)
290 "*A function generating a file name to save articles in article format.
291 The function is called with NEWSGROUP, HEADERS, and optional
294 (defvar gnus-split-methods nil
295 "*Variable used to suggest where articles are to be saved.
296 The syntax of this variable is the same as `nnmail-split-methods'.
298 For instance, if you would like to save articles related to Gnus in
299 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
300 you could set this variable to something like:
302 '(("^Subject:.*gnus\\|^Newsgroups:.*gnus" "gnus-stuff")
303 ("^Subject:.*vm\\|^Xref:.*vm" "vm-stuff"))")
305 (defvar gnus-score-file-suffix "SCORE"
306 "*Suffix of the score files.")
308 (defvar gnus-fetch-old-headers nil
309 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
310 If an unread article in the group refers to an older, already read (or
311 just marked as read) article, the old article will not normally be
312 displayed in the Summary buffer. If this variable is non-nil, Gnus
313 will attempt to grab the headers to the old articles, and thereby
314 build complete threads. If it has the value `some', only enough
315 headers to connect otherwise loose threads will be displayed.
317 The server has to support XOVER for any of this to work.")
319 (defvar gnus-visual t
320 "*If non-nil, will do various highlighting.
321 If nil, no mouse highlights (or any other highlights) will be
322 performed. This might speed up Gnus some when generating large group
323 and summary buffers.")
325 (defvar gnus-novice-user t
326 "*Non-nil means that you are a usenet novice.
327 If non-nil, verbose messages may be displayed and confirmations may be
330 (defvar gnus-expert-user nil
331 "*Non-nil means that you will never be asked for confirmation about anything.
332 And that means *anything*.")
334 (defvar gnus-keep-same-level nil
335 "*Non-nil means that the next newsgroup after the current will be on the same level.
336 When you type, for instance, `n' after reading the last article in the
337 current newsgroup, you will go to the next newsgroup. If this variable
338 is nil, the next newsgroup will be the next from the group
340 If this variable is non-nil, Gnus will either put you in the
341 next newsgroup with the same level, or, if no such newsgroup is
342 available, the next newsgroup with the lowest possible level higher
343 than the current level.
344 If this variable is `best', Gnus will make the next newsgroup the one
345 with the best level.")
347 (defvar gnus-summary-make-false-root 'adopt
348 "*nil means that Gnus won't gather loose threads.
349 If the root of a thread has expired or been read in a previous
350 session, the information necessary to build a complete thread has been
351 lost. Instead of having many small sub-threads from this original thread
352 scattered all over the summary buffer, Gnus can gather them.
354 If non-nil, Gnus will try to gather all loose sub-threads from an
355 original thread into one large thread.
357 If this variable is non-nil, it should be one of `none', `adopt',
360 If this variable is `none', Gnus will not make a false root, but just
361 present the sub-threads after another.
362 If this variable is `dummy', Gnus will create a dummy root that will
363 have all the sub-threads as children.
364 If this variable is `adopt', Gnus will make one of the \"children\"
365 the parent and mark all the step-children as such.
366 If this variable is `empty', the \"children\" are printed with empty
367 subject fields. (Or rather, they will be printed with a string
368 given by the `gnus-summary-same-subject' variable.)")
370 (defvar gnus-summary-gather-subject-limit nil
371 "*Maximum length of subject comparisons when gathering loose threads.
372 Use nil to compare full subjects. Setting this variable to a low
373 number will help gather threads that have been corrupted by
374 newsreaders chopping off subject lines, but it might also mean that
375 unrelated articles that have subject that happen to begin with the
376 same few characters will be incorrectly gathered.
378 If this variable is `fuzzy', Gnus will use a fuzzy algortihm when
379 comparing subjects.")
381 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
382 (defvar gnus-summary-same-subject ""
383 "*String indicating that the current article has the same subject as the previous.
384 This variable will only be used if the value of
385 `gnus-summary-make-false-root' is `empty'.")
387 (defvar gnus-summary-goto-unread nil
388 "*If non-nil, marking commands will go to the next unread article.")
390 (defvar gnus-check-new-newsgroups t
391 "*Non-nil means that Gnus will add new newsgroups at startup.
392 If this variable is `ask-server', Gnus will ask the server for new
393 groups since the last time it checked. This means that the killed list
394 is no longer necessary, so you could set `gnus-save-killed-list' to
397 A variant is to have this variable be a list of select methods. Gnus
398 will then use the `ask-server' method on all these select methods to
399 query for new groups from all those servers.
402 (setq gnus-check-new-newsgroups
403 '((nntp \"some.server\") (nntp \"other.server\")))
405 If this variable is nil, then you have to tell Gnus explicitly to
406 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
408 (defvar gnus-check-bogus-newsgroups nil
409 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
410 If this variable is nil, then you have to tell Gnus explicitly to
411 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
413 (defvar gnus-read-active-file t
414 "*Non-nil means that Gnus will read the entire active file at startup.
415 If this variable is nil, Gnus will only know about the groups in your
418 If this variable is `some', Gnus will try to only read the relevant
419 parts of the active file from the server. Not all servers support
420 this, and it might be quite slow with other servers, but this should
421 generally be faster than both the t and nil value.
423 If you set this variable to nil or `some', you probably still want to
424 be told about new newsgroups that arrive. To do that, set
425 `gnus-check-new-newsgroups' to `ask-server'. This may not work
426 properly with all servers.")
428 (defvar gnus-level-subscribed 5
429 "*Groups with levels less than or equal to this variable are subscribed.")
431 (defvar gnus-level-unsubscribed 7
432 "*Groups with levels less than or equal to this variable are unsubscribed.
433 Groups with levels less than `gnus-level-subscribed', which should be
434 less than thiss variable, are subscribed.")
436 (defvar gnus-level-zombie 8
437 "*Groups with this level are zombie groups.")
439 (defvar gnus-level-killed 9
440 "*Groups with this level are killed.")
442 (defvar gnus-level-default-subscribed 3
443 "*New subscribed groups will be subscribed at this level.")
445 (defvar gnus-level-default-unsubscribed
446 "*New unsubscribed groups will be unsubscribed at this level.")
448 (defvar gnus-activate-foreign-newsgroups nil
449 "*If nil, Gnus will not check foreign newsgroups at startup.
450 If it is non-nil, it should be a number between one and nine. Foreign
451 newsgroups that have a level lower or equal to this number will be
452 activated on startup. For instance, if you want to active all
453 subscribed newsgroups, but not the rest, you'd set this variable to
454 `gnus-level-subscribed'.
456 If you subscribe to lots of newsgroups from different servers, startup
457 might take a while. By setting this variable to nil, you'll save time,
458 but you won't be told how many unread articles there are in the
461 (defvar gnus-save-newsrc-file t
462 "*Non-nil means that Gnus will save the `.newsrc' file.
463 Gnus always saves its own startup file, which is called
464 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
465 be readily understood by other newsreaders. If you don't plan on
466 using other newsreaders, set this variable to nil to save some time on
469 (defvar gnus-save-killed-list t
470 "*If non-nil, save the list of killed groups to the startup file.
471 This will save both time (when starting and quitting) and space (both
472 memory and disk), but it will also mean that Gnus has no record of
473 which groups are new and which are old, so the automatic new
474 newsgroups subscription methods become meaningless. You should always
475 set `gnus-check-new-newsgroups' to `ask-server' or nil if you set this
478 (defvar gnus-interactive-catchup t
479 "*If non-nil, require your confirmation when catching up a group.")
481 (defvar gnus-interactive-post t
482 "*If non-nil, group name will be asked for when posting.")
484 (defvar gnus-interactive-exit t
485 "*If non-nil, require your confirmation when exiting Gnus.")
487 (defvar gnus-kill-killed nil
488 "*If non-nil, Gnus will apply kill files to already killed articles.
489 If it is nil, Gnus will never apply kill files to articles that have
490 already been through the scoring process, which might very well save lots
493 (defvar gnus-extract-address-components 'gnus-extract-address-components
494 "*Function for extracting address components from a From header.
495 Two pre-defined function exist: `gnus-extract-address-components',
496 which is the default, quite fast, and too simplistic solution, and
497 `mail-extract-address-components', which works much better, but is
500 (defvar gnus-score-interactive-default-score 1000
501 "*Scoring commands will raise/lower the score with this number as the default.")
503 (defvar gnus-save-score nil
504 "*If non-nil, save group scoring info.")
506 (defvar gnus-global-score-files nil
507 "*List of global score files and directories.
508 Set this variable if you want to use people's score files. One entry
509 for each score file or each score file directory. Gnus will decide
510 by itself what score files are applicable to which group.
512 Say you want to use the single score file
513 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all
514 score files in the \"/ftp.some-where:/pub/score\" directory.
516 (setq gnus-global-score-files
517 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\"
518 \"/ftp.some-where:/pub/score\"))")
520 (defvar gnus-summary-default-score 0
521 "*Default article score level.
522 If this variable is nil, scoring will be disabled.")
524 (defvar gnus-group-default-list-level gnus-level-subscribed
525 "*Default listing level.")
527 (defvar gnus-group-always-list-unread gnus-level-subscribed
528 "*Always list groups less than this variable with unread articles.
529 If nil, use parameter to specify.")
531 (defvar gnus-user-login-name nil
532 "*The login name of the user.
533 Got from the function `user-login-name' if undefined.")
535 (defvar gnus-user-full-name nil
536 "*The full name of the user.
537 Got from the NAME environment variable if undefined.")
539 (defvar gnus-user-from-line nil
540 "*Your full, complete e-mail address.
541 Overrides the other Gnus variables if it is non-nil.
543 Here are two example values of this variable:
545 \"Lars Magne Ingebrigtsen <larsi@ifi.uio.no>\"
549 \"larsi@ifi.uio.no (Lars Magne Ingebrigtsen)\"
551 The first version is recommended, but the name has to be quoted if it
552 contains non-alphanumerical characters.")
554 (defvar gnus-show-mime nil
555 "*If non-ni, do mime processing of articles.
556 The articles will simply be fed to the function given by
557 `gnus-show-mime-method'.")
559 (defvar gnus-show-mime-method (function metamail-buffer)
560 "*Function to process a MIME message.
561 The function is called from the article buffer.")
563 (defvar gnus-show-threads t
564 "*If non-nil, display threads in summary mode.")
566 (defvar gnus-thread-hide-subtree nil
567 "*If non-nil, hide all threads initially.
568 If threads are hidden, you have to run the command
569 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
570 to expose hidden threads.")
572 (defvar gnus-thread-hide-killed t
573 "*If non-nil, hide killed threads automatically.")
575 (defvar gnus-thread-ignore-subject nil
576 "*If non-nil, ignore subjects and do all threading based on the Reference header.
577 If nil, which is the default, articles that have different subjects
578 from their parents will start separate threads.")
580 (defvar gnus-thread-indent-level 4
581 "*Number that says how much each sub-thread should be indented.")
583 ;; jwz: nuke newsgroups whose name is all digits - that means that
584 ;; some loser has let articles get into the root of the news spool,
585 ;; which is toxic. Lines beginning with whitespace also tend to be
587 (defvar gnus-ignored-newsgroups
588 (purecopy (mapconcat 'identity
589 '("^to\\." ; not "real" groups
590 "^[0-9. \t]+ " ; all digits in name
591 "[][\"#'() ;\\]" ; bogus characters
594 "*A regexp to match uninteresting newsgroups in the active file.
595 Any lines in the active file matching this regular expression are
596 removed from the newsgroup list before anything else is done to it,
597 thus making them effectively non-existant.")
599 (defvar gnus-ignored-headers
600 "^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:"
601 "*All headers that match this regexp will be hidden.
602 Also see `gnus-visible-headers'.")
604 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
605 "*All headers that do not match this regexp will be hidden.
606 Also see `gnus-ignored-headers'.")
608 (defvar gnus-sorted-header-list
609 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
610 "^Cc:" "^Date:" "^Organization:")
611 "*This variable is a list of regular expressions.
612 If it is non-nil, headers that match the regular expressions will
613 be placed first in the article buffer in the sequence specified by
616 (defvar gnus-check-before-posting t
617 "In non-nil, Gnus will attempt to run some checks on outgoing posts.")
619 (defvar gnus-required-headers
620 '(From Date Newsgroups Subject Message-ID Organization Lines X-Newsreader)
621 "*Headers to be generated or prompted for when posting an article.
622 RFC977 and RFC1036 require From, Date, Newsgroups, Subject,
623 Message-ID. Organization, Lines and X-Newsreader are optional. If
624 you want Gnus not to insert some header, remove it from this list.")
626 (defvar gnus-show-all-headers nil
627 "*If non-nil, don't hide any headers.")
629 (defvar gnus-save-all-headers t
630 "*If non-nil, don't remove any headers before saving.")
632 (defvar gnus-inhibit-startup-message nil
633 "*If non-nil, the startup message will not be displayed.")
635 (defvar gnus-auto-extend-newsgroup t
636 "*If non-nil, extend newsgroup forward and backward when requested.")
638 (defvar gnus-auto-select-first t
639 "*If non-nil, select the first unread article when entering a group.
640 If you want to prevent automatic selection of the first unread article
641 in some newsgroups, set the variable to nil in
642 `gnus-select-group-hook'.")
644 (defvar gnus-auto-select-next t
645 "*If non-nil, offer to go to the next group from the end of the previous.
646 If the value is t and the next newsgroup is empty, Gnus will exit
647 summary mode and go back to group mode. If the value is neither nil
648 nor t, Gnus will select the following unread newsgroup. In
649 particular, if the value is the symbol `quietly', the next unread
650 newsgroup will be selected without any confirmations.")
652 (defvar gnus-auto-select-same nil
653 "*If non-nil, select the next article with the same subject.")
655 (defvar gnus-auto-center-summary t
656 "*If non-nil, always center the current summary buffer.")
658 (defvar gnus-auto-mail-to-author nil
659 "*If non-nil, mail the authors of articles a copy of your follow-ups.
660 If this variable is `ask', the user will be prompted for whether to
661 mail a copy. The string given by `gnus-mail-courtesy-message' will be
662 inserted at the beginning of the mail copy.
664 Mail is sent using the function specified by the
665 `gnus-mail-send-method' variable.")
667 ;; Added by Ethan Bradford <ethanb@ptolemy.astro.washington.edu>.
668 (defvar gnus-mail-courtesy-message
669 "*The following message is a courtesy copy of an article\nthat has been posted as well.\n\n"
670 "This is inserted at the start of a mailed copy of a posted message.
671 If this variable is nil, no such courtesy message will be added.")
673 (defvar gnus-break-pages t
674 "*If non-nil, do page breaking on articles.
675 The page delimiter is specified by the `gnus-page-delimiter'
678 (defvar gnus-page-delimiter "^\^L"
679 "*Regexp describing what to use as article page delimiters.
680 The default value is \"^\^L\", which is a form linefeed at the
681 beginning of a line.")
683 (defvar gnus-use-full-window t
684 "*If non-nil, use the entire Emacs screen.")
686 ; for split windows. maybe a better way?
687 (defvar gnus-split-window nil
688 "*If non-nil, put the article buffer in left-hand side of the window .")
690 (defvar gnus-window-configuration
694 "*Specify window configurations for each action.
695 The format of the variable is either a list of (ACTION (G S A)), where
696 G, S, and A are the relative height of group, summary, and article
697 windows, respectively, or a list of (ACTION FUNCTION), where FUNCTION
698 is a function that will be called with ACTION as an argument. ACTION
699 can be `summary', `newsgroups', or `article'.")
701 (defvar gnus-mail-reply-method (function gnus-mail-reply-using-mail)
702 "*Function to compose a reply.
703 Two pre-made functions are `gnus-mail-reply-using-mail' (sendmail) and
704 `gnus-mail-reply-using-mhe' (MH-E).")
706 (defvar gnus-mail-forward-method (function gnus-mail-forward-using-mail)
707 "*Function to forward the current message to another user.
708 Two pre-made functions are `gnus-mail-forward-using-mail' (sendmail)
709 and `gnus-mail-forward-using-mhe' (MH-E).")
711 (defvar gnus-mail-other-window-method 'gnus-mail-other-window-using-mail
712 "*Function to compose mail in the other window.
713 Two pre-made functions are `gnus-mail-other-window-using-mail'
714 (sendmail) and `gnus-mail-other-window-using-mhe' (MH-E).")
716 (defvar gnus-mail-send-method send-mail-function
717 "*Function to mail a message which is also being posted as an article.
718 The message must have To or Cc header. The default is copied from
719 the variable `send-mail-function'.")
721 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
722 "*Function called with a group name when new group is detected.
723 A few pre-made functions are supplied: `gnus-subscribe-randomly'
724 inserts new groups at the beginning of the list of groups;
725 `gnus-subscribe-alphabetically' inserts new groups in strict
726 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
727 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
730 ;; Suggested by a bug report by Hallvard B Furuseth.
731 ;; <h.b.furuseth@usit.uio.no>.
732 (defvar gnus-subscribe-options-newsgroup-method
733 (function gnus-subscribe-alphabetically)
734 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
735 If, for instance, you want to subscribe to all newsgroups in the
736 \"no\" and \"alt\" hierarchies, you'd put the following in your
739 options -n no.all alt.all
741 Gnus will the subscribe all new newsgroups in these hierarchies with
742 the subscription method in this variable.")
744 (defvar gnus-subscribe-hierarchical-interactive nil
745 "*If non-nil, Gnus will offer to subscribe hierarchically.
746 When a new hierarchy appears, Gnus will ask the user:
748 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
750 If the user pressed `d', Gnus will descend the hierarchy, `y' will
751 subscribe to all newsgroups in the hierarchy and `s' will skip this
752 hierarchy in its entirety.")
754 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
755 "*Function used for sorting the group buffer.
756 This function will be called with group info entries as the arguments
757 for the groups to be sorted. Pre-made functions include
758 `gnus-sort-by-alphabet', `gnus-sort-by-unread' and
759 `gnus-sort-by-level'")
761 ;; Mark variables suggested by Thomas Michanek
762 ;; <Thomas.Michanek@telelogic.se>.
763 (defvar gnus-unread-mark ?
764 "*Mark used for unread articles.")
765 (defvar gnus-ticked-mark ?!
766 "*Mark used for ticked articles.")
767 (defvar gnus-dormant-mark ??
768 "*Mark used for dormant articles.")
769 (defvar gnus-dread-mark ?D
770 "*Mark used for read articles.")
771 (defvar gnus-read-mark ?d
772 "*Mark used for read articles.")
773 (defvar gnus-expirable-mark ?E
774 "*Mark used for expirable articles.")
775 (defvar gnus-killed-mark ?K
776 "*Mark used for killed articles.")
777 (defvar gnus-kill-file-mark ?X
778 "*Mark used for articles killed by kill files.")
779 (defvar gnus-low-score-mark ?Y
780 "*Mark used for articles with a low score.")
781 (defvar gnus-catchup-mark ?C
782 "*Mark used for articles that are caught up.")
783 (defvar gnus-replied-mark ?R
784 "*Mark used for articles that have been replied to.")
785 (defvar gnus-process-mark ?#
787 (defvar gnus-ancient-mark ?A
788 "*Mark used for ancient articles.")
789 (defvar gnus-canceled-mark ?G
790 "*Mark used for cancelled articles.")
791 (defvar gnus-score-over-mark ?+
792 "*Score mark used for articles with high scores.")
793 (defvar gnus-score-below-mark ?-
794 "*Score mark used for articles with low scores.")
796 (defvar gnus-view-pseudo-asynchronously nil
797 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
799 (defvar gnus-view-pseudos nil
800 "*If `automatic', pseudo-articles will be viewed automatically.
801 If `not-confirm', pseudos will be viewed automatically, and the user
802 will not be asked to confirm the command.")
804 (defvar gnus-group-line-format "%M%S%5y: %(%g%)\n"
805 "*Format of group lines.
806 It works along the same lines as a normal formatting string,
807 with some simple extensions.
809 %M Only marked articles (character, \"*\" or \" \")
810 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
811 %L Level of subscribedness (integer)
812 %N Number of unread articles (integer)
813 %I Number of dormant articles (integer)
814 %i Number of ticked and dormant (integer)
815 %T Number of ticked articles (integer)
816 %R Number of read articles (integer)
817 %t Total number of articles (integer)
818 %y Number of unread, unticked articles (integer)
819 %G Group name (string)
820 %g Qualified group name (string)
821 %D Group description (string)
822 %s Select method (string)
823 %o Moderated group (char, \"m\")
824 %O Moderated group (string, \"(m)\" or \"\")
825 %n Select from where (string)
826 %z A string that look like `<%s:%n>' if a foreign select method is used
827 %u User defined specifier. The next character in the format string should
828 be a letter. Gnus will call the function gnus-user-format-function-X,
829 where X is the letter following %u. The function will be passed the
830 current header as argument. The function should return a string, which
831 will be inserted into the buffer just like information from any other
834 Text between %( and %) will be highlighted with `gnus-mouse-face' when
835 the mouse point move inside the area. There can only be one such area.
837 Note that this format specification is not always respected. For
838 reasons of efficiency, when listing killed groups, this specification
839 is ignored altogether. If the spec is changed considerably, your
840 output may end up looking strange when listing both alive and killed
843 If you use %o or %O, reading the active file will be slower and quite
844 a bit of extra memory will be used. %D will also worsen performance.
845 Also note that if you change the format specification to include any
846 of these specs, you must probably re-start Gnus to see them go into
849 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
850 "*The format specification of the lines in the summary buffer.
852 It works along the same lines as a normal formatting string,
853 with some simple extensions.
855 %N Article number, left padded with spaces (string)
857 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
858 %n Name of the poster (string)
859 %A Address of the poster (string)
860 %F Contents of the From: header (string)
861 %x Contents of the Xref: header (string)
862 %D Date of the article (string)
863 %d Date of the article (string) in DD-MMM format
864 %M Message-id of the article (string)
865 %r References of the article (string)
866 %c Number of characters in the article (integer)
867 %L Number of lines in the article (integer)
868 %I Indentation based on thread level (a string of spaces)
869 %T A string with two possible values: 80 spaces if the article
870 is on thread level two or larger and 0 spaces on level one
871 %R \"R\" if this article has been replied to, \" \" otherwise (character)
872 %U Status of this article (character, \"D\", \"K\", \"-\" or \" \")
873 %[ Opening bracket (character, \"[\" or \"<\")
874 %] Closing bracket (character, \"]\" or \">\")
875 %> Spaces of length thread-level (string)
876 %< Spaces of length (- 20 thread-level) (string)
877 %i Article score (number)
878 %z Article zcore (character)
879 %t Number of articles under the current thread.
880 %u User defined specifier. The next character in the format string should
881 be a letter. Gnus will call the function gnus-user-format-function-X,
882 where X is the letter following %u. The function will be passed the
883 current header as argument. The function should return a string, which
884 will be inserted into the summary just like information from any other
887 Text between %( and %) will be highlighted with `gnus-mouse-face'
888 when the mouse point is placed inside the area. There can only be one
891 The %U (status), %R (replied) and %z (zcore) specs have to be handled
892 with care. For reasons of efficiency, Gnus will compute what column
893 these characters will end up in, and \"hard-code\" that. This means that
894 it is illegal to have these specs after a variable-length spec. Well,
895 you might not be arrested, but your summary buffer will look strange,
898 The smart choice is to have these specs as for to the left as
901 This restriction may disappear in later versions of Gnus.")
903 (defvar gnus-summary-dummy-line-format "* : : %S\n"
904 "*The format specification for the dummy roots in the summary buffer.
905 It works along the same lines as a normal formatting string,
906 with some simple extensions.
910 (defvar gnus-summary-mode-line-format "(ding) %G/%A %Z"
911 "*The format specification for the summary mode line.")
913 (defvar gnus-article-mode-line-format "(ding) %G/%A %S"
914 "*The format specification for the article mode line.")
916 (defvar gnus-group-mode-line-format "(ding) List of groups {%M:%S} "
917 "*The format specification for the group mode line.")
919 (defvar gnus-valid-select-methods
920 '(("nntp" post address prompt-address)
922 ("nnvirtual" none virtual prompt-address address)
923 ("nnmbox" mail respool)
924 ("nnml" mail respool)
925 ("nnmh" mail respool)
926 ("nndir" none prompt-address address)
928 ("nndoc" none prompt-address)
929 ("nnbabyl" mail respool)
930 ("nnkiboze" none virtual)
931 ("nnfolder" mail respool))
932 "An alist of valid select methods.
933 The first element of each list lists should be a string with the name
934 of the select method. The other elements may be be the category of
935 this method (ie. `post', `mail', `none' or whatever) or other
936 properties that this method has (like being respoolable).
937 If you implement a new select method, all you should have to change is
938 this variable. I think.")
940 (defvar gnus-updated-mode-lines '(group article summary)
941 "*List of buffers that should update their mode lines.
942 The list may contain the symbols `group', `article' and `summary'. If
943 the corresponding symbol is present, Gnus will keep that mode line
944 updated with information that may be pertinent.
945 If this variable is nil, screen refresh may be quicker.")
947 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
948 (defvar gnus-mode-non-string-length 21
949 "*Max length of mode-line non-string contents.
950 If this is nil, Gnus will take space as is needed, leaving the rest
951 of the modeline intact.")
953 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
954 (defvar gnus-mouse-face 'highlight
955 "*Face used for mouse highlighting in Gnus.
956 No mouse highlights will be done if `gnus-visual' is nil.")
958 (defvar gnus-summary-mark-below nil
959 "*Mark all articles with a score below this variable as read.
960 This variable is local to each summary buffer and usually set by the
963 (defvar gnus-orphan-score nil
964 "*All orphans get this score added. Set in the score file.")
966 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
967 "*List of functions used for sorting threads in the summary buffer.
968 By default, threads are sorted by article number.
970 Each function takes two threads and return non-nil if the first thread
971 should be sorted before the other. If you use more than one function,
972 the primary sort function should be the last.
974 Ready-mady functions include `gnus-thread-sort-by-number',
975 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
976 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
977 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
979 The latter two only work on threads that have been scored prior to
980 entering the newsgroup.")
982 (defvar gnus-thread-score-function '+
983 "*Function used for calculating the total score of a thread.
985 The function is called with the scores of the article and each
986 subthread and should then return the score of the thread.
988 Some functions you can use are `+', `max', or `min'.")
990 (defvar gnus-score-find-score-files-function 'gnus-score-find-bnews
991 "*Function used to find SCORE files.
992 The function will be called with the group name as the argument, and
993 should return a list of score files to apply to that group. The score
994 files do not actually have to exist.
996 Predefined values are:
998 gnus-score-find-single: Only apply the group's own SCORE file.
999 gnus-score-find-hierarchical: Also apply SCORE files from parent groups.
1000 gnus-score-find-bnews: Apply SCORE files whose names matches.
1002 See the documentation to these functions for more information.
1004 This variable can also be a list of functions to be called. Each
1005 function should either return a list of score files, or a list of
1008 (defvar gnus-options-subscribe nil
1009 "*All new groups matching this regexp will be subscribed unconditionally.
1010 Note that this variable deals only with new newsgroups. This variable
1011 does not affect old newsgroups.")
1013 (defvar gnus-options-not-subscribe nil
1014 "*All new groups matching this regexp will be ignored.
1015 Note that this variable deals only with new newsgroups. This variable
1016 does not affect old (already subscribed) newsgroups.")
1018 (defvar gnus-auto-expirable-newsgroups nil
1019 "*Groups in which to automatically mark read articles as expirable.
1020 If non-nil, this should be a regexp that should match all groups in
1021 which to perform auto-expiry. This only makes sense for mail groups.")
1026 (defvar gnus-group-mode-hook nil
1027 "*A hook for Gnus group mode.")
1029 (defvar gnus-summary-mode-hook nil
1030 "*A hook for Gnus summary mode.")
1032 (defvar gnus-article-mode-hook nil
1033 "*A hook for Gnus article mode.")
1035 (defvar gnus-open-server-hook nil
1036 "*A hook called just before opening connection to the news server.")
1038 (defvar gnus-startup-hook nil
1039 "*A hook called at startup.
1040 This hook is called after Gnus is connected to the NNTP server.")
1042 (defvar gnus-get-new-news-hook nil
1043 "*A hook run just before Gnus checks for new news.")
1045 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1046 "*A function that is called to generate the group buffer.
1047 The function is called with three arguments: The first is a number;
1048 all group with a level less or equal to that number should be listed,
1049 if the second is non-nil, empty groups should also be displayed. If
1050 the third is non-nil, it is a number. No groups with a level lower
1051 than this number should be displayed.
1053 The only current function implemented is `gnus-group-prepare-flat'.")
1055 (defvar gnus-group-prepare-hook nil
1056 "*A hook called after the group buffer has been generated.
1057 If you want to modify the group buffer, you can use this hook.")
1059 (defvar gnus-summary-prepare-hook nil
1060 "*A hook called after the summary buffer has been generated.
1061 If you want to modify the summary buffer, you can use this hook.")
1063 (defvar gnus-article-prepare-hook nil
1064 "*A hook called after an article has been prepared in the article buffer.
1065 If you want to run a special decoding program like nkf, use this hook.")
1067 (defvar gnus-article-display-hook nil
1068 "*A hook called after the article is displayed in the article buffer.
1069 The hook is designed to change the contents of the article
1070 buffer. Typical functions that this hook may contain are
1071 `gnus-article-hide-headers' (hide selected headers),
1072 `gnus-article-hide-signature' (hide signature) and
1073 `gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1074 (add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1075 (add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1077 (defconst gnus-article-x-face-command "uncompface | ikon2xbm | xv -"
1078 "String or function to be executed to display an X-Face header.
1079 If it is a string, the command will be executed in a sub-shell
1080 asynchronously. The compressed face will be piped to this command.")
1082 (defvar gnus-select-group-hook nil
1083 "*A hook called when a newsgroup is selected.
1085 If you'd like to simplify subjects like the
1086 `gnus-summary-next-same-subject' command does, you can use the
1089 (setq gnus-select-group-hook
1092 (mapcar (lambda (header)
1095 (gnus-simplify-subject
1096 (header-subject header) 're-only)))
1097 gnus-newsgroup-headers))))")
1099 (defvar gnus-select-article-hook
1100 '(gnus-summary-show-thread)
1101 "*A hook called when an article is selected.
1102 The default hook shows conversation thread subtrees of the selected
1103 article automatically using `gnus-summary-show-thread'.")
1105 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1106 "*A hook called to apply kill files to a group.
1107 This hook is intended to apply a kill file to the selected newsgroup.
1108 The function `gnus-apply-kill-file' is called by default.
1110 Since a general kill file is too heavy to use only for a few
1111 newsgroups, I recommend you to use a lighter hook function. For
1112 example, if you'd like to apply a kill file to articles which contains
1113 a string `rmgroup' in subject in newsgroup `control', you can use the
1116 \(setq gnus-apply-kill-hook
1119 (cond ((string-match \"control\" gnus-newsgroup-name)
1120 (gnus-kill \"Subject\" \"rmgroup\")
1121 (gnus-expunge \"X\"))))))")
1123 (defvar gnus-visual-mark-article-hook
1124 (list 'gnus-visual-highlight-selected-summary)
1125 "*Hook run after selecting an article in the summary buffer.
1126 It is meant to be used for highlighting the article in some way. It
1127 is not run if `gnus-visual' is nil.")
1129 (defvar gnus-prepare-article-hook (list 'gnus-inews-insert-signature)
1130 "*A hook called after preparing body, but before preparing header headers.
1131 The default hook (`gnus-inews-insert-signature') inserts a signature
1132 file specified by the variable `gnus-signature-file'.")
1134 (defvar gnus-inews-article-hook (list 'gnus-inews-do-fcc)
1135 "*A hook called before finally posting an article.
1136 The default hook (`gnus-inews-do-fcc') does FCC processing (ie. saves
1137 the article to a file).")
1139 (defvar gnus-inews-article-header-hook nil
1140 "*A hook called after inserting the headers in an article to be posted.
1141 The hook is called from the *post-news* buffer, narrowed to the
1144 (defvar gnus-exit-group-hook nil
1145 "*A hook called when exiting (not quitting) summary mode.")
1147 (defvar gnus-suspend-gnus-hook nil
1148 "*A hook called when suspending (not exiting) Gnus.")
1150 (defvar gnus-exit-gnus-hook nil
1151 "*A hook called when exiting Gnus.")
1153 (defvar gnus-save-newsrc-hook nil
1154 "*A hook called when saving the newsrc file.")
1156 (defvar gnus-visual-summary-update-hook
1157 (list 'gnus-visual-summary-highlight-line)
1158 "*A hook called when a summary line is changed.
1159 The hook will not be called if `gnus-visual' is nil.
1161 The default function `gnus-visual-summary-highlight-line' will
1162 highlight the line according to the `gnus-visual-summary-highlight'
1165 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1166 "*A hook called when an article is selected for the first time.
1167 The hook is intended to mark an article as read (or unread)
1168 automatically when it is selected.")
1170 ;; Site dependent variables. These variables should be defined in
1173 (defvar gnus-default-nntp-server nil
1174 "*Specify a default NNTP server.
1175 This variable should be defined in paths.el, and should never be set
1177 If you want to change servers, you should use `gnus-select-method'.
1178 See the documentation to that variable.")
1180 (defconst gnus-backup-default-subscribed-newsgroups
1181 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
1182 "Default default new newsgroups the first time Gnus is run.
1183 Should be set in paths.el, and shouldn't be touched by the user.")
1185 (defvar gnus-local-domain nil
1186 "*Local domain name without a host name.
1187 The DOMAINNAME environment variable is used instead if it is defined.
1188 If the `system-name' function returns the full Internet name, there is
1189 no need to set this variable.")
1191 (defvar gnus-local-organization nil
1192 "*String with a description of what organization (if any) the user belongs to.
1193 The ORGANIZATION environment variable is used instead if it is defined.
1194 If this variable contains a function, this function will be called
1195 with the current newsgroup name as the argument. The function should
1197 In any case, if the string (either in the variable, in the environment
1198 variable, or returned by the function) is a file name, the contents of
1199 this file will be used as the organization.")
1201 (defvar gnus-use-generic-from nil
1202 "*If nil, the full host name will be the system name prepended to the domain name.
1203 If this is a string, the full host name will be this string.
1204 If this is non-nil, non-string, the domain name will be used as the
1207 (defvar gnus-use-generic-path nil
1208 "*If nil, use the NNTP server name in the Path header.
1209 If stringp, use this; if non-nil, use no host name (user name only).")
1212 ;; Internal variables
1214 ;; Avoid highlighting in kill files.
1215 (defvar gnus-summary-inhibit-highlight nil)
1216 (defvar gnus-newsgroup-selected-overlay nil)
1218 (defvar gnus-article-mode-map nil)
1219 (defvar caesar-translate-table nil)
1220 (defvar gnus-dribble-buffer nil)
1221 (defvar gnus-headers-retrieved-by nil)
1222 (defvar gnus-article-reply nil)
1223 (defvar gnus-override-method nil)
1224 (defvar gnus-article-check-size nil)
1225 (defvar gnus-score-file-list nil)
1226 (defvar gnus-internal-global-score-files nil)
1227 (defvar gnus-current-score-file nil)
1229 (defvar gnus-current-move-group nil)
1231 (defvar gnus-score-alist nil
1232 "Alist containing score information.
1233 The keys can be symbols or strings. The following symbols are defined.
1235 touched: If this alist has been modified.
1236 mark: Automatically mark articles below this.
1237 expunge: Automatically expunge articles below this.
1238 files: List of other SCORE files to load when loading this one.
1239 eval: Sexp to be evaluated when the score file is loaded.
1241 String entries have the form (HEADER (MATCH TYPE SCORE DATE) ...)
1242 where HEADER is the header being scored, MATCH is the string we are
1243 looking for, TYPE is a flag indicating whether it should use regexp or
1244 substring matching, SCORE is the score to add and DATE is the date
1245 of the last succesful match.")
1247 (defvar gnus-score-cache nil)
1248 (defvar gnus-scores-articles nil)
1249 (defvar gnus-scores-exclude-files nil)
1250 (defvar gnus-header-index nil)
1251 (defvar gnus-score-index nil)
1253 (defvar gnus-newsgroup-dependencies nil)
1254 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1256 (defconst gnus-group-line-format-alist
1257 (list (list ?M 'marked ?c)
1258 (list ?S 'subscribed ?c)
1260 (list ?N 'number ?s)
1261 (list ?I 'number-of-dormant ?d)
1262 (list ?T 'number-of-ticked ?d)
1263 (list ?R 'number-of-read ?s)
1264 (list ?t 'number-total ?d)
1265 (list ?y 'number-of-unread-unticked ?s)
1266 (list ?i 'number-of-ticked-and-dormant ?d)
1268 (list ?G 'qualified-group ?s)
1269 (list ?D 'newsgroup-description ?s)
1270 (list ?o 'moderated ?c)
1271 (list ?O 'moderated-string ?s)
1272 (list ?s 'news-server ?s)
1273 (list ?n 'news-method ?s)
1274 (list ?z 'news-method-string ?s)
1275 (list ?u 'user-defined ?s)))
1277 (defconst gnus-summary-line-format-alist
1278 (list (list ?N 'number ?s)
1279 (list ?S 'subject ?s)
1280 (list ?s 'subject-or-nil ?s)
1282 (list ?A 'address ?s)
1284 (list ?x (macroexpand '(header-xref header)) ?s)
1285 (list ?D (macroexpand '(header-date header)) ?s)
1286 (list ?d '(gnus-dd-mmm (header-date header)) ?s)
1287 (list ?M (macroexpand '(header-id header)) ?s)
1288 (list ?r (macroexpand '(header-references header)) ?s)
1289 (list ?c (macroexpand '(header-chars header)) ?d)
1291 (list ?I 'indentation ?s)
1292 (list ?T '(if (< level 1) "" (make-string (frame-width) ? )) ?s)
1293 (list ?R 'replied ?c)
1294 (list ?\[ 'opening-bracket ?c)
1295 (list ?\] 'closing-bracket ?c)
1296 (list ?\> '(make-string level ? ) ?s)
1297 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1299 (list ?z 'score-char ?c)
1300 (list ?U 'unread ?c)
1301 (list ?t '(gnus-summary-number-of-articles-in-thread thread) ?d)
1302 (list ?u 'user-defined ?s))
1303 "An alist of format specifications that can appear in summary lines,
1304 and what variables they correspond with, along with the type of the
1305 variable (string, integer, character, etc).")
1307 (defconst gnus-summary-dummy-line-format-alist
1308 (list (list ?S 'subject ?s)
1309 (list ?N 'number ?d)
1310 (list ?u 'user-defined ?s)))
1312 (defconst gnus-summary-mode-line-format-alist
1313 (list (list ?G 'group-name ?s)
1314 (list ?g '(gnus-short-group-name group-name) ?s)
1315 (list ?A 'article-number ?d)
1316 (list ?Z 'unread-and-unselected ?s)
1317 (list ?V 'gnus-version ?s)
1318 (list ?U 'unread ?d)
1319 (list ?S 'subject ?s)
1320 (list ?e 'unselected ?d)
1321 (list ?u 'user-defined ?s)
1322 (list ?s '(gnus-current-score-file-nondirectory)?s)))
1324 (defconst gnus-group-mode-line-format-alist
1325 (list (list ?S 'news-server ?s)
1326 (list ?M 'news-method ?s)
1327 (list ?u 'user-defined ?s)))
1329 (defvar gnus-have-read-active-file nil)
1331 (defconst gnus-maintainer "Lars Magne Ingebrigtsen <larsi@ifi.uio.no>"
1332 "The mail address of the Gnus maintainer.")
1334 (defconst gnus-version "(ding) Gnus v0.54"
1335 "Version number for this version of Gnus.")
1337 (defvar gnus-info-nodes
1338 '((gnus-group-mode "(gnus)The Group Buffer")
1339 (gnus-summary-mode "(gnus)The Summary Buffer")
1340 (gnus-article-mode "(gnus)The Article Buffer"))
1341 "Assoc list of major modes and related Info nodes.")
1343 (defvar gnus-documentation-group-file "~/dgnus/lisp/doc.txt"
1344 "The location of the (ding) Gnus documentation group.")
1346 (defvar gnus-group-buffer "*Group*")
1347 (defvar gnus-summary-buffer "*Summary*")
1348 (defvar gnus-article-buffer "*Article*")
1349 (defvar gnus-server-buffer "*Server*")
1351 (defvar gnus-buffer-list nil
1352 "Gnus buffers that should be killed on exit.")
1354 (defvar gnus-server-alist nil
1355 "List of available servers.")
1357 (defvar gnus-variable-list
1358 '(gnus-newsrc-options gnus-newsrc-options-n
1359 gnus-newsrc-last-checked-date
1360 gnus-newsrc-assoc gnus-server-alist
1361 gnus-killed-list gnus-zombie-list)
1362 "Gnus variables saved in the quick startup file.")
1364 (defvar gnus-overload-functions
1365 '((news-inews gnus-inews-news "rnewspost")
1366 (caesar-region gnus-caesar-region "rnews"))
1367 "Functions overloaded by gnus.
1368 It is a list of `(original overload &optional file)'.")
1370 (defvar gnus-newsrc-options nil
1371 "Options line in the .newsrc file.")
1373 (defvar gnus-newsrc-options-n nil
1374 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1376 (defvar gnus-newsrc-last-checked-date nil
1377 "Date Gnus last asked server for new newsgroups.")
1379 (defvar gnus-newsrc-assoc nil
1380 "Assoc list of read articles.
1381 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1383 (defvar gnus-newsrc-hashtb nil
1384 "Hashtable of gnus-newsrc-assoc.")
1386 (defvar gnus-killed-list nil
1387 "List of killed newsgroups.")
1389 (defvar gnus-killed-hashtb nil
1390 "Hash table equivalent of gnus-killed-list.")
1392 (defvar gnus-zombie-list nil
1393 "List of almost dead newsgroups.")
1395 (defvar gnus-description-hashtb nil
1396 "Descriptions of newsgroups.")
1398 (defvar gnus-list-of-killed-groups nil
1399 "List of newsgroups that have recently been killed by the user.")
1401 (defvar gnus-active-hashtb nil
1402 "Hashtable of active articles.")
1404 (defvar gnus-moderated-list nil
1405 "List of moderated newsgroups.")
1407 (defvar gnus-current-startup-file nil
1408 "Startup file for the current host.")
1410 (defvar gnus-last-search-regexp nil
1411 "Default regexp for article search command.")
1413 (defvar gnus-last-shell-command nil
1414 "Default shell command on article.")
1416 (defvar gnus-current-select-method nil
1417 "The current method for selecting a newsgroup.")
1419 (defvar gnus-have-all-newsgroups nil)
1421 (defvar gnus-article-internal-prepare-hook nil)
1423 (defvar gnus-newsgroup-name nil)
1424 (defvar gnus-newsgroup-begin nil)
1425 (defvar gnus-newsgroup-end nil)
1426 (defvar gnus-newsgroup-last-rmail nil)
1427 (defvar gnus-newsgroup-last-mail nil)
1428 (defvar gnus-newsgroup-last-folder nil)
1429 (defvar gnus-newsgroup-last-file nil)
1430 (defvar gnus-newsgroup-auto-expire nil)
1431 (defvar gnus-newsgroup-active nil)
1433 (defvar gnus-newsgroup-unreads nil
1434 "List of unread articles in the current newsgroup.")
1436 (defvar gnus-newsgroup-unselected nil
1437 "List of unselected unread articles in the current newsgroup.")
1439 (defvar gnus-newsgroup-marked nil
1440 "List of ticked articles in the current newsgroup (a subset of unread art).")
1442 (defvar gnus-newsgroup-killed nil
1443 "List of ranges of articles that have been through the scoring process.")
1445 (defvar gnus-newsgroup-kill-headers nil)
1447 (defvar gnus-newsgroup-replied nil
1448 "List of articles that have been replied to in the current newsgroup.")
1450 (defvar gnus-newsgroup-expirable nil
1451 "List of articles in the current newsgroup that can be expired.")
1453 (defvar gnus-newsgroup-processable nil
1454 "List of articles in the current newsgroup that can be processed.")
1456 (defvar gnus-newsgroup-bookmarks nil
1457 "List of articles in the current newsgroup that have bookmarks.")
1459 (defvar gnus-newsgroup-dormant nil
1460 "List of dormant articles in the current newsgroup.")
1462 (defvar gnus-newsgroup-scored nil
1463 "List of scored articles in the current newsgroup.")
1465 (defvar gnus-newsgroup-headers nil
1466 "List of article headers in the current newsgroup.")
1467 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1469 (defvar gnus-newsgroup-ancient nil
1470 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1472 (defvar gnus-current-article nil)
1473 (defvar gnus-article-current nil)
1474 (defvar gnus-current-headers nil)
1475 (defvar gnus-have-all-headers nil)
1476 (defvar gnus-last-article nil)
1477 (defvar gnus-newsgroup-history nil)
1478 (defvar gnus-current-kill-article nil)
1480 ;; Save window configuration.
1481 (defvar gnus-winconf-edit-group nil)
1482 (defvar gnus-winconf-edit-score nil)
1485 (defvar gnus-summary-line-format-spec nil)
1486 (defvar gnus-summary-dummy-line-format-spec nil)
1487 (defvar gnus-group-line-format-spec nil)
1488 (defvar gnus-summary-mode-line-format-spec nil)
1489 (defvar gnus-article-mode-line-format-spec nil)
1490 (defvar gnus-group-mode-line-format-spec nil)
1491 (defvar gnus-summary-mark-positions nil)
1493 (defvar gnus-summary-expunge-below nil)
1494 (defvar gnus-reffed-article-number nil)
1496 (defvar rmail-default-file (expand-file-name "~/XMBOX"))
1497 (defvar rmail-default-rmail-file (expand-file-name "~/XNEWS"))
1499 (defconst gnus-summary-local-variables
1500 '(gnus-newsgroup-name
1501 gnus-newsgroup-begin gnus-newsgroup-end
1502 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1503 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1504 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1505 gnus-newsgroup-unselected gnus-newsgroup-marked
1506 gnus-newsgroup-replied gnus-newsgroup-expirable
1507 gnus-newsgroup-processable gnus-newsgroup-killed
1508 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1509 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1510 gnus-current-article gnus-current-headers gnus-have-all-headers
1511 gnus-last-article gnus-article-internal-prepare-hook
1512 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1513 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1514 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1515 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1516 gnus-newsgroup-history gnus-newsgroup-ancient)
1517 "Variables that are buffer-local to the summary buffers.")
1519 ;;; End of variables.
1521 ;; Define some autoload functions Gnus might use.
1523 (autoload 'metamail-buffer "metamail")
1524 (autoload 'Info-goto-node "info")
1526 (autoload 'timezone-make-date-arpa-standard "timezone")
1527 (autoload 'timezone-fix-time "timezone")
1528 (autoload 'timezone-make-sortable-date "timezone")
1529 (autoload 'timezone-make-time-string "timezone")
1531 (autoload 'rmail-output "rmailout")
1532 (autoload 'mail-position-on-field "sendmail")
1533 (autoload 'mail-setup "sendmail")
1534 (autoload 'news-mail-other-window "rnewspost")
1535 (autoload 'news-reply-yank-original "rnewspost")
1537 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1538 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1539 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1540 (autoload 'gnus-summary-save-in-folder "gnus-mh")
1541 (autoload 'gnus-Folder-save-name "gnus-mh")
1542 (autoload 'gnus-folder-save-name "gnus-mh")
1544 (autoload 'gnus-group-make-menu-bar "gnus-visual")
1545 (autoload 'gnus-summary-make-menu-bar "gnus-visual")
1546 (autoload 'gnus-article-make-menu-bar "gnus-visual")
1547 (autoload 'gnus-visual-highlight-selected-summary "gnus-visual")
1548 (autoload 'gnus-visual-summary-highlight-line "gnus-visual")
1550 (autoload 'gnus-uu-mark-by-regexp "gnus-uu")
1551 (autoload 'gnus-uu-mark-region "gnus-uu")
1552 (autoload 'gnus-uu-mark-thread "gnus-uu")
1553 (autoload 'gnus-uu-mark-sparse "gnus-uu")
1554 (autoload 'gnus-uu-mark-series "gnus-uu")
1555 (autoload 'gnus-uu-mark-all "gnus-uu")
1556 (autoload 'gnus-uu-post-news "gnus-uu")
1557 (autoload 'gnus-uu-digest-and-forward "gnus-uu")
1559 (autoload 'gnus-uu-decode-uu "gnus-uu")
1560 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu")
1561 (autoload 'gnus-uu-decode-unshar "gnus-uu")
1562 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu")
1563 (autoload 'gnus-uu-decode-save "gnus-uu")
1564 (autoload 'gnus-uu-decode-binhex "gnus-uu")
1565 (autoload 'gnus-uu-decode-uu-view "gnus-uu")
1566 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu")
1567 (autoload 'gnus-uu-decode-unshar-view "gnus-uu")
1568 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu")
1569 (autoload 'gnus-uu-decode-save-view "gnus-uu")
1570 (autoload 'gnus-uu-decode-binhex-view "gnus-uu")
1571 (autoload 'gnus-uu-decode-postscript "gnus-uu")
1572 (autoload 'gnus-uu-decode-postscript-and-save "gnus-uu")
1573 (autoload 'gnus-uu-decode-postscript-view "gnus-uu")
1574 (autoload 'gnus-uu-decode-postscript-and-save-view "gnus-uu")
1576 (autoload 'gnus-kill "gnus-kill")
1577 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1578 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1579 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1580 (autoload 'gnus-execute "gnus-kill")
1583 (autoload 'pp-to-string "pp")
1584 (autoload 'mail-extract-address-components "mail-extr")
1589 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1590 ;; If you want the cursor to go somewhere else, set these two
1591 ;; functions in some startup hook to whatever you want.
1592 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon)
1593 (defalias 'gnus-group-position-cursor 'gnus-goto-colon)
1595 ;; Cruft to make Gnus work under GNU XEmacs.
1596 (defvar gnus-xemacs nil
1597 "Non-nil if Gnus is running under GNU XEmacs.")
1599 (if (not (string-match "XEmacs\\|Lucid" emacs-version))
1601 (setq gnus-xemacs t)
1603 '((or (memq 'underline (list-faces))
1604 (make-face 'underline))
1605 (or (face-differs-from-default-p 'underline)
1606 (set-face-underline-p 'underline t))
1608 (defun set-text-properties (start end props &optional buffer)
1610 (put-text-property start end (car props) (cadr props) buffer)
1611 (remove-text-properties start end ()))))))
1614 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1615 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1616 (` (let ((GnusStartBufferWindow (selected-window)))
1619 (pop-to-buffer (, buffer))
1621 (select-window GnusStartBufferWindow)))))
1623 (defun gnus-make-hashtable (&optional hashsize)
1624 "Make a hash table (default and minimum size is 255).
1625 Optional argument HASHSIZE specifies the table size."
1626 (make-vector (if hashsize
1627 (max (gnus-create-hash-size hashsize) 255)
1630 (defmacro gnus-gethash (string hashtable)
1631 "Get hash value of STRING in HASHTABLE."
1632 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1633 ;;(` (abbrev-expansion (, string) (, hashtable)))
1634 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1636 (defmacro gnus-sethash (string value hashtable)
1637 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1638 ;; We cannot use define-abbrev since it only accepts string as value.
1639 ; (set (intern string hashtable) value))
1640 (` (set (intern (, string) (, hashtable)) (, value))))
1642 (defsubst gnus-buffer-substring (beg end)
1643 (buffer-substring (match-beginning beg) (match-end end)))
1645 (defsubst gnus-simplify-subject-re (subject)
1646 "Remove \"Re:\" from subject lines."
1647 (let ((case-fold-search t))
1648 (if (string-match "^re: *" subject)
1649 (substring subject (match-end 0))
1652 (defsubst gnus-goto-char (point)
1653 (and point (goto-char point)))
1655 (defsubst gnus-point-at-bol ()
1656 "Return point at the beginning of line."
1663 (defsubst gnus-point-at-eol ()
1664 "Return point at the beginning of line."
1673 ;;; Gnus Utility Functions
1676 (defun gnus-extract-address-components (from)
1678 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1679 (setq address (substring from (match-beginning 0) (match-end 0))))
1681 (string-match (concat "<" (regexp-quote address) ">") from)
1682 (setq name (substring from 0 (1- (match-beginning 0)))))
1684 (and (string-match "(.+)" from)
1685 (setq name (substring from (1+ (match-beginning 0))
1686 (1- (match-end 0))))))
1687 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1688 (list (or name from) (or address from))))
1690 (defun gnus-fetch-field (field)
1691 "Return the value of the header FIELD of current article."
1694 (gnus-narrow-to-headers)
1695 (mail-fetch-field field))))
1697 (defun gnus-goto-colon ()
1699 (search-forward ":" (gnus-point-at-eol) t))
1701 (defun gnus-narrow-to-headers ()
1705 (if (search-forward "\n\n")
1706 (narrow-to-region 1 (1- (point))))))
1708 ;; Get a number that is suitable for hashing; bigger than MIN
1709 (defun gnus-create-hash-size (min)
1715 (defun gnus-update-format-specifications ()
1716 (setq gnus-summary-line-format-spec
1718 gnus-summary-line-format gnus-summary-line-format-alist))
1719 (gnus-update-summary-mark-positions)
1720 (setq gnus-summary-dummy-line-format-spec
1721 (gnus-parse-format gnus-summary-dummy-line-format
1722 gnus-summary-dummy-line-format-alist))
1723 (setq gnus-group-line-format-spec
1725 gnus-group-line-format
1726 gnus-group-line-format-alist))
1727 (if (and (string-match "%D" gnus-group-line-format)
1728 (not gnus-description-hashtb)
1729 gnus-read-active-file)
1730 (gnus-read-descriptions-file))
1731 (setq gnus-summary-mode-line-format-spec
1732 (gnus-parse-format gnus-summary-mode-line-format
1733 gnus-summary-mode-line-format-alist))
1734 (setq gnus-article-mode-line-format-spec
1735 (gnus-parse-format gnus-article-mode-line-format
1736 gnus-summary-mode-line-format-alist))
1737 (setq gnus-group-mode-line-format-spec
1738 (gnus-parse-format gnus-group-mode-line-format
1739 gnus-group-mode-line-format-alist)))
1741 (defun gnus-update-summary-mark-positions ()
1743 (let ((gnus-replied-mark 129)
1744 (gnus-score-below-mark 130)
1745 (gnus-score-over-mark 130)
1748 (set-buffer (get-buffer-create " *gnus work*"))
1749 (buffer-disable-undo (current-buffer))
1751 (gnus-summary-insert-line
1752 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1753 (goto-char (point-min))
1754 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1756 (goto-char (point-min))
1757 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1758 (- (point) 2))) pos))
1759 (goto-char (point-min))
1760 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1761 (- (point) 2))) pos))
1762 (setq gnus-summary-mark-positions pos)
1763 (kill-buffer (current-buffer)))))
1765 (defun gnus-format-max-width (var length)
1767 (if (> (length (setq result (eval var))) length)
1768 (format "%s" (substring result 0 length))
1769 (format "%s" result))))
1771 (defun gnus-set-mouse-face (string)
1772 ;; Set mouse face property on STRING.
1774 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string))
1777 (defun gnus-parse-format (format spec-alist)
1778 ;; This function parses the FORMAT string with the help of the
1779 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1780 ;; string. If the FORMAT string contains the specifiers %( and %)
1781 ;; the text between them will have the mouse-face text property.
1782 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1783 (if (and gnus-visual gnus-mouse-face)
1784 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1785 (button (substring format (match-beginning 2) (match-end 2)))
1786 (post (substring format (match-beginning 3) (match-end 3))))
1788 (gnus-parse-simple-format pre spec-alist)
1789 (list 'gnus-set-mouse-face
1790 (gnus-parse-simple-format button spec-alist))
1791 (gnus-parse-simple-format post spec-alist)))
1792 (gnus-parse-simple-format
1793 (concat (substring format (match-beginning 1) (match-end 1))
1794 (substring format (match-beginning 2) (match-end 2))
1795 (substring format (match-beginning 3) (match-end 3)))
1797 (gnus-parse-simple-format format spec-alist)))
1799 (defun gnus-parse-simple-format (format spec-alist)
1800 ;; This function parses the FORMAT string with the help of the
1801 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1802 ;; string. The list will consist of the symbol `format', a format
1803 ;; specification string, and a list of forms depending on the
1806 spec flist fstring b newspec max-width elem beg)
1808 (set-buffer (get-buffer-create " *gnus work*"))
1809 (buffer-disable-undo (current-buffer))
1810 (gnus-add-current-to-buffer-list)
1814 (while (re-search-forward "%[-0-9]*\\(,[0-9]*\\)*\\(.\\)\\(.\\)?" nil t)
1815 (setq spec (string-to-char (buffer-substring (match-beginning 2)
1817 ;; First check if there are any specs that look anything like
1818 ;; "%12,12A", ie. with a "max width specification". These have
1819 ;; to be treated specially.
1820 (if (setq beg (match-beginning 1))
1823 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
1825 (setq beg (match-beginning 2)))
1826 ;; Find the specification from `spec-alist'.
1827 (if (not (setq elem (cdr (assq spec spec-alist))))
1828 (setq elem '("*" ?s)))
1829 ;; Treat user defined format specifiers specially
1830 (and (eq (car elem) 'user-defined)
1833 (list (intern (concat "gnus-user-format-function-"
1839 (delete-region (match-beginning 3) (match-end 3)))
1840 (if (not (zerop max-width))
1841 (let ((el (car elem)))
1842 (cond ((= (car (cdr elem)) ?c)
1843 (setq el (list 'char-to-string el)))
1844 ((= (car (cdr elem)) ?d)
1845 (numberp el) (setq el (list 'int-to-string el))))
1846 (setq flist (cons (list 'gnus-format-max-width
1850 (setq flist (cons (car elem) flist))
1851 (setq newspec (car (cdr elem))))
1852 ;; Remove the old specification (and possibly a ",12" string).
1853 (delete-region beg (match-end 2))
1854 ;; Insert the new specification.
1857 (setq fstring (buffer-substring 1 (point-max))))
1858 (cons 'format (cons fstring (nreverse flist)))))
1860 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
1861 (defun gnus-read-init-file ()
1863 (or (and (file-exists-p gnus-init-file)
1864 ;; Don't try to load a directory.
1865 (not (file-directory-p gnus-init-file)))
1866 (file-exists-p (concat gnus-init-file ".el"))
1867 (file-exists-p (concat gnus-init-file ".elc")))
1868 (load gnus-init-file nil t)))
1870 ;; Article file names when saving.
1872 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
1873 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1874 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
1875 Otherwise, it is like ~/News/news/group/num."
1878 (concat (if (gnus-use-long-file-name 'not-save)
1879 (gnus-capitalize-newsgroup newsgroup)
1880 (gnus-newsgroup-directory-form newsgroup))
1881 "/" (int-to-string (header-number headers)))
1882 (or gnus-article-save-directory "~/News"))))
1884 (string-equal (file-name-directory default)
1885 (file-name-directory last-file))
1886 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1888 (or last-file default))))
1890 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
1891 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1892 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group/num.
1893 Otherwise, it is like ~/News/news/group/num."
1896 (concat (if (gnus-use-long-file-name 'not-save)
1898 (gnus-newsgroup-directory-form newsgroup))
1899 "/" (int-to-string (header-number headers)))
1900 (or gnus-article-save-directory "~/News"))))
1902 (string-equal (file-name-directory default)
1903 (file-name-directory last-file))
1904 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1906 (or last-file default))))
1908 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
1909 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1910 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group.
1911 Otherwise, it is like ~/News/news/group/news."
1914 (if (gnus-use-long-file-name 'not-save)
1915 (gnus-capitalize-newsgroup newsgroup)
1916 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1917 (or gnus-article-save-directory "~/News"))))
1919 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
1920 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1921 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group.
1922 Otherwise, it is like ~/News/news/group/news."
1925 (if (gnus-use-long-file-name 'not-save)
1927 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1928 (or gnus-article-save-directory "~/News"))))
1930 ;; For subscribing new newsgroup
1932 (defun gnus-subscribe-hierarchical-interactive (groups)
1933 (let ((groups (sort groups 'string<))
1934 prefixes prefix start rest ans group starts)
1936 (setq prefixes (list "^"))
1937 (while (and groups prefixes)
1938 (while (not (string-match (car prefixes) (car groups)))
1939 (setq prefixes (cdr prefixes)))
1940 (setq prefix (car prefixes))
1941 (setq start (1- (length prefix)))
1942 (if (and (string-match "[^\\.]\\." (car groups) start)
1945 (concat "^" (substring (car groups) 0 (match-end 0))))
1946 (string-match prefix (car (cdr groups))))
1948 (setq prefixes (cons prefix prefixes))
1949 (message "Descend hierarchy %s? ([y]nsq): "
1950 (substring prefix 1 (1- (length prefix))))
1951 (setq ans (read-char))
1954 (string-match prefix
1955 (setq group (car groups))))
1956 (setq gnus-killed-list
1957 (cons group gnus-killed-list))
1958 (gnus-sethash group group gnus-killed-hashtb)
1959 (setq groups (cdr groups)))
1960 (setq starts (cdr starts)))
1963 (string-match prefix
1964 (setq group (car groups))))
1965 (gnus-sethash group group gnus-killed-hashtb)
1966 (gnus-subscribe-alphabetically (car groups))
1967 (setq groups (cdr groups)))
1968 (setq starts (cdr starts)))
1971 (setq group (car groups))
1972 (setq gnus-killed-list (cons group gnus-killed-list))
1973 (gnus-sethash group group gnus-killed-hashtb)
1974 (setq groups (cdr groups))))
1976 (message "Subscribe %s? ([n]yq)" (car groups))
1977 (setq ans (read-char))
1978 (setq group (car groups))
1980 (gnus-subscribe-alphabetically (car groups))
1981 (gnus-sethash group group gnus-killed-hashtb))
1984 (setq group (car groups))
1985 (setq gnus-killed-list (cons group gnus-killed-list))
1986 (gnus-sethash group group gnus-killed-hashtb)
1987 (setq groups (cdr groups))))
1989 (setq gnus-killed-list (cons group gnus-killed-list))
1990 (gnus-sethash group group gnus-killed-hashtb)))
1991 (setq groups (cdr groups)))))))
1993 (defun gnus-subscribe-randomly (newsgroup)
1994 "Subscribe new NEWSGROUP by making it the first newsgroup."
1995 (gnus-subscribe-newsgroup newsgroup))
1997 (defun gnus-subscribe-alphabetically (newgroup)
1998 "Subscribe new NEWSGROUP and insert it in alphabetical order."
1999 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2000 (let ((groups (cdr gnus-newsrc-assoc))
2002 (while (and (not before) groups)
2003 (if (string< newgroup (car (car groups)))
2004 (setq before (car (car groups)))
2005 (setq groups (cdr groups))))
2006 (gnus-subscribe-newsgroup newgroup before)))
2008 (defun gnus-subscribe-hierarchically (newgroup)
2009 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2010 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2012 (set-buffer (find-file-noselect gnus-current-startup-file))
2013 (let ((groupkey newgroup)
2015 (while (and (not before) groupkey)
2016 (goto-char (point-min))
2018 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2019 (while (and (re-search-forward groupkey-re nil t)
2021 (setq before (buffer-substring
2022 (match-beginning 1) (match-end 1)))
2023 (string< before newgroup)))))
2024 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2026 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2027 (substring groupkey (match-beginning 1) (match-end 1)))))
2028 (gnus-subscribe-newsgroup newgroup before))))
2030 (defun gnus-subscribe-interactively (newsgroup)
2031 "Subscribe new NEWSGROUP interactively.
2032 It is inserted in hierarchical newsgroup order if subscribed. If not,
2034 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
2035 (gnus-subscribe-hierarchically newsgroup)
2036 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
2038 (defun gnus-subscribe-zombies (newsgroup)
2039 "Make new NEWSGROUP a zombie group."
2040 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
2042 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2043 "Subscribe new NEWSGROUP.
2044 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2045 the first newsgroup."
2046 ;; We subscribe the group by changing its level to `subscribed'.
2047 (gnus-group-change-level
2048 newsgroup gnus-level-default-subscribed
2049 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2050 (message "Subscribe newsgroup: %s" newsgroup))
2054 (defun gnus-newsgroup-directory-form (newsgroup)
2055 "Make hierarchical directory name from NEWSGROUP name."
2056 (let ((newsgroup (substring newsgroup 0)) ;Copy string.
2057 (len (length newsgroup))
2059 ;; Replace all occurrences of `.' with `/'.
2061 (if (= (aref newsgroup idx) ?.)
2062 (aset newsgroup idx ?/))
2063 (setq idx (1+ idx)))
2067 (defun gnus-make-directory (dir)
2068 "Make DIRECTORY recursively."
2069 (let* ((dir (expand-file-name dir default-directory))
2071 (if (string-match "/$" dir)
2072 (setq dir (substring dir 0 (match-beginning 0))))
2073 (while (not (file-exists-p dir))
2074 (setq dirs (cons dir dirs))
2075 (string-match "/[^/]+$" dir)
2076 (setq dir (substring dir 0 (match-beginning 0))))
2078 (make-directory (car dirs))
2079 (setq dirs (cdr dirs)))))
2081 (defun gnus-capitalize-newsgroup (newsgroup)
2082 "Capitalize NEWSGROUP name."
2083 (and (not (zerop (length newsgroup)))
2084 (concat (char-to-string (upcase (aref newsgroup 0)))
2085 (substring newsgroup 1))))
2089 (defun gnus-simplify-subject (subject &optional re-only)
2090 "Remove `Re:' and words in parentheses.
2091 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2092 (let ((case-fold-search t)) ;Ignore case.
2093 ;; Remove `Re:' and `Re^N:'.
2094 (if (string-match "^re:[ \t]*" subject)
2095 (setq subject (substring subject (match-end 0))))
2096 ;; Remove words in parentheses from end.
2098 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2099 (setq subject (substring subject 0 (match-beginning 0)))))
2100 ;; Return subject string.
2103 (defun gnus-simplify-subject-fuzzy (subject)
2104 (let ((case-fold-search t))
2105 (and (string-match "^re:[ \t]*" subject)
2106 (setq subject (substring subject (match-end 0))))
2107 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2108 (setq subject (substring subject 0 (match-beginning 0))))
2111 (while (string-match "[ \t]+" subject beg)
2113 (concat osubject (substring
2114 subject beg (match-beginning 0)) " ")
2116 (setq osubject (concat osubject (substring subject beg)))
2117 (and (string-match " \\'" osubject)
2118 (setq osubject (substring osubject 0 (match-beginning 0))))
2121 (defun gnus-add-current-to-buffer-list ()
2122 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list)))
2124 (defun gnus-string> (s1 s2)
2125 (not (or (string< s1 s2)
2128 ;; Functions accessing headers.
2129 ;; Functions are more convenient than macros in some cases.
2131 (defun gnus-header-number (header)
2132 "Return article number in HEADER."
2133 (header-number header))
2135 (defun gnus-header-subject (header)
2136 "Return subject string in HEADER."
2137 (header-subject header))
2139 (defun gnus-header-from (header)
2140 "Return author string in HEADER."
2141 (header-from header))
2143 (defun gnus-header-xref (header)
2144 "Return xref string in HEADER."
2145 (header-xref header))
2147 (defun gnus-header-lines (header)
2148 "Return lines in HEADER."
2149 (header-lines header))
2151 (defun gnus-header-date (header)
2152 "Return date in HEADER."
2153 (header-date header))
2155 (defun gnus-header-id (header)
2156 "Return Id in HEADER."
2159 (defun gnus-header-references (header)
2160 "Return references in HEADER."
2161 (header-references header))
2163 (defun gnus-clear-system ()
2164 "Clear all variables and buffers."
2165 ;; Clear Gnus variables.
2166 (let ((variables gnus-variable-list))
2168 (set (car variables) nil)
2169 (setq variables (cdr variables))))
2170 ;; Clear other internal variables.
2171 (setq gnus-list-of-killed-groups nil
2172 gnus-have-read-active-file nil
2173 gnus-newsrc-assoc nil
2174 gnus-newsrc-hashtb nil
2175 gnus-killed-list nil
2176 gnus-zombie-list nil
2177 gnus-killed-hashtb nil
2178 gnus-active-hashtb nil
2179 gnus-moderated-list nil
2180 gnus-description-hashtb nil
2181 gnus-newsgroup-headers nil
2182 gnus-score-cache nil
2183 gnus-newsgroup-headers-hashtb-by-number nil
2184 gnus-newsgroup-name nil
2185 gnus-internal-global-score-files nil
2186 gnus-server-alist nil
2187 gnus-current-select-method nil)
2188 ;; Kill the startup file.
2189 (and gnus-current-startup-file
2190 (get-file-buffer gnus-current-startup-file)
2191 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2192 (gnus-dribble-clear)
2193 ;; Kill global KILL file buffer.
2194 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2195 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2196 (and (buffer-name nntp-server-buffer)
2197 (kill-buffer nntp-server-buffer))
2198 ;; Kill Gnus buffers.
2199 (while gnus-buffer-list
2200 (if (and (get-buffer (car gnus-buffer-list))
2201 (buffer-name (get-buffer (car gnus-buffer-list))))
2202 (kill-buffer (car gnus-buffer-list)))
2203 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2205 (defun gnus-configure-windows (action &optional force)
2206 "Configure Gnus windows according to the next ACTION.
2207 The ACTION is either a symbol, such as `summary', or a
2208 configuration list such as `(1 1 2)'. If ACTION is not a list,
2209 configuration list is got from the variable gnus-window-configuration.
2210 If FORCE is non-nil, the updating will be done whether it is necessary
2213 (if (listp action) action
2214 (if (listp gnus-window-configuration)
2215 (car (cdr (assq action gnus-window-configuration)))
2216 gnus-window-configuration)))
2217 (grpwin (get-buffer-window gnus-group-buffer))
2218 (subwin (get-buffer-window gnus-summary-buffer))
2219 (artwin (get-buffer-window gnus-article-buffer))
2225 ;; Make split-window-vertically leave focus in upper window.
2226 (split-window-keep-point t))
2227 (if (and (symbolp windows) (fboundp windows))
2228 (funcall windows action)
2229 (if (and (not force)
2230 (or (null windows) ;No configuration is specified.
2231 (and (eq (null grpwin)
2232 (zerop (nth 0 windows)))
2234 (zerop (nth 1 windows)))
2236 (zerop (nth 2 windows))))))
2237 ;; No need to change window configuration.
2239 (select-window (or grpwin subwin artwin (selected-window)))
2240 ;; First of all, compute the height of each window.
2241 (cond (gnus-use-full-window
2242 ;; Take up the entire screen.
2243 (delete-other-windows)
2244 (setq height (window-height (selected-window))))
2246 (setq height (+ (if grpwin (window-height grpwin) 0)
2247 (if subwin (window-height subwin) 0)
2248 (if artwin (window-height artwin) 0)))))
2249 ;; The group buffer exits always. So, use it to extend the
2250 ;; group window so as to get enough window space.
2251 (switch-to-buffer gnus-group-buffer 'norecord)
2252 (and (get-buffer gnus-summary-buffer)
2253 (delete-windows-on gnus-summary-buffer))
2254 (and (get-buffer gnus-article-buffer)
2255 (delete-windows-on gnus-article-buffer))
2256 ;; Compute expected window height.
2257 (setq winsum (apply (function +) windows))
2258 (if (not (zerop (nth 0 windows)))
2259 (setq grpheight (max window-min-height
2260 (/ (* height (nth 0 windows)) winsum))))
2261 (if (not (zerop (nth 1 windows)))
2262 (setq subheight (max window-min-height
2263 (/ (* height (nth 1 windows)) winsum))))
2264 (if (not (zerop (nth 2 windows)))
2265 (if gnus-split-window ;hack by erik
2266 (setq artheight height)
2267 (setq artheight (max window-min-height
2268 (/ (* height (nth 2 windows)) winsum)))))
2269 (setq height (+ grpheight subheight artheight))
2270 (enlarge-window (max 0 (- height (window-height (selected-window)))))
2271 ;; Then split the window.
2272 (if (and (not (zerop artheight))
2273 (or (not (zerop grpheight))
2274 (not (zerop subheight))))
2275 (if gnus-split-window
2276 (split-window-horizontally)
2277 (split-window-vertically (+ grpheight subheight))))
2278 (and (not (zerop grpheight))
2279 (not (zerop subheight))
2280 (split-window-vertically grpheight))
2281 ;; Then select buffers in each window.
2282 (or (zerop grpheight)
2284 (switch-to-buffer gnus-group-buffer 'norecord)
2286 (or (zerop subheight)
2288 (switch-to-buffer gnus-summary-buffer 'norecord)
2290 (or (zerop artheight)
2292 ;; If article buffer does not exist, it will be created
2294 (gnus-article-setup-buffer)
2295 (switch-to-buffer gnus-article-buffer 'norecord)
2296 (setq buffer-read-only t) ; !!! Why!?!
2297 (bury-buffer gnus-summary-buffer)
2298 (bury-buffer gnus-group-buffer)))
2299 (or (zerop subheight)
2301 (pop-to-buffer gnus-summary-buffer)
2302 ;; It seems that some code in this function will set
2303 ;; buffer-read-only to nil. I have absolutely no idea
2305 (setq buffer-read-only t))))))) ; !!! Why!?!
2307 (defun gnus-window-configuration-split (action)
2308 (switch-to-buffer gnus-group-buffer t)
2309 (delete-other-windows)
2310 (split-window-horizontally)
2311 (cond ((or (eq action 'newsgoups) (eq action 'summary))
2312 (if (and (get-buffer gnus-summary-buffer)
2313 (buffer-name gnus-summary-buffer))
2314 (switch-to-buffer-other-window gnus-summary-buffer)))
2315 ((eq action 'article)
2316 (switch-to-buffer gnus-summary-buffer t)
2318 (gnus-article-setup-buffer)
2319 (switch-to-buffer gnus-article-buffer t))))
2321 (defun gnus-version ()
2322 "Version numbers of this version of Gnus."
2324 (let ((methods gnus-valid-select-methods)
2327 ;; Go through all the legal select methods and add their version
2328 ;; numbers to the total version string. Only the backends that are
2329 ;; currently in use will have their message numbers taken into
2332 (setq meth (intern (concat (car (car methods)) "-version")))
2334 (stringp (symbol-value meth))
2335 (setq mess (concat mess "; " (symbol-value meth))))
2336 (setq methods (cdr methods)))
2339 (defun gnus-info-find-node ()
2340 "Find Info documentation of Gnus."
2342 ;; Enlarge info window if needed.
2343 (cond ((eq major-mode 'gnus-group-mode)
2344 (gnus-configure-windows '(1 0 0)) ;Take all windows.
2345 (pop-to-buffer gnus-group-buffer))
2346 ((eq major-mode 'gnus-summary-mode)
2347 (gnus-configure-windows '(0 1 0)) ;Take all windows.
2348 (pop-to-buffer gnus-summary-buffer)))
2349 (Info-goto-node (car (cdr (assq major-mode gnus-info-nodes)))))
2352 "Send a bug report to the Gnus maintainers."
2354 (pop-to-buffer "*Gnus Bug*")
2356 (mail-setup gnus-maintainer "[Gnus Bug Report] " nil nil nil nil)
2357 (goto-char (point-min))
2358 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
2360 (insert (format "%s\n%s\n\n" (gnus-version) (emacs-version)))
2365 (defun gnus-debug ()
2366 "Attemps to go through the Gnus source file and report what variables have been changed.
2367 The source file has to be in the Emacs load path."
2369 (let ((dirs load-path)
2372 (if (file-exists-p (setq file (concat (car dirs) "/gnus.el")))
2375 (set-buffer (get-buffer-create "*gnus bug info*"))
2376 (buffer-disable-undo (current-buffer))
2378 (insert-file-contents file)
2379 (goto-char (point-min))
2380 (or (search-forward "\n;; Internal variables" nil t)
2381 (error "Malformed sources"))
2382 (narrow-to-region (point-min) (point))
2383 (goto-char (point-min))
2384 (while (setq expr (condition-case ()
2385 (read (current-buffer)) (error nil)))
2386 (and (eq (car expr) 'defvar)
2387 (stringp (nth 3 expr))
2388 (not (equal (eval (nth 2 expr))
2389 (and (boundp (nth 1 expr))
2390 (symbol-value (nth 1 expr)))))
2391 (setq olist (cons (nth 1 expr) olist))))
2392 (kill-buffer (current-buffer)))
2393 (setq dirs (cdr dirs))))
2395 (insert "(setq " (symbol-name (car olist)) " '"
2396 (prin1-to-string (symbol-value (car olist))) ")\n")
2397 (setq olist (cdr olist)))
2400 (defun gnus-overload-functions (&optional overloads)
2401 "Overload functions specified by optional argument OVERLOADS.
2402 If nothing is specified, use the variable gnus-overload-functions."
2404 (overloads (or overloads gnus-overload-functions)))
2406 (setq defs (car overloads))
2407 (setq overloads (cdr overloads))
2408 ;; Load file before overloading function if necessary. Make
2409 ;; sure we cannot use `require' always.
2410 (and (not (fboundp (car defs)))
2411 (car (cdr (cdr defs)))
2412 (load (car (cdr (cdr defs))) nil 'nomessage))
2413 (fset (car defs) (car (cdr defs))))))
2415 (defun gnus-replace-chars-in-string (string from to)
2416 "Replace characters in STRING from FROM to TO."
2417 (let ((string (substring string 0)) ;Copy string.
2418 (len (length string))
2420 ;; Replace all occurrences of FROM with TO.
2422 (if (= (aref string idx) from)
2423 (aset string idx to))
2424 (setq idx (1+ idx)))
2427 (defun gnus-days-between (date1 date2)
2428 ;; Return the number of days between date1 and date2.
2429 (let ((d1 (mapcar (lambda (s) (and s (string-to-int s)) )
2430 (timezone-parse-date date1)))
2431 (d2 (mapcar (lambda (s) (and s (string-to-int s)) )
2432 (timezone-parse-date date2))))
2433 (- (timezone-absolute-from-gregorian
2434 (nth 1 d1) (nth 2 d1) (car d1))
2435 (timezone-absolute-from-gregorian
2436 (nth 1 d2) (nth 2 d2) (car d2)))))
2438 (defun gnus-day-number (date)
2439 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2440 (timezone-parse-date date))))
2441 (timezone-absolute-from-gregorian
2442 (nth 1 dat) (nth 2 dat) (car dat))))
2444 (defun gnus-file-newer-than (file date)
2445 (let ((fdate (nth 5 (file-attributes file))))
2446 (or (> (car fdate) (car date))
2447 (and (= (car fdate) (car date))
2448 (> (nth 1 fdate) (nth 1 date))))))
2450 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2452 (defun gnus-y-or-n-p (prompt)
2457 (defun gnus-yes-or-no-p (prompt)
2459 (yes-or-no-p prompt)
2462 ;; Return a string of length POS+1 representing NUMber in BASE. The
2463 ;; resulting string will be left padded with zeds.
2464 (defun gnus-number-base-x (num pos base)
2469 (aref "zyxwvutsrqponmlkjihgfedcba9876543210" (/ num (expt base pos))))
2471 (% num (expt base pos)) (1- pos) base))))
2473 ;; Check whether to use long file names.
2474 (defun gnus-use-long-file-name (symbol)
2475 ;; The variable has to be set...
2476 (and gnus-use-long-file-name
2477 ;; If it isn't a list, then we return t.
2478 (or (not (listp gnus-use-long-file-name))
2479 ;; If it is a list, and the list contains `symbol', we
2481 (not (memq symbol gnus-use-long-file-name)))))
2483 ;; I suspect there's a better way, but I haven't taken the time to do
2484 ;; it yet. -erik selberg@cs.washington.edu
2485 (defun gnus-dd-mmm (messy-date)
2486 "Return a string like DD-MMM from a big messy string"
2487 (let ((datevec (timezone-parse-date messy-date)))
2489 (or (aref datevec 2) "??")
2492 (nth (1- (string-to-number (aref datevec 1)))
2493 timezone-months-assoc))
2496 ;; List and range functions
2498 (defun gnus-last-element (list)
2499 "Return last element of LIST."
2501 (setq list (cdr list)))
2504 (defun gnus-copy-sequence (list)
2505 "Do a complete, total copy of a list."
2506 (if (and (consp list) (not (consp (cdr list))))
2507 (cons (car list) (cdr list))
2508 (mapcar (lambda (elem) (if (consp elem)
2509 (if (consp (cdr elem))
2510 (gnus-copy-sequence elem)
2511 (cons (car elem) (cdr elem)))
2515 (defun gnus-set-difference (list1 list2)
2516 "Return a list of elements of LIST1 that do not appear in LIST2."
2517 (let ((list1 (copy-sequence list1)))
2519 (setq list1 (delq (car list2) list1))
2520 (setq list2 (cdr list2)))
2523 (defun gnus-sorted-complement (list1 list2)
2524 "Return a list of elements of LIST1 that do not appear in LIST2.
2525 Both lists have to be sorted over <."
2527 (while (and list1 list2)
2528 (cond ((= (car list1) (car list2))
2529 (setq list1 (cdr list1)
2531 ((< (car list1) (car list2))
2532 (setq out (cons (car list1) out))
2533 (setq list1 (cdr list1)))
2535 (setq out (cons (car list2) out))
2536 (setq list2 (cdr list2)))))
2537 (nreverse (append (or list1 list2) out))))
2539 (defun gnus-intersection (list1 list2)
2542 (if (memq (car list2) list1)
2543 (setq result (cons (car list2) result)))
2544 (setq list2 (cdr list2)))
2547 (defun gnus-sorted-intersection (list1 list2)
2548 ;; LIST1 and LIST2 have to be sorted over <.
2550 (while (and list1 list2)
2551 (cond ((= (car list1) (car list2))
2552 (setq out (cons (car list1) out)
2555 ((< (car list1) (car list2))
2556 (setq list1 (cdr list1)))
2558 (setq list2 (cdr list2)))))
2561 (defun gnus-set-sorted-intersection (list1 list2)
2562 ;; LIST1 and LIST2 have to be sorted over <.
2563 ;; This function modifies LIST1.
2564 (let* ((top (cons nil list1))
2566 (while (and list1 list2)
2567 (cond ((= (car list1) (car list2))
2571 ((< (car list1) (car list2))
2572 (setcdr prev (cdr list1))
2573 (setq list1 (cdr list1)))
2575 (setq list2 (cdr list2)))))
2579 (defun gnus-compress-sequence (numbers &optional always-list)
2580 "Convert list of numbers to a list of ranges or a single range.
2581 If ALWAYS-LIST is non-nil, this function will always release a list of
2583 (let* ((first (car numbers))
2584 (last (car numbers))
2588 (if (not (listp (cdr numbers)))
2591 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2592 ((= (1+ last) (car numbers)) ;Still in sequence
2593 (setq last (car numbers)))
2594 (t ;End of one sequence
2596 (cons (if (= first last) first (cons first last)) result))
2597 (setq first (car numbers))
2598 (setq last (car numbers))))
2599 (setq numbers (cdr numbers)))
2600 (if (and (not always-list) (null result))
2601 (if (= first last) first (cons first last))
2602 (nreverse (cons (if (= first last) first (cons first last))
2605 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2606 (defun gnus-uncompress-range (ranges)
2607 "Expand a list of ranges into a list of numbers.
2608 RANGES is either a single range on the form `(num . num)' or a list of
2610 (let (first last result)
2614 ((not (listp (cdr ranges)))
2615 (setq first (car ranges))
2616 (setq last (cdr ranges))
2617 (while (<= first last)
2618 (setq result (cons first result))
2619 (setq first (1+ first)))
2623 (if (atom (car ranges))
2624 (if (numberp (car ranges))
2625 (setq result (cons (car ranges) result)))
2626 (setq first (car (car ranges)))
2627 (setq last (cdr (car ranges)))
2628 (while (<= first last)
2629 (setq result (cons first result))
2630 (setq first (1+ first))))
2631 (setq ranges (cdr ranges)))
2632 (nreverse result)))))
2634 (defun gnus-add-to-range (ranges list)
2635 "Return a list of ranges that has all articles from both RANGES and LIST.
2636 Note: LIST has to be sorted over `<'."
2638 (gnus-compress-sequence list t)
2639 (setq list (copy-sequence list))
2640 (or (listp (cdr ranges))
2641 (setq ranges (list ranges)))
2643 ilist lowest highest temp)
2644 (while (and ranges list)
2646 (setq lowest (or (and (atom (car ranges)) (car ranges))
2647 (car (car ranges))))
2648 (while (and list (cdr list) (< (car (cdr list)) lowest))
2649 (setq list (cdr list)))
2650 (if (< (car ilist) lowest)
2653 (setq list (cdr list))
2655 (setq out (nconc (gnus-compress-sequence ilist t) out))))
2656 (setq highest (or (and (atom (car ranges)) (car ranges))
2657 (cdr (car ranges))))
2658 (while (and list (<= (car list) highest))
2659 (setq list (cdr list)))
2660 (setq ranges (cdr ranges)))
2662 (setq out (nconc (gnus-compress-sequence list t) out)))
2663 (setq out (sort out (lambda (r1 r2)
2664 (< (or (and (atom r1) r1) (car r1))
2665 (or (and (atom r2) r2) (car r2))))))
2668 (if (atom (car ranges))
2670 (if (atom (car (cdr ranges)))
2671 (if (= (1+ (car ranges)) (car (cdr ranges)))
2673 (setcar ranges (cons (car ranges)
2674 (car (cdr ranges))))
2675 (setcdr ranges (cdr (cdr ranges)))))
2676 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
2678 (setcar (car (cdr ranges)) (car ranges))
2679 (setcar ranges (car (cdr ranges)))
2680 (setcdr ranges (cdr (cdr ranges)))))))
2682 (if (atom (car (cdr ranges)))
2683 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
2685 (setcdr (car ranges) (car (cdr ranges)))
2686 (setcdr ranges (cdr (cdr ranges)))))
2687 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
2689 (setcdr (car ranges) (cdr (car (cdr ranges))))
2690 (setcdr ranges (cdr (cdr ranges))))))))
2691 (setq ranges (cdr ranges)))
2694 (defun gnus-add-to-range-new (ranges list)
2695 (gnus-compress-sequence
2696 (sort (nconc (gnus-uncompress-range ranges) list) '<)))
2698 (defun gnus-add-to-range-old (ranges list)
2699 "Return a list of ranges that has all articles from both RANGES and LIST.
2700 Note: LIST has to be sorted over `<'."
2701 (let* ((ranges (if (and ranges (not (listp (cdr ranges))))
2702 (list ranges) ranges))
2705 range nranges first last)
2709 (gnus-compress-sequence list t)
2711 (> (car (car ranges)) 1)
2714 (setq inrange (setq ranges (cons (cons 1 1) ranges)))))
2715 (while (and ranges list)
2716 (setq range (car ranges))
2717 (while (and list (>= (car list) (car range))
2718 (<= (car list) (cdr range)))
2719 (setq list (cdr list)))
2720 (while (and list (= (1- (car list)) (cdr range)))
2721 (setcdr range (car list))
2722 (setq list (cdr list)))
2723 (if (and list (and (> (car list) (cdr range))
2725 (< (car list) (car (car (cdr ranges))))))
2726 (setcdr ranges (cons (cons (car list) (car list)) (cdr ranges))))
2727 (setq ranges (cdr ranges)))
2728 (if (and list (not ranges))
2729 (setq inrange (nconc inrange (gnus-compress-sequence list t))))
2731 (if (eq (cdr (car inrange)) 1)
2732 (setq inrange (cdr inrange))
2733 (setcar (car inrange) 2)))
2734 (setq ranges inrange)
2736 (if (and (cdr ranges) (>= (1+ (cdr (car ranges)))
2737 (car (car (cdr ranges)))))
2739 (setcdr (car ranges) (cdr (car (cdr ranges))))
2740 (setcdr ranges (cdr (cdr ranges))))
2741 (setq ranges (cdr ranges))))
2742 (if (not (cdr inrange))
2746 (defun gnus-remove-from-range (ranges list)
2747 "Return a list of ranges that has all articles from LIST removed from RANGES.
2748 Note: LIST has to be sorted over `<'."
2749 ;; !!! This function shouldn't look like this, but I've got a headache.
2750 (gnus-compress-sequence
2751 (gnus-sorted-complement
2752 (gnus-uncompress-range ranges) list)))
2754 (defun gnus-member-of-range (number ranges)
2755 (if (not (listp (cdr ranges)))
2756 (and (>= number (car ranges))
2757 (<= number (cdr ranges)))
2760 (if (numberp (car ranges))
2761 (>= number (car ranges))
2762 (>= number (car (car ranges))))
2764 (if (if (numberp (car ranges))
2765 (= number (car ranges))
2766 (and (>= number (car (car ranges)))
2767 (<= number (cdr (car ranges)))))
2768 (setq not-stop nil))
2769 (setq ranges (cdr ranges)))
2777 (defvar gnus-group-mode-map nil)
2778 (defvar gnus-group-make-map nil)
2779 (defvar gnus-group-list-map nil)
2780 (defvar gnus-group-sub-map nil)
2781 (put 'gnus-group-mode 'mode-class 'special)
2783 (if gnus-group-mode-map
2785 (setq gnus-group-mode-map (make-keymap))
2786 (suppress-keymap gnus-group-mode-map)
2787 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
2788 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
2789 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
2790 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
2791 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
2792 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
2793 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
2794 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
2795 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
2796 (define-key gnus-group-mode-map "\M-n" 'gnus-group-next-unread-group-same-level)
2797 (define-key gnus-group-mode-map "\M-p" 'gnus-group-prev-unread-group-same-level)
2798 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
2799 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
2800 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
2801 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
2802 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
2803 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
2804 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
2805 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
2806 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
2807 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
2808 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
2809 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
2810 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
2811 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
2812 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
2813 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
2814 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
2815 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
2816 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
2817 (define-key gnus-group-mode-map "\C-c\M-C-a" 'gnus-group-description-apropos)
2818 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
2819 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
2820 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
2821 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
2822 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
2823 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
2824 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
2825 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
2826 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
2827 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
2828 (define-key gnus-group-mode-map "V" 'gnus-version)
2829 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
2830 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
2831 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
2832 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
2833 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
2834 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
2835 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
2836 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
2837 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group-method)
2838 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
2839 (define-key gnus-group-mode-map
2840 (if gnus-xemacs [button2] [mouse-2]) 'gnus-mouse-pick-group)
2841 (define-key gnus-group-mode-map "<" 'beginning-of-buffer)
2842 (define-key gnus-group-mode-map ">" 'end-of-buffer)
2844 (define-prefix-command 'gnus-group-make-map)
2845 (define-key gnus-group-mode-map "M" 'gnus-group-make-map)
2846 (define-key gnus-group-make-map "d" 'gnus-group-make-directory-group)
2847 (define-key gnus-group-make-map "h" 'gnus-group-make-help-group)
2848 (define-key gnus-group-make-map "a" 'gnus-group-make-archive-group)
2849 (define-key gnus-group-make-map "k" 'gnus-group-make-kiboze-group)
2850 (define-key gnus-group-make-map "m" 'gnus-group-make-group)
2851 (define-key gnus-group-make-map "E" 'gnus-group-edit-group)
2852 (define-key gnus-group-make-map "e" 'gnus-group-edit-group-method)
2853 (define-key gnus-group-make-map "p" 'gnus-group-edit-group-parameters)
2855 (define-prefix-command 'gnus-group-list-map)
2856 (define-key gnus-group-mode-map "G" 'gnus-group-list-map)
2857 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
2858 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
2859 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
2860 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
2861 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
2862 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
2863 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
2864 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
2866 (define-prefix-command 'gnus-group-sub-map)
2867 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
2868 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
2869 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
2870 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
2871 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
2872 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
2873 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
2874 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
2876 (defun gnus-group-mode ()
2877 "Major mode for reading news.
2879 All normal editing commands are switched off.
2880 \\<gnus-group-mode-map>
2881 The group buffer lists (some of) the groups available. For instance,
2882 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
2883 lists all zombie groups.
2885 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
2886 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
2888 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
2890 The following commands are available:
2892 \\{gnus-group-mode-map}"
2894 (if gnus-visual (gnus-group-make-menu-bar))
2895 (kill-all-local-variables)
2896 (setq mode-line-modified "-- ")
2897 (make-local-variable 'mode-line-format)
2898 (setq mode-line-format (copy-sequence mode-line-format))
2899 (and (equal (nth 3 mode-line-format) " ")
2900 (setcar (nthcdr 3 mode-line-format) ""))
2901 (setq major-mode 'gnus-group-mode)
2902 (setq mode-name "Group")
2903 (gnus-group-set-mode-line)
2904 (setq mode-line-process nil)
2905 (use-local-map gnus-group-mode-map)
2906 (buffer-disable-undo (current-buffer))
2907 (setq truncate-lines t)
2908 (setq buffer-read-only t)
2909 (run-hooks 'gnus-group-mode-hook))
2911 (defun gnus-mouse-pick-group (e)
2914 (gnus-group-read-group nil))
2917 (defun gnus-no-server (&optional arg)
2919 If ARG is a positive number, Gnus will use that as the
2920 startup level. If ARG is nil, Gnus will be started at level 2.
2921 If ARG is non-nil and not a positive number, Gnus will
2922 prompt the user for the name of an NNTP server to use.
2923 As opposed to `gnus', this command will not connect to the local server."
2925 (gnus (or arg (1- gnus-level-default-subscribed)) t))
2927 (defalias '\(ding\) 'gnus)
2930 (defun gnus (&optional arg dont-connect)
2932 If ARG is non-nil and a positive number, Gnus will use that as the
2933 startup level. If ARG is non-nil and not a positive number, Gnus will
2934 prompt the user for the name of an NNTP server to use."
2936 (if (get-buffer gnus-group-buffer)
2938 (switch-to-buffer gnus-group-buffer)
2939 (gnus-group-get-new-news))
2941 (gnus-read-init-file)
2942 (let ((level (and arg (numberp arg) (> arg 0) arg))
2946 (switch-to-buffer (get-buffer-create gnus-group-buffer))
2947 (gnus-add-current-to-buffer-list)
2951 (gnus-start-news-server (and arg (not level))))))
2952 (if (and (not dont-connect)
2955 (run-hooks 'gnus-startup-hook)
2956 ;; NNTP server is successfully open.
2957 (gnus-update-format-specifications)
2958 (let ((buffer-read-only nil))
2960 (if (not gnus-inhibit-startup-message)
2962 (gnus-group-startup-message)
2964 (gnus-setup-news nil level)
2965 (and gnus-use-dribble-file (gnus-dribble-open))
2966 (or t (not gnus-novice-user)
2968 (gnus-group-describe-briefly)) ;Show brief help message.
2969 (gnus-group-list-groups level))))))
2971 (defun gnus-group-startup-message (&optional x y)
2972 "Insert startup message in current buffer."
2973 ;; Insert the message.
2990 ;; And then hack it.
2991 ;; 18 is the longest line.
2992 (indent-rigidly (point-min) (point-max)
2993 (/ (max (- (window-width) (or x 28)) 0) 2))
2994 (goto-char (point-min))
2995 ;; +4 is fuzzy factor.
2996 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2)))
2998 (defun gnus-group-setup-buffer ()
2999 (or (get-buffer gnus-group-buffer)
3001 (switch-to-buffer (get-buffer-create gnus-group-buffer))
3002 (gnus-add-current-to-buffer-list)
3003 (gnus-group-mode))))
3005 (defun gnus-group-list-groups (level &optional unread)
3006 "List newsgroups with level LEVEL or lower that have unread alticles.
3007 Default is all subscribed groups.
3008 If argument UNREAD is non-nil, groups with no unread articles are also listed."
3010 (setq level (or level gnus-group-default-list-level gnus-level-subscribed))
3011 (gnus-group-setup-buffer) ;May call from out of group buffer
3012 (let ((case-fold-search nil)
3013 (group (gnus-group-group-name)))
3014 (funcall gnus-group-prepare-function level unread nil)
3015 (if (zerop (buffer-size))
3016 (message gnus-no-groups-message)
3017 (goto-char (point-min))
3019 ;; Go to the first group with unread articles.
3020 (gnus-group-search-forward nil nil nil t)
3021 ;; Find the right group to put point on. If the current group
3022 ;; has disapeared in the new listing, try to find the next
3023 ;; one. If no next one can be found, just leave point at the
3024 ;; first newsgroup in the buffer.
3025 (if (not (gnus-goto-char
3026 (text-property-any (point-min) (point-max)
3027 'gnus-group (intern group))))
3028 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
3030 (not (gnus-goto-char
3032 (point-min) (point-max) 'gnus-group
3033 (intern (car (car newsrc)))))))
3034 (setq newsrc (cdr newsrc)))
3035 (or newsrc (progn (goto-char (point-max))
3036 (forward-line -1))))))
3037 ;; Adjust cursor point.
3038 (gnus-group-position-cursor))))
3040 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
3041 "List all newsgroups with unread articles of level LEVEL or lower.
3042 If ALL is non-nil, list groups that have no unread articles.
3043 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3044 If REGEXP, only list groups matching REGEXP."
3045 (set-buffer gnus-group-buffer)
3046 (let ((buffer-read-only nil)
3047 (newsrc (cdr gnus-newsrc-assoc))
3048 (lowest (or lowest 1))
3049 info clevel unread group)
3051 (if (< lowest gnus-level-zombie)
3052 ;; List living groups.
3054 (setq info (car newsrc)
3057 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3058 (and unread ; This group might be bogus
3060 (string-match regexp group))
3061 (<= (setq clevel (car (cdr info))) level)
3063 (or all ; We list all groups?
3064 (eq unread t) ; We list unactivated groups
3065 (> unread 0) ; We list groups with unread articles
3066 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
3067 (gnus-group-insert-group-line
3068 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
3070 ;; List dead groups.
3071 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3072 (gnus-group-prepare-flat-list-dead
3073 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3074 gnus-level-zombie ?Z
3076 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3077 (gnus-group-prepare-flat-list-dead
3078 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3079 gnus-level-killed ?K regexp))
3081 (gnus-group-set-mode-line)
3082 (setq gnus-have-all-newsgroups all)
3083 (run-hooks 'gnus-group-prepare-hook)))
3085 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
3086 ;; List zombies and killed lists somehwat faster, which was
3087 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3088 ;; this by ignoring the group format specification altogether.
3091 (setq group (car groups)
3092 groups (cdr groups))
3093 (if (or (not regexp)
3094 (string-match regexp group))
3097 (insert (format " %c *: %s\n" mark group))
3098 (add-text-properties
3100 (list 'gnus-group (intern group)
3102 'gnus-level level)))))))
3104 (defun gnus-group-real-name (group)
3105 "Find the real name of a foreign newsgroup."
3106 (if (string-match "^[^:]+:" group)
3107 (substring group (match-end 0))
3110 (defun gnus-group-prefixed-name (group method)
3111 "Return the whole name from GROUP and METHOD."
3112 (and (stringp method) (setq method (gnus-server-to-method method)))
3113 (concat (format "%s" (car method))
3115 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3116 (not (string= (nth 1 method) "")))
3117 (concat "+" (nth 1 method)))
3120 (defun gnus-group-real-prefix (group)
3121 "Return the prefix of the current group name."
3122 (if (string-match "^[^:]+:" group)
3123 (substring group 0 (match-end 0))
3126 (defun gnus-group-method-name (group)
3127 "Return the method used for selecting GROUP."
3128 (let ((prefix (gnus-group-real-prefix group)))
3129 (if (equal prefix "")
3131 (if (string-match "^[^\\+]+\\+" prefix)
3132 (list (intern (substring prefix 0 (1- (match-end 0))))
3133 (substring prefix (match-end 0) (1- (length prefix))))
3134 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3136 (defun gnus-group-foreign-p (group)
3137 "Return nil if GROUP is native, non-nil if it is foreign."
3138 (string-match ":" group))
3140 (defun gnus-group-set-info (info &optional method-only-group part)
3141 (let* ((entry (gnus-gethash
3142 (or method-only-group (car info)) gnus-newsrc-hashtb))
3144 (info (if method-only-group (nth 2 entry) info)))
3145 (if (not method-only-group)
3148 (error "Trying to change non-existant group %s" method-only-group))
3149 ;; We have recevied parts of the actual group info - either the
3150 ;; select method or the group parameters. We first check
3151 ;; whether we have to extend the info, and if so, do that.
3152 (let ((len (length info))
3153 (total (if (eq part 'method) 5 6)))
3155 (setcdr (nthcdr (1- len) info)
3156 (make-list (- total len) nil)))
3157 ;; Then we enter the new info.
3158 (setcar (nthcdr (1- total) info) part-info)))
3159 ;; We uncompress some lists of marked articles.
3161 (if (not (setq marked (nth 3 info)))
3164 (or (eq 'score (car (car marked)))
3165 (eq 'bookmark (car (car marked)))
3166 (eq 'killed (car (car marked)))
3167 (setcdr (car marked)
3168 (gnus-uncompress-range (cdr (car marked)))))
3169 (setq marked (cdr marked)))))
3172 ;; This is a new group, so we just create it.
3174 (set-buffer gnus-group-buffer)
3176 ;; It's a foreign group...
3177 (gnus-group-make-group
3178 (gnus-group-real-name (car info))
3179 (prin1-to-string (car (nth 4 info)))
3180 (nth 1 (nth 4 info)))
3181 ;; It's a native group.
3182 (gnus-group-make-group
3184 (prin1-to-string (car gnus-select-method))
3185 (nth 1 gnus-select-method)))
3186 (message "Note: New group created")
3188 (gnus-gethash (gnus-group-prefixed-name
3189 (gnus-group-real-name (car info))
3190 (or (nth 4 info) gnus-select-method))
3191 gnus-newsrc-hashtb))))
3192 ;; Whether it was a new group or not, we now have the entry, so we
3193 ;; can do the update.
3196 (setcar (nthcdr 2 entry) info)
3197 (if (and (not (eq (car entry) t))
3198 (gnus-gethash (car info) gnus-active-hashtb))
3199 (let ((marked (nth 3 info)))
3201 (max 0 (- (length (gnus-list-of-unread-articles
3203 (length (cdr (assq 'tick marked)))
3204 (length (cdr (assq 'dormant marked)))))))))
3205 (error "No such group: %s" (car info)))))
3207 (defun gnus-group-set-method-info (group select-method)
3208 (gnus-group-set-info select-method group 'method))
3210 (defun gnus-group-set-params-info (group params)
3211 (gnus-group-set-info params group 'params))
3213 (defun gnus-group-update-group-line ()
3214 "This function updates the current line in the newsgroup buffer and
3215 moves the point to the colon."
3216 (let* ((buffer-read-only nil)
3217 (group (gnus-group-group-name))
3218 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3221 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3224 (delete-region (point) (progn (forward-line 1) (point)))
3225 (gnus-group-insert-group-line-info group)
3227 (gnus-group-position-cursor)))
3229 (defun gnus-group-insert-group-line-info (group)
3230 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3234 (setq info (nth 2 entry))
3235 (gnus-group-insert-group-line
3236 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3237 (setq active (gnus-gethash group gnus-active-hashtb))
3238 (gnus-group-insert-group-line
3239 nil group (if (member group gnus-zombie-list) gnus-level-zombie
3241 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3243 (defun gnus-group-insert-group-line (gformat group level marked number method)
3244 (let* ((gformat (or gformat gnus-group-line-format-spec))
3245 (active (gnus-gethash group gnus-active-hashtb))
3246 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3247 (number-of-dormant (length (cdr (assq 'dormant marked))))
3248 (number-of-ticked (length (cdr (assq 'tick marked))))
3249 (number-of-ticked-and-dormant
3250 (+ number-of-ticked number-of-dormant))
3251 (number-of-unread-unticked
3252 (if (numberp number) (int-to-string (max 0 number))
3255 (if (numberp number)
3256 (max 0 (- number-total number))
3258 (subscribed (cond ((<= level gnus-level-subscribed) ? )
3259 ((<= level gnus-level-unsubscribed) ?U)
3260 ((= level gnus-level-zombie) ?Z)
3262 (qualified-group (gnus-group-real-name group))
3263 (newsgroup-description
3264 (if gnus-description-hashtb
3265 (or (gnus-gethash group gnus-description-hashtb) "")
3267 (moderated (if (member group gnus-moderated-list) ?m ? ))
3268 (moderated-string (if (eq moderated ?m) "(m)" ""))
3269 (method (gnus-server-get-method group method))
3270 (news-server (or (car (cdr method)) ""))
3271 (news-method (or (car method) ""))
3273 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3277 (> number-of-ticked 0))
3279 (number (if (eq number t) "*" (+ number number-of-dormant
3281 (buffer-read-only nil)
3286 (insert (eval gformat))
3288 (add-text-properties
3289 b (1+ b) (list 'gnus-group (intern group)
3290 'gnus-unread (if (numberp number)
3291 (string-to-int number-of-unread-unticked)
3294 'gnus-level level))))
3296 (defun gnus-group-update-group (group &optional visible-only)
3297 "Update newsgroup info of GROUP.
3298 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3300 (set-buffer gnus-group-buffer)
3301 (let ((buffer-read-only nil)
3303 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3306 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3308 ;; Buffer may be narrowed.
3311 ;; Search a line to modify. If the buffer is large, the search
3312 ;; takes long time. In most cases, current point is on the line
3313 ;; we are looking for. So, first of all, check current line.
3316 (eq (get-text-property (point) 'gnus-group)
3321 (point-min) (point-max) 'gnus-group (intern group)))))
3322 ;; GROUP is listed in current buffer. So, delete old line.
3326 (delete-region (point) (progn (forward-line 1) (point))))
3327 ;; No such line in the buffer, find out where it's supposed to
3328 ;; go, and insert it there (or at the end of the buffer).
3329 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3331 (let ((entry (cdr (gnus-gethash group gnus-newsrc-hashtb))))
3336 (point-min) (point-max)
3337 'gnus-group (intern (car (car entry)))))))
3338 (setq entry (cdr entry)))
3339 (or entry (goto-char (point-max)))))))
3340 (if (or visible (not visible-only))
3341 (gnus-group-insert-group-line-info group))
3342 (gnus-group-set-mode-line))))
3344 (defun gnus-group-set-mode-line ()
3345 (if (memq 'group gnus-updated-mode-lines)
3346 (let* ((gformat (or gnus-group-mode-line-format-spec
3347 (setq gnus-group-mode-line-format-spec
3349 gnus-group-mode-line-format
3350 gnus-group-mode-line-format-alist))))
3351 (news-server (car (cdr gnus-select-method)))
3352 (news-method (car gnus-select-method))
3353 (mode-string (eval gformat))
3355 (if (> (length mode-string) max-len)
3356 (setq mode-string (substring mode-string 0 (- max-len 4))))
3357 (setq mode-line-buffer-identification mode-string)
3358 (set-buffer-modified-p t))))
3360 (defun gnus-group-group-name ()
3361 "Get the name of the newsgroup on the current line."
3362 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
3363 (and group (symbol-name group))))
3365 (defun gnus-group-group-level ()
3366 "Get the level of the newsgroup on the current line."
3367 (get-text-property (gnus-point-at-bol) 'gnus-level))
3369 (defun gnus-group-search-forward (&optional backward all level first-too)
3370 "Find the next newsgroup with unread articles.
3371 If BACKWARD is non-nil, find the previous newsgroup instead.
3372 If ALL is non-nil, just find any newsgroup.
3373 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3375 If FIRST-TOO, the current line is also eligeble as a target."
3376 (let ((way (if backward -1 1))
3380 (or first-too (forward-line way))
3388 (get-text-property (point) 'gnus-unread)))
3389 (or (eq unread t) (and unread (> unread 0))))
3390 (let ((lev (get-text-property
3391 (point) 'gnus-level)))
3392 (and lev (<= (get-text-property
3393 (point) 'gnus-level)
3394 gnus-level-subscribed)))))
3396 (let ((lev (get-text-property (point) 'gnus-level)))
3397 (if (and lev (<= lev level))
3402 (setq pos (point))))
3404 (zerop (forward-line way))))
3406 (progn (gnus-group-position-cursor) t)
3407 (if pos (goto-char pos) (goto-char beg))
3410 ;; Gnus group mode commands
3412 (defun gnus-group-read-group (all &optional no-article group)
3413 "Read news in this newsgroup.
3414 If argument ALL is non-nil, already read articles become readable.
3415 If optional argument NO-ARTICLE is non-nil, no article body is displayed."
3417 (let ((group (or group (gnus-group-group-name)))
3418 number active marked entry)
3419 (or group (error "No group on current line"))
3421 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3422 ;; This group might be a dead group. In that case we have to get
3423 ;; the number of unread articles from `gnus-active-hashtb'.
3425 (setq number (car entry))
3426 (if (setq active (gnus-gethash group gnus-active-hashtb))
3427 (setq number (- (1+ (cdr active)) (car active)))))
3428 (gnus-summary-read-group
3429 group (or all (and (numberp number)
3430 (zerop (+ number (length (cdr (assq 'tick marked)))
3431 (length (cdr (assq 'dormant marked)))))))
3434 (defun gnus-group-select-group (all)
3435 "Select this newsgroup.
3436 No article is selected automatically.
3437 If argument ALL is non-nil, already read articles become readable."
3439 (gnus-group-read-group all t))
3441 (defun gnus-group-jump-to-group (group)
3442 "Jump to newsgroup GROUP."
3443 (interactive (list (completing-read "Group: " gnus-active-hashtb nil
3444 (not (not gnus-read-active-file)))))
3446 (if (equal group "")
3447 (error "empty group name"))
3449 (let ((b (text-property-any (point-min) (point-max)
3450 'gnus-group (intern group))))
3452 ;; Either go to the line in the group buffer...
3454 ;; ... or insert the line.
3456 (gnus-gethash group gnus-active-hashtb)
3457 (gnus-activate-newsgroup group)
3458 (error "%s error: %s" group (gnus-status-message group)))
3460 (gnus-group-update-group group)
3461 (goto-char (text-property-any (point-min) (point-max)
3462 'gnus-group (intern group)))))
3463 ;; Adjust cursor point.
3464 (gnus-group-position-cursor))
3466 (defun gnus-group-next-group (n)
3467 "Go to next N'th newsgroup.
3468 If N is negative, search backward instead.
3469 Returns the difference between N and the number of skips actually
3472 (gnus-group-next-unread-group n t))
3474 (defun gnus-group-next-unread-group (n &optional all level)
3475 "Go to next N'th unread newsgroup.
3476 If N is negative, search backward instead.
3477 If ALL is non-nil, choose any newsgroup, unread or not.
3478 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
3479 such group can be found, the next group with a level higher than
3481 Returns the difference between N and the number of skips actually
3484 (let ((backward (< n 0))
3487 (gnus-group-search-forward backward all level))
3489 (if (/= 0 n) (message "No more%s newsgroups%s" (if all "" " unread")
3490 (if level " on this level or higher" "")))
3493 (defun gnus-group-prev-group (n)
3494 "Go to previous N'th newsgroup.
3495 Returns the difference between N and the number of skips actually
3498 (gnus-group-next-unread-group (- n) t))
3500 (defun gnus-group-prev-unread-group (n)
3501 "Go to previous N'th unread newsgroup.
3502 Returns the difference between N and the number of skips actually
3505 (gnus-group-next-unread-group (- n)))
3507 (defun gnus-group-next-unread-group-same-level (n)
3508 "Go to next N'th unread newsgroup on the same level.
3509 If N is negative, search backward instead.
3510 Returns the difference between N and the number of skips actually
3513 (gnus-group-next-unread-group n t (gnus-group-group-level))
3514 (gnus-group-position-cursor))
3516 (defun gnus-group-prev-unread-group-same-level (n)
3517 "Go to next N'th unread newsgroup on the same level.
3518 Returns the difference between N and the number of skips actually
3521 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
3522 (gnus-group-position-cursor))
3524 (defun gnus-group-best-unread-group (&optional exclude-group)
3525 "Go to the group with the highest level.
3526 If EXCLUDE-GROUP, do not go to that group."
3528 (goto-char (point-min))
3531 (while (setq unread (get-text-property (point) 'gnus-unread))
3532 (if (and (numberp unread) (> unread 0))
3534 (or best-point (setq best-point (point)))
3535 (if (and (< (get-text-property (point) 'gnus-level) best)
3536 (or (not exclude-group)
3537 (not (equal exclude-group (gnus-group-group-name)))))
3539 (setq best (get-text-property (point) 'gnus-level))
3540 (setq best-point (point))))))
3542 (if best-point (goto-char best-point))
3543 (gnus-summary-position-cursor)
3544 (and best-point (gnus-group-group-name))))
3546 (defun gnus-group-first-unread-group ()
3547 "Go to the first group with unread articles."
3549 (goto-char (point-min))
3550 (gnus-group-next-unread-group 1))
3552 (defun gnus-group-enter-server-mode ()
3553 "Jump to the server buffer."
3555 (gnus-server-setup-buffer)
3556 (switch-to-buffer gnus-server-buffer)
3557 (gnus-server-prepare))
3559 (defun gnus-group-make-group (name method address)
3560 "Add a new newsgroup.
3561 The user will be prompted for a NAME, for a select METHOD, and an
3565 (read-string "Group name: ")
3568 "Method: " (append gnus-valid-select-methods gnus-server-alist)
3570 (if (assoc method gnus-valid-select-methods)
3572 (if (memq 'prompt-address
3573 (assoc method gnus-valid-select-methods))
3574 (read-string "Address: ")
3576 (list method nil)))))
3578 (let* ((meth (if address (list (intern method) address) method))
3579 (nname (gnus-group-prefixed-name name meth))
3581 (and (gnus-gethash nname gnus-active-hashtb)
3582 (error "Group %s already exists" nname))
3583 (gnus-group-change-level
3584 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
3585 gnus-level-default-subscribed gnus-level-killed
3586 (gnus-gethash (or (gnus-group-group-name) "dummy.group")
3587 gnus-newsrc-hashtb) t)
3588 (gnus-sethash nname '(0 . 0) gnus-active-hashtb)
3590 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
3591 (gnus-group-insert-group-line-info nname)
3593 (and (gnus-check-backend-function 'request-create-group nname)
3594 (gnus-request-create-group nname))))
3596 (defun gnus-group-edit-group (group &optional part)
3597 "Edit the group on the current line."
3598 (interactive (list (gnus-group-group-name)))
3600 (if group (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
3601 (error "No group on current line"))
3602 (setq gnus-winconf-edit-group (current-window-configuration))
3603 (pop-to-buffer (get-buffer-create gnus-group-edit-buffer))
3604 (gnus-add-current-to-buffer-list)
3606 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3607 (use-local-map (copy-keymap emacs-lisp-mode-map))
3608 (local-set-key "\C-c\C-c" 'gnus-group-edit-group-done)
3610 (insert ";; Type `C-c C-c' after you have edited the newsgroup entry.\n\n")
3611 (let ((cinfo (gnus-copy-sequence info))
3613 (if (not (setq marked (nth 3 cinfo)))
3616 (or (eq 'score (car (car marked)))
3617 (eq 'bookmark (car (car marked)))
3618 (eq 'killed (car (car marked)))
3619 (setcdr (car marked)
3620 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
3621 (setq marked (cdr marked))))
3622 (cond ((eq part 'method)
3624 "(gnus-group-set-method-info \"" group "\"\n "
3625 (pp-to-string (list 'quote (or (nth 4 info) "native"))) ")\n"))
3628 "(gnus-group-set-params-info \"" group "\"\n "
3629 (pp-to-string (list 'quote (nth 5 info))) ")\n"))
3631 (insert (pp-to-string
3632 (list 'gnus-group-set-info (list 'quote cinfo)))))))))
3634 (defun gnus-group-edit-group-method (group)
3635 "Edit the select method of GROUP."
3636 (interactive (list (gnus-group-group-name)))
3637 (gnus-group-edit-group group 'method))
3639 (defun gnus-group-edit-group-parameters (group)
3640 "Edit the group parameters of GROUP."
3641 (interactive (list (gnus-group-group-name)))
3642 (gnus-group-edit-group group 'params))
3644 (defun gnus-group-edit-group-done ()
3646 (set-buffer (get-buffer-create gnus-group-edit-buffer))
3647 (eval-current-buffer)
3648 (kill-buffer (current-buffer))
3649 (and gnus-winconf-edit-group
3650 (set-window-configuration gnus-winconf-edit-group))
3651 (setq gnus-winconf-edit-group nil)
3652 (set-buffer gnus-group-buffer)
3653 (gnus-group-update-group (gnus-group-group-name))
3654 (gnus-group-position-cursor))
3656 (defun gnus-group-make-help-group ()
3657 "Create the (ding) Gnus documentation group."
3659 (and (gnus-gethash (gnus-group-prefixed-name "gnus-help" '(nndoc ""))
3661 (error "Documentation group already exists"))
3662 (let ((path load-path))
3664 (not (file-exists-p (concat (file-name-as-directory (car path))
3666 (setq path (cdr path)))
3667 (or path (error "Couldn't find doc group"))
3668 (gnus-group-make-group
3670 (concat (file-name-as-directory (car path)) "doc.txt"))
3671 (gnus-group-position-cursor)))
3673 (defun gnus-group-make-archive-group ()
3674 "Create the (ding) Gnus archive group."
3676 (and (gnus-gethash (gnus-group-prefixed-name "ding.archives" '(nndir ""))
3678 (error "Archive group already exists"))
3679 (gnus-group-make-group "ding.archives" "nndir" gnus-group-archive-directory)
3680 (gnus-group-position-cursor))
3682 (defun gnus-group-make-directory-group (dir)
3683 "Create an nndir group.
3684 The user will be prompted for a directory. The contents of this
3685 directory will be used as a newsgroup. The directory should contain
3686 mail messages or news articles in files that have numeric names."
3688 (list (read-file-name "Create group from directory: ")))
3689 (or (file-exists-p dir) (error "No such directory"))
3690 (or (file-directory-p dir) (error "Not a directory"))
3691 (gnus-group-make-group dir "nndir" dir)
3692 (gnus-group-position-cursor))
3694 (defun gnus-group-make-kiboze-group (group address scores)
3695 "Create an nnkiboze group.
3696 The user will be prompted for a name, a regexp to match groups, and
3697 score file entries for articles to include in the group."
3700 (read-string "nnkiboze group name: ")
3701 (read-string "Source groups (regexp): ")
3702 (let ((headers (mapcar (lambda (group) (list group))
3703 '("subject" "from" "number" "date" "message-id"
3704 "references" "chars" "lines" "xref")))
3705 scores header regexp regexps)
3706 (while (not (equal "" (setq header (completing-read
3707 "Match on header: " headers nil t))))
3709 (while (not (equal "" (setq regexp (read-string
3710 (format "Match on %s (string): "
3712 (setq regexps (cons (list regexp nil 1000 nil) regexps)))
3713 (setq scores (cons (cons header regexps) scores)))
3715 (gnus-group-make-group group "nnkiboze" address)
3717 (set-buffer (get-buffer-create " *gnus work*"))
3718 (buffer-disable-undo (current-buffer))
3719 (let (emacs-lisp-mode-hook)
3720 (pp (list 'setq 'gnus-score-alist
3721 (list 'quote (list scores)))
3723 (write-region (point-min) (point-max)
3724 (concat (or gnus-kill-files-directory "~/News")
3725 "nnkiboze:" group "." gnus-score-file-suffix))
3726 (kill-buffer (current-buffer)))
3727 (gnus-group-position-cursor))
3729 ;; Group sorting commands
3730 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
3732 (defun gnus-group-sort-groups ()
3733 "Sort the group buffer using `gnus-group-sort-function'."
3735 (setq gnus-newsrc-assoc
3736 (sort (cdr gnus-newsrc-assoc) gnus-group-sort-function))
3737 (gnus-make-hashtable-from-newsrc-alist)
3738 (gnus-get-unread-articles (1+ gnus-level-subscribed))
3739 (gnus-group-list-groups nil))
3741 (defun gnus-group-sort-by-alphabet (info1 info2)
3742 (string< (car info1) (car info2)))
3744 (defun gnus-group-sort-by-unread (info1 info2)
3745 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
3746 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
3747 (< (or (and (numberp n1) n1) 0)
3748 (or (and (numberp n2) n2) 0))))
3750 (defun gnus-group-sort-by-level (info1 info2)
3751 (< (nth 1 info1) (nth 1 info2)))
3753 ;; Group catching up.
3755 (defun gnus-group-catchup-current (n &optional all)
3756 "Mark all articles not marked as unread in current newsgroup as read.
3757 If prefix argument N is numeric, the ARG next newsgroups will be
3758 caught up. If ALL is non-nil, marked articles will also be marked as
3759 read. Cross references (Xref: header) of articles are ignored.
3760 The difference between N and actual number of newsgroups that were
3761 caught up is returned."
3763 (if (or (not gnus-interactive-catchup) ;Without confirmation?
3767 "Do you really want to mark all articles as read? "
3768 "Mark all unread articles as read? ")))
3774 (gnus-group-catchup (gnus-group-group-name) all)
3775 (gnus-group-update-group-line)
3777 (zerop (gnus-group-next-unread-group 1))))))
3780 (defun gnus-group-catchup-current-all (n)
3781 "Mark all articles in current newsgroup as read.
3782 Cross references (Xref: header) of articles are ignored."
3784 (gnus-group-catchup-current n 'all))
3786 (defun gnus-group-catchup (group &optional all)
3787 "Mark all articles in GROUP as read.
3788 If ALL is non-nil, all articles are marked as read.
3789 The return value is the number of articles that were marked as read,
3790 or nil if no action could be taken."
3791 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3793 (marked (nth 3 (nth 2 entry)))
3795 (if (not (numberp (car entry)))
3796 (message "Can't catch up; non-active group")
3797 ;; Do the updating only if the newsgroup isn't killed
3800 (setq ticked (if all nil (cdr (assq 'tick marked))))
3801 (gnus-update-read-articles group ticked nil ticked)
3802 (if (and all marked)
3803 (setcar (nthcdr 3 (nth 2 entry))
3804 (delq (assq 'dormant marked) marked))))))
3807 (defun gnus-group-expire-articles (newsgroup)
3808 "Expire all expirable articles in the current newsgroup."
3809 (interactive (list (gnus-group-group-name)))
3810 (if (not newsgroup) (error "No current newsgroup"))
3812 (assq 'expire (nth 3 (nth 2 (gnus-gethash newsgroup
3813 gnus-newsrc-hashtb))))))
3815 (gnus-check-backend-function 'request-expire-articles newsgroup)
3817 (gnus-request-expire-articles (cdr expirable) newsgroup)))))
3819 (defun gnus-group-expire-all-groups ()
3820 "Expire all expirable articles in all newsgroups."
3822 (message "Expiring...")
3823 (let ((newsrc (cdr gnus-newsrc-assoc)))
3825 (gnus-group-expire-articles (car (car newsrc)))
3826 (setq newsrc (cdr newsrc))))
3827 (message "Expiring...done"))
3829 (defun gnus-group-set-current-level (n)
3830 "Set the level of the current group to the numeric prefix."
3832 (setq n (or n (string-to-int
3835 (mapcar (lambda (n) (list (char-to-string n))) "123456789")
3837 (let ((group (gnus-group-group-name)))
3838 (if (not group) (error "No newsgroup on current line.")
3839 (if (and (numberp n) (>= n 1) (<= n 9))
3841 (message "Changed level of %s from %d to %d"
3842 group (gnus-group-group-level) n)
3843 (gnus-group-change-level group n (gnus-group-group-level))
3844 (gnus-group-update-group-line))
3845 (error "Illegal level: %s" n))))
3847 (gnus-group-position-cursor))
3849 (defun gnus-group-unsubscribe-current-group (arg)
3850 "Toggle subscribe from/to unsubscribe current group."
3852 (let ((group (gnus-group-group-name)))
3853 (or group (error "No newsgroup on current line"))
3854 (or arg (setq arg (if (<= (gnus-group-group-level) 5) 6 3)))
3855 (gnus-group-unsubscribe-group group arg)
3856 (gnus-group-next-group 1)))
3858 (defun gnus-group-unsubscribe-group (group &optional level)
3859 "Toggle subscribe from/to unsubscribe GROUP.
3860 New newsgroup is added to .newsrc automatically."
3862 (list (completing-read "Group: " gnus-active-hashtb nil
3863 gnus-have-read-active-file)))
3864 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3866 ;; Toggle subscription flag.
3867 (gnus-group-change-level
3868 newsrc (if level level (if (< (nth 1 (nth 2 newsrc)) 6) 6 4)))
3869 (gnus-group-update-group group))
3870 ((and (stringp group)
3871 (or (not gnus-have-read-active-file)
3872 (gnus-gethash group gnus-active-hashtb)))
3873 ;; Add new newsgroup.
3874 (gnus-group-change-level
3877 (or (and (member group gnus-zombie-list) 8) 9)
3878 (or (and (gnus-group-group-name)
3879 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb))
3880 (gnus-gethash (car (car gnus-newsrc-assoc))
3881 gnus-newsrc-hashtb)))
3882 (gnus-group-update-group group))
3883 (t (error "No such newsgroup: %s" group)))
3884 (gnus-group-position-cursor)))
3886 (defun gnus-group-transpose-groups (arg)
3887 "Exchange current newsgroup and previous newsgroup.
3888 With argument ARG, takes previous newsgroup and moves it past ARG newsgroup."
3890 ;; BUG: last newsgroup and the last but one cannot be transposed
3891 ;; since gnus-group-search-forward does not move forward beyond the
3892 ;; last. If we instead use forward-line, no problem, but I don't
3893 ;; want to use it for later extension.
3895 (gnus-group-search-forward t t)
3896 (gnus-group-kill-group 1)
3897 (gnus-group-search-forward nil t)
3898 (gnus-group-yank-group)
3899 (gnus-group-search-forward nil t)
3900 (setq arg (1- arg))))
3902 (defun gnus-group-kill-all-zombies ()
3903 "Kill all zombie newsgroups."
3905 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3906 (setq gnus-zombie-list nil)
3907 (funcall gnus-group-prepare-function 5 nil nil)
3908 (goto-char (point-min))
3909 (gnus-group-position-cursor))
3911 (defun gnus-group-kill-region (begin end)
3912 "Kill newsgroups in current region (excluding current point).
3913 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3916 ;; Exclude a line where current point is on.
3930 (beginning-of-line) ;Important when LINES < 1
3931 (gnus-group-kill-group lines)))
3933 (defun gnus-group-kill-group (n)
3934 "The the next N groups.
3935 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3936 However, only groups that were alive can be yanked; already killed
3937 groups or zombie groups can't be yanked.
3938 The return value is the name of the (last) newsgroup that was killed."
3940 (let ((buffer-read-only nil)
3942 (while (>= (setq n (1- n)) 0)
3943 (setq group (gnus-group-group-name))
3945 (signal 'end-of-buffer nil))
3946 (setq level (gnus-group-group-level))
3948 (delete-region (point) (progn (forward-line 1) (point)))
3949 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
3950 (setq gnus-list-of-killed-groups
3951 (cons (cons (car entry) (nth 2 entry))
3952 gnus-list-of-killed-groups)))
3953 (gnus-group-change-level (if entry entry group) 9 (if entry nil level)))
3956 (gnus-group-position-cursor)
3959 (defun gnus-group-yank-group (&optional arg)
3960 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
3961 inserting it before the current newsgroup. The numeric ARG specifies
3962 how many newsgroups are to be yanked. The name of the (last)
3963 newsgroup yanked is returned."
3965 (if (not arg) (setq arg 1))
3966 (let (info group prev)
3967 (while (>= (setq arg (1- arg)) 0)
3968 (if (not (setq info (car gnus-list-of-killed-groups)))
3969 (error "No more newsgroups to yank"))
3970 (setq group (nth 2 info))
3971 ;; Find which newsgroup to insert this one before - search
3972 ;; backward until something suitable is found. If there are no
3973 ;; other newsgroups in this buffer, just make this newsgroup the
3975 (while (and (not (setq prev (gnus-group-group-name)))
3976 (zerop (forward-line -1))))
3978 (setq prev (car (car gnus-newsrc-assoc))))
3979 (gnus-group-change-level
3981 (gnus-gethash prev gnus-newsrc-hashtb)
3983 (gnus-group-insert-group-line-info (nth 1 info))
3984 (setq gnus-list-of-killed-groups
3985 (cdr gnus-list-of-killed-groups)))
3987 (gnus-group-position-cursor)
3990 (defun gnus-group-list-all-groups (arg)
3991 "List all newsgroups with level ARG or lower.
3992 Default is 7, which lists all subscribed and most unsubscribed groups."
3994 (setq arg (or arg 7))
3995 (gnus-group-list-groups arg t))
3997 (defun gnus-group-list-killed ()
3998 "List all killed newsgroups in the group buffer."
4000 (if (not gnus-killed-list)
4001 (message "No killed groups")
4002 (funcall gnus-group-prepare-function 9 t 9)
4003 (goto-char (point-min)))
4004 (gnus-group-position-cursor))
4006 (defun gnus-group-list-zombies ()
4007 "List all zombie newsgroups in the group buffer."
4009 (if (not gnus-zombie-list)
4010 (message "No zombie groups")
4011 (funcall gnus-group-prepare-function 8 t 8)
4012 (goto-char (point-min)))
4013 (gnus-group-position-cursor))
4015 (defun gnus-group-get-new-news (&optional arg)
4016 "Get newly arrived articles.
4017 If ARG is non-nil, it should be a number between one and nine to
4018 specify which levels you are interested in re-scanning."
4020 (run-hooks 'gnus-get-new-news-hook)
4021 (if (and gnus-read-active-file (not arg))
4023 (gnus-read-active-file)
4024 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed))))
4025 (let ((gnus-read-active-file nil))
4026 (gnus-get-unread-articles (or arg (1+ gnus-level-subscribed)))))
4027 (gnus-group-list-groups
4028 (or gnus-group-always-list-unread arg gnus-level-subscribed)
4029 gnus-have-all-newsgroups))
4031 (defun gnus-group-get-new-news-this-group (n)
4032 "Check for newly arrived news in the current group (and the N-1 next groups).
4033 The difference between N and the number of newsgroup checked is returned.
4034 If N is negative, this group and the N-1 previous groups will be checked."
4036 (let ((way (if (< n 0) -1 1))
4038 (w-p (window-start))
4042 (or (gnus-get-new-news-in-group
4043 (setq group (gnus-group-group-name)))
4046 (message "%s error: %s"
4047 group (gnus-status-message group))))
4049 (zerop (gnus-group-next-group way)))
4051 (if (/= 0 n) (message "No more newsgroups"))
4052 ;; !!! I don't know why the buffer scrolls forward when updating
4053 ;; the first line in the group buffer, but it does. So we set the
4054 ;; window start forcibly.
4055 (set-window-start (get-buffer-window (current-buffer)) w-p)
4058 (defun gnus-get-new-news-in-group (group)
4060 (gnus-activate-newsgroup group)
4062 (gnus-get-unread-articles-in-group
4063 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
4064 (gnus-gethash group gnus-active-hashtb))
4065 (gnus-group-update-group-line)
4068 (defun gnus-group-fetch-faq (group)
4069 "Fetch the FAQ for the current group."
4070 (interactive (list (gnus-group-group-name)))
4071 (or group (error "No group name given"))
4072 (let ((file (concat gnus-group-faq-directory group)))
4073 (if (not (file-exists-p file))
4074 (error "No such file: %s" file)
4077 (defun gnus-group-describe-group (force &optional group)
4078 "Display a description of the current newsgroup."
4080 (and force (setq gnus-description-hashtb nil))
4081 (let ((group (or group (gnus-group-group-name)))
4083 (or group (message "No group name given"))
4084 (and (or gnus-description-hashtb
4085 (setq desc (gnus-group-get-description group))
4086 (gnus-read-descriptions-file))
4088 (or desc (gnus-gethash group gnus-description-hashtb)
4089 "No description available")))))
4091 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4092 (defun gnus-group-describe-all-groups (force)
4093 "Pop up a buffer with descriptons of all newsgroups."
4095 (and force (setq gnus-description-hashtb nil))
4096 (if (not (or gnus-description-hashtb
4097 (gnus-read-descriptions-file)))
4098 (error "Couldn't request descriptions file"))
4099 (let ((buffer-read-only nil)
4105 (insert (format " *: %-20s %s\n" (symbol-name group)
4106 (symbol-value group)))
4107 (add-text-properties
4108 b (1+ b) (list 'gnus-group group
4109 'gnus-unread t 'gnus-marked nil
4110 'gnus-level (1+ gnus-level-subscribed))))
4111 gnus-description-hashtb)
4112 (goto-char (point-min))
4113 (gnus-group-position-cursor)))
4115 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
4116 (defun gnus-group-apropos (regexp &optional search-description)
4117 "List all newsgroups that have names that match a regexp."
4118 (interactive "sGnus apropos (regexp): ")
4120 (obuf (current-buffer))
4122 ;; Go through all newsgroups that are known to Gnus.
4125 (and (string-match regexp (symbol-name group))
4126 (setq groups (cons (symbol-name group) groups))))
4128 ;; Go through all descriptions that are known to Gnus.
4129 (if search-description
4132 (and (string-match regexp (symbol-value group))
4133 (gnus-gethash (symbol-name group) gnus-active-hashtb)
4134 (setq groups (cons (symbol-name group) groups))))
4135 gnus-description-hashtb))
4137 (message "No groups matched \"%s\"." regexp)
4138 ;; Print out all the groups.
4140 (pop-to-buffer (get-buffer-create "*Gnus Help*"))
4141 (buffer-disable-undo (current-buffer))
4143 (setq groups (sort groups 'string<))
4145 ;; Groups may be entered twice into the list of groups.
4146 (if (not (string= (car groups) prev))
4148 (insert (setq prev (car groups)) "\n")
4149 (if (and gnus-description-hashtb
4150 (setq des (gnus-gethash (car groups)
4151 gnus-description-hashtb)))
4152 (insert " " des "\n"))))
4153 (setq groups (cdr groups)))
4155 (pop-to-buffer obuf)))
4157 (defun gnus-group-description-apropos (regexp)
4158 "List all newsgroups that have names or desccriptions that match a regexp."
4159 (interactive "sGnus description apropos (regexp): ")
4160 (if (not (or gnus-description-hashtb
4161 (gnus-read-descriptions-file)))
4162 (error "Couldn't request descriptions file"))
4163 (gnus-group-apropos regexp t))
4165 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4166 (defun gnus-group-list-matching (level regexp &optional all lowest)
4167 "List all groups with unread articles that match REGEXP.
4168 If the prefix LEVEL is non-nil, it should be a number that says which
4169 level to cut off listing groups.
4170 If ALL, also list groups with no unread articles.
4171 If LOWEST, don't list groups with level lower than LOWEST."
4172 (interactive "P\nsList newsgroups matching: ")
4173 (gnus-group-prepare-flat (or level gnus-level-subscribed)
4174 all (or lowest 1) regexp)
4175 (goto-char (point-min))
4176 (gnus-group-position-cursor))
4178 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4179 "List all groups that match REGEXP.
4180 If the prefix LEVEL is non-nil, it should be a number that says which
4181 level to cut off listing groups.
4182 If LOWEST, don't list groups with level lower than LOWEST."
4183 (interactive "P\nsList newsgroups matching: ")
4184 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4186 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4187 (defun gnus-group-save-newsrc ()
4188 "Save the Gnus startup files."
4190 (gnus-save-newsrc-file))
4192 (defun gnus-group-restart (&optional arg)
4193 "Force Gnus to read the .newsrc file."
4195 (gnus-save-newsrc-file)
4196 (gnus-setup-news 'force)
4197 (gnus-group-list-groups arg gnus-have-all-newsgroups))
4199 (defun gnus-group-read-init-file ()
4200 "Read the Gnus elisp init file."
4202 (gnus-read-init-file))
4204 (defun gnus-group-check-bogus-groups ()
4205 "Check bogus newsgroups."
4207 (gnus-check-bogus-newsgroups (not gnus-expert-user)) ;Require confirmation.
4208 (gnus-group-list-groups nil gnus-have-all-newsgroups))
4210 (defun gnus-group-mail ()
4211 "Start composing a mail."
4215 (defun gnus-group-edit-global-kill (article &optional group)
4216 "Edit the global kill file.
4217 If GROUP, edit that local kill file instead."
4219 (setq gnus-current-kill-article article)
4220 (gnus-kill-file-edit-file group)
4222 (substitute-command-keys
4223 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
4225 (defun gnus-group-edit-local-kill (article group)
4226 "Edit a local kill file."
4227 (interactive (list nil (gnus-group-group-name)))
4228 (gnus-group-edit-global-kill article group))
4230 (defun gnus-group-force-update ()
4231 "Update `.newsrc' file."
4233 (gnus-save-newsrc-file))
4235 (defun gnus-group-suspend ()
4236 "Suspend the current Gnus session.
4237 In fact, cleanup buffers except for group mode buffer.
4238 The hook gnus-suspend-gnus-hook is called before actually suspending."
4240 (run-hooks 'gnus-suspend-gnus-hook)
4241 ;; Kill Gnus buffers except for group mode buffer.
4242 (let ((group-buf (get-buffer gnus-group-buffer)))
4243 (while gnus-buffer-list
4244 (and (not (eq (get-buffer (car gnus-buffer-list)) group-buf))
4245 (not (eq (get-buffer (car gnus-buffer-list)) gnus-dribble-buffer))
4246 (get-buffer (car gnus-buffer-list))
4247 (buffer-name (get-buffer (car gnus-buffer-list)))
4248 (kill-buffer (car gnus-buffer-list)))
4249 (setq gnus-buffer-list (cdr gnus-buffer-list)))
4250 (setq gnus-buffer-list (list group-buf))
4251 (bury-buffer group-buf)
4252 (delete-windows-on group-buf t)))
4254 (defun gnus-group-clear-dribble ()
4255 "Clear all information from the dribble buffer."
4257 (gnus-dribble-clear))
4259 (defun gnus-group-exit ()
4260 "Quit reading news after updating .newsrc.eld and .newsrc.
4261 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4263 (if (or noninteractive ;For gnus-batch-kill
4264 (zerop (buffer-size)) ;No news is good news.
4265 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
4266 (not gnus-interactive-exit) ;Without confirmation
4268 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4270 (run-hooks 'gnus-exit-gnus-hook)
4271 (gnus-save-newsrc-file)
4272 (gnus-close-backends)
4273 (gnus-clear-system))))
4275 (defun gnus-close-backends ()
4276 ;; Send a close request to all backends that support such a request.
4277 (let ((methods gnus-valid-select-methods)
4280 (if (fboundp (setq func (intern (concat (car (car methods))
4281 "-request-close"))))
4283 (setq methods (cdr methods)))))
4285 (defun gnus-group-quit ()
4286 "Quit reading news without updating .newsrc.eld or .newsrc.
4287 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4289 (if (or noninteractive ;For gnus-batch-kill
4290 (zerop (buffer-size))
4291 (not (gnus-server-opened gnus-select-method))
4293 (not gnus-current-startup-file)
4295 (format "Quit reading news without saving %s? "
4296 (file-name-nondirectory gnus-current-startup-file))))
4298 (run-hooks 'gnus-exit-gnus-hook)
4300 (gnus-close-backends)
4301 (gnus-clear-system))))
4303 (defun gnus-group-describe-briefly ()
4304 "Give a one line description of the group mode commands."
4307 (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")))
4309 (defun gnus-group-browse-foreign-server (method)
4310 "Browse a foreign news server.
4311 If called interactively, this function will ask for a select method
4312 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4313 If not, METHOD should be a list where the first element is the method
4314 and the second element is the address."
4316 (list (list (intern (completing-read
4318 gnus-valid-select-methods nil t "nntp"))
4319 ;; Suggested by mapjph@bath.ac.uk.
4322 (mapcar (lambda (server) (list server))
4323 gnus-secondary-servers)))))
4324 (gnus-browse-foreign-server method))
4328 ;;; Browse Server Mode
4331 (defvar gnus-browse-server-mode-hook nil)
4332 (defvar gnus-browse-server-mode-map nil)
4333 (put 'gnus-browse-server-mode 'mode-class 'special)
4335 (if gnus-browse-server-mode-map
4337 (setq gnus-browse-server-mode-map (make-keymap))
4338 (suppress-keymap gnus-browse-server-mode-map)
4339 (define-key gnus-browse-server-mode-map " " 'gnus-browse-read-group)
4340 (define-key gnus-browse-server-mode-map "=" 'gnus-browse-read-group)
4341 (define-key gnus-browse-server-mode-map "n" 'gnus-browse-next-group)
4342 (define-key gnus-browse-server-mode-map "p" 'gnus-browse-prev-group)
4343 (define-key gnus-browse-server-mode-map "\177" 'gnus-browse-prev-group)
4344 (define-key gnus-browse-server-mode-map "N" 'gnus-browse-next-group)
4345 (define-key gnus-browse-server-mode-map "P" 'gnus-browse-prev-group)
4346 (define-key gnus-browse-server-mode-map "\M-n" 'gnus-browse-next-group)
4347 (define-key gnus-browse-server-mode-map "\M-p" 'gnus-browse-prev-group)
4348 (define-key gnus-browse-server-mode-map "\r" 'gnus-browse-read-group)
4349 (define-key gnus-browse-server-mode-map "u" 'gnus-browse-unsubscribe-current-group)
4350 (define-key gnus-browse-server-mode-map "l" 'gnus-browse-exit)
4351 (define-key gnus-browse-server-mode-map "L" 'gnus-browse-exit)
4352 (define-key gnus-browse-server-mode-map "q" 'gnus-browse-exit)
4353 (define-key gnus-browse-server-mode-map "Q" 'gnus-browse-exit)
4354 (define-key gnus-browse-server-mode-map "\C-c\C-c" 'gnus-browse-exit)
4355 (define-key gnus-browse-server-mode-map "?" 'gnus-browse-describe-briefly)
4356 (define-key gnus-browse-server-mode-map "\C-c\C-i" 'gnus-info-find-node)
4359 (defvar gnus-browse-current-method nil)
4361 (defun gnus-browse-foreign-server (method)
4362 (setq gnus-browse-current-method method)
4363 (let ((gnus-select-method method)
4365 (message "Connecting to %s..." (nth 1 method))
4366 (or (gnus-server-opened method)
4367 (gnus-open-server method)
4368 (error "Unable to contact server: %s" (gnus-status-message method)))
4369 (or (gnus-request-list method)
4370 (error "Couldn't request list: %s" (gnus-status-message method)))
4371 (set-buffer (get-buffer-create "*Gnus Browse Server*"))
4372 (gnus-add-current-to-buffer-list)
4373 (buffer-disable-undo (current-buffer))
4374 (let ((buffer-read-only nil))
4376 (gnus-browse-server-mode)
4377 (setq mode-line-buffer-identification
4379 "(ding) Browse Server {%s:%s}" (car method) (car (cdr method))))
4381 (set-buffer nntp-server-buffer)
4382 (let ((cur (current-buffer)))
4384 (delete-matching-lines gnus-ignored-newsgroups)
4385 (while (re-search-forward
4386 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
4387 (goto-char (match-end 1))
4388 (setq groups (cons (cons (buffer-substring (match-beginning 1)
4390 (- (read cur) (read cur)))
4392 (setq groups (sort groups
4394 (string< (car l1) (car l2)))))
4395 (let ((buffer-read-only nil))
4397 (setq group (car groups))
4399 (format "K%7d: %s\n" (cdr group) (car group)))
4400 (setq groups (cdr groups))))
4401 (switch-to-buffer (current-buffer))
4403 (gnus-group-position-cursor)))
4405 (defun gnus-browse-server-mode ()
4406 "Major mode for browsing a foreign server."
4408 (kill-all-local-variables)
4409 (setq mode-line-modified "-- ")
4410 (make-local-variable 'mode-line-format)
4411 (setq mode-line-format (copy-sequence mode-line-format))
4412 (and (equal (nth 3 mode-line-format) " ")
4413 (setcar (nthcdr 3 mode-line-format) ""))
4414 (setq major-mode 'gnus-browse-server-mode)
4415 (setq mode-name "Browse Server")
4416 (setq mode-line-process nil)
4417 (use-local-map gnus-browse-server-mode-map)
4418 (buffer-disable-undo (current-buffer))
4419 (setq truncate-lines t)
4420 (setq buffer-read-only t)
4421 (run-hooks 'gnus-browse-server-mode-hook))
4423 (defun gnus-browse-read-group ()
4424 "Not implemented, and will probably never be."
4426 (error "You can't read while browsing"))
4428 (defun gnus-browse-next-group (n)
4429 "Go to the next group."
4433 (gnus-group-position-cursor)))
4435 (defun gnus-browse-prev-group (n)
4436 "Go to the next group."
4438 (gnus-browse-next-group (- n)))
4440 (defun gnus-browse-unsubscribe-current-group (arg)
4441 "(Un)subscribe to the next ARG groups."
4444 (error "No group at current line."))
4445 (let ((ward (if (< arg 0) -1 1))
4447 (while (and (> arg 0)
4449 (gnus-browse-unsubscribe-group)
4450 (zerop (gnus-browse-next-group ward)))
4451 (setq arg (1- arg)))
4452 (gnus-group-position-cursor)
4453 (if (/= 0 arg) (message "No more newsgroups"))
4456 (defun gnus-browse-unsubscribe-group ()
4458 (buffer-read-only nil)
4462 (if (= (following-char) ?K) (setq sub t))
4463 (re-search-forward ": \\(.*\\)$" nil t)
4464 (setq group (gnus-group-prefixed-name
4465 (buffer-substring (match-beginning 1) (match-end 1))
4466 gnus-browse-current-method))
4471 (gnus-group-change-level
4472 (list t group gnus-level-default-subscribed
4473 nil nil gnus-browse-current-method)
4474 gnus-level-default-subscribed gnus-level-killed
4475 (gnus-gethash (car (nth 1 gnus-newsrc-assoc)) gnus-newsrc-hashtb)
4478 (gnus-group-change-level
4479 group gnus-level-killed gnus-level-default-subscribed)
4483 (defun gnus-browse-exit ()
4484 "Quit browsing and return to the group buffer."
4486 (if (eq major-mode 'gnus-browse-server-mode)
4487 (kill-buffer (current-buffer)))
4488 (switch-to-buffer gnus-group-buffer)
4489 (gnus-group-list-groups nil))
4491 (defun gnus-browse-describe-briefly ()
4492 "Give a one line description of the group mode commands."
4495 (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")))
4499 ;;; Gnus summary mode
4502 (defvar gnus-summary-mode-map nil)
4503 (defvar gnus-summary-mark-map nil)
4504 (defvar gnus-summary-mscore-map nil)
4505 (defvar gnus-summary-send-map nil)
4506 (defvar gnus-summary-extract-map nil)
4507 (defvar gnus-summary-extract-view-map nil)
4508 (defvar gnus-summary-article-map nil)
4509 (defvar gnus-summary-thread-map nil)
4510 (defvar gnus-summary-goto-map nil)
4511 (defvar gnus-summary-exit-map nil)
4512 (defvar gnus-summary-various-map nil)
4513 (defvar gnus-summary-interest-map nil)
4514 (defvar gnus-summary-process-map nil)
4515 (defvar gnus-summary-score-map nil)
4516 (defvar gnus-summary-sort-map nil)
4517 (defvar gnus-summary-mgroup-map nil)
4518 (defvar gnus-summary-vsave-map nil)
4519 (defvar gnus-summary-increase-map nil)
4520 (defvar gnus-summary-inc-subject-map nil)
4521 (defvar gnus-summary-inc-author-map nil)
4522 (defvar gnus-summary-inc-body-map nil)
4523 (defvar gnus-summary-inc-id-map nil)
4524 (defvar gnus-summary-inc-xref-map nil)
4525 (defvar gnus-summary-inc-thread-map nil)
4526 (defvar gnus-summary-inc-fol-map nil)
4527 (defvar gnus-summary-lower-map nil)
4528 (defvar gnus-summary-low-subject-map nil)
4529 (defvar gnus-summary-low-author-map nil)
4530 (defvar gnus-summary-low-body-map nil)
4531 (defvar gnus-summary-low-id-map nil)
4532 (defvar gnus-summary-low-xref-map nil)
4533 (defvar gnus-summary-low-thread-map nil)
4534 (defvar gnus-summary-low-fol-map nil)
4535 (put 'gnus-summary-mode 'mode-class 'special)
4537 (if gnus-summary-mode-map
4539 (setq gnus-summary-mode-map (make-keymap))
4540 (suppress-keymap gnus-summary-mode-map)
4542 ;; Non-orthogonal keys
4544 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
4545 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
4546 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
4547 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
4548 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
4549 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
4550 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
4551 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
4552 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
4553 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
4554 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
4555 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
4556 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
4557 (define-key gnus-summary-mode-map "\M-s" 'gnus-summary-search-article-forward)
4558 (define-key gnus-summary-mode-map "\M-r" 'gnus-summary-search-article-backward)
4559 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
4560 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
4561 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
4562 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
4563 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
4564 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
4565 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
4566 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
4567 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
4568 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
4569 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
4570 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
4571 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
4572 (define-key gnus-summary-mode-map "k" 'gnus-summary-kill-same-subject-and-select)
4573 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
4574 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
4575 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
4576 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
4577 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
4578 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
4579 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
4580 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
4581 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
4582 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
4583 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
4584 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
4585 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
4586 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
4587 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
4588 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
4589 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
4590 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
4591 (define-key gnus-summary-mode-map "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
4592 (define-key gnus-summary-mode-map "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
4593 (define-key gnus-summary-mode-map "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
4594 (define-key gnus-summary-mode-map "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
4595 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
4596 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
4597 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
4598 (define-key gnus-summary-mode-map "\C-x\C-s" 'gnus-summary-reselect-current-group)
4599 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
4600 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
4601 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
4602 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
4603 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
4604 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
4605 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
4606 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
4607 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
4608 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
4609 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
4610 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
4611 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
4612 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
4613 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
4614 (define-key gnus-summary-mode-map "V" 'gnus-version)
4615 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
4616 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
4617 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
4618 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
4619 (define-key gnus-summary-mode-map
4620 (if gnus-xemacs [button2] [mouse-2]) 'gnus-mouse-pick-article)
4621 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
4622 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
4623 (define-key gnus-summary-mode-map "x" 'gnus-summary-remove-lines-marked-as-read)
4624 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
4625 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
4626 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
4627 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
4628 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
4629 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
4630 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
4631 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
4634 ;; Sort of orthogonal keymap
4635 (define-prefix-command 'gnus-summary-mark-map)
4636 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
4637 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
4638 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
4639 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
4640 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
4641 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
4642 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
4643 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
4644 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
4645 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
4646 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
4647 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
4648 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
4649 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
4650 (define-key gnus-summary-mark-map "\M-r" 'gnus-summary-remove-lines-marked-as-read)
4651 (define-key gnus-summary-mark-map "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
4652 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
4653 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
4654 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
4655 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
4656 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
4657 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
4658 (define-key gnus-summary-mark-map "k" 'gnus-summary-kill-same-subject-and-select)
4659 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
4661 (define-prefix-command 'gnus-summary-mscore-map)
4662 (define-key gnus-summary-mark-map "s" 'gnus-summary-mscore-map)
4663 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
4664 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
4665 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
4666 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
4668 (define-prefix-command 'gnus-summary-process-map)
4669 (define-key gnus-summary-mark-map "p" 'gnus-summary-process-map)
4670 (define-key gnus-summary-process-map "p" 'gnus-summary-mark-as-processable)
4671 (define-key gnus-summary-process-map "u" 'gnus-summary-unmark-as-processable)
4672 (define-key gnus-summary-process-map "U" 'gnus-summary-unmark-all-processable)
4673 (define-key gnus-summary-process-map "s" 'gnus-uu-mark-series)
4674 (define-key gnus-summary-process-map "r" 'gnus-uu-mark-region)
4675 (define-key gnus-summary-process-map "R" 'gnus-uu-mark-by-regexp)
4676 (define-key gnus-summary-process-map "t" 'gnus-uu-mark-thread)
4677 (define-key gnus-summary-process-map "a" 'gnus-uu-mark-all)
4678 (define-key gnus-summary-process-map "S" 'gnus-uu-mark-sparse)
4681 (define-prefix-command 'gnus-summary-send-map)
4682 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
4683 (define-key gnus-summary-send-map "p" 'gnus-summary-post-news)
4684 (define-key gnus-summary-send-map "f" 'gnus-summary-followup)
4685 (define-key gnus-summary-send-map "F" 'gnus-summary-followup-with-original)
4686 (define-key gnus-summary-send-map "b" 'gnus-summary-followup-and-reply)
4687 (define-key gnus-summary-send-map "B" 'gnus-summary-followup-and-reply-with-original)
4688 (define-key gnus-summary-send-map "c" 'gnus-summary-cancel-article)
4689 (define-key gnus-summary-send-map "s" 'gnus-summary-supersede-article)
4690 (define-key gnus-summary-send-map "r" 'gnus-summary-reply)
4691 (define-key gnus-summary-send-map "R" 'gnus-summary-reply-with-original)
4692 (define-key gnus-summary-send-map "\C-f" 'gnus-summary-mail-forward)
4693 (define-key gnus-summary-send-map "m" 'gnus-summary-mail-other-window)
4694 (define-key gnus-summary-send-map "u" 'gnus-uu-post-news)
4695 (define-key gnus-summary-send-map "\M-f" 'gnus-uu-digest-and-forward)
4698 (define-prefix-command 'gnus-summary-goto-map)
4699 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
4700 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
4701 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
4702 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
4703 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
4704 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
4705 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
4706 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
4707 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
4708 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
4709 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
4710 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
4711 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
4712 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
4715 (define-prefix-command 'gnus-summary-thread-map)
4716 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
4717 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
4718 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
4719 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
4720 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
4721 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
4722 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
4723 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
4724 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
4725 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
4726 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
4727 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
4728 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
4729 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
4732 (define-prefix-command 'gnus-summary-exit-map)
4733 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
4734 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
4735 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
4736 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
4737 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
4738 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
4739 (define-key gnus-summary-exit-map "n" 'gnus-summary-catchup-and-goto-next-group)
4742 (define-prefix-command 'gnus-summary-article-map)
4743 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
4744 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
4745 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
4746 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
4747 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
4748 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
4749 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
4750 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
4751 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
4752 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
4753 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
4754 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
4755 (define-key gnus-summary-article-map "w" 'gnus-summary-stop-page-breaking)
4756 (define-key gnus-summary-article-map "c" 'gnus-summary-caesar-message)
4757 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
4758 (define-key gnus-summary-article-map "t" 'gnus-summary-toggle-header)
4759 (define-key gnus-summary-article-map "hh" 'gnus-article-hide-headers)
4760 (define-key gnus-summary-article-map "hs" 'gnus-article-hide-signature)
4761 (define-key gnus-summary-article-map "hc" 'gnus-article-hide-citation)
4762 (define-key gnus-summary-article-map "ho" 'gnus-article-treat-overstrike)
4763 (define-key gnus-summary-article-map "hw" 'gnus-article-word-wrap)
4764 (define-key gnus-summary-article-map "hd" 'gnus-article-remove-cr)
4765 (define-key gnus-summary-article-map "hq" 'gnus-article-de-quoted-unreadable)
4766 (define-key gnus-summary-article-map "hf" 'gnus-article-display-x-face)
4767 (define-key gnus-summary-article-map "m" 'gnus-summary-toggle-mime)
4768 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
4771 (define-prefix-command 'gnus-summary-extract-map)
4772 (define-key gnus-summary-mode-map "X" 'gnus-summary-extract-map)
4773 ; (define-key gnus-summary-extract-map "x" 'gnus-summary-extract-any)
4774 ; (define-key gnus-summary-extract-map "m" 'gnus-summary-extract-mime)
4775 (define-key gnus-summary-extract-map "u" 'gnus-uu-decode-uu)
4776 (define-key gnus-summary-extract-map "U" 'gnus-uu-decode-uu-and-save)
4777 (define-key gnus-summary-extract-map "s" 'gnus-uu-decode-unshar)
4778 (define-key gnus-summary-extract-map "S" 'gnus-uu-decode-unshar-and-save)
4779 (define-key gnus-summary-extract-map "o" 'gnus-uu-decode-save)
4780 (define-key gnus-summary-extract-map "O" 'gnus-uu-decode-save)
4781 (define-key gnus-summary-extract-map "b" 'gnus-uu-decode-binhex)
4782 (define-key gnus-summary-extract-map "B" 'gnus-uu-decode-binhex)
4783 (define-key gnus-summary-extract-map "p" 'gnus-uu-decode-postscript)
4784 (define-key gnus-summary-extract-map "P" 'gnus-uu-decode-postscript-and-save)
4787 (define-prefix-command 'gnus-summary-extract-view-map)
4788 (define-key gnus-summary-extract-map "v" 'gnus-summary-extract-view-map)
4789 (define-key gnus-summary-extract-view-map "u" 'gnus-uu-decode-uu-view)
4790 (define-key gnus-summary-extract-view-map "U" 'gnus-uu-decode-uu-and-save-view)
4791 (define-key gnus-summary-extract-view-map "s" 'gnus-uu-decode-unshar-view)
4792 (define-key gnus-summary-extract-view-map "S" 'gnus-uu-decode-unshar-and-save-view)
4793 (define-key gnus-summary-extract-view-map "o" 'gnus-uu-decode-save-view)
4794 (define-key gnus-summary-extract-view-map "O" 'gnus-uu-decode-save-view)
4795 (define-key gnus-summary-extract-view-map "b" 'gnus-uu-decode-binhex-view)
4796 (define-key gnus-summary-extract-view-map "B" 'gnus-uu-decode-binhex-view)
4797 (define-key gnus-summary-extract-view-map "p" 'gnus-uu-decode-postscript-view)
4798 (define-key gnus-summary-extract-view-map "P" 'gnus-uu-decode-postscript-and-save-view)
4801 (define-prefix-command 'gnus-summary-various-map)
4802 (define-key gnus-summary-mode-map "V" 'gnus-summary-various-map)
4803 (define-key gnus-summary-various-map "u" 'gnus-summary-universal-argument)
4804 (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
4805 (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
4806 (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
4807 (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
4808 (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
4809 (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
4810 (define-key gnus-summary-various-map "S" 'gnus-summary-reselect-current-group)
4811 (define-key gnus-summary-various-map "g" 'gnus-summary-rescan-group)
4812 (define-key gnus-summary-various-map "V" 'gnus-version)
4813 (define-key gnus-summary-various-map "f" 'gnus-summary-fetch-faq)
4814 (define-key gnus-summary-various-map "d" 'gnus-summary-describe-group)
4815 (define-key gnus-summary-various-map "?" 'gnus-summary-describe-briefly)
4816 (define-key gnus-summary-various-map "i" 'gnus-info-find-node)
4817 (define-key gnus-summary-various-map "D" 'gnus-summary-enter-digest-group)
4818 (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
4819 (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
4821 (define-prefix-command 'gnus-summary-vsave-map)
4822 (define-key gnus-summary-various-map "o" 'gnus-summary-vsave-map)
4823 (define-key gnus-summary-vsave-map "o" 'gnus-summary-save-article)
4824 (define-key gnus-summary-vsave-map "m" 'gnus-summary-save-article-mail)
4825 (define-key gnus-summary-vsave-map "r" 'gnus-summary-save-article-rmail)
4826 (define-key gnus-summary-vsave-map "f" 'gnus-summary-save-article-file)
4827 (define-key gnus-summary-vsave-map "h" 'gnus-summary-save-article-folder)
4828 (define-key gnus-summary-vsave-map "p" 'gnus-summary-pipe-output)
4830 (define-prefix-command 'gnus-summary-score-map)
4831 (define-key gnus-summary-various-map "S" 'gnus-summary-score-map)
4832 (define-key gnus-summary-score-map "s" 'gnus-summary-set-score)
4833 (define-key gnus-summary-score-map "c" 'gnus-score-change-score-file)
4834 (define-key gnus-summary-score-map "m" 'gnus-score-set-mark-below)
4835 (define-key gnus-summary-score-map "x" 'gnus-score-set-expunge-below)
4836 (define-key gnus-summary-score-map "e" 'gnus-score-edit-alist)
4837 (define-key gnus-summary-score-map "f" 'gnus-score-edit-file)
4839 (define-prefix-command 'gnus-summary-sort-map)
4840 (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
4841 (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
4842 (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
4843 (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
4844 (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
4845 (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
4847 (define-prefix-command 'gnus-summary-mgroup-map)
4848 (define-key gnus-summary-various-map "m" 'gnus-summary-mgroup-map)
4849 (define-key gnus-summary-mgroup-map "e" 'gnus-summary-expire-articles)
4850 (define-key gnus-summary-mgroup-map "\177" 'gnus-summary-delete-article)
4851 (define-key gnus-summary-mgroup-map "m" 'gnus-summary-move-article)
4852 (define-key gnus-summary-mgroup-map "r" 'gnus-summary-respool-article)
4853 (define-key gnus-summary-mgroup-map "w" 'gnus-summary-edit-article)
4854 (define-key gnus-summary-mgroup-map "c" 'gnus-summary-copy-article)
4857 (define-prefix-command 'gnus-summary-increase-map)
4858 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-map)
4859 (define-key gnus-summary-increase-map "i" 'gnus-summary-raise-same-subject-and-select)
4860 (define-key gnus-summary-increase-map "I" 'gnus-summary-raise-same-subject)
4861 (define-key gnus-summary-increase-map "\C-i" 'gnus-summary-raise-score)
4863 (define-prefix-command 'gnus-summary-inc-subject-map)
4864 (define-key gnus-summary-increase-map "s" 'gnus-summary-inc-subject-map)
4865 (define-key gnus-summary-increase-map "S" 'gnus-summary-temporarily-raise-by-subject)
4866 (define-key gnus-summary-inc-subject-map "s" 'gnus-summary-temporarily-raise-by-subject)
4867 (define-key gnus-summary-inc-subject-map "S" 'gnus-summary-raise-by-subject)
4868 (define-key gnus-summary-inc-subject-map "t" 'gnus-summary-temporarily-raise-by-subject)
4869 (define-key gnus-summary-inc-subject-map "p" 'gnus-summary-raise-by-subject)
4871 (define-prefix-command 'gnus-summary-inc-author-map)
4872 (define-key gnus-summary-increase-map "a" 'gnus-summary-inc-author-map)
4873 (define-key gnus-summary-increase-map "A" 'gnus-summary-temporarily-raise-by-author)
4874 (define-key gnus-summary-inc-author-map "a" 'gnus-summary-temporarily-raise-by-author)
4875 (define-key gnus-summary-inc-author-map "A" 'gnus-summary-raise-by-author)
4876 (define-key gnus-summary-inc-author-map "t" 'gnus-summary-temporarily-raise-by-author)
4877 (define-key gnus-summary-inc-author-map "p" 'gnus-summary-raise-by-author)
4879 (define-prefix-command 'gnus-summary-inc-body-map)
4880 (define-key gnus-summary-increase-map "b" 'gnus-summary-inc-body-map)
4881 (define-key gnus-summary-increase-map "B" 'gnus-summary-temporarily-raise-by-body)
4882 (define-key gnus-summary-inc-body-map "b" 'gnus-summary-temporarily-raise-by-body)
4883 (define-key gnus-summary-inc-body-map "B" 'gnus-summary-raise-by-body)
4884 (define-key gnus-summary-inc-body-map "t" 'gnus-summary-temporarily-raise-by-body)
4885 (define-key gnus-summary-inc-body-map "p" 'gnus-summary-raise-by-body)
4887 (define-prefix-command 'gnus-summary-inc-id-map)
4888 (define-key gnus-summary-increase-map "i" 'gnus-summary-inc-id-map)
4889 (define-key gnus-summary-increase-map "I" 'gnus-summary-temporarily-raise-by-id)
4890 (define-key gnus-summary-inc-id-map "i" 'gnus-summary-temporarily-raise-by-id)
4891 (define-key gnus-summary-inc-id-map "I" 'gnus-summary-raise-by-id)
4892 (define-key gnus-summary-inc-id-map "t" 'gnus-summary-temporarily-raise-by-id)
4893 (define-key gnus-summary-inc-id-map "p" 'gnus-summary-raise-by-id)
4895 (define-prefix-command 'gnus-summary-inc-thread-map)
4896 (define-key gnus-summary-increase-map "t" 'gnus-summary-inc-thread-map)
4897 (define-key gnus-summary-increase-map "T" 'gnus-summary-temporarily-raise-by-thread)
4898 (define-key gnus-summary-inc-thread-map "t" 'gnus-summary-temporarily-raise-by-thread)
4899 (define-key gnus-summary-inc-thread-map "T" 'gnus-summary-raise-by-thread)
4900 (define-key gnus-summary-inc-thread-map "t" 'gnus-summary-temporarily-raise-by-thread)
4901 (define-key gnus-summary-inc-thread-map "p" 'gnus-summary-raise-by-thread)
4903 (define-prefix-command 'gnus-summary-inc-xref-map)
4904 (define-key gnus-summary-increase-map "x" 'gnus-summary-inc-xref-map)
4905 (define-key gnus-summary-increase-map "X" 'gnus-summary-temporarily-raise-by-xref)
4906 (define-key gnus-summary-inc-xref-map "x" 'gnus-summary-temporarily-raise-by-xref)
4907 (define-key gnus-summary-inc-xref-map "X" 'gnus-summary-raise-by-xref)
4908 (define-key gnus-summary-inc-xref-map "t" 'gnus-summary-temporarily-raise-by-xref)
4909 (define-key gnus-summary-inc-xref-map "p" 'gnus-summary-raise-by-xref)
4911 (define-prefix-command 'gnus-summary-inc-fol-map)
4912 (define-key gnus-summary-increase-map "f" 'gnus-summary-inc-fol-map)
4913 (define-key gnus-summary-increase-map "F" 'gnus-summary-raise-followups-to-author)
4914 (define-key gnus-summary-inc-fol-map "f" 'gnus-summary-raise-followups-to-author)
4915 (define-key gnus-summary-inc-fol-map "F" 'gnus-summary-raise-followups-to-author)
4916 (define-key gnus-summary-inc-fol-map "t" 'gnus-summary-raise-followups-to-author)
4917 (define-key gnus-summary-inc-fol-map "p" 'gnus-summary-raise-followups-to-author)
4919 (define-prefix-command 'gnus-summary-lower-map)
4920 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-map)
4921 (define-key gnus-summary-lower-map "l" 'gnus-summary-lower-same-subject-and-select)
4922 (define-key gnus-summary-lower-map "L" 'gnus-summary-lower-same-subject)
4923 (define-key gnus-summary-lower-map "\C-l" 'gnus-summary-lower-score)
4925 (define-prefix-command 'gnus-summary-low-subject-map)
4926 (define-key gnus-summary-lower-map "s" 'gnus-summary-low-subject-map)
4927 (define-key gnus-summary-lower-map "S" 'gnus-summary-temporarily-lower-by-subject)
4928 (define-key gnus-summary-low-subject-map "s" 'gnus-summary-temporarily-lower-by-subject)
4929 (define-key gnus-summary-low-subject-map "S" 'gnus-summary-lower-by-subject)
4930 (define-key gnus-summary-low-subject-map "t" 'gnus-summary-temporarily-lower-by-subject)
4931 (define-key gnus-summary-low-subject-map "p" 'gnus-summary-lower-by-subject)
4933 (define-prefix-command 'gnus-summary-low-body-map)
4934 (define-key gnus-summary-lower-map "b" 'gnus-summary-low-body-map)
4935 (define-key gnus-summary-lower-map "B" 'gnus-summary-temporarily-lower-by-body)
4936 (define-key gnus-summary-low-body-map "b" 'gnus-summary-temporarily-lower-by-body)
4937 (define-key gnus-summary-low-body-map "B" 'gnus-summary-lower-by-body)
4938 (define-key gnus-summary-low-body-map "t" 'gnus-summary-temporarily-lower-by-body)
4939 (define-key gnus-summary-low-body-map "p" 'gnus-summary-lower-by-body)
4941 (define-prefix-command 'gnus-summary-low-author-map)
4942 (define-key gnus-summary-lower-map "a" 'gnus-summary-low-author-map)
4943 (define-key gnus-summary-lower-map "A" 'gnus-summary-temporarily-lower-by-author)
4944 (define-key gnus-summary-low-author-map "a" 'gnus-summary-temporarily-lower-by-author)
4945 (define-key gnus-summary-low-author-map "A" 'gnus-summary-lower-by-author)
4946 (define-key gnus-summary-low-author-map "t" 'gnus-summary-temporarily-lower-by-author)
4947 (define-key gnus-summary-low-author-map "p" 'gnus-summary-lower-by-author)
4949 (define-prefix-command 'gnus-summary-low-id-map)
4950 (define-key gnus-summary-lower-map "i" 'gnus-summary-low-id-map)
4951 (define-key gnus-summary-lower-map "I" 'gnus-summary-temporarily-lower-by-id)
4952 (define-key gnus-summary-low-id-map "i" 'gnus-summary-temporarily-lower-by-id)
4953 (define-key gnus-summary-low-id-map "I" 'gnus-summary-lower-by-id)
4954 (define-key gnus-summary-low-id-map "t" 'gnus-summary-temporarily-lower-by-id)
4955 (define-key gnus-summary-low-id-map "p" 'gnus-summary-lower-by-id)
4957 (define-prefix-command 'gnus-summary-low-thread-map)
4958 (define-key gnus-summary-lower-map "t" 'gnus-summary-low-thread-map)
4959 (define-key gnus-summary-lower-map "T" 'gnus-summary-temporarily-lower-by-thread)
4960 (define-key gnus-summary-low-thread-map "t" 'gnus-summary-temporarily-lower-by-thread)
4961 (define-key gnus-summary-low-thread-map "T" 'gnus-summary-lower-by-thread)
4962 (define-key gnus-summary-low-thread-map "t" 'gnus-summary-temporarily-lower-by-thread)
4963 (define-key gnus-summary-low-thread-map "p" 'gnus-summary-lower-by-thread)
4965 (define-prefix-command 'gnus-summary-low-xref-map)
4966 (define-key gnus-summary-lower-map "x" 'gnus-summary-low-xref-map)
4967 (define-key gnus-summary-lower-map "X" 'gnus-summary-temporarily-lower-by-xref)
4968 (define-key gnus-summary-low-xref-map "x" 'gnus-summary-temporarily-lower-by-xref)
4969 (define-key gnus-summary-low-xref-map "X" 'gnus-summary-lower-by-xref)
4970 (define-key gnus-summary-low-xref-map "t" 'gnus-summary-temporarily-lower-by-xref)
4971 (define-key gnus-summary-low-xref-map "p" 'gnus-summary-lower-by-xref)
4973 (define-prefix-command 'gnus-summary-low-fol-map)
4974 (define-key gnus-summary-lower-map "f" 'gnus-summary-low-fol-map)
4975 (define-key gnus-summary-lower-map "F" 'gnus-summary-lower-followups-to-author)
4976 (define-key gnus-summary-low-fol-map "f" 'gnus-summary-lower-followups-to-author)
4977 (define-key gnus-summary-low-fol-map "F" 'gnus-summary-lower-followups-to-author)
4978 (define-key gnus-summary-low-fol-map "t" 'gnus-summary-lower-followups-to-author)
4979 (define-key gnus-summary-low-fol-map "p" 'gnus-summary-lower-followups-to-author)
4985 (defun gnus-summary-mode ()
4986 "Major mode for reading articles.
4988 All normal editing commands are switched off.
4989 \\<gnus-summary-mode-map>
4990 Each line in this buffer represents one article. To read an
4991 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
4992 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
4995 You can also post articles and send mail from this buffer. To
4996 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
4997 of an article, type `\\[gnus-summary-reply]'.
4999 There are approx. one gazillion commands you can execute in this
5000 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
5002 The following commands are available:
5004 \\{gnus-summary-mode-map}"
5006 (if gnus-visual (gnus-summary-make-menu-bar))
5007 (kill-all-local-variables)
5008 (let ((locals gnus-summary-local-variables))
5010 (if (consp (car locals))
5012 (make-local-variable (car (car locals)))
5013 (set (car (car locals)) (eval (cdr (car locals)))))
5014 (make-local-variable (car locals))
5015 (set (car locals) nil))
5016 (setq locals (cdr locals))))
5017 (gnus-update-format-specifications)
5018 (setq mode-line-modified "-- ")
5019 (make-local-variable 'mode-line-format)
5020 (setq mode-line-format (copy-sequence mode-line-format))
5021 (and (equal (nth 3 mode-line-format) " ")
5022 (setcar (nthcdr 3 mode-line-format) ""))
5023 (setq major-mode 'gnus-summary-mode)
5024 (setq mode-name "Summary")
5025 (make-local-variable 'minor-mode-alist)
5026 (gnus-set-mode-line 'summary)
5027 (use-local-map gnus-summary-mode-map)
5028 (buffer-disable-undo (current-buffer))
5029 (setq buffer-read-only t) ;Disable modification
5030 (setq truncate-lines t)
5031 (setq selective-display t)
5032 (setq selective-display-ellipses t) ;Display `...'
5033 (run-hooks 'gnus-summary-mode-hook))
5035 (defun gnus-summary-clear-local-variables ()
5036 (let ((locals gnus-summary-local-variables))
5038 (if (consp (car locals))
5039 (set (car (car locals)) nil)
5040 (set (car locals) nil))
5041 (setq locals (cdr locals)))))
5043 (defun gnus-mouse-pick-article (e)
5046 (gnus-summary-next-page nil t))
5048 (defun gnus-summary-setup-buffer (group)
5049 "Initialize summary buffer."
5050 (let ((buffer (concat "*Summary " group "*")))
5051 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
5052 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
5053 (gnus-add-current-to-buffer-list)
5054 (gnus-summary-mode)))
5056 (defun gnus-set-global-variables ()
5057 ;; Set the global equivalents of the summary buffer-local variables
5058 ;; to the latest values they had. These reflect the summary buffer
5059 ;; that was in action when the last article was fetched.
5060 (if (eq major-mode 'gnus-summary-mode)
5062 (setq gnus-summary-buffer (current-buffer))
5063 (let ((name gnus-newsgroup-name)
5064 (marked gnus-newsgroup-marked)
5065 (unread gnus-newsgroup-unreads)
5066 (headers gnus-current-headers))
5068 (set-buffer gnus-group-buffer)
5069 (setq gnus-newsgroup-name name)
5070 (setq gnus-newsgroup-marked marked)
5071 (setq gnus-newsgroup-unreads unread)
5072 (setq gnus-current-headers headers))))))
5074 (defun gnus-summary-insert-dummy-line (sformat subject number)
5076 (setq sformat gnus-summary-dummy-line-format-spec))
5080 (insert (eval sformat))
5081 (add-text-properties
5083 (list 'gnus-subject (gnus-simplify-subject-re subject)
5088 (defun gnus-summary-insert-line
5089 (sformat header level current unread replied expirable subject-or-nil
5090 &optional dummy score)
5091 (or sformat (setq sformat gnus-summary-line-format-spec))
5093 (make-string (* level gnus-thread-indent-level) ? ))
5094 (lines (or (header-lines header) 0))
5095 (score (or score gnus-summary-default-score 0))
5096 (score-char (if (or (null gnus-summary-default-score)
5097 (= score gnus-summary-default-score)) ?
5098 (if (< score gnus-summary-default-score)
5099 gnus-score-below-mark gnus-score-over-mark)))
5100 (replied (if replied gnus-replied-mark ? ))
5101 (from (header-from header))
5102 (name-address (funcall gnus-extract-address-components from))
5103 (address (car (cdr name-address)))
5104 (name (or (car name-address) (car (cdr name-address))))
5105 (number (header-number header))
5106 (subject (header-subject header))
5107 (buffer-read-only nil)
5108 (opening-bracket (if dummy ?\< ?\[))
5109 (closing-bracket (if dummy ?\> ?\]))
5111 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
5112 (if (not (numberp lines)) (setq lines 0))
5115 (insert (eval sformat))
5116 (add-text-properties
5118 (list 'gnus-subject (gnus-simplify-subject-re subject)
5120 'gnus-mark (or unread gnus-unread-mark ? )
5121 'gnus-thread level))))
5123 (defun gnus-summary-update-line (&optional dont-update)
5124 ;; Update summary line after change.
5125 (or (not gnus-summary-default-score)
5126 gnus-summary-inhibit-highlight
5127 (let ((gnus-summary-inhibit-highlight t)
5128 (article (gnus-summary-article-number)))
5131 (if (and gnus-summary-mark-below
5132 (< (gnus-summary-article-score)
5133 gnus-summary-mark-below))
5134 (and (not (memq article gnus-newsgroup-marked))
5135 (not (memq article gnus-newsgroup-dormant))
5136 (memq article gnus-newsgroup-unreads)
5137 (gnus-summary-mark-article nil gnus-low-score-mark))
5138 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
5139 (gnus-summary-mark-article nil gnus-unread-mark))))
5141 (run-hooks 'gnus-visual-summary-update-hook))))))
5143 (defun gnus-summary-update-lines ()
5144 ;; Rehighlight summary buffer according to `gnus-summary-highlight'.
5145 (and (save-excursion
5146 (set-buffer gnus-summary-buffer)
5147 (goto-char (point-min))
5149 (gnus-summary-update-line)
5150 (forward-line 1)))))
5152 (defun gnus-summary-number-of-articles-in-thread (thread)
5153 ;; Sum up all elements (and sub-elements) in a list.
5155 (apply '+ (mapcar 'gnus-summary-number-of-articles-in-thread thread))
5158 (defun gnus-summary-read-group (group &optional show-all no-article kill-buffer)
5159 "Start reading news in newsgroup GROUP.
5160 If SHOW-ALL is non-nil, already read articles are also listed.
5161 If NO-ARTICLE is non-nil, no article is selected initially."
5162 (message "Retrieving newsgroup: %s..." group)
5163 (gnus-summary-setup-buffer group)
5164 (if (gnus-select-newsgroup group show-all)
5166 (gnus-set-global-variables)
5167 ;; Save the active value in effect when the group was entered.
5168 (setq gnus-newsgroup-active
5170 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5171 ;; You can change the subjects in this hook.
5172 (run-hooks 'gnus-select-group-hook)
5173 ;; Do score processing.
5174 (gnus-score-headers)
5175 ;; Update the format specifiers.
5176 (gnus-update-format-specifications)
5177 ;; Generate the summary buffer.
5178 (gnus-summary-prepare)
5179 (if (zerop (buffer-size))
5180 (cond (gnus-newsgroup-dormant
5181 (gnus-summary-show-all-dormant))
5182 ((and gnus-newsgroup-scored show-all)
5183 (gnus-summary-show-all-expunged))))
5184 ;; Function `gnus-apply-kill-file' must be called in this hook.
5185 (run-hooks 'gnus-apply-kill-hook)
5186 (if (zerop (buffer-size))
5188 ;; This newsgroup is empty.
5189 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
5190 (message "No unread news")
5192 (get-buffer kill-buffer)
5193 (buffer-name (get-buffer kill-buffer))
5194 (kill-buffer kill-buffer)))
5197 (let ((gnus-summary-buffer kill-buffer))
5198 (gnus-configure-windows 'newsgroups t))))
5199 ;; Hide conversation thread subtrees. We cannot do this in
5200 ;; gnus-summary-prepare-hook since kill processing may not
5201 ;; work with hidden articles.
5202 (and gnus-show-threads
5203 gnus-thread-hide-subtree
5204 (gnus-summary-hide-all-threads))
5205 ;; Show first unread article if requested.
5206 (goto-char (point-min))
5207 (if (and (not no-article)
5208 gnus-auto-select-first
5209 (gnus-summary-first-unread-article))
5210 (gnus-configure-windows 'article)
5211 (gnus-configure-windows 'summary))
5212 (pop-to-buffer gnus-summary-buffer)
5213 (gnus-set-mode-line 'summary)
5214 (gnus-summary-position-cursor)
5215 (if (and kill-buffer
5216 (get-buffer kill-buffer)
5217 (buffer-name (get-buffer kill-buffer)))
5218 (kill-buffer kill-buffer))))
5219 ;; Cannot select newsgroup GROUP.
5220 (message "Couldn't select newsgroup")
5221 (and (eq major-mode 'gnus-summary-mode)
5222 (kill-buffer (current-buffer)))
5223 (switch-to-buffer gnus-group-buffer)
5224 (gnus-group-next-unread-group 1)))
5226 (defun gnus-summary-prepare ()
5227 "Prepare summary list of current newsgroup in summary buffer."
5228 (let ((buffer-read-only nil))
5230 (gnus-summary-prepare-threads
5231 (if gnus-show-threads
5232 (gnus-gather-threads
5234 (if gnus-summary-expunge-below
5235 (gnus-make-threads-and-expunge)
5236 (gnus-make-threads))))
5237 gnus-newsgroup-headers)
5239 ;; Erase header retrieval message.
5240 (gnus-summary-update-lines)
5242 ;; Call hooks for modifying summary buffer.
5243 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
5244 (goto-char (point-min))
5245 (run-hooks 'gnus-summary-prepare-hook)))
5247 (defun gnus-gather-threads (threads)
5248 "Gather threads that have lost their roots."
5249 (if (not gnus-summary-make-false-root)
5251 (let ((hashtb (gnus-make-hashtable 1023))
5254 thread subject hthread unre-subject whole-subject)
5256 (setq subject (header-subject (car (car threads)))
5257 whole-subject subject)
5258 (and gnus-summary-gather-subject-limit
5259 (or (and (numberp gnus-summary-gather-subject-limit)
5260 (> (length subject) gnus-summary-gather-subject-limit)
5262 (substring subject 0
5263 gnus-summary-gather-subject-limit)))
5264 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
5265 (setq subject (gnus-simplify-subject-fuzzy subject)))))
5268 (setq unre-subject (gnus-simplify-subject-re subject))
5271 (or (stringp (car (car hthread)))
5272 (setcar hthread (list whole-subject (car hthread))))
5273 (setcdr (car hthread) (nconc (cdr (car hthread))
5274 (list (car threads))))
5275 (setcdr prev (cdr threads))
5276 (setq threads prev))
5277 (gnus-sethash unre-subject threads hashtb))
5279 (setq threads (cdr threads)))
5282 (defun gnus-make-threads ()
5283 ;; This function takes the dependencies already made by
5284 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5285 ;; through the dependecies in the hash table and finds all the
5286 ;; roots. Roots do not refer back to any valid articles.
5288 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5289 (gnus-build-old-threads))
5292 (if (not (car (symbol-value refs)))
5293 (setq roots (append (cdr (symbol-value refs)) roots))
5294 ;; Ok, these refer back to valid articles, but if
5295 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5296 ;; the root has the same subject as its children. The children
5297 ;; that do not are made into roots and removed from the list
5299 (or gnus-thread-ignore-subject
5300 (let* ((prev (symbol-value refs))
5301 (subject (gnus-simplify-subject-re
5302 (header-subject (car prev))))
5303 (headers (cdr prev)))
5305 (if (not (string= subject
5306 (gnus-simplify-subject-re
5307 (header-subject (car headers)))))
5309 (setq roots (cons (car headers) roots))
5310 (setcdr prev (cdr headers)))
5311 (setq prev headers))
5312 (setq headers (cdr headers)))))))
5313 gnus-newsgroup-dependencies)
5315 (mapcar 'gnus-trim-thread
5317 (mapcar 'gnus-cut-thread
5318 (mapcar 'gnus-make-sub-thread roots))))))
5320 (defun gnus-make-threads-and-expunge ()
5321 ;; This function takes the dependencies already made by
5322 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5323 ;; through the dependecies in the hash table and finds all the
5324 ;; roots. Roots do not refer back to any valid articles.
5326 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5327 (gnus-build-old-threads))
5330 (if (not (car (symbol-value refs)))
5331 (if (and gnus-summary-expunge-below
5332 (not gnus-fetch-old-headers))
5333 (let ((headers (cdr (symbol-value refs))))
5335 (if (not (< (or (cdr (assq (header-number (car headers))
5336 gnus-newsgroup-scored))
5337 gnus-summary-default-score 0)
5338 gnus-summary-expunge-below))
5339 (setq roots (cons (car headers) roots))
5340 (setq gnus-newsgroup-unreads
5341 (delq (header-number (car headers))
5342 gnus-newsgroup-unreads)))
5343 (setq headers (cdr headers))))
5344 (setq roots (append (cdr (symbol-value refs)) roots)))
5345 ;; Ok, these refer back to valid articles, but if
5346 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5347 ;; the root has the same subject as its children. The children
5348 ;; that do not are made into roots and removed from the list
5350 (or gnus-thread-ignore-subject
5351 (let* ((prev (symbol-value refs))
5352 (subject (gnus-simplify-subject-re
5353 (header-subject (car prev))))
5354 (headers (cdr prev)))
5356 (if (not (string= subject
5357 (gnus-simplify-subject-re
5358 (header-subject (car headers)))))
5360 (setq roots (cons (car headers) roots))
5361 (setcdr prev (cdr headers)))
5362 (setq prev headers))
5363 (setq headers (cdr headers)))))
5364 (and gnus-summary-expunge-below
5365 (not gnus-fetch-old-headers)
5366 (let* ((prev (symbol-value refs))
5367 (headers (cdr prev))
5370 (if (not (< (or (cdr (assq (header-number (car headers))
5371 gnus-newsgroup-scored))
5372 gnus-summary-default-score 0)
5373 gnus-summary-expunge-below))
5374 (setq prev (cdr prev))
5375 (setq gnus-newsgroup-unreads
5376 (delq (header-number (car headers))
5377 gnus-newsgroup-unreads))
5378 (setcdr prev (cdr headers))
5379 (setq id (gnus-gethash (header-id (car headers))
5380 gnus-newsgroup-dependencies))
5383 (if (not (< (or (cdr (assq (header-number (car h))
5384 gnus-newsgroup-scored))
5385 gnus-summary-default-score 0)
5386 gnus-summary-expunge-below))
5387 (setq roots (cons (car h) roots)))
5389 (setq headers (cdr headers)))))))
5390 gnus-newsgroup-dependencies)
5392 (mapcar 'gnus-trim-thread
5394 (mapcar 'gnus-cut-thread
5395 (mapcar 'gnus-make-sub-thread roots))))))
5397 (defun gnus-cut-thread (thread)
5398 ;; Remove leaf dormant or ancient articles from THREAD.
5399 (let ((head (car thread))
5400 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
5401 (if (and (null tail)
5402 (let ((number (header-number head)))
5403 (or (memq number gnus-newsgroup-ancient)
5404 (memq number gnus-newsgroup-dormant)
5405 (and gnus-summary-expunge-below
5406 (eq gnus-fetch-old-headers 'some)
5407 (< (or (cdr (assq number gnus-newsgroup-scored))
5408 gnus-summary-default-score 0)
5409 gnus-summary-expunge-below)
5411 (setq gnus-newsgroup-unreads
5412 (delq number gnus-newsgroup-unreads))
5415 (list (cons head tail)))))
5417 (defun gnus-trim-thread (thread)
5418 ;; Remove root ancient articles with only one child from THREAD.
5419 (if (and (eq gnus-fetch-old-headers 'some)
5420 (memq (header-number (car thread)) gnus-newsgroup-ancient)
5421 (= (length thread) 2))
5422 (gnus-trim-thread (nth 1 thread))
5425 (defun gnus-make-sub-thread (root)
5426 ;; This function makes a sub-tree for a node in the tree.
5427 (let ((children (reverse (cdr (gnus-gethash (downcase (header-id root))
5428 gnus-newsgroup-dependencies)))))
5429 (cons root (mapcar 'gnus-make-sub-thread children))))
5431 (defun gnus-build-old-threads ()
5432 ;; Look at all the articles that refer back to old articles, and
5433 ;; fetch the headers for the articles that aren't there. This will
5434 ;; build complete threads - if the roots haven't been expired by the
5439 (if (not (car (symbol-value refs)))
5441 (setq heads (cdr (symbol-value refs)))
5443 (if (not (memq (header-number (car heads))
5444 gnus-newsgroup-dormant))
5446 (setq id (symbol-name refs))
5447 (while (and (setq id (gnus-build-get-header id))
5448 (not (car (gnus-gethash
5449 id gnus-newsgroup-dependencies)))))
5451 (setq heads (cdr heads)))))))
5452 gnus-newsgroup-dependencies)))
5454 (defun gnus-build-get-header (id)
5455 ;; Look through the buffer of NOV lines and find the header to
5456 ;; ID. Enter this line into the dependencies hash table, and return
5457 ;; the id of the parent article (if any).
5458 (let ((deps gnus-newsgroup-dependencies)
5462 (set-buffer nntp-server-buffer)
5463 (goto-char (point-min))
5464 (while (and (not found) (search-forward id nil t))
5466 (setq found (looking-at (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
5467 (regexp-quote id))))
5468 (or found (beginning-of-line 2)))
5473 (setq header (gnus-nov-parse-line
5474 (read (current-buffer)) deps))
5475 (setq ref (header-references header))
5476 (string-match "\\(<[^>]+>\\) *$" ref)
5477 (substring ref (match-beginning 1) (match-end 1))))))
5479 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
5480 gnus-newsgroup-ancient (cons (header-number header)
5481 gnus-newsgroup-ancient))))))
5483 (defun gnus-sort-threads (threads)
5484 ;; Sort threads as specified in `gnus-thread-sort-functions'.
5485 (let ((fun gnus-thread-sort-functions))
5487 (setq threads (sort threads (car fun))
5491 (defun gnus-thread-header (thread)
5492 ;; Return header of first article in THREAD.
5494 (if (stringp (car thread))
5495 (car (car (cdr thread)))
5499 (defun gnus-thread-sort-by-number (h1 h2)
5500 "Sort threads by root article number."
5501 (let ((h1 (gnus-thread-header h1))
5502 (h2 (gnus-thread-header h2)))
5503 (< (header-number h1) (header-number h2))))
5505 (defun gnus-thread-sort-by-author (h1 h2)
5506 "Sort threads by root author."
5507 (let ((h1 (gnus-thread-header h1))
5508 (h2 (gnus-thread-header h2)))
5510 (let ((extract (funcall
5511 gnus-extract-address-components (header-from h1))))
5512 (or (car extract) (cdr extract)))
5513 (let ((extract (funcall
5514 gnus-extract-address-components (header-from h2))))
5515 (or (car extract) (cdr extract))))))
5517 (defun gnus-thread-sort-by-subject (h1 h2)
5518 "Sort threads by root subject."
5519 (let ((h1 (gnus-thread-header h1))
5520 (h2 (gnus-thread-header h2)))
5522 (downcase (gnus-simplify-subject (header-subject h1)))
5523 (downcase (gnus-simplify-subject (header-subject h2))))))
5525 (defun gnus-thread-sort-by-date (h1 h2)
5526 "Sort threads by root article date."
5527 (let ((h1 (gnus-thread-header h1))
5528 (h2 (gnus-thread-header h2)))
5530 (gnus-sortable-date (header-date h1))
5531 (gnus-sortable-date (header-date h2)))))
5533 (defun gnus-thread-sort-by-score (h1 h2)
5534 "Sort threads by root article score.
5535 Unscored articles will be counted as havin a score of zero."
5536 (let ((h1 (gnus-thread-header h1))
5537 (h2 (gnus-thread-header h2)))
5538 (let ((s1 (assq (header-number h1) gnus-newsgroup-scored))
5539 (s2 (assq (header-number h2) gnus-newsgroup-scored)))
5540 (> (or (cdr s1) gnus-summary-default-score 0)
5541 (or (cdr s2) gnus-summary-default-score 0)))))
5543 (defun gnus-thread-sort-by-total-score (h1 h2)
5544 "Sort threads by the sum of all scores in the thread.
5545 Unscored articles will be counted as havin a score of zero."
5546 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5548 (defun gnus-thread-total-score (thread)
5549 ;; This function find the total score of THREAD.
5551 (if (stringp (car thread))
5552 (apply gnus-thread-score-function 0
5553 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5554 (gnus-thread-total-score-1 thread))
5555 (gnus-thread-total-score-1 (list thread))))
5557 (defun gnus-thread-total-score-1 (root)
5558 ;; This function find the total score of the thread below ROOT.
5559 (setq root (car root))
5560 (apply gnus-thread-score-function
5561 (or (cdr (assq (header-number root) gnus-newsgroup-scored))
5562 gnus-summary-default-score 0)
5563 (mapcar 'gnus-thread-total-score
5564 (cdr (gnus-gethash (downcase (header-id root))
5565 gnus-newsgroup-dependencies)))))
5567 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5568 (defvar gnus-tmp-prev-subject "")
5570 ;; Basic ideas by Paul Dworkin <paul@media-lab.media.mit.edu>.
5571 (defun gnus-summary-prepare-threads
5572 (threads level &optional not-child no-subject cull)
5573 "Prepare summary buffer from THREADS and indentation LEVEL.
5574 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5575 or a straight list of headers."
5576 (let (thread header number subject clevel)
5578 (setq thread (car threads)
5579 threads (cdr threads))
5580 ;; If `thread' is a cons, hierarchical threads are used. If not,
5581 ;; `thread' is the header.
5583 (setq header (car thread))
5584 (setq header thread)
5586 (or (memq (setq number (header-number header))
5587 gnus-newsgroup-dormant)
5588 (and gnus-summary-expunge-below
5589 (< (or (cdr (assq number gnus-newsgroup-scored))
5590 gnus-summary-default-score 0)
5591 gnus-summary-expunge-below)))
5594 (setq gnus-newsgroup-unreads
5595 (delq number gnus-newsgroup-unreads)))))
5598 ;; The header is a dummy root.
5599 (cond ((eq gnus-summary-make-false-root 'adopt)
5600 ;; We let the first article adopt the rest.
5601 (gnus-summary-prepare-threads (list (car (cdr thread))) 0)
5602 (setq thread (cdr (cdr thread)))
5604 (gnus-summary-prepare-threads (list (car thread)) 1 t)
5605 (setq thread (cdr thread))))
5606 ((eq gnus-summary-make-false-root 'dummy)
5607 ;; We output a dummy root.
5608 (gnus-summary-insert-dummy-line
5609 nil header (header-number (car (car (cdr thread)))))
5611 ((eq gnus-summary-make-false-root 'empty)
5612 ;; We print the articles with empty subject fields.
5613 (gnus-summary-prepare-threads (list (car (cdr thread))) 0)
5614 (setq thread (cdr (cdr thread)))
5616 (gnus-summary-prepare-threads
5617 (list (car thread)) 0 nil
5618 (not (and (eq gnus-summary-gather-subject-limit 'fuzzy)
5620 (gnus-simplify-subject-re
5621 (header-subject (car (car thread))))
5622 (gnus-simplify-subject-re header))))))
5623 (setq thread (cdr thread))))
5625 ;; We do not make a root for the gathered
5626 ;; sub-threads at all.
5628 ;; Print the sub-threads.
5629 (and (consp thread) (cdr thread)
5630 (gnus-summary-prepare-threads (cdr thread) clevel)))
5631 ;; The header is a real article.
5633 (setq number (header-number header)
5634 subject (header-subject header))
5635 (gnus-summary-insert-line
5636 nil header level nil
5637 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
5638 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
5639 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
5640 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
5641 (t gnus-ancient-mark))
5642 (memq number gnus-newsgroup-replied)
5643 (memq number gnus-newsgroup-expirable)
5645 gnus-summary-same-subject
5646 (if (or (zerop level)
5647 (and gnus-thread-ignore-subject
5649 (gnus-simplify-subject-re gnus-tmp-prev-subject)
5650 (gnus-simplify-subject-re subject)))))
5652 gnus-summary-same-subject))
5654 (cdr (assq number gnus-newsgroup-scored)))
5655 (setq gnus-tmp-prev-subject subject)
5656 ;; Recursively print subthreads.
5657 (and (consp thread) (cdr thread)
5658 (gnus-summary-prepare-threads (cdr thread) (1+ level))))))))
5660 (defun gnus-select-newsgroup (group &optional read-all)
5661 "Select newsgroup GROUP.
5662 If READ-ALL is non-nil, all articles in the group are selected."
5663 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5664 (info (nth 2 entry))
5665 articles header-marks)
5666 (gnus-check-news-server
5667 (setq gnus-current-select-method (gnus-find-method-for-group group)))
5669 (or (gnus-server-opened gnus-current-select-method)
5670 (gnus-open-server gnus-current-select-method)
5671 (error "Couldn't open server"))
5673 (or (and (eq (car entry) t)
5674 (gnus-activate-newsgroup (car info)))
5675 (gnus-request-group group t)
5677 (kill-buffer (current-buffer))
5678 (error "Couldn't request group %s: %s"
5679 group (gnus-status-message group))))
5681 (setq gnus-newsgroup-name group)
5682 (setq gnus-newsgroup-unselected nil)
5683 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5685 (if (not (setq articles (gnus-articles-to-read group read-all)))
5687 ;; Init the dependencies hash table.
5688 (setq gnus-newsgroup-dependencies
5689 (gnus-make-hashtable (length articles)))
5690 ;; Retrieve the headers and read them in.
5691 (setq gnus-newsgroup-headers
5692 (if (eq 'nov (setq gnus-headers-retrieved-by
5693 (gnus-retrieve-headers
5694 (if gnus-fetch-old-headers
5695 (cons 1 articles) articles)
5696 gnus-newsgroup-name)))
5698 (gnus-get-newsgroup-headers-xover articles))
5699 (gnus-get-newsgroup-headers)))
5700 ;; If we were to fetch old headers, but the backend didn't
5701 ;; support XOVER, then it is possible we fetched one article
5702 ;; that we shouldn't have. If that's the case, we pop it off the
5704 (and (not (eq gnus-headers-retrieved-by 'nov))
5705 gnus-fetch-old-headers
5706 gnus-newsgroup-headers
5707 (/= (header-number (car gnus-newsgroup-headers)) (car articles))
5708 (setq gnus-newsgroup-headers (cdr gnus-newsgroup-headers)))
5709 ;; Remove cancelled articles from the list of unread articles.
5710 (setq gnus-newsgroup-unreads
5711 (gnus-set-sorted-intersection
5712 gnus-newsgroup-unreads
5713 (mapcar (lambda (headers) (header-number headers))
5714 gnus-newsgroup-headers)))
5715 ;; Adjust and set lists of article marks.
5718 (gnus-adjust-marked-articles info)
5719 (setq gnus-newsgroup-marked
5720 (cdr (assq 'tick (setq marked (nth 3 info)))))
5721 (setq gnus-newsgroup-replied (cdr (assq 'reply marked)))
5722 (setq gnus-newsgroup-expirable (cdr (assq 'expire marked)))
5723 (setq gnus-newsgroup-killed (cdr (assq 'killed marked)))
5724 (setq gnus-newsgroup-bookmarks (cdr (assq 'bookmark marked)))
5725 (setq gnus-newsgroup-dormant (cdr (assq 'dormant marked)))
5726 (setq gnus-newsgroup-scored (cdr (assq 'score marked)))
5727 (setq gnus-newsgroup-processable nil)))
5728 ;; Check whether auto-expire is to be done in this group.
5729 (setq gnus-newsgroup-auto-expire
5730 (or (and (stringp gnus-auto-expirable-newsgroups)
5731 (string-match gnus-auto-expirable-newsgroups group))
5732 (memq 'auto-expire (nth 5 info))))
5733 ;; First and last article in this newsgroup.
5734 (and gnus-newsgroup-headers
5735 (setq gnus-newsgroup-begin
5736 (header-number (car gnus-newsgroup-headers)))
5737 (setq gnus-newsgroup-end
5738 (header-number (gnus-last-element gnus-newsgroup-headers))))
5739 (setq gnus-reffed-article-number -1)
5740 ;; GROUP is successfully selected.
5741 (or gnus-newsgroup-headers t))))
5743 (defun gnus-articles-to-read (group read-all)
5744 ;; Find out what articles the user wants to read.
5746 ;; Select all articles if `read-all' is non-nil, or if all the
5747 ;; unread articles are dormant articles.
5749 (= (length gnus-newsgroup-unreads)
5750 (length gnus-newsgroup-dormant)))
5751 (gnus-uncompress-range
5752 (gnus-gethash group gnus-active-hashtb))
5753 gnus-newsgroup-unreads))
5754 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5755 (scored (length scored-list))
5756 (number (length articles))
5757 (marked (+ (length gnus-newsgroup-marked)
5758 (length gnus-newsgroup-dormant)))
5761 (cond ((and (or (<= scored marked)
5763 (numberp gnus-large-newsgroup)
5764 (> number gnus-large-newsgroup))
5768 "How many articles from %s (default %d): "
5769 gnus-newsgroup-name number))))
5770 (if (string-equal input "")
5772 ((and (> scored marked) (< scored number))
5776 "%s %s (%d scored, %d total): "
5777 "How many articles from"
5778 group scored number))))
5779 (if (string-equal input "")
5784 (setq select (if (numberp select) select (string-to-number select)))
5787 (if (and (not (zerop scored)) (<= (abs select) scored))
5789 (setq articles (sort scored-list '<))
5790 (setq number (length articles)))
5791 (setq articles (copy-sequence articles)))
5793 (setq total-articles articles)
5795 (if (< (abs select) number)
5797 ;; Select the N oldest articles.
5798 (setcdr (nthcdr (1- (abs select)) articles) nil)
5799 ;; Select the N most recent articles.
5800 (setq articles (nthcdr (- number select) articles))))
5801 (setq gnus-newsgroup-unselected
5802 (gnus-sorted-intersection
5803 gnus-newsgroup-unreads
5804 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
5807 (defun gnus-killed-articles (killed articles)
5810 (if (inline (gnus-member-of-range (car articles) killed))
5811 (setq out (cons (car articles) out)))
5812 (setq articles (cdr articles)))
5815 (defun gnus-adjust-marked-articles (info &optional active)
5816 "Remove all marked articles that are no longer legal."
5817 (let ((marked-lists (nth 3 info))
5818 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
5820 ;; There are many types of marked articles.
5822 (setq m (cdr (setq prev (car marked-lists))))
5823 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
5824 ;; Make sure that all ticked articles are a subset of the
5825 ;; unread/unselected articles.
5827 (if (or (memq (car m) gnus-newsgroup-unreads)
5828 (memq (car m) gnus-newsgroup-unselected))
5830 (setcdr prev (cdr m)))
5832 ((eq 'score (car prev))
5833 ;; Scored articles should be a subset of
5834 ;; unread/unselected articles.
5836 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
5837 (memq (car (car m)) gnus-newsgroup-unreads))
5839 (setcdr prev (cdr m)))
5841 ((eq 'bookmark (car prev))
5842 ;; Bookmarks should be a subset of active articles.
5844 (if (< (car (car m)) (car active))
5845 (setcdr prev (cdr m))
5848 ((eq 'killed (car prev))
5849 ;; Articles that have been through the kill process are
5850 ;; to be a subset of active articles.
5851 (while (and m (< (or (and (numberp (car m)) (car m))
5854 (setcdr prev (cdr m))
5856 (if (and m (< (or (and (numberp (car m)) (car m))
5859 (setcar (if (numberp (car m)) m (car m)) (car active))))
5860 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
5861 ;; The replied and expirable articles have to be articles
5864 (if (< (car m) (car active))
5865 (setcdr prev (cdr m))
5868 (setq marked-lists (cdr marked-lists)))
5869 ;; Remove all lists that are empty.
5870 (setq marked-lists (nth 3 info))
5873 (while (= 1 (length (car marked-lists)))
5874 (setq marked-lists (cdr marked-lists)))
5875 (setq m (cdr (setq prev marked-lists)))
5877 (if (= 1 (length (car m)))
5878 (setcdr prev (cdr m))
5881 (setcar (nthcdr 3 info) marked-lists)))
5882 ;; Finally, if there are no marked lists at all left, and if there
5883 ;; are no elements after the lists in the info list, we just chop
5884 ;; the info list off before the marked lists.
5885 (and (null marked-lists)
5886 (not (nthcdr 4 info))
5887 (setcdr (nthcdr 2 info) nil)))
5890 (defun gnus-set-marked-articles
5891 (info ticked replied expirable killed dormant bookmark score)
5892 "Enter the various lists of marked articles into the newsgroup info list."
5894 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
5895 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
5896 (and expirable (setq newmarked (cons (cons 'expire expirable)
5898 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
5899 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
5900 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
5902 (and score (setq newmarked (cons (cons 'score score) newmarked)))
5905 (setcar (nthcdr 3 info) newmarked)
5906 (if (not (nthcdr 4 info))
5907 (setcdr (nthcdr 2 info) nil)
5908 (setcar (nthcdr 3 info) nil)))
5910 (setcdr (nthcdr 2 info) (cons newmarked nil))))))
5912 (defun gnus-add-marked-articles (group type articles &optional info force)
5913 ;; Add ARTICLES of TYPE to the info of GROUP.
5914 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
5915 ;; add, but replace marked articles of TYPE with ARTICLES.
5916 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
5919 (and (not (setq marked (nthcdr 3 info)))
5920 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
5921 (and (not (setq m (assq type (car marked))))
5922 (setcar marked (cons (cons type articles) (car marked))))
5925 (nconc m articles)))))
5927 (defun gnus-set-mode-line (where)
5928 "This function sets the mode line of the article or summary buffers.
5929 If WHERE is `summary', the summary mode line format will be used."
5930 (if (memq where gnus-updated-mode-lines)
5933 (set-buffer gnus-summary-buffer)
5934 (let* ((mformat (if (eq where 'article)
5935 gnus-article-mode-line-format-spec
5936 gnus-summary-mode-line-format-spec))
5937 (group-name gnus-newsgroup-name)
5938 (article-number (or gnus-current-article 0))
5939 (unread (- (length gnus-newsgroup-unreads)
5940 (length gnus-newsgroup-dormant)))
5941 (unread-and-unticked
5942 (- unread (length gnus-newsgroup-marked)))
5943 (unselected (length gnus-newsgroup-unselected))
5944 (unread-and-unselected
5945 (cond ((and (zerop unread-and-unticked)
5946 (zerop unselected)) "")
5948 (format "{%d more}" unread-and-unticked))
5949 (t (format "{%d(+%d) more}"
5950 unread-and-unticked unselected))))
5952 (if gnus-current-headers
5953 (header-subject gnus-current-headers) ""))
5954 (max-len (and gnus-mode-non-string-length
5955 (- (frame-width) gnus-mode-non-string-length)))
5956 header) ;; passed as argument to any user-format-funcs
5957 (setq mode-string (eval mformat))
5958 (and (numberp max-len)
5960 (if (> (length mode-string) max-len)
5962 (concat (substring mode-string 0 (- max-len 3))
5964 (setq mode-string (format (format "%%-%ds" max-len)
5966 (setq mode-line-buffer-identification mode-string)
5967 (set-buffer-modified-p t))))
5969 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5970 "Go through the HEADERS list and add all Xrefs to a hash table.
5971 The resulting hash table is returned, or nil if no Xrefs were found."
5972 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
5974 (gnus-group-foreign-p from-newsgroup)
5976 (assoc (symbol-name (car from-method))
5977 gnus-valid-select-methods))))
5978 (gnus-group-real-prefix from-newsgroup)))
5979 (xref-hashtb (make-vector 63 0))
5980 start group entry number xrefs header)
5982 (setq header (car headers))
5983 (if (and (setq xrefs (header-xref header))
5984 (not (memq (header-number header) unreads)))
5987 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
5988 (setq start (match-end 0))
5989 (setq group (concat prefix (substring xrefs (match-beginning 1)
5992 (string-to-int (substring xrefs (match-beginning 2)
5994 (if (setq entry (gnus-gethash group xref-hashtb))
5995 (setcdr entry (cons number (cdr entry)))
5996 (gnus-sethash group (cons number nil) xref-hashtb)))))
5997 (setq headers (cdr headers)))
5998 (if start xref-hashtb nil)))
6000 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
6001 "Look through all the headers and mark the Xrefs as read."
6002 (let ((virtual (memq 'virtual
6003 (assoc (symbol-name (car (gnus-find-method-for-group
6005 gnus-valid-select-methods)))
6006 name entry read info xref-hashtb idlist active num range exps method
6009 (set-buffer gnus-group-buffer)
6010 (if (setq xref-hashtb
6011 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6014 (if (string= from-newsgroup (setq name (symbol-name group)))
6016 (setq idlist (symbol-value group))
6017 ;; Dead groups are not updated.
6019 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
6021 (if (stringp (setq nth4 (nth 4 info)))
6022 (setq nth4 (gnus-server-to-method nth4))))
6023 ;; Only do the xrefs if the group has the same
6024 ;; select method as the group we have just read.
6025 (or (gnus-methods-equal-p
6026 nth4 (gnus-find-method-for-group from-newsgroup))
6029 (setq method (gnus-find-method-for-group
6031 (and (equal (car nth4) (car method))
6032 (equal (nth 1 nth4) (nth 1 method))))
6033 gnus-use-cross-reference
6034 (or (not (eq gnus-use-cross-reference t))
6036 ;; Only do cross-references on subscribed
6037 ;; groups, if that is what is wanted.
6038 (<= (nth 1 info) gnus-level-subscribed)))
6041 ;; Set the new list of read articles in this group.
6042 (setq active (gnus-gethash name gnus-active-hashtb))
6043 ;; First peel off all illegal article numbers.
6046 (ticked (cdr (assq 'tick (nth 3 info))))
6047 (dormant (cdr (assq 'dormant (nth 3 info))))
6052 (if (or (> id (cdr active))
6056 (setq idlist (delq id idlist)))
6057 (and (memq id expirable)
6058 (setq exps (cons id exps)))
6059 (setq ids (cdr ids)))))
6060 ;; Update expirable articles.
6061 (gnus-add-marked-articles nil 'expirable exps info)
6062 (and (null (nth 2 info))
6064 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
6065 (setcar (nthcdr 2 info)
6069 (setq idlist (sort idlist '<)))))
6070 ;; Then we have to re-compute how many unread
6071 ;; articles there are in this group.
6076 (setq num (- (1+ (cdr active)) (car active))))
6077 ((not (listp (cdr range)))
6078 (setq num (- (cdr active) (- (1+ (cdr range))
6082 (if (numberp (car range))
6084 (setq num (+ num (- (1+ (cdr (car range)))
6085 (car (car range))))))
6086 (setq range (cdr range)))
6087 (setq num (- (cdr active) num))))
6088 ;; Update the number of unread articles.
6092 (length (cdr (assq 'tick (nth 3 info))))
6094 (cdr (assq 'dormant (nth 3 info)))))))
6095 ;; Update the group buffer.
6096 (gnus-group-update-group name t)))))))
6099 (defun gnus-methods-equal-p (m1 m2)
6100 (let ((m1 (or m1 gnus-select-method))
6101 (m2 (or m2 gnus-select-method)))
6103 (and (eq (car m1) (car m2))
6104 (or (not (memq 'address (assoc (symbol-name (car m1))
6105 gnus-valid-select-methods)))
6106 (equal (nth 1 m1) (nth 1 m2)))))))
6108 (defsubst gnus-header-value ()
6109 (buffer-substring (match-end 0) (gnus-point-at-eol)))
6111 (defun gnus-get-newsgroup-headers ()
6112 (setq gnus-article-internal-prepare-hook nil)
6113 (let ((cur nntp-server-buffer)
6114 (dependencies gnus-newsgroup-dependencies)
6116 headers char article id dep end)
6118 (set-buffer nntp-server-buffer)
6120 ;; Search to the beginning of the next header. Error messages
6121 ;; do not begin with 2 or 3.
6122 (while (re-search-forward "^[23][0-9]+ " nil t)
6123 (let ((header (make-vector 9 nil))
6124 (c (following-char))
6125 (case-fold-search t)
6127 from subject in-reply-to references ref)
6133 (header-set-number header (setq article (read cur)))
6134 ;; This implementation of this function, with nine
6135 ;; search-forwards instead of the one re-search-forward and
6136 ;; a case (which basically was the old function) is actually
6137 ;; about twice as fast, even though it looks messier. You
6138 ;; can't have everything, I guess. Speed and elegance
6139 ;; doesn't always come hand in hand.
6141 (narrow-to-region (point) (save-excursion
6142 (search-forward "\n.\n" nil t)))
6143 (if (search-forward "\nfrom: " nil t)
6144 (header-set-from header (gnus-header-value))
6145 (header-set-from header "(nobody)"))
6147 (if (search-forward "\nsubject: " nil t)
6148 (header-set-subject header (gnus-header-value))
6149 (header-set-subject header "(none)"))
6151 (and (search-forward "\nxref: " nil t)
6152 (header-set-xref header (gnus-header-value)))
6154 (and (search-forward "\nlines: " nil t)
6155 (header-set-lines header (read cur)))
6157 (and (search-forward "\ndate: " nil t)
6158 (header-set-date header (gnus-header-value)))
6160 (if (search-forward "\nmessage-id: " nil t)
6161 (header-set-id header (setq id (gnus-header-value)))
6162 ;; If there was no message-id, we just fake one to make
6163 ;; subsequent routines simpler.
6166 (setq id (concat "none+" (int-to-string
6167 (setq none-id (1+ none-id)))))))
6169 (if (search-forward "\nreferences: " nil t)
6171 (header-set-references header (gnus-header-value))
6172 (setq end (match-end 0))
6179 (search-backward ">" end t)
6182 (search-backward "<" end t)
6184 ;; Get the references from the in-reply-to header if there
6185 ;; ware no references and the in-reply-to header looks
6187 (if (and (search-forward "\nin-reply-to: " nil t)
6188 (setq in-reply-to (gnus-header-value))
6189 (string-match "<[^>]+>" in-reply-to))
6191 (header-set-references
6193 (setq ref (substring in-reply-to (match-beginning 0)
6195 (setq ref (downcase ref)))
6197 ;; We do some threading while we read the headers. The
6198 ;; message-id and the last reference are both entered into
6199 ;; the same hash table. Some tippy-toeing around has to be
6200 ;; done in case an article has arrived before the article
6201 ;; which it refers to.
6202 (if (boundp (setq dep (intern (downcase id) dependencies)))
6203 (if (car (symbol-value dep))
6204 ;; An article with this Message-ID has already
6205 ;; been seen, so we ignore this one, except we add
6206 ;; any additional Xrefs (in case the two articles
6207 ;; came from different servers.
6210 (car (symbol-value dep))
6211 (concat (or (header-xref (car (symbol-value dep))) "")
6212 (or (header-xref header) "")))
6214 (setcar (symbol-value dep) header))
6215 (set dep (list header)))
6218 (if (boundp (setq dep (intern ref dependencies)))
6219 (setcdr (symbol-value dep)
6220 (cons header (cdr (symbol-value dep))))
6221 (set dep (list nil header)))
6222 (setq headers (cons header headers))))
6223 (goto-char (point-max))))))
6224 (nreverse headers)))
6226 ;; The following macros and functions were written by Felix Lee
6227 ;; <flee@cse.psu.edu>.
6229 ;; This is almost 4x faster than (string-to-int (buffer-substring ... ))
6230 ;; primarily because of garbage collection. -jwz
6231 (defmacro gnus-read-integer (&optional point move-p)
6232 (` ((, (if move-p 'progn 'save-excursion))
6233 (,@ (if point (list (list 'goto-char point))))
6234 (if (and (<= (following-char) ?9)
6235 (>= (following-char) ?0))
6236 (read (current-buffer))
6239 (defmacro gnus-nov-skip-field ()
6240 '(search-forward "\t" eol 'end))
6242 (defmacro gnus-nov-field ()
6245 (progn (gnus-nov-skip-field) (1- (point)))))
6247 ;; Goes through the xover lines and returns a list of vectors
6248 (defun gnus-get-newsgroup-headers-xover (sequence)
6249 "Parse the news overview data in the server buffer, and return a
6250 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
6251 ;; Get the Xref when the users reads the articles since most/some
6252 ;; NNTP servers do not include Xrefs when using XOVER.
6253 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6254 (let ((cur nntp-server-buffer)
6255 (dependencies gnus-newsgroup-dependencies)
6257 number headers header)
6259 (set-buffer nntp-server-buffer)
6260 (goto-char (point-min))
6261 (while (and sequence (not (eobp)))
6262 (setq number (read cur))
6263 (while (and sequence (< (car sequence) number))
6264 (setq sequence (cdr sequence)))
6266 (eq number (car sequence))
6268 (setq sequence (cdr sequence))
6270 (inline (gnus-nov-parse-line number dependencies)))
6271 (setq headers (cons header headers)))))
6273 (setq headers (nreverse headers)))
6276 (defun gnus-nov-parse-line (number dependencies)
6277 "Point has to be after the number on the beginning of the line."
6279 header (eol (gnus-point-at-eol)) ref id dep)
6281 ;; overview: [num subject from date id refs chars lines misc]
6283 (narrow-to-region (point) eol)
6288 (gnus-nov-field) ; subject
6289 (gnus-nov-field) ; from
6290 (gnus-nov-field) ; date
6291 (setq id (or (gnus-nov-field)
6294 (setq none (1+ none)))))) ; id
6297 (let ((beg (point)))
6298 (search-forward "\t" eol)
6299 (if (search-backward ">" beg t)
6305 (search-backward "<" beg t)
6308 (gnus-nov-field)) ; refs
6309 (read (current-buffer)) ; chars
6310 (read (current-buffer)) ; lines
6311 (if (/= (following-char) ?\t)
6314 (gnus-nov-field)) ; misc
6319 ;; We build the thread tree.
6321 (if (boundp (setq dep (intern (downcase id) dependencies)))
6322 (if (car (symbol-value dep))
6323 ;; An article with this Message-ID has already been seen,
6324 ;; so we ignore this one, except we add any additional
6325 ;; Xrefs (in case the two articles came from different
6329 (car (symbol-value dep))
6330 (concat (or (header-xref (car (symbol-value dep))) "")
6331 (or (header-xref header) "")))
6333 (setcar (symbol-value dep) header))
6334 (set dep (list header))))
6337 (if (boundp (setq dep (intern (or ref "none")
6339 (setcdr (symbol-value dep)
6340 (cons header (cdr (symbol-value dep))))
6341 (set dep (list nil header)))))
6344 (defun gnus-article-get-xrefs ()
6345 "Fill in the Xref value in `gnus-current-headers', if necessary.
6346 This is meant to be called in `gnus-article-internal-prepare-hook'."
6347 (or (not gnus-use-cross-reference)
6348 (header-xref gnus-current-headers)
6349 (let ((case-fold-search t)
6352 (gnus-narrow-to-headers)
6353 (goto-char (point-min))
6354 (if (or (and (eq (downcase (following-char)) ?x)
6355 (looking-at "Xref:"))
6356 (search-forward "\nXref:" nil t))
6358 (goto-char (1+ (match-end 0)))
6359 (setq xref (buffer-substring (point)
6360 (progn (end-of-line) (point))))
6362 (set-buffer gnus-summary-buffer)
6363 (header-set-xref gnus-current-headers xref))))))))
6365 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
6366 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
6368 ;; Return a header specified by a NUMBER.
6369 (defun gnus-get-header-by-number (number)
6371 (set-buffer gnus-summary-buffer)
6372 (or gnus-newsgroup-headers-hashtb-by-number
6373 (gnus-make-headers-hashtable-by-number))
6374 (gnus-gethash (int-to-string number)
6375 gnus-newsgroup-headers-hashtb-by-number)))
6377 (defun gnus-make-headers-hashtable-by-number ()
6378 "Make hashtable for the variable gnus-newsgroup-headers by number."
6380 (set-buffer gnus-summary-buffer)
6381 (let ((headers gnus-newsgroup-headers)
6383 (setq gnus-newsgroup-headers-hashtb-by-number
6384 (gnus-make-hashtable (length headers)))
6386 (setq header (car headers))
6387 (gnus-sethash (int-to-string (header-number header))
6388 header gnus-newsgroup-headers-hashtb-by-number)
6389 (setq headers (cdr headers))))))
6391 (defun gnus-more-header-backward ()
6392 "Find new header backward."
6393 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6394 (artnum gnus-newsgroup-begin)
6396 (while (and (not header)
6398 (setq artnum (1- artnum))
6399 (setq header (gnus-read-header artnum)))
6402 (defun gnus-more-header-forward (&optional backward)
6403 "Find new header forward.
6404 If BACKWARD, find new header backward instead."
6406 (gnus-more-header-backward)
6407 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6408 (artnum gnus-newsgroup-end)
6410 (while (and (not header)
6412 (setq artnum (1+ artnum))
6413 (setq header (gnus-read-header artnum)))
6416 (defun gnus-extend-newsgroup (header &optional backward)
6417 "Extend newsgroup selection with HEADER.
6418 Optional argument BACKWARD means extend toward backward."
6420 (let ((artnum (header-number header)))
6421 (setq gnus-newsgroup-headers
6423 (cons header gnus-newsgroup-headers)
6424 (nconc gnus-newsgroup-headers (list header))))
6425 (setq gnus-newsgroup-unselected
6426 (delq artnum gnus-newsgroup-unselected))
6427 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
6428 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
6430 (defun gnus-summary-work-articles (n)
6431 "Return a list of articles to be worked upon. The prefix argument,
6432 the list of process marked articles, and the current article will be
6433 taken into consideration."
6435 (if (and n (numberp n))
6436 (let ((backward (< n 0))
6440 (setq articles (cons (gnus-summary-article-number)
6442 (gnus-summary-search-forward nil nil backward))
6444 (sort articles (function <)))
6445 (or (reverse gnus-newsgroup-processable)
6446 (list (gnus-summary-article-number))))))
6448 (defun gnus-summary-search-group (&optional backward use-level)
6449 "Search for next unread newsgroup.
6450 If optional argument BACKWARD is non-nil, search backward instead."
6452 (set-buffer gnus-group-buffer)
6454 ;; We don't want to alter current point of group mode buffer.
6455 (if (gnus-group-search-forward
6457 (if use-level (gnus-group-group-level) nil))
6458 (gnus-group-group-name)))))
6460 (defun gnus-summary-best-group (&optional exclude-group)
6461 "Find the name of the best unread group.
6462 If EXCLUDE-GROUP, do not go to this group."
6464 (set-buffer gnus-group-buffer)
6466 (gnus-group-best-unread-group exclude-group))))
6468 (defun gnus-summary-search-subject (&optional backward unread subject)
6469 "Search for article forward.
6470 If BACKWARD is non-nil, search backward.
6471 If UNREAD is non-nil, only unread articles are selected.
6472 If SUBJECT is non-nil, the article which has the same subject will be
6474 (let ((func (if backward 'previous-single-property-change
6475 'next-single-property-change))
6480 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
6481 (while (and (setq pos (funcall func (point) 'gnus-number))
6482 (goto-char (if backward (1- pos) pos))
6484 (not (and (or (not unread)
6485 (eq (get-text-property (point) 'gnus-mark)
6488 (equal (gnus-simplify-subject-re
6490 (gnus-simplify-subject-re
6493 'gnus-subject)))))))
6494 (if backward (if (bobp) nil (forward-char -1) t)
6495 (if (eobp) nil (forward-char 1) t))))
6497 (progn (goto-char beg) nil)
6499 (get-text-property (point) 'gnus-number)
6500 (gnus-summary-position-cursor)))))
6502 (defun gnus-summary-search-forward (&optional unread subject backward)
6503 "Search for article forward.
6504 If UNREAD is non-nil, only unread articles are selected.
6505 If SUBJECT is non-nil, the article which has the same subject will be
6507 If BACKWARD is non-nil, the search will be performed backwards instead."
6508 (gnus-summary-search-subject backward unread subject))
6510 (defun gnus-summary-search-backward (&optional unread subject)
6511 "Search for article backward.
6512 If 1st optional argument UNREAD is non-nil, only unread article is selected.
6513 If 2nd optional argument SUBJECT is non-nil, the article which has
6514 the same subject will be searched for."
6515 (gnus-summary-search-forward unread subject t))
6517 (defun gnus-summary-article-number (&optional number-or-nil)
6518 "The article number of the article on the current line.
6519 If there isn's an article number here, then we return the current
6522 (number (get-text-property
6523 (progn (beginning-of-line) (prog1 (point) (goto-char p)))
6525 (if number-or-nil number (or number gnus-current-article))))
6527 (defun gnus-summary-thread-level ()
6528 "The thread level of the article on the current line."
6529 (or (get-text-property (gnus-point-at-bol) 'gnus-thread)
6532 (defun gnus-summary-pseudo-article ()
6533 "The thread level of the article on the current line."
6534 (get-text-property (gnus-point-at-bol) 'gnus-pseudo))
6536 (defun gnus-summary-article-mark ()
6537 "The mark on the current line."
6538 (get-text-property (gnus-point-at-bol) 'gnus-mark))
6540 (defun gnus-summary-subject-string ()
6541 "Return current subject string or nil if nothing."
6542 (get-text-property (gnus-point-at-bol) 'gnus-subject))
6544 (defalias 'gnus-summary-score 'gnus-summary-article-score)
6545 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
6546 (defun gnus-summary-article-score ()
6547 "Return current article score."
6548 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
6549 gnus-summary-default-score 0))
6551 (defun gnus-summary-recenter ()
6552 "Center point in the summary window.
6553 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6554 displayed, no centering will be performed."
6555 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6556 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6557 (let ((top (cond ((< (window-height) 4) 0)
6558 ((< (window-height) 6) 1)
6561 ;; The user has to want it,
6562 gnus-auto-center-summary
6563 ;; the article buffer must be displayed,
6564 (get-buffer-window gnus-article-buffer)
6565 ;; there must be lines left to scroll forward,
6566 (zerop (save-excursion (forward-line (- (window-height) 1 top))))
6569 (get-buffer-window (current-buffer))
6570 (save-excursion (forward-line (- top)) (point))))))
6572 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
6573 (defun gnus-short-group-name (newsgroup)
6574 "Convert a long group name to an initialized form.
6575 The last part of the name is left intact: \"rec.arts.anime\" becomes
6579 (if (string-match "\\." newsgroup)
6581 (setq name (concat name (substring newsgroup 0 1))
6582 newsgroup (substring newsgroup (match-end 0))
6583 name (concat name ".")))
6584 (setq name (concat name newsgroup)
6589 (defun gnus-summary-jump-to-group (newsgroup)
6590 "Move point to NEWSGROUP in group mode buffer."
6591 ;; Keep update point of group mode buffer if visible.
6592 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6593 (save-window-excursion
6594 ;; Take care of tree window mode.
6595 (if (get-buffer-window gnus-group-buffer)
6596 (pop-to-buffer gnus-group-buffer))
6597 (gnus-group-jump-to-group newsgroup))
6599 ;; Take care of tree window mode.
6600 (if (get-buffer-window gnus-group-buffer)
6601 (pop-to-buffer gnus-group-buffer)
6602 (set-buffer gnus-group-buffer))
6603 (gnus-group-jump-to-group newsgroup))))
6605 ;; This function returns a list of article numbers based on the
6606 ;; difference between the ranges of read articles in this group and
6607 ;; the range of active articles.
6608 (defun gnus-list-of-unread-articles (group)
6609 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6610 (active (gnus-gethash group gnus-active-hashtb))
6612 unread first nlast unread)
6613 ;; If none are read, then all are unread.
6615 (setq first (car active))
6616 ;; If the range of read articles is a single range, then the
6617 ;; first unread article is the article after the last read
6618 ;; article. Sounds logical, doesn't it?
6619 (if (not (listp (cdr read)))
6620 (setq first (1+ (cdr read)))
6621 ;; `read' is a list of ranges.
6622 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
6623 (car (car read)))) 1)
6627 (while (< first nlast)
6628 (setq unread (cons first unread))
6629 (setq first (1+ first))))
6630 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
6631 (setq nlast (if (atom (car (cdr read)))
6633 (car (car (cdr read)))))
6634 (setq read (cdr read)))))
6635 ;; And add the last unread articles.
6636 (while (<= first last)
6637 (setq unread (cons first unread))
6638 (setq first (1+ first)))
6639 ;; Return the list of unread articles.
6643 ;; Various summary commands
6645 (defun gnus-summary-universal-argument ()
6646 "Perform any operation on all articles marked with the process mark."
6648 (gnus-set-global-variables)
6649 (let ((articles (reverse gnus-newsgroup-processable))
6651 (or articles (error "No articles marked"))
6652 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
6653 (error "Undefined key"))
6655 (gnus-summary-goto-subject (car articles))
6656 (command-execute func)
6657 (gnus-summary-remove-process-mark (car articles))
6658 (setq articles (cdr articles)))))
6660 (defun gnus-summary-toggle-truncation (arg)
6661 "Toggle truncation of summary lines.
6662 With arg, turn line truncation on iff arg is positive."
6664 (setq truncate-lines
6665 (if (null arg) (not truncate-lines)
6666 (> (prefix-numeric-value arg) 0)))
6669 (defun gnus-summary-reselect-current-group (all)
6670 "Once exit and then reselect the current newsgroup.
6671 The prefix argument ALL means to select all articles."
6673 (gnus-set-global-variables)
6674 (let ((current-subject (gnus-summary-article-number)))
6675 (gnus-summary-exit t)
6676 ;; We have to adjust the point of group mode buffer because the
6677 ;; current point was moved to the next unread newsgroup by
6679 (gnus-summary-jump-to-group gnus-newsgroup-name)
6680 (gnus-group-read-group all t)
6681 (gnus-summary-goto-subject current-subject)))
6683 (defun gnus-summary-rescan-group (all)
6684 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6686 (gnus-set-global-variables)
6687 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
6688 (let ((group gnus-newsgroup-name))
6689 (gnus-summary-exit t)
6690 (gnus-summary-jump-to-group group)
6692 (set-buffer gnus-group-buffer)
6693 (gnus-group-get-new-news-this-group 1))
6694 (gnus-summary-jump-to-group group)
6695 (gnus-group-read-group all)))
6697 (defun gnus-summary-exit (&optional temporary)
6698 "Exit reading current newsgroup, and then return to group selection mode.
6699 gnus-exit-group-hook is called with no arguments if that value is non-nil."
6701 (gnus-set-global-variables)
6702 (gnus-kill-save-kill-buffer)
6703 (let* ((group gnus-newsgroup-name)
6704 (quit-buffer (cdr (assoc 'quit-buffer (gnus-find-method-for-group
6705 gnus-newsgroup-name))))
6707 (method (car (gnus-find-method-for-group group)))
6708 (buf (current-buffer)))
6709 (if gnus-newsgroup-kill-headers
6710 (setq gnus-newsgroup-killed
6711 (gnus-compress-sequence
6713 (gnus-set-sorted-intersection
6714 (gnus-uncompress-range gnus-newsgroup-killed)
6715 (setq gnus-newsgroup-unselected
6716 (sort gnus-newsgroup-unselected '<)))
6717 (setq gnus-newsgroup-unreads
6718 (sort gnus-newsgroup-unreads '<))) t)))
6719 (or (listp (cdr gnus-newsgroup-killed))
6720 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6722 (headers gnus-newsgroup-headers))
6723 (gnus-close-group group)
6724 (run-hooks 'gnus-exit-group-hook)
6726 (gnus-update-read-articles
6727 group gnus-newsgroup-unreads gnus-newsgroup-unselected
6728 gnus-newsgroup-marked
6729 t gnus-newsgroup-replied gnus-newsgroup-expirable
6730 gnus-newsgroup-killed gnus-newsgroup-dormant
6731 gnus-newsgroup-bookmarks
6732 (and gnus-save-score gnus-newsgroup-scored))
6733 (and gnus-use-cross-reference
6734 (gnus-mark-xrefs-as-read
6735 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
6736 ;; Do not switch windows but change the buffer to work.
6737 (set-buffer gnus-group-buffer)
6738 (or (eq 'nndigest method)
6739 (gnus-group-update-group group)))
6740 ;; Make sure where I was, and go to next newsgroup.
6741 (if (eq method 'nndigest)
6743 (gnus-group-jump-to-group group)
6744 (gnus-group-next-unread-group 1))
6746 ;; If exiting temporary, caller should adjust group mode
6747 ;; buffer point by itself.
6749 ;; We set all buffer-local variables to nil. It is unclear why
6750 ;; this is needed, but if we don't, buffer-local variables are
6751 ;; not garbage-collected, it seems. This would the lead to en
6752 ;; ever-growing Emacs.
6754 (gnus-summary-clear-local-variables)
6755 ;; We clear the global counterparts of the buffer-local
6756 ;; variables as well, just to be on the safe side.
6757 (set-buffer gnus-group-buffer)
6758 (gnus-summary-clear-local-variables)
6759 (gnus-configure-windows 'newsgroups t)
6760 ;; Return to group mode buffer.
6761 (and (get-buffer buf)
6762 (eq mode 'gnus-summary-mode)
6764 (if (get-buffer gnus-article-buffer)
6765 (bury-buffer gnus-article-buffer))
6766 (setq gnus-current-select-method gnus-select-method)
6767 (pop-to-buffer gnus-group-buffer)
6768 (if (and quit-buffer (buffer-name quit-buffer))
6770 (switch-to-buffer quit-buffer)
6771 (gnus-set-global-variables)
6772 (gnus-configure-windows 'summary))))))
6774 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6775 (defun gnus-summary-exit-no-update (&optional no-questions)
6776 "Quit reading current newsgroup without updating read article info."
6778 (let* ((group gnus-newsgroup-name)
6779 (quit-buffer (cdr (assoc 'quit-buffer
6780 (gnus-find-method-for-group group)))))
6781 (if (or no-questions
6783 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
6785 (gnus-close-group group)
6786 (gnus-summary-clear-local-variables)
6787 (set-buffer gnus-group-buffer)
6788 (gnus-summary-clear-local-variables)
6789 ;; Return to group selection mode.
6790 (gnus-configure-windows 'newsgroups)
6791 (if (get-buffer gnus-summary-buffer)
6792 (kill-buffer gnus-summary-buffer))
6793 (if (get-buffer gnus-article-buffer)
6794 (bury-buffer gnus-article-buffer))
6795 (pop-to-buffer gnus-group-buffer)
6796 (gnus-group-jump-to-group group)
6797 (gnus-group-next-group 1)
6798 (if (and quit-buffer (buffer-name quit-buffer))
6800 (switch-to-buffer quit-buffer)
6801 (gnus-configure-windows 'summary)))))))
6803 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6804 (defun gnus-summary-fetch-faq (group)
6805 "Fetch the FAQ for the current group."
6806 (interactive (list gnus-newsgroup-name))
6807 (gnus-configure-windows 'article)
6808 (pop-to-buffer gnus-article-buffer)
6809 (find-file (concat gnus-group-faq-directory group)))
6811 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6812 (defun gnus-summary-describe-group (force)
6813 "Describe the current newsgroup."
6815 (gnus-group-describe-group force gnus-newsgroup-name))
6817 (defun gnus-summary-describe-briefly ()
6818 "Describe summary mode commands briefly."
6821 (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")))
6823 ;; Walking around group mode buffer from summary mode.
6825 (defun gnus-summary-next-group (&optional no-article group backward)
6826 "Exit current newsgroup and then select next unread newsgroup.
6827 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
6828 If BACKWARD, go to previous group instead."
6830 (gnus-set-global-variables)
6831 (let ((ingroup gnus-newsgroup-name)
6832 (sumbuf (current-buffer))
6834 (gnus-summary-exit t) ;Update all information.
6836 (or (and (numberp (setq num (car (gnus-gethash
6837 group gnus-newsrc-hashtb))))
6841 (gnus-group-jump-to-group group)
6843 (gnus-group-jump-to-group ingroup))
6844 (let ((group (or group (gnus-summary-search-group backward)))
6845 (buf gnus-summary-buffer))
6847 (gnus-summary-exit-no-update t)
6848 (message "Selecting %s..." group)
6849 ;; We are now in group mode buffer.
6850 ;; Make sure group mode buffer point is on GROUP.
6851 (gnus-group-jump-to-group group)
6853 (gnus-summary-read-group group nil no-article buf)
6854 (and (string= gnus-newsgroup-name ingroup)
6855 (bufferp sumbuf) (buffer-name sumbuf)
6857 (set-buffer (setq gnus-summary-buffer sumbuf))
6858 (gnus-summary-exit-no-update t))))))))
6860 (defun gnus-summary-prev-group (no-article)
6861 "Exit current newsgroup and then select previous unread newsgroup.
6862 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6864 (gnus-summary-next-group no-article nil t))
6866 ;; Walking around summary lines.
6868 (defun gnus-summary-first-subject (unread)
6869 "Go to the first unread subject.
6870 If UNREAD is non-nil, go to the first unread article.
6871 Returns nil if there are no unread articles."
6873 (let ((begin (point)))
6875 (if (not (gnus-goto-char
6876 (text-property-any (point-min) (point-max)
6877 'gnus-mark gnus-unread-mark)))
6879 ;; If there is no unread articles, stay where you are.
6881 (message "No more unread articles")
6884 (goto-char (point-min)))))
6886 (defun gnus-summary-next-subject (n &optional unread)
6887 "Go to next N'th summary line.
6888 If N is negative, go to the previous N'th subject line.
6889 If UNREAD is non-nil, only unread articles are selected.
6890 The difference between N and the actual number of steps taken is
6893 (let ((backward (< n 0))
6896 (gnus-summary-search-forward unread nil backward))
6898 (gnus-summary-recenter)
6899 (if (/= 0 n) (message "No more%s articles" (if unread " unread" "")))
6900 (gnus-summary-position-cursor)
6903 (defun gnus-summary-next-unread-subject (n)
6904 "Go to next N'th unread summary line."
6906 (gnus-summary-next-subject n t))
6908 (defun gnus-summary-prev-subject (n &optional unread)
6909 "Go to previous N'th summary line.
6910 If optional argument UNREAD is non-nil, only unread article is selected."
6912 (gnus-summary-next-subject (- n) unread))
6914 (defun gnus-summary-prev-unread-subject (n)
6915 "Go to previous N'th unread summary line."
6917 (gnus-summary-next-subject (- n) t))
6919 (defun gnus-summary-goto-subject (article)
6920 "Go the subject line of ARTICLE."
6924 (completing-read "Article number: "
6928 (int-to-string (header-number headers))))
6929 gnus-newsgroup-headers)
6930 nil 'require-match))))
6931 (or article (error "No article number"))
6932 (if (or (eq article (gnus-summary-article-number t))
6935 (point-min) (point-max) 'gnus-number article)))
6938 ;; Walking around summary lines with displaying articles.
6940 (defun gnus-summary-expand-window ()
6941 "Expand summary window to show headers full window."
6943 (gnus-set-global-variables)
6944 (gnus-configure-windows 'summary)
6945 (pop-to-buffer gnus-summary-buffer))
6947 (defun gnus-summary-display-article (article &optional all-header)
6948 "Display ARTICLE in article buffer."
6949 (gnus-set-global-variables)
6952 (gnus-article-prepare article all-header)
6953 (if (eq (gnus-summary-article-mark) ?Z)
6956 (gnus-summary-position-cursor)))
6957 (run-hooks 'gnus-select-article-hook)
6958 (gnus-summary-recenter)
6959 ; (set-window-point (get-buffer-window (current-buffer)) (point-max))
6961 (gnus-summary-goto-subject article)
6962 ;; Successfully display article.
6963 (gnus-summary-update-line)
6966 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6967 "Select the current article.
6968 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6969 non-nil, the article will be re-fetched even if it already present in
6970 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6972 (and (not pseudo) (gnus-summary-pseudo-article)
6973 (error "This is a pseudo-article."))
6974 (let ((article (or article (gnus-summary-article-number)))
6975 (all-headers (not (not all-headers)))) ;Must be T or NIL.
6976 (if (or (null gnus-current-article)
6977 (null gnus-article-current)
6978 (/= article (cdr gnus-article-current))
6979 (not (equal (car gnus-article-current) gnus-newsgroup-name))
6981 ;; The requested article is different from the current article.
6983 (gnus-summary-display-article article all-headers)
6985 (if all-headers (gnus-article-show-all-headers))
6986 (gnus-configure-windows 'article)
6987 (pop-to-buffer gnus-summary-buffer)
6990 (defun gnus-summary-set-current-mark (&optional current-mark)
6991 "Obsolete function."
6994 (defun gnus-summary-next-article (unread &optional subject backward)
6995 "Select the next article.
6996 If UNREAD, only unread articles are selected.
6997 If SUBJECT, only articles with SUBJECT are selected.
6998 If BACKWARD, the previous article is selected instead of the next."
7000 (let ((opoint (point))
7001 (method (car (gnus-find-method-for-group gnus-newsgroup-name)))
7004 ;; Is there such an article?
7005 ((gnus-summary-display-article
7006 (gnus-summary-search-forward unread subject backward))
7007 (gnus-summary-position-cursor))
7008 ;; If not, we try the first unread, if that is wanted.
7010 gnus-auto-select-same
7011 (gnus-summary-first-unread-article))
7012 (message "Wrapped"))
7013 ;; Try to get next/previous article not displayed in this group.
7014 ((and gnus-auto-extend-newsgroup
7015 (not unread) (not subject)
7016 (setq header (gnus-more-header-forward backward)))
7017 (gnus-extend-newsgroup header backward)
7018 (let ((buffer-read-only nil))
7019 (goto-char (if backward (point-min) (point-max)))
7020 (gnus-summary-prepare-threads (list header) 0))
7021 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
7022 gnus-newsgroup-end)))
7023 ;; Go to next/previous group.
7025 (gnus-summary-jump-to-group gnus-newsgroup-name)
7026 (let ((cmd (aref (this-command-keys) 0))
7028 (if (eq gnus-keep-same-level 'best)
7029 (gnus-summary-best-group gnus-newsgroup-name)
7030 (gnus-summary-search-group backward gnus-keep-same-level))))
7031 ;; Keep just the event type of CMD.
7032 (and (listp cmd) (setq cmd (car cmd)))
7033 ;; Select next unread newsgroup automagically.
7035 ((not gnus-auto-select-next)
7036 (message "No more%s articles" (if unread " unread" "")))
7037 ((eq gnus-auto-select-next 'quietly)
7039 (if (eq method 'nndigest)
7041 (message "No more%s articles (%s)..."
7042 (if unread " unread" "")
7043 (if group (concat "selecting " group)
7045 (gnus-summary-next-group nil group backward)))
7047 (let ((keystrokes '(?\C-n ?\C-p))
7049 (while (or (null key) (memq key keystrokes))
7051 "No more%s articles%s" (if unread " unread" "")
7052 (if (and group (not (eq method 'nndigest)))
7053 (format " (Type %s for %s [%s])"
7054 (single-key-description cmd) group
7055 (car (gnus-gethash group gnus-newsrc-hashtb)))
7056 (format " (Type %s to exit %s)"
7057 (single-key-description cmd)
7058 gnus-newsgroup-name)))
7059 ;; Confirm auto selection.
7060 (let* ((event (read-event)))
7061 (setq key (if (listp event) (car event) event))
7062 (if (member key keystrokes)
7063 (let ((obuf (current-buffer)))
7064 (switch-to-buffer gnus-group-buffer)
7065 (gnus-group-jump-to-group group)
7066 (execute-kbd-macro (char-to-string key))
7067 (setq group (gnus-group-group-name))
7068 (switch-to-buffer obuf)))))
7070 (if (or (not group) (eq method 'nndigest))
7072 (gnus-summary-next-group nil group backward))
7073 (setq unread-command-events (list key)))))))))))
7075 (defun gnus-summary-next-unread-article ()
7076 "Select unread article after current one."
7078 (gnus-summary-next-article t (and gnus-auto-select-same
7079 (gnus-summary-subject-string))))
7081 (defun gnus-summary-prev-article (unread &optional subject)
7082 "Select the article after the current one.
7083 If UNREAD is non-nil, only unread articles are selected."
7085 (gnus-summary-next-article unread subject t))
7087 (defun gnus-summary-prev-unread-article ()
7088 "Select unred article before current one."
7090 (gnus-summary-prev-article t (and gnus-auto-select-same
7091 (gnus-summary-subject-string))))
7093 (defun gnus-summary-next-page (lines &optional circular)
7094 "Show next page of selected article.
7095 If end of article, select next article.
7096 Argument LINES specifies lines to be scrolled up.
7097 If CIRCULAR is non-nil, go to the start of the article instead of
7098 instead of selecting the next article when reaching the end of the
7101 (setq gnus-summary-buffer (current-buffer))
7102 (gnus-set-global-variables)
7103 (let ((article (gnus-summary-article-number))
7105 (if (or (null gnus-current-article)
7106 (null gnus-article-current)
7107 (/= article (cdr gnus-article-current))
7108 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7109 ;; Selected subject is different from current article's.
7110 (gnus-summary-display-article article)
7111 (gnus-configure-windows 'article)
7112 (gnus-eval-in-buffer-window
7114 (setq endp (gnus-article-next-page lines)))
7115 (pop-to-buffer gnus-summary-buffer)
7118 (gnus-summary-beginning-of-article))
7120 (message "End of message"))
7122 (gnus-summary-next-unread-article))))
7123 (pop-to-buffer gnus-summary-buffer)))
7124 (gnus-summary-position-cursor))
7126 (defun gnus-summary-prev-page (lines)
7127 "Show previous page of selected article.
7128 Argument LINES specifies lines to be scrolled down."
7130 (let ((article (gnus-summary-article-number)))
7131 (if (or (null gnus-current-article)
7132 (null gnus-article-current)
7133 (/= article (cdr gnus-article-current))
7134 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7135 ;; Selected subject is different from current article's.
7136 (gnus-summary-display-article article)
7137 (gnus-configure-windows 'article)
7138 (pop-to-buffer gnus-summary-buffer)
7139 (gnus-eval-in-buffer-window gnus-article-buffer
7140 (gnus-article-prev-page lines))))
7141 (gnus-summary-position-cursor))
7143 (defun gnus-summary-scroll-up (lines)
7144 "Scroll up (or down) one line current article.
7145 Argument LINES specifies lines to be scrolled up (or down if negative)."
7147 (or (gnus-summary-select-article nil nil 'pseudo)
7148 (gnus-eval-in-buffer-window
7151 (if (gnus-article-next-page lines)
7152 (message "End of message")))
7154 (gnus-article-prev-page (- lines))))))
7155 (gnus-summary-position-cursor))
7157 (defun gnus-summary-next-same-subject ()
7158 "Select next article which has the same subject as current one."
7160 (gnus-summary-next-article nil (gnus-summary-subject-string)))
7162 (defun gnus-summary-prev-same-subject ()
7163 "Select previous article which has the same subject as current one."
7165 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
7167 (defun gnus-summary-next-unread-same-subject ()
7168 "Select next unread article which has the same subject as current one."
7170 (gnus-summary-next-article t (gnus-summary-subject-string)))
7172 (defun gnus-summary-prev-unread-same-subject ()
7173 "Select previous unread article which has the same subject as current one."
7175 (gnus-summary-prev-article t (gnus-summary-subject-string)))
7177 (defun gnus-summary-first-unread-article ()
7178 "Select the first unread article.
7179 Return nil if there are no unread articles."
7182 (if (gnus-summary-first-subject t)
7183 (gnus-summary-display-article (gnus-summary-article-number)))
7184 (gnus-summary-position-cursor)))
7186 (defun gnus-summary-best-unread-article ()
7187 "Select the unread article with the highest score."
7189 (gnus-set-global-variables)
7190 (let ((scored gnus-newsgroup-scored)
7194 (or (> best (cdr (car scored)))
7195 (and (memq (setq art (car (car scored))) gnus-newsgroup-unreads)
7196 (not (memq art gnus-newsgroup-marked))
7197 (not (memq art gnus-newsgroup-dormant))
7198 (if (= best (cdr (car scored)))
7199 (setq article (min art article))
7201 (setq best (cdr (car scored))))))
7202 (setq scored (cdr scored)))
7204 (gnus-summary-goto-article article)
7205 (gnus-summary-first-unread-article))
7206 (gnus-summary-position-cursor)))
7208 (defun gnus-summary-goto-article (article &optional all-headers)
7209 "Fetch ARTICLE and display it if it exists.
7210 If ALL-HEADERS is non-nil, no header lines are hidden."
7216 (mapcar (lambda (headers) (list (int-to-string (header-number headers))))
7217 gnus-newsgroup-headers)
7218 nil 'require-match))))
7219 (if (gnus-summary-goto-subject article)
7220 (gnus-summary-display-article article all-headers))
7221 (gnus-summary-position-cursor))
7223 (defun gnus-summary-goto-last-article ()
7224 "Go to the last article."
7226 (if gnus-last-article
7227 (gnus-summary-goto-article gnus-last-article))
7228 (gnus-summary-position-cursor))
7230 (defun gnus-summary-pop-article (number)
7231 "Pop one article off the history and go to the previous.
7232 NUMBER articles will be popped off."
7235 (setq gnus-newsgroup-history
7236 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7238 (gnus-summary-goto-article (car to))
7239 (error "Article history empty")))
7240 (gnus-summary-position-cursor))
7242 ;; Summary article oriented commands
7244 (defun gnus-summary-refer-parent-article (n)
7245 "Refer parent article N times.
7246 The difference between N and the number of articles fetched is returned."
7248 (gnus-set-global-variables)
7252 (let ((ref (header-references (gnus-get-header-by-number
7253 (gnus-summary-article-number)))))
7254 (if (and ref (not (equal ref ""))
7255 (string-match "<[^<>]*>[ \t]*$" ref))
7256 (gnus-summary-refer-article
7257 (substring ref (match-beginning 0) (match-end 0))))))
7259 (or (zerop n) (message "No references in article or expired article."))
7260 (gnus-summary-position-cursor)
7263 (defun gnus-summary-refer-article (message-id)
7264 "Refer article specified by MESSAGE-ID.
7265 NOTE: This command only works with newsgroup that use NNTP."
7266 (interactive "sMessage-ID: ")
7267 (if (or (not (stringp message-id))
7268 (zerop (length message-id)))
7270 ;; Construct the correct Message-ID if necessary.
7271 ;; Suggested by tale@pawl.rpi.edu.
7272 (or (string-match "^<" message-id)
7273 (setq message-id (concat "<" message-id)))
7274 (or (string-match ">$" message-id)
7275 (setq message-id (concat message-id ">")))
7276 (let ((header (car (gnus-gethash (downcase message-id)
7277 gnus-newsgroup-dependencies))))
7279 (gnus-summary-goto-article (header-number header))
7280 (let ((gnus-override-method gnus-refer-article-method))
7281 (if (gnus-article-prepare
7282 message-id nil (gnus-read-header message-id))
7284 (gnus-summary-insert-line
7285 nil gnus-current-headers 0 nil gnus-read-mark nil nil
7286 (header-subject gnus-current-headers))
7288 (gnus-summary-position-cursor)
7289 (gnus-summary-update-line)
7291 (message "No such references")
7294 (defun gnus-summary-enter-digest-group ()
7295 "Enter a digest group based on the current article."
7297 (gnus-summary-select-article)
7298 (let ((name (format "%s/%d"
7299 (gnus-group-prefixed-name
7300 gnus-newsgroup-name (list 'nndigest ""))
7301 gnus-current-article))
7302 (buf (current-buffer)))
7303 (set-buffer gnus-group-buffer)
7306 (list t nil (list name gnus-level-default-subscribed nil nil
7307 (list 'nndigest gnus-article-buffer
7308 (cons 'quit-buffer buf))))
7310 (gnus-group-read-group t nil name)))
7312 (defun gnus-summary-isearch-article ()
7313 "Do incremental search forward on current article."
7315 (gnus-summary-select-article)
7316 (gnus-eval-in-buffer-window gnus-article-buffer
7319 (defun gnus-summary-search-article-forward (regexp)
7320 "Search for an article containing REGEXP forward.
7321 gnus-select-article-hook is not called during the search."
7324 (concat "Search forward (regexp): "
7325 (if gnus-last-search-regexp
7326 (concat "(default " gnus-last-search-regexp ") "))))))
7327 (if (string-equal regexp "")
7328 (setq regexp (or gnus-last-search-regexp ""))
7329 (setq gnus-last-search-regexp regexp))
7330 (if (gnus-summary-search-article regexp nil)
7331 (gnus-eval-in-buffer-window
7334 (error "Search failed: \"%s\"" regexp)))
7336 (defun gnus-summary-search-article-backward (regexp)
7337 "Search for an article containing REGEXP backward.
7338 gnus-select-article-hook is not called during the search."
7341 (concat "Search backward (regexp): "
7342 (if gnus-last-search-regexp
7343 (concat "(default " gnus-last-search-regexp ") "))))))
7344 (if (string-equal regexp "")
7345 (setq regexp (or gnus-last-search-regexp ""))
7346 (setq gnus-last-search-regexp regexp))
7347 (if (gnus-summary-search-article regexp t)
7348 (gnus-eval-in-buffer-window
7351 (error "Search failed: \"%s\"" regexp)))
7353 (defun gnus-summary-search-article (regexp &optional backward)
7354 "Search for an article containing REGEXP.
7355 Optional argument BACKWARD means do search for backward.
7356 gnus-select-article-hook is not called during the search."
7357 (let ((gnus-select-article-hook nil) ;Disable hook.
7358 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7361 (function re-search-backward) (function re-search-forward)))
7364 ;; Hidden thread subtrees must be searched for ,too.
7365 (gnus-summary-show-all-threads)
7366 (if (eobp) (forward-line -1))
7367 ;; First of all, search current article.
7368 ;; We don't want to read article again from NNTP server nor reset
7370 (gnus-summary-select-article)
7371 (message "Searching article: %d..." gnus-current-article)
7372 (setq last gnus-current-article)
7373 (gnus-eval-in-buffer-window gnus-article-buffer
7376 ;; Begin search from current point.
7377 (setq found (funcall re-search regexp nil t))))
7378 ;; Then search next articles.
7379 (while (and (not found)
7380 (gnus-summary-display-article
7381 (gnus-summary-search-subject backward nil nil)))
7382 (message "Searching article: %d..." gnus-current-article)
7383 (gnus-eval-in-buffer-window gnus-article-buffer
7386 (goto-char (if backward (point-max) (point-min)))
7387 (setq found (funcall re-search regexp nil t)))))
7389 ;; Adjust article pointer.
7390 (or (eq last gnus-current-article)
7391 (setq gnus-last-article last))
7392 ;; Return T if found such article.
7395 (defun gnus-summary-execute-command (header regexp command &optional backward)
7396 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7397 If HEADER is an empty string (or nil), the match is done on the entire
7398 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7400 (list (let ((completion-ignore-case t))
7403 (mapcar (string) (list string)
7404 '("Number" "Subject" "From" "Lines" "Date"
7405 "Message-ID" "Xref" "References")
7406 nil 'require-match)))
7407 (read-string "Regexp: ")
7408 (read-key-sequence "Command: ")
7409 current-prefix-arg))
7410 ;; Hidden thread subtrees must be searched as well.
7411 (gnus-summary-show-all-threads)
7412 ;; We don't want to change current point nor window configuration.
7414 (save-window-excursion
7415 (message "Executing %s..." (key-description command))
7416 ;; We'd like to execute COMMAND interactively so as to give arguments.
7417 (gnus-execute header regexp
7419 (call-interactively '(, (key-binding command)))))
7421 (message "Executing %s... done" (key-description command)))))
7423 (defun gnus-summary-beginning-of-article ()
7424 "Scroll the article back to the beginning."
7426 (gnus-summary-select-article)
7427 (gnus-eval-in-buffer-window
7430 (goto-char (point-min))
7431 (and gnus-break-pages (gnus-narrow-to-page))))
7433 (defun gnus-summary-end-of-article ()
7434 "Scroll to the end of the article."
7436 (gnus-summary-select-article)
7437 (gnus-eval-in-buffer-window
7440 (goto-char (point-max))
7441 (and gnus-break-pages (gnus-narrow-to-page))))
7443 (defun gnus-summary-show-article ()
7444 "Force re-fetching of the current article."
7446 (gnus-summary-select-article gnus-have-all-headers t t))
7448 (defun gnus-summary-toggle-header (arg)
7449 "Show the headers if they are hidden, or hide them if they are shown.
7450 If ARG is a positive number, show the entire header.
7451 If ARG is a negative number, hide the unwanted header lines."
7453 (gnus-set-global-variables)
7455 (set-buffer gnus-article-buffer)
7456 (let ((buffer-read-only nil))
7458 (if (> arg 0) (remove-text-properties 1 (point-max) '(invisible t))
7459 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
7460 (if (text-property-any 1 (point-max) 'invisible t)
7461 (remove-text-properties 1 (point-max) '(invisible t))
7462 (let ((gnus-have-all-headers nil))
7463 (run-hooks 'gnus-article-display-hook))))
7464 (set-window-point (get-buffer-window (current-buffer)) 1))))
7466 (defun gnus-summary-show-all-headers ()
7467 "Make all header lines visible."
7469 (gnus-article-show-all-headers))
7471 (defun gnus-summary-toggle-mime (arg)
7472 "Toggle MIME processing.
7473 If ARG is a positive number, turn MIME processing on."
7475 (setq gnus-show-mime
7476 (if (null arg) (not gnus-show-mime)
7477 (> (prefix-numeric-value arg) 0)))
7478 (gnus-summary-select-article t 'force))
7480 (defun gnus-summary-caesar-message (rotnum)
7481 "Caesar rotates all letters of current message by 13/47 places.
7482 With prefix arg, specifies the number of places to rotate each letter forward.
7483 Caesar rotates Japanese letters by 47 places in any case."
7485 (gnus-summary-select-article)
7486 (let ((mail-header-separator "")) ; !!! Is this necessary?
7487 (gnus-overload-functions)
7488 (gnus-eval-in-buffer-window
7492 ;; We don't want to jump to the beginning of the message.
7493 ;; `save-excursion' does not do its job.
7494 (move-to-window-line 0)
7495 (let ((last (point)))
7496 (news-caesar-buffer-body rotnum)
7500 (defun gnus-summary-stop-page-breaking ()
7501 "Stop page breaking in the current article."
7503 (gnus-summary-select-article)
7504 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
7506 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
7508 (defun gnus-summary-move-article (n &optional to-newsgroup select-method)
7509 "Move the current article to a different newsgroup.
7510 If N is a positive number, move the N next articles.
7511 If N is a negative number, move the N previous articles.
7512 If N is nil and any articles have been marked with the process mark,
7513 move those articles instead.
7514 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7515 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
7516 re-spool using this method.
7517 For this function to work, both the current newsgroup and the
7518 newsgroup that you want to move to have to support the `request-move'
7519 and `request-accept' functions. (Ie. mail newsgroups at present.)"
7521 (gnus-set-global-variables)
7522 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
7523 (error "The current newsgroup does not support article moving"))
7524 (let ((articles (gnus-summary-work-articles n))
7525 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7527 (if (and (not to-newsgroup) (not select-method))
7530 (format "Where do you want to move %s? %s"
7531 (if (> (length articles) 1)
7532 (format "these %d articles" (length articles))
7534 (if gnus-current-move-group
7535 (format "(%s default) " gnus-current-move-group)
7537 gnus-active-hashtb nil nil prefix)))
7540 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
7541 (setq to-newsgroup (or gnus-current-move-group "")))
7542 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
7543 (error "No such group: %s" to-newsgroup))
7544 (setq gnus-current-move-group to-newsgroup)))
7545 (or (gnus-check-backend-function 'request-accept-article
7546 (or select-method to-newsgroup))
7547 (error "%s does not support article moving" to-newsgroup))
7548 (message "Moving to %s: %s..." (or select-method to-newsgroup) articles)
7551 (gnus-request-move-article
7552 (car articles) ; Article to move
7553 gnus-newsgroup-name ; From newsgrouo
7554 (nth 1 (gnus-find-method-for-group
7555 gnus-newsgroup-name)) ; Server
7556 (list 'gnus-request-accept-article
7558 (quote select-method)
7560 (not (cdr articles))) ; Accept form
7561 (not (cdr articles)))) ; Only save nov last time
7562 (let* ((buffer-read-only nil)
7565 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7567 (gnus-group-prefixed-name
7569 (if select-method (list select-method "")
7570 (gnus-find-method-for-group to-newsgroup)))
7571 gnus-newsrc-hashtb)))
7572 (info (nth 2 entry))
7573 (article (car articles))
7574 (marked (nth 3 info)))
7575 (gnus-summary-goto-subject article)
7577 (delete-region (point)
7578 (progn (forward-line 1) (point)))
7579 (if (not (memq article gnus-newsgroup-unreads))
7580 (setcar (cdr (cdr info))
7581 (gnus-add-to-range (nth 2 info)
7582 (list (cdr art-group)))))
7583 ;; Copy any marks over to the new group.
7584 (let ((marks '((tick . gnus-newsgroup-marked)
7585 (dormant . gnus-newsgroup-dormant)
7586 (expire . gnus-newsgroup-expirable)
7587 (bookmark . gnus-newsgroup-bookmarks)
7588 ; (score . gnus-newsgroup-scored)
7589 (reply . gnus-newsgroup-replied)))
7590 (to-article (cdr art-group)))
7592 (if (memq article (symbol-value (cdr (car marks))))
7593 (gnus-add-marked-articles
7594 (car info) (car (car marks)) (list to-article) info))
7595 (setq marks (cdr marks))))
7596 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7597 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7598 (setq gnus-newsgroup-dormant
7599 (delq article gnus-newsgroup-dormant)))
7600 (message "Couldn't move article %s" (car articles)))
7601 (gnus-summary-remove-process-mark (car articles))
7602 (setq articles (cdr articles)))))
7604 (defun gnus-summary-respool-article (n &optional respool-method)
7605 "Respool the current article.
7606 The article will be squeezed through the mail spooling process again,
7607 which means that it will be put in some mail newsgroup or other
7608 depending on `nnmail-split-methods'.
7609 If N is a positive number, respool the N next articles.
7610 If N is a negative number, respool the N previous articles.
7611 If N is nil and any articles have been marked with the process mark,
7612 respool those articles instead.
7614 Respooling can be done both from mail groups and \"real\" newsgroups.
7615 In the former case, the articles in question will be moved from the
7616 current group into whatever groups they are destined to. In the
7617 latter case, they will be copied into the relevant groups."
7619 (gnus-set-global-variables)
7620 (let ((respool-methods (gnus-methods-using 'respool)))
7622 (setq respool-method
7624 "What method do you want to use when respooling? "
7625 respool-methods nil t)))
7626 (if (assoc (symbol-name
7627 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7629 (gnus-summary-move-article n nil (intern respool-method)))
7630 (gnus-summary-copy-article n nil (intern respool-method))))
7632 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
7633 (defun gnus-summary-copy-article (n &optional to-newsgroup select-method)
7634 "Move the current article to a different newsgroup.
7635 If N is a positive number, move the N next articles.
7636 If N is a negative number, move the N previous articles.
7637 If N is nil and any articles have been marked with the process mark,
7638 move those articles instead.
7639 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7640 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
7641 re-spool using this method.
7642 For this function to work, the newsgroup that you want to move to have
7643 to support the `request-move' and `request-accept'
7644 functions. (Ie. mail newsgroups at present.)"
7646 (gnus-set-global-variables)
7647 (let ((articles (gnus-summary-work-articles n))
7648 (copy-buf (get-buffer-create "*copy work*"))
7649 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7651 (buffer-disable-undo copy-buf)
7652 (if (and (not to-newsgroup) (not select-method))
7655 (format "Where do you want to copy %s? %s"
7656 (if (> (length articles) 1)
7657 (format "these %d articles" (length articles))
7659 (if gnus-current-move-group
7660 (format "(%s default) " gnus-current-move-group)
7662 gnus-active-hashtb nil nil prefix)))
7665 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
7666 (setq to-newsgroup (or gnus-current-move-group "")))
7667 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
7668 (error "No such group: %s" to-newsgroup))
7669 (setq gnus-current-move-group to-newsgroup)))
7670 (or (gnus-check-backend-function 'request-accept-article
7671 (or select-method to-newsgroup))
7672 (error "%s does not support article copying" to-newsgroup))
7673 (message "Copying to %s: %s..." (or select-method to-newsgroup) articles)
7677 (set-buffer copy-buf)
7678 (gnus-request-article-this-buffer
7679 (car articles) gnus-newsgroup-name)
7680 (gnus-request-accept-article
7681 (if select-method (quote select-method) to-newsgroup)
7682 (not (cdr articles)))))
7685 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7687 (gnus-group-prefixed-name
7689 (if select-method (list select-method "")
7690 (gnus-find-method-for-group to-newsgroup)))
7691 gnus-newsrc-hashtb)))
7692 (info (nth 2 entry))
7693 (article (car articles))
7694 (marked (nth 3 info)))
7695 (if (not (memq article gnus-newsgroup-unreads))
7696 (setcar (cdr (cdr info))
7697 (gnus-add-to-range (nth 2 info)
7698 (list (cdr art-group)))))
7699 ;; Copy any marks over to the new group.
7700 (let ((marks '((tick . gnus-newsgroup-marked)
7701 (dormant . gnus-newsgroup-dormant)
7702 (expire . gnus-newsgroup-expirable)
7703 (bookmark . gnus-newsgroup-bookmarks)
7704 ; (score . gnus-newsgroup-scored)
7705 (reply . gnus-newsgroup-replied)))
7706 (to-article (cdr art-group)))
7708 (if (memq article (symbol-value (cdr (car marks))))
7709 (gnus-add-marked-articles
7710 (car info) (car (car marks)) (list to-article) info))
7711 (setq marks (cdr marks)))))
7712 (message "Couldn't copy article %s" (car articles)))
7713 (gnus-summary-remove-process-mark (car articles))
7714 (setq articles (cdr articles)))
7715 (kill-buffer copy-buf)))
7717 (defun gnus-summary-expire-articles ()
7718 "Expire all articles that are marked as expirable in the current group."
7720 (if (and gnus-newsgroup-expirable
7721 (gnus-check-backend-function
7722 'request-expire-articles gnus-newsgroup-name))
7723 (let ((expirable gnus-newsgroup-expirable))
7724 ;; The list of articles that weren't expired is returned.
7725 (setq gnus-newsgroup-expirable
7726 (gnus-request-expire-articles gnus-newsgroup-expirable
7727 gnus-newsgroup-name))
7728 ;; We go through the old list of expirable, and mark all
7729 ;; really expired articles as non-existant.
7731 (or (memq (car expirable) gnus-newsgroup-expirable)
7732 (gnus-summary-mark-as-read (car expirable) "%"))
7733 (setq expirable (cdr expirable))))))
7735 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7736 (defun gnus-summary-delete-article (n)
7737 "Delete the N next (mail) articles.
7738 This command actually deletes articles. This is not a marking
7739 command. The article will disappear forever from you life, never to
7741 If N is negative, delete backwards.
7742 If N is nil and articles have been marked with the process mark,
7743 delete these instead."
7745 (or (gnus-check-backend-function 'request-expire-articles
7746 gnus-newsgroup-name)
7747 (error "The current newsgroup does not support article deletion."))
7748 ;; Compute the list of articles to delete.
7749 (let ((articles (gnus-summary-work-articles n)))
7750 (if (and gnus-novice-user
7752 (format "Do you really want to delete %s forever? "
7753 (if (> (length articles) 1) "these articles"
7756 ;; Delete the articles.
7757 (setq gnus-newsgroup-expirable
7758 (gnus-request-expire-articles
7759 articles gnus-newsgroup-name 'force))
7761 (gnus-summary-remove-process-mark (car articles))
7762 ;; The backend might not have been able to delete the article
7764 (or (memq (car articles) gnus-newsgroup-expirable)
7765 (gnus-summary-mark-as-read (car articles) gnus-canceled-mark))
7766 (setq articles (cdr articles))))))
7768 (defun gnus-summary-edit-article ()
7769 "Enter into a buffer and edit the current article.
7770 This will have permanent effect only in mail groups."
7772 (or (gnus-check-backend-function
7773 'request-replace-article gnus-newsgroup-name)
7774 (error "The current newsgroup does not support article editing."))
7775 (gnus-summary-select-article t)
7777 (message "C-c C-c to end edits")
7778 (setq buffer-read-only nil)
7780 (use-local-map (copy-keymap (current-local-map)))
7781 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
7783 (search-forward "\n\n" nil t))
7785 (defun gnus-summary-edit-article-done ()
7786 "Make edits to the current article permanent."
7788 (if (not (gnus-request-replace-article
7789 (cdr gnus-article-current) (car gnus-article-current)
7791 (error "Couldn't replace article.")
7793 (use-local-map gnus-article-mode-map)
7794 (setq buffer-read-only t)
7795 (pop-to-buffer gnus-summary-buffer)))
7797 ;; Summary score commands.
7799 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
7801 (defun gnus-summary-raise-score (n)
7802 "Raise the score of the current article by N."
7804 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
7806 (defun gnus-summary-lower-score (n)
7807 "Lower the score of the current article by N."
7809 (gnus-summary-raise-score (- n)))
7811 (defun gnus-summary-set-score (n)
7812 "Set the score of the current article to N."
7814 ;; Skip dummy header line.
7816 (if (eq (gnus-summary-article-mark) ?Z)
7818 (let ((buffer-read-only nil))
7820 (gnus-summary-update-mark
7821 (if (= n (or gnus-summary-default-score 0)) ?
7822 (if (< n (or gnus-summary-default-score 0))
7823 gnus-score-below-mark gnus-score-over-mark)) 'score))
7824 (let* ((article (gnus-summary-article-number))
7825 (score (assq article gnus-newsgroup-scored)))
7826 (if score (setcdr score n)
7827 (setq gnus-newsgroup-scored
7828 (cons (cons article n) gnus-newsgroup-scored))))
7829 (gnus-summary-update-line)))
7831 ;; Summary marking commands.
7833 (defun gnus-summary-raise-same-subject-and-select (score)
7834 "Raise articles which has the same subject with SCORE and select the next."
7836 (let ((subject (gnus-summary-subject-string)))
7837 (gnus-summary-raise-score score)
7838 (while (gnus-summary-search-subject nil nil subject)
7839 (gnus-summary-raise-score score))
7840 (gnus-summary-next-article t)))
7842 (defun gnus-summary-raise-same-subject (score)
7843 "Raise articles which has the same subject with SCORE."
7845 (let ((subject (gnus-summary-subject-string)))
7846 (gnus-summary-raise-score score)
7847 (while (gnus-summary-search-subject nil nil subject)
7848 (gnus-summary-raise-score score))
7849 (gnus-summary-next-subject 1 t)))
7851 (defun gnus-summary-raise-thread (score)
7852 "Raise articles under current thread with SCORE."
7856 (let ((level (gnus-summary-thread-level)))
7857 (gnus-summary-raise-score score)
7858 (while (and (zerop (gnus-summary-next-subject 1))
7859 (> (gnus-summary-thread-level) level))
7860 (gnus-summary-raise-score score))
7862 (or (zerop (gnus-summary-next-subject 1 t))
7864 (gnus-summary-position-cursor)
7865 (gnus-set-mode-line 'summary))
7867 (defun gnus-summary-lower-same-subject-and-select (score)
7868 "Raise articles which has the same subject with SCORE and select the next."
7870 (gnus-summary-raise-same-subject-and-select (- score)))
7872 (defun gnus-summary-lower-same-subject (score)
7873 "Raise articles which has the same subject with SCORE."
7875 (gnus-summary-raise-same-subject (- score)))
7877 (defun gnus-summary-lower-thread (score)
7878 "Raise articles under current thread with SCORE."
7880 (gnus-summary-raise-thread (- score)))
7882 (defun gnus-summary-kill-same-subject-and-select (unmark)
7883 "Mark articles which has the same subject as read, and then select the next.
7884 If UNMARK is positive, remove any kind of mark.
7885 If UNMARK is negative, tick articles."
7888 (setq unmark (prefix-numeric-value unmark)))
7890 (gnus-summary-mark-same-subject
7891 (gnus-summary-subject-string) unmark)))
7892 ;; Select next unread article. If auto-select-same mode, should
7893 ;; select the first unread article.
7894 (gnus-summary-next-article t (and gnus-auto-select-same
7895 (gnus-summary-subject-string)))
7896 (message "%d articles are marked as %s"
7897 count (if unmark "unread" "read"))))
7899 (defun gnus-summary-kill-same-subject (unmark)
7900 "Mark articles which has the same subject as read.
7901 If UNMARK is positive, remove any kind of mark.
7902 If UNMARK is negative, tick articles."
7905 (setq unmark (prefix-numeric-value unmark)))
7907 (gnus-summary-mark-same-subject
7908 (gnus-summary-subject-string) unmark)))
7909 ;; If marked as read, go to next unread subject.
7911 ;; Go to next unread subject.
7912 (gnus-summary-next-subject 1 t))
7913 (message "%d articles are marked as %s"
7914 count (if unmark "unread" "read"))))
7916 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7917 "Mark articles with same SUBJECT as read, and return marked number.
7918 If optional argument UNMARK is positive, remove any kinds of marks.
7919 If optional argument UNMARK is negative, mark articles as unread instead."
7922 (cond ((null unmark)
7923 (gnus-summary-mark-as-read nil gnus-killed-mark))
7925 (gnus-summary-tick-article nil t))
7927 (gnus-summary-tick-article)))
7929 (gnus-summary-search-forward nil subject))
7930 (cond ((null unmark)
7931 (gnus-summary-mark-as-read nil gnus-killed-mark))
7933 (gnus-summary-tick-article nil t))
7935 (gnus-summary-tick-article)))
7936 (setq count (1+ count))))
7937 ;; Hide killed thread subtrees. Does not work properly always.
7938 ;;(and (null unmark)
7939 ;; gnus-thread-hide-killed
7940 ;; (gnus-summary-hide-thread))
7941 ;; Return number of articles marked as read.
7944 (defun gnus-summary-mark-as-processable (n &optional unmark)
7945 "Set the process mark on the next N articles.
7946 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7947 the process mark instead. The difference between N and the actual
7948 number of articles marked is returned."
7950 (let ((backward (< n 0))
7955 (gnus-summary-remove-process-mark (gnus-summary-article-number))
7956 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7957 (zerop (gnus-summary-next-subject (if backward -1 1))))
7959 (if (/= 0 n) (message "No more articles"))
7962 (defun gnus-summary-unmark-as-processable (n)
7963 "Remove the process mark from the next N articles.
7964 If N is negative, mark backward instead. The difference between N and
7965 the actual number of articles marked is returned."
7967 (gnus-summary-mark-as-processable n t))
7969 (defun gnus-summary-unmark-all-processable ()
7970 "Remove the process mark from all articles."
7973 (while gnus-newsgroup-processable
7974 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7975 (gnus-summary-position-cursor))
7977 (defun gnus-summary-mark-as-expirable (n)
7978 "Mark N articles forward as expirable.
7979 If N is negative, mark backward instead. The difference between N and
7980 the actual number of articles marked is returned."
7982 (gnus-summary-mark-forward n gnus-expirable-mark))
7984 (defun gnus-summary-mark-article-as-replied (article)
7985 "Mark ARTICLE replied and update the summary line."
7986 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
7987 (let ((buffer-read-only nil))
7988 (if (gnus-summary-goto-subject article)
7990 (gnus-summary-update-mark gnus-replied-mark 'replied)
7993 (defun gnus-summary-set-bookmark (article)
7994 "Set a bookmark in current article."
7995 (interactive (list (gnus-summary-article-number)))
7996 (if (or (not (get-buffer gnus-article-buffer))
7997 (not gnus-current-article)
7998 (not gnus-article-current)
7999 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8000 (error "No current article selected"))
8001 ;; Remove old bookmark, if one exists.
8002 (let ((old (assq article gnus-newsgroup-bookmarks)))
8003 (if old (setq gnus-newsgroup-bookmarks
8004 (delq old gnus-newsgroup-bookmarks))))
8005 ;; Set the new bookmark, which is on the form
8006 ;; (article-number . line-number-in-body).
8007 (setq gnus-newsgroup-bookmarks
8011 (set-buffer gnus-article-buffer)
8016 (search-forward "\n\n" nil t)
8019 gnus-newsgroup-bookmarks))
8020 (message "A bookmark has been added to the current article."))
8022 (defun gnus-summary-remove-bookmark (article)
8023 "Remove the bookmark from the current article."
8024 (interactive (list (gnus-summary-article-number)))
8025 ;; Remove old bookmark, if one exists.
8026 (let ((old (assq article gnus-newsgroup-bookmarks)))
8029 (setq gnus-newsgroup-bookmarks
8030 (delq old gnus-newsgroup-bookmarks))
8031 (message "Removed bookmark."))
8032 (message "No bookmark in current article."))))
8034 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8035 (defun gnus-summary-mark-as-dormant (n)
8036 "Mark N articles forward as dormant.
8037 If N is negative, mark backward instead. The difference between N and
8038 the actual number of articles marked is returned."
8040 (gnus-summary-mark-forward n gnus-dormant-mark))
8042 (defun gnus-summary-set-process-mark (article)
8043 "Set the process mark on ARTICLE and update the summary line."
8044 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
8045 (let ((buffer-read-only nil))
8046 (if (gnus-summary-goto-subject article)
8048 (and (eq (gnus-summary-article-mark) ?Z)
8050 (gnus-summary-update-mark gnus-process-mark 'replied)
8053 (defun gnus-summary-remove-process-mark (article)
8054 "Remove the process mark from ARTICLE and update the summary line."
8055 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8056 (let ((buffer-read-only nil))
8057 (if (gnus-summary-goto-subject article)
8059 (and (eq (gnus-summary-article-mark) ?Z)
8061 (gnus-summary-update-mark ? 'replied)
8062 (if (memq article gnus-newsgroup-replied)
8063 (gnus-summary-update-mark gnus-replied-mark 'replied))
8066 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8067 "Mark N articles as read forwards.
8068 If N is negative, mark backwards instead.
8069 Mark with MARK. If MARK is ? , ?! or ??, articles will be
8071 The difference between N and the actual number of articles marked is
8074 (gnus-set-global-variables)
8075 (let ((backward (< n 0))
8077 (mark (or mark gnus-dread-mark)))
8079 (gnus-summary-mark-article nil mark no-expire)
8080 (zerop (gnus-summary-next-subject
8081 (if backward -1 1) gnus-summary-goto-unread)))
8083 (if (/= 0 n) (message "No more %sarticles" (if mark "" "unread ")))
8084 (gnus-set-mode-line 'summary)
8087 (defun gnus-summary-mark-article (&optional article mark no-expire)
8088 "Mark ARTICLE with MARK.
8089 MARK can be any character.
8090 Five MARK strings are reserved: ? (unread),
8091 ?! (ticked), ?? (dormant), ?D (read), ?E (expirable).
8092 If MARK is nil, then the default character ?D is used.
8093 If ARTICLE is nil, then the article on the current line will be
8095 ;; If no mark is given, then we check auto-expiring.
8096 (and (not no-expire)
8097 gnus-newsgroup-auto-expire
8099 (and (numberp mark) (or (= mark gnus-killed-mark)
8100 (= mark gnus-dread-mark)
8101 (= mark gnus-catchup-mark)
8102 (= mark gnus-low-score-mark)
8103 (= mark gnus-read-mark))))
8104 (setq mark gnus-expirable-mark))
8105 (let* ((buffer-read-only nil)
8106 (mark (or (and (stringp mark) (aref mark 0)) mark gnus-dread-mark))
8107 (article (or article (gnus-summary-article-number))))
8108 (if (or (= mark gnus-unread-mark)
8109 (= mark gnus-ticked-mark)
8110 (= mark gnus-dormant-mark))
8111 (gnus-mark-article-as-unread article mark)
8112 (gnus-mark-article-as-read article mark))
8113 (if (gnus-summary-goto-subject article)
8115 (gnus-summary-show-thread)
8117 (and (eq (gnus-summary-article-mark) ?Z)
8120 (gnus-summary-update-mark mark 'unread)
8123 (defun gnus-summary-update-mark (mark type)
8125 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8129 (forward-char forward)
8130 (setq plist (text-properties-at (point)))
8132 (and (memq 'gnus-mark plist) (setcar (cdr (memq 'gnus-mark plist)) mark))
8134 (and plist (add-text-properties (1- (point)) (point) plist))
8135 (gnus-summary-update-line (eq mark gnus-unread-mark)))))
8137 (defun gnus-mark-article-as-read (article &optional mark)
8138 "Enter ARTICLE in the pertinent lists and remove it from others."
8139 ;; Make the article expirable.
8140 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-dread-mark)))
8141 (if (= mark gnus-expirable-mark)
8142 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
8143 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8144 ;; Remove from unread and marked lists.
8145 (setq gnus-newsgroup-unreads
8146 (delq article gnus-newsgroup-unreads))
8147 (setq gnus-newsgroup-marked
8148 (delq article gnus-newsgroup-marked))
8149 (setq gnus-newsgroup-dormant
8150 (delq article gnus-newsgroup-dormant))))
8152 (defun gnus-mark-article-as-unread (article &optional mark)
8153 "Enter ARTICLE in the pertinent lists and remove it from others."
8154 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-ticked-mark)))
8155 ;; Add to unread list.
8156 (or (memq article gnus-newsgroup-unreads)
8157 (setq gnus-newsgroup-unreads
8158 (cons article gnus-newsgroup-unreads)))
8159 ;; If CLEAR-MARK is non-nil, the article must be removed from marked
8160 ;; list. Otherwise, it must be added to the list.
8161 (setq gnus-newsgroup-marked
8162 (delq article gnus-newsgroup-marked))
8163 (setq gnus-newsgroup-dormant
8164 (delq article gnus-newsgroup-dormant))
8165 (setq gnus-newsgroup-expirable
8166 (delq article gnus-newsgroup-expirable))
8167 (if (= mark gnus-ticked-mark)
8168 (setq gnus-newsgroup-marked
8169 (cons article gnus-newsgroup-marked)))
8170 (if (= mark gnus-dormant-mark)
8171 (setq gnus-newsgroup-dormant
8172 (cons article gnus-newsgroup-dormant)))))
8174 (defalias 'gnus-summary-mark-as-unread-forward
8175 'gnus-summary-tick-article-forward)
8176 (make-obsolete 'gnus-summary-mark-as-unread-forward
8177 'gnus-summary-tick-article-forward)
8178 (defun gnus-summary-tick-article-forward (n)
8179 "Tick N articles forwards.
8180 If N is negative, tick backwards instead.
8181 The difference between N and the number of articles ticked is returned."
8183 (gnus-summary-mark-forward n gnus-ticked-mark))
8185 (defalias 'gnus-summary-mark-as-unread-backward
8186 'gnus-summary-tick-article-backward)
8187 (make-obsolete 'gnus-summary-mark-as-unread-backward
8188 'gnus-summary-tick-article-backward)
8189 (defun gnus-summary-tick-article-backward (n)
8190 "Tick N articles backwards.
8191 The difference between N and the number of articles ticked is returned."
8193 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8195 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8196 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8197 (defun gnus-summary-tick-article (&optional article clear-mark)
8198 "Mark current article as unread.
8199 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8200 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8201 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8204 (defun gnus-summary-mark-as-read-forward (n)
8205 "Mark N articles as read forwards.
8206 If N is negative, mark backwards instead.
8207 The difference between N and the actual number of articles marked is
8210 (gnus-summary-mark-forward n gnus-dread-mark t))
8212 (defun gnus-summary-mark-as-read-backward (n)
8213 "Mark the N articles as read backwards.
8214 The difference between N and the actual number of articles marked is
8217 (gnus-summary-mark-forward (- n) gnus-dread-mark t))
8219 (defun gnus-summary-mark-as-read (&optional article mark)
8220 "Mark current article as read.
8221 ARTICLE specifies the article to be marked as read.
8222 MARK specifies a string to be inserted at the beginning of the line."
8223 (gnus-summary-mark-article article mark))
8225 (defun gnus-summary-clear-mark-forward (n)
8226 "Clear marks from N articles forward.
8227 If N is negative, clear backward instead.
8228 The difference between N and the number of marks cleared is returned."
8230 (gnus-summary-mark-forward n gnus-unread-mark))
8232 (defun gnus-summary-clear-mark-backward (n)
8233 "Clear marks from N articles backward.
8234 The difference between N and the number of marks cleared is returned."
8236 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8238 (defun gnus-summary-mark-unread-as-read ()
8239 "Intended to be used by `gnus-summary-mark-article-hook'."
8240 (or (memq gnus-current-article gnus-newsgroup-marked)
8241 (memq gnus-current-article gnus-newsgroup-dormant)
8242 (memq gnus-current-article gnus-newsgroup-expirable)
8243 (gnus-summary-mark-as-read gnus-current-article gnus-read-mark)))
8245 (defun gnus-summary-mark-region-as-read (point mark all)
8246 "Mark all unread articles between point and mark as read.
8247 If given a prefix, mark all articles between point and mark as read,
8248 even ticked and dormant ones."
8249 (interactive "r\nP")
8259 (not (memq (gnus-summary-article-number)
8260 gnus-newsgroup-marked))
8261 (not (memq (gnus-summary-article-number)
8262 gnus-newsgroup-dormant))))
8263 (gnus-summary-mark-article
8264 (gnus-summary-article-number) gnus-dread-mark))
8266 (zerop (forward-line 1))))))
8268 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
8269 (defalias 'gnus-summary-delete-marked-as-read
8270 'gnus-summary-remove-lines-marked-as-read)
8271 (make-obsolete 'gnus-summary-delete-marked-as-read
8272 'gnus-summary-remove-lines-marked-as-read)
8273 (defun gnus-summary-remove-lines-marked-as-read ()
8274 "Remove lines that are marked as read."
8276 (gnus-summary-remove-lines-marked-with
8278 (lambda (char) (char-to-string (symbol-value char)))
8279 '(gnus-dread-mark gnus-read-mark
8280 gnus-killed-mark gnus-kill-file-mark
8281 gnus-low-score-mark gnus-expirable-mark)
8284 (defalias 'gnus-summary-delete-marked-with
8285 'gnus-summary-remove-lines-marked-with)
8286 (make-obsolete 'gnus-summary-delete-marked-with
8287 'gnus-summary-remove-lines-marked-with)
8288 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
8289 (defun gnus-summary-remove-lines-marked-with (marks)
8290 "Remove lines that are marked with MARKS (e.g. \"DK\")."
8291 (interactive "sMarks: ")
8292 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
8294 (set-buffer gnus-summary-buffer)
8295 (let ((buffer-read-only nil)
8296 (marks (concat "^[" marks "]")))
8297 (goto-char (point-min))
8298 (while (search-forward-regexp marks (point-max) t)
8300 (delete-region (point)
8301 (progn (forward-line 1) (point)))))
8302 (or (zerop (buffer-size))
8304 (gnus-summary-prev-subject 1)
8305 (gnus-summary-position-cursor)))))
8307 (defun gnus-summary-expunge-below (score)
8308 "Remove articles with score less than SCORE."
8310 (setq score (if score
8311 (prefix-numeric-value score)
8312 (or gnus-summary-default-score 0)))
8314 (set-buffer gnus-summary-buffer)
8315 (goto-char (point-min))
8316 (let ((buffer-read-only nil)
8319 (if (< (gnus-summary-article-score) score)
8323 (delete-region beg (point)))
8326 (or (zerop (buffer-size))
8328 (gnus-summary-prev-subject 1)
8329 (gnus-summary-position-cursor))))))
8331 (defun gnus-summary-mark-below (score mark)
8332 "Mark articles with score less than SCORE with MARK."
8333 (interactive "P\ncMark: ")
8334 (setq score (if score
8335 (prefix-numeric-value score)
8336 (or gnus-summary-default-score 0)))
8338 (set-buffer gnus-summary-buffer)
8339 (goto-char (point-min))
8341 (and (< (gnus-summary-article-score) score)
8342 (gnus-summary-mark-article nil mark))
8345 (defun gnus-summary-kill-below (score)
8346 "Mark articles with score below SCORE as read."
8348 (gnus-summary-mark-below score gnus-killed-mark))
8350 (defun gnus-summary-clear-above (score)
8351 "Clear all marks from articles with score above SCORE."
8353 (gnus-summary-mark-above score gnus-unread-mark))
8355 (defun gnus-summary-tick-above (score)
8356 "Tick all articles with score above SCORE."
8358 (gnus-summary-mark-above score gnus-ticked-mark))
8360 (defun gnus-summary-mark-above (score mark)
8361 "Mark articles with score over SCORE with MARK."
8362 (interactive "P\ncMark: ")
8363 (setq score (if score
8364 (prefix-numeric-value score)
8365 (or gnus-summary-default-score 0)))
8367 (set-buffer gnus-summary-buffer)
8368 (goto-char (point-min))
8370 (if (> (gnus-summary-article-score) score)
8372 (gnus-summary-mark-article nil mark)
8374 (forward-line 1)))))
8376 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8377 (defun gnus-summary-show-all-expunged ()
8378 "Display all the hidden articles that were expunged for low scores."
8380 (let ((buffer-read-only nil))
8381 (let ((scored gnus-newsgroup-scored)
8384 (or (gnus-summary-goto-subject (car (car scored)))
8385 (and (setq h (gnus-get-header-by-number (car (car scored))))
8386 (< (cdr (car scored)) gnus-summary-expunge-below)
8387 (setq headers (cons h headers))))
8388 (setq scored (cdr scored)))
8389 (or headers (error "No expunged articles hidden."))
8390 (goto-char (point-min))
8392 (gnus-summary-prepare-threads (nreverse headers) 0)))
8393 (goto-char (point-min))
8394 (gnus-summary-position-cursor)))
8396 (defun gnus-summary-show-all-dormant ()
8397 "Display all the hidden articles that are marked as dormant."
8399 (let ((buffer-read-only nil))
8400 (goto-char (point-min))
8401 (let ((dormant gnus-newsgroup-dormant)
8404 (or (gnus-summary-goto-subject (car dormant))
8405 (and (setq h (gnus-get-header-by-number (car dormant)))
8406 (setq headers (cons h headers))))
8407 (setq dormant (cdr dormant)))
8408 (or headers (error "No dormant articles hidden."))
8409 (save-excursion (gnus-summary-prepare-threads (nreverse headers) 0)))
8410 (goto-char (point-min))
8411 (gnus-summary-position-cursor)))
8413 (defun gnus-summary-hide-all-dormant ()
8414 "Hide all dormant articles."
8416 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
8417 (gnus-summary-position-cursor))
8419 (defun gnus-summary-catchup (all &optional quietly to-here)
8420 "Mark all articles not marked as unread in this newsgroup as read.
8421 If prefix argument ALL is non-nil, all articles are marked as read.
8422 If QUIETLY is non-nil, no questions will be asked.
8423 If TO-HERE is non-nil, it should be a point in the buffer. All
8424 articles before this point will be marked as read.
8425 The number of articles marked as read is returned."
8429 (not gnus-interactive-catchup) ;Without confirmation?
8433 "Mark absolutely all articles as read? "
8434 "Mark all unread articles as read? ")))
8435 (let ((unreads (length gnus-newsgroup-unreads)))
8436 (if (gnus-summary-first-subject (not all))
8437 (while (and (gnus-summary-mark-as-read nil gnus-catchup-mark)
8438 (if to-here (< (point) to-here) t)
8439 (gnus-summary-search-subject nil (not all)))))
8440 (- unreads (length gnus-newsgroup-unreads))
8442 (setq gnus-newsgroup-unreads gnus-newsgroup-marked))))
8443 (gnus-summary-position-cursor)))
8445 (defun gnus-summary-catchup-to-here (&optional all)
8446 "Mark all unticked articles before the current one as read.
8447 If ALL is non-nil, also mark ticked and dormant articles as read."
8450 (gnus-summary-catchup all t (point))
8451 (gnus-summary-position-cursor))
8453 (defun gnus-summary-catchup-all (&optional quietly)
8454 "Mark all articles in this newsgroup as read."
8456 (gnus-summary-catchup t quietly))
8458 (defun gnus-summary-catchup-and-exit (all &optional quietly)
8459 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8460 If prefix argument ALL is non-nil, all articles are marked as read."
8462 (gnus-summary-catchup all quietly)
8463 ;; Select next newsgroup or exit.
8464 (if (eq gnus-auto-select-next 'quietly)
8465 (gnus-summary-next-group nil)
8466 (gnus-summary-exit)))
8468 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8469 "Mark all articles in this newsgroup as read, and then exit."
8471 (gnus-summary-catchup-and-exit t quietly))
8473 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8474 (defun gnus-summary-catchup-and-goto-next-group (all)
8475 "Mark all articles in this group as read and select the next group.
8476 If given a prefix, mark all articles, unread as well as ticked, as
8479 (gnus-summary-catchup all)
8480 (gnus-summary-next-group))
8482 ;; Thread-based commands.
8484 (defun gnus-summary-toggle-threads (arg)
8485 "Toggle showing conversation threads.
8486 If ARG is positive number, turn showing conversation threads on."
8488 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8489 (setq gnus-show-threads
8490 (if (null arg) (not gnus-show-threads)
8491 (> (prefix-numeric-value arg) 0)))
8492 (gnus-summary-prepare)
8493 (gnus-summary-goto-subject current)
8494 (gnus-summary-position-cursor)))
8496 (defun gnus-summary-show-all-threads ()
8500 (let ((buffer-read-only nil))
8501 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8502 (gnus-summary-position-cursor))
8504 (defun gnus-summary-show-thread ()
8505 "Show thread subtrees.
8506 Returns nil if no thread was there to be shown."
8510 (let ((buffer-read-only nil)
8511 ;; first goto end then to beg, to have point at beg after let
8512 (end (progn (end-of-line) (point)))
8513 (beg (progn (beginning-of-line) (point))))
8515 ;; Any hidden lines here?
8516 (search-forward "\r" end t)
8517 (subst-char-in-region beg end ?\^M ?\n t))))
8518 (gnus-summary-position-cursor)))
8520 (defun gnus-summary-hide-all-threads ()
8521 "Hide all thread subtrees."
8524 (goto-char (point-min))
8525 (gnus-summary-hide-thread)
8526 (while (and (not (eobp)) (zerop (forward-line 1)))
8527 (gnus-summary-hide-thread)))
8528 (gnus-summary-position-cursor))
8530 (defun gnus-summary-hide-thread ()
8531 "Hide thread subtrees.
8532 Returns nil if no threads were there to be hidden."
8534 (let ((buffer-read-only nil)
8536 (level (gnus-summary-thread-level))
8538 ;; Go forward until either the buffer ends or the subthread
8542 (while (and (zerop (forward-line 1))
8543 (> (gnus-summary-thread-level) level))
8548 (search-backward "\n" start t))
8549 (subst-char-in-region start end ?\n ?\^M t)
8550 (forward-line -1)))))
8552 (defun gnus-summary-go-to-next-thread (&optional previous)
8553 "Go to the same level (or less) next thread.
8554 If PREVIOUS is non-nil, go to previous thread instead.
8555 Return the article number moved to, or nil if moving was impossible."
8556 (let ((level (gnus-summary-thread-level))
8557 (article (gnus-summary-article-number)))
8559 (while (and (zerop (gnus-summary-prev-subject 1))
8560 (> (gnus-summary-thread-level) level)))
8561 (while (and (zerop (gnus-summary-next-subject 1))
8562 (> (gnus-summary-thread-level) level))))
8563 (let ((oart (gnus-summary-article-number)))
8564 (and (/= oart article) oart))))
8566 (defun gnus-summary-next-thread (n)
8567 "Go to the same level next N'th thread.
8568 If N is negative, search backward instead.
8569 Returns the difference between N and the number of skips actually
8572 (let ((backward (< n 0))
8575 (gnus-summary-go-to-next-thread backward))
8577 (gnus-summary-position-cursor)
8578 (if (/= 0 n) (message "No more threads"))
8581 (defun gnus-summary-prev-thread (n)
8582 "Go to the same level previous N'th thread.
8583 Returns the difference between N and the number of skips actually
8586 (gnus-summary-next-thread (- n)))
8588 (defun gnus-summary-go-down-thread (&optional same)
8589 "Go down one level in the current thread.
8590 If SAME is non-nil, also move to articles of the same level."
8591 (let ((level (gnus-summary-thread-level))
8593 (if (and (zerop (forward-line 1))
8594 (> (gnus-summary-thread-level) level))
8599 (defun gnus-summary-go-up-thread ()
8600 "Go up one level in the current thread."
8601 (let ((level (gnus-summary-thread-level))
8603 (while (and (zerop (forward-line -1))
8604 (>= (gnus-summary-thread-level) level)))
8605 (if (>= (gnus-summary-thread-level) level)
8611 (defun gnus-summary-down-thread (n)
8612 "Go down thread N steps.
8613 If N is negative, go up instead.
8614 Returns the difference between N and how many steps down that were
8620 (if up (gnus-summary-go-up-thread)
8621 (gnus-summary-go-down-thread)))
8623 (gnus-summary-position-cursor)
8624 (if (/= 0 n) (message "Can't go further"))
8627 (defun gnus-summary-up-thread (n)
8628 "Go up thread N steps.
8629 If N is negative, go up instead.
8630 Returns the difference between N and how many steps down that were
8633 (gnus-summary-down-thread (- n)))
8635 (defun gnus-summary-kill-thread (unmark)
8636 "Mark articles under current thread as read.
8637 If the prefix argument is positive, remove any kinds of marks.
8638 If the prefix argument is negative, tick articles instead."
8641 (setq unmark (prefix-numeric-value unmark)))
8643 (level (gnus-summary-thread-level)))
8646 ;; Mark the article...
8647 (cond ((null unmark) (gnus-summary-mark-as-read nil gnus-killed-mark))
8648 ((> unmark 0) (gnus-summary-tick-article nil t))
8649 (t (gnus-summary-tick-article)))
8650 ;; ...and go forward until either the buffer ends or the subtree
8652 (if (not (and (zerop (forward-line 1))
8653 (> (gnus-summary-thread-level) level)))
8654 (setq killing nil))))
8655 ;; Hide killed subtrees.
8657 gnus-thread-hide-killed
8658 (gnus-summary-hide-thread))
8659 ;; If marked as read, go to next unread subject.
8661 ;; Go to next unread subject.
8662 (gnus-summary-next-subject 1 t)))
8663 (gnus-set-mode-line 'summary))
8665 ;; Summary sorting commands
8667 (defun gnus-summary-sort-by-number (reverse)
8668 "Sort summary buffer by article number.
8669 Argument REVERSE means reverse order."
8672 (cons 'gnus-summary-article-number 'gnus-thread-sort-by-number) reverse))
8674 (defun gnus-summary-sort-by-author (reverse)
8675 "Sort summary buffer by author name alphabetically.
8676 If case-fold-search is non-nil, case of letters is ignored.
8677 Argument REVERSE means reverse order."
8682 (let ((extract (funcall
8683 gnus-extract-address-components
8684 (header-from (gnus-get-header-by-number
8685 (gnus-summary-article-number))))))
8686 (or (car extract) (cdr extract))))
8687 'gnus-thread-sort-by-author)
8690 (defun gnus-summary-sort-by-subject (reverse)
8691 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
8692 If case-fold-search is non-nil, case of letters is ignored.
8693 Argument REVERSE means reverse order."
8698 (downcase (gnus-simplify-subject (gnus-summary-subject-string))))
8699 'gnus-thread-sort-by-subject)
8702 (defun gnus-summary-sort-by-date (reverse)
8703 "Sort summary buffer by date.
8704 Argument REVERSE means reverse order."
8711 (gnus-get-header-by-number (gnus-summary-article-number)))))
8712 'gnus-thread-sort-by-date)
8715 (defun gnus-summary-sort-by-score (reverse)
8716 "Sort summary buffer by score.
8717 Argument REVERSE means reverse order."
8720 (cons 'gnus-summary-article-score 'gnus-thread-sort-by-score)
8723 (defvar gnus-summary-already-sorted nil)
8724 (defun gnus-summary-sort (predicate reverse)
8725 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
8726 (if gnus-summary-already-sorted
8728 (let (buffer-read-only)
8729 (if (not gnus-show-threads)
8731 (goto-char (point-min))
8732 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
8733 (let ((gnus-thread-sort-functions (list (cdr predicate)))
8734 (gnus-summary-already-sorted nil))
8735 (gnus-summary-prepare))))))
8737 (defun gnus-sortable-date (date)
8738 "Make sortable string by string-lessp from DATE.
8739 Timezone package is used."
8740 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
8741 (year (aref date 0))
8742 (month (aref date 1))
8743 (day (aref date 2)))
8744 (timezone-make-sortable-date
8746 (timezone-make-time-string
8747 (aref date 3) (aref date 4) (aref date 5)))))
8750 ;; Summary saving commands.
8752 (defun gnus-summary-save-article (n)
8753 "Save the current article using the default saver function.
8754 If N is a positive number, save the N next articles.
8755 If N is a negative number, save the N previous articles.
8756 If N is nil and any articles have been marked with the process mark,
8757 save those articles instead.
8758 The variable `gnus-default-article-saver' specifies the saver function."
8760 (let (articles process)
8761 (if (and n (numberp n))
8762 (let ((backward (< n 0))
8766 (setq articles (cons (gnus-summary-article-number)
8768 (gnus-summary-search-forward nil nil backward))
8770 (setq articles (sort articles (function <))))
8771 (if gnus-newsgroup-processable
8773 (setq articles (setq gnus-newsgroup-processable
8774 (nreverse gnus-newsgroup-processable)))
8776 (setq articles (list (gnus-summary-article-number)))))
8778 (let ((header (gnus-gethash (int-to-string (car articles))
8779 gnus-newsgroup-headers-hashtb-by-number)))
8780 (if (vectorp header)
8782 (gnus-summary-select-article t nil nil (car articles))
8783 (or gnus-save-all-headers
8784 (gnus-article-hide-headers t))
8785 ;; Remove any X-Gnus lines.
8788 (set-buffer gnus-article-buffer)
8789 (let ((buffer-read-only nil))
8790 (goto-char (point-min))
8791 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
8793 (while (re-search-forward "^X-Gnus" nil t)
8795 (delete-region (point)
8796 (progn (forward-line 1) (point))))
8798 (if gnus-default-article-saver
8799 (funcall gnus-default-article-saver)
8800 (error "No default saver is defined.")))
8801 (if (assq 'name header)
8802 (gnus-copy-file (cdr (assq 'name header)))
8803 (message "Article %d is unsaveable" (car articles)))))
8805 (gnus-summary-remove-process-mark (car articles)))
8806 (setq articles (cdr articles)))
8807 (if process (setq gnus-newsgroup-processable
8808 (nreverse gnus-newsgroup-processable)))
8809 (gnus-summary-position-cursor)
8812 (defun gnus-summary-pipe-output (arg)
8813 "Pipe the current article to a subprocess.
8814 If N is a positive number, pipe the N next articles.
8815 If N is a negative number, pipe the N previous articles.
8816 If N is nil and any articles have been marked with the process mark,
8817 pipe those articles instead."
8819 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8820 (gnus-summary-save-article arg)))
8822 (defun gnus-summary-save-article-mail (arg)
8823 "Append the current article to an mail file.
8824 If N is a positive number, save the N next articles.
8825 If N is a negative number, save the N previous articles.
8826 If N is nil and any articles have been marked with the process mark,
8827 save those articles instead."
8829 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8830 (gnus-summary-save-article arg)))
8832 (defun gnus-summary-save-article-rmail (arg)
8833 "Append the current article to an rmail file.
8834 If N is a positive number, save the N next articles.
8835 If N is a negative number, save the N previous articles.
8836 If N is nil and any articles have been marked with the process mark,
8837 save those articles instead."
8839 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8840 (gnus-summary-save-article arg)))
8842 (defun gnus-summary-save-article-file (arg)
8843 "Append the current article to a file.
8844 If N is a positive number, save the N next articles.
8845 If N is a negative number, save the N previous articles.
8846 If N is nil and any articles have been marked with the process mark,
8847 save those articles instead."
8849 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8850 (gnus-summary-save-article arg)))
8852 (defun gnus-summary-save-article-folder (arg)
8853 "Append the current article to an mh folder.
8854 If N is a positive number, save the N next articles.
8855 If N is a negative number, save the N previous articles.
8856 If N is nil and any articles have been marked with the process mark,
8857 save those articles instead."
8859 (let ((gnus-default-article-saver 'gnus-summary-save-in-folder))
8860 (gnus-summary-save-article arg)))
8862 (defun gnus-read-save-file-name (prompt default-name)
8863 (let ((methods gnus-split-methods)
8865 (if (not gnus-split-methods)
8868 (set-buffer gnus-article-buffer)
8869 (gnus-narrow-to-headers)
8871 (goto-char (point-min))
8872 (and (condition-case ()
8873 (re-search-forward (car (car methods)) nil t)
8875 (setq split-name (cons (nth 1 (car methods)) split-name)))
8876 (setq methods (cdr methods)))
8878 (cond ((null split-name)
8880 (concat prompt " (default "
8881 (file-name-nondirectory default-name) ") ")
8882 (file-name-directory default-name)
8884 ((= 1 (length split-name))
8886 (concat prompt " (default " (car split-name) ") ")
8887 gnus-article-save-directory
8888 (concat gnus-article-save-directory (car split-name))))
8890 (setq split-name (mapcar (lambda (el) (list el))
8891 (nreverse split-name)))
8892 (let ((result (completing-read
8894 split-name nil nil)))
8895 (concat gnus-article-save-directory
8896 (if (string= result "")
8897 (car (car split-name))
8900 (defun gnus-summary-save-in-rmail (&optional filename)
8901 "Append this article to Rmail file.
8902 Optional argument FILENAME specifies file name.
8903 Directory to save to is default to `gnus-article-save-directory' which
8904 is initialized from the SAVEDIR environment variable."
8907 (funcall gnus-rmail-save-name gnus-newsgroup-name
8908 gnus-current-headers gnus-newsgroup-last-rmail)))
8910 (setq filename (gnus-read-save-file-name
8911 "Save in rmail file:" default-name)))
8912 (gnus-make-directory (file-name-directory filename))
8913 (gnus-eval-in-buffer-window
8918 (gnus-output-to-rmail filename))))
8919 ;; Remember the directory name to save articles.
8920 (setq gnus-newsgroup-last-rmail filename)))
8922 (defun gnus-summary-save-in-mail (&optional filename)
8923 "Append this article to Unix mail file.
8924 Optional argument FILENAME specifies file name.
8925 Directory to save to is default to `gnus-article-save-directory' which
8926 is initialized from the SAVEDIR environment variable."
8929 (funcall gnus-mail-save-name gnus-newsgroup-name
8930 gnus-current-headers gnus-newsgroup-last-mail)))
8932 (setq filename (gnus-read-save-file-name
8933 "Save in Unix mail file:" default-name)))
8935 (expand-file-name filename
8937 (file-name-directory default-name))))
8938 (gnus-make-directory (file-name-directory filename))
8939 (gnus-eval-in-buffer-window
8944 (if (and (file-readable-p filename) (rmail-file-p filename))
8945 (gnus-output-to-rmail filename)
8946 (rmail-output filename 1 t t)))))
8947 ;; Remember the directory name to save articles.
8948 (setq gnus-newsgroup-last-mail filename)))
8950 (defun gnus-summary-save-in-file (&optional filename)
8951 "Append this article to file.
8952 Optional argument FILENAME specifies file name.
8953 Directory to save to is default to `gnus-article-save-directory' which
8954 is initialized from the SAVEDIR environment variable."
8957 (funcall gnus-file-save-name gnus-newsgroup-name
8958 gnus-current-headers gnus-newsgroup-last-file)))
8960 (setq filename (gnus-read-save-file-name
8961 "Save in file:" default-name)))
8962 (gnus-make-directory (file-name-directory filename))
8963 (gnus-eval-in-buffer-window
8968 (gnus-output-to-file filename))))
8969 ;; Remember the directory name to save articles.
8970 (setq gnus-newsgroup-last-file filename)))
8972 (defun gnus-summary-save-in-pipe (&optional command)
8973 "Pipe this article to subprocess."
8975 (let ((command (read-string "Shell command on article: "
8976 gnus-last-shell-command)))
8977 (if (string-equal command "")
8978 (setq command gnus-last-shell-command))
8979 (gnus-eval-in-buffer-window
8983 (shell-command-on-region (point-min) (point-max) command nil)))
8984 (setq gnus-last-shell-command command)))
8986 ;; Summary extract commands
8988 (defun gnus-summary-insert-pseudos (pslist)
8989 (let ((buffer-read-only nil)
8990 (article (gnus-summary-article-number))
8992 (or (gnus-summary-goto-subject article)
8993 (error (format "No such article: %d" article)))
8994 (or gnus-newsgroup-headers-hashtb-by-number
8995 (gnus-make-headers-hashtable-by-number))
8996 (gnus-summary-position-cursor)
8997 (if gnus-view-pseudos
8999 (and (assq 'execute (car pslist))
9000 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9001 (eq gnus-view-pseudos 'not-confirm)))
9002 (setq pslist (cdr pslist)))
9005 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
9006 (gnus-summary-article-number)))
9009 (insert " " (file-name-nondirectory
9010 (cdr (assq 'name (car pslist))))
9011 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9012 (add-text-properties
9013 b (1+ b) (list 'gnus-subject (cdr (assq 'name (car pslist)))
9014 'gnus-number gnus-reffed-article-number
9015 'gnus-mark gnus-unread-mark
9016 'gnus-pseudo (car pslist)
9019 (gnus-sethash (int-to-string gnus-reffed-article-number)
9020 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
9021 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9022 (setq pslist (cdr pslist)))))))
9024 (defun gnus-request-pseudo-article (props)
9025 (cond ((assq 'execute props)
9026 (gnus-execute-command (cdr (assq 'execute props)))))
9027 (let ((gnus-current-article (gnus-summary-article-number)))
9028 (run-hooks 'gnus-mark-article-hook)))
9030 (defun gnus-execute-command (command &optional automatic)
9032 (gnus-article-setup-buffer)
9033 (set-buffer gnus-article-buffer)
9034 (let ((command (if automatic command (read-string "Command: " command)))
9035 (buffer-read-only nil))
9037 (insert "$ " command "\n\n")
9038 (if gnus-view-pseudo-asynchronously
9039 (start-process "gnus-execute" nil "sh" "-c" command)
9040 (call-process "sh" nil t nil "-c" command)))))
9042 (defun gnus-copy-file (file &optional to)
9045 (list (read-file-name "Copy file: " default-directory)
9046 (read-file-name "Copy file to: " default-directory)))
9047 (or to (setq to (read-file-name "Copy file to: " default-directory)))
9048 (and (file-directory-p to)
9049 (setq to (concat (file-name-as-directory to)
9050 (file-name-nondirectory file))))
9051 (copy-file file to))
9053 ;; Summary score file commands
9055 ;; Much modification of the kill (ahem, score) code and lots of the
9056 ;; functions are written by Per Abrahamsen <amanda@iesd.auc.dk>.
9058 (defun gnus-summary-header (header)
9059 ;; Return HEADER for current articles, or error.
9060 (let ((article (gnus-summary-article-number)))
9062 (aref (gnus-get-header-by-number article)
9063 (nth 1 (assoc header gnus-header-index)))
9064 (error "No article on current line"))))
9066 (defun gnus-summary-score-entry (header match type score date &optional prompt)
9067 "Enter score file entry.
9068 HEADER is the header being scored.
9069 MATCH is the string we are looking for.
9070 TYPE is a flag indicating if it is a regexp or substring.
9071 SCORE is the score to add.
9072 DATE is the expire date."
9074 (list (completing-read "Header: "
9076 (lambda (x) (fboundp (nth 2 x)))
9078 (read-string "Match: ")
9079 (y-or-n-p "Use regexp match? ")
9080 (prefix-numeric-value current-prefix-arg)
9081 (if (y-or-n-p "Expire kill? ")
9082 (current-time-string)
9084 (let ((score (gnus-score-default score))
9085 (header (downcase header)))
9086 (and prompt (setq match (read-string
9087 (format "Match %s on %s, %s: "
9088 (if date "temp" "permanent")
9090 (if (< score 0) "lower" "raise"))
9092 (and (>= (nth 1 (assoc header gnus-header-index)) 0)
9093 (gnus-summary-score-effect header match type score))
9094 (and (= score gnus-score-interactive-default-score)
9096 (let ((new (cond (type
9097 (list match score (and date (gnus-day-number date)) type))
9099 (list match score (gnus-day-number date)))
9104 (old (gnus-score-get header)))
9107 (if old (cons new old) (list new))))
9108 (gnus-score-set 'touched '(t))))
9110 (defun gnus-summary-score-effect (header match type score)
9111 "Simulate the effect of a score file entry.
9112 HEADER is the header being scored.
9113 MATCH is the string we are looking for.
9114 TYPE is a flag indicating if it is a regexp or substring.
9115 SCORE is the score to add."
9116 (interactive (list (completing-read "Header: "
9118 (lambda (x) (fboundp (nth 2 x)))
9120 (read-string "Match: ")
9121 (y-or-n-p "Use regexp match? ")
9122 (prefix-numeric-value current-prefix-arg)))
9124 (or (and (stringp match) (> (length match) 0))
9126 (goto-char (point-min))
9127 (let ((regexp (if type
9129 (concat "\\`.*" (regexp-quote match) ".*\\'"))))
9131 (let ((content (gnus-summary-header header))
9132 (case-fold-search t))
9134 (if (string-match regexp content)
9135 (gnus-summary-raise-score score))))
9136 (beginning-of-line 2)))))
9138 (defun gnus-summary-score-crossposting (score date)
9139 ;; Enter score file entry for current crossposting.
9140 ;; SCORE is the score to add.
9141 ;; DATE is the expire date.
9142 (let ((xref (gnus-summary-header "xref"))
9145 (or xref (error "This article is not crossposted"))
9146 (while (string-match " \\([^ \t]+\\):" xref start)
9147 (setq start (match-end 0))
9150 (substring xref (match-beginning 1) (match-end 1)))
9151 gnus-newsgroup-name))
9152 (gnus-summary-score-entry
9153 "xref" (concat " " group ":") nil score date t)))))
9155 (defun gnus-summary-temporarily-lower-by-subject (level)
9156 "Temporarily lower score by LEVEL for current subject.
9157 See `gnus-score-expiry-days'."
9159 (gnus-summary-score-entry
9160 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
9161 nil (- (gnus-score-default level))
9162 (current-time-string) t))
9164 (defun gnus-summary-temporarily-lower-by-author (level)
9165 "Temporarily lower score by LEVEL for current author.
9166 See `gnus-score-expiry-days'."
9168 (gnus-summary-score-entry
9169 "from" (gnus-summary-header "from") nil (- (gnus-score-default level))
9170 (current-time-string) t))
9172 (defun gnus-summary-temporarily-lower-by-body (level)
9173 "Temporarily lower score by LEVEL for a match on the body of the article.
9174 See `gnus-score-expiry-days'."
9176 (gnus-summary-score-entry
9177 "body" "" nil (- (gnus-score-default level)) (current-time-string) t))
9179 (defun gnus-summary-temporarily-lower-by-id (level)
9180 "Temporarily lower score by LEVEL for current message-id.
9181 See `gnus-score-expiry-days'."
9183 (gnus-summary-score-entry
9184 "message-id" (gnus-summary-header "message-id")
9185 nil (- (gnus-score-default level))
9186 (current-time-string)))
9188 (defun gnus-summary-temporarily-lower-by-xref (level)
9189 "Temporarily lower score by LEVEL for current xref.
9190 See `gnus-score-expiry-days'."
9192 (gnus-summary-score-crossposting
9193 (- (gnus-score-default level)) (current-time-string)))
9195 (defun gnus-summary-temporarily-lower-by-thread (level)
9196 "Temporarily lower score by LEVEL for current thread.
9197 See `gnus-score-expiry-days'."
9199 (gnus-summary-score-entry
9200 "references" (gnus-summary-header "message-id")
9201 nil (- (gnus-score-default level)) (current-time-string)))
9203 (defun gnus-summary-lower-by-subject (level)
9204 "Lower score by LEVEL for current subject."
9206 (gnus-summary-score-entry
9207 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
9208 nil (- (gnus-score-default level))
9211 (defun gnus-summary-lower-by-author (level)
9212 "Lower score by LEVEL for current author."
9214 (gnus-summary-score-entry
9215 "from" (gnus-summary-header "from") nil
9216 (- (gnus-score-default level)) nil t))
9218 (defun gnus-summary-lower-by-body (level)
9219 "Lower score by LEVEL for a match on the body of the article."
9221 (gnus-summary-score-entry
9222 "body" "" nil (- (gnus-score-default level)) nil t))
9224 (defun gnus-summary-lower-by-id (level)
9225 "Lower score by LEVEL for current message-id."
9227 (gnus-summary-score-entry
9228 "message-id" (gnus-summary-header "message-id") nil
9229 (- (gnus-score-default level)) nil))
9231 (defun gnus-summary-lower-by-xref (level)
9232 "Lower score by LEVEL for current xref."
9234 (gnus-summary-score-crossposting (- (gnus-score-default level)) nil))
9236 (defun gnus-summary-lower-followups-to-author (level)
9237 "Lower score by LEVEL for all followups to the current author."
9239 (gnus-summary-raise-followups-to-author
9240 (- (gnus-score-default level))))
9242 (defun gnus-summary-temporarily-raise-by-subject (level)
9243 "Temporarily raise score by LEVEL for current subject.
9244 See `gnus-score-expiry-days'."
9246 (gnus-summary-score-entry
9247 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
9248 nil level (current-time-string) t))
9250 (defun gnus-summary-temporarily-raise-by-author (level)
9251 "Temporarily raise score by LEVEL for current author.
9252 See `gnus-score-expiry-days'."
9254 (gnus-summary-score-entry
9255 "from" (gnus-summary-header "from") nil level (current-time-string) t))
9257 (defun gnus-summary-temporarily-raise-by-body (level)
9258 "Temporarily raise score by LEVEL for a match on the body of the article.
9259 See `gnus-score-expiry-days'."
9261 (gnus-summary-score-entry "body" "" nil level (current-time-string) t))
9263 (defun gnus-summary-temporarily-raise-by-id (level)
9264 "Temporarily raise score by LEVEL for current message-id.
9265 See `gnus-score-expiry-days'."
9267 (gnus-summary-score-entry
9268 "message-id" (gnus-summary-header "message-id")
9269 nil level (current-time-string)))
9271 (defun gnus-summary-temporarily-raise-by-xref (level)
9272 "Temporarily raise score by LEVEL for current xref.
9273 See `gnus-score-expiry-days'."
9275 (gnus-summary-score-crossposting level (current-time-string)))
9277 (defun gnus-summary-temporarily-raise-by-thread (level)
9278 "Temporarily raise score by LEVEL for current thread.
9279 See `gnus-score-expiry-days'."
9281 (gnus-summary-score-entry
9282 "references" (gnus-summary-header "message-id")
9283 nil level (current-time-string)))
9285 (defun gnus-summary-raise-by-subject (level)
9286 "Raise score by LEVEL for current subject."
9288 (gnus-summary-score-entry
9289 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
9292 (defun gnus-summary-raise-by-author (level)
9293 "Raise score by LEVEL for current author."
9295 (gnus-summary-score-entry
9296 "from" (gnus-summary-header "from") nil level nil t))
9298 (defun gnus-summary-raise-by-body (level)
9299 "Raise score by LEVEL for a match on the body of the article."
9301 (gnus-summary-score-entry "body" "" nil level nil t))
9303 (defun gnus-summary-raise-by-id (level)
9304 "Raise score by LEVEL for current message-id."
9306 (gnus-summary-score-entry
9307 "message-id" (gnus-summary-header "message-id") nil level nil))
9309 (defun gnus-summary-raise-by-xref (level)
9310 "Raise score by LEVEL for current xref."
9312 (gnus-summary-score-crossposting level nil))
9314 (defun gnus-summary-raise-followups-to-author (level)
9315 "Raise score by LEVEL for all followups to the current author."
9317 (let ((article (gnus-summary-article-number)))
9318 (if article (setq gnus-current-headers (gnus-get-header-by-number article))
9319 (error "No article on current line")))
9320 (gnus-kill-file-raise-followups-to-author
9321 (gnus-score-default level)))
9323 ;; Summary kill commands.
9325 (defun gnus-summary-edit-global-kill (article)
9326 "Edit the global score file."
9327 (interactive (list (gnus-summary-article-number)))
9328 (gnus-group-edit-global-kill article))
9330 (defun gnus-summary-edit-local-kill ()
9331 "Edit a local score file applied to the current newsgroup."
9333 (setq gnus-current-headers
9335 (int-to-string (gnus-summary-article-number))
9336 gnus-newsgroup-headers-hashtb-by-number))
9337 (gnus-set-global-variables)
9338 (gnus-group-edit-local-kill
9339 (gnus-summary-article-number) gnus-newsgroup-name))
9343 ;;; Gnus article mode
9346 (put 'gnus-article-mode 'mode-class 'special)
9348 (if gnus-article-mode-map
9350 (setq gnus-article-mode-map (make-keymap))
9351 (suppress-keymap gnus-article-mode-map)
9352 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
9353 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
9354 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
9355 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
9356 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
9357 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
9358 (define-key gnus-article-mode-map "\C-c\C-M" 'gnus-article-mail-with-original)
9359 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
9361 ;; Duplicate almost all summary keystrokes in the article mode map.
9363 (list "#" "\M-#" "\C-c\M-#" "\r" "n" "p"
9364 "N" "P" "\M-\C-n" "\M-\C-p" "." "\M-s" "\M-r"
9365 "<" ">" "l" "j" "^" "\M-^" "-" "u" "U" "d" "D"
9366 "\M-u" "\M-U" "k" "\C-k" "\M-\C-k" "c" "x" "X"
9367 "\M-\C-x" "\M-\177" "b" "B" "$" "w" "\C-c\C-r"
9368 "t" "\M-t" "a" "f" "F" "C" "S" "r" "R" "\C-c\C-f"
9369 "m" "o" "\C-o" "|" "\M-m" "\M-\C-m" "\M-k" "m" "M"
9370 "V" "\C-c\C-d" "q" "Q")))
9372 (define-key gnus-article-mode-map (car commands)
9373 'gnus-article-summary-command)
9374 (setq commands (cdr commands)))))
9377 (defun gnus-article-mode ()
9378 "Major mode for displaying an article.
9380 All normal editing commands are switched off.
9382 The following commands are available:
9384 \\<gnus-article-mode-map>
9385 \\[gnus-article-next-page]\t Scroll the article one page forwards
9386 \\[gnus-article-prev-page]\t Scroll the article one page backwards
9387 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
9388 \\[gnus-article-show-summary]\t Display the summary buffer
9389 \\[gnus-article-mail]\t Send a reply to the address near point
9390 \\[gnus-article-mail-with-original]\t Send a reply to the address near point; include the original article
9391 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
9392 \\[gnus-info-find-node]\t Go to the Gnus info node"
9394 (if gnus-visual (gnus-article-make-menu-bar))
9395 (kill-all-local-variables)
9396 (setq mode-line-modified "-- ")
9397 (make-local-variable 'mode-line-format)
9398 (setq mode-line-format (copy-sequence mode-line-format))
9399 (and (equal (nth 3 mode-line-format) " ")
9400 (setcar (nthcdr 3 mode-line-format) ""))
9401 (setq mode-name "Article")
9402 (setq major-mode 'gnus-article-mode)
9403 (make-local-variable 'minor-mode-alist)
9404 (or (assq 'gnus-show-mime minor-mode-alist)
9405 (setq minor-mode-alist
9406 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
9407 (use-local-map gnus-article-mode-map)
9408 (make-local-variable 'page-delimiter)
9409 (setq page-delimiter gnus-page-delimiter)
9410 (buffer-disable-undo (current-buffer))
9411 (setq buffer-read-only t) ;Disable modification
9412 (run-hooks 'gnus-article-mode-hook))
9414 (defun gnus-article-setup-buffer ()
9415 "Initialize article mode buffer."
9416 (or (get-buffer gnus-article-buffer)
9418 (set-buffer (get-buffer-create gnus-article-buffer))
9419 (gnus-add-current-to-buffer-list)
9420 (gnus-article-mode))))
9422 (defun gnus-request-article-this-buffer (article &optional group)
9423 "Get an article and insert it into this buffer."
9424 (setq group (or group gnus-newsgroup-name))
9425 ;; Using `gnus-request-article' directly will insert the article into
9426 ;; `nntp-server-buffer' - so we'll save some time by not having to
9427 ;; copy it from the server buffer into the article buffer.
9429 ;; We only request an article by message-id when we do not have the
9430 ;; headers for it, so we'll have to get those.
9431 (and (stringp article)
9432 (let ((gnus-override-method gnus-refer-article-method))
9433 (gnus-read-header article)))
9435 ;; If the article number is negative, that means that this article
9436 ;; doesn't belong in this newsgroup (possibly), so we find its
9437 ;; message-id and request it by id instead of number.
9438 (if (and (numberp article) (< article 0))
9440 (set-buffer gnus-summary-buffer)
9441 (let ((header (gnus-gethash (int-to-string article)
9442 gnus-newsgroup-headers-hashtb-by-number)))
9443 (if (vectorp header)
9444 ;; It's a real article.
9445 (setq article (header-id header))
9446 ;; It is an extracted pseudo-article.
9448 (gnus-request-pseudo-article header)))))
9449 ;; Get the article and into the article buffer.
9453 (let ((gnus-override-method
9454 (and (stringp article) gnus-refer-article-method)))
9455 (and (gnus-request-article article group (current-buffer))
9459 (defun gnus-read-header (id)
9460 "Read the headers of article ID and enter them into the Gnus system."
9461 (or gnus-newsgroup-headers-hashtb-by-number
9462 (gnus-make-headers-hashtable-by-number))
9464 (if (not (setq header
9465 (car (if (let ((gnus-nov-is-evil t))
9466 (gnus-retrieve-headers
9467 (list id) gnus-newsgroup-name))
9468 (gnus-get-newsgroup-headers)))))
9471 (header-set-number header gnus-reffed-article-number))
9472 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
9473 (gnus-sethash (int-to-string (header-number header)) header
9474 gnus-newsgroup-headers-hashtb-by-number)
9476 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
9477 (setq gnus-current-headers header)
9480 (defun gnus-article-prepare (article &optional all-headers header)
9481 "Prepare ARTICLE in article mode buffer.
9482 ARTICLE should either be an article number or a Message-ID.
9483 If ARTICLE is an id, HEADER should be the article headers.
9484 If ALL-HEADERS is non-nil, no headers are hidden."
9486 ;; Make sure we start in a summary buffer.
9487 (or (eq major-mode 'gnus-summary-mode)
9488 (set-buffer gnus-summary-buffer))
9489 (setq gnus-summary-buffer (current-buffer))
9490 ;; Make sure the connection to the server is alive.
9491 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
9493 (gnus-check-news-server
9494 (gnus-find-method-for-group gnus-newsgroup-name))
9495 (gnus-request-group gnus-newsgroup-name t)))
9496 (or gnus-newsgroup-headers-hashtb-by-number
9497 (gnus-make-headers-hashtable-by-number))
9498 (let* ((article (if header (header-number header) article))
9499 (summary-buffer (current-buffer))
9500 (internal-hook gnus-article-internal-prepare-hook)
9501 (bookmark (cdr (assq article gnus-newsgroup-bookmarks)))
9502 (group gnus-newsgroup-name)
9505 (gnus-article-setup-buffer)
9506 (set-buffer gnus-article-buffer)
9507 (let ((buffer-read-only nil))
9508 (if (not (setq result (gnus-request-article-this-buffer
9510 ;; There is no such article.
9513 (set-buffer gnus-summary-buffer)
9514 (setq gnus-current-article 0)
9515 (and (numberp article)
9516 (gnus-summary-mark-as-read article gnus-canceled-mark))
9517 (message "No such article (may be canceled)")
9519 (setq gnus-article-current nil)
9521 (if (not (eq result 'article))
9524 (set-buffer summary-buffer)
9525 (setq gnus-last-article gnus-current-article
9526 gnus-newsgroup-history (cons gnus-current-article
9527 gnus-newsgroup-history)
9528 gnus-current-article 0
9529 gnus-current-headers nil
9530 gnus-article-current nil)
9531 (gnus-configure-windows 'article)
9532 (gnus-set-global-variables))
9533 (gnus-set-mode-line 'article))
9534 ;; The result from the `request' was an actual article -
9535 ;; or at least some text that is now displayed in the
9537 (if (and (numberp article)
9538 (not (eq article gnus-current-article)))
9539 ;; Seems like a new article has been selected.
9540 ;; `gnus-current-article' must be an article number.
9542 (set-buffer summary-buffer)
9543 (setq gnus-last-article gnus-current-article
9544 gnus-newsgroup-history (cons gnus-current-article
9545 gnus-newsgroup-history)
9546 gnus-current-article article
9547 gnus-current-headers
9548 (gnus-get-header-by-number gnus-current-article)
9549 gnus-article-current
9550 (cons gnus-newsgroup-name gnus-current-article))
9551 (run-hooks 'gnus-mark-article-hook)
9552 (gnus-set-mode-line 'summary)
9554 (run-hooks 'gnus-visual-mark-article-hook))
9555 ;; Set the global newsgroup variables here.
9556 ;; Suggested by Jim Sisolak
9557 ;; <sisolak@trans4.neep.wisc.edu>.
9558 (gnus-set-global-variables)))
9559 ;; gnus-have-all-headers must be either T or NIL.
9560 (setq gnus-have-all-headers
9561 (not (not (or all-headers gnus-show-all-headers))))
9562 ;; Hooks for getting information from the article.
9563 ;; This hook must be called before being narrowed.
9564 (run-hooks 'internal-hook)
9565 (run-hooks 'gnus-article-prepare-hook)
9566 ;; Decode MIME message.
9567 (if (and gnus-show-mime
9568 (gnus-fetch-field "Mime-Version"))
9569 (funcall gnus-show-mime-method))
9570 ;; Perform the article display hooks.
9571 (let ((buffer-read-only nil))
9572 (run-hooks 'gnus-article-display-hook))
9574 (goto-char (point-min))
9575 (and gnus-break-pages (gnus-narrow-to-page))
9576 (gnus-set-mode-line 'article)
9577 (gnus-configure-windows 'article)
9580 (get-buffer-window gnus-article-buffer) (point-min))
9583 (message "Moved to bookmark")
9584 (search-forward "\n\n" nil t)
9585 (forward-line bookmark)))
9588 (defun gnus-article-show-all-headers ()
9589 "Show all article headers in article mode buffer."
9591 (setq gnus-have-all-headers t)
9592 (gnus-article-setup-buffer)
9593 (set-buffer gnus-article-buffer)
9594 (let ((buffer-read-only nil))
9595 (remove-text-properties 1 (point-max) '(invisible t)))))
9597 (defun gnus-article-hide-headers-if-wanted ()
9598 "Hide unwanted headers if `gnus-have-all-headers' is nil.
9599 Provided for backwards compatability."
9600 (or gnus-have-all-headers
9601 (gnus-article-hide-headers)))
9603 (defun gnus-article-hide-headers (&optional delete)
9604 "Hide unwanted headers and possibly sort them as well."
9607 (set-buffer gnus-article-buffer)
9609 (let ((sorted gnus-sorted-header-list)
9610 (buffer-read-only nil)
9611 want want-list beg want-l)
9612 ;; First we narrow to just the headers.
9615 ;; Hide any "From " lines at the beginning of (mail) articles.
9616 (while (looking-at rmail-unix-mail-delimiter)
9619 (add-text-properties 1 (point) '(invisible t)))
9620 ;; Then treat the rest of the header lines.
9623 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
9624 ;; Then we use the two regular expressions
9625 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
9626 ;; select which header lines is to remain visible in the
9629 (while (re-search-forward "^[^ \t]*:" nil t)
9631 ;; We add the headers we want to keep to a list and delete
9632 ;; them from the buffer.
9633 (if (or (and (stringp gnus-visible-headers)
9634 (looking-at gnus-visible-headers))
9635 (and (not (stringp gnus-visible-headers))
9636 (stringp gnus-ignored-headers)
9637 (not (looking-at gnus-ignored-headers))))
9641 ;; Be sure to get multi-line headers...
9642 (re-search-forward "^[^ \t]*:" nil t)
9645 (cons (buffer-substring beg (point)) want-list))
9646 (delete-region beg (point))
9649 ;; Next we perform the sorting by looking at
9650 ;; `gnus-sorted-header-list'.
9652 (while (and sorted want-list)
9653 (setq want-l want-list)
9655 (not (string-match (car sorted) (car want-l))))
9656 (setq want-l (cdr want-l)))
9659 (insert (car want-l))
9660 (setq want-list (delq (car want-l) want-list))))
9661 (setq sorted (cdr sorted)))
9662 ;; Any headers that were not matched by the sorted list we
9663 ;; just tack on the end of the visible header list.
9665 (insert (car want-list))
9666 (setq want-list (cdr want-list)))
9667 ;; And finally we make the unwanted headers invisible.
9669 (delete-region (point) (point-max))
9670 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
9671 (add-text-properties (point) (point-max) '(invisible t)))))))
9673 (defun gnus-article-hide-signature ()
9674 "Hides the signature in an article.
9675 It does this by hiding everyting after \"^-- *$\", which is what all
9676 signatures should be preceded by. Note that this may mean that parts
9677 of an article may disappear if the article has such a line in the
9678 middle of the text."
9681 (set-buffer gnus-article-buffer)
9682 (let ((buffer-read-only nil))
9683 (goto-char (point-max))
9684 (if (re-search-backward "^-- *$" nil t)
9686 (add-text-properties (point) (point-max) '(invisible t)))))))
9688 (defun gnus-article-hide-citation ()
9689 "Hide all cited text.
9690 This function uses the famous, extremely intelligent \"shoot in foot\"
9691 algorithm - which is simply deleting all lines that start with
9692 \">\". Your mileage may vary. If you come up with anything better,
9693 please do mail it to me."
9696 (set-buffer gnus-article-buffer)
9697 (let ((buffer-read-only nil))
9699 (search-forward "\n\n" nil t)
9701 (if (looking-at ">")
9702 (add-text-properties
9703 (point) (save-excursion (forward-line 1) (point))
9705 (forward-line 1)))))
9707 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
9708 (defun gnus-article-treat-overstrike ()
9709 "Translate overstrikes into bold text."
9712 (set-buffer gnus-article-buffer)
9713 (let ((buffer-read-only nil))
9714 (while (search-forward "\b" nil t)
9715 (let ((next (following-char))
9716 (previous (char-after (- (point) 2))))
9717 (cond ((eq next previous)
9718 (delete-region (- (point) 2) (point))
9719 (put-text-property (point) (1+ (point))
9722 (delete-region (1- (point)) (1+ (point)))
9723 (put-text-property (1- (point)) (point)
9726 (delete-region (- (point) 2) (point))
9727 (put-text-property (point) (1+ (point))
9728 'face 'underline))))))))
9730 (defun gnus-article-word-wrap ()
9731 "Format too long lines."
9734 (set-buffer gnus-article-buffer)
9735 (let ((buffer-read-only nil))
9737 (search-forward "\n\n" nil t)
9739 (let ((paragraph-start "^\\W"))
9741 (and (>= (current-column) (window-width))
9742 (/= (preceding-char) ?:)
9743 (fill-paragraph nil))
9744 (end-of-line 2))))))
9746 (defun gnus-article-remove-cr ()
9747 "Remove carriage returns from an article."
9750 (set-buffer gnus-article-buffer)
9751 (let ((buffer-read-only nil))
9752 (goto-char (point-min))
9753 (while (search-forward "\r" nil t)
9754 (replace-match "")))))
9756 (defun gnus-article-display-x-face ()
9757 "Look for an X-Face header and display it if present."
9760 (set-buffer gnus-article-buffer)
9761 (goto-char (point-min))
9762 (if (or (not gnus-article-x-face-command)
9763 (not (re-search-forward "^X-Face: " nil t)))
9770 (while (and (looking-at "[ \t]")
9771 (zerop (forward-line 1))))
9773 (command gnus-article-x-face-command))
9774 (if (symbolp command)
9775 (and (or (fboundp command) (error "%s is not a function" command))
9776 (funcall command face))
9777 (let ((process (start-process "gnus-x-face" nil "sh" "-c" command)))
9780 (process-send-string process face)
9781 (process-send-eof process))
9782 (error "Couldn't start process"))))))))
9784 (defun gnus-article-de-quoted-unreadable ()
9785 "Do a naive translation of a quoted-printable-encoded article.
9786 This is in no way, shape or form meant as a replacement for real MIME
9787 processing, but is simply a stop-gap measure until MIME support is
9792 (set-buffer gnus-article-buffer)
9793 (let ((buffer-read-only nil))
9795 (goto-char (point-min))
9796 (while (re-search-forward "=[0-9A-F][0-9A-F]" nil t)
9800 (* 16 (gnus-hex-char-to-integer
9801 (char-after (1+ (match-beginning 0)))))
9802 (gnus-hex-char-to-integer
9803 (char-after (1- (match-end 0))))))))))))
9805 ;; Taken from hexl.el.
9806 (defun gnus-hex-char-to-integer (character)
9807 "Take a char and return its value as if it was a hex digit."
9808 (if (and (>= character ?0) (<= character ?9))
9810 (let ((ch (logior character 32)))
9811 (if (and (>= ch ?a) (<= ch ?f))
9813 (error (format "Invalid hex digit `%c'." ch))))))
9817 (defun gnus-output-to-rmail (file-name)
9818 "Append the current article to an Rmail file named FILE-NAME."
9820 ;; Most of these codes are borrowed from rmailout.el.
9821 (setq file-name (expand-file-name file-name))
9822 (setq rmail-default-rmail-file file-name)
9823 (let ((artbuf (current-buffer))
9824 (tmpbuf (get-buffer-create " *Gnus-output*")))
9826 (or (get-file-buffer file-name)
9827 (file-exists-p file-name)
9828 (if (gnus-yes-or-no-p
9829 (concat "\"" file-name "\" does not exist, create it? "))
9830 (let ((file-buffer (create-file-buffer file-name)))
9832 (set-buffer file-buffer)
9833 (rmail-insert-rmail-file-header)
9834 (let ((require-final-newline nil))
9835 (write-region (point-min) (point-max) file-name t 1)))
9836 (kill-buffer file-buffer))
9837 (error "Output file does not exist")))
9839 (buffer-disable-undo (current-buffer))
9841 (insert-buffer-substring artbuf)
9842 (gnus-convert-article-to-rmail)
9843 ;; Decide whether to append to a file or to an Emacs buffer.
9844 (let ((outbuf (get-file-buffer file-name)))
9846 (append-to-file (point-min) (point-max) file-name)
9847 ;; File has been visited, in buffer OUTBUF.
9849 (let ((buffer-read-only nil)
9850 (msg (and (boundp 'rmail-current-message)
9851 rmail-current-message)))
9852 ;; If MSG is non-nil, buffer is in RMAIL mode.
9855 (narrow-to-region (point-max) (point-max))))
9856 (insert-buffer-substring tmpbuf)
9859 (goto-char (point-min))
9861 (search-backward "\^_")
9862 (narrow-to-region (point) (point-max))
9863 (goto-char (1+ (point-min)))
9864 (rmail-count-new-messages t)
9865 (rmail-show-message msg)))))))
9866 (kill-buffer tmpbuf)))
9868 (defun gnus-output-to-file (file-name)
9869 "Append the current article to a file named FILE-NAME."
9870 (setq file-name (expand-file-name file-name))
9871 (let ((artbuf (current-buffer))
9872 (tmpbuf (get-buffer-create " *Gnus-output*")))
9875 (buffer-disable-undo (current-buffer))
9877 (insert-buffer-substring artbuf)
9878 ;; Append newline at end of the buffer as separator, and then
9880 (goto-char (point-max))
9882 (append-to-file (point-min) (point-max) file-name))
9883 (kill-buffer tmpbuf)))
9885 (defun gnus-convert-article-to-rmail ()
9886 "Convert article in current buffer to Rmail message format."
9887 (let ((buffer-read-only nil))
9888 ;; Convert article directly into Babyl format.
9889 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
9890 (goto-char (point-min))
9891 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
9892 (while (search-forward "\n\^_" nil t) ;single char
9893 (replace-match "\n^_")) ;2 chars: "^" and "_"
9894 (goto-char (point-max))
9897 (defun gnus-narrow-to-page (&optional arg)
9898 "Make text outside current page invisible except for page delimiter.
9899 A numeric arg specifies to move forward or backward by that many pages,
9900 thus showing a page other than the one point was originally in."
9902 (setq arg (if arg (prefix-numeric-value arg) 0))
9904 (forward-page -1) ;Beginning of current page.
9909 (forward-page (1- arg))))
9910 ;; Find the end of the page.
9912 ;; If we stopped due to end of buffer, stay there.
9913 ;; If we stopped after a page delimiter, put end of restriction
9914 ;; at the beginning of that line.
9915 ;; These are commented out.
9916 ;; (if (save-excursion (beginning-of-line)
9917 ;; (looking-at page-delimiter))
9918 ;; (beginning-of-line))
9919 (narrow-to-region (point)
9921 ;; Find the top of the page.
9923 ;; If we found beginning of buffer, stay there.
9924 ;; If extra text follows page delimiter on same line,
9926 ;; Otherwise, show text starting with following line.
9927 (if (and (eolp) (not (bobp)))
9931 (defun gnus-gmt-to-local ()
9932 "Rewrite Date header described in GMT to local in current buffer.
9933 Intended to be used with gnus-article-prepare-hook."
9937 (goto-char (point-min))
9938 (narrow-to-region (point-min)
9939 (progn (search-forward "\n\n" nil 'move) (point)))
9940 (goto-char (point-min))
9941 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
9942 (let ((buffer-read-only nil)
9943 (date (buffer-substring (match-beginning 1) (match-end 1))))
9944 (delete-region (match-beginning 1) (match-end 1))
9946 (timezone-make-date-arpa-standard
9947 date nil (current-time-zone))))))))
9950 ;; Article mode commands
9952 (defun gnus-article-next-page (lines)
9953 "Show next page of current article.
9954 If end of article, return non-nil. Otherwise return nil.
9955 Argument LINES specifies lines to be scrolled up."
9957 (move-to-window-line -1)
9958 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
9961 (and (pos-visible-in-window-p) ;Not continuation line.
9963 ;; Nothing in this page.
9964 (if (or (not gnus-break-pages)
9967 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
9969 (gnus-narrow-to-page 1) ;Go to next page.
9971 ;; More in this page.
9975 ;; Long lines may cause an end-of-buffer error.
9976 (goto-char (point-max))))
9979 (defun gnus-article-prev-page (lines)
9980 "Show previous page of current article.
9981 Argument LINES specifies lines to be scrolled down."
9983 (move-to-window-line 0)
9984 (if (and gnus-break-pages
9986 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
9988 (gnus-narrow-to-page -1) ;Go to previous page.
9989 (goto-char (point-max))
9991 (scroll-down lines)))
9993 (defun gnus-article-refer-article ()
9994 "Read article specified by message-id around point."
9996 (search-forward ">" nil t) ;Move point to end of "<....>".
9997 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
9999 (buffer-substring (match-beginning 1) (match-end 1))))
10000 (set-buffer gnus-summary-buffer)
10001 (gnus-summary-refer-article message-id))
10002 (error "No references around point")))
10004 (defun gnus-article-mail (yank)
10005 "Send a reply to the address near point.
10006 If YANK is non-nil, include the original article."
10010 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
10011 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
10014 (switch-to-buffer gnus-summary-buffer)
10015 (funcall gnus-mail-reply-method yank address)))))
10017 (defun gnus-article-mail-with-original ()
10018 "Send a reply to the address near point and include the original article."
10020 (gnus-article-mail 'yank))
10022 (defun gnus-article-show-summary ()
10023 "Reconfigure windows to show summary buffer."
10025 (gnus-configure-windows 'article)
10026 (pop-to-buffer gnus-summary-buffer)
10027 (gnus-summary-goto-subject gnus-current-article))
10029 (defun gnus-article-describe-briefly ()
10030 "Describe article mode commands briefly."
10033 (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")))
10035 (defun gnus-article-summary-command ()
10036 "Execute the last keystroke in the summary buffer."
10039 (let ((obuf (current-buffer))
10040 (owin (current-window-configuration)))
10041 (switch-to-buffer gnus-summary-buffer 'norecord)
10042 (execute-kbd-macro (this-command-keys))
10044 (let ((npoint (point)))
10045 (set-window-configuration owin)
10046 (set-window-start (get-buffer-window (current-buffer)) (point)))))
10048 ;; caesar-region written by phr@prep.ai.mit.edu Nov 86
10049 ;; Modified by tower@prep Nov 86
10050 ;; Modified by umerin@flab.flab.Fujitsu.JUNET for ROT47.
10052 (defun gnus-caesar-region (&optional n)
10053 "Caesar rotation of region by N, default 13, for decrypting netnews.
10054 ROT47 will be performed for Japanese text in any case."
10055 (interactive (if current-prefix-arg ; Was there a prefix arg?
10056 (list (prefix-numeric-value current-prefix-arg))
10058 (cond ((not (numberp n)) (setq n 13))
10059 (t (setq n (mod n 26)))) ;canonicalize N
10060 (if (not (zerop n)) ; no action needed for a rot of 0
10062 (if (or (not (boundp 'caesar-translate-table))
10063 (not caesar-translate-table)
10064 (/= (aref caesar-translate-table ?a) (+ ?a n)))
10066 (lower "abcdefghijklmnopqrstuvwxyz")
10068 (message "Building caesar-translate-table...")
10069 (setq caesar-translate-table (make-vector 256 0))
10071 (aset caesar-translate-table i i)
10073 (setq lower (concat lower lower)
10074 upper (upcase lower)
10077 (aset caesar-translate-table (+ ?a i) (aref lower (+ i n)))
10078 (aset caesar-translate-table (+ ?A i) (aref upper (+ i n)))
10080 ;; ROT47 for Japanese text.
10081 ;; Thanks to ichikawa@flab.fujitsu.junet.
10083 (let ((t1 (logior ?O 128))
10084 (t2 (logior ?! 128))
10085 (t3 (logior ?~ 128)))
10087 (aset caesar-translate-table i
10088 (let ((v (aref caesar-translate-table i)))
10089 (if (<= v t1) (if (< v t2) v (+ v 47))
10090 (if (<= v t3) (- v 47) v))))
10092 (message "Building caesar-translate-table... done")))
10093 (let ((from (region-beginning))
10096 (setq str (buffer-substring from to))
10097 (setq len (length str))
10099 (aset str i (aref caesar-translate-table (aref str i)))
10102 (delete-region from to)
10106 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
10109 (defalias 'gnus-batch-kill 'gnus-batch-score)
10111 (defun gnus-batch-score ()
10112 "Run batched scoring.
10113 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
10114 Newsgroups is a list of strings in Bnews format. If you want to score
10115 the comp hierarchy, you'd say \"comp.all\". If you would not like to
10116 score the alt hierarchy, you'd say \"!alt.all\"."
10119 (gnus-parse-n-options
10120 (apply (function concat)
10121 (mapcar (lambda (g) (concat g " "))
10122 command-line-args-left))))
10123 (gnus-expert-user t)
10124 (nnmail-spool-file nil)
10125 (gnus-use-dribble-file nil)
10126 (yes (car yes-and-no))
10127 (no (cdr yes-and-no))
10128 group subscribed newsrc entry
10129 ;; Disable verbose message.
10130 gnus-novice-user gnus-large-newsgroup)
10131 ;; Eat all arguments.
10132 (setq command-line-args-left nil)
10135 ;; Apply kills to specified newsgroups in command line arguments.
10136 (setq newsrc (cdr gnus-newsrc-assoc))
10138 (setq group (car (car newsrc)))
10139 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
10140 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
10142 (or (eq (car entry) t)
10143 (not (zerop (car entry)))))
10144 (if yes (string-match yes group) t)
10145 (or (null no) (not (string-match no group))))
10147 (gnus-summary-read-group group nil t)
10148 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
10149 (gnus-summary-exit))))
10150 (setq newsrc (cdr newsrc)))
10152 (switch-to-buffer gnus-group-buffer)
10153 (gnus-group-save-newsrc)))
10155 (defun gnus-apply-kill-file ()
10156 "Apply a kill file to the current newsgroup.
10157 Returns the number of articles marked as read."
10158 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
10159 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
10160 (gnus-apply-kill-file-internal)
10163 (defun gnus-kill-save-kill-buffer ()
10165 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
10166 (if (get-file-buffer file)
10168 (set-buffer (get-file-buffer file))
10169 (and (buffer-modified-p) (save-buffer))
10170 (kill-buffer (current-buffer)))))))
10172 (defvar gnus-kill-file-name "KILL"
10173 "Suffix of the kill files.")
10175 (defun gnus-newsgroup-kill-file (newsgroup)
10176 "Return the name of a kill file name for NEWSGROUP.
10177 If NEWSGROUP is nil, return the global kill file name instead."
10178 (cond ((or (null newsgroup)
10179 (string-equal newsgroup ""))
10180 ;; The global KILL file is placed at top of the directory.
10181 (expand-file-name gnus-kill-file-name
10182 (or gnus-kill-files-directory "~/News")))
10183 ((gnus-use-long-file-name 'not-kill)
10184 ;; Append ".KILL" to newsgroup name.
10185 (expand-file-name (concat newsgroup "." gnus-kill-file-name)
10186 (or gnus-kill-files-directory "~/News")))
10188 ;; Place "KILL" under the hierarchical directory.
10189 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
10190 "/" gnus-kill-file-name)
10191 (or gnus-kill-files-directory "~/News")))))
10195 ;;; Gnus Score Files
10198 ;; All score code written by Per Abrahamsen <abraham@iesd.auc.dk>.
10200 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10201 (defun gnus-score-set-mark-below (score)
10202 "Automatically mark articles with score below SCORE as read."
10204 (list (or (and current-prefix-arg (prefix-numeric-value current-prefix-arg))
10205 (string-to-int (read-string "Mark below: ")))))
10206 (setq score (or score gnus-summary-default-score 0))
10207 (gnus-score-set 'mark (list score))
10208 (gnus-score-set 'touched '(t))
10209 (setq gnus-summary-mark-below score)
10210 (gnus-summary-update-lines))
10212 (defun gnus-score-set-expunge-below (score)
10213 "Automatically expunge articles with score below SCORE."
10215 (list (or (and current-prefix-arg (prefix-numeric-value current-prefix-arg))
10216 (string-to-int (read-string "Expunge below: ")))))
10217 (setq score (or score gnus-summary-default-score 0))
10218 (gnus-score-set 'expunge (list score))
10219 (gnus-score-set 'touched '(t)))
10221 (defun gnus-score-default (level)
10222 (if level (prefix-numeric-value level)
10223 gnus-score-interactive-default-score))
10225 (defun gnus-score-set (symbol value &optional alist)
10226 ;; Set SYMBOL to VALUE in ALIST.
10231 (gnus-score-load (gnus-score-file-name gnus-newsgroup-name))
10232 gnus-score-alist)))
10233 (entry (assoc symbol alist)))
10234 (cond ((gnus-score-get 'read-only alist)
10235 ;; This is a read-only score file, so we do nothing.
10238 (setcdr entry value))
10240 (error "Empty alist"))
10243 (cons (cons symbol value) (cdr alist)))))))
10245 (defun gnus-score-get (symbol &optional alist)
10246 ;; Get SYMBOL's definition in ALIST.
10252 (gnus-score-file-name gnus-newsgroup-name))
10253 gnus-score-alist)))))
10255 (defun gnus-score-change-score-file (file)
10256 "Change current score alist."
10258 (list (completing-read "Score file: " gnus-score-cache)))
10259 (setq gnus-current-score-file file)
10260 (gnus-score-load-file file)
10261 (gnus-set-mode-line 'summary))
10263 (defun gnus-score-edit-alist (file)
10264 "Edit the current score alist."
10265 (interactive (list gnus-current-score-file))
10266 (and (buffer-name gnus-summary-buffer) (gnus-score-save))
10267 (setq gnus-winconf-edit-score (current-window-configuration))
10268 (gnus-configure-windows 'article)
10269 (pop-to-buffer (find-file-noselect file))
10270 (message (substitute-command-keys
10271 "\\<gnus-score-mode-map>\\[gnus-score-edit-done] to save edits"))
10274 (defun gnus-score-edit-file (file)
10275 "Edit a score file."
10277 (list (read-file-name "Edit score file: " gnus-kill-files-directory)))
10278 (and (buffer-name gnus-summary-buffer) (gnus-score-save))
10279 (setq gnus-winconf-edit-score (current-window-configuration))
10280 (gnus-configure-windows 'article)
10281 (pop-to-buffer (find-file-noselect file))
10282 (message (substitute-command-keys
10283 "\\<gnus-score-mode-map>\\[gnus-score-edit-done] to save edits"))
10286 (defun gnus-score-load-file (file)
10287 ;; Load score file FILE. Returns a list a retrieved score-alists.
10288 (setq gnus-kill-files-directory (or gnus-kill-files-directory "~/News/"))
10289 (let* ((file (expand-file-name
10290 (or (and (string-match
10291 (concat "^" (expand-file-name
10292 gnus-kill-files-directory))
10293 (expand-file-name file))
10295 (concat gnus-kill-files-directory file))))
10296 (cached (assoc file gnus-score-cache))
10297 (global (member file gnus-internal-global-score-files))
10300 ;; The score file was already loaded.
10301 (setq alist (cdr cached))
10302 ;; We load the score file.
10303 (setq gnus-score-alist nil)
10304 (setq alist (gnus-score-load-score-alist file))
10305 ;; We add '(touched) to the alist to signify that it hasn't been
10307 (or (assq 'touched alist) (setq alist (cons (list 'touched nil) alist)))
10308 ;; If it is a global score file, we make it read-only.
10310 (not (assq 'read-only alist))
10311 (setq alist (cons (list 'read-only t) alist)))
10313 (setq gnus-score-cache
10314 (cons (cons file alist) gnus-score-cache)))
10315 ;; If there are actual scores in the alist, we add it to the
10316 ;; return value of this function.
10317 (if (memq t (mapcar (lambda (e) (stringp (car e))) alist))
10318 (setq lists (list alist)))
10319 ;; Treat the other possible atoms in the score alist.
10320 (let ((mark (car (gnus-score-get 'mark alist)))
10321 (expunge (car (gnus-score-get 'expunge alist)))
10323 (car (gnus-score-get 'mark-and-expunge alist)))
10324 (read-only (gnus-score-get 'read-only alist))
10325 (files (gnus-score-get 'files alist))
10326 (exclude-files (gnus-score-get 'exclude-files alist))
10327 (orphan (gnus-score-get 'orphan alist))
10328 (eval (gnus-score-get 'eval alist)))
10329 ;; We do not respect eval and files atoms from global score
10331 (and files (not global)
10332 (setq lists (apply 'append lists
10333 (mapcar (lambda (file)
10334 (gnus-score-load-file file))
10336 (and eval (not global) (eval eval))
10337 (setq gnus-scores-exclude-files exclude-files)
10338 (if orphan (setq gnus-orphan-score (car orphan)))
10339 (setq gnus-summary-mark-below
10340 (or mark mark-and-expunge gnus-summary-mark-below))
10341 (setq gnus-summary-expunge-below
10342 (or expunge mark-and-expunge gnus-summary-expunge-below)))
10343 (setq gnus-current-score-file file)
10344 (setq gnus-score-alist alist)
10347 (defun gnus-score-load (file)
10348 ;; Load score FILE.
10349 (let ((cache (assoc file gnus-score-cache)))
10351 (setq gnus-score-alist (cdr cache))
10352 (setq gnus-score-alist nil)
10353 (gnus-score-load-score-alist file)
10354 (or gnus-score-alist
10355 (setq gnus-score-alist (copy-alist '((touched nil)))))
10356 (setq gnus-score-cache
10357 (cons (cons file gnus-score-alist) gnus-score-cache)))))
10359 (defun gnus-score-remove-from-cache (file)
10360 (setq gnus-score-cache
10361 (delq (assoc file gnus-score-cache) gnus-score-cache)))
10363 (defun gnus-score-load-score-alist (file)
10365 (if (file-readable-p file)
10368 (set-buffer (get-buffer-create " *gnus work*"))
10369 (buffer-disable-undo (current-buffer))
10371 (insert-file-contents file)
10372 (goto-char (point-min))
10373 ;; Only do the loading if the score file isn't empty.
10374 (if (save-excursion (re-search-forward "[()0-9a-zA-Z]" nil t))
10377 (read (current-buffer))
10380 (message "Problem with score file %s" file)
10384 (if (eq (car alist) 'setq)
10385 (setq gnus-score-alist (gnus-score-transform-old-to-new alist))
10386 (setq gnus-score-alist alist))
10387 (setq gnus-score-alist
10388 (gnus-score-check-syntax gnus-score-alist)))
10389 (setq gnus-score-alist nil))))
10391 (defun gnus-score-check-syntax (alist)
10395 ((not (consp alist))
10396 (message "Score file is not a list: %s" alist)
10402 (while (and a (not err))
10403 (cond ((not (listp (car a)))
10404 (message "Illegal score element: %s" (car a))
10406 ((and (stringp (car (car a)))
10407 (not (listp (nth 1 (car a)))))
10408 (message "Illegal header match: %s" (nth 1 (car a)))
10411 (setq a (cdr a)))))
10418 (defun gnus-score-transform-old-to-new (alist)
10419 (let* ((alist (nth 2 alist))
10421 (if (eq (car alist) 'quote)
10422 (setq alist (nth 1 alist)))
10424 (setq entry (car alist))
10425 (if (stringp (car entry))
10426 (let ((scor (cdr entry)))
10427 (setq out (cons entry out))
10430 (list (car (car scor)) (nth 2 (car scor))
10431 (and (nth 3 (car scor))
10432 (gnus-day-number (nth 3 (car scor))))
10433 (if (nth 1 (car scor)) 'r 's)))
10434 (setq scor (cdr scor))))
10435 (setq out (cons (if (not (listp (cdr entry)))
10436 (list (car entry) (cdr entry))
10439 (setq alist (cdr alist)))
10440 (cons (list 'touched t) (nreverse out))))
10442 (defun gnus-score-save ()
10443 ;; Save all SCORE information.
10444 (let ((cache gnus-score-cache))
10446 (setq gnus-score-alist nil)
10447 (set-buffer (get-buffer-create "*Score*"))
10448 (buffer-disable-undo (current-buffer))
10449 (let (entry score file)
10451 (setq entry (car cache)
10455 (if (or (not (equal (gnus-score-get 'touched score) '(t)))
10456 (gnus-score-get 'read-only score)
10457 (not (file-writable-p file)))
10459 (setq score (delq (assq 'touched score) score))
10461 (let (emacs-lisp-mode-hook)
10462 (pp score (current-buffer)))
10463 (gnus-make-directory (file-name-directory file))
10464 (write-region (point-min) (point-max) file nil 'silent))))
10465 (kill-buffer (current-buffer)))))
10467 (defun gnus-score-headers ()
10468 ;; Score `gnus-newsgroup-headers'.
10469 (let ((func gnus-score-find-score-files-function)
10470 score-files scores)
10471 (and func (not (listp func))
10472 (setq func (list func)))
10473 ;; Go through all the functions for finding score files (or actual
10474 ;; scores) and add them to a list.
10476 (and (symbolp (car func))
10477 (fboundp (car func))
10479 (nconc score-files (funcall (car func) gnus-newsgroup-name))))
10480 (setq func (cdr func)))
10481 ;; PLM: probably this is not the best place to clear orphan-score
10482 (setq gnus-orphan-score nil)
10483 ;; Load the SCORE files.
10485 (if (stringp (car score-files))
10486 ;; It is a string, which means that it's a score file name,
10487 ;; so we load the score file and add the score alist to
10488 ;; the list of alists.
10489 (setq scores (nconc (gnus-score-load-file (car score-files)) scores))
10490 ;; It is an alist, so we just add it to the list directly.
10491 (setq scores (nconc (car score-files) scores)))
10492 (setq score-files (cdr score-files)))
10493 ;; Prune the score files that are to be excluded, if any.
10494 (if (not gnus-scores-exclude-files)
10499 (and (setq c (rassq (car s) gnus-score-cache))
10500 (member (car c) gnus-scores-exclude-files)
10501 (setq scores (delq (car s) scores)))
10502 (setq s (cdr s)))))
10503 (if (not (and gnus-summary-default-score
10505 (> (length gnus-newsgroup-headers)
10506 (length gnus-newsgroup-scored))))
10508 (let* ((entries gnus-header-index)
10509 (now (gnus-day-number (current-time-string)))
10510 (expire (- now gnus-score-expiry-days))
10511 (headers gnus-newsgroup-headers)
10513 (message "Scoring...")
10514 ;; Create articles, an alist of the form `(HEADER . SCORE)'.
10516 (setq header (car headers)
10517 headers (cdr headers))
10518 ;; WARNING: The assq makes the function O(N*S) while it could
10519 ;; be written as O(N+S), where N is (length gnus-newsgroup-headers)
10520 ;; and S is (length gnus-newsgroup-scored).
10521 (or (assq (header-number header) gnus-newsgroup-scored)
10522 (setq gnus-scores-articles ;Total of 2 * N cons-cells used.
10523 (cons (cons header (or gnus-summary-default-score 0))
10524 gnus-scores-articles))))
10527 (set-buffer (get-buffer-create "*Headers*"))
10528 (buffer-disable-undo (current-buffer))
10530 (if gnus-orphan-score
10532 (setq gnus-score-index
10533 (nth 1 (assoc "references" gnus-header-index)))
10534 (gnus-score-orphans gnus-orphan-score)))
10535 ;; Run each header through the score process.
10537 (setq entry (car entries)
10538 header (nth 0 entry)
10539 entries (cdr entries))
10540 (setq gnus-score-index (nth 1 (assoc header gnus-header-index)))
10541 (if (< 0 (apply 'max (mapcar
10543 (length (gnus-score-get header score)))
10545 (funcall (nth 2 entry) scores header now expire)))
10546 ;; Remove the buffer.
10547 (kill-buffer (current-buffer)))
10549 ;; Add articles to `gnus-newsgroup-scored'.
10550 (while gnus-scores-articles
10551 (or (= gnus-summary-default-score (cdr (car gnus-scores-articles)))
10552 (setq gnus-newsgroup-scored
10553 (cons (cons (header-number
10554 (car (car gnus-scores-articles)))
10555 (cdr (car gnus-scores-articles)))
10556 gnus-newsgroup-scored)))
10557 (setq gnus-scores-articles (cdr gnus-scores-articles)))
10559 (message "Scoring...done")))))
10562 (defun gnus-get-new-thread-ids (articles)
10563 (let ((index (nth 1 (assoc "message-id" gnus-header-index)))
10564 (refind gnus-score-index)
10565 id-list art this tref)
10567 (setq art (car articles)
10568 this (aref (car art) index)
10569 tref (aref (car art) refind)
10570 articles (cdr articles))
10571 (if (string-equal tref "") ;no references line
10572 (setq id-list (cons this id-list))))
10575 ;; Orphan functions written by plm@atcmp.nl (Peter Mutsaers).
10576 (defun gnus-score-orphans (score)
10577 (let ((new-thread-ids (gnus-get-new-thread-ids gnus-scores-articles))
10578 (index (nth 1 (assoc "references" gnus-header-index)))
10579 alike articles art arts this last this-id)
10581 (setq gnus-scores-articles (sort gnus-scores-articles 'gnus-score-string<)
10582 articles gnus-scores-articles)
10584 ;;more or less the same as in gnus-score-string
10587 (setq art (car articles)
10588 this (aref (car art) gnus-score-index)
10589 articles (cdr articles))
10590 ;;completely skip if this is empty (not a child, so not an orphan)
10591 (if (not (string= this ""))
10592 (if (equal last this)
10593 ;; O(N*H) cons-cells used here, where H is the number of
10595 (setq alike (cons art alike))
10598 ;; Insert the line, with a text property on the
10599 ;; terminating newline refering to the articles with
10602 (put-text-property (1- (point)) (point) 'articles alike)))
10603 (setq alike (list art)
10605 (and last ; Bwadr, duplicate code.
10608 (put-text-property (1- (point)) (point) 'articles alike)))
10610 ;; PLM: now delete those lines that contain an entry from new-thread-ids
10611 (while new-thread-ids
10612 (setq this-id (car new-thread-ids)
10613 new-thread-ids (cdr new-thread-ids))
10614 (goto-char (point-min))
10615 (while (search-forward this-id nil t)
10616 ;; found a match. remove this line
10617 (beginning-of-line)
10620 ;; now for each line: update its articles with score by moving to
10621 ;; every end-of-line in the buffer and read the articles property
10622 (goto-char (point-min))
10623 (while (eq 0 (progn
10625 (setq arts (get-text-property (point) 'articles))
10627 (setq art (car arts)
10629 (setcdr art (+ score (cdr art))))
10630 (forward-line))))))
10633 (defun gnus-score-integer (scores header now expire)
10634 (let ((gnus-score-index (nth 1 (assoc header gnus-header-index)))
10635 alike last this art entries alist articles)
10639 (setq alist (car scores)
10640 scores (cdr scores)
10641 entries (assoc header alist))
10642 (while (cdr entries) ;First entry is the header index.
10643 (let* ((rest (cdr entries))
10645 (match (nth 0 kill))
10646 (type (or (nth 3 kill) '>))
10647 (score (or (nth 1 kill) gnus-score-interactive-default-score))
10648 (date (nth 2 kill))
10650 (match-func (if (or (eq type '>) (eq type '<) (eq type '<=)
10651 (eq type '>=) (eq type '=))
10653 (error "Illegal match type: %s" type)))
10654 (articles gnus-scores-articles)
10656 ;; Instead of doing all the clever stuff that
10657 ;; `gnus-score-string' does to minimize searches and stuff,
10658 ;; I will assume that people generally will put so few
10659 ;; matches on numbers that any cleverness will take more
10660 ;; time than one would gain.
10662 (and (funcall match-func match
10663 (or (aref (car (car articles)) gnus-score-index) 0))
10666 (setcdr (car articles) (+ score (cdr (car articles))))))
10667 (setq articles (cdr articles)))
10668 ;; Update expire date
10669 (cond ((null date)) ;Permanent entry.
10670 (found ;Match, update date.
10671 (gnus-score-set 'touched '(t) alist)
10672 (setcar (nthcdr 2 kill) now))
10673 ((< date expire) ;Old entry, remove.
10674 (gnus-score-set 'touched '(t) alist)
10675 (setcdr entries (cdr rest))
10676 (setq rest entries)))
10677 (setq entries rest))))))
10679 (defun gnus-score-date (scores header now expire)
10680 (let ((gnus-score-index (nth 1 (assoc header gnus-header-index)))
10681 alike last this art entries alist articles)
10685 (setq alist (car scores)
10686 scores (cdr scores)
10687 entries (assoc header alist))
10688 (while (cdr entries) ;First entry is the header index.
10689 (let* ((rest (cdr entries))
10691 (match (timezone-make-date-sortable (nth 0 kill)))
10692 (type (or (nth 3 kill) 'before))
10693 (score (or (nth 1 kill) gnus-score-interactive-default-score))
10694 (date (nth 2 kill))
10697 (cond ((eq type 'after) 'string<)
10698 ((eq type 'before) 'gnus-string>)
10699 ((eq type 'at) 'string=)
10700 (t (error "Illegal match type: %s" type))))
10701 (articles gnus-scores-articles)
10703 ;; Instead of doing all the clever stuff that
10704 ;; `gnus-score-string' does to minimize searches and stuff,
10705 ;; I will assume that people generally will put so few
10706 ;; matches on numbers that any cleverness will take more
10707 ;; time than one would gain.
10710 (setq l (aref (car (car articles)) gnus-score-index))
10711 (funcall match-func match (timezone-make-date-sortable l))
10714 (setcdr (car articles) (+ score (cdr (car articles))))))
10715 (setq articles (cdr articles)))
10716 ;; Update expire date
10717 (cond ((null date)) ;Permanent entry.
10718 (found ;Match, update date.
10719 (gnus-score-set 'touched '(t) alist)
10720 (setcar (nthcdr 2 kill) now))
10721 ((< date expire) ;Old entry, remove.
10722 (gnus-score-set 'touched '(t) alist)
10723 (setcdr entries (cdr rest))
10724 (setq rest entries)))
10725 (setq entries rest))))))
10727 (defun gnus-score-body (scores header now expire)
10729 (set-buffer nntp-server-buffer)
10731 (let* ((buffer-read-only nil)
10732 (articles gnus-scores-articles)
10733 (all-scores scores)
10734 (request-func (cond ((string= "head" (downcase header))
10735 'gnus-request-head)
10736 ((string= "body" (downcase header))
10737 'gnus-request-body)
10738 (t 'gnus-request-article)))
10739 alike last this art entries alist ofunc article)
10740 ;; Not all backends support partial fetching. In that case,
10741 ;; we just fetch the entire article.
10742 (or (gnus-check-backend-function request-func gnus-newsgroup-name)
10744 (setq ofunc request-func)
10745 (setq request-func 'gnus-request-article)))
10747 (setq article (header-number (car (car articles))))
10748 (message "Scoring on article %s..." article)
10749 (if (not (funcall request-func article gnus-newsgroup-name))
10752 (goto-char (point-min))
10753 ;; If just parts of the article is to be searched, but the
10754 ;; backend didn't support partial fetching, we just narrow
10755 ;; to the relevant parts.
10757 (if (eq ofunc 'gnus-request-head)
10760 (or (search-forward "\n\n" nil t) (point-max)))
10762 (or (search-forward "\n\n" nil t) (point))
10764 (setq scores all-scores)
10767 (setq alist (car scores)
10768 scores (cdr scores)
10769 entries (assoc header alist))
10770 (while (cdr entries) ;First entry is the header index.
10771 (let* ((rest (cdr entries))
10773 (match (nth 0 kill))
10774 (type (or (nth 3 kill) 's))
10775 (score (or (nth 1 kill)
10776 gnus-score-interactive-default-score))
10777 (date (nth 2 kill))
10780 (not (or (eq type 'R) (eq type 'S)
10781 (eq type 'Regexp) (eq type 'String))))
10783 (cond ((or (eq type 'r) (eq type 'R)
10784 (eq type 'regexp) (eq type 'Regexp))
10785 're-search-forward)
10786 ((or (eq type 's) (eq type 'S)
10787 (eq type 'string) (eq type 'String))
10790 (error "Illegal match type: %s" type))))
10792 (goto-char (point-min))
10793 (if (funcall search-func match nil t)
10794 ;; Found a match, update scores.
10796 (setcdr (car articles) (+ score (cdr (car articles))))
10798 ;; Update expire date
10799 (cond ((null date)) ;Permanent entry.
10800 (found ;Match, update date.
10801 (gnus-score-set 'touched '(t) alist)
10802 (setcar (nthcdr 2 kill) now))
10803 ((< date expire) ;Old entry, remove.
10804 (gnus-score-set 'touched '(t) alist)
10805 (setcdr entries (cdr rest))
10806 (setq rest entries)))
10807 (setq entries rest)))))
10808 (setq articles (cdr articles)))))))
10810 (defun gnus-score-string (scores header now expire)
10811 ;; Score ARTICLES according to HEADER in SCORES.
10812 ;; Update matches entries to NOW and remove unmatched entried older
10815 ;; Insert the unique article headers in the buffer.
10816 (let ((gnus-score-index (nth 1 (assoc header gnus-header-index)))
10817 ;; gnus-score-index is used as a free variable.
10818 alike last this art entries alist articles)
10820 ;; Sorting the articles costs os O(N*log N) but will allow us to
10821 ;; only match with each unique header. Thus the actual matching
10822 ;; will be O(M*U) where M is the number of strings to match with,
10823 ;; and U is the number of unique headers. It is assumed (but
10824 ;; untested) this will be a net win because of the large constant
10825 ;; factor involved with string matching.
10826 (setq gnus-scores-articles (sort gnus-scores-articles 'gnus-score-string<)
10827 articles gnus-scores-articles)
10831 (setq art (car articles)
10832 this (aref (car art) gnus-score-index)
10833 articles (cdr articles))
10834 (if (equal last this)
10835 ;; O(N*H) cons-cells used here, where H is the number of
10837 (setq alike (cons art alike))
10840 ;; Insert the line, with a text property on the
10841 ;; terminating newline refering to the articles with
10844 (put-text-property (1- (point)) (point) 'articles alike)))
10845 (setq alike (list art)
10847 (and last ; Bwadr, duplicate code.
10850 (put-text-property (1- (point)) (point) 'articles alike)))
10854 (setq alist (car scores)
10855 scores (cdr scores)
10856 entries (assoc header alist))
10857 (while (cdr entries) ;First entry is the header index.
10858 (let* ((rest (cdr entries))
10860 (match (nth 0 kill))
10861 (type (or (nth 3 kill) 's))
10862 (score (or (nth 1 kill) gnus-score-interactive-default-score))
10863 (date (nth 2 kill))
10866 (not (or (eq type 'R) (eq type 'S)
10867 (eq type 'Regexp) (eq type 'String))))
10868 (search-func (cond ((or (eq type 'r) (eq type 'R)
10869 (eq type 'regexp) (eq type 'Regexp))
10870 're-search-forward)
10871 ((or (eq type 's) (eq type 'S)
10872 (eq type 'string) (eq type 'String))
10875 (error "Illegal match type: %s" type))))
10877 (goto-char (point-min))
10878 (while (funcall search-func match nil t)
10881 arts (get-text-property (point) 'articles))
10882 ;; Found a match, update scores.
10884 (setq art (car arts)
10886 (setcdr art (+ score (cdr art)))))
10887 ;; Update expire date
10888 (cond ((null date)) ;Permanent entry.
10889 (found ;Match, update date.
10890 (gnus-score-set 'touched '(t) alist)
10891 (setcar (nthcdr 2 kill) now))
10892 ((< date expire) ;Old entry, remove.
10893 (gnus-score-set 'touched '(t) alist)
10894 (setcdr entries (cdr rest))
10895 (setq rest entries)))
10896 (setq entries rest))))))
10898 (defun gnus-score-string< (a1 a2)
10899 ;; Compare headers in articles A2 and A2.
10900 ;; The header index used is the free variable `gnus-score-index'.
10901 (string-lessp (aref (car a1) gnus-score-index)
10902 (aref (car a2) gnus-score-index)))
10904 (defun gnus-score-build-cons (article)
10905 ;; Build a `gnus-newsgroup-scored' type cons from ARTICLE.
10906 (cons (header-number (car article)) (cdr article)))
10908 (defconst gnus-header-index
10909 ;; Name to index alist.
10910 '(("number" 0 gnus-score-integer)
10911 ("subject" 1 gnus-score-string)
10912 ("from" 2 gnus-score-string)
10913 ("date" 3 gnus-score-date)
10914 ("message-id" 4 gnus-score-string)
10915 ("references" 5 gnus-score-string)
10916 ("chars" 6 gnus-score-integer)
10917 ("lines" 7 gnus-score-integer)
10918 ("xref" 8 gnus-score-string)
10919 ("head" -1 gnus-score-body)
10920 ("body" -1 gnus-score-body)
10921 ("all" -1 gnus-score-body)))
10923 (defun gnus-score-file-name (newsgroup)
10924 "Return the name of a score file for NEWSGROUP."
10925 (cond ((or (null newsgroup)
10926 (string-equal newsgroup ""))
10927 ;; The global score file is placed at top of the directory.
10928 (expand-file-name gnus-score-file-suffix
10929 (or gnus-kill-files-directory "~/News")))
10930 ((gnus-use-long-file-name 'not-score)
10931 ;; Append ".SCORE" to newsgroup name.
10932 (expand-file-name (concat newsgroup "." gnus-score-file-suffix)
10933 (or gnus-kill-files-directory "~/News")))
10935 ;; Place "SCORE" under the hierarchical directory.
10936 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
10937 "/" gnus-score-file-suffix)
10938 (or gnus-kill-files-directory "~/News")))))
10940 (defun gnus-score-score-files (group)
10941 "Return a list of all possible score files."
10942 (and gnus-global-score-files
10943 (or gnus-internal-global-score-files
10944 (gnus-score-search-global-directories gnus-global-score-files)))
10945 (setq gnus-kill-files-directory
10946 (file-name-as-directory
10947 (or gnus-kill-files-directory "~/News/")))
10948 (if (not (file-readable-p gnus-kill-files-directory))
10949 (setq gnus-score-file-list nil)
10950 (if (gnus-use-long-file-name 'not-score)
10951 (if (or (not gnus-score-file-list)
10952 (gnus-file-newer-than gnus-kill-files-directory
10953 (car gnus-score-file-list)))
10954 (setq gnus-score-file-list
10955 (cons (nth 5 (file-attributes gnus-kill-files-directory))
10958 gnus-kill-files-directory t
10959 (concat gnus-score-file-suffix "$"))))))
10960 (let ((dir (expand-file-name
10961 (concat gnus-kill-files-directory
10962 (gnus-replace-chars-in-string group ?. ?/))))
10963 (mdir (length (expand-file-name gnus-kill-files-directory)))
10965 (if (file-exists-p (concat dir "/" gnus-score-file-suffix))
10966 (setq files (list (concat dir "/" gnus-score-file-suffix))))
10967 (while (>= (1+ (length dir)) mdir)
10968 (and (file-exists-p (concat dir "/all/" gnus-score-file-suffix))
10969 (setq files (cons (concat dir "/all/" gnus-score-file-suffix)
10971 (string-match "/[^/]*$" dir)
10972 (setq dir (substring dir 0 (match-beginning 0))))
10973 (setq gnus-score-file-list
10974 (cons nil (nreverse files)))))
10975 (cdr gnus-score-file-list)))
10977 (defun gnus-score-find-single (group)
10978 "Return list containing the score file for GROUP."
10979 (list (gnus-score-file-name group)))
10981 (defun gnus-score-find-hierarchical (group)
10982 "Return list of score files for GROUP.
10983 This includes the score file for the group and all its parents."
10984 (let ((all (copy-sequence '(nil)))
10986 (while (string-match "\\." group (1+ start))
10987 (setq start (match-beginning 0))
10988 (setq all (cons (substring group 0 start) all)))
10989 (setq all (cons group all))
10990 (mapcar 'gnus-score-file-name (nreverse all))))
10992 (defun gnus-score-find-bnews (group)
10993 "Return a list of score files for GROUP.
10994 The score files are those files in the ~/News directory which matches
10995 GROUP using BNews sys file syntax."
10996 (let* ((sfiles (append (gnus-score-score-files group)
10997 gnus-internal-global-score-files))
10998 (kill-dir (file-name-as-directory
10999 (expand-file-name gnus-kill-files-directory)))
11000 (klen (length kill-dir))
11001 ofiles not-match regexp)
11003 (set-buffer (get-buffer-create "*gnus score files*"))
11004 (buffer-disable-undo (current-buffer))
11005 ;; Go through all score file names and create regexp with them
11009 (insert (car sfiles))
11011 ;; First remove the suffix itself.
11012 (re-search-forward (concat "." gnus-score-file-suffix "$"))
11015 (if (looking-at (regexp-quote kill-dir))
11016 ;; If the file name was just "SCORE", `klen' is one character
11018 (delete-char (min (1- (point-max)) klen))
11019 (goto-char (point-max))
11020 (search-backward "/")
11021 (delete-region (1+ (point)) (point-min)))
11022 ;; Translate "all" to ".*".
11023 (while (search-forward "all" nil t)
11024 (replace-match ".*"))
11026 ;; Deal with "not."s.
11027 (if (looking-at "not.")
11030 (setq regexp (buffer-substring 5 (point-max))))
11031 (setq regexp (buffer-substring 1 (point-max)))
11032 (setq not-match nil))
11033 ;; Finally - if this resulting regexp matches the group name,
11034 ;; we add this score file to the list of score files
11035 ;; applicable to this group.
11036 (if (or (and not-match
11037 (not (string-match regexp group)))
11038 (and (not not-match)
11039 (string-match regexp group)))
11040 (setq ofiles (cons (car sfiles) ofiles)))
11041 (setq sfiles (cdr sfiles)))
11042 (kill-buffer (current-buffer))
11043 ;; Slight kludge here - the last score file returned should be
11044 ;; the local score file, whether it exists or not. This is so
11045 ;; that any score commands the user enters will go to the right
11046 ;; file, and not end up in some global score file.
11049 (if (gnus-use-long-file-name 'not-score)
11050 (concat gnus-kill-files-directory group "."
11051 gnus-score-file-suffix)
11052 (concat gnus-kill-files-directory
11053 (gnus-replace-chars-in-string group ?. ?/)
11054 "/" gnus-score-file-suffix)))))
11055 (and (member localscore ofiles)
11056 (delete localscore ofiles))
11057 (setq ofiles (cons localscore ofiles)))
11058 (nreverse ofiles))))
11060 (defun gnus-score-search-global-directories (files)
11061 "Scan all global score directories for score files."
11062 ;; Set the variable `gnus-internal-global-score-files' to all
11063 ;; available global score files.
11064 (interactive (list gnus-global-score-files))
11067 (if (string-match "/$" (car files))
11068 (setq out (nconc (directory-files
11070 (concat gnus-score-file-suffix "$"))))
11071 (setq out (cons (car files) out)))
11072 (setq files (cdr files)))
11073 (setq gnus-internal-global-score-files out)))
11075 (defun gnus-current-score-file-nondirectory (&optional score-file)
11076 (let ((score-file (or score-file gnus-current-score-file)))
11078 (gnus-short-group-name (file-name-nondirectory score-file))
11085 (defvar gnus-score-mode-map nil)
11086 (defvar gnus-score-mode-hook nil)
11088 (if gnus-score-mode-map
11090 (setq gnus-score-mode-map (copy-keymap emacs-lisp-mode-map))
11091 (define-key gnus-score-mode-map "\C-c\C-c" 'gnus-score-edit-done)
11092 (define-key gnus-score-mode-map "\C-c\C-d" 'gnus-score-edit-insert-date))
11094 (defun gnus-score-mode ()
11095 "Mode for editing score files.
11096 This mode is an extended emacs-lisp mode.
11098 \\{gnus-score-mode-map}"
11100 (kill-all-local-variables)
11101 (use-local-map gnus-score-mode-map)
11102 (set-syntax-table emacs-lisp-mode-syntax-table)
11103 (setq major-mode 'gnus-score-mode)
11104 (setq mode-name "Score")
11105 (lisp-mode-variables nil)
11106 (run-hooks 'emacs-lisp-mode-hook 'gnus-score-mode-hook))
11108 (defun gnus-score-edit-insert-date ()
11109 "Insert date in numerical format."
11111 (insert (int-to-string (gnus-day-number (current-time-string)))))
11113 (defun gnus-score-edit-done ()
11114 "Save the score file and return to the summary buffer."
11116 (let ((bufnam (buffer-file-name (current-buffer))))
11118 (kill-buffer (current-buffer))
11119 (and gnus-winconf-edit-score
11120 (set-window-configuration gnus-winconf-edit-score))
11121 (gnus-score-remove-from-cache bufnam)
11122 (gnus-score-load-file bufnam)))
11126 ;;; Gnus Posting Functions
11129 (defvar gnus-organization-file "/usr/lib/news/organization"
11130 "*Local news organization file.")
11132 (defvar gnus-post-news-buffer "*post-news*")
11133 (defvar gnus-winconf-post-news nil)
11135 ;;; Post news commands of Gnus group mode and summary mode
11137 (defun gnus-group-post-news ()
11140 (gnus-set-global-variables)
11141 ;; Save window configuration.
11142 (setq gnus-winconf-post-news (current-window-configuration))
11143 (let ((gnus-newsgroup-name nil))
11145 (if gnus-split-window
11147 (pop-to-buffer gnus-article-buffer)
11149 (split-window-vertically)
11150 (gnus-post-news 'post))
11152 (pop-to-buffer gnus-article-buffer)
11154 (delete-other-windows)
11155 (gnus-post-news 'post))
11157 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
11158 (not (zerop (buffer-size))))
11159 ;; Restore last window configuration.
11160 (and gnus-winconf-post-news
11161 (set-window-configuration gnus-winconf-post-news)))))
11162 ;; We don't want to return to summary buffer nor article buffer later.
11163 (setq gnus-winconf-post-news nil)
11164 (if (get-buffer gnus-summary-buffer)
11165 (bury-buffer gnus-summary-buffer))
11166 (if (get-buffer gnus-article-buffer)
11167 (bury-buffer gnus-article-buffer)))
11169 (defun gnus-summary-post-news ()
11172 (gnus-set-global-variables)
11173 ;; Save window configuration.
11174 (setq gnus-winconf-post-news (current-window-configuration))
11176 (gnus-post-news 'post gnus-newsgroup-name)
11177 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
11178 (not (zerop (buffer-size))))
11179 ;; Restore last window configuration.
11180 (and gnus-winconf-post-news
11181 (set-window-configuration gnus-winconf-post-news))))
11182 ;; We don't want to return to article buffer later.
11183 (if (get-buffer gnus-article-buffer)
11184 (bury-buffer gnus-article-buffer)))
11186 (defun gnus-summary-followup (yank)
11187 "Compose a followup to an article.
11188 If prefix argument YANK is non-nil, original article is yanked automatically."
11190 (gnus-set-global-variables)
11191 (save-window-excursion
11192 (gnus-summary-select-article t))
11193 (let ((headers gnus-current-headers)
11194 (gnus-newsgroup-name gnus-newsgroup-name))
11195 ;; Check Followup-To: poster.
11196 (set-buffer gnus-article-buffer)
11197 (if (and gnus-use-followup-to
11198 (string-equal "poster" (gnus-fetch-field "followup-to"))
11199 (or (not (eq gnus-use-followup-to t))
11200 (not (gnus-y-or-n-p
11201 "Do you want to ignore `Followup-To: poster'? "))))
11202 ;; Mail to the poster. Gnus is now RFC1036 compliant.
11203 (gnus-summary-reply yank)
11204 ;; Save window configuration.
11205 (setq gnus-winconf-post-news (current-window-configuration))
11207 (gnus-post-news nil gnus-newsgroup-name
11208 headers gnus-article-buffer yank)
11209 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
11210 (not (zerop (buffer-size))))
11211 ;; Restore last window configuration.
11212 (and gnus-winconf-post-news
11213 (set-window-configuration gnus-winconf-post-news))))
11214 ;; We don't want to return to article buffer later.
11215 (bury-buffer gnus-article-buffer)))
11216 (gnus-article-hide-headers-if-wanted))
11218 (defun gnus-summary-followup-with-original ()
11219 "Compose a followup to an article and include the original article."
11221 (gnus-summary-followup t))
11223 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11224 (defun gnus-summary-followup-and-reply (yank)
11225 "Compose a followup and do an auto mail to author."
11227 (let ((gnus-auto-mail-to-author t))
11228 (gnus-summary-followup yank)))
11230 (defun gnus-summary-followup-and-reply-with-original ()
11231 "Compose a followup, include the original, and do an auto mail to author."
11233 (gnus-summary-followup-and-reply t))
11235 (defun gnus-summary-cancel-article ()
11236 "Cancel an article you posted."
11238 (gnus-set-global-variables)
11239 (gnus-summary-select-article t)
11240 (gnus-eval-in-buffer-window gnus-article-buffer (gnus-cancel-news))
11241 (gnus-article-hide-headers-if-wanted))
11243 (defun gnus-summary-supersede-article ()
11244 "Compose an article that will supersede a previous article.
11245 This is done simply by taking the old article and adding a Supersedes
11246 header line with the old Message-ID."
11248 (gnus-set-global-variables)
11251 (downcase (mail-strip-quoted-names
11252 (header-from gnus-current-headers)))
11253 (downcase (mail-strip-quoted-names (gnus-inews-user-name)))))
11254 (error "This article is not yours."))
11255 (gnus-summary-select-article t)
11257 (set-buffer gnus-article-buffer)
11258 (let ((buffer-read-only nil))
11259 (goto-char (point-min))
11260 (search-forward "\n\n" nil t)
11261 (if (not (re-search-backward "^Message-ID: " nil t))
11262 (error "No Message-ID in this article"))))
11263 (if (gnus-post-news 'post gnus-newsgroup-name)
11266 (insert-buffer gnus-article-buffer)
11267 (goto-char (point-min))
11268 (search-forward "\n\n" nil t)
11269 (if (not (re-search-backward "^Message-ID: " nil t))
11270 (error "No Message-ID in this article")
11271 (replace-match "Supersedes: "))
11272 (search-forward "\n\n")
11274 (insert mail-header-separator))))
11278 (fset 'sendnews 'gnus-post-news)
11281 (fset 'postnews 'gnus-post-news)
11283 (defun gnus-post-news (post &optional group header article-buffer yank)
11284 "Begin editing a new USENET news article to be posted.
11285 Type \\[describe-mode] in the buffer to get a list of commands."
11286 (interactive (list t))
11287 (if (or (not gnus-novice-user)
11291 (format "%s" (car (gnus-find-method-for-group
11292 gnus-newsgroup-name)))
11293 gnus-valid-select-methods))))
11294 (assq 'to-address (nth 5 (nth 2 (gnus-gethash gnus-newsgroup-name
11295 gnus-newsrc-hashtb))))
11296 (gnus-y-or-n-p "Are you sure you want to post to all of USENET? "))
11297 (let ((sumart (if (not post)
11299 (set-buffer gnus-summary-buffer)
11300 (cons (current-buffer) gnus-current-article))))
11301 (from (and header (header-from header)))
11302 subject follow-to real-group)
11303 (and gnus-interactive-post
11304 (not gnus-expert-user)
11308 (completing-read "Group: " gnus-active-hashtb))
11309 (setq subject (read-string "Subject: "))))
11310 (setq mail-reply-buffer article-buffer)
11312 (let ((gnus-newsgroup-name (or group gnus-newsgroup-name "")))
11313 (setq real-group (and group (gnus-group-real-name group)))
11314 (setq gnus-post-news-buffer
11315 (gnus-request-post-buffer
11316 post real-group subject header article-buffer
11317 (nth 2 (and group (gnus-gethash group gnus-newsrc-hashtb)))
11318 (if (and (boundp 'gnus-followup-to-function)
11319 gnus-followup-to-function)
11322 (set-buffer article-buffer)
11323 (funcall gnus-followup-to-function group))))
11324 (eq gnus-use-followup-to t)))
11327 (gnus-configure-windows '(1 0 0))
11328 (switch-to-buffer gnus-post-news-buffer))
11329 (gnus-configure-windows '(0 1 0))
11332 (switch-to-buffer article-buffer)
11333 (pop-to-buffer gnus-post-news-buffer))
11334 (switch-to-buffer gnus-post-news-buffer)))
11335 (gnus-overload-functions)
11336 (make-local-variable 'gnus-article-reply)
11337 (make-local-variable 'gnus-article-check-size)
11338 (setq gnus-article-reply sumart)
11339 ;; Handle `gnus-auto-mail-to-author'.
11340 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11341 (let ((to (if (eq gnus-auto-mail-to-author 'ask)
11342 (and (y-or-n-p "Also send mail to author? ") from)
11343 (and gnus-auto-mail-to-author from))))
11346 (if (mail-fetch-field "To")
11348 (beginning-of-line)
11349 (insert "Cc: " to "\n"))
11350 (mail-position-on-field "To")
11352 ;; Handle author copy using BCC field.
11353 (if (and gnus-mail-self-blind
11354 (not (mail-fetch-field "bcc")))
11356 (mail-position-on-field "Bcc")
11357 (insert (if (stringp gnus-mail-self-blind)
11358 gnus-mail-self-blind
11359 (user-login-name)))))
11360 ;; Handle author copy using FCC field.
11361 (if gnus-author-copy
11363 (mail-position-on-field "Fcc")
11364 (insert gnus-author-copy)))
11365 (goto-char (point-min))
11368 (re-search-forward "^Newsgroup:" nil t)
11371 (re-search-forward "^Subject:" nil t)
11375 (concat "^" (regexp-quote mail-header-separator) "$"))
11378 (concat "^" (regexp-quote mail-header-separator) "$"))
11380 (and yank (save-excursion (news-reply-yank-original nil)))
11381 (if gnus-post-prepare-function
11382 (funcall gnus-post-prepare-function group))))))
11383 (setq gnus-article-check-size (cons (buffer-size) (gnus-article-checksum)))
11387 (defun gnus-inews-news (&optional use-group-method)
11388 "Send a news message.
11389 If given a prefix, and the group is a foreign group, this function
11390 will attempt to use the foreign server to post the article."
11392 ;; Check whether the article is a good Net Citizen.
11393 (if (and gnus-article-check-size (not (gnus-inews-check-post)))
11396 ;; Looks ok, so we do the nasty.
11397 (let* ((case-fold-search nil)
11398 (server-running (gnus-server-opened gnus-select-method))
11399 (reply gnus-article-reply))
11401 ;; Connect to default NNTP server if necessary.
11402 ;; Suggested by yuki@flab.fujitsu.junet.
11403 (gnus-start-news-server) ;Use default server.
11404 ;; NNTP server must be opened before current buffer is modified.
11406 (goto-char (point-min))
11407 (run-hooks 'news-inews-hook)
11412 (goto-char (point-min))
11414 (concat "^" (regexp-quote mail-header-separator) "$"))))
11416 ;; Correct newsgroups field: change sequence of spaces to comma and
11417 ;; eliminate spaces around commas. Eliminate imbedded line breaks.
11418 (goto-char (point-min))
11419 (if (search-forward-regexp "^Newsgroups: +" nil t)
11423 (if (re-search-forward "^[^ \t]" nil 'end)
11424 (match-beginning 0)
11426 (goto-char (point-min))
11427 (replace-regexp "\n[ \t]+" " ") ;No line breaks (too confusing)
11428 (goto-char (point-min))
11429 (replace-regexp "[ \t\n]*,[ \t\n]*\\|[ \t]+" ",")))
11431 ;; Added by Per Abrahamsen <abraham@iesd.auc.dk>.
11432 ;; Help save the the world!
11435 (let ((newsgroups (mail-fetch-field "newsgroups"))
11436 (followup-to (mail-fetch-field "followup-to"))
11438 (if (and (string-match "," newsgroups) (not followup-to))
11440 (while (string-match "," newsgroups)
11442 (cons (list (substring newsgroups
11443 0 (match-beginning 0)))
11445 (setq newsgroups (substring newsgroups (match-end 0))))
11446 (setq groups (nreverse (cons (list newsgroups) groups)))
11449 (completing-read "Followups to: (default all groups) "
11451 (if (> (length to) 0)
11453 (goto-char (point-min))
11454 (insert "Followup-To: " to "\n")))))))
11456 ;; Cleanup Followup-To.
11457 (goto-char (point-min))
11458 (if (search-forward-regexp "^Followup-To: +" nil t)
11462 (if (re-search-forward "^[^ \t]" nil 'end)
11463 (match-beginning 0)
11465 (goto-char (point-min))
11466 (replace-regexp "\n[ \t]+" " ") ;No line breaks (too confusing)
11467 (goto-char (point-min))
11468 (replace-regexp "[ \t\n]*,[ \t\n]*\\|[ \t]+" ",")))
11470 ;; Mail the message too if To:, Bcc:. or Cc: exists.
11471 (if (or (mail-fetch-field "to" nil t)
11472 (mail-fetch-field "bcc" nil t)
11473 (mail-fetch-field "cc" nil t))
11474 (if gnus-mail-send-method
11478 (message "Sending via mail...")
11480 (if gnus-mail-courtesy-message
11482 ;; Insert "courtesy" mail message.
11485 (concat "^" (regexp-quote
11486 mail-header-separator) "$"))
11488 (insert gnus-mail-courtesy-message)
11489 (funcall gnus-mail-send-method)
11491 (search-forward gnus-mail-courtesy-message)
11492 (replace-match ""))
11493 (funcall gnus-mail-send-method))
11495 (message "Sending via mail... done")
11499 1 (re-search-forward
11500 (concat "^" (regexp-quote
11501 mail-header-separator) "$")))
11503 (delete-matching-lines "BCC:.*")))
11505 (message "No mailer defined. To: and/or Cc: fields ignored.")
11508 ;; Send to NNTP server.
11509 (message "Posting to USENET...")
11510 (if (gnus-inews-article use-group-method)
11512 (message "Posting to USENET... done")
11514 (get-buffer (car reply))
11515 (buffer-name (car reply)))
11518 (set-buffer gnus-summary-buffer)
11519 (gnus-summary-mark-article-as-replied
11521 ;; We cannot signal an error.
11522 (ding) (message "Article rejected: %s"
11523 (gnus-status-message gnus-select-method)))
11524 (set-buffer-modified-p nil))
11525 ;; If NNTP server is opened by gnus-inews-news, close it by myself.
11527 (gnus-close-server (gnus-find-method-for-group gnus-newsgroup-name)))
11528 (and (fboundp 'bury-buffer) (bury-buffer))
11529 ;; Restore last window configuration.
11530 (and gnus-winconf-post-news
11531 (set-window-configuration gnus-winconf-post-news))
11532 (setq gnus-winconf-post-news nil))))
11534 (defun gnus-inews-check-post ()
11535 "Check whether the post looks ok."
11537 (not gnus-check-before-posting)
11539 ;; We narrow to the headers and check them first.
11542 (goto-char (point-min))
11546 (concat "^" (regexp-quote mail-header-separator) "$")))
11547 (goto-char (point-min))
11549 ;; Check for commands in Subject.
11551 (if (string-match "^cmsg " (mail-fetch-field "subject"))
11553 "The control code \"cmsg \" is in the subject. Really post? ")
11555 ;; Check for multiple identical headers.
11558 (while (and (not found) (re-search-forward "^[^ \t:]+: " nil t))
11560 (or (re-search-forward
11561 (concat "^" (setq found
11563 (match-beginning 0)
11564 (- (match-end 0) 2))))
11566 (setq found nil))))
11569 (format "Multiple %s headers. Really post? " found))
11571 ;; Check for version and sendsys.
11573 (if (re-search-forward "^Sendsys:\\|^Version:" nil t)
11575 (format "The article contains a %s command. Really post? "
11576 (buffer-substring (match-beginning 0)
11577 (1- (match-end 0)))))
11579 ;; Check the Message-Id header.
11581 (let* ((case-fold-search t)
11582 (message-id (mail-fetch-field "message-id")))
11583 (or (and (string-match "@" message-id)
11584 (string-match "@[^\\.]*\\." message-id))
11586 (format "The Message-ID looks strange: \"%s\". Really post? "
11588 ;; Check the From header.
11590 (let* ((case-fold-search t)
11591 (from (mail-fetch-field "from")))
11592 (or (and (string-match "@" from)
11593 (string-match "@[^\\.]*\\." from))
11595 (format "The From looks strange: \"%s\". Really post? "
11597 ;; Check for long lines.
11599 (goto-char (point-min))
11601 (concat "^" (regexp-quote mail-header-separator) "$"))
11605 (< (current-column) 80))
11606 (zerop (forward-line 1))))
11610 "You have lines longer than 79 characters. Really post? "))))
11611 ;; Check for control characters.
11613 (if (re-search-forward "[\000-\007\013\015-\037\200-\237]" nil t)
11615 "The article contains control characters. Really post? ")
11617 ;; Check excessive size.
11618 (if (> (buffer-size) 60000)
11619 (gnus-y-or-n-p (format "The article is %d octets long. Really post? "
11622 ;; Use the (size . checksum) variable to see whether the
11623 ;; article is empty or has only quoted text.
11624 (if (and (= (buffer-size) (car gnus-article-check-size))
11625 (= (gnus-article-checksum) (cdr gnus-article-check-size)))
11627 "It looks like there's no new text in your article. Really post? ")
11630 (defun gnus-article-checksum ()
11633 (while (not (eobp))
11634 (setq sum (logxor sum (following-char)))
11638 (defun gnus-cancel-news ()
11639 "Cancel an article you posted."
11641 (if (or gnus-expert-user
11642 (gnus-yes-or-no-p "Do you really want to cancel this article? "))
11646 (distribution nil))
11648 ;; Get header info. from original article.
11650 (gnus-article-show-all-headers)
11651 (goto-char (point-min))
11652 (search-forward "\n\n" nil 'move)
11653 (narrow-to-region (point-min) (point))
11654 (setq from (mail-fetch-field "from"))
11655 (setq newsgroups (mail-fetch-field "newsgroups"))
11656 (setq message-id (mail-fetch-field "message-id"))
11657 (setq distribution (mail-fetch-field "distribution")))
11658 ;; Verify if the article is absolutely user's by comparing
11659 ;; user id with value of its From: field.
11662 (downcase (mail-strip-quoted-names from))
11663 (downcase (mail-strip-quoted-names (gnus-inews-user-name)))))
11665 (ding) (message "This article is not yours."))
11666 ;; Make control article.
11667 (set-buffer (get-buffer-create " *Gnus-canceling*"))
11668 (buffer-disable-undo (current-buffer))
11670 (insert "Newsgroups: " newsgroups "\n"
11671 "Subject: cancel " message-id "\n"
11672 "Control: cancel " message-id "\n"
11673 mail-header-separator "\n"
11674 "This is a cancel message from " from ".\n")
11675 ;; Send the control article to NNTP server.
11676 (message "Canceling your article...")
11677 (if (gnus-inews-article)
11678 (message "Canceling your article... done")
11680 (message "Cancel failed; %s"
11681 (gnus-status-message gnus-newsgroup-name)))
11682 ;; Kill the article buffer.
11683 (kill-buffer (current-buffer)))))))
11686 ;;; Lowlevel inews interface
11688 (defun gnus-inews-article (&optional use-group-method)
11689 "Post an article in current buffer using NNTP protocol."
11690 (let ((artbuf (current-buffer))
11691 (tmpbuf (get-buffer-create " *Gnus-posting*")))
11693 (goto-char (point-max))
11694 ;; require a newline at the end for inews to append .signature to
11695 (or (= (preceding-char) ?\n)
11697 ;; Prepare article headers. All message body such as signature
11698 ;; must be inserted before Lines: field is prepared.
11700 (goto-char (point-min))
11705 (concat "^" (regexp-quote mail-header-separator) "$"))
11706 (match-beginning 0)))
11707 (gnus-inews-insert-headers)
11708 (run-hooks gnus-inews-article-header-hook)
11711 (set-buffer tmpbuf)
11712 (buffer-disable-undo (current-buffer))
11714 (insert-buffer-substring artbuf)
11715 ;; Remove the header separator.
11716 (goto-char (point-min))
11718 (concat "^" (regexp-quote mail-header-separator) "$"))
11720 ;; This hook may insert a signature.
11721 (run-hooks 'gnus-prepare-article-hook)
11722 ;; Run final inews hooks. This hook may do FCC.
11723 ;; The article must be saved before being posted because
11724 ;; `gnus-request-post' modifies the buffer.
11725 (run-hooks 'gnus-inews-article-hook)
11726 ;; Post an article to NNTP server.
11727 ;; Return NIL if post failed.
11730 (if use-group-method
11731 (gnus-find-method-for-group gnus-newsgroup-name)
11732 gnus-select-method) use-group-method)
11733 (kill-buffer (current-buffer))))))
11735 (defun gnus-inews-insert-headers ()
11736 "Prepare article headers.
11737 Headers already prepared in the buffer are not modified.
11738 Headers in `gnus-required-headers' will be generated."
11739 (let ((Date (gnus-inews-date))
11740 (Message-ID (gnus-inews-message-id))
11741 (Organization (gnus-inews-organization))
11742 (From (gnus-inews-user-name))
11743 (Path (gnus-inews-path))
11747 (Lines (gnus-inews-lines))
11748 (X-Newsreader gnus-version)
11749 (headers gnus-required-headers)
11750 (case-fold-search t)
11752 ;; First we remove any old Message-IDs. This might be slightly
11753 ;; fascist, but if the user really wants to generate Message-IDs
11754 ;; by herself, she should remove it from the `gnus-required-list'.
11755 (goto-char (point-min))
11756 (and (memq 'Message-ID headers)
11757 (re-search-forward "^Message-ID:" nil t)
11758 (delete-region (progn (beginning-of-line) (point))
11759 (progn (forward-line 1) (point))))
11760 ;; Remove NNTP-posting-host.
11761 (goto-char (point-min))
11762 (and (re-search-forward "^nntp-posting-host:" nil t)
11763 (delete-region (progn (beginning-of-line) (point))
11764 (progn (forward-line 1) (point))))
11765 ;; Insert new Sender if the From is strange.
11766 (let ((from (mail-fetch-field "from")))
11767 (if (and from (not (string= (downcase from) (downcase From))))
11769 (goto-char (point-min))
11770 (and (re-search-forward "^Sender:" nil t)
11771 (delete-region (progn (beginning-of-line) (point))
11772 (progn (forward-line 1) (point))))
11773 (insert "Sender: " From "\n"))))
11774 ;; If there are References, and no "Re: ", then the thread has
11775 ;; changed name. See Son-of-1036.
11776 (if (and (mail-fetch-field "references")
11777 (get-buffer gnus-article-buffer))
11778 (let ((psubject (gnus-simplify-subject-re
11779 (mail-fetch-field "subject")))
11782 (set-buffer (get-buffer gnus-article-buffer))
11784 (gnus-narrow-to-headers)
11785 (if (setq subject (mail-fetch-field "subject"))
11787 (and gnus-summary-gather-subject-limit
11788 (numberp gnus-summary-gather-subject-limit)
11789 (> (length subject) gnus-summary-gather-subject-limit)
11791 (substring subject 0
11792 gnus-summary-gather-subject-limit)))
11793 (setq subject (gnus-simplify-subject-re subject))))))
11794 (or (and psubject subject (string= subject psubject))
11796 (string-match "@" Message-ID)
11798 (concat (substring Message-ID 0 (match-beginning 0))
11800 (substring Message-ID (match-beginning 0))))))))
11801 ;; Go through all the required headers and see if they are in the
11802 ;; articles already. If they are not, or are empty, they are
11803 ;; inserted automatically - except for Subject, Newsgroups and
11806 (goto-char (point-min))
11807 (setq elem (car headers))
11809 (setq header (car elem))
11810 (setq header elem))
11811 (if (or (not (re-search-forward
11812 (concat "^" (downcase (symbol-name header)) ":") nil t))
11814 (if (= (following-char) ? ) (forward-char 1) (insert " "))
11815 (looking-at "[ \t]*$")))
11818 (or (if (consp elem)
11819 ;; The element is a cons. Either the cdr is
11820 ;; a string to be inserted verbatim, or it
11821 ;; is a function, and we insert the value
11822 ;; returned from this function.
11823 (or (and (stringp (cdr elem)) (cdr elem))
11824 (and (fboundp (cdr elem)) (funcall (cdr elem))))
11825 ;; The element is a symbol. We insert the
11826 ;; value of this symbol, if any.
11827 (and (boundp header) (symbol-value header)))
11828 ;; We couldn't generate a value for this header,
11829 ;; so we just ask the user.
11830 (read-from-minibuffer
11831 (format "Empty header for %s; enter value: " header))))
11834 (goto-char (point-max))
11835 (insert (symbol-name header) ": " value "\n"))
11836 (replace-match value))))
11837 (setq headers (cdr headers)))))
11839 (defun gnus-inews-insert-signature ()
11840 "Insert a signature file.
11841 If `gnus-signature-function' is bound and returns a string, this
11842 string is used instead of the variable `gnus-signature-file'.
11843 In either case, if the string is a file name, this file is
11844 inserted. If the string is not a file name, the string itself is
11846 If you never want any signature inserted, set both those variables to
11850 (or (and gnus-signature-function
11851 (fboundp gnus-signature-function)
11852 (funcall gnus-signature-function gnus-newsgroup-name))
11853 gnus-signature-file))
11856 (or (file-exists-p signature)
11857 (string-match " " signature)
11859 "^/[^/]+/" (expand-file-name signature)))))
11861 (goto-char (point-max))
11862 ;; Delete any previous signatures.
11863 (if (and mail-signature (search-backward "\n-- \n" nil t))
11864 (delete-region (1+ (point)) (point-max)))
11866 (and (< 4 (setq b (count-lines
11869 (if (file-exists-p signature)
11870 (insert-file-contents signature)
11871 (insert signature))
11872 (goto-char (point-max))
11873 (or (bolp) (insert "\n"))
11875 (not gnus-expert-user)
11879 "Your .sig is %d lines; it should be max 4. Really post? "
11881 (if (file-exists-p signature)
11882 (error (format "Edit %s." signature))
11883 (error "Trim your signature."))))))))
11885 (defun gnus-inews-do-fcc ()
11886 "Process FCC: fields in current article buffer.
11887 Unless the first character of the field is `|', the article is saved
11888 to the specified file using the function specified by the variable
11889 gnus-author-copy-saver. The default function rmail-output saves in
11890 Unix mailbox format.
11891 If the first character is `|', the contents of the article is send to
11892 a program specified by the rest of the value."
11893 (let ((fcc-list nil)
11895 (case-fold-search t)) ;Should ignore case.
11898 (goto-char (point-min))
11899 (search-forward "\n\n")
11900 (narrow-to-region (point-min) (point))
11901 (goto-char (point-min))
11902 (while (re-search-forward "^FCC:[ \t]*" nil t)
11904 (cons (buffer-substring
11908 (skip-chars-backward " \t")
11911 (delete-region (match-beginning 0)
11912 (progn (forward-line 1) (point))))
11913 ;; Process FCC operations.
11916 (setq fcc-file (car fcc-list))
11917 (setq fcc-list (cdr fcc-list))
11918 (cond ((string-match "^[ \t]*|[ \t]*\\(.*\\)[ \t]*$" fcc-file)
11919 (let ((program (substring fcc-file
11920 (match-beginning 1) (match-end 1))))
11921 ;; Suggested by yuki@flab.fujitsu.junet.
11922 ;; Send article to named program.
11923 (call-process-region (point-min) (point-max) shell-file-name
11924 nil nil nil "-c" program)))
11926 ;; Suggested by hyoko@flab.fujitsu.junet.
11927 ;; Save article in Unix mail format by default.
11928 (if (and gnus-author-copy-saver
11929 (not (eq gnus-author-copy-saver 'rmail-output)))
11930 (funcall gnus-author-copy-saver fcc-file)
11931 (if (and (file-readable-p fcc-file) (rmail-file-p fcc-file))
11932 (gnus-output-to-rmail fcc-file)
11933 (rmail-output fcc-file 1 t t))))))))))
11935 (defun gnus-inews-path ()
11936 "Return uucp path."
11937 (let ((login-name (gnus-inews-login-name)))
11938 (cond ((null gnus-use-generic-path)
11939 (concat (nth 1 gnus-select-method) "!" login-name))
11940 ((stringp gnus-use-generic-path)
11941 ;; Support GENERICPATH. Suggested by vixie@decwrl.dec.com.
11942 (concat gnus-use-generic-path "!" login-name))
11945 (defun gnus-inews-user-name ()
11946 "Return user's network address as \"NAME@DOMAIN (FULL-NAME)\"."
11947 (let ((full-name (gnus-inews-full-name)))
11948 (or gnus-user-from-line
11949 (concat (if (or gnus-user-login-name gnus-use-generic-from
11950 gnus-local-domain (getenv "DOMAINNAME"))
11951 (concat (gnus-inews-login-name) "@"
11952 (gnus-inews-domain-name gnus-use-generic-from))
11954 ;; User's full name.
11955 (cond ((string-equal full-name "") "")
11956 ((string-equal full-name "&") ;Unix hack.
11957 (concat " (" (user-login-name) ")"))
11959 (concat " (" full-name ")")))))))
11961 (defun gnus-inews-login-name ()
11962 "Return login name."
11963 (or gnus-user-login-name (getenv "LOGNAME") (user-login-name)))
11965 (defun gnus-inews-full-name ()
11966 "Return full user name."
11967 (or gnus-user-full-name (getenv "NAME") (user-full-name)))
11969 (defun gnus-inews-domain-name (&optional genericfrom)
11970 "Return user's domain name.
11971 If optional argument GENERICFROM is a string, use it as the domain
11972 name; if it is non-nil, strip off local host name from the domain name.
11973 If the function `system-name' returns full internet name and the
11974 domain is undefined, the domain name is got from it."
11975 (if (or genericfrom gnus-local-domain (getenv "DOMAINNAME"))
11976 (let* ((system-name (system-name))
11978 (or (if (stringp genericfrom) genericfrom)
11979 (getenv "DOMAINNAME")
11981 ;; Function `system-name' may return full internet name.
11982 ;; Suggested by Mike DeCorte <mrd@sun.soe.clarkson.edu>.
11983 (if (string-match "\\." system-name)
11984 (substring system-name (match-end 0)))
11985 (read-string "Domain name (no host): ")))
11986 (host (or (if (string-match "\\." system-name)
11987 (substring system-name 0 (match-beginning 0)))
11989 (if (string-equal "." (substring domain 0 1))
11990 (setq domain (substring domain 1)))
11991 ;; Support GENERICFROM as same as standard Bnews system.
11992 ;; Suggested by ohm@kaba.junet and vixie@decwrl.dec.com.
11993 (cond ((null genericfrom)
11994 (concat host "." domain))
11995 ;;((stringp genericfrom) genericfrom)
11997 (if (string-match "\\." (system-name))
11999 (substring user-mail-address
12000 (1+ (string-match "@" user-mail-address))))))
12002 (defun gnus-inews-full-address ()
12003 (let ((domain (gnus-inews-domain-name))
12004 (system (system-name))
12005 (case-fold-search t))
12006 (if (string-match "\\." system) system
12007 (if (string-match (concat "^" (regexp-quote system)) domain) domain
12008 (concat system "." domain)))))
12010 (defun gnus-inews-message-id ()
12011 "Generate unique Message-ID for user."
12012 ;; Message-ID should not contain a slash and should be terminated by
12013 ;; a number. I don't know the reason why it is so.
12014 (concat "<" (gnus-inews-unique-id) "@" (gnus-inews-full-address) ">"))
12016 (defun gnus-inews-unique-id ()
12017 "Generate unique ID from user name and current time."
12018 (concat (downcase (gnus-inews-login-name))
12020 (lambda (num) (gnus-number-base-x num 3 31))
12021 (current-time) "")))
12023 (defun gnus-inews-date ()
12024 "Current time string."
12025 (timezone-make-date-arpa-standard
12026 (current-time-string) (current-time-zone)))
12028 (defun gnus-inews-organization ()
12029 "Return user's organization.
12030 The ORGANIZATION environment variable is used if defined.
12031 If not, the variable `gnus-local-organization' is used instead.
12032 If it is a function, the function will be called with the current
12033 newsgroup name as the argument.
12034 If this is a file name, the contents of this file will be used as the
12036 (let* ((organization
12037 (or (getenv "ORGANIZATION")
12038 (if gnus-local-organization
12039 (if (and (symbolp gnus-local-organization)
12040 (fboundp gnus-local-organization))
12041 (funcall gnus-local-organization gnus-newsgroup-name)
12042 gnus-local-organization))
12043 gnus-organization-file
12044 "~/.organization")))
12045 (and (stringp organization)
12046 (> (length organization) 0)
12047 (or (file-exists-p organization)
12048 (string-match " " organization)
12049 (not (string-match "^/[^/]+/" (expand-file-name organization))))
12051 (set-buffer (get-buffer-create " *Gnus organization*"))
12052 (buffer-disable-undo (current-buffer))
12054 (if (file-exists-p organization)
12055 (insert-file-contents organization)
12056 (insert organization))
12057 (goto-char (point-min))
12058 (while (re-search-forward " *\n *" nil t)
12059 (replace-match " "))
12060 (buffer-substring (point-min) (point-max))))))
12062 (defun gnus-inews-lines ()
12063 "Count the number of lines and return numeric string."
12067 (goto-char (point-min))
12068 (search-forward "\n\n" nil 'move)
12069 (int-to-string (count-lines (point) (point-max))))))
12073 ;;; Gnus Mail Functions
12076 ;;; Mail reply commands of Gnus summary mode
12078 (defun gnus-summary-reply (yank)
12079 "Reply mail to news author.
12080 If prefix argument YANK is non-nil, original article is yanked automatically.
12081 Customize the variable gnus-mail-reply-method to use another mailer."
12083 ;; Bug fix by jbw@bigbird.bu.edu (Joe Wells)
12084 ;; Stripping headers should be specified with mail-yank-ignored-headers.
12085 (gnus-set-global-variables)
12086 (setq gnus-winconf-post-news (current-window-configuration))
12087 (gnus-summary-select-article t)
12088 (let ((gnus-newsgroup-name gnus-newsgroup-name))
12089 (bury-buffer gnus-article-buffer)
12090 (funcall gnus-mail-reply-method yank))
12091 (gnus-article-hide-headers-if-wanted))
12093 (defun gnus-summary-reply-with-original ()
12094 "Reply mail to news author with original article.
12095 Customize the variable gnus-mail-reply-method to use another mailer."
12097 (gnus-summary-reply t))
12099 (defun gnus-summary-mail-forward ()
12100 "Forward the current message to another user.
12101 Customize the variable gnus-mail-forward-method to use another mailer."
12103 (gnus-summary-select-article t)
12104 (setq gnus-winconf-post-news (current-window-configuration))
12105 (or gnus-split-window
12106 (switch-to-buffer gnus-article-buffer))
12108 (or gnus-split-window (delete-other-windows))
12109 (or gnus-split-window (bury-buffer gnus-article-buffer))
12110 (let ((gnus-newsgroup-name gnus-newsgroup-name))
12111 (funcall gnus-mail-forward-method))
12112 (gnus-article-hide-headers-if-wanted))
12114 (defun gnus-summary-mail-other-window ()
12115 "Compose mail in other window.
12116 Customize the variable `gnus-mail-other-window-method' to use another
12119 (setq gnus-winconf-post-news (current-window-configuration))
12120 (let ((gnus-newsgroup-name gnus-newsgroup-name))
12121 (funcall gnus-mail-other-window-method)))
12123 (defun gnus-mail-reply-using-mail (&optional yank to-address)
12125 (set-buffer gnus-summary-buffer)
12126 (let ((info (nth 2 (gnus-gethash gnus-newsgroup-name gnus-newsrc-hashtb)))
12127 (group (gnus-group-real-name gnus-newsgroup-name))
12128 (cur (cons (current-buffer) (cdr gnus-article-current)))
12129 from subject date to reply-to message-of
12130 references message-id sender follow-to cc)
12131 (set-buffer (get-buffer-create "*mail*"))
12133 (make-local-variable 'gnus-article-reply)
12134 (setq gnus-article-reply cur)
12135 (use-local-map (copy-keymap mail-mode-map))
12136 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
12137 (if (and (buffer-modified-p)
12138 (> (buffer-size) 0)
12139 (not (gnus-y-or-n-p
12140 "Unsent article being composed; erase it? ")))
12144 (set-buffer gnus-article-buffer)
12145 (let ((buffer-read-only nil))
12146 (goto-char (point-min))
12147 (narrow-to-region (point-min)
12148 (progn (search-forward "\n\n") (point)))
12149 (add-text-properties (point-min) (point-max) '(invisible nil)))
12150 (if (and (boundp 'gnus-reply-to-function)
12151 gnus-reply-to-function)
12154 (gnus-narrow-to-headers)
12155 (setq follow-to (funcall gnus-reply-to-function group)))))
12156 (setq from (mail-fetch-field "from"))
12157 (setq date (mail-fetch-field "date"))
12160 (string-match " *at \\| *@ \\| *(\\| *<" from)))
12162 (concat (if stop-pos (substring from 0 stop-pos) from)
12163 "'s message of " date))))
12164 (setq sender (mail-fetch-field "sender"))
12165 (setq subject (or (mail-fetch-field "subject")
12167 (or (string-match "^[Rr][Ee]:" subject)
12168 (setq subject (concat "Re: " subject)))
12169 (setq cc (mail-fetch-field "cc"))
12170 (setq reply-to (mail-fetch-field "reply-to"))
12171 (setq references (mail-fetch-field "references"))
12172 (setq message-id (mail-fetch-field "message-id"))
12174 (setq news-reply-yank-from from)
12175 (setq news-reply-yank-message-id message-id)
12176 (mail-setup (or to-address
12177 (if (and follow-to (not (stringp follow-to))) ""
12178 (or follow-to reply-to from sender "")))
12179 subject message-of nil gnus-article-buffer nil)
12180 (if (and follow-to (listp follow-to))
12182 (goto-char (point-min))
12184 (insert (car (car follow-to)) ": " (cdr (car follow-to)) "\n")
12185 (setq follow-to (cdr follow-to)))))
12186 ;; Fold long references line to follow RFC1036.
12187 (mail-position-on-field "References")
12188 (let ((begin (- (point) (length "References: ")))
12190 (fill-prefix "\t"))
12191 (if references (insert references))
12192 (if (and references message-id) (insert " "))
12193 (if message-id (insert message-id))
12194 ;; The region must end with a newline to fill the region
12195 ;; without inserting extra newline.
12196 (fill-region-as-paragraph begin (1+ (point))))
12197 (goto-char (point-min))
12199 (concat "^" (regexp-quote mail-header-separator) "$"))
12202 (let ((last (point)))
12204 (mail-yank-original nil))
12205 (run-hooks 'news-reply-header-hook)
12206 (goto-char last))))
12207 (let ((mail (current-buffer)))
12210 (gnus-configure-windows '(0 1 0))
12211 (switch-to-buffer mail))
12212 (gnus-configure-windows '(0 0 1))
12213 (switch-to-buffer-other-window mail))))))
12215 (defun gnus-mail-yank-original ()
12218 (mail-yank-original nil))
12219 (run-hooks 'news-reply-header-hook))
12221 (defun gnus-mail-send-and-exit ()
12223 (let ((cbuf (current-buffer)))
12224 (mail-send-and-exit nil)
12225 (if (get-buffer gnus-group-buffer)
12229 (let ((reply gnus-article-reply))
12231 (get-buffer (car reply))
12232 (buffer-name (car reply)))
12234 (set-buffer (car reply))
12236 (gnus-summary-mark-article-as-replied
12238 (and gnus-winconf-post-news
12239 (set-window-configuration gnus-winconf-post-news))
12240 (setq gnus-winconf-post-news nil)))))
12242 (defun gnus-mail-forward-using-mail ()
12243 "Forward the current message to another user using mail."
12244 ;; This is almost a carbon copy of rmail-forward in rmail.el.
12245 (let ((forward-buffer (current-buffer))
12247 (concat "[" (if (memq 'mail (assoc (symbol-name
12248 (car (gnus-find-method-for-group
12249 gnus-newsgroup-name)))
12250 gnus-valid-select-methods))
12251 (gnus-fetch-field "From")
12252 gnus-newsgroup-name)
12253 "] " (or (gnus-fetch-field "Subject") "")))
12255 ;; If only one window, use it for the mail buffer.
12256 ;; Otherwise, use another window for the mail buffer
12257 ;; so that the Rmail buffer remains visible
12258 ;; and sending the mail will get back to it.
12259 (if (if (one-window-p t)
12260 (mail nil nil subject)
12261 (mail-other-window nil nil subject))
12263 (use-local-map (copy-keymap emacs-lisp-mode-map))
12264 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
12265 (setq beg (goto-char (point-max)))
12266 (insert "------- Start of forwarded message -------\n")
12267 (insert-buffer forward-buffer)
12268 (goto-char (point-max))
12269 (insert "------- End of forwarded message -------\n")
12270 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
12272 (while (setq beg (next-single-property-change (point) 'invisible))
12274 (delete-region beg (or (next-single-property-change
12275 (point) 'invisible)
12277 ;; You have a chance to arrange the message.
12278 (run-hooks 'gnus-mail-forward-hook)))))
12280 (defun gnus-mail-other-window-using-mail ()
12281 "Compose mail other window using mail."
12282 (mail-other-window nil nil nil nil nil (get-buffer gnus-article-buffer))
12283 (use-local-map (copy-keymap (current-local-map)))
12284 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit))
12291 (defvar gnus-dribble-ignore nil)
12293 (defun gnus-dribble-file-name ()
12294 (concat gnus-startup-file "-dribble"))
12296 (defun gnus-dribble-open ()
12299 (setq gnus-dribble-buffer (find-file-noselect (gnus-dribble-file-name))))
12300 (buffer-disable-undo (current-buffer))
12301 (bury-buffer gnus-dribble-buffer)
12303 (goto-char (point-max))))
12305 (defun gnus-dribble-enter (string)
12306 (if (and (not gnus-dribble-ignore)
12307 gnus-dribble-buffer
12308 (buffer-name gnus-dribble-buffer))
12309 (let ((obuf (current-buffer)))
12310 (set-buffer gnus-dribble-buffer)
12311 (insert string "\n")
12312 (set-window-point (get-buffer-window (current-buffer)) (point-max))
12313 (set-buffer obuf))))
12315 (defun gnus-dribble-read-file ()
12316 (let ((dribble-file (gnus-dribble-file-name)))
12318 (set-buffer (setq gnus-dribble-buffer
12320 (file-name-nondirectory dribble-file))))
12321 (gnus-add-current-to-buffer-list)
12323 (set-visited-file-name dribble-file)
12324 (buffer-disable-undo (current-buffer))
12325 (bury-buffer (current-buffer))
12326 (set-buffer-modified-p nil)
12327 (let ((auto (make-auto-save-file-name))
12328 (gnus-dribble-ignore t))
12329 (if (or (file-exists-p auto) (file-exists-p dribble-file))
12331 (if (file-newer-than-file-p auto dribble-file)
12332 (setq dribble-file auto))
12333 (insert-file-contents dribble-file)
12334 (if (not (zerop (buffer-size)))
12335 (set-buffer-modified-p t))
12337 "Auto-save file exists. Do you want to read it? ")
12339 (message "Reading %s..." dribble-file)
12340 (eval-current-buffer)
12341 (message "Reading %s...done" dribble-file)))))))))
12343 (defun gnus-dribble-delete-file ()
12344 (if (file-exists-p (gnus-dribble-file-name))
12345 (delete-file (gnus-dribble-file-name)))
12346 (if gnus-dribble-buffer
12348 (set-buffer gnus-dribble-buffer)
12349 (let ((auto (make-auto-save-file-name)))
12350 (if (file-exists-p auto)
12351 (delete-file auto))
12353 (set-buffer-modified-p nil)))))
12355 (defun gnus-dribble-save ()
12356 (if (and gnus-dribble-buffer
12357 (buffer-name gnus-dribble-buffer))
12359 (set-buffer gnus-dribble-buffer)
12362 (defun gnus-dribble-clear ()
12364 (if (and gnus-dribble-buffer
12365 (buffer-name (get-buffer gnus-dribble-buffer)))
12367 (set-buffer gnus-dribble-buffer)
12369 (set-buffer-modified-p nil)
12370 (setq buffer-saved-size (buffer-size))))))
12373 ;;; Server Communication
12376 ;; All the Gnus backends have the same interface, and should return
12377 ;; data in a similar format. Below is an overview of what functions
12378 ;; these packages must supply and what results they should return.
12382 ;; `nntp-server-buffer' - All data should be returned to Gnus in this
12385 ;; Functions for the imaginary backend `choke':
12387 ;; `choke-retrieve-headers ARTICLES &optional GROUP SERVER'
12388 ;; Should return all headers for all ARTICLES, or return NOV lines for
12391 ;; `choke-request-group GROUP &optional SERVER DISCARD'
12392 ;; Switch to GROUP. If DISCARD is nil, active information on the group
12393 ;; must be returned.
12395 ;; `choke-close-group GROUP &optional SERVER'
12396 ;; Close group. Most backends won't have to do anything with this
12397 ;; call, but it is an opportunity to clean up, if that is needed. It
12398 ;; is called when Gnus exits a group.
12400 ;; `choke-request-article ARTICLE &optional GROUP SERVER'
12401 ;; Return ARTICLE, which is either an article number or
12402 ;; message-id. Note that not all backends can return articles based on
12405 ;; `choke-request-list SERVER'
12406 ;; Return a list of all newsgroups on SERVER.
12408 ;; `choke-request-list-newsgroups SERVER'
12409 ;; Return a list of descriptions of all newsgroups on SERVER.
12411 ;; `choke-request-newgroups DATE &optional SERVER'
12412 ;; Return a list of all groups that have arrived after DATE on
12413 ;; SERVER. Note that the date doesn't have to be respected - Gnus will
12414 ;; always check whether the groups are old or not. Backends that do
12415 ;; not store date information may just return the entire list of
12416 ;; groups, although this might not be a good idea in general.
12418 ;; `choke-request-post-buffer METHOD HEADER ARTICLE-BUFFER GROUP INFO'
12419 ;; Should return a buffer that is suitable for "posting". nnspool and
12420 ;; nntp return a `*post-buffer*', and nnmail return a `*mail*'
12421 ;; buffer. This function should fill out the appropriate headers.
12423 ;; `choke-request-post &optional SERVER'
12424 ;; Function that will be called from a buffer to be posted.
12426 ;; `choke-open-server SERVER &optional ARGUMENT'
12427 ;; Open a connection to SERVER.
12429 ;; `choke-close-server &optional SERVER'
12430 ;; Close the connection to SERVER.
12432 ;; `choke-server-opened &optional SERVER'
12433 ;; Whether the conenction to SERVER is opened or not.
12435 ;; `choke-server-status &optional SERVER'
12436 ;; Should return a status string (not in the nntp buffer, but as the
12437 ;; result of the function).
12439 ;; `choke-retrieve-groups GROUPS &optional SERVER'
12440 ;; Optional function for retrieving active file info on all groups in
12441 ;; GROUPS. Two return formats are supported: The normal active file
12442 ;; format, and a list of GROUP lines. This function should return (as
12443 ;; a function value) either `active' or `group', depending on what
12444 ;; format it returns.
12446 ;; The following functions are optional and apply only to backends
12447 ;; that are able to control the contents of their groups totally
12448 ;; (ie. mail backends.) Backends that aren't able to do that
12449 ;; shouldn't define these functions at all. Gnus will check for their
12450 ;; presence before attempting to call them.
12452 ;; `choke-request-expire-articles ARTICLES &optional NEWSGROUP SERVER'
12453 ;; Should expire (according to some aging scheme) all ARTICLES. Most
12454 ;; backends will not be able to expire articles. Should return a list
12455 ;; of all articles that were not expired.
12457 ;; `choke-request-move-article ARTICLE GROUP SERVER ACCEPT-FORM &optional LAST'
12458 ;; Should move ARTICLE from GROUP on SERVER by using ACCEPT-FORM.
12459 ;; Removes any information it has added to the article (extra headers,
12460 ;; whatever - make it as clean as possible), and then passes the
12461 ;; article on by evaling ACCEPT-FORM, which is normally a call to the
12462 ;; function described below. If the ACCEPT-FORM returns a non-nil
12463 ;; value, the article should then be deleted. If LAST is nil, that
12464 ;; means that there will be further calls to this function. This might
12465 ;; be taken as an advice not to save buffers/internal variables just
12466 ;; yet, but wait until the last call to speed things up.
12468 ;; `choke-request-accept-article GROUP &optional LAST'
12469 ;; The contents of the current buffer will be put into GROUP. There
12470 ;; should, of course, be an article in the current buffer. This
12471 ;; function is normally only called by the function described above,
12472 ;; and LAST works the same way as in that function.
12474 ;; `choke-request-replace-article ARTICLE GROUP BUFFER'
12475 ;; Replace ARTICLE in GROUP with the contents of BUFFER.
12476 ;; This provides an easy interface for allowing editing of
12477 ;; articles. Note that even headers may be edited, so the backend has
12478 ;; to update any tables (nov buffers, etc) that it maintains after
12479 ;; replacing the article.
12481 ;; `choke-request-create-group GROUP &optional SERVER'
12482 ;; Create GROUP on SERVER. This might be a new, empty group, or it
12483 ;; might be a group that already exists, but hasn't been registered
12486 ;; All these functions must return nil if they couldn't service the
12487 ;; request. If the optional arguments are not supplied, some "current"
12488 ;; or "default" values should be used. In short, one should emulate an
12489 ;; NNTP server, in a way.
12491 ;; If you want to write a new backend, you just have to supply the
12492 ;; functions listed above. In addition, you must enter the new backend
12493 ;; into the list of valid select methods:
12494 ;; (setq gnus-valid-select-methods
12495 ;; (cons '("choke" mail) gnus-valid-select-methods))
12496 ;; The first element in this list is the name of the backend. Other
12497 ;; elemnets may be `mail' (for mail groups), `post' (for news
12498 ;; groups), `none' (neither), `respool' (for groups that can control
12499 ;; their contents).
12501 (defun gnus-start-news-server (&optional confirm)
12502 "Open a method for getting news.
12503 If CONFIRM is non-nil, the user will be asked for an NNTP server."
12505 (if gnus-current-select-method
12506 ;; Stream is already opened.
12508 ;; Open NNTP server.
12509 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
12512 ;; Read server name with completion.
12513 (setq gnus-nntp-server
12514 (completing-read "NNTP server: "
12515 (mapcar (lambda (server) (list server))
12516 (cons (list gnus-nntp-server)
12517 gnus-secondary-servers))
12518 nil nil gnus-nntp-server))))
12520 (if (and gnus-nntp-server
12521 (stringp gnus-nntp-server)
12522 (not (string= gnus-nntp-server "")))
12523 (setq gnus-select-method
12524 (cond ((or (string= gnus-nntp-server "")
12525 (string= gnus-nntp-server "::"))
12526 (list 'nnspool (system-name)))
12527 ((string-match ":" gnus-nntp-server)
12528 (list 'nnmh gnus-nntp-server))
12530 (list 'nntp gnus-nntp-server)))))
12532 (setq how (car gnus-select-method))
12533 (setq where (car (cdr gnus-select-method)))
12534 (cond ((eq how 'nnspool)
12536 (message "Looking up local news spool..."))
12539 (message "Looking up mh spool..."))
12542 (setq gnus-current-select-method gnus-select-method)
12543 (run-hooks 'gnus-open-server-hook)
12545 ;; gnus-open-server-hook might have opened it
12546 (gnus-server-opened gnus-select-method)
12547 (gnus-open-server gnus-select-method)
12550 "%s server on %s can't be opened. Continue? "
12551 (car gnus-select-method) (nth 1 gnus-select-method)))
12553 (message "Couldn't open server on %s" (nth 1 gnus-select-method))
12557 (defun gnus-check-news-server (method)
12558 "If the news server is down, start it up again."
12559 (let ((method (if method method gnus-select-method)))
12560 (and (stringp method)
12561 (setq method (gnus-server-to-method method)))
12562 (if (gnus-server-opened method)
12563 ;; Stream is already opened.
12566 (message "Opening server %s on %s..." (car method) (nth 1 method))
12567 (run-hooks 'gnus-open-server-hook)
12568 (or (gnus-server-opened method)
12569 (gnus-open-server method))
12572 (defun gnus-nntp-message (&optional message)
12573 "Check the status of the NNTP server.
12574 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
12575 is returned insted of the status string."
12576 (let ((status (gnus-status-message (gnus-find-method-for-group
12577 gnus-newsgroup-name)))
12578 (message (or message "")))
12579 (if (and (stringp status) (> (length status) 0))
12582 (defun gnus-get-function (method function)
12583 (and (stringp method)
12584 (setq method (gnus-server-to-method method)))
12585 (let ((func (intern (format "%s-%s" (car method) function))))
12586 (if (not (fboundp func))
12588 (require (car method))
12589 (if (not (fboundp func))
12590 (error "No such function: %s" func))))
12593 ;;; Interface functions to the backends.
12595 (defun gnus-open-server (method)
12596 (funcall (gnus-get-function method 'open-server)
12597 (nth 1 method) (nthcdr 2 method)))
12599 (defun gnus-close-server (method)
12600 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
12602 (defun gnus-request-list (method)
12603 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
12605 (defun gnus-request-list-newsgroups (method)
12606 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
12608 (defun gnus-request-newgroups (date method)
12609 (funcall (gnus-get-function method 'request-newgroups)
12610 date (nth 1 method)))
12612 (defun gnus-server-opened (method)
12613 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
12615 (defun gnus-status-message (method)
12616 (let ((method (if (stringp method) (gnus-find-method-for-group method)
12618 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
12620 (defun gnus-request-group (group &optional dont-check)
12621 (let ((method (gnus-find-method-for-group group)))
12622 (funcall (gnus-get-function method 'request-group)
12623 (gnus-group-real-name group) (nth 1 method) dont-check)))
12625 (defun gnus-list-active-group (group)
12626 (let ((method (gnus-find-method-for-group group))
12627 (func 'list-active-group))
12628 (and (gnus-check-backend-function func group)
12629 (funcall (gnus-get-function method func)
12630 (gnus-group-real-name group) (nth 1 method)))))
12632 (defun gnus-request-group-description (group)
12633 (let ((method (gnus-find-method-for-group group))
12634 (func 'request-group-description))
12635 (and (gnus-check-backend-function func group)
12636 (funcall (gnus-get-function method func)
12637 (gnus-group-real-name group) (nth 1 method)))))
12639 (defun gnus-close-group (group)
12640 (let ((method (gnus-find-method-for-group group)))
12641 (funcall (gnus-get-function method 'close-group)
12642 (gnus-group-real-name group) (nth 1 method))))
12644 (defun gnus-retrieve-headers (articles group)
12645 (let ((method (gnus-find-method-for-group group)))
12646 (funcall (gnus-get-function method 'retrieve-headers)
12647 articles (gnus-group-real-name group) (nth 1 method))))
12649 (defun gnus-retrieve-groups (groups method)
12650 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
12652 (defun gnus-request-article (article group &optional buffer)
12653 (let ((method (gnus-find-method-for-group group)))
12654 (funcall (gnus-get-function method 'request-article)
12655 article (gnus-group-real-name group) (nth 1 method) buffer)))
12657 (defun gnus-request-head (article group)
12658 (let ((method (gnus-find-method-for-group group)))
12659 (funcall (gnus-get-function method 'request-head)
12660 article (gnus-group-real-name group) (nth 1 method))))
12662 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
12663 (defun gnus-request-post-buffer (post group subject header artbuf
12664 info follow-to respect-poster)
12665 (let* ((info (or info (and group (nth 2 (gnus-gethash
12666 group gnus-newsrc-hashtb)))))
12668 (if (and gnus-post-method
12669 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
12671 (format "%s" (car (gnus-find-method-for-group
12672 gnus-newsgroup-name)))
12673 gnus-valid-select-methods)))
12675 (gnus-find-method-for-group gnus-newsgroup-name))))
12676 (let ((mail-self-blind nil)
12677 (mail-archive-file-name nil))
12678 (funcall (gnus-get-function method 'request-post-buffer)
12679 post group subject header artbuf info follow-to
12682 (defun gnus-request-post (method &optional force)
12683 (and (stringp method)
12684 (setq method (gnus-server-to-method method)))
12685 (and (not force) gnus-post-method
12686 (memq 'post (assoc (format "%s" (car method))
12687 gnus-valid-select-methods))
12688 (setq method gnus-post-method))
12689 (funcall (gnus-get-function method 'request-post)
12692 (defun gnus-request-expire-articles (articles group &optional force)
12693 (let ((method (gnus-find-method-for-group group)))
12694 (funcall (gnus-get-function method 'request-expire-articles)
12695 articles (gnus-group-real-name group) (nth 1 method)
12698 (defun gnus-request-move-article
12699 (article group server accept-function &optional last)
12700 (let ((method (gnus-find-method-for-group group)))
12701 (funcall (gnus-get-function method 'request-move-article)
12702 article (gnus-group-real-name group)
12703 (nth 1 method) accept-function last)))
12705 (defun gnus-request-accept-article (group &optional last)
12706 (let ((func (if (symbolp group) group
12707 (car (gnus-find-method-for-group group)))))
12708 (funcall (intern (format "%s-request-accept-article" func))
12709 (if (stringp group) (gnus-group-real-name group) group)
12712 (defun gnus-request-replace-article (article group buffer)
12713 (let ((func (car (gnus-find-method-for-group group))))
12714 (funcall (intern (format "%s-request-replace-article" func))
12715 article (gnus-group-real-name group) buffer)))
12717 (defun gnus-request-create-group (group)
12718 (let ((method (gnus-find-method-for-group group)))
12719 (funcall (gnus-get-function method 'request-create-group)
12720 (gnus-group-real-name group) (nth 1 method))))
12722 (defun gnus-find-method-for-group (group &optional info)
12723 (or gnus-override-method
12725 gnus-select-method)
12726 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
12729 (not (setq method (nth 4 info))))
12730 (setq method gnus-select-method)
12732 (cond ((stringp method)
12733 (gnus-server-to-method method))
12734 ((stringp (car method))
12735 (gnus-server-extend-method group method))
12738 (gnus-server-add-address method))))
12740 (defun gnus-check-backend-function (func group)
12741 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
12743 (fboundp (intern (format "%s-%s" method func)))))
12745 (defun gnus-methods-using (method)
12746 (let ((valids gnus-valid-select-methods)
12749 (if (memq method (car valids))
12750 (setq outs (cons (car valids) outs)))
12751 (setq valids (cdr valids)))
12755 ;;; Active & Newsrc File Handling
12758 ;; Newsrc related functions.
12759 ;; Gnus internal format of gnus-newsrc-assoc:
12760 ;; (("alt.general" 3 (1 . 1))
12761 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
12762 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
12763 ;; The first item is the group name; the second is the subscription
12764 ;; level; the third is either a range of a list of ranges of read
12765 ;; articles, the optional fourth element is a list of marked articles,
12766 ;; the optional fifth element is the select method.
12768 ;; Gnus internal format of gnus-newsrc-hashtb:
12769 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
12770 ;; This is the entry for "alt.misc". The first element is the number
12771 ;; of unread articles in "alt.misc". The cdr of this entry is the
12772 ;; element *before* "alt.misc" in gnus-newsrc-assoc, which makes is
12773 ;; trivial to remove or add new elements into gnus-newsrc-assoc
12774 ;; without scanning the entire list. So, to get the actual information
12775 ;; of "alt.misc", you'd say something like
12776 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
12778 ;; Gnus internal format of gnus-active-hashtb:
12782 ;; The only element in each entry in this hash table is a range of
12783 ;; (possibly) available articles. (Articles in this range may have
12784 ;; been expired or cancelled.)
12786 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
12787 ;; ("alt.misc" "alt.test" "alt.general" ...)
12789 (defun gnus-setup-news (&optional rawfile level)
12790 "Setup news information.
12791 If RAWFILE is non-nil, the .newsrc file will also be read.
12792 If LEVEL is non-nil, the news will be set up at level LEVEL."
12793 (let ((init (not (and gnus-newsrc-assoc gnus-active-hashtb (not rawfile)))))
12794 ;; Clear some variables to re-initialize news information.
12795 (if init (setq gnus-newsrc-assoc nil gnus-active-hashtb nil))
12797 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
12798 (if init (gnus-read-newsrc-file rawfile))
12800 ;; Read the active file and create `gnus-active-hashtb'.
12801 ;; If `gnus-read-active-file' is nil, then we just create an empty
12802 ;; hash table. The partial filling out of the hash table will be
12803 ;; done in `gnus-get-unread-articles'.
12804 (if (and gnus-read-active-file
12806 (gnus-server-opened gnus-select-method))
12807 (gnus-read-active-file)
12808 (setq gnus-active-hashtb (make-vector 4095 0)))
12810 ;; Find the number of unread articles in each non-dead group.
12811 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed)))
12812 ;; Find new newsgroups and treat them.
12813 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
12814 (gnus-server-opened gnus-select-method))
12815 (gnus-find-new-newsgroups))
12816 (if (and init gnus-check-bogus-newsgroups
12817 gnus-read-active-file (not level)
12818 (gnus-server-opened gnus-select-method))
12819 (gnus-check-bogus-newsgroups))))
12821 (defun gnus-find-new-newsgroups ()
12822 "Search for new newsgroups and add them.
12823 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
12824 The `-n' option line from .newsrc is respected."
12826 (or (gnus-check-first-time-used)
12827 (if (or (consp gnus-check-new-newsgroups)
12828 (eq gnus-check-new-newsgroups 'ask-server))
12829 (gnus-ask-server-for-new-groups)
12831 group new-newsgroups)
12832 (or gnus-have-read-active-file (gnus-read-active-file))
12833 (setq gnus-newsrc-last-checked-date (current-time-string))
12834 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
12835 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
12836 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
12839 (setq group (symbol-name sym))
12840 (if (or (gnus-gethash group gnus-killed-hashtb)
12841 (gnus-gethash group gnus-newsrc-hashtb))
12843 (let ((do-sub (gnus-matches-options-n group)))
12844 (cond ((eq do-sub 'subscribe)
12845 (setq groups (1+ groups))
12846 (gnus-sethash group group gnus-killed-hashtb)
12848 gnus-subscribe-options-newsgroup-method group))
12849 ((eq do-sub 'ignore)
12852 (setq groups (1+ groups))
12853 (gnus-sethash group group gnus-killed-hashtb)
12854 (if gnus-subscribe-hierarchical-interactive
12855 (setq new-newsgroups (cons group new-newsgroups))
12856 (funcall gnus-subscribe-newsgroup-method group)))))))
12857 gnus-active-hashtb)
12859 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12860 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12862 (message "%d new newsgroup%s arrived."
12863 groups (if (> groups 1) "s have" " has")))))))
12865 (defun gnus-matches-options-n (group)
12866 ;; Returns `subscribe' if the group is to be uncoditionally
12867 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
12868 ;; no match for the group.
12870 ;; First we check the two user variables.
12872 ((and gnus-options-not-subscribe
12873 (string-match gnus-options-not-subscribe group))
12875 ((and gnus-options-subscribe
12876 (string-match gnus-options-subscribe group))
12878 ;; Then we go through the list that was retrieved from the .newsrc
12879 ;; file. This list has elements on the form
12880 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
12881 ;; is in the reverse order of the options line) is returned.
12883 (let ((regs gnus-newsrc-options-n))
12885 (not (string-match (car (car gnus-newsrc-options-n)) group)))
12886 (setq regs (cdr regs)))
12887 (and regs (cdr (car regs)))))))
12889 (defun gnus-ask-server-for-new-groups ()
12890 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
12891 (methods (cons gnus-select-method
12893 (and (consp gnus-check-new-newsgroups)
12894 gnus-check-new-newsgroups)
12895 gnus-secondary-select-methods)))
12897 (new-date (current-time-string))
12898 hashtb group new-newsgroups got-new)
12899 ;; Go thorugh both primary and secondary select methods and
12900 ;; request new newsgroups.
12902 (if (gnus-request-newgroups date (car methods))
12905 (or hashtb (setq hashtb (gnus-make-hashtable
12906 (count-lines (point-min) (point-max)))))
12907 (set-buffer nntp-server-buffer)
12908 ;; Enter all the new groups in a hashtable.
12909 (gnus-active-to-gnus-format (car methods) hashtb)))
12910 (setq methods (cdr methods)))
12911 (and got-new (setq gnus-newsrc-last-checked-date new-date))
12912 ;; Now all new groups from all select methods are in `hashtb'.
12914 (lambda (group-sym)
12915 (setq group (symbol-name group-sym))
12916 (if (or (gnus-gethash group gnus-newsrc-hashtb)
12917 (member group gnus-zombie-list)
12918 (member group gnus-killed-list))
12919 ;; The group is already known.
12921 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb)
12922 (let ((do-sub (gnus-matches-options-n group)))
12923 (cond ((eq do-sub 'subscribe)
12924 (setq groups (1+ groups))
12925 (gnus-sethash group group gnus-killed-hashtb)
12927 gnus-subscribe-options-newsgroup-method group))
12928 ((eq do-sub 'ignore)
12931 (setq groups (1+ groups))
12932 (gnus-sethash group group gnus-killed-hashtb)
12933 (if gnus-subscribe-hierarchical-interactive
12934 (setq new-newsgroups (cons group new-newsgroups))
12935 (funcall gnus-subscribe-newsgroup-method group)))))))
12938 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12939 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12941 (message "%d new newsgroup%s arrived."
12942 groups (if (> groups 1) "s have" " has")))
12945 (defun gnus-check-first-time-used ()
12946 (if (or (> (length gnus-newsrc-assoc) 1)
12947 (file-exists-p gnus-startup-file)
12948 (file-exists-p (concat gnus-startup-file ".el"))
12949 (file-exists-p (concat gnus-startup-file ".eld")))
12951 (message "First time user; subscribing you to default groups")
12952 (or gnus-have-read-active-file (gnus-read-active-file))
12953 (setq gnus-newsrc-last-checked-date (current-time-string))
12954 (let ((groups gnus-default-subscribed-newsgroups)
12958 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
12961 (setq group (symbol-name sym))
12962 (let ((do-sub (gnus-matches-options-n group)))
12963 (cond ((eq do-sub 'subscribe)
12964 (gnus-sethash group group gnus-killed-hashtb)
12966 gnus-subscribe-options-newsgroup-method group))
12967 ((eq do-sub 'ignore)
12970 (setq gnus-killed-list (cons group gnus-killed-list))))))
12971 gnus-active-hashtb)
12973 (if (gnus-gethash (car groups) gnus-active-hashtb)
12974 (gnus-group-change-level
12975 (car groups) gnus-level-default-subscribed gnus-level-killed))
12976 (setq groups (cdr groups)))
12977 (gnus-group-make-help-group)
12978 (and gnus-novice-user
12979 (message (substitute-command-keys "\\<gnus-group-mode-map>\\[gnus-group-list-killed] to list killed groups")))))))
12981 ;; `gnus-group-change-level' is the fundamental function for changing
12982 ;; subscription levels of newsgroups. This might mean just changing
12983 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
12984 ;; again, which subscribes/unsubscribes a group, which is equally
12985 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
12986 ;; from 8-9 to 1-7 means that you remove the group from the list of
12987 ;; killed (or zombie) groups and add them to the (kinda) subscribed
12988 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
12989 ;; which is trivial.
12990 ;; ENTRY can either be a string (newsgroup name) or a list (if
12991 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
12992 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
12994 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
12995 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
12997 (defun gnus-group-change-level (entry level &optional oldlevel
12998 previous fromkilled)
12999 (let ((pinfo entry)
13000 group info active num)
13001 ;; Glean what info we can from the arguments
13003 (if fromkilled (setq group (nth 1 entry))
13004 (setq group (car (nth 2 entry))))
13005 (setq group entry))
13006 (if (and (stringp entry)
13008 (< oldlevel gnus-level-zombie))
13009 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
13010 (if (and (not oldlevel)
13012 (setq oldlevel (car (cdr (nth 2 entry)))))
13013 (if (stringp previous)
13014 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
13016 (gnus-dribble-enter
13017 (format "(gnus-group-change-level %S %S %S %S %S)"
13018 group level oldlevel (car (nth 2 previous)) fromkilled))
13020 ;; Then we remove the newgroup from any old structures, if needed.
13021 ;; If the group was killed, we remove it from the killed or zombie
13022 ;; list. If not, and it is in fact going to be killed, we remove
13023 ;; it from the newsrc hash table and assoc.
13024 (cond ((>= oldlevel gnus-level-zombie)
13025 (if (= oldlevel gnus-level-zombie)
13026 (setq gnus-zombie-list (delete group gnus-zombie-list))
13027 (setq gnus-killed-list (delete group gnus-killed-list))))
13029 (if (>= level gnus-level-zombie)
13031 (gnus-sethash (car (nth 2 entry))
13032 nil gnus-newsrc-hashtb)
13034 (setcdr (gnus-gethash (car (nth 3 entry))
13035 gnus-newsrc-hashtb)
13037 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
13039 ;; Finally we enter (if needed) the list where it is supposed to
13040 ;; go, and change the subscription level. If it is to be killed,
13041 ;; we enter it into the killed or zombie list.
13042 (cond ((>= level gnus-level-zombie)
13043 (and (string= group (gnus-group-real-name group))
13044 (if (= level gnus-level-zombie)
13045 (setq gnus-zombie-list (cons group gnus-zombie-list))
13046 (setq gnus-killed-list (cons group gnus-killed-list)))))
13048 ;; If the list is to be entered into the newsrc assoc, and
13049 ;; it was killed, we have to create an entry in the newsrc
13050 ;; hashtb format and fix the pointers in the newsrc assoc.
13051 (if (>= oldlevel gnus-level-zombie)
13055 (setq info (cdr entry))
13056 (setq num (car entry)))
13057 (setq active (gnus-gethash group gnus-active-hashtb))
13058 (setq num (if active (- (1+ (cdr active)) (car active)) t))
13059 ;; Check whether the group is foreign. If so, the
13060 ;; foreign select method has to be entered into the
13062 (let ((method (gnus-group-method-name group)))
13063 (if (eq method gnus-select-method)
13064 (setq info (list group level nil))
13065 (setq info (list group level nil nil method)))))
13066 (setq entry (cons info (if previous (cdr (cdr previous))
13067 (cdr gnus-newsrc-assoc))))
13068 (setcdr (if previous (cdr previous) gnus-newsrc-assoc)
13070 (gnus-sethash group (cons num (if previous (cdr previous)
13071 gnus-newsrc-assoc))
13072 gnus-newsrc-hashtb)
13074 (setcdr (gnus-gethash (car (car (cdr entry)))
13075 gnus-newsrc-hashtb)
13077 ;; It was alive, and it is going to stay alive, so we
13078 ;; just change the level and don't change any pointers or
13079 ;; hash table entries.
13080 (setcar (cdr (car (cdr (cdr entry)))) level))))))
13082 (defun gnus-kill-newsgroup (newsgroup)
13083 "Obsolete function. Kills a newsgroup."
13084 (gnus-group-change-level
13085 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
13087 (defun gnus-check-bogus-newsgroups (&optional confirm)
13088 "Remove bogus newsgroups.
13089 If CONFIRM is non-nil, the user has to confirm the deletion of every
13091 (let ((newsrc (cdr gnus-newsrc-assoc))
13093 (message "Checking bogus newsgroups...")
13094 (or gnus-have-read-active-file (gnus-read-active-file))
13095 ;; Find all bogus newsgroup that are subscribed.
13097 (setq group (car (car newsrc)))
13098 (if (or (gnus-gethash group gnus-active-hashtb)
13099 (nth 4 (car newsrc))
13101 (not (gnus-y-or-n-p
13102 (format "Remove bogus newsgroup: %s " group)))))
13103 ;; Active newsgroup.
13105 ;; Found a bogus newsgroup.
13106 (setq bogus (cons group bogus)))
13107 (setq newsrc (cdr newsrc)))
13108 ;; Remove all bogus subscribed groups by first killing them, and
13109 ;; then removing them from the list of killed groups.
13111 (gnus-group-change-level
13112 (gnus-gethash (car bogus) gnus-newsrc-hashtb) gnus-level-killed)
13113 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))
13114 (setq bogus (cdr bogus)))
13115 ;; Then we remove all bogus groups from the list of killed and
13116 ;; zombie groups. They are are removed without confirmation.
13117 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
13120 (setq killed (symbol-value (car dead-lists)))
13122 (setq group (car killed))
13123 (or (gnus-gethash group gnus-active-hashtb)
13124 ;; The group is bogus.
13125 (set (car dead-lists)
13126 (delete group (symbol-value (car dead-lists)))))
13127 (setq killed (cdr killed)))
13128 (setq dead-lists (cdr dead-lists))))
13129 (message "Checking bogus newsgroups... done")))
13131 (defun gnus-check-duplicate-killed-groups ()
13132 "Remove duplicates from the list of killed groups."
13134 (let ((killed gnus-killed-list))
13136 (message "%d" (length killed))
13137 (setcdr killed (delete (car killed) (cdr killed)))
13138 (setq killed (cdr killed)))))
13140 ;; Go though `gnus-newsrc-assoc' and compare with `gnus-active-hashtb'
13141 ;; and compute how many unread articles there are in each group.
13142 (defun gnus-get-unread-articles (&optional level)
13143 (let ((newsrc (cdr gnus-newsrc-assoc))
13144 (level (or level (1+ gnus-level-subscribed)))
13145 info group active virtuals)
13146 (message "Checking new news...")
13148 (setq info (car newsrc))
13149 (setq group (car info))
13150 (setq active (gnus-gethash group gnus-active-hashtb))
13152 ;; Check newsgroups. If the user doesn't want to check them, or
13153 ;; they can't be checked (for instance, if the news server can't
13154 ;; be reached) we just set the number of unread articles in this
13155 ;; newsgroup to t. This means that Gnus thinks that there are
13156 ;; unread articles, but it has no idea how many.
13158 (if (or (and gnus-activate-foreign-newsgroups
13159 (not (numberp gnus-activate-foreign-newsgroups)))
13160 (and (numberp gnus-activate-foreign-newsgroups)
13161 (<= (nth 1 info) gnus-activate-foreign-newsgroups)
13162 (<= (nth 1 info) level)))
13163 (if (eq (car (nth 4 info)) 'nnvirtual)
13164 (setq virtuals (cons info virtuals))
13165 (setq active (gnus-activate-newsgroup (car info)))))
13166 (if (and (not gnus-read-active-file)
13167 (<= (nth 1 info) level))
13169 (setq active (gnus-activate-newsgroup (car info))))))
13171 (or active (progn (gnus-sethash group nil gnus-active-hashtb)
13172 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
13173 (and active (gnus-get-unread-articles-in-group info active))
13174 (setq newsrc (cdr newsrc)))
13176 ;; Activate the virtual groups. This has to be done after all the
13178 ;; !!! If one virtual group contains another virtual group, even
13179 ;; doing it this way might cause problems.
13181 (and (setq active (gnus-activate-newsgroup (car (car virtuals))))
13182 (gnus-get-unread-articles-in-group (car virtuals) active))
13183 (setq virtuals (cdr virtuals)))
13185 (message "Checking new news... done")))
13187 ;; Create a hash table out of the newsrc alist. The `car's of the
13188 ;; alist elements are used as keys.
13189 (defun gnus-make-hashtable-from-newsrc-alist ()
13190 (let ((alist gnus-newsrc-assoc)
13192 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
13194 (setq prev (setq gnus-newsrc-assoc
13195 (cons (list "dummy.group" 0 nil) alist))))
13197 (gnus-sethash (car (car alist)) (cons nil prev) gnus-newsrc-hashtb)
13199 (setq alist (cdr alist)))))
13201 (defun gnus-make-hashtable-from-killed ()
13202 "Create a hash table from the killed and zombie lists."
13203 (let ((lists '(gnus-killed-list gnus-zombie-list))
13205 (setq gnus-killed-hashtb
13206 (gnus-make-hashtable
13207 (+ (length gnus-killed-list) (length gnus-zombie-list))))
13209 (setq list (symbol-value (car lists)))
13210 (setq lists (cdr lists))
13212 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
13213 (setq list (cdr list))))))
13215 (defun gnus-get-unread-articles-in-group (info active)
13216 (let* ((range (nth 2 info))
13218 (marked (nth 3 info))
13219 srange lowest group highest)
13220 ;; Modify the list of read articles according to what articles
13221 ;; are available; then tally the unread articles and add the
13222 ;; number to the group hash table entry.
13223 (cond ((zerop (cdr active))
13226 (setq num (- (1+ (cdr active)) (car active))))
13227 ((not (listp (cdr range)))
13228 ;; Fix a single (num . num) range according to the
13229 ;; active hash table.
13230 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
13231 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
13232 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
13233 ;; Compute number of unread articles.
13234 (setq num (max 0 (- (cdr active)
13235 (- (1+ (cdr range)) (car range))))))
13237 ;; The read list is a list of ranges. Fix them according to
13238 ;; the active hash table.
13239 ;; First peel off any elements that are below the lower
13241 (while (and (cdr range)
13243 (or (and (atom (car (cdr range))) (car (cdr range)))
13244 (car (car (cdr range))))))
13245 (if (numberp (car range))
13248 (or (and (numberp (car (cdr range)))
13250 (cdr (car (cdr range))))))
13251 (setcdr (car range)
13252 (or (and (numberp (nth 1 range)) (nth 1 range))
13253 (cdr (car (cdr range))))))
13254 (setcdr range (cdr (cdr range))))
13255 ;; Adjust the first element to be the same as the lower limit.
13256 (if (and (not (atom (car range)))
13257 (< (cdr (car range)) (car active)))
13258 (setcdr (car range) (1- (car active))))
13259 ;; Then we want to peel off any elements that are higher
13260 ;; than the upper active limit.
13261 (let ((srange range))
13262 ;; Go past all legal elements.
13263 (while (and (cdr srange)
13264 (<= (or (and (atom (car (cdr srange)))
13265 (car (cdr srange)))
13266 (car (car (cdr srange)))) (cdr active)))
13267 (setq srange (cdr srange)))
13269 ;; Nuke all remaining illegal elements.
13270 (setcdr srange nil))
13272 ;; Adjust the final element.
13273 (if (and (not (atom (car srange)))
13274 (> (cdr (car srange)) (cdr active)))
13275 (setcdr (car srange) (cdr active))))
13276 ;; Compute the number of unread articles.
13278 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
13279 (cdr (car range))))
13280 (or (and (atom (car range)) (car range))
13281 (car (car range))))))
13282 (setq range (cdr range)))
13283 (setq num (max 0 (- (cdr active) num)))))
13286 (and (assq 'tick marked)
13287 (inline (gnus-remove-illegal-marked-articles
13288 (assq 'tick marked) (nth 2 info))))
13289 (and (assq 'dormant marked)
13290 (inline (gnus-remove-illegal-marked-articles
13291 (assq 'dormant marked) (nth 2 info))))
13293 (gnus-gethash (car info) gnus-newsrc-hashtb)
13294 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
13295 (length (cdr (assq 'dormant marked)))))))))
13298 (defun gnus-remove-illegal-marked-articles (marked ranges)
13299 (let ((m (cdr marked)))
13300 ;; Make sure that all ticked articles are a subset of the unread
13303 (if (gnus-member-of-range (car m) ranges)
13304 (setcdr marked (cdr m))
13306 (setq m (cdr m)))))
13308 (defun gnus-activate-newsgroup (group)
13309 (let ((method (gnus-find-method-for-group group))
13311 (and (or (gnus-server-opened method) (gnus-open-server method))
13312 (gnus-request-group group)
13314 (set-buffer nntp-server-buffer)
13316 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
13318 (goto-char (match-beginning 1))
13320 group (setq active (cons (read (current-buffer))
13321 (read (current-buffer))))
13322 gnus-active-hashtb))
13325 (defun gnus-update-read-articles
13326 (group unread unselected ticked &optional domarks replied expirable killed
13327 dormant bookmark score)
13328 "Update the list of read and ticked articles in GROUP using the
13329 UNREAD and TICKED lists.
13330 Note: UNSELECTED has to be sorted over `<'.
13331 Returns whether the updating was successful."
13332 (let* ((active (or gnus-newsgroup-active
13333 (gnus-gethash group gnus-active-hashtb)))
13334 (entry (gnus-gethash group gnus-newsrc-hashtb))
13335 (number (car entry))
13336 (info (nth 2 entry))
13337 (marked (nth 3 info))
13339 (unread (sort (copy-sequence unread) (function <)))
13341 (if (or (not info) (not active))
13342 ;; There is no info on this group if it was, in fact,
13343 ;; killed. Gnus stores no information on killed groups, so
13344 ;; there's nothing to be done.
13345 ;; One could store the information somewhere temporarily,
13346 ;; perhaps... Hmmm...
13348 ;; Remove any negative articles numbers.
13349 (while (and unread (< (car unread) 0))
13350 (setq unread (cdr unread)))
13351 (setq unread (sort (append unselected unread) '<))
13352 ;; Set the number of unread articles in gnus-newsrc-hashtb.
13353 (setcar entry (max 0 (- (length unread) (length ticked)
13354 (length dormant))))
13355 ;; Compute the ranges of read articles by looking at the list of
13356 ;; unread articles.
13358 (if (/= (car unread) prev)
13359 (setq read (cons (if (= prev (1- (car unread))) prev
13360 (cons prev (1- (car unread)))) read)))
13361 (setq prev (1+ (car unread)))
13362 (setq unread (cdr unread)))
13363 (if (<= prev (cdr active))
13364 (setq read (cons (cons prev (cdr active)) read)))
13365 ;; Enter this list into the group info.
13366 (setcar (cdr (cdr info))
13367 (if (> (length read) 1) (nreverse read) read))
13368 ;; Enter the list of ticked articles.
13369 (gnus-set-marked-articles
13371 (if domarks replied (cdr (assq 'reply marked)))
13372 (if domarks expirable (cdr (assq 'expire marked)))
13373 (if domarks killed (cdr (assq 'killed marked)))
13374 (if domarks dormant (cdr (assq 'dormant marked)))
13375 (if domarks bookmark (cdr (assq 'bookmark marked)))
13376 (if domarks score (cdr (assq 'score marked))))
13379 (defun gnus-make-articles-unread (group articles)
13380 "Mark ARTICLES in GROUP as unread."
13381 (let ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
13382 (gnus-gethash (gnus-group-real-name group)
13383 gnus-newsrc-hashtb)))))
13384 (setcar (nthcdr 2 info)
13385 (gnus-remove-from-range (nth 2 info) articles))
13386 (gnus-group-update-group group t)))
13388 (defun gnus-read-active-file ()
13389 "Get active file from NNTP server."
13390 (gnus-group-set-mode-line)
13391 (let ((methods (cons gnus-select-method gnus-secondary-select-methods))
13393 (setq gnus-have-read-active-file nil)
13395 (set-buffer nntp-server-buffer)
13397 (let* ((where (nth 1 (car methods)))
13398 (mesg (format "Reading active file%s via %s..."
13399 (if (and where (not (zerop (length where))))
13400 (concat " from " where) "")
13401 (car (car methods)))))
13403 (gnus-check-news-server (car methods))
13405 ((and (eq gnus-read-active-file 'some)
13406 (gnus-check-backend-function
13407 'retrieve-groups (car (car methods))))
13408 (let ((newsrc (cdr gnus-newsrc-assoc))
13411 (and (gnus-server-equal
13412 (gnus-find-method-for-group
13413 (car (car newsrc)) (car newsrc))
13414 (gnus-server-get-method nil (car methods)))
13415 (setq groups (cons (car (car newsrc)) groups)))
13416 (setq newsrc (cdr newsrc)))
13417 (setq list-type (gnus-retrieve-groups groups (car methods)))
13418 (cond ((not list-type)
13419 (message "Cannot read partial active file from %s server."
13420 (car (car methods)))
13422 ((eq list-type 'active)
13423 (gnus-active-to-gnus-format
13424 (and gnus-have-read-active-file (car methods)))
13425 (setq gnus-have-read-active-file t))
13427 (gnus-groups-to-gnus-format
13428 (and gnus-have-read-active-file (car methods)))
13429 (setq gnus-have-read-active-file t)))))
13431 (if (not (gnus-request-list (car methods)))
13433 (message "Cannot read active file from %s server."
13434 (car (car methods)))
13436 (gnus-active-to-gnus-format
13437 (and gnus-have-read-active-file (car methods)))
13438 (setq gnus-have-read-active-file t)
13439 (message "%s...done" mesg)))))
13440 (setq methods (cdr methods))))))
13442 ;; rewritten by jwz based on ideas from Rick Sladkey <jrs@world.std.com>
13443 ;; Further rewrites by lmi.
13444 (defun gnus-active-to-gnus-format (method &optional hashtb)
13445 "Convert active file format to internal format.
13446 Lines matching `gnus-ignored-newsgroups' are ignored."
13447 (let ((cur (current-buffer))
13451 (setq gnus-active-hashtb
13452 (gnus-make-hashtable
13453 (count-lines (point-min) (point-max))))))))
13454 ;; Delete unnecessary lines.
13455 (goto-char (point-min))
13456 (delete-matching-lines gnus-ignored-newsgroups)
13457 (and method (not (eq method gnus-select-method))
13458 (let ((prefix (gnus-group-prefixed-name "" method)))
13459 (goto-char (point-min))
13460 (while (and (not (eobp))
13461 (null (insert prefix))
13462 (zerop (forward-line 1))))))
13463 (goto-char (point-min))
13464 ;; Store active file in hashtable.
13466 (if (or (re-search-forward "\n.\r?$" nil t)
13467 (goto-char (point-max)))
13469 (beginning-of-line)
13470 (narrow-to-region (point-min) (point))))
13471 (goto-char (point-min))
13472 (if (string-match "%[oO]" gnus-group-line-format)
13473 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
13474 ;; If we want information on moderated groups, we use this
13477 (let ((mod-hashtb (make-vector 7 0))
13479 (while (not (eobp))
13480 (setq group (let ((obarray hashtb))
13482 (setq max (read cur))
13483 (set group (cons (read cur) max))
13484 ;; Enter moderated groups into a list.
13486 (symbol-name (let ((obarray mod-hashtb)) (read cur)))
13488 (setq gnus-moderated-list
13489 (cons (symbol-name group) gnus-moderated-list)))
13492 (progn (ding) (message "Possible error in active file."))))
13493 ;; And if we do not care about moderation, we use this loop,
13494 ;; which is faster.
13497 (while (not (eobp))
13498 ;; group gets set to a symbol interned in the hash table
13500 (setq group (let ((obarray hashtb)) (read cur)))
13501 (setq max (read cur))
13502 (set group (cons (read cur) max))
13505 (progn (ding) (message "Possible error in active file."))))))))
13507 (defun gnus-groups-to-gnus-format (method &optional hashtb)
13508 ;; Parse a "groups" active file.
13509 (let ((cur (current-buffer))
13513 (setq gnus-active-hashtb
13514 (gnus-make-hashtable
13515 (count-lines (point-min) (point-max)))))))
13516 (prefix (and method (not (eq method gnus-select-method))
13517 (gnus-group-prefixed-name "" method))))
13519 (goto-char (point-min))
13521 ;; We split this into to separate loops, one with the prefix
13522 ;; and one without to speed the reading up somewhat.
13524 (let (min max opoint)
13525 (while (not (eobp))
13526 (read cur) (read cur)
13527 (setq min (read cur)
13530 (skip-chars-forward " \t")
13533 (set (let ((obarray hashtb)) (read cur))
13536 (let (min max opoint)
13537 (while (not (eobp))
13538 (read cur) (read cur)
13539 (setq min (read cur)
13541 (set (let ((obarray hashtb)) (read cur))
13543 (forward-line 1))))
13545 (progn (ding) (message "Possible error in active file."))))))
13547 (defun gnus-read-newsrc-file (&optional force)
13548 "Read startup file.
13549 If FORCE is non-nil, the .newsrc file is read."
13550 (setq gnus-current-startup-file (gnus-make-newsrc-file gnus-startup-file))
13551 ;; Reset variables that might be defined in the .newsrc.eld file.
13552 (let ((variables gnus-variable-list))
13554 (set (car variables) nil)
13555 (setq variables (cdr variables))))
13556 (let* ((newsrc-file gnus-current-startup-file)
13557 (quick-file (concat newsrc-file ".el")))
13559 ;; We always load the .newsrc.eld file. If always contains
13560 ;; much information that can not be gotten from the .newsrc
13561 ;; file (ticked articles, killed groups, foreign methods, etc.)
13562 (gnus-read-newsrc-el-file quick-file)
13565 (and (file-newer-than-file-p newsrc-file quick-file)
13566 (file-newer-than-file-p newsrc-file
13567 (concat quick-file "d")))
13568 (not gnus-newsrc-assoc))
13569 ;; We read the .newsrc file. Note that if there if a
13570 ;; .newsrc.eld file exists, it has already been read, and
13571 ;; the `gnus-newsrc-hashtb' has been created. While reading
13572 ;; the .newsrc file, Gnus will only use the information it
13573 ;; can find there for changing the data already read -
13574 ;; ie. reading the .newsrc file will not trash the data
13575 ;; already read (except for read articles).
13577 (message "Reading %s..." newsrc-file)
13578 (set-buffer (find-file-noselect newsrc-file))
13579 (buffer-disable-undo (current-buffer))
13580 (gnus-newsrc-to-gnus-format)
13581 (kill-buffer (current-buffer))
13582 (message "Reading %s... done" newsrc-file)))
13583 (and gnus-use-dribble-file (gnus-dribble-read-file)))))
13585 (defun gnus-read-newsrc-el-file (file)
13586 (let ((ding-file (concat file "d")))
13587 ;; We always, always read the .eld file.
13588 (message "Reading %s..." ding-file)
13589 (condition-case nil
13590 (load ding-file t t t)
13592 (gnus-uncompress-newsrc-assoc)
13593 (gnus-make-hashtable-from-newsrc-alist)
13594 (if (not (file-newer-than-file-p file ding-file))
13596 ;; Old format quick file
13597 (message "Reading %s..." file)
13598 ;; The .el file is newer than the .eld file, so we read that one
13600 (gnus-read-old-newsrc-el-file file))))
13602 ;; Parse the old-style quick startup file
13603 (defun gnus-read-old-newsrc-el-file (file)
13604 (let (newsrc killed marked group g m len info)
13606 (let (gnus-killed-assoc gnus-marked-assoc gnus-newsrc-assoc)
13608 (condition-case nil
13611 (setq newsrc gnus-newsrc-assoc
13612 killed gnus-killed-assoc
13613 marked gnus-marked-assoc)))
13614 (setq gnus-newsrc-assoc nil)
13616 (setq group (car newsrc))
13617 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
13620 (setcar (nthcdr 2 info) (cdr (cdr group)))
13622 (if (nth 1 group) gnus-level-default-subscribed
13623 gnus-level-default-unsubscribed))
13624 (setq gnus-newsrc-assoc (cons info gnus-newsrc-assoc)))
13625 (setq gnus-newsrc-assoc
13629 (if (nth 1 group) gnus-level-default-subscribed
13630 gnus-level-default-unsubscribed)
13631 (cdr (cdr group))))
13632 gnus-newsrc-assoc)))
13633 (if (setq m (assoc (car group) marked))
13634 (setcdr (cdr (cdr info)) (cons (list (cons 'tick (cdr m))) nil))))
13635 (setq newsrc (cdr newsrc)))
13636 (setq newsrc killed)
13638 (setcar newsrc (car (car newsrc)))
13639 (setq newsrc (cdr newsrc)))
13640 (setq gnus-killed-list killed))
13641 (setq gnus-newsrc-assoc (nreverse gnus-newsrc-assoc))
13642 (gnus-make-hashtable-from-newsrc-alist)))
13644 (defun gnus-make-newsrc-file (file)
13645 "Make server dependent file name by catenating FILE and server host name."
13646 (let* ((file (expand-file-name file nil))
13647 (real-file (concat file "-" (nth 1 gnus-select-method))))
13648 (if (file-exists-p real-file)
13651 (defun gnus-uncompress-newsrc-assoc ()
13652 ;; Uncompress all lists of marked articles in the newsrc assoc.
13653 (let ((newsrc gnus-newsrc-assoc)
13656 (if (not (setq marked (nth 3 (car newsrc))))
13659 (or (eq 'score (car (car marked)))
13660 (eq 'bookmark (car (car marked)))
13661 (eq 'killed (car (car marked)))
13662 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
13663 (setq marked (cdr marked))))
13664 (setq newsrc (cdr newsrc)))))
13666 (defun gnus-compress-newsrc-assoc ()
13667 ;; Compress all lists of marked articles in the newsrc assoc.
13668 (let ((newsrc gnus-newsrc-assoc)
13671 (if (not (setq marked (nth 3 (car newsrc))))
13674 (or (eq 'score (car (car marked)))
13675 (eq 'bookmark (car (car marked)))
13676 (eq 'killed (car (car marked)))
13677 (setcdr (car marked)
13678 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
13679 (setq marked (cdr marked))))
13680 (setq newsrc (cdr newsrc)))))
13682 ;; jwz: rewrote this function to be much more efficient, and not be
13683 ;; subject to regexp overflow errors when it encounters very long
13684 ;; lines -- the old behavior was to blow off the rest of the *file*
13685 ;; when a line was encountered that was too long to match!! Now it
13686 ;; uses only simple looking-at calls, and doesn't create as many
13687 ;; temporary strings. It also now handles multiple consecutive
13688 ;; options lines (before it only handled the first.)
13689 ;; Tiny rewrite by lmi.
13690 (defun gnus-newsrc-to-gnus-format ()
13691 "Parse current buffer as .newsrc file."
13692 ;; We have to re-initialize these variables (except for
13693 ;; gnus-killed-list) because the quick startup file may contain bogus
13695 (setq gnus-newsrc-options nil)
13696 (setq gnus-newsrc-options-n nil)
13697 (gnus-parse-options-lines)
13698 (gnus-parse-newsrc-body))
13700 (defun gnus-parse-options-lines ()
13701 ;; newsrc.5 seems to indicate that the options line can come anywhere
13702 ;; in the file, and that there can be any number of them:
13704 ;; An options line starts with the word options (left-
13705 ;; justified). Then there are the list of options just as
13706 ;; they would be on the readnews command line. For instance:
13708 ;; options -n all !net.sf-lovers !mod.human-nets -r
13711 ;; A string of lines beginning with a space or tab after the
13712 ;; initial options line will be considered continuation
13715 ;; For now, we only accept it at the beginning of the file.
13717 (goto-char (point-min))
13718 (skip-chars-forward " \t\n")
13719 (setq gnus-newsrc-options nil)
13720 (while (looking-at "^options[ \t]*\\(.*\\)\n")
13721 ;; handle consecutive options lines
13722 (setq gnus-newsrc-options (concat gnus-newsrc-options
13723 (if gnus-newsrc-options "\n\t")
13724 (buffer-substring (match-beginning 1)
13727 (while (looking-at "[ \t]+\\(.*\\)\n")
13728 ;; handle subsequent continuation lines of this options line
13729 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n\t"
13730 (buffer-substring (match-beginning 1)
13733 ;; Gather all "-n" options lines.
13736 (if gnus-newsrc-options
13737 (while (and (string-match "^[ \t]*-n\\([^\n]*\\)$"
13738 gnus-newsrc-options
13740 (setq start (match-end 0)))
13741 (setq result (concat result
13743 (substring gnus-newsrc-options
13744 (match-beginning 1)
13747 (and result (gnus-parse-n-options result))
13750 (defun gnus-parse-newsrc-body ()
13751 ;; Point has been positioned after the options lines. We shouldn't
13752 ;; see any more in here.
13754 (let ((subscribe nil)
13756 (line (1+ (count-lines (point-min) (point))))
13760 (skip-chars-forward " \t")
13761 (while (not (eobp))
13763 ((= (following-char) ?\n)
13764 ;; skip blank lines
13768 (skip-chars-forward "^:!\n")
13769 (if (= (following-char) ?\n)
13770 (error "line %d is unparsable in %s" line (buffer-name)))
13772 (skip-chars-backward " \t")
13774 ;; #### note: we could avoid consing a string here by binding obarray
13775 ;; and reading the newsgroup directly into the gnus-newsrc-hashtb,
13776 ;; then setq'ing newsgroup to symbol-name of that, like we do in
13777 ;; gnus-active-to-gnus-format.
13778 (setq newsgroup (buffer-substring p (point)))
13781 (setq subscribe (= (following-char) ?:))
13782 (setq read-list nil)
13784 (forward-char 1) ; after : or !
13785 (skip-chars-forward " \t")
13786 (while (not (= (following-char) ?\n))
13787 (skip-chars-forward " \t")
13790 ((looking-at "\\([0-9]+\\)-\\([0-9]+\\)") ; a range
13795 ;; faster that buffer-substring/string-to-int
13796 (narrow-to-region (point-min) (match-end 1))
13797 (read (current-buffer)))
13799 (narrow-to-region (point-min) (match-end 2))
13800 (forward-char) ; skip over "-"
13802 (read (current-buffer))
13806 ((looking-at "[0-9]+")
13807 ;; faster that buffer-substring/string-to-int
13808 (narrow-to-region (point-min) (match-end 0))
13809 (setq p (read (current-buffer)))
13811 (setq read-list (cons (cons p p) read-list))
13814 ;; bogus chars in ranges
13817 (goto-char (match-end 0))
13818 (skip-chars-forward " \t")
13819 (cond ((= (following-char) ?,)
13822 ((= (following-char) ?\n)
13825 ;; bogus char after range
13827 ;; if we get here, the parse failed
13829 (end-of-line) ; give up on this line
13831 (message "Ignoring bogus line %d for %s in %s"
13832 line newsgroup (buffer-name))
13834 ;; We have already read .newsrc.eld, so we gently update the
13835 ;; data in the hash table with the information we have just
13837 (let ((info (nth 2 (gnus-gethash newsgroup gnus-newsrc-hashtb)))
13841 (setcar (nthcdr 2 info) (nreverse read-list))
13842 ;; We update the level very gently. In fact, we
13843 ;; only change it if there's been a status change
13844 ;; from subscribed to unsubscribed, or vice versa.
13845 (setq level (nth 1 info))
13846 (cond ((and (<= level gnus-level-subscribed) (not subscribe))
13847 (setq level (if read-list
13848 gnus-level-default-unsubscribed
13849 (1+ gnus-level-default-unsubscribed))))
13850 ((and (> level gnus-level-subscribed) subscribe)
13851 (setq level gnus-level-default-subscribed)))
13852 (setcar (cdr info) level))
13853 (setq gnus-newsrc-assoc
13854 (cons (list newsgroup
13856 gnus-level-default-subscribed
13857 (if read-list gnus-level-default-subscribed
13858 (1+ gnus-level-default-subscribed)))
13859 (nreverse read-list))
13860 gnus-newsrc-assoc))))))
13861 (setq line (1+ line))
13862 (forward-line 1))))
13863 (setq gnus-newsrc-assoc (cdr gnus-newsrc-assoc))
13864 (gnus-make-hashtable-from-newsrc-alist)
13867 (defun gnus-parse-n-options (options)
13868 "Parse -n NEWSGROUPS options and return a cons of YES and NO regexps."
13869 (let (yes no yes-or-no out newsgroup)
13870 ;; Parse each newsgroup description such as "comp.all". Commas
13871 ;; and white spaces can be a newsgroup separator.
13873 (string-match "^[ \t\n,]*\\(!?\\)\\([^- \t\n,][^ \t\n,]*\\)" options)
13875 (substring options (match-beginning 1) (match-end 1)))
13879 (match-beginning 2) (match-end 2))))
13880 (setq options (substring options (match-end 2)))
13881 ;; Rewrite "all" to ".+" not ".*". ".+" requires at least one
13883 (while (string-match "\\(^\\|\\\\[.]\\)all\\(\\\\[.]\\|$\\)" newsgroup)
13885 (concat (substring newsgroup 0 (match-end 1))
13887 (substring newsgroup (match-beginning 2)))))
13888 ;; It is yes or no.
13889 (setq out (cons (cons (if (string= yes-or-no "!") 'ignore 'subscribe)
13890 (concat "^" newsgroup "$"))
13892 (setq gnus-newsrc-options-n out)))
13894 (defun gnus-save-newsrc-file ()
13895 "Save .newsrc file."
13896 ;; Note: We cannot save .newsrc file if all newsgroups are removed
13897 ;; from the variable gnus-newsrc-assoc.
13898 (and (or gnus-newsrc-assoc gnus-killed-list)
13899 gnus-current-startup-file
13900 (let ((make-backup-files t)
13901 (version-control nil)
13902 (require-final-newline t)) ;Don't ask even if requested.
13903 ;; You can stop or change version control of backup file.
13904 ;; Suggested by jason@violet.berkeley.edu.
13905 (run-hooks 'gnus-save-newsrc-hook)
13907 (if (or (not gnus-dribble-buffer)
13908 (not (buffer-name gnus-dribble-buffer))
13909 (zerop (save-excursion
13910 (set-buffer gnus-dribble-buffer)
13912 (message "(No changes need to be saved)")
13913 (if gnus-save-newsrc-file
13915 (message "Saving %s..." gnus-current-startup-file)
13916 ;; Make backup file of master newsrc.
13917 (gnus-gnus-to-newsrc-format)
13918 (message "Saving %s... done" gnus-current-startup-file)))
13919 ;; Quickly loadable .newsrc.
13920 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
13921 (gnus-add-current-to-buffer-list)
13922 (buffer-disable-undo (current-buffer))
13924 (message "Saving %s.eld..." gnus-current-startup-file)
13925 (gnus-gnus-to-quick-newsrc-format)
13926 (write-region 1 (point-max)
13927 (concat gnus-current-startup-file ".eld")
13929 (kill-buffer (current-buffer))
13930 (message "Saving %s.eld... done" gnus-current-startup-file)
13931 (gnus-dribble-delete-file))))))
13933 (defun gnus-gnus-to-quick-newsrc-format ()
13934 "Insert Gnus variables such as gnus-newsrc-assoc in lisp format."
13935 (insert ";; (ding) Gnus startup file.\n")
13936 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
13937 (insert ";; to read .newsrc.\n")
13938 (let ((variables gnus-variable-list)
13939 (gnus-newsrc-assoc (cdr gnus-newsrc-assoc))
13941 ;; insert lisp expressions.
13942 (gnus-compress-newsrc-assoc)
13944 (setq variable (car variables))
13945 (and (boundp variable)
13946 (symbol-value variable)
13947 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
13948 (insert "(setq " (symbol-name variable) " '"
13949 (prin1-to-string (symbol-value variable))
13951 (setq variables (cdr variables)))
13952 (gnus-uncompress-newsrc-assoc)))
13955 (defun gnus-gnus-to-newsrc-format ()
13956 ;; Generate and save the .newsrc file.
13957 (let ((newsrc (cdr gnus-newsrc-assoc))
13960 (set-buffer (create-file-buffer gnus-startup-file))
13961 (buffer-disable-undo (current-buffer))
13964 (if gnus-newsrc-options (insert "options " gnus-newsrc-options "\n"))
13965 ;; Write subscribed and unsubscribed.
13967 (setq info (car newsrc))
13968 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
13970 (insert (car info) (if (> (nth 1 info) gnus-level-subscribed)
13972 (if (setq ranges (nth 2 info))
13975 (if (not (listp (cdr ranges)))
13976 (if (= (car ranges) (cdr ranges))
13977 (insert (int-to-string (car ranges)))
13978 (insert (int-to-string (car ranges)) "-"
13979 (int-to-string (cdr ranges))))
13981 (setq range (car ranges)
13982 ranges (cdr ranges))
13983 (if (or (atom range) (= (car range) (cdr range)))
13984 (insert (int-to-string
13985 (or (and (atom range) range)
13987 (insert (int-to-string (car range)) "-"
13988 (int-to-string (cdr range))))
13989 (if ranges (insert ","))))))
13991 (setq newsrc (cdr newsrc)))
13992 (write-region 1 (point-max) gnus-current-startup-file nil 'nomesg)
13993 (kill-buffer (current-buffer)))))
13995 (defun gnus-read-descriptions-file ()
13996 (message "Reading descriptions file...")
13997 (if (not (gnus-request-list-newsgroups gnus-select-method))
13999 (message "Couldn't read newsgroups descriptions")
14002 (setq gnus-description-hashtb
14003 (gnus-make-hashtable (length gnus-active-hashtb)))
14006 (set-buffer nntp-server-buffer)
14007 (goto-char (point-min))
14008 (delete-non-matching-lines "^[-\\._+A-Za-z0-9]+[ \t]")
14009 (goto-char (point-min))
14010 (if (or (search-forward "\n.\n" nil t)
14011 (goto-char (point-max)))
14013 (beginning-of-line)
14014 (narrow-to-region (point-min) (point))))
14015 (goto-char (point-min))
14016 (while (not (eobp))
14017 (setq group (let ((obarray gnus-description-hashtb))
14018 (read (current-buffer))))
14019 (skip-chars-forward " \t")
14020 (set group (buffer-substring
14021 (point) (gnus-point-at-eol)))
14022 (forward-line 1))))
14023 (message "Reading descriptions file...done")
14026 (defun gnus-group-get-description (group)
14027 ;; Get the description of a group by sending XGTITLE to the server.
14028 (and (gnus-request-group-description group)
14030 (set-buffer nntp-server-buffer)
14031 (goto-char (point-min))
14032 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
14033 (buffer-substring (match-beginning 1) (match-end 1))))))
14039 (defvar gnus-server-mode-hook nil
14040 "Hook run in `gnus-server-mode' buffers.")
14042 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
14043 "Format of server lines.
14044 It works along the same lines as a normal formatting string,
14045 with some simple extensions.")
14047 (defvar gnus-server-mode-line-format "(ding) List of servers"
14048 "The format specification for the server mode line.")
14050 (defconst gnus-server-line-format-alist
14051 (list (list ?h 'how ?s)
14053 (list ?w 'where ?s)
14056 (defconst gnus-server-mode-line-format-alist
14057 (list (list ?S 'news-server ?s)
14058 (list ?M 'news-method ?s)
14059 (list ?u 'user-defined ?s)))
14061 (defvar gnus-server-line-format-spec nil)
14062 (defvar gnus-server-mode-line-format-spec nil)
14063 (defvar gnus-server-killed-servers nil)
14065 (defvar gnus-server-mode-map nil)
14066 (put 'gnus-server-mode 'mode-class 'special)
14068 (if gnus-server-mode-map
14070 (setq gnus-server-mode-map (make-sparse-keymap))
14071 (suppress-keymap gnus-server-mode-map)
14072 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
14073 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
14074 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
14075 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
14076 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
14077 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
14078 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
14079 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
14081 (defun gnus-server-mode ()
14082 "Major mode for listing and editing servers.
14084 All normal editing commands are switched off.
14085 \\<gnus-server-mode-map>
14087 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
14089 The following commands are available:
14091 \\{gnus-server-mode-map}"
14093 ; (if gnus-visual (gnus-server-make-menu-bar))
14094 (kill-all-local-variables)
14095 (setq mode-line-modified "-- ")
14096 (make-local-variable 'mode-line-format)
14097 (setq mode-line-format (copy-sequence mode-line-format))
14098 (and (equal (nth 3 mode-line-format) " ")
14099 (setcar (nthcdr 3 mode-line-format) ""))
14100 (setq major-mode 'gnus-server-mode)
14101 (setq mode-name "Server")
14102 ; (gnus-group-set-mode-line)
14103 (setq mode-line-process nil)
14104 (use-local-map gnus-server-mode-map)
14105 (buffer-disable-undo (current-buffer))
14106 (setq truncate-lines t)
14107 (setq buffer-read-only t)
14108 (run-hooks 'gnus-server-mode-hook))
14110 (defun gnus-server-insert-server-line (sformat name method)
14111 (let* ((sformat (or sformat gnus-server-line-format-spec))
14113 (where (nth 1 method))
14115 (beginning-of-line)
14117 ;; Insert the text.
14118 (insert (eval sformat))
14119 (add-text-properties
14120 b (1+ b) (list 'gnus-server (intern name)))))
14122 (defun gnus-server-setup-buffer ()
14123 (if (get-buffer gnus-server-buffer)
14126 (set-buffer (get-buffer-create gnus-server-buffer))
14127 (gnus-server-mode))))
14129 (defun gnus-server-prepare ()
14130 (setq gnus-server-mode-line-format-spec
14131 (gnus-parse-format gnus-server-mode-line-format
14132 gnus-server-mode-line-format-alist))
14133 (setq gnus-server-line-format-spec
14134 (gnus-parse-format gnus-server-line-format
14135 gnus-server-line-format-alist))
14136 (let ((alist gnus-server-alist)
14137 (buffer-read-only nil))
14140 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
14141 (setq alist (cdr alist))))
14142 (goto-char (point-min))
14143 (gnus-server-position-cursor))
14145 (defun gnus-server-server-name ()
14146 (let ((server (get-text-property
14147 (save-excursion (beginning-of-line) (point)) 'gnus-server)))
14148 (and server (symbol-name server))))
14150 (defalias 'gnus-server-position-cursor 'gnus-goto-colon)
14152 (defvar gnus-winconf-edit-server nil)
14153 (defconst gnus-server-edit-buffer "*Gnus edit server*")
14155 (defun gnus-server-update-server (server)
14157 (set-buffer gnus-server-buffer)
14158 (let ((buffer-read-only nil)
14159 (info (cdr (assoc server gnus-server-alist))))
14160 (gnus-dribble-enter
14161 (concat "(gnus-server-set-info \"" server "\" '"
14162 (prin1-to-string info) ")"))
14163 ;; Buffer may be narrowed.
14166 (if (gnus-server-goto-server server)
14167 (delete-region (progn (beginning-of-line) (point))
14168 (progn (forward-line 1) (point))))
14169 (let ((entry (assoc server gnus-server-alist)))
14170 (gnus-server-insert-server-line nil (car entry) (cdr entry))
14171 (gnus-server-position-cursor))))))
14173 (defun gnus-server-set-info (info)
14174 ;; Enter a select method into the virtual server alist.
14175 (gnus-dribble-enter
14176 (concat "(gnus-server-set-info '"
14177 (prin1-to-string info) ")"))
14178 (let* ((server (nth 1 info))
14179 (entry (assoc server gnus-server-alist)))
14180 (if entry (setcdr entry info)
14181 (setq gnus-server-alist
14182 (nconc gnus-server-alist (list (cons server info)))))))
14184 (defun gnus-server-to-method (server)
14185 ;; Map virtual server names to select methods.
14186 (cdr (assoc server gnus-server-alist)))
14188 (defun gnus-server-extend-method (group method)
14189 ;; This function "extends" a virtual server. If the server is
14190 ;; "hello", and the select method is ("hello" (my-var "something"))
14191 ;; in the group "alt.alt", this will result in a new virtual server
14192 ;; called "helly+alt.alt".
14194 (gnus-copy-sequence
14195 (if (equal (car method) "native") gnus-select-method
14196 (cdr (assoc (car method) gnus-server-alist))))))
14197 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
14198 (nconc entry (cdr method))))
14200 (defun gnus-server-get-method (group method)
14201 ;; Input either a server name, and extended server name, or a
14202 ;; select method, and return a select method.
14203 (cond ((stringp method)
14204 (gnus-server-to-method method))
14205 ((stringp (car method))
14206 (gnus-server-extend-method group method))
14208 (gnus-server-add-address method))))
14210 (defun gnus-server-add-address (method)
14211 (let ((method-name (symbol-name (car method))))
14212 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
14213 (not (assq (intern (concat method-name "-address")) method)))
14214 (append method (list (list (intern (concat method-name "-address"))
14218 (defun gnus-server-equal (s1 s2)
14220 (and (= (length s1) (length s2))
14222 (while (and s1 (member (car s1) s2))
14223 (setq s1 (cdr s1)))
14226 ;;; Interactive server functions.
14228 (defun gnus-server-kill-server (server)
14229 "Kill the server on the current line."
14230 (interactive (list (gnus-server-server-name)))
14231 (or (gnus-server-goto-server server)
14232 (if server (error "No such server: %s" server)
14233 (error "No server on the current line")))
14234 (let ((buffer-read-only nil))
14235 (delete-region (progn (beginning-of-line) (point))
14236 (progn (forward-line 1) (point))))
14237 (setq gnus-server-killed-servers
14238 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
14239 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
14240 gnus-server-alist))
14241 (gnus-server-position-cursor))
14243 (defun gnus-server-yank-server ()
14244 "Yank the previously killed server."
14246 (or gnus-server-killed-servers
14247 (error "No killed servers to be yanked"))
14248 (let ((alist gnus-server-alist)
14249 (server (gnus-server-server-name))
14250 (killed (car gnus-server-killed-servers)))
14252 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
14253 (if (string= server (car (car gnus-server-alist)))
14254 (setq gnus-server-alist (cons killed gnus-server-alist))
14255 (while (and (cdr alist)
14256 (not (string= server (car (car (cdr alist))))))
14257 (setq alist (cdr alist)))
14258 (setcdr alist (cons killed (cdr alist)))))
14259 (gnus-server-update-server (car killed))
14260 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
14261 (gnus-server-position-cursor)))
14263 (defun gnus-server-exit ()
14264 "Return to the group buffer."
14266 (kill-buffer (current-buffer))
14267 (switch-to-buffer gnus-group-buffer))
14269 (defun gnus-server-list-servers ()
14270 "List all available servers."
14272 (let ((cur (gnus-server-server-name)))
14273 (gnus-server-prepare)
14274 (if cur (gnus-server-goto-server cur)
14275 (goto-char (point-max))
14277 (gnus-server-position-cursor)))
14279 (defun gnus-server-copy-server (from to)
14282 (or (gnus-server-server-name)
14283 (error "No server on the current line"))
14284 (read-string "Copy to: ")))
14285 (or from (error "No server on current line"))
14286 (or (and to (not (string= to ""))) (error "No name to copy to"))
14287 (and (assoc to gnus-server-alist) (error "%s already exists" to))
14288 (or (assoc from gnus-server-alist)
14289 (error "%s: no such server" from))
14290 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
14291 (setcar to-entry to)
14292 (setcar (nthcdr 2 to-entry) to)
14293 (setq gnus-server-killed-servers
14294 (cons to-entry gnus-server-killed-servers))
14295 (gnus-server-yank-server)))
14297 (defun gnus-server-add-server (how where)
14299 (list (intern (completing-read "Server method: "
14300 gnus-valid-select-methods nil t))
14301 (read-string "Server name: ")))
14302 (setq gnus-server-killed-servers
14303 (cons (list where how where) gnus-server-killed-servers))
14304 (gnus-server-yank-server))
14306 (defun gnus-server-goto-server (server)
14307 "Jump to a server line."
14309 (list (completing-read "Goto server: " gnus-server-alist nil t)))
14310 (let ((to (text-property-any (point-min) (point-max)
14311 'gnus-server (intern server))))
14315 (gnus-server-position-cursor)))))
14317 (defun gnus-server-edit-server (server)
14318 "Edit the server on the current line."
14319 (interactive (list (gnus-server-server-name)))
14321 (error "No server on current line"))
14322 (setq gnus-winconf-edit-server (current-window-configuration))
14323 (pop-to-buffer (get-buffer-create gnus-server-edit-buffer))
14324 (gnus-add-current-to-buffer-list)
14326 (use-local-map (copy-keymap (current-local-map)))
14327 (local-set-key "\C-c\C-c" 'gnus-server-edit-server-done)
14329 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
14330 (insert "(gnus-server-set-info \n "
14331 (pp-to-string (list 'quote (cdr (assoc server gnus-server-alist))))
14334 (defun gnus-server-edit-server-done ()
14336 (set-buffer (get-buffer-create gnus-server-edit-buffer))
14337 (eval-current-buffer)
14338 (kill-buffer (current-buffer))
14339 (and gnus-winconf-edit-server
14340 (set-window-configuration gnus-winconf-edit-server))
14341 (setq gnus-winconf-edit-server nil)
14342 (set-buffer gnus-server-buffer)
14343 (gnus-server-update-server (gnus-server-server-name))
14344 (gnus-server-position-cursor))
14349 ;;; gnus.el ends here