1 ;;; (ding) Gnus --- a newsreader for GNU Emacs
2 ;; Copyright (C) 1987,88,89,90,93,94,95 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26 ;; Although (ding) Gnus looks suspiciously like GNUS, it isn't quite
27 ;; the same beast. Most internal structures have been changed. If you
28 ;; have written packages that depend on any of the hash tables,
29 ;; `gnus-newsrc-assoc', `gnus-killed-assoc', marked lists, the .newsrc
30 ;; buffer, or internal knowledge of the `nntp-header-' macros, or
31 ;; dependence on the buffers having a certain format, your code will
43 ;; Customization variables
45 (defvar gnus-select-method
46 (list 'nntp (or (getenv "NNTPSERVER")
47 (if (and gnus-default-nntp-server
48 (not (string= gnus-default-nntp-server "")))
49 gnus-default-nntp-server)
52 "*Default method for selecting a newsgroup.
53 This variable should be a list, where the first element is how the
54 news is to be fetched, the second is the address. An optional third
55 element can be included to specify a port number if nntp is used.
57 For instance, if you want to get your news via NNTP from
58 \"flab.flab.edu\" on port 23, you could say:
60 (setq gnus-select-method '(nntp \"flab.flab.edu\" 23))
62 If you want to use your local spool, say:
64 (setq gnus-select-method (list 'nnspool (system-name)))
66 If you use this variable, you must set `gnus-nntp-server' to nil.")
68 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
69 (defvar gnus-post-method nil
70 "*Preferred method for posting USENET news.
71 If this variable is nil, Gnus will use the current method to decide
72 which method to use when posting. If it is non-nil, it will override
73 the current method. This method will not be used in mail groups and
74 the like, only in \"real\" newsgroups.
76 The value must be a valid method as discussed in the documentation of
77 `gnus-select-method'.")
79 (defvar gnus-refer-article-method nil
80 "*Preferred method for fetching an article by Message-ID.
81 If you are reading news from the local spool (with nnspool), fetching
82 articles by Message-ID is painfully slow. By setting this method to an
83 nntp method, you might get acceptable results.
85 The value of this variable must be a valid select method as discussed
86 in the documentation of `gnus-select-method'")
88 (defvar gnus-secondary-select-methods nil
89 "*A list of secondary methods that will be used for reading news.
90 This is a list where each element is a complete select methdod (see
91 `gnus-select-method').
93 If, for instance, you want to read your mail with the nnml backend,
94 you could set this variable:
96 (setq gnus-secondary-select-methods '((nnml \"\"))")
98 (defvar gnus-secondary-servers nil
99 "*List of NNTP servers that the user can choose between interactively.
100 To make Gnus query you for a server, you have to give `gnus' a
101 non-numeric prefix - `C-u M-x gnus', in short.")
103 (defvar gnus-nntp-server nil
104 "*The name of the host running the NNTP server.
105 This variable is semi-obsolete. Use the `gnus-select-method'
108 (defvar gnus-nntp-service "nntp"
109 "*NNTP service name (\"nntp\" or 119).
110 This is an obsolete variable, which is scarcely used. If you use an
111 nntp server for your newsgroup and want to change the port number
112 used to 899, you would say something along these lines:
114 (setq gnus-select-method '(nntp \"my.nntp.server\" 899))")
116 (defvar gnus-startup-file "~/.newsrc"
117 "*Your `.newsrc' file.
118 `.newsrc-SERVER' will be used instead if that exists.")
120 (defvar gnus-signature-file "~/.signature"
121 "*Your signature file.
122 If the variable is a string that doesn't correspond to a file, the
123 string itself is inserted.")
125 (defvar gnus-signature-function nil
126 "*A function that should return a signature file name.
127 The function will be called with the name of the newsgroup being
129 If the function returns a string that doesn't correspond to a file, the
130 string itself is inserted.
131 If the function returns nil, the `gnus-signature-file' variable will
134 (defvar gnus-init-file "~/.gnus"
135 "*Your Gnus elisp startup file.
136 If a file with the .el or .elc suffixes exist, it will be read
139 (defvar gnus-group-faq-directory
140 "/anonymous@rtfm.mit.edu:/pub/usenet-by-group/"
141 "*Directory where the group FAQs are stored.
142 This will most commonly be on a remote machine, and the file will be
143 fetched by ange-ftp.")
145 (defvar gnus-group-archive-directory
146 "/ftp@sina.tcamc.uh.edu:/pub/emacs/ding-list/"
147 "*The address of the (ding) archives.")
149 (defvar gnus-default-subscribed-newsgroups nil
150 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
151 It should be a list of strings.
152 If it is `t', Gnus will not do anything special the first time it is
153 started; it'll just use the normal newsgroups subscription methods.")
155 (defvar gnus-post-prepare-function nil
156 "*Function that is run after a post buffer has been prepared.
157 It is called with the name of the newsgroup that is posted to. It
158 might be used, for instance, for inserting signatures based on the
159 newsgroup name. (In that case, `gnus-signature-file' and
160 `mail-signature' should both be set to nil).")
162 (defvar gnus-use-cross-reference t
163 "*Non-nil means that cross referenced articles will be marked as read.
164 If nil, ignore cross references. If t, mark articles as read in
165 subscribed newsgroups. If neither t nor nil, mark as read in all
168 (defvar gnus-use-dribble-file t
169 "*Non-nil means that Gnus will use a dribble file to store user updates.
170 If Emacs should crash without saving the .newsrc files, complete
171 information can be restored from the dribble file.")
173 (defvar gnus-use-followup-to 'use
174 "*Specifies what to do with Followup-To header.
175 If nil, ignore the header. If it is t, use its value, but ignore
176 `poster'. If it is neither nil nor t, which is the default, always use
179 (defvar gnus-followup-to-function nil
180 "*A variable that contains a function that returns a followup address.
181 The function will be called in the buffer of the article that is being
182 followed up. The buffer will be narrowed to the headers of the
183 article. To pick header headers, one might use `mail-fetch-field'. The
184 function will be called with the name of the current newsgroup as the
187 Here's an example `gnus-followup-to-function':
189 (setq gnus-followup-to-function
191 (cond ((string= group \"mail.list\")
192 (or (mail-fetch-field \"sender\")
193 (mail-fetch-field \"from\")))
195 (or (mail-fetch-field \"reply-to\")
196 (mail-fetch-field \"from\"))))))")
198 (defvar gnus-reply-to-function nil
199 "*A variable that contains a function that returns a reply address.
200 See the `gnus-followup-to-function' variable for an explanation of how
201 this variable is used.
203 This function should return a string that will be used to fill in the
204 header. This function may also return a list. In that case, every
205 list element should be a cons where the first car should be a string
206 with the header name, and the cdr should be a string with the header
209 (defvar gnus-large-newsgroup 200
210 "*The number of articles which indicates a large newsgroup.
211 If the number of articles in a newsgroup is greater than this value,
212 confirmation is required for selecting the newsgroup.")
214 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
215 (defvar gnus-no-groups-message "No news is horrible news"
216 "*Message displayed by Gnus when no groups are available.")
218 (defvar gnus-author-copy (getenv "AUTHORCOPY")
219 "*Save outgoing articles in this file.
220 Initialized from the AUTHORCOPY environment variable.
222 If this variable begins with the character \"|\", outgoing articles
223 will be piped to the named program. It is possible to save an article
224 in an MH folder as follows:
226 \(setq gnus-author-copy \"|/usr/local/lib/mh/rcvstore +Article\")
228 If the first character is not a pipe, articles are saved using the
229 function specified by the `gnus-author-copy-saver' variable.")
231 (defvar gnus-mail-self-blind nil
232 "*Non-nil means insert a BCC header in all outgoing articles.
233 This will result in having a copy of the article mailed to yourself.
234 The BCC header is inserted when the post buffer is initialized, so you
235 can remove or alter the BCC header to override the default.")
237 (defvar gnus-author-copy-saver (function rmail-output)
238 "*A function called to save outgoing articles.
239 This function will be called with the same of the file to store the
240 article in. The default function is `rmail-output' which saves in Unix
243 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
244 "*Non-nil means that the default name of a file to save articles in is the group name.
245 If it's nil, the directory form of the group name is used instead.
247 If this variable is a list, and the list contains the element
248 `not-score', long file names will not be used for score files; if it
249 contains the element `not-save', long file names will not be used for
250 saving; and if it contains the element `not-kill', long file names
251 will not be used for kill files.")
253 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
254 "*Name of the directory articles will be saved in (default \"~/News\").
255 Initialized from the SAVEDIR environment variable.")
257 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
258 "*Name of the directory where kill files will be stored (default \"~/News\").
259 Initialized from the SAVEDIR environment variable.")
261 (defvar gnus-score-expiry-days 7
262 "*Number of days before unused score file entries are expired.")
264 (defvar gnus-default-article-saver (function gnus-summary-save-in-rmail)
265 "*A function to save articles in your favorite format.
266 The function must be interactively callable (in other words, it must
267 be an Emacs command).
269 Gnus provides the following functions:
271 * gnus-summary-save-in-rmail (Rmail format)
272 * gnus-summary-save-in-mail (Unix mail format)
273 * gnus-summary-save-in-folder (MH folder)
274 * gnus-summary-save-in-file (article format).")
276 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
277 "*A function generating a file name to save articles in Rmail format.
278 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
280 (defvar gnus-mail-save-name (function gnus-plain-save-name)
281 "*A function generating a file name to save articles in Unix mail format.
282 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
284 (defvar gnus-folder-save-name (function gnus-folder-save-name)
285 "*A function generating a file name to save articles in MH folder.
286 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
288 (defvar gnus-file-save-name (function gnus-numeric-save-name)
289 "*A function generating a file name to save articles in article format.
290 The function is called with NEWSGROUP, HEADERS, and optional
293 (defvar gnus-split-methods nil
294 "*Variable used to suggest where articles are to be saved.
295 The syntax of this variable is the same as `nnmail-split-methods'.
297 For instance, if you would like to save articles related to Gnus in
298 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
299 you could set this variable to something like:
301 '(("^Subject:.*gnus\\|^Newsgroups:.*gnus" "gnus-stuff")
302 ("^Subject:.*vm\\|^Xref:.*vm" "vm-stuff"))")
304 (defvar gnus-score-file-suffix "SCORE"
305 "*Suffix of the score files.")
307 (defvar gnus-fetch-old-headers nil
308 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
309 If an unread article in the group refers to an older, already read (or
310 just marked as read) article, the old article will not normally be
311 displayed in the Summary buffer. If this variable is non-nil, Gnus
312 will attempt to grab the headers to the old articles, and thereby
313 build complete threads. If it has the value `some', only enough
314 headers to connect otherwise loose threads will be displayed.
316 The server has to support XOVER for any of this to work.")
318 (defvar gnus-visual t
319 "*If non-nil, will do various highlighting.
320 If nil, no mouse highlights (or any other highlights) will be
321 performed. This might speed up Gnus some when generating large group
322 and summary buffers.")
324 (defvar gnus-novice-user t
325 "*Non-nil means that you are a usenet novice.
326 If non-nil, verbose messages may be displayed and confirmations may be
329 (defvar gnus-expert-user nil
330 "*Non-nil means that you will never be asked for confirmation about anything.
331 And that means *anything*.")
333 (defvar gnus-keep-same-level nil
334 "*Non-nil means that the next newsgroup after the current will be on the same level.
335 When you type, for instance, `n' after reading the last article in the
336 current newsgroup, you will go to the next newsgroup. If this variable
337 is nil, the next newsgroup will be the next from the group
339 If this variable is non-nil, Gnus will either put you in the
340 next newsgroup with the same level, or, if no such newsgroup is
341 available, the next newsgroup with the lowest possible level higher
342 than the current level.
343 If this variable is `best', Gnus will make the next newsgroup the one
344 with the best level.")
346 (defvar gnus-summary-make-false-root 'adopt
347 "*nil means that Gnus won't gather loose threads.
348 If the root of a thread has expired or been read in a previous
349 session, the information necessary to build a complete thread has been
350 lost. Instead of having many small sub-threads from this original thread
351 scattered all over the summary buffer, Gnus can gather them.
353 If non-nil, Gnus will try to gather all loose sub-threads from an
354 original thread into one large thread.
356 If this variable is non-nil, it should be one of `none', `adopt',
359 If this variable is `none', Gnus will not make a false root, but just
360 present the sub-threads after another.
361 If this variable is `dummy', Gnus will create a dummy root that will
362 have all the sub-threads as children.
363 If this variable is `adopt', Gnus will make one of the \"children\"
364 the parent and mark all the step-children as such.
365 If this variable is `empty', the \"children\" are printed with empty
366 subject fields. (Or rather, they will be printed with a string
367 given by the `gnus-summary-same-subject' variable.)")
369 (defvar gnus-summary-gather-subject-limit nil
370 "*Maximum length of subject comparisons when gathering loose threads.
371 Use nil to compare full subjects. Setting this variable to a low
372 number will help gather threads that have been corrupted by
373 newsreaders chopping off subject lines, but it might also mean that
374 unrelated articles that have subject that happen to begin with the
375 same few characters will be incorrectly gathered.
377 If this variable is `fuzzy', Gnus will use a fuzzy algortihm when
378 comparing subjects.")
380 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
381 (defvar gnus-summary-same-subject ""
382 "*String indicating that the current article has the same subject as the previous.
383 This variable will only be used if the value of
384 `gnus-summary-make-false-root' is `empty'.")
386 (defvar gnus-summary-goto-unread nil
387 "*If non-nil, marking commands will go to the next unread article.")
389 (defvar gnus-check-new-newsgroups t
390 "*Non-nil means that Gnus will add new newsgroups at startup.
391 If this variable is `ask-server', Gnus will ask the server for new
392 groups since the last time it checked. This means that the killed list
393 is no longer necessary, so you could set `gnus-save-killed-list' to
396 A variant is to have this variable be a list of select methods. Gnus
397 will then use the `ask-server' method on all these select methods to
398 query for new groups from all those servers.
401 (setq gnus-check-new-newsgroups
402 '((nntp \"some.server\") (nntp \"other.server\")))
404 If this variable is nil, then you have to tell Gnus explicitly to
405 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
407 (defvar gnus-check-bogus-newsgroups nil
408 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
409 If this variable is nil, then you have to tell Gnus explicitly to
410 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
412 (defvar gnus-read-active-file t
413 "*Non-nil means that Gnus will read the entire active file at startup.
414 If this variable is nil, Gnus will only know about the groups in your
417 If you set this variable to nil, you probably still want to be told
418 about new newsgroups that arrive. To do that, set
419 `gnus-check-new-newsgroups' to `ask-server'. This may not work
420 properly with all servers.")
422 (defvar gnus-activate-foreign-newsgroups nil
423 "*If nil, Gnus will not check foreign newsgroups at startup.
424 If it is non-nil, it should be a number between one and nine. Foreign
425 newsgroups that have a level lower or equal to this number will be
426 activated on startup. For instance, if you want to active all
427 subscribed newsgroups, but not the rest, you'd set this variable to 5.
429 If you subscribe to lots of newsgroups from different servers, startup
430 might take a while. By setting this variable to nil, you'll save time,
431 but you won't be told how many unread articles there are in the
434 (defvar gnus-save-newsrc-file t
435 "*Non-nil means that Gnus will save the `.newsrc' file.
436 Gnus always saves its own startup file, which is called
437 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
438 be readily understood by other newsreaders. If you don't plan on
439 using other newsreaders, set this variable to nil to save some time on
442 (defvar gnus-save-killed-list t
443 "*If non-nil, save the list of killed groups to the startup file.
444 This will save both time (when starting and quitting) and space (both
445 memory and disk), but it will also mean that Gnus has no record of
446 which groups are new and which are old, so the automatic new
447 newsgroups subscription methods become meaningless. You should always
448 set `gnus-check-new-newsgroups' to `ask-server' or nil if you set this
451 (defvar gnus-interactive-catchup t
452 "*If non-nil, require your confirmation when catching up a group.")
454 (defvar gnus-interactive-post t
455 "*If non-nil, group name will be asked for when posting.")
457 (defvar gnus-interactive-exit t
458 "*If non-nil, require your confirmation when exiting Gnus.")
460 (defvar gnus-kill-killed nil
461 "*If non-nil, Gnus will apply kill files to already killed articles.
462 If it is nil, Gnus will never apply kill files to articles that have
463 already been through the scoring process, which might very well save lots
466 (defvar gnus-extract-address-components 'gnus-extract-address-components
467 "*Function for extracting address components from a From header.
468 Two pre-defined function exist: `gnus-extract-address-components',
469 which is the default, quite fast, and too simplistic solution, and
470 `mail-extract-address-components', which works much better, but is
473 (defvar gnus-score-interactive-default-score 1000
474 "*Scoring commands will raise/lower the score with this number as the default.")
476 (defvar gnus-save-score nil
477 "*If non-nil, save group scoring info.")
479 (defvar gnus-global-score-files nil
480 "*List of global score files and directories.
481 Set this variable if you want to use people's score files. One entry
482 for each score file or each score file directory. Gnus will decide
483 by itself what score files are applicable to which group.
485 Say you want to use the single score file
486 \"/ftp.ifi.uio.no@ftp:/pub/larsi/ding/score/soc.motss.SCORE\" and all
487 score files in the \"/ftp.some-where:/pub/score\" directory.
489 (setq gnus-global-score-files
490 '(\"/ftp.ifi.uio.no:/pub/larsi/ding/score/soc.motss.SCORE\"
491 \"/ftp.some-where:/pub/score\"))")
493 (defvar gnus-summary-default-score 0
494 "*Default article score level.
495 If this variable is nil, scoring will be disabled.")
497 (defvar gnus-group-default-list-level 5
498 "*Default listing level.")
500 (defvar gnus-user-login-name nil
501 "*The login name of the user.
502 Got from the function `user-login-name' if undefined.")
504 (defvar gnus-user-full-name nil
505 "*The full name of the user.
506 Got from the NAME environment variable if undefined.")
508 (defvar gnus-user-from-line nil
509 "*Your full, complete e-mail address.
510 Overrides the other Gnus variables if it is non-nil.
512 Here are two example values of this variable:
514 \"Lars Magne Ingebrigtsen <larsi@ifi.uio.no>\"
518 \"larsi@ifi.uio.no (Lars Magne Ingebrigtsen)\"
520 The first version is recommended, but the name has to be quoted if it
521 contains non-alphanumerical characters.")
523 (defvar gnus-show-mime nil
524 "*If non-ni, do mime processing of articles.
525 The articles will simply be fed to the function given by
526 `gnus-show-mime-method'.")
528 (defvar gnus-show-mime-method (function metamail-buffer)
529 "*Function to process a MIME message.
530 The function is called from the article buffer.")
532 (defvar gnus-show-threads t
533 "*If non-nil, display threads in summary mode.")
535 (defvar gnus-thread-hide-subtree nil
536 "*If non-nil, hide all threads initially.
537 If threads are hidden, you have to run the command
538 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
539 to expose hidden threads.")
541 (defvar gnus-thread-hide-killed t
542 "*If non-nil, hide killed threads automatically.")
544 (defvar gnus-thread-ignore-subject nil
545 "*If non-nil, ignore subjects and do all threading based on the Reference header.
546 If nil, which is the default, articles that have different subjects
547 from their parents will start separate threads.")
549 (defvar gnus-thread-indent-level 4
550 "*Number that says how much each sub-thread should be indented.")
552 ;; jwz: nuke newsgroups whose name is all digits - that means that
553 ;; some loser has let articles get into the root of the news spool,
554 ;; which is toxic. Lines beginning with whitespace also tend to be
556 (defvar gnus-ignored-newsgroups
557 (purecopy (mapconcat 'identity
558 '("^to\\." ; not "real" groups
559 "^[0-9. \t]+ " ; all digits in name
560 "[][\"#'() ;\\]" ; bogus characters
563 "*A regexp to match uninteresting newsgroups in the active file.
564 Any lines in the active file matching this regular expression are
565 removed from the newsgroup list before anything else is done to it,
566 thus making them effectively non-existant.")
568 (defvar gnus-ignored-headers
569 "^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:"
570 "*All headers that match this regexp will be hidden.
571 Also see `gnus-visible-headers'.")
573 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
574 "*All headers that do not match this regexp will be hidden.
575 Also see `gnus-ignored-headers'.")
577 (defvar gnus-sorted-header-list
578 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
579 "^Cc:" "^Date:" "^Organization:")
580 "*This variable is a list of regular expressions.
581 If it is non-nil, headers that match the regular expressions will
582 be placed first in the article buffer in the sequence specified by
585 (defvar gnus-required-headers
586 '(From Date Newsgroups Subject Message-ID Organization Lines X-Newsreader)
587 "*Headers to be generated or prompted for when posting an article.
588 RFC977 and RFC1036 require From, Date, Newsgroups, Subject,
589 Message-ID. Organization, Lines and X-Newsreader are optional. If
590 you want Gnus not to insert some header, remove it from this list.")
592 (defvar gnus-show-all-headers nil
593 "*If non-nil, don't hide any headers.")
595 (defvar gnus-save-all-headers t
596 "*If non-nil, don't remove any headers before saving.")
598 (defvar gnus-inhibit-startup-message nil
599 "*If non-nil, the startup message will not be displayed.")
601 (defvar gnus-auto-extend-newsgroup t
602 "*If non-nil, extend newsgroup forward and backward when requested.")
604 (defvar gnus-auto-select-first t
605 "*If non-nil, select the first unread article when entering a group.
606 If you want to prevent automatic selection of the first unread article
607 in some newsgroups, set the variable to nil in
608 `gnus-select-group-hook'.")
610 (defvar gnus-auto-select-next t
611 "*If non-nil, offer to go to the next group from the end of the previous.
612 If the value is t and the next newsgroup is empty, Gnus will exit
613 summary mode and go back to group mode. If the value is neither nil
614 nor t, Gnus will select the following unread newsgroup. In
615 particular, if the value is the symbol `quietly', the next unread
616 newsgroup will be selected without any confirmations.")
618 (defvar gnus-auto-select-same nil
619 "*If non-nil, select the next article with the same subject.")
621 (defvar gnus-auto-center-summary t
622 "*If non-nil, always center the current summary buffer.")
624 (defvar gnus-auto-mail-to-author nil
625 "*If non-nil, mail the authors of articles a copy of your follow-ups.
626 If this variable is `ask', the user will be prompted for whether to
627 mail a copy. The string given by `gnus-mail-courtesy-message' will be
628 inserted at the beginning of the mail copy.
630 Mail is sent using the function specified by the
631 `gnus-mail-send-method' variable.")
633 ;; Added by Ethan Bradford <ethanb@ptolemy.astro.washington.edu>.
634 (defvar gnus-mail-courtesy-message
635 "*The following message is a courtesy copy of an article\nthat has been posted as well.\n\n"
636 "This is inserted at the start of a mailed copy of a posted message.
637 If this variable is nil, no such courtesy message will be added.")
639 (defvar gnus-break-pages t
640 "*If non-nil, do page breaking on articles.
641 The page delimiter is specified by the `gnus-page-delimiter'
644 (defvar gnus-page-delimiter "^\^L"
645 "*Regexp describing what to use as article page delimiters.
646 The default value is \"^\^L\", which is a form linefeed at the
647 beginning of a line.")
649 (defvar gnus-use-full-window t
650 "*If non-nil, use the entire Emacs screen.")
652 (defvar gnus-window-configuration
656 "*Specify window configurations for each action.
657 The format of the variable is either a list of (ACTION (G S A)), where
658 G, S, and A are the relative height of group, summary, and article
659 windows, respectively, or a list of (ACTION FUNCTION), where FUNCTION
660 is a function that will be called with ACTION as an argument. ACTION
661 can be `summary', `newsgroups', or `article'.")
663 (defvar gnus-mail-reply-method (function gnus-mail-reply-using-mail)
664 "*Function to compose a reply.
665 Two pre-made functions are `gnus-mail-reply-using-mail' (sendmail) and
666 `gnus-mail-reply-using-mhe' (MH-E).")
668 (defvar gnus-mail-forward-method (function gnus-mail-forward-using-mail)
669 "*Function to forward the current message to another user.
670 Two pre-made functions are `gnus-mail-forward-using-mail' (sendmail)
671 and `gnus-mail-forward-using-mhe' (MH-E).")
673 (defvar gnus-mail-other-window-method 'gnus-mail-other-window-using-mail
674 "*Function to compose mail in the other window.
675 Two pre-made functions are `gnus-mail-other-window-using-mail'
676 (sendmail) and `gnus-mail-other-window-using-mhe' (MH-E).")
678 (defvar gnus-mail-send-method send-mail-function
679 "*Function to mail a message which is also being posted as an article.
680 The message must have To or Cc header. The default is copied from
681 the variable `send-mail-function'.")
683 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
684 "*Function called with a group name when new group is detected.
685 A few pre-made functions are supplied: `gnus-subscribe-randomly'
686 inserts new groups at the beginning of the list of groups;
687 `gnus-subscribe-alphabetically' inserts new groups in strict
688 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
689 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
692 ;; Suggested by a bug report by Hallvard B Furuseth.
693 ;; <h.b.furuseth@usit.uio.no>.
694 (defvar gnus-subscribe-options-newsgroup-method
695 (function gnus-subscribe-alphabetically)
696 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
697 If, for instance, you want to subscribe to all newsgroups in the
698 \"no\" and \"alt\" hierarchies, you'd put the following in your
701 options -n no.all alt.all
703 Gnus will the subscribe all new newsgroups in these hierarchies with
704 the subscription method in this variable.")
706 (defvar gnus-subscribe-hierarchical-interactive nil
707 "*If non-nil, Gnus will offer to subscribe hierarchically.
708 When a new hierarchy appears, Gnus will ask the user:
710 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
712 If the user pressed `d', Gnus will descend the hierarchy, `y' will
713 subscribe to all newsgroups in the hierarchy and `s' will skip this
714 hierarchy in its entirety.")
716 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
717 "*Function used for sorting the group buffer.
718 This function will be called with group info entries as the arguments
719 for the groups to be sorted. Pre-made functions include
720 `gnus-sort-by-alphabet', `gnus-sort-by-unread' and
721 `gnus-sort-by-level'")
723 ;; Mark variables suggested by Thomas Michanek
724 ;; <Thomas.Michanek@telelogic.se>.
725 (defvar gnus-unread-mark ?
726 "*Mark used for unread articles.")
727 (defvar gnus-ticked-mark ?!
728 "*Mark used for ticked articles.")
729 (defvar gnus-dormant-mark ??
730 "*Mark used for dormant articles.")
731 (defvar gnus-dread-mark ?D
732 "*Mark used for read articles.")
733 (defvar gnus-read-mark ?d
734 "*Mark used for read articles.")
735 (defvar gnus-expirable-mark ?E
736 "*Mark used for expirable articles.")
737 (defvar gnus-killed-mark ?K
738 "*Mark used for killed articles.")
739 (defvar gnus-kill-file-mark ?X
740 "*Mark used for articles killed by kill files.")
741 (defvar gnus-low-score-mark ?Y
742 "*Mark used for articles with a low score.")
743 (defvar gnus-catchup-mark ?C
744 "*Mark used for articles that are caught up.")
745 (defvar gnus-replied-mark ?R
746 "*Mark used for articles that have been replied to.")
747 (defvar gnus-process-mark ?#
749 (defvar gnus-ancient-mark ?A
750 "*Mark used for ancient articles.")
751 (defvar gnus-canceled-mark ?G
752 "*Mark used for cancelled articles.")
753 (defvar gnus-score-over-mark ?+
754 "*Score mark used for articles with high scores.")
755 (defvar gnus-score-below-mark ?-
756 "*Score mark used for articles with low scores.")
758 (defvar gnus-view-pseudo-asynchronously nil
759 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
761 (defvar gnus-view-pseudos nil
762 "*If `automatic', pseudo-articles will be viewed automatically.
763 If `not-confirm', pseudos will be viewed automatically, and the user
764 will not be asked to confirm the command.")
766 (defvar gnus-group-line-format "%M%S%5y: %(%g%)\n"
767 "*Format of group lines.
768 It works along the same lines as a normal formatting string,
769 with some simple extensions.
771 %M Only marked articles (character, \"*\" or \" \")
772 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
773 %L Level of subscribedness (integer, 1-9)
774 %N Number of unread articles (integer)
775 %I Number of dormant articles (integer)
776 %i Number of ticked and dormant (integer)
777 %T Number of ticked articles (integer)
778 %R Number of read articles (integer)
779 %t Total number of articles (integer)
780 %y Number of unread, unticked articles (integer)
781 %G Group name (string)
782 %g Qualified group name (string)
783 %D Group description (string)
784 %s Select method (string)
785 %o Moderated group (char, \"m\")
786 %O Moderated group (string, \"(m)\" or \"\")
787 %n Select from where (string)
788 %z A string that look like `<%s:%n>' if a foreign select method is used
789 %u User defined specifier. The next character in the format string should
790 be a letter. Gnus will call the function gnus-user-format-function-X,
791 where X is the letter following %u. The function will be passed the
792 current header as argument. The function should return a string, which
793 will be inserted into the buffer just like information from any other
796 Text between %( and %) will be highlighted with `gnus-mouse-face' when
797 the mouse point move inside the area. There can only be one such area.
799 Note that this format specification is not always respected. For
800 reasons of efficiency, when listing killed groups, this specification
801 is ignored altogether. If the spec is changed considerably, your
802 output may end up looking strange when listing both alive and killed
805 If you use %o or %O, reading the active file will be slower and quite
806 a bit of extra memory will be used. %D will also worsen performance.
807 Also note that if you change the format specification to include any
808 of these specs, you must probably re-start Gnus to see them go into
811 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
812 "*The format specification of the lines in the summary buffer.
814 It works along the same lines as a normal formatting string,
815 with some simple extensions.
817 %N Article number, left padded with spaces (string)
819 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
820 %n Name of the poster (string)
821 %A Address of the poster (string)
822 %L Number of lines in the article (integer)
823 %c Number of characters in the article (integer)
824 %D Date of the article (string)
825 %I Indentation based on thread level (a string of spaces)
826 %T A string with two possible values: 80 spaces if the article
827 is on thread level two or larger and 0 spaces on level one
828 %U Status of this article (character, \"D\", \"K\", \"-\" or \" \")
829 %[ Opening bracket (character, \"[\" or \"<\")
830 %] Closing bracket (character, \"]\" or \">\")
831 %> Spaces of length thread-level (string)
832 %< Spaces of length (- 20 thread-level) (string)
833 %i Article score (number)
834 %z Article zcore (character)
835 %t Number of articles under the current thread.
836 %u User defined specifier. The next character in the format string should
837 be a letter. Gnus will call the function gnus-user-format-function-X,
838 where X is the letter following %u. The function will be passed the
839 current header as argument. The function should return a string, which
840 will be inserted into the summary just like information from any other
843 Text between %( and %) will be highlighted with `gnus-mouse-face'
844 when the mouse point is placed inside the area. There can only be one
847 The %U (status), %R (replied) and %z (zcore) specs have to be handled
848 with care. For reasons of efficiency, Gnus will compute what column
849 these characters will end up in, and \"hard-code\" that. This means that
850 it is illegal to have these specs after a variable-length spec. Well,
851 you might not be arrested, but your summary buffer will look strange,
854 The smart choice is to have these specs as for to the left as
857 This restriction may disappear in later versions of Gnus.")
859 (defvar gnus-summary-dummy-line-format "* : : %S\n"
860 "*The format specification for the dummy roots in the summary buffer.
861 It works along the same lines as a normal formatting string,
862 with some simple extensions.
866 (defvar gnus-summary-mode-line-format "(ding) %G/%A %Z"
867 "*The format specification for the summary mode line.")
869 (defvar gnus-article-mode-line-format "(ding) %G/%A %S"
870 "*The format specification for the article mode line.")
872 (defvar gnus-group-mode-line-format "(ding) List of groups {%M:%S} "
873 "*The format specification for the group mode line.")
875 (defvar gnus-valid-select-methods
876 '(("nntp" post address prompt-address)
878 ("nnvirtual" none virtual prompt-address address)
879 ("nnmbox" mail respool)
880 ("nnml" mail respool)
881 ("nnmh" mail respool)
882 ("nndir" none prompt-address address)
884 ("nndoc" none prompt-address)
885 ("nnbabyl" mail respool)
886 ("nnkiboze" none virtual)
887 ("nnfolder" mail respool))
888 "An alist of valid select methods.
889 The first element of each list lists should be a string with the name
890 of the select method. The other elements may be be the category of
891 this method (ie. `post', `mail', `none' or whatever) or other
892 properties that this method has (like being respoolable).
893 If you implement a new select method, all you should have to change is
894 this variable. I think.")
896 (defvar gnus-updated-mode-lines '(group article summary)
897 "*List of buffers that should update their mode lines.
898 The list may contain the symbols `group', `article' and `summary'. If
899 the corresponding symbol is present, Gnus will keep that mode line
900 updated with information that may be pertinent.
901 If this variable is nil, screen refresh may be quicker.")
903 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
904 (defvar gnus-mode-non-string-length 21
905 "*Max length of mode-line non-string contents buffer contents.")
907 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
908 (defvar gnus-mouse-face 'highlight
909 "*Face used for mouse highlighting in Gnus.
910 No mouse highlights will be done if `gnus-visual' is nil.")
912 (defvar gnus-summary-mark-below nil
913 "*Mark all articles with a score below this variable as read.
914 This variable is local to each summary buffer and usually set by the
917 (defvar gnus-orphan-score nil
918 "*All orphans get this score added. Set in the score file.")
920 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
921 "*List of functions used for sorting threads in the summary buffer.
922 By default, threads are sorted by article number.
924 Each function takes two threads and return non-nil if the first thread
925 should be sorted before the other. If you use more than one function,
926 the primary sort function should be the last.
928 Ready-mady functions include `gnus-thread-sort-by-number',
929 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
930 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
931 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
933 The latter two only work on threads that have been scored prior to
934 entering the newsgroup.")
936 (defvar gnus-thread-score-function '+
937 "*Function used for calculating the total score of a thread.
939 The function is called with the scores of the article and each
940 subthread and should then return the score of the thread.
942 Some functions you can use are `+', `max', or `min'.")
944 (defvar gnus-score-find-score-files-function 'gnus-score-find-bnews
945 "*Function used to find SCORE files.
946 The function will be called with the group name as the argument, and
947 should return a list of score files to apply to that group. The score
948 files do not actually have to exist.
950 Predefined values are:
952 gnus-score-find-single: Only apply the group's own SCORE file.
953 gnus-score-find-hierarchical: Also apply SCORE files from parent groups.
954 gnus-score-find-bnews: Apply SCORE files whose names matches.
956 See the documentation to these functions for more information.
958 This variable can also be a list of functions to be called. Each
959 function should either return a list of score files, or a list of
962 (defvar gnus-options-subscribe nil
963 "*All new groups matching this regexp will be subscribed unconditionally.
964 Note that this variable deals only with new newsgroups. This variable
965 does not affect old newsgroups.")
967 (defvar gnus-options-not-subscribe nil
968 "*All new groups matching this regexp will be ignored.
969 Note that this variable deals only with new newsgroups. This variable
970 does not affect old (already subscribed) newsgroups.")
972 (defvar gnus-auto-expirable-newsgroups nil
973 "*Groups in which to automatically mark read articles as expirable.
974 If non-nil, this should be a regexp that should match all groups in
975 which to perform auto-expiry. This only makes sense for mail groups.")
980 (defvar gnus-group-mode-hook nil
981 "*A hook for Gnus group mode.")
983 (defvar gnus-summary-mode-hook nil
984 "*A hook for Gnus summary mode.")
986 (defvar gnus-article-mode-hook nil
987 "*A hook for Gnus article mode.")
989 (defvar gnus-open-server-hook nil
990 "*A hook called just before opening connection to the news server.")
992 (defvar gnus-startup-hook nil
993 "*A hook called at startup.
994 This hook is called after Gnus is connected to the NNTP server.")
996 (defvar gnus-get-new-news-hook nil
997 "*A hook run just before Gnus checks for new news.")
999 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1000 "*A function that is called to generate the group buffer.
1001 The function is called with three arguments: The first is a number;
1002 all group with a level less or equal to that number should be listed,
1003 if the second is non-nil, empty groups should also be displayed. If
1004 the third is non-nil, it is a number. No groups with a level lower
1005 than this number should be displayed.
1007 The only current function implemented is `gnus-group-prepare-flat'.")
1009 (defvar gnus-group-prepare-hook nil
1010 "*A hook called after the group buffer has been generated.
1011 If you want to modify the group buffer, you can use this hook.")
1013 (defvar gnus-summary-prepare-hook nil
1014 "*A hook called after the summary buffer has been generated.
1015 If you want to modify the summary buffer, you can use this hook.")
1017 (defvar gnus-article-prepare-hook nil
1018 "*A hook called after an article has been prepared in the article buffer.
1019 If you want to run a special decoding program like nkf, use this hook.")
1021 (defvar gnus-article-display-hook nil
1022 "*A hook called after the article is displayed in the article buffer.
1023 The hook is designed to change the contents of the article
1024 buffer. Typical functions that this hook may contain are
1025 `gnus-article-hide-headers' (hide selected headers),
1026 `gnus-article-hide-signature' (hide signature) and
1027 `gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1028 (add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1029 (add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1031 (defconst gnus-article-x-face-command "uncompface | ikon2xbm | xv -"
1032 "String or function to be executed to display an X-Face header.
1033 If it is a string, the command will be executed in a sub-shell
1034 asynchronously. The compressed face will be piped to this command.")
1036 (defvar gnus-select-group-hook nil
1037 "*A hook called when a newsgroup is selected.
1039 If you'd like to simplify subjects like the
1040 `gnus-summary-next-same-subject' command does, you can use the
1043 (setq gnus-select-group-hook
1046 (mapcar (lambda (header)
1049 (gnus-simplify-subject
1050 (header-subject header) 're-only)))
1051 gnus-newsgroup-headers))))")
1053 (defvar gnus-select-article-hook
1054 '(gnus-summary-show-thread)
1055 "*A hook called when an article is selected.
1056 The default hook shows conversation thread subtrees of the selected
1057 article automatically using `gnus-summary-show-thread'.")
1059 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1060 "*A hook called to apply kill files to a group.
1061 This hook is intended to apply a kill file to the selected newsgroup.
1062 The function `gnus-apply-kill-file' is called by default.
1064 Since a general kill file is too heavy to use only for a few
1065 newsgroups, I recommend you to use a lighter hook function. For
1066 example, if you'd like to apply a kill file to articles which contains
1067 a string `rmgroup' in subject in newsgroup `control', you can use the
1070 \(setq gnus-apply-kill-hook
1073 (cond ((string-match \"control\" gnus-newsgroup-name)
1074 (gnus-kill \"Subject\" \"rmgroup\")
1075 (gnus-expunge \"X\"))))))")
1077 (defvar gnus-visual-mark-article-hook
1078 (list 'gnus-visual-highlight-selected-summary)
1079 "*Hook run after selecting an article in the summary buffer.
1080 It is meant to be used for highlighting the article in some way. It
1081 is not run if `gnus-visual' is nil.")
1083 (defvar gnus-prepare-article-hook (list 'gnus-inews-insert-signature)
1084 "*A hook called after preparing body, but before preparing header headers.
1085 The default hook (`gnus-inews-insert-signature') inserts a signature
1086 file specified by the variable `gnus-signature-file'.")
1088 (defvar gnus-inews-article-hook (list 'gnus-inews-do-fcc)
1089 "*A hook called before finally posting an article.
1090 The default hook (`gnus-inews-do-fcc') does FCC processing (ie. saves
1091 the article to a file).")
1093 (defvar gnus-inews-article-header-hook nil
1094 "*A hook called after inserting the headers in an article to be posted.
1095 The hook is called from the *post-news* buffer, narrowed to the
1098 (defvar gnus-exit-group-hook nil
1099 "*A hook called when exiting (not quitting) summary mode.")
1101 (defvar gnus-suspend-gnus-hook nil
1102 "*A hook called when suspending (not exiting) Gnus.")
1104 (defvar gnus-exit-gnus-hook nil
1105 "*A hook called when exiting Gnus.")
1107 (defvar gnus-save-newsrc-hook nil
1108 "*A hook called when saving the newsrc file.")
1110 (defvar gnus-visual-summary-update-hook
1111 (list 'gnus-visual-summary-highlight-line)
1112 "*A hook called when a summary line is changed.
1113 The hook will not be called if `gnus-visual' is nil.
1115 The default function `gnus-visual-summary-highlight-line' will
1116 highlight the line according to the `gnus-visual-summary-highlight'
1119 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1120 "*A hook called when an article is selected for the first time.
1121 The hook is intended to mark an article as read (or unread)
1122 automatically when it is selected.")
1124 ;; Site dependent variables. These variables should be defined in
1127 (defvar gnus-default-nntp-server nil
1128 "*Specify a default NNTP server.
1129 This variable should be defined in paths.el, and should never be set
1131 If you want to change servers, you should use `gnus-select-method'.
1132 See the documentation to that variable.")
1134 (defconst gnus-backup-default-subscribed-newsgroups
1135 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
1136 "Default default new newsgroups the first time Gnus is run.
1137 Should be set in paths.el, and shouldn't be touched by the user.")
1139 (defvar gnus-local-domain nil
1140 "*Local domain name without a host name.
1141 The DOMAINNAME environment variable is used instead if it is defined.
1142 If the `system-name' function returns the full Internet name, there is
1143 no need to set this variable.")
1145 (defvar gnus-local-organization nil
1146 "*String with a description of what organization (if any) the user belongs to.
1147 The ORGANIZATION environment variable is used instead if it is defined.
1148 If this variable contains a function, this function will be called
1149 with the current newsgroup name as the argument. The function should
1151 In any case, if the string (either in the variable, in the environment
1152 variable, or returned by the function) is a file name, the contents of
1153 this file will be used as the organization.")
1155 (defvar gnus-use-generic-from nil
1156 "*If nil, the full host name will be the system name prepended to the domain name.
1157 If this is a string, the full host name will be this string.
1158 If this is non-nil, non-string, the domain name will be used as the
1161 (defvar gnus-use-generic-path nil
1162 "*If nil, use the NNTP server name in the Path header.
1163 If stringp, use this; if non-nil, use no host name (user name only).")
1166 ;; Internal variables
1168 ;; Avoid highlighting in kill files.
1169 (defvar gnus-summary-inhibit-highlight nil)
1170 (defvar gnus-newsgroup-selected-overlay nil)
1172 (defvar gnus-article-mode-map nil)
1173 (defvar caesar-translate-table nil)
1174 (defvar gnus-dribble-buffer nil)
1175 (defvar gnus-headers-retrieved-by nil)
1176 (defvar gnus-article-reply nil)
1177 (defvar gnus-override-method nil)
1178 (defvar gnus-article-check-size nil)
1179 (defvar gnus-score-file-list nil)
1180 (defvar gnus-internal-global-score-files nil)
1181 (defvar gnus-current-score-file nil)
1183 (defvar gnus-current-move-group nil)
1185 (defvar gnus-score-alist nil
1186 "Alist containing score information.
1187 The keys can be symbols or strings. The following symbols are defined.
1189 touched: If this alist has been modified.
1190 mark: Automatically mark articles below this.
1191 expunge: Automatically expunge articles below this.
1192 files: List of other SCORE files to load when loading this one.
1193 eval: Sexp to be evaluated when the score file is loaded.
1195 String entries have the form (HEADER (MATCH TYPE SCORE DATE) ...)
1196 where HEADER is the header being scored, MATCH is the string we are
1197 looking for, TYPE is a flag indicating whether it should use regexp or
1198 substring matching, SCORE is the score to add and DATE is the date
1199 of the last succesful match.")
1201 (defvar gnus-score-cache nil)
1202 (defvar gnus-scores-articles nil)
1203 (defvar gnus-scores-exclude-files nil)
1204 (defvar gnus-header-index nil)
1205 (defvar gnus-score-index nil)
1207 (defvar gnus-newsgroup-dependencies nil)
1208 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1209 (defvar gnus-default-subscribe-level 2)
1210 (defvar gnus-default-unsubscribe-level 6)
1211 (defvar gnus-default-kill-level 9)
1213 (defconst gnus-group-line-format-alist
1214 (list (list ?M 'marked ?c)
1215 (list ?S 'subscribed ?c)
1217 (list ?N 'number ?s)
1218 (list ?I 'number-of-dormant ?d)
1219 (list ?T 'number-of-ticked ?d)
1220 (list ?R 'number-of-read ?s)
1221 (list ?t 'number-total ?d)
1222 (list ?y 'number-of-unread-unticked ?s)
1223 (list ?i 'number-of-ticked-and-dormant ?d)
1225 (list ?G 'qualified-group ?s)
1226 (list ?D 'newsgroup-description ?s)
1227 (list ?o 'moderated ?c)
1228 (list ?O 'moderated-string ?s)
1229 (list ?s 'news-server ?s)
1230 (list ?n 'news-method ?s)
1231 (list ?z 'news-method-string ?s)
1232 (list ?u 'user-defined ?s)))
1234 (defconst gnus-summary-line-format-alist
1235 (list (list ?N 'number ?s)
1236 (list ?S 'subject ?s)
1237 (list ?s 'subject-or-nil ?s)
1239 (list ?A 'address ?s)
1241 (list ?x (macroexpand '(header-xref header)) ?s)
1242 (list ?D (macroexpand '(header-date header)) ?s)
1243 (list ?M (macroexpand '(header-id header)) ?s)
1244 (list ?r (macroexpand '(header-references header)) ?s)
1245 (list ?c (macroexpand '(header-chars header)) ?d)
1247 (list ?I 'indentation ?s)
1248 (list ?T '(if (< level 1) "" (make-string (frame-width) ? )) ?s)
1249 (list ?R 'replied ?c)
1250 (list ?\[ 'opening-bracket ?c)
1251 (list ?\] 'closing-bracket ?c)
1252 (list ?\> '(make-string level ? ) ?s)
1253 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1255 (list ?z 'score-char ?c)
1256 (list ?U 'unread ?c)
1257 (list ?t '(gnus-summary-number-of-articles-in-thread thread) ?d)
1258 (list ?u 'user-defined ?s))
1259 "An alist of format specifications that can appear in summary lines,
1260 and what variables they correspond with, along with the type of the
1261 variable (string, integer, character, etc).")
1263 (defconst gnus-summary-dummy-line-format-alist
1264 (list (list ?S 'subject ?s)
1265 (list ?N 'number ?d)
1266 (list ?u 'user-defined ?s)))
1268 (defconst gnus-summary-mode-line-format-alist
1269 (list (list ?G 'group-name ?s)
1270 (list ?g '(gnus-short-group-name group-name))
1271 (list ?A 'article-number ?d)
1272 (list ?Z 'unread-and-unselected ?s)
1273 (list ?V 'gnus-version ?s)
1274 (list ?U 'unread ?d)
1275 (list ?S 'subject ?s)
1276 (list ?e 'unselected ?d)
1277 (list ?u 'user-defined ?s)
1278 (list ?s 'gnus-current-score-file ?s)))
1280 (defconst gnus-group-mode-line-format-alist
1281 (list (list ?S 'news-server ?s)
1282 (list ?M 'news-method ?s)
1283 (list ?u 'user-defined ?s)))
1285 (defvar gnus-have-read-active-file nil)
1287 (defconst gnus-maintainer "Lars Magne Ingebrigtsen <larsi@ifi.uio.no>"
1288 "The mail address of the Gnus maintainer.")
1290 (defconst gnus-version "(ding) Gnus v0.51"
1291 "Version number for this version of Gnus.")
1293 (defvar gnus-info-nodes
1294 '((gnus-group-mode "(gnus)The Group Buffer")
1295 (gnus-summary-mode "(gnus)The Summary Buffer")
1296 (gnus-article-mode "(gnus)The Article Buffer"))
1297 "Assoc list of major modes and related Info nodes.")
1299 (defvar gnus-documentation-group-file "~/dgnus/lisp/doc.txt"
1300 "The location of the (ding) Gnus documentation group.")
1302 (defvar gnus-group-buffer "*Group*")
1303 (defvar gnus-summary-buffer "*Summary*")
1304 (defvar gnus-article-buffer "*Article*")
1305 (defvar gnus-server-buffer "*Server*")
1307 (defvar gnus-buffer-list nil
1308 "Gnus buffers that should be killed on exit.")
1310 (defvar gnus-server-alist nil
1311 "List of available servers.")
1313 (defvar gnus-variable-list
1314 '(gnus-newsrc-options gnus-newsrc-options-n
1315 gnus-newsrc-last-checked-date
1316 gnus-newsrc-assoc gnus-server-alist
1317 gnus-killed-list gnus-zombie-list)
1318 "Gnus variables saved in the quick startup file.")
1320 (defvar gnus-overload-functions
1321 '((news-inews gnus-inews-news "rnewspost")
1322 (caesar-region gnus-caesar-region "rnews"))
1323 "Functions overloaded by gnus.
1324 It is a list of `(original overload &optional file)'.")
1326 (defvar gnus-newsrc-options nil
1327 "Options line in the .newsrc file.")
1329 (defvar gnus-newsrc-options-n nil
1330 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1332 (defvar gnus-newsrc-last-checked-date nil
1333 "Date Gnus last asked server for new newsgroups.")
1335 (defvar gnus-newsrc-assoc nil
1336 "Assoc list of read articles.
1337 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1339 (defvar gnus-newsrc-hashtb nil
1340 "Hashtable of gnus-newsrc-assoc.")
1342 (defvar gnus-killed-list nil
1343 "List of killed newsgroups.")
1345 (defvar gnus-killed-hashtb nil
1346 "Hash table equivalent of gnus-killed-list.")
1348 (defvar gnus-zombie-list nil
1349 "List of almost dead newsgroups.")
1351 (defvar gnus-description-hashtb nil
1352 "Descriptions of newsgroups.")
1354 (defvar gnus-list-of-killed-groups nil
1355 "List of newsgroups that have recently been killed by the user.")
1357 (defvar gnus-active-hashtb nil
1358 "Hashtable of active articles.")
1360 (defvar gnus-moderated-list nil
1361 "List of moderated newsgroups.")
1363 (defvar gnus-current-startup-file nil
1364 "Startup file for the current host.")
1366 (defvar gnus-last-search-regexp nil
1367 "Default regexp for article search command.")
1369 (defvar gnus-last-shell-command nil
1370 "Default shell command on article.")
1372 (defvar gnus-current-select-method nil
1373 "The current method for selecting a newsgroup.")
1375 (defvar gnus-have-all-newsgroups nil)
1377 (defvar gnus-article-internal-prepare-hook nil)
1379 (defvar gnus-newsgroup-name nil)
1380 (defvar gnus-newsgroup-begin nil)
1381 (defvar gnus-newsgroup-end nil)
1382 (defvar gnus-newsgroup-last-rmail nil)
1383 (defvar gnus-newsgroup-last-mail nil)
1384 (defvar gnus-newsgroup-last-folder nil)
1385 (defvar gnus-newsgroup-last-file nil)
1386 (defvar gnus-newsgroup-auto-expire nil)
1387 (defvar gnus-newsgroup-active nil)
1389 (defvar gnus-newsgroup-unreads nil
1390 "List of unread articles in the current newsgroup.")
1392 (defvar gnus-newsgroup-unselected nil
1393 "List of unselected unread articles in the current newsgroup.")
1395 (defvar gnus-newsgroup-marked nil
1396 "List of ticked articles in the current newsgroup (a subset of unread art).")
1398 (defvar gnus-newsgroup-killed nil
1399 "List of ranges of articles that have been through the scoring process.")
1401 (defvar gnus-newsgroup-kill-headers nil)
1403 (defvar gnus-newsgroup-replied nil
1404 "List of articles that have been replied to in the current newsgroup.")
1406 (defvar gnus-newsgroup-expirable nil
1407 "List of articles in the current newsgroup that can be expired.")
1409 (defvar gnus-newsgroup-processable nil
1410 "List of articles in the current newsgroup that can be processed.")
1412 (defvar gnus-newsgroup-bookmarks nil
1413 "List of articles in the current newsgroup that have bookmarks.")
1415 (defvar gnus-newsgroup-dormant nil
1416 "List of dormant articles in the current newsgroup.")
1418 (defvar gnus-newsgroup-scored nil
1419 "List of scored articles in the current newsgroup.")
1421 (defvar gnus-newsgroup-headers nil
1422 "List of article headers in the current newsgroup.")
1423 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1425 (defvar gnus-newsgroup-ancient nil
1426 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1428 (defvar gnus-current-article nil)
1429 (defvar gnus-article-current nil)
1430 (defvar gnus-current-headers nil)
1431 (defvar gnus-have-all-headers nil)
1432 (defvar gnus-last-article nil)
1433 (defvar gnus-newsgroup-history nil)
1434 (defvar gnus-current-kill-article nil)
1436 ;; Save window configuration.
1437 (defvar gnus-winconf-edit-group nil)
1438 (defvar gnus-winconf-edit-score nil)
1441 (defvar gnus-summary-line-format-spec nil)
1442 (defvar gnus-summary-dummy-line-format-spec nil)
1443 (defvar gnus-group-line-format-spec nil)
1444 (defvar gnus-summary-mode-line-format-spec nil)
1445 (defvar gnus-article-mode-line-format-spec nil)
1446 (defvar gnus-group-mode-line-format-spec nil)
1447 (defvar gnus-summary-mark-positions nil)
1449 (defvar gnus-summary-expunge-below nil)
1450 (defvar gnus-reffed-article-number nil)
1452 (defvar rmail-default-file (expand-file-name "~/XMBOX"))
1453 (defvar rmail-default-rmail-file (expand-file-name "~/XNEWS"))
1455 (defconst gnus-summary-local-variables
1456 '(gnus-newsgroup-name
1457 gnus-newsgroup-begin gnus-newsgroup-end
1458 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1459 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1460 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1461 gnus-newsgroup-unselected gnus-newsgroup-marked
1462 gnus-newsgroup-replied gnus-newsgroup-expirable
1463 gnus-newsgroup-processable gnus-newsgroup-killed
1464 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1465 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1466 gnus-current-article gnus-current-headers gnus-have-all-headers
1467 gnus-last-article gnus-article-internal-prepare-hook
1468 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1469 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1470 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1471 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1472 gnus-newsgroup-history gnus-newsgroup-ancient)
1473 "Variables that are buffer-local to the summary buffers.")
1475 ;;; End of variables.
1477 ;; Define some autoload functions Gnus might use.
1479 (autoload 'metamail-buffer "metamail")
1480 (autoload 'Info-goto-node "info")
1482 (autoload 'timezone-make-date-arpa-standard "timezone")
1483 (autoload 'timezone-fix-time "timezone")
1484 (autoload 'timezone-make-sortable-date "timezone")
1485 (autoload 'timezone-make-time-string "timezone")
1487 (autoload 'rmail-output "rmailout")
1488 (autoload 'mail-position-on-field "sendmail")
1489 (autoload 'mail-setup "sendmail")
1490 (autoload 'news-mail-other-window "rnewspost")
1491 (autoload 'news-reply-yank-original "rnewspost")
1493 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1494 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1495 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1496 (autoload 'gnus-summary-save-in-folder "gnus-mh")
1497 (autoload 'gnus-Folder-save-name "gnus-mh")
1498 (autoload 'gnus-folder-save-name "gnus-mh")
1500 (autoload 'gnus-group-make-menu-bar "gnus-visual")
1501 (autoload 'gnus-summary-make-menu-bar "gnus-visual")
1502 (autoload 'gnus-article-make-menu-bar "gnus-visual")
1503 (autoload 'gnus-visual-highlight-selected-summary "gnus-visual")
1504 (autoload 'gnus-visual-summary-highlight-line "gnus-visual")
1506 (autoload 'gnus-uu-mark-by-regexp "gnus-uu")
1507 (autoload 'gnus-uu-mark-region "gnus-uu")
1508 (autoload 'gnus-uu-mark-thread "gnus-uu")
1509 (autoload 'gnus-uu-mark-sparse "gnus-uu")
1510 (autoload 'gnus-uu-mark-series "gnus-uu")
1511 (autoload 'gnus-uu-mark-all "gnus-uu")
1512 (autoload 'gnus-uu-post-news "gnus-uu")
1513 (autoload 'gnus-uu-digest-and-forward "gnus-uu")
1515 (autoload 'gnus-uu-decode-uu "gnus-uu")
1516 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu")
1517 (autoload 'gnus-uu-decode-unshar "gnus-uu")
1518 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu")
1519 (autoload 'gnus-uu-decode-save "gnus-uu")
1520 (autoload 'gnus-uu-decode-binhex "gnus-uu")
1521 (autoload 'gnus-uu-decode-uu-view "gnus-uu")
1522 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu")
1523 (autoload 'gnus-uu-decode-unshar-view "gnus-uu")
1524 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu")
1525 (autoload 'gnus-uu-decode-save-view "gnus-uu")
1526 (autoload 'gnus-uu-decode-binhex-view "gnus-uu")
1528 (autoload 'gnus-kill "gnus-kill")
1529 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1530 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1531 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1532 (autoload 'gnus-execute "gnus-kill")
1535 (autoload 'pp-to-string "pp")
1536 (autoload 'mail-extract-address-components "mail-extr")
1541 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1542 ;; If you want the cursor to go somewhere else, set these two
1543 ;; functions in some startup hook to whatever you want.
1544 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon)
1545 (defalias 'gnus-group-position-cursor 'gnus-goto-colon)
1547 ;; Cruft to make Gnus work under GNU XEmacs.
1548 (defvar gnus-xemacs nil
1549 "Non-nil if Gnus is running under GNU XEmacs.")
1551 (if (not (string-match "XEmacs\\|Lucid" emacs-version))
1553 (setq gnus-xemacs t)
1555 '((or (memq 'underline (list-faces))
1556 (make-face 'underline))
1557 (or (face-differs-from-default-p 'underline)
1558 (set-face-underline-p 'underline t))
1560 (defun set-text-properties (start end props &optional buffer)
1562 (put-text-property start end (car props) (cadr props) buffer)
1563 (remove-text-properties start end ()))))))
1566 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1567 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1568 (` (let ((GnusStartBufferWindow (selected-window)))
1571 (pop-to-buffer (, buffer))
1573 (select-window GnusStartBufferWindow)))))
1575 (defun gnus-make-hashtable (&optional hashsize)
1576 "Make a hash table (default and minimum size is 255).
1577 Optional argument HASHSIZE specifies the table size."
1578 (make-vector (if hashsize
1579 (max (gnus-create-hash-size hashsize) 255)
1582 (defmacro gnus-gethash (string hashtable)
1583 "Get hash value of STRING in HASHTABLE."
1584 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1585 ;;(` (abbrev-expansion (, string) (, hashtable)))
1586 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1588 (defmacro gnus-sethash (string value hashtable)
1589 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1590 ;; We cannot use define-abbrev since it only accepts string as value.
1591 ; (set (intern string hashtable) value))
1592 (` (set (intern (, string) (, hashtable)) (, value))))
1594 (defsubst gnus-buffer-substring (beg end)
1595 (buffer-substring (match-beginning beg) (match-end end)))
1597 (defsubst gnus-simplify-subject-re (subject)
1598 "Remove \"Re:\" from subject lines."
1599 (let ((case-fold-search t))
1600 (if (string-match "^re: *" subject)
1601 (substring subject (match-end 0))
1604 (defsubst gnus-goto-char (point)
1605 (and point (goto-char point)))
1609 ;;; Gnus Utility Functions
1612 (defun gnus-extract-address-components (from)
1614 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1615 (setq address (substring from (match-beginning 0) (match-end 0))))
1617 (string-match (concat "<" (regexp-quote address) ">") from)
1618 (setq name (substring from 0 (1- (match-beginning 0)))))
1620 (and (string-match "(.+)" from)
1621 (setq name (substring from (1+ (match-beginning 0))
1622 (1- (match-end 0))))))
1623 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1624 (list (or name from) (or address from))))
1626 (defun gnus-fetch-field (field)
1627 "Return the value of the header FIELD of current article."
1630 (gnus-narrow-to-headers)
1631 (mail-fetch-field field))))
1633 (defun gnus-goto-colon ()
1635 (search-forward ":" (save-excursion (end-of-line) (point)) t))
1637 (defun gnus-narrow-to-headers ()
1641 (if (search-forward "\n\n")
1642 (narrow-to-region 1 (1- (point))))))
1644 ;; Get a number that is suitable for hashing; bigger than MIN
1645 (defun gnus-create-hash-size (min)
1651 (defun gnus-update-format-specifications ()
1652 (setq gnus-summary-line-format-spec
1654 gnus-summary-line-format gnus-summary-line-format-alist))
1655 (gnus-update-summary-mark-positions)
1656 (setq gnus-summary-dummy-line-format-spec
1657 (gnus-parse-format gnus-summary-dummy-line-format
1658 gnus-summary-dummy-line-format-alist))
1659 (setq gnus-group-line-format-spec
1661 gnus-group-line-format
1662 gnus-group-line-format-alist))
1663 (if (and (string-match "%D" gnus-group-line-format)
1664 (not gnus-description-hashtb)
1665 gnus-read-active-file)
1666 (gnus-read-descriptions-file))
1667 (setq gnus-summary-mode-line-format-spec
1668 (gnus-parse-format gnus-summary-mode-line-format
1669 gnus-summary-mode-line-format-alist))
1670 (setq gnus-article-mode-line-format-spec
1671 (gnus-parse-format gnus-article-mode-line-format
1672 gnus-summary-mode-line-format-alist))
1673 (setq gnus-group-mode-line-format-spec
1674 (gnus-parse-format gnus-group-mode-line-format
1675 gnus-group-mode-line-format-alist)))
1677 (defun gnus-update-summary-mark-positions ()
1679 (let ((gnus-replied-mark 129)
1680 (gnus-score-below-mark 130)
1681 (gnus-score-over-mark 130)
1683 (set-buffer (get-buffer-create " *gnus work*"))
1684 (buffer-disable-undo (current-buffer))
1686 (gnus-summary-insert-line
1687 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1688 (goto-char (point-min))
1689 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1691 (goto-char (point-min))
1692 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1693 (- (point) 2))) pos))
1694 (goto-char (point-min))
1695 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1696 (- (point) 2))) pos))
1697 (setq gnus-summary-mark-positions pos)
1698 (kill-buffer (current-buffer)))))
1700 (defun gnus-format-max-width (var length)
1702 (if (> (length (setq result (eval var))) length)
1703 (format "%s" (substring result 0 length))
1704 (format "%s" result))))
1706 (defun gnus-set-mouse-face (string)
1707 ;; Set mouse face property on STRING.
1709 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string))
1712 (defun gnus-parse-format (format spec-alist)
1713 ;; This function parses the FORMAT string with the help of the
1714 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1715 ;; string. If the FORMAT string contains the specifiers %( and %)
1716 ;; the text between them will have the mouse-face text property.
1717 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1718 (if (and gnus-visual gnus-mouse-face)
1719 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1720 (button (substring format (match-beginning 2) (match-end 2)))
1721 (post (substring format (match-beginning 3) (match-end 3))))
1723 (gnus-parse-simple-format pre spec-alist)
1724 (list 'gnus-set-mouse-face
1725 (gnus-parse-simple-format button spec-alist))
1726 (gnus-parse-simple-format post spec-alist)))
1727 (gnus-parse-simple-format
1728 (concat (substring format (match-beginning 1) (match-end 1))
1729 (substring format (match-beginning 2) (match-end 2))
1730 (substring format (match-beginning 3) (match-end 3)))
1732 (gnus-parse-simple-format format spec-alist)))
1734 (defun gnus-parse-simple-format (format spec-alist)
1735 ;; This function parses the FORMAT string with the help of the
1736 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1737 ;; string. The list will consist of the symbol `format', a format
1738 ;; specification string, and a list of forms depending on the
1741 spec flist fstring b newspec max-width elem beg)
1743 (set-buffer (get-buffer-create " *gnus work*"))
1744 (buffer-disable-undo (current-buffer))
1745 (gnus-add-current-to-buffer-list)
1749 (while (re-search-forward "%[-0-9]*\\(,[0-9]*\\)*\\(.\\)\\(.\\)?" nil t)
1750 (setq spec (string-to-char (buffer-substring (match-beginning 2)
1752 ;; First check if there are any specs that look anything like
1753 ;; "%12,12A", ie. with a "max width specification". These have
1754 ;; to be treated specially.
1755 (if (setq beg (match-beginning 1))
1758 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
1760 (setq beg (match-beginning 2)))
1761 ;; Find the specification from `spec-alist'.
1762 (if (not (setq elem (cdr (assq spec spec-alist))))
1763 (setq elem '("*" ?s)))
1764 ;; Treat user defined format specifiers specially
1765 (and (eq (car elem) 'user-defined)
1768 (list (intern (concat "gnus-user-format-function-"
1774 (delete-region (match-beginning 3) (match-end 3)))
1775 (if (not (zerop max-width))
1776 (let ((el (car elem)))
1777 (cond ((= (car (cdr elem)) ?c)
1778 (setq el (list 'char-to-string el)))
1779 ((= (car (cdr elem)) ?d)
1780 (numberp el) (setq el (list 'int-to-string el))))
1781 (setq flist (cons (list 'gnus-format-max-width
1785 (setq flist (cons (car elem) flist))
1786 (setq newspec (car (cdr elem))))
1787 ;; Remove the old specification (and possibly a ",12" string).
1788 (delete-region beg (match-end 2))
1789 ;; Insert the new specification.
1792 (setq fstring (buffer-substring 1 (point-max))))
1793 (cons 'format (cons fstring (nreverse flist)))))
1795 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
1796 (defun gnus-read-init-file ()
1798 (or (and (file-exists-p gnus-init-file)
1799 ;; Don't try to load a directory.
1800 (not (file-directory-p gnus-init-file)))
1801 (file-exists-p (concat gnus-init-file ".el"))
1802 (file-exists-p (concat gnus-init-file ".elc")))
1803 (load gnus-init-file nil t)))
1805 ;; Article file names when saving.
1807 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
1808 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1809 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
1810 Otherwise, it is like ~/News/news/group/num."
1813 (concat (if (gnus-use-long-file-name 'not-save)
1814 (gnus-capitalize-newsgroup newsgroup)
1815 (gnus-newsgroup-directory-form newsgroup))
1816 "/" (int-to-string (header-number headers)))
1817 (or gnus-article-save-directory "~/News"))))
1819 (string-equal (file-name-directory default)
1820 (file-name-directory last-file))
1821 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1823 (or last-file default))))
1825 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
1826 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1827 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group/num.
1828 Otherwise, it is like ~/News/news/group/num."
1831 (concat (if (gnus-use-long-file-name 'not-save)
1833 (gnus-newsgroup-directory-form newsgroup))
1834 "/" (int-to-string (header-number headers)))
1835 (or gnus-article-save-directory "~/News"))))
1837 (string-equal (file-name-directory default)
1838 (file-name-directory last-file))
1839 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1841 (or last-file default))))
1843 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
1844 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1845 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group.
1846 Otherwise, it is like ~/News/news/group/news."
1849 (if (gnus-use-long-file-name 'not-save)
1850 (gnus-capitalize-newsgroup newsgroup)
1851 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1852 (or gnus-article-save-directory "~/News"))))
1854 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
1855 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1856 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group.
1857 Otherwise, it is like ~/News/news/group/news."
1860 (if (gnus-use-long-file-name 'not-save)
1862 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1863 (or gnus-article-save-directory "~/News"))))
1865 ;; For subscribing new newsgroup
1867 (defun gnus-subscribe-hierarchical-interactive (groups)
1868 (let ((groups (sort groups 'string<))
1869 prefixes prefix start rest ans group starts)
1871 (setq prefixes (list "^"))
1872 (while (and groups prefixes)
1873 (while (not (string-match (car prefixes) (car groups)))
1874 (setq prefixes (cdr prefixes)))
1875 (setq prefix (car prefixes))
1876 (setq start (1- (length prefix)))
1877 (if (and (string-match "[^\\.]\\." (car groups) start)
1880 (concat "^" (substring (car groups) 0 (match-end 0))))
1881 (string-match prefix (car (cdr groups))))
1883 (setq prefixes (cons prefix prefixes))
1884 (message "Descend hierarchy %s? ([y]nsq): "
1885 (substring prefix 1 (1- (length prefix))))
1886 (setq ans (read-char))
1889 (string-match prefix
1890 (setq group (car groups))))
1891 (setq gnus-killed-list
1892 (cons group gnus-killed-list))
1893 (gnus-sethash group group gnus-killed-hashtb)
1894 (setq groups (cdr groups)))
1895 (setq starts (cdr starts)))
1898 (string-match prefix
1899 (setq group (car groups))))
1900 (gnus-sethash group group gnus-killed-hashtb)
1901 (gnus-subscribe-alphabetically (car groups))
1902 (setq groups (cdr groups)))
1903 (setq starts (cdr starts)))
1906 (setq group (car groups))
1907 (setq gnus-killed-list (cons group gnus-killed-list))
1908 (gnus-sethash group group gnus-killed-hashtb)
1909 (setq groups (cdr groups))))
1911 (message "Subscribe %s? ([n]yq)" (car groups))
1912 (setq ans (read-char))
1913 (setq group (car groups))
1915 (gnus-subscribe-alphabetically (car groups))
1916 (gnus-sethash group group gnus-killed-hashtb))
1919 (setq group (car groups))
1920 (setq gnus-killed-list (cons group gnus-killed-list))
1921 (gnus-sethash group group gnus-killed-hashtb)
1922 (setq groups (cdr groups))))
1924 (setq gnus-killed-list (cons group gnus-killed-list))
1925 (gnus-sethash group group gnus-killed-hashtb)))
1926 (setq groups (cdr groups)))))))
1928 (defun gnus-subscribe-randomly (newsgroup)
1929 "Subscribe new NEWSGROUP by making it the first newsgroup."
1930 (gnus-subscribe-newsgroup newsgroup))
1932 (defun gnus-subscribe-alphabetically (newgroup)
1933 "Subscribe new NEWSGROUP and insert it in alphabetical order."
1934 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
1935 (let ((groups (cdr gnus-newsrc-assoc))
1937 (while (and (not before) groups)
1938 (if (string< newgroup (car (car groups)))
1939 (setq before (car (car groups)))
1940 (setq groups (cdr groups))))
1941 (gnus-subscribe-newsgroup newgroup before)))
1943 (defun gnus-subscribe-hierarchically (newgroup)
1944 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
1945 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
1947 (set-buffer (find-file-noselect gnus-current-startup-file))
1948 (let ((groupkey newgroup)
1950 (while (and (not before) groupkey)
1951 (goto-char (point-min))
1953 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
1954 (while (and (re-search-forward groupkey-re nil t)
1956 (setq before (buffer-substring
1957 (match-beginning 1) (match-end 1)))
1958 (string< before newgroup)))))
1959 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
1961 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
1962 (substring groupkey (match-beginning 1) (match-end 1)))))
1963 (gnus-subscribe-newsgroup newgroup before))))
1965 (defun gnus-subscribe-interactively (newsgroup)
1966 "Subscribe new NEWSGROUP interactively.
1967 It is inserted in hierarchical newsgroup order if subscribed. If not,
1969 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
1970 (gnus-subscribe-hierarchically newsgroup)
1971 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
1973 (defun gnus-subscribe-zombies (newsgroup)
1974 "Make new NEWSGROUP a zombie group."
1975 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
1977 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
1978 "Subscribe new NEWSGROUP.
1979 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
1980 the first newsgroup."
1981 ;; We subscribe the group by changing its level to 3.
1982 (gnus-group-change-level
1983 newsgroup 3 9 (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
1984 (message "Subscribe newsgroup: %s" newsgroup))
1988 (defun gnus-newsgroup-directory-form (newsgroup)
1989 "Make hierarchical directory name from NEWSGROUP name."
1990 (let ((newsgroup (substring newsgroup 0)) ;Copy string.
1991 (len (length newsgroup))
1993 ;; Replace all occurrences of `.' with `/'.
1995 (if (= (aref newsgroup idx) ?.)
1996 (aset newsgroup idx ?/))
1997 (setq idx (1+ idx)))
2001 (defun gnus-make-directory (dir)
2002 "Make DIRECTORY recursively."
2003 (let* ((dir (expand-file-name dir default-directory))
2005 (if (string-match "/$" dir)
2006 (setq dir (substring dir 0 (match-beginning 0))))
2007 (while (not (file-exists-p dir))
2008 (setq dirs (cons dir dirs))
2009 (string-match "/[^/]+$" dir)
2010 (setq dir (substring dir 0 (match-beginning 0))))
2012 (make-directory (car dirs))
2013 (setq dirs (cdr dirs)))))
2015 (defun gnus-capitalize-newsgroup (newsgroup)
2016 "Capitalize NEWSGROUP name."
2017 (and (not (zerop (length newsgroup)))
2018 (concat (char-to-string (upcase (aref newsgroup 0)))
2019 (substring newsgroup 1))))
2023 (defun gnus-simplify-subject (subject &optional re-only)
2024 "Remove `Re:' and words in parentheses.
2025 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2026 (let ((case-fold-search t)) ;Ignore case.
2027 ;; Remove `Re:' and `Re^N:'.
2028 (if (string-match "^re:[ \t]*" subject)
2029 (setq subject (substring subject (match-end 0))))
2030 ;; Remove words in parentheses from end.
2032 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2033 (setq subject (substring subject 0 (match-beginning 0)))))
2034 ;; Return subject string.
2037 (defun gnus-simplify-subject-fuzzy (subject)
2038 (let ((case-fold-search t))
2039 (and (string-match "^re:[ \t]*" subject)
2040 (setq subject (substring subject (match-end 0))))
2041 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2042 (setq subject (substring subject 0 (match-beginning 0))))
2045 (while (string-match "[ \t]+" subject beg)
2047 (concat osubject (substring
2048 subject beg (match-beginning 0)) " ")
2050 (setq osubject (concat osubject (substring subject beg)))
2051 (and (string-match " \\'" osubject)
2052 (setq osubject (substring osubject 0 (match-beginning 0))))
2055 (defun gnus-add-current-to-buffer-list ()
2056 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list)))
2058 (defun gnus-string> (s1 s2)
2059 (not (or (string< s1 s2)
2062 ;; Functions accessing headers.
2063 ;; Functions are more convenient than macros in some cases.
2065 (defun gnus-header-number (header)
2066 "Return article number in HEADER."
2067 (header-number header))
2069 (defun gnus-header-subject (header)
2070 "Return subject string in HEADER."
2071 (header-subject header))
2073 (defun gnus-header-from (header)
2074 "Return author string in HEADER."
2075 (header-from header))
2077 (defun gnus-header-xref (header)
2078 "Return xref string in HEADER."
2079 (header-xref header))
2081 (defun gnus-header-lines (header)
2082 "Return lines in HEADER."
2083 (header-lines header))
2085 (defun gnus-header-date (header)
2086 "Return date in HEADER."
2087 (header-date header))
2089 (defun gnus-header-id (header)
2090 "Return Id in HEADER."
2093 (defun gnus-header-references (header)
2094 "Return references in HEADER."
2095 (header-references header))
2097 (defun gnus-clear-system ()
2098 "Clear all variables and buffers."
2099 ;; Clear Gnus variables.
2100 (let ((variables gnus-variable-list))
2102 (set (car variables) nil)
2103 (setq variables (cdr variables))))
2104 ;; Clear other internal variables.
2105 (setq gnus-list-of-killed-groups nil
2106 gnus-have-read-active-file nil
2107 gnus-newsrc-assoc nil
2108 gnus-newsrc-hashtb nil
2109 gnus-killed-list nil
2110 gnus-zombie-list nil
2111 gnus-killed-hashtb nil
2112 gnus-active-hashtb nil
2113 gnus-moderated-list nil
2114 gnus-description-hashtb nil
2115 gnus-newsgroup-headers nil
2116 gnus-score-cache nil
2117 gnus-newsgroup-headers-hashtb-by-number nil
2118 gnus-newsgroup-name nil
2119 gnus-internal-global-score-files nil
2120 gnus-server-alist nil
2121 gnus-current-select-method nil)
2122 ;; Kill the startup file.
2123 (and gnus-current-startup-file
2124 (get-file-buffer gnus-current-startup-file)
2125 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2126 (gnus-dribble-clear)
2127 ;; Kill global KILL file buffer.
2128 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2129 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2130 (and (buffer-name nntp-server-buffer)
2131 (kill-buffer nntp-server-buffer))
2132 ;; Kill Gnus buffers.
2133 (while gnus-buffer-list
2134 (if (and (get-buffer (car gnus-buffer-list))
2135 (buffer-name (get-buffer (car gnus-buffer-list))))
2136 (kill-buffer (car gnus-buffer-list)))
2137 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2139 (defun gnus-configure-windows (action &optional force)
2140 "Configure Gnus windows according to the next ACTION.
2141 The ACTION is either a symbol, such as `summary', or a
2142 configuration list such as `(1 1 2)'. If ACTION is not a list,
2143 configuration list is got from the variable gnus-window-configuration.
2144 If FORCE is non-nil, the updating will be done whether it is necessary
2147 (if (listp action) action
2148 (if (listp gnus-window-configuration)
2149 (car (cdr (assq action gnus-window-configuration)))
2150 gnus-window-configuration)))
2151 (grpwin (get-buffer-window gnus-group-buffer))
2152 (subwin (get-buffer-window gnus-summary-buffer))
2153 (artwin (get-buffer-window gnus-article-buffer))
2160 ;; Make split-window-vertically leave focus in upper window.
2161 (split-window-keep-point t))
2162 (if (and (symbolp windows) (fboundp windows))
2163 (funcall windows action)
2164 (if (and (not force)
2165 (or (null windows) ;No configuration is specified.
2166 (and (eq (null grpwin)
2167 (zerop (nth 0 windows)))
2169 (zerop (nth 1 windows)))
2171 (zerop (nth 2 windows))))))
2172 ;; No need to change window configuration.
2174 (select-window (or grpwin subwin artwin (selected-window)))
2175 ;; First of all, compute the height of each window.
2176 (cond (gnus-use-full-window
2177 ;; Take up the entire screen.
2178 (delete-other-windows)
2179 (setq height (window-height (selected-window))))
2181 (setq height (+ (if grpwin (window-height grpwin) 0)
2182 (if subwin (window-height subwin) 0)
2183 (if artwin (window-height artwin) 0)))))
2184 ;; The group buffer exits always. So, use it to extend the
2185 ;; group window so as to get enough window space.
2186 (switch-to-buffer gnus-group-buffer 'norecord)
2187 (and (get-buffer gnus-summary-buffer)
2188 (delete-windows-on gnus-summary-buffer))
2189 (and (get-buffer gnus-article-buffer)
2190 (delete-windows-on gnus-article-buffer))
2191 ;; Compute expected window height.
2192 (setq winsum (apply (function +) windows))
2193 (if (not (zerop (nth 0 windows)))
2194 (setq grpheight (max window-min-height
2195 (/ (* height (nth 0 windows)) winsum))))
2196 (if (not (zerop (nth 1 windows)))
2197 (setq subheight (max window-min-height
2198 (/ (* height (nth 1 windows)) winsum))))
2199 (if (not (zerop (nth 2 windows)))
2200 (setq artheight (max window-min-height
2201 (/ (* height (nth 2 windows)) winsum))))
2202 (setq height (+ grpheight subheight artheight))
2203 (enlarge-window (max 0 (- height (window-height (selected-window)))))
2204 ;; Then split the window.
2205 (and (not (zerop artheight))
2206 (or (not (zerop grpheight))
2207 (not (zerop subheight)))
2208 (split-window-vertically (+ grpheight subheight)))
2209 (and (not (zerop grpheight))
2210 (not (zerop subheight))
2211 (split-window-vertically grpheight))
2212 ;; Then select buffers in each window.
2213 (or (zerop grpheight)
2215 (switch-to-buffer gnus-group-buffer 'norecord)
2217 (or (zerop subheight)
2219 (switch-to-buffer gnus-summary-buffer 'norecord)
2221 (or (zerop artheight)
2223 ;; If article buffer does not exist, it will be created
2225 (gnus-article-setup-buffer)
2226 (switch-to-buffer gnus-article-buffer 'norecord)
2227 (setq buffer-read-only t) ; !!! Why!?!
2228 (bury-buffer gnus-summary-buffer)
2229 (bury-buffer gnus-group-buffer)))
2230 (or (zerop subheight)
2232 (pop-to-buffer gnus-summary-buffer)
2233 ;; It seems that some code in this function will set
2234 ;; buffer-read-only to nil. I have absolutely no idea
2236 (setq buffer-read-only t))))))) ; !!! Why!?!
2238 (defun gnus-window-configuration-split (action)
2239 (switch-to-buffer gnus-group-buffer t)
2240 (delete-other-windows)
2241 (split-window-horizontally)
2242 (cond ((or (eq action 'newsgoups) (eq action 'summary))
2243 (if (and (get-buffer gnus-summary-buffer)
2244 (buffer-name gnus-summary-buffer))
2245 (switch-to-buffer-other-window gnus-summary-buffer)))
2246 ((eq action 'article)
2247 (switch-to-buffer gnus-summary-buffer t)
2249 (gnus-article-setup-buffer)
2250 (switch-to-buffer gnus-article-buffer t))))
2252 (defun gnus-version ()
2253 "Version numbers of this version of Gnus."
2255 (let ((methods gnus-valid-select-methods)
2258 ;; Go through all the legal select methods and add their version
2259 ;; numbers to the total version string. Only the backends that are
2260 ;; currently in use will have their message numbers taken into
2263 (setq meth (intern (concat (car (car methods)) "-version")))
2265 (stringp (symbol-value meth))
2266 (setq mess (concat mess "; " (symbol-value meth))))
2267 (setq methods (cdr methods)))
2270 (defun gnus-info-find-node ()
2271 "Find Info documentation of Gnus."
2273 ;; Enlarge info window if needed.
2274 (cond ((eq major-mode 'gnus-group-mode)
2275 (gnus-configure-windows '(1 0 0)) ;Take all windows.
2276 (pop-to-buffer gnus-group-buffer))
2277 ((eq major-mode 'gnus-summary-mode)
2278 (gnus-configure-windows '(0 1 0)) ;Take all windows.
2279 (pop-to-buffer gnus-summary-buffer)))
2280 (Info-goto-node (car (cdr (assq major-mode gnus-info-nodes)))))
2283 "Send a bug report to the Gnus maintainers."
2285 (pop-to-buffer "*Gnus Bug*")
2287 (mail-setup gnus-maintainer "[Gnus Bug Report] " nil nil nil nil)
2288 (goto-char (point-min))
2289 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
2291 (insert (format "%s\n%s\n\n" (gnus-version) (emacs-version)))
2296 (defun gnus-debug ()
2297 "Attemps to go through the Gnus source file and report what variables have been changed.
2298 The source file has to be in the Emacs load path."
2300 (let ((dirs load-path)
2303 (if (file-exists-p (setq file (concat (car dirs) "/gnus.el")))
2306 (set-buffer (get-buffer-create "*gnus bug info*"))
2307 (buffer-disable-undo (current-buffer))
2309 (insert-file-contents file)
2310 (goto-char (point-min))
2311 (or (search-forward "\n;; Internal variables" nil t)
2312 (error "Malformed sources"))
2313 (narrow-to-region (point-min) (point))
2314 (goto-char (point-min))
2315 (while (setq expr (condition-case ()
2316 (read (current-buffer)) (error nil)))
2317 (and (eq (car expr) 'defvar)
2318 (stringp (nth 3 expr))
2319 (not (equal (eval (nth 2 expr))
2320 (and (boundp (nth 1 expr))
2321 (symbol-value (nth 1 expr)))))
2322 (setq olist (cons (nth 1 expr) olist))))
2323 (kill-buffer (current-buffer)))
2324 (setq dirs (cdr dirs))))
2326 (insert "(setq " (symbol-name (car olist)) " '"
2327 (prin1-to-string (symbol-value (car olist))) ")\n")
2328 (setq olist (cdr olist)))
2331 (defun gnus-overload-functions (&optional overloads)
2332 "Overload functions specified by optional argument OVERLOADS.
2333 If nothing is specified, use the variable gnus-overload-functions."
2335 (overloads (or overloads gnus-overload-functions)))
2337 (setq defs (car overloads))
2338 (setq overloads (cdr overloads))
2339 ;; Load file before overloading function if necessary. Make
2340 ;; sure we cannot use `require' always.
2341 (and (not (fboundp (car defs)))
2342 (car (cdr (cdr defs)))
2343 (load (car (cdr (cdr defs))) nil 'nomessage))
2344 (fset (car defs) (car (cdr defs))))))
2346 (defun gnus-replace-chars-in-string (string from to)
2347 "Replace characters in STRING from FROM to TO."
2348 (let ((string (substring string 0)) ;Copy string.
2349 (len (length string))
2351 ;; Replace all occurrences of FROM with TO.
2353 (if (= (aref string idx) from)
2354 (aset string idx to))
2355 (setq idx (1+ idx)))
2358 (defun gnus-days-between (date1 date2)
2359 ;; Return the number of days between date1 and date2.
2360 (let ((d1 (mapcar (lambda (s) (and s (string-to-int s)) )
2361 (timezone-parse-date date1)))
2362 (d2 (mapcar (lambda (s) (and s (string-to-int s)) )
2363 (timezone-parse-date date2))))
2364 (- (timezone-absolute-from-gregorian
2365 (nth 1 d1) (nth 2 d1) (car d1))
2366 (timezone-absolute-from-gregorian
2367 (nth 1 d2) (nth 2 d2) (car d2)))))
2369 (defun gnus-day-number (date)
2370 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2371 (timezone-parse-date date))))
2372 (timezone-absolute-from-gregorian
2373 (nth 1 dat) (nth 2 dat) (car dat))))
2375 (defun gnus-file-newer-than (file date)
2376 (let ((fdate (nth 5 (file-attributes file))))
2377 (or (> (car fdate) (car date))
2378 (and (= (car fdate) (car date))
2379 (> (nth 1 fdate) (nth 1 date))))))
2381 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2383 (defun gnus-y-or-n-p (prompt)
2388 (defun gnus-yes-or-no-p (prompt)
2390 (yes-or-no-p prompt)
2393 ;; Return a string of length POS+1 representing NUMber in BASE. The
2394 ;; resulting string will be left padded with zeds.
2395 (defun gnus-number-base-x (num pos base)
2400 (aref "zyxwvutsrqponmlkjihgfedcba9876543210" (/ num (expt base pos))))
2402 (% num (expt base pos)) (1- pos) base))))
2404 ;; Check whether to use long file names.
2405 (defun gnus-use-long-file-name (symbol)
2406 ;; The variable has to be set...
2407 (and gnus-use-long-file-name
2408 ;; If it isn't a list, then we return t.
2409 (or (not (listp gnus-use-long-file-name))
2410 ;; If it is a list, and the list contains `symbol', we
2412 (not (memq symbol gnus-use-long-file-name)))))
2414 ;; List and range functions
2416 (defun gnus-last-element (list)
2417 "Return last element of LIST."
2419 (setq list (cdr list)))
2422 (defun gnus-copy-sequence (list)
2423 "Do a complete, total copy of a list."
2424 (if (and (consp list) (not (consp (cdr list))))
2425 (cons (car list) (cdr list))
2426 (mapcar (lambda (elem) (if (consp elem)
2427 (if (consp (cdr elem))
2428 (gnus-copy-sequence elem)
2429 (cons (car elem) (cdr elem)))
2433 (defun gnus-set-difference (list1 list2)
2434 "Return a list of elements of LIST1 that do not appear in LIST2."
2435 (let ((list1 (copy-sequence list1)))
2437 (setq list1 (delq (car list2) list1))
2438 (setq list2 (cdr list2)))
2441 (defun gnus-sorted-complement (list1 list2)
2442 "Return a list of elements of LIST1 that do not appear in LIST2.
2443 Both lists have to be sorted over <."
2445 (while (and list1 list2)
2446 (cond ((= (car list1) (car list2))
2447 (setq list1 (cdr list1)
2449 ((< (car list1) (car list2))
2450 (setq out (cons (car list1) out))
2451 (setq list1 (cdr list1)))
2453 (setq out (cons (car list2) out))
2454 (setq list2 (cdr list2)))))
2455 (nreverse (append (or list1 list2) out))))
2457 (defun gnus-intersection (list1 list2)
2460 (if (memq (car list2) list1)
2461 (setq result (cons (car list2) result)))
2462 (setq list2 (cdr list2)))
2465 (defun gnus-sorted-intersection (list1 list2)
2466 ;; LIST1 and LIST2 have to be sorted over <.
2468 (while (and list1 list2)
2469 (cond ((= (car list1) (car list2))
2470 (setq out (cons (car list1) out)
2473 ((< (car list1) (car list2))
2474 (setq list1 (cdr list1)))
2476 (setq list2 (cdr list2)))))
2479 (defun gnus-set-sorted-intersection (list1 list2)
2480 ;; LIST1 and LIST2 have to be sorted over <.
2481 ;; This function modifies LIST1.
2482 (let* ((top (cons nil list1))
2484 (while (and list1 list2)
2485 (cond ((= (car list1) (car list2))
2489 ((< (car list1) (car list2))
2490 (setcdr prev (cdr list1))
2491 (setq list1 (cdr list1)))
2493 (setq list2 (cdr list2)))))
2497 (defun gnus-compress-sequence (numbers &optional always-list)
2498 "Convert list of numbers to a list of ranges or a single range.
2499 If ALWAYS-LIST is non-nil, this function will always release a list of
2501 (let* ((first (car numbers))
2502 (last (car numbers))
2506 (if (not (listp (cdr numbers)))
2509 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2510 ((= (1+ last) (car numbers)) ;Still in sequence
2511 (setq last (car numbers)))
2512 (t ;End of one sequence
2514 (cons (if (= first last) first (cons first last)) result))
2515 (setq first (car numbers))
2516 (setq last (car numbers))))
2517 (setq numbers (cdr numbers)))
2518 (if (and (not always-list) (null result))
2519 (if (= first last) first (cons first last))
2520 (nreverse (cons (if (= first last) first (cons first last))
2523 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2524 (defun gnus-uncompress-range (ranges)
2525 "Expand a list of ranges into a list of numbers.
2526 RANGES is either a single range on the form `(num . num)' or a list of
2528 (let (first last result)
2532 ((not (listp (cdr ranges)))
2533 (setq first (car ranges))
2534 (setq last (cdr ranges))
2535 (while (<= first last)
2536 (setq result (cons first result))
2537 (setq first (1+ first)))
2541 (if (atom (car ranges))
2542 (if (numberp (car ranges))
2543 (setq result (cons (car ranges) result)))
2544 (setq first (car (car ranges)))
2545 (setq last (cdr (car ranges)))
2546 (while (<= first last)
2547 (setq result (cons first result))
2548 (setq first (1+ first))))
2549 (setq ranges (cdr ranges)))
2550 (nreverse result)))))
2552 (defun gnus-add-to-range (ranges list)
2553 "Return a list of ranges that has all articles from both RANGES and LIST.
2554 Note: LIST has to be sorted over `<'."
2556 (gnus-compress-sequence list t)
2557 (setq list (copy-sequence list))
2558 (or (listp (cdr ranges))
2559 (setq ranges (list ranges)))
2561 ilist lowest highest temp)
2562 (while (and ranges list)
2564 (setq lowest (or (and (atom (car ranges)) (car ranges))
2565 (car (car ranges))))
2566 (while (and list (cdr list) (< (car (cdr list)) lowest))
2567 (setq list (cdr list)))
2568 (if (< (car ilist) lowest)
2571 (setq list (cdr list))
2573 (setq out (nconc (gnus-compress-sequence ilist t) out))))
2574 (setq highest (or (and (atom (car ranges)) (car ranges))
2575 (cdr (car ranges))))
2576 (while (and list (<= (car list) highest))
2577 (setq list (cdr list)))
2578 (setq ranges (cdr ranges)))
2580 (setq out (nconc (gnus-compress-sequence list t) out)))
2581 (setq out (sort out (lambda (r1 r2)
2582 (< (or (and (atom r1) r1) (car r1))
2583 (or (and (atom r2) r2) (car r2))))))
2586 (if (atom (car ranges))
2588 (if (atom (car (cdr ranges)))
2589 (if (= (1+ (car ranges)) (car (cdr ranges)))
2591 (setcar ranges (cons (car ranges)
2592 (car (cdr ranges))))
2593 (setcdr ranges (cdr (cdr ranges)))))
2594 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
2596 (setcar (car (cdr ranges)) (car ranges))
2597 (setcar ranges (car (cdr ranges)))
2598 (setcdr ranges (cdr (cdr ranges)))))))
2600 (if (atom (car (cdr ranges)))
2601 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
2603 (setcdr (car ranges) (car (cdr ranges)))
2604 (setcdr ranges (cdr (cdr ranges)))))
2605 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
2607 (setcdr (car ranges) (cdr (car (cdr ranges))))
2608 (setcdr ranges (cdr (cdr ranges))))))))
2609 (setq ranges (cdr ranges)))
2612 (defun gnus-add-to-range-new (ranges list)
2613 (gnus-compress-sequence
2614 (sort (nconc (gnus-uncompress-range ranges) list) '<)))
2616 (defun gnus-add-to-range-old (ranges list)
2617 "Return a list of ranges that has all articles from both RANGES and LIST.
2618 Note: LIST has to be sorted over `<'."
2619 (let* ((ranges (if (and ranges (not (listp (cdr ranges))))
2620 (list ranges) ranges))
2623 range nranges first last)
2627 (gnus-compress-sequence list t)
2629 (> (car (car ranges)) 1)
2632 (setq inrange (setq ranges (cons (cons 1 1) ranges)))))
2633 (while (and ranges list)
2634 (setq range (car ranges))
2635 (while (and list (>= (car list) (car range))
2636 (<= (car list) (cdr range)))
2637 (setq list (cdr list)))
2638 (while (and list (= (1- (car list)) (cdr range)))
2639 (setcdr range (car list))
2640 (setq list (cdr list)))
2641 (if (and list (and (> (car list) (cdr range))
2643 (< (car list) (car (car (cdr ranges))))))
2644 (setcdr ranges (cons (cons (car list) (car list)) (cdr ranges))))
2645 (setq ranges (cdr ranges)))
2646 (if (and list (not ranges))
2647 (setq inrange (nconc inrange (gnus-compress-sequence list t))))
2649 (if (eq (cdr (car inrange)) 1)
2650 (setq inrange (cdr inrange))
2651 (setcar (car inrange) 2)))
2652 (setq ranges inrange)
2654 (if (and (cdr ranges) (>= (1+ (cdr (car ranges)))
2655 (car (car (cdr ranges)))))
2657 (setcdr (car ranges) (cdr (car (cdr ranges))))
2658 (setcdr ranges (cdr (cdr ranges))))
2659 (setq ranges (cdr ranges))))
2660 (if (not (cdr inrange))
2664 (defun gnus-remove-from-range (ranges list)
2665 "Return a list of ranges that has all articles from LIST removed from RANGES.
2666 Note: LIST has to be sorted over `<'."
2667 ;; !!! This function shouldn't look like this, but I've got a headache.
2668 (gnus-compress-sequence
2669 (gnus-sorted-complement
2670 (gnus-uncompress-range ranges) list)))
2672 (defun gnus-member-of-range (number ranges)
2673 (if (not (listp (cdr ranges)))
2674 (and (>= number (car ranges))
2675 (<= number (cdr ranges)))
2678 (if (numberp (car ranges))
2679 (>= number (car ranges))
2680 (>= number (car (car ranges))))
2682 (if (if (numberp (car ranges))
2683 (= number (car ranges))
2684 (and (>= number (car (car ranges)))
2685 (<= number (cdr (car ranges)))))
2686 (setq not-stop nil))
2687 (setq ranges (cdr ranges)))
2695 (defvar gnus-group-mode-map nil)
2696 (defvar gnus-group-make-map nil)
2697 (defvar gnus-group-list-map nil)
2698 (defvar gnus-group-sub-map nil)
2699 (put 'gnus-group-mode 'mode-class 'special)
2701 (if gnus-group-mode-map
2703 (setq gnus-group-mode-map (make-keymap))
2704 (suppress-keymap gnus-group-mode-map)
2705 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
2706 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
2707 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
2708 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
2709 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
2710 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
2711 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
2712 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
2713 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
2714 (define-key gnus-group-mode-map "\M-n" 'gnus-group-next-unread-group-same-level)
2715 (define-key gnus-group-mode-map "\M-p" 'gnus-group-prev-unread-group-same-level)
2716 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
2717 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
2718 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
2719 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
2720 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
2721 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
2722 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
2723 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
2724 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
2725 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
2726 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
2727 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
2728 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
2729 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
2730 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
2731 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
2732 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
2733 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
2734 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
2735 (define-key gnus-group-mode-map "\C-c\M-C-a" 'gnus-group-description-apropos)
2736 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
2737 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
2738 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
2739 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
2740 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
2741 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
2742 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
2743 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
2744 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
2745 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
2746 (define-key gnus-group-mode-map "V" 'gnus-version)
2747 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
2748 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
2749 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
2750 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
2751 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
2752 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
2753 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
2754 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
2755 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group)
2756 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
2757 (define-key gnus-group-mode-map
2758 (if gnus-xemacs [button2] [mouse-2]) 'gnus-mouse-pick-group)
2760 (define-prefix-command 'gnus-group-make-map)
2761 (define-key gnus-group-mode-map "M" 'gnus-group-make-map)
2762 (define-key gnus-group-make-map "d" 'gnus-group-make-directory-group)
2763 (define-key gnus-group-make-map "h" 'gnus-group-make-help-group)
2764 (define-key gnus-group-make-map "a" 'gnus-group-make-archive-group)
2765 (define-key gnus-group-make-map "k" 'gnus-group-make-kiboze-group)
2766 (define-key gnus-group-make-map "m" 'gnus-group-make-group)
2767 (define-key gnus-group-make-map "e" 'gnus-group-edit-group)
2769 (define-prefix-command 'gnus-group-list-map)
2770 (define-key gnus-group-mode-map "G" 'gnus-group-list-map)
2771 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
2772 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
2773 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
2774 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
2775 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
2776 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
2777 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
2778 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
2780 (define-prefix-command 'gnus-group-sub-map)
2781 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
2782 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
2783 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
2784 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
2785 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
2786 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
2787 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
2788 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
2790 (defun gnus-group-mode ()
2791 "Major mode for reading news.
2793 All normal editing commands are switched off.
2794 \\<gnus-group-mode-map>
2795 The group buffer lists (some of) the groups available. For instance,
2796 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
2797 lists all zombie groups.
2799 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
2800 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
2802 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
2804 The following commands are available:
2806 \\{gnus-group-mode-map}"
2808 (if gnus-visual (gnus-group-make-menu-bar))
2809 (kill-all-local-variables)
2810 (setq mode-line-modified "-- ")
2811 (make-local-variable 'mode-line-format)
2812 (setq mode-line-format (copy-sequence mode-line-format))
2813 (and (equal (nth 3 mode-line-format) " ")
2814 (setcar (nthcdr 3 mode-line-format) ""))
2815 (setq major-mode 'gnus-group-mode)
2816 (setq mode-name "Group")
2817 (gnus-group-set-mode-line)
2818 (setq mode-line-process nil)
2819 (use-local-map gnus-group-mode-map)
2820 (buffer-disable-undo (current-buffer))
2821 (setq truncate-lines t)
2822 (setq buffer-read-only t)
2823 (run-hooks 'gnus-group-mode-hook))
2825 (defun gnus-mouse-pick-group (e)
2828 (gnus-group-read-group nil))
2831 (defun gnus-no-server (&optional arg)
2833 If ARG is a positive number, Gnus will use that as the
2834 startup level. If ARG is nil, Gnus will be started at level 2.
2835 If ARG is non-nil and not a positive number, Gnus will
2836 prompt the user for the name of an NNTP server to use.
2837 As opposed to `gnus', this command will not connect to the local server."
2839 (gnus (or arg 2) t))
2841 (defalias '\(ding\) 'gnus)
2844 (defun gnus (&optional arg dont-connect)
2846 If ARG is non-nil and a positive number, Gnus will use that as the
2847 startup level. If ARG is non-nil and not a positive number, Gnus will
2848 prompt the user for the name of an NNTP server to use."
2850 (if (get-buffer gnus-group-buffer)
2852 (switch-to-buffer gnus-group-buffer)
2853 (gnus-group-get-new-news))
2855 (gnus-read-init-file)
2856 (let ((level (and arg (numberp arg) (> arg 0) arg))
2860 (switch-to-buffer (get-buffer-create gnus-group-buffer))
2861 (gnus-add-current-to-buffer-list)
2865 (gnus-start-news-server (and arg (not level))))))
2866 (if (and (not dont-connect)
2869 (run-hooks 'gnus-startup-hook)
2870 ;; NNTP server is successfully open.
2871 (gnus-update-format-specifications)
2872 (let ((buffer-read-only nil))
2874 (if (not gnus-inhibit-startup-message)
2876 (gnus-group-startup-message)
2878 (gnus-setup-news nil level)
2879 (and gnus-use-dribble-file (gnus-dribble-open))
2880 (or t (not gnus-novice-user)
2882 (gnus-group-describe-briefly)) ;Show brief help message.
2883 (gnus-group-list-groups level))))))
2885 (defun gnus-group-startup-message (&optional x y)
2886 "Insert startup message in current buffer."
2887 ;; Insert the message.
2904 ;; And then hack it.
2905 ;; 18 is the longest line.
2906 (indent-rigidly (point-min) (point-max)
2907 (/ (max (- (window-width) (or x 28)) 0) 2))
2908 (goto-char (point-min))
2909 ;; +4 is fuzzy factor.
2910 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2)))
2912 (defun gnus-group-setup-buffer ()
2913 (or (get-buffer gnus-group-buffer)
2915 (switch-to-buffer (get-buffer-create gnus-group-buffer))
2916 (gnus-add-current-to-buffer-list)
2917 (gnus-group-mode))))
2919 (defun gnus-group-list-groups (level &optional unread)
2920 "List newsgroups with level LEVEL or lower that have unread alticles.
2921 Default is 5, which lists all subscribed groups.
2922 If argument UNREAD is non-nil, groups with no unread articles are also listed."
2924 (setq level (or level gnus-group-default-list-level 5))
2925 (gnus-group-setup-buffer) ;May call from out of group buffer
2926 (let ((case-fold-search nil)
2927 (group (gnus-group-group-name)))
2928 (funcall gnus-group-prepare-function level unread nil)
2929 (if (zerop (buffer-size))
2930 (message gnus-no-groups-message)
2931 (goto-char (point-min))
2933 ;; Go to the first group with unread articles.
2934 (gnus-group-search-forward nil nil nil t)
2935 ;; Find the right group to put point on. If the current group
2936 ;; has disapeared in the new listing, try to find the next
2937 ;; one. If no next one can be found, just leave point at the
2938 ;; first newsgroup in the buffer.
2939 (if (not (gnus-goto-char
2940 (text-property-any (point-min) (point-max)
2941 'gnus-group (intern group))))
2942 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
2944 (not (gnus-goto-char
2946 (point-min) (point-max) 'gnus-group
2947 (intern (car (car newsrc)))))))
2948 (setq newsrc (cdr newsrc)))
2949 (or newsrc (progn (goto-char (point-max))
2950 (forward-line -1))))))
2951 ;; Adjust cursor point.
2952 (gnus-group-position-cursor))))
2954 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
2955 "List all newsgroups with unread articles of level LEVEL or lower.
2956 If ALL is non-nil, list groups that have no unread articles.
2957 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
2958 If REGEXP, only list groups matching REGEXP."
2959 (set-buffer gnus-group-buffer)
2960 (let ((buffer-read-only nil)
2961 (newsrc (cdr gnus-newsrc-assoc))
2962 (lowest (or lowest 1))
2963 info clevel unread group)
2966 ;; List living groups.
2968 (setq info (car newsrc)
2971 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
2972 (and unread ; This group might be bogus
2974 (string-match regexp group))
2975 (<= (setq clevel (car (cdr info))) level)
2977 (or all ; We list all groups?
2978 (eq unread t) ; We list unactivated groups
2979 (> unread 0) ; We list groups with unread articles
2980 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
2981 (gnus-group-insert-group-line
2982 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
2984 ;; List dead groups.
2985 (and (>= level 8) (<= lowest 8)
2986 (gnus-group-prepare-flat-list-dead
2987 (setq gnus-zombie-list (sort gnus-zombie-list 'string<)) 8 ?Z
2989 (and (>= level 9) (<= lowest 9)
2990 (gnus-group-prepare-flat-list-dead
2991 (setq gnus-killed-list (sort gnus-killed-list 'string<)) 9 ?K
2994 (gnus-group-set-mode-line)
2995 (setq gnus-have-all-newsgroups all)
2996 (run-hooks 'gnus-group-prepare-hook)))
2998 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
2999 ;; List zombies and killed lists somehwat faster, which was
3000 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3001 ;; this by ignoring the group format specification altogether.
3004 (setq group (car groups)
3005 groups (cdr groups))
3006 (if (or (not regexp)
3007 (string-match regexp group))
3010 (insert (format " %c *: %s\n" mark group))
3011 (add-text-properties
3013 (list 'gnus-group (intern group)
3015 'gnus-level level)))))))
3017 (defun gnus-group-real-name (group)
3018 "Find the real name of a foreign newsgroup."
3019 (if (string-match "^[^:]+:" group)
3020 (substring group (match-end 0))
3023 (defun gnus-group-prefixed-name (group method)
3024 "Return the whole name from GROUP and METHOD."
3025 (and (stringp method) (setq method (gnus-server-to-method method)))
3026 (concat (format "%s" (car method))
3028 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3029 (not (string= (nth 1 method) "")))
3030 (concat "+" (nth 1 method)))
3033 (defun gnus-group-real-prefix (group)
3034 "Return the prefix of the current group name."
3035 (if (string-match "^[^:]+:" group)
3036 (substring group 0 (match-end 0))
3039 (defun gnus-group-method-name (group)
3040 "Return the method used for selecting GROUP."
3041 (let ((prefix (gnus-group-real-prefix group)))
3042 (if (equal prefix "")
3044 (if (string-match "^[^\\+]+\\+" prefix)
3045 (list (intern (substring prefix 0 (1- (match-end 0))))
3046 (substring prefix (match-end 0) (1- (length prefix))))
3047 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3049 (defun gnus-group-foreign-p (group)
3050 "Return nil if GROUP is native, non-nil if it is foreign."
3051 (string-match ":" group))
3053 (defun gnus-group-set-info (info)
3054 (let ((entry (gnus-gethash (car info) gnus-newsrc-hashtb)))
3056 (if (not (setq marked (nth 3 info)))
3059 (or (eq 'score (car (car marked)))
3060 (eq 'bookmark (car (car marked)))
3061 (eq 'killed (car (car marked)))
3062 (setcdr (car marked)
3063 (gnus-uncompress-range (cdr (car marked)))))
3064 (setq marked (cdr marked)))))
3068 (set-buffer gnus-group-buffer)
3070 (gnus-group-make-group
3071 (gnus-group-real-name (car info))
3072 (prin1-to-string (car (nth 4 info)))
3073 (nth 1 (nth 4 info)))
3074 (gnus-group-make-group
3076 (prin1-to-string (car gnus-select-method))
3077 (nth 1 gnus-select-method)))
3078 (message "Note: New group created")
3080 (gnus-gethash (gnus-group-prefixed-name
3081 (gnus-group-real-name (car info))
3082 (or (nth 4 info) gnus-select-method))
3083 gnus-newsrc-hashtb))))
3086 (setcar (nthcdr 2 entry) info)
3087 (if (and (not (eq (car entry) t))
3088 (gnus-gethash (car info) gnus-active-hashtb))
3089 (let ((marked (nth 3 info)))
3091 (max 0 (- (length (gnus-list-of-unread-articles
3093 (length (cdr (assq 'tick marked)))
3094 (length (cdr (assq 'dormant marked)))))))))
3095 (error "No such group: %s" (car info)))))
3097 (defun gnus-group-update-group-line ()
3098 "This function updates the current line in the newsgroup buffer and
3099 moves the point to the colon."
3100 (let* ((buffer-read-only nil)
3101 (group (gnus-group-group-name))
3102 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3105 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3108 (delete-region (point) (save-excursion (forward-line 1) (point)))
3109 (gnus-group-insert-group-line-info group)
3111 (gnus-group-position-cursor)))
3113 (defun gnus-group-insert-group-line-info (group)
3114 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3118 (setq info (nth 2 entry))
3119 (gnus-group-insert-group-line
3120 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3121 (setq active (gnus-gethash group gnus-active-hashtb))
3122 (gnus-group-insert-group-line
3123 nil group (if (member group gnus-zombie-list) 8 9)
3124 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3126 (defun gnus-group-insert-group-line (gformat group level marked number method)
3127 (let* ((gformat (or gformat gnus-group-line-format-spec))
3128 (active (gnus-gethash group gnus-active-hashtb))
3129 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3130 (number-of-dormant (length (cdr (assq 'dormant marked))))
3131 (number-of-ticked (length (cdr (assq 'tick marked))))
3132 (number-of-ticked-and-dormant
3133 (+ number-of-ticked number-of-dormant))
3134 (number-of-unread-unticked
3135 (if (numberp number) (int-to-string (max 0 number))
3138 (if (numberp number)
3139 (max 0 (- number-total number))
3141 (subscribed (cond ((< level 6) ? )
3145 (qualified-group (gnus-group-real-name group))
3146 (newsgroup-description
3147 (if gnus-description-hashtb
3148 (or (gnus-gethash group gnus-description-hashtb) "")
3150 (moderated (if (member group gnus-moderated-list) ?m ? ))
3151 (moderated-string (if (eq moderated ?m) "(m)" ""))
3152 (method (gnus-server-get-method group method))
3153 (news-server (or (car (cdr method)) ""))
3154 (news-method (or (car method) ""))
3156 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3160 (> number-of-ticked 0))
3162 (number (if (eq number t) "*" (+ number number-of-dormant
3164 (buffer-read-only nil)
3169 (insert (eval gformat))
3171 (add-text-properties
3172 b (1+ b) (list 'gnus-group (intern group)
3173 'gnus-unread (if (numberp number)
3174 (string-to-int number-of-unread-unticked)
3177 'gnus-level level))))
3179 (defun gnus-group-update-group (group &optional visible-only)
3180 "Update newsgroup info of GROUP.
3181 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3183 (set-buffer gnus-group-buffer)
3184 (let ((buffer-read-only nil)
3186 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3189 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3191 ;; Buffer may be narrowed.
3194 ;; Search a line to modify. If the buffer is large, the search
3195 ;; takes long time. In most cases, current point is on the line
3196 ;; we are looking for. So, first of all, check current line.
3199 (eq (get-text-property (point) 'gnus-group)
3204 (point-min) (point-max) 'gnus-group (intern group)))))
3205 ;; GROUP is listed in current buffer. So, delete old line.
3209 (delete-region (point) (progn (forward-line 1) (point))))
3210 ;; No such line in the buffer, find out where it's supposed to
3211 ;; go, and insert it there (or at the end of the buffer).
3212 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3214 (let ((entry (cdr (gnus-gethash group gnus-newsrc-hashtb))))
3219 (point-min) (point-max)
3220 'gnus-group (intern (car (car entry)))))))
3221 (setq entry (cdr entry)))
3222 (or entry (goto-char (point-max)))))))
3223 (if (or visible (not visible-only))
3224 (gnus-group-insert-group-line-info group))
3225 (gnus-group-set-mode-line))))
3227 (defun gnus-group-set-mode-line ()
3228 (if (memq 'group gnus-updated-mode-lines)
3229 (let* ((gformat (or gnus-group-mode-line-format-spec
3230 (setq gnus-group-mode-line-format-spec
3232 gnus-group-mode-line-format
3233 gnus-group-mode-line-format-alist))))
3234 (news-server (car (cdr gnus-select-method)))
3235 (news-method (car gnus-select-method))
3236 (mode-string (eval gformat))
3238 (if (> (length mode-string) max-len)
3239 (setq mode-string (substring mode-string 0 (- max-len 4))))
3240 (setq mode-line-buffer-identification mode-string)
3241 (set-buffer-modified-p t))))
3243 (defun gnus-group-group-name ()
3244 "Get the name of the newsgroup on the current line."
3245 (let ((group (get-text-property
3246 (save-excursion (beginning-of-line) (point)) 'gnus-group)))
3247 (and group (symbol-name group))))
3249 (defun gnus-group-group-level ()
3250 "Get the level of the newsgroup on the current line."
3251 (get-text-property (save-excursion (beginning-of-line) (point)) 'gnus-level))
3253 (defun gnus-group-search-forward (&optional backward all level first-too)
3254 "Find the next newsgroup with unread articles.
3255 If BACKWARD is non-nil, find the previous newsgroup instead.
3256 If ALL is non-nil, just find any newsgroup.
3257 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3259 If FIRST-TOO, the current line is also eligeble as a target."
3260 (let ((way (if backward -1 1))
3264 (or first-too (forward-line way))
3272 (get-text-property (point) 'gnus-unread)))
3273 (or (eq unread t) (and unread (> unread 0))))
3274 (let ((lev (get-text-property (point) 'gnus-level)))
3275 (and lev (< (get-text-property (point) 'gnus-level) 6)))))
3277 (let ((lev (get-text-property (point) 'gnus-level)))
3278 (if (and lev (<= lev level))
3283 (setq pos (point))))
3285 (zerop (forward-line way))))
3287 (progn (gnus-group-position-cursor) t)
3288 (if pos (goto-char pos) (goto-char beg))
3291 ;; Gnus group mode commands
3293 (defun gnus-group-read-group (all &optional no-article group)
3294 "Read news in this newsgroup.
3295 If argument ALL is non-nil, already read articles become readable.
3296 If optional argument NO-ARTICLE is non-nil, no article body is displayed."
3298 (let ((group (or group (gnus-group-group-name)))
3299 number active marked entry)
3300 (or group (error "No group on current line"))
3302 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3303 ;; This group might be a dead group. In that case we have to get
3304 ;; the number of unread articles from `gnus-active-hashtb'.
3306 (setq number (car entry))
3307 (if (setq active (gnus-gethash group gnus-active-hashtb))
3308 (setq number (- (1+ (cdr active)) (car active)))))
3309 (gnus-summary-read-group
3310 group (or all (and (numberp number)
3311 (zerop (+ number (length (cdr (assq 'tick marked)))
3312 (length (cdr (assq 'dormant marked)))))))
3315 (defun gnus-group-select-group (all)
3316 "Select this newsgroup.
3317 No article is selected automatically.
3318 If argument ALL is non-nil, already read articles become readable."
3320 (gnus-group-read-group all t))
3322 (defun gnus-group-jump-to-group (group)
3323 "Jump to newsgroup GROUP."
3324 (interactive (list (completing-read "Group: " gnus-active-hashtb nil
3325 (not (not gnus-read-active-file)))))
3327 (if (equal group "")
3328 (error "empty group name"))
3330 (let ((b (text-property-any (point-min) (point-max)
3331 'gnus-group (intern group))))
3333 ;; Either go to the line in the group buffer...
3335 ;; ... or insert the line.
3337 (gnus-gethash group gnus-active-hashtb)
3338 (gnus-activate-newsgroup group)
3339 (error "%s error: %s" group (gnus-status-message group)))
3341 (gnus-group-update-group group)
3342 (goto-char (text-property-any (point-min) (point-max)
3343 'gnus-group (intern group)))))
3344 ;; Adjust cursor point.
3345 (gnus-group-position-cursor))
3347 (defun gnus-group-next-group (n)
3348 "Go to next N'th newsgroup.
3349 If N is negative, search backward instead.
3350 Returns the difference between N and the number of skips actually
3353 (gnus-group-next-unread-group n t))
3355 (defun gnus-group-next-unread-group (n &optional all level)
3356 "Go to next N'th unread newsgroup.
3357 If N is negative, search backward instead.
3358 If ALL is non-nil, choose any newsgroup, unread or not.
3359 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
3360 such group can be found, the next group with a level higher than
3362 Returns the difference between N and the number of skips actually
3365 (let ((backward (< n 0))
3368 (gnus-group-search-forward backward all level))
3370 (if (/= 0 n) (message "No more%s newsgroups%s" (if all "" " unread")
3371 (if level " on this level or higher" "")))
3374 (defun gnus-group-prev-group (n)
3375 "Go to previous N'th newsgroup.
3376 Returns the difference between N and the number of skips actually
3379 (gnus-group-next-unread-group (- n) t))
3381 (defun gnus-group-prev-unread-group (n)
3382 "Go to previous N'th unread newsgroup.
3383 Returns the difference between N and the number of skips actually
3386 (gnus-group-next-unread-group (- n)))
3388 (defun gnus-group-next-unread-group-same-level (n)
3389 "Go to next N'th unread newsgroup on the same level.
3390 If N is negative, search backward instead.
3391 Returns the difference between N and the number of skips actually
3394 (gnus-group-next-unread-group n t (gnus-group-group-level))
3395 (gnus-group-position-cursor))
3397 (defun gnus-group-prev-unread-group-same-level (n)
3398 "Go to next N'th unread newsgroup on the same level.
3399 Returns the difference between N and the number of skips actually
3402 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
3403 (gnus-group-position-cursor))
3405 (defun gnus-group-best-unread-group (&optional exclude-group)
3406 "Go to the group with the highest level.
3407 If EXCLUDE-GROUP, do not go to that group."
3409 (goto-char (point-min))
3412 (while (setq unread (get-text-property (point) 'gnus-unread))
3413 (if (and (numberp unread) (> unread 0))
3415 (or best-point (setq best-point (point)))
3416 (if (and (< (get-text-property (point) 'gnus-level) best)
3417 (or (not exclude-group)
3418 (not (equal exclude-group (gnus-group-group-name)))))
3420 (setq best (get-text-property (point) 'gnus-level))
3421 (setq best-point (point))))))
3423 (if best-point (goto-char best-point))
3424 (gnus-summary-position-cursor)
3425 (and best-point (gnus-group-group-name))))
3427 (defun gnus-group-first-unread-group ()
3428 "Go to the first group with unread articles."
3430 (goto-char (point-min))
3431 (gnus-group-next-unread-group 1))
3433 (defun gnus-group-enter-server-mode ()
3434 "Jump to the server buffer."
3436 (gnus-server-setup-buffer)
3437 (switch-to-buffer gnus-server-buffer)
3438 (gnus-server-prepare))
3440 (defun gnus-group-make-group (name method address)
3441 "Add a new newsgroup.
3442 The user will be prompted for a NAME, for a select METHOD, and an
3446 (read-string "Group name: ")
3449 "Method: " (append gnus-valid-select-methods gnus-server-alist)
3451 (if (assoc method gnus-valid-select-methods)
3453 (if (memq 'prompt-address
3454 (assoc method gnus-valid-select-methods))
3455 (read-string "Address: ")
3457 (list method nil)))))
3459 (let* ((meth (if address (list (intern method) address) method))
3460 (nname (gnus-group-prefixed-name name meth))
3462 (and (gnus-gethash nname gnus-active-hashtb)
3463 (error "Group %s already exists" nname))
3464 (gnus-group-change-level
3465 (setq info (list t nname 3 nil nil meth))
3466 3 9 (gnus-gethash (or (gnus-group-group-name) "dummy.group")
3467 gnus-newsrc-hashtb) t)
3468 (gnus-sethash nname '(0 . 0) gnus-active-hashtb)
3470 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
3471 (gnus-group-insert-group-line-info nname)
3473 (and (gnus-check-backend-function 'request-create-group nname)
3474 (gnus-request-create-group nname))))
3476 (defun gnus-group-edit-group (group)
3477 "Edit the group on the current line."
3478 (interactive (list (gnus-group-group-name)))
3480 (if group (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
3481 (error "No group on current line"))
3482 (setq gnus-winconf-edit-group (current-window-configuration))
3483 (pop-to-buffer (get-buffer-create gnus-group-edit-buffer))
3484 (gnus-add-current-to-buffer-list)
3486 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3487 (use-local-map (copy-keymap emacs-lisp-mode-map))
3488 (local-set-key "\C-c\C-c" 'gnus-group-edit-group-done)
3490 (insert ";; Type `C-c C-c' after you have edited the newsgroup entry.\n\n")
3491 (let ((cinfo (gnus-copy-sequence info))
3493 (if (not (setq marked (nth 3 cinfo)))
3496 (or (eq 'score (car (car marked)))
3497 (eq 'bookmark (car (car marked)))
3498 (eq 'killed (car (car marked)))
3499 (setcdr (car marked)
3500 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
3501 (setq marked (cdr marked))))
3502 (insert (pp-to-string (list 'gnus-group-set-info
3503 (list 'quote cinfo)))))))
3505 (defun gnus-group-edit-group-done ()
3507 (set-buffer (get-buffer-create gnus-group-edit-buffer))
3508 (eval-current-buffer)
3509 (kill-buffer (current-buffer))
3510 (and gnus-winconf-edit-group
3511 (set-window-configuration gnus-winconf-edit-group))
3512 (setq gnus-winconf-edit-group nil)
3513 (set-buffer gnus-group-buffer)
3514 (gnus-group-update-group (gnus-group-group-name))
3515 (gnus-group-position-cursor))
3517 (defun gnus-group-make-help-group ()
3518 "Create the (ding) Gnus documentation group."
3520 (and (gnus-gethash (gnus-group-prefixed-name "gnus-help" '(nndoc ""))
3522 (error "Documentation group already exists"))
3523 (let ((path load-path))
3525 (not (file-exists-p (concat (file-name-as-directory (car path))
3527 (setq path (cdr path)))
3528 (or path (error "Couldn't find doc group"))
3529 (gnus-group-make-group
3531 (concat (file-name-as-directory (car path)) "doc.txt"))
3532 (gnus-group-position-cursor)))
3534 (defun gnus-group-make-archive-group ()
3535 "Create the (ding) Gnus archive group."
3537 (and (gnus-gethash (gnus-group-prefixed-name "ding.archives" '(nndir ""))
3539 (error "Archive group already exists"))
3540 (gnus-group-make-group "ding.archives" "nndir" gnus-group-archive-directory)
3541 (gnus-group-position-cursor))
3543 (defun gnus-group-make-directory-group (dir)
3544 "Create an nndir group.
3545 The user will be prompted for a directory. The contents of this
3546 directory will be used as a newsgroup. The directory should contain
3547 mail messages or news articles in files that have numeric names."
3549 (list (read-file-name "Create group from directory: ")))
3550 (or (file-exists-p dir) (error "No such directory"))
3551 (or (file-directory-p dir) (error "Not a directory"))
3552 (gnus-group-make-group dir "nndir" dir)
3553 (gnus-group-position-cursor))
3555 (defun gnus-group-make-kiboze-group (group address scores)
3556 "Create an nnkiboze group.
3557 The user will be prompted for a name, a regexp to match groups, and
3558 score file entries for articles to include in the group."
3561 (read-string "nnkiboze group name: ")
3562 (read-string "Source groups (regexp): ")
3563 (let ((headers (mapcar (lambda (group) (list group))
3564 '("subject" "from" "number" "date" "message-id"
3565 "references" "chars" "lines" "xref")))
3566 scores header regexp regexps)
3567 (while (not (equal "" (setq header (completing-read
3568 "Match on header: " headers nil t))))
3570 (while (not (equal "" (setq regexp (read-string
3571 (format "Match on %s (string): "
3573 (setq regexps (cons (list regexp nil 1000 nil) regexps)))
3574 (setq scores (cons (cons header regexps) scores)))
3576 (gnus-group-make-group group "nnkiboze" address)
3578 (set-buffer (get-buffer-create " *gnus work*"))
3579 (buffer-disable-undo (current-buffer))
3580 (let (emacs-lisp-mode-hook)
3581 (pp (list 'setq 'gnus-score-alist
3582 (list 'quote (list scores)))
3584 (write-region (point-min) (point-max)
3585 (concat (or gnus-kill-files-directory "~/News")
3586 "nnkiboze:" group "." gnus-score-file-suffix))
3587 (kill-buffer (current-buffer)))
3588 (gnus-group-position-cursor))
3590 ;; Group sorting commands
3591 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
3593 (defun gnus-group-sort-groups ()
3594 "Sort the group buffer using `gnus-group-sort-function'."
3596 (setq gnus-newsrc-assoc
3597 (sort (cdr gnus-newsrc-assoc) gnus-group-sort-function))
3598 (gnus-make-hashtable-from-newsrc-alist)
3599 (gnus-get-unread-articles 6)
3600 (gnus-group-list-groups nil))
3602 (defun gnus-group-sort-by-alphabet (info1 info2)
3603 (string< (car info1) (car info2)))
3605 (defun gnus-group-sort-by-unread (info1 info2)
3606 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
3607 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
3608 (< (or (and (numberp n1) n1) 0)
3609 (or (and (numberp n2) n2) 0))))
3611 (defun gnus-group-sort-by-level (info1 info2)
3612 (< (nth 1 info1) (nth 1 info2)))
3614 ;; Group catching up.
3616 (defun gnus-group-catchup-current (n &optional all)
3617 "Mark all articles not marked as unread in current newsgroup as read.
3618 If prefix argument N is numeric, the ARG next newsgroups will be
3619 caught up. If ALL is non-nil, marked articles will also be marked as
3620 read. Cross references (Xref: header) of articles are ignored.
3621 The difference between N and actual number of newsgroups that were
3622 caught up is returned."
3624 (if (or (not gnus-interactive-catchup) ;Without confirmation?
3628 "Do you really want to mark all articles as read? "
3629 "Mark all unread articles as read? ")))
3635 (gnus-group-catchup (gnus-group-group-name) all)
3636 (gnus-group-update-group-line)
3638 (zerop (gnus-group-next-unread-group 1))))))
3641 (defun gnus-group-catchup-current-all (n)
3642 "Mark all articles in current newsgroup as read.
3643 Cross references (Xref: header) of articles are ignored."
3645 (gnus-group-catchup-current n 'all))
3647 (defun gnus-group-catchup (group &optional all)
3648 "Mark all articles in GROUP as read.
3649 If ALL is non-nil, all articles are marked as read.
3650 The return value is the number of articles that were marked as read,
3651 or nil if no action could be taken."
3652 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3654 (marked (nth 3 (nth 2 entry)))
3656 (if (not (numberp (car entry)))
3657 (message "Can't catch up; non-active group")
3658 ;; Do the updating only if the newsgroup isn't killed
3661 (setq ticked (if all nil (cdr (assq 'tick marked))))
3662 (gnus-update-read-articles group ticked nil ticked)
3663 (if (and all marked)
3664 (setcar (nthcdr 3 (nth 2 entry))
3665 (delq (assq 'dormant marked) marked))))))
3668 (defun gnus-group-expire-articles (newsgroup)
3669 "Expire all expirable articles in the current newsgroup."
3670 (interactive (list (gnus-group-group-name)))
3671 (if (not newsgroup) (error "No current newsgroup"))
3673 (assq 'expire (nth 3 (nth 2 (gnus-gethash newsgroup
3674 gnus-newsrc-hashtb))))))
3676 (gnus-check-backend-function 'request-expire-articles newsgroup)
3678 (gnus-request-expire-articles (cdr expirable) newsgroup)))))
3680 (defun gnus-group-expire-all-groups ()
3681 "Expire all expirable articles in all newsgroups."
3683 (message "Expiring...")
3684 (let ((newsrc (cdr gnus-newsrc-assoc)))
3686 (gnus-group-expire-articles (car (car newsrc)))
3687 (setq newsrc (cdr newsrc))))
3688 (message "Expiring...done"))
3690 (defun gnus-group-set-current-level (n)
3691 "Set the level of the current group to the numeric prefix."
3693 (setq n (or n (string-to-int
3696 (mapcar (lambda (n) (list (char-to-string n))) "123456789")
3698 (let ((group (gnus-group-group-name)))
3699 (if (not group) (error "No newsgroup on current line.")
3700 (if (and (numberp n) (>= n 1) (<= n 9))
3702 (message "Changed level of %s from %d to %d"
3703 group (gnus-group-group-level) n)
3704 (gnus-group-change-level group n (gnus-group-group-level))
3705 (gnus-group-update-group-line))
3706 (error "Illegal level: %s" n))))
3708 (gnus-group-position-cursor))
3710 (defun gnus-group-unsubscribe-current-group (arg)
3711 "Toggle subscribe from/to unsubscribe current group."
3713 (let ((group (gnus-group-group-name)))
3714 (or group (error "No newsgroup on current line"))
3715 (or arg (setq arg (if (<= (gnus-group-group-level) 5) 6 3)))
3716 (gnus-group-unsubscribe-group group arg)
3717 (gnus-group-next-group 1)))
3719 (defun gnus-group-unsubscribe-group (group &optional level)
3720 "Toggle subscribe from/to unsubscribe GROUP.
3721 New newsgroup is added to .newsrc automatically."
3723 (list (completing-read "Group: " gnus-active-hashtb nil
3724 gnus-have-read-active-file)))
3725 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3727 ;; Toggle subscription flag.
3728 (gnus-group-change-level
3729 newsrc (if level level (if (< (nth 1 (nth 2 newsrc)) 6) 6 4)))
3730 (gnus-group-update-group group))
3731 ((and (stringp group)
3732 (or (not gnus-have-read-active-file)
3733 (gnus-gethash group gnus-active-hashtb)))
3734 ;; Add new newsgroup.
3735 (gnus-group-change-level
3738 (or (and (member group gnus-zombie-list) 8) 9)
3739 (or (and (gnus-group-group-name)
3740 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb))
3741 (gnus-gethash (car (car gnus-newsrc-assoc))
3742 gnus-newsrc-hashtb)))
3743 (gnus-group-update-group group))
3744 (t (error "No such newsgroup: %s" group)))
3745 (gnus-group-position-cursor)))
3747 (defun gnus-group-transpose-groups (arg)
3748 "Exchange current newsgroup and previous newsgroup.
3749 With argument ARG, takes previous newsgroup and moves it past ARG newsgroup."
3751 ;; BUG: last newsgroup and the last but one cannot be transposed
3752 ;; since gnus-group-search-forward does not move forward beyond the
3753 ;; last. If we instead use forward-line, no problem, but I don't
3754 ;; want to use it for later extension.
3756 (gnus-group-search-forward t t)
3757 (gnus-group-kill-group 1)
3758 (gnus-group-search-forward nil t)
3759 (gnus-group-yank-group)
3760 (gnus-group-search-forward nil t)
3761 (setq arg (1- arg))))
3763 (defun gnus-group-kill-all-zombies ()
3764 "Kill all zombie newsgroups."
3766 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3767 (setq gnus-zombie-list nil)
3768 (funcall gnus-group-prepare-function 5 nil nil)
3769 (goto-char (point-min))
3770 (gnus-group-position-cursor))
3772 (defun gnus-group-kill-region (begin end)
3773 "Kill newsgroups in current region (excluding current point).
3774 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3777 ;; Exclude a line where current point is on.
3791 (beginning-of-line) ;Important when LINES < 1
3792 (gnus-group-kill-group lines)))
3794 (defun gnus-group-kill-group (n)
3795 "The the next N groups.
3796 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3797 However, only groups that were alive can be yanked; already killed
3798 groups or zombie groups can't be yanked.
3799 The return value is the name of the (last) newsgroup that was killed."
3801 (let ((buffer-read-only nil)
3803 (while (>= (setq n (1- n)) 0)
3804 (setq group (gnus-group-group-name))
3806 (signal 'end-of-buffer nil))
3807 (setq level (gnus-group-group-level))
3809 (delete-region (point) (progn (forward-line 1) (point)))
3810 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
3811 (setq gnus-list-of-killed-groups
3812 (cons (cons (car entry) (nth 2 entry))
3813 gnus-list-of-killed-groups)))
3814 (gnus-group-change-level (if entry entry group) 9 (if entry nil level)))
3817 (gnus-group-position-cursor)
3820 (defun gnus-group-yank-group (&optional arg)
3821 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
3822 inserting it before the current newsgroup. The numeric ARG specifies
3823 how many newsgroups are to be yanked. The name of the (last)
3824 newsgroup yanked is returned."
3826 (if (not arg) (setq arg 1))
3827 (let (info group prev)
3828 (while (>= (setq arg (1- arg)) 0)
3829 (if (not (setq info (car gnus-list-of-killed-groups)))
3830 (error "No more newsgroups to yank"))
3831 (setq group (nth 2 info))
3832 ;; Find which newsgroup to insert this one before - search
3833 ;; backward until something suitable is found. If there are no
3834 ;; other newsgroups in this buffer, just make this newsgroup the
3836 (while (and (not (setq prev (gnus-group-group-name)))
3837 (zerop (forward-line -1))))
3839 (setq prev (car (car gnus-newsrc-assoc))))
3840 (gnus-group-change-level
3842 (gnus-gethash prev gnus-newsrc-hashtb)
3844 (gnus-group-insert-group-line-info (nth 1 info))
3845 (setq gnus-list-of-killed-groups
3846 (cdr gnus-list-of-killed-groups)))
3848 (gnus-group-position-cursor)
3851 (defun gnus-group-list-all-groups (arg)
3852 "List all newsgroups with level ARG or lower.
3853 Default is 7, which lists all subscribed and most unsubscribed groups."
3855 (setq arg (or arg 7))
3856 (gnus-group-list-groups arg t))
3858 (defun gnus-group-list-killed ()
3859 "List all killed newsgroups in the group buffer."
3861 (if (not gnus-killed-list)
3862 (message "No killed groups")
3863 (funcall gnus-group-prepare-function 9 t 9)
3864 (goto-char (point-min)))
3865 (gnus-group-position-cursor))
3867 (defun gnus-group-list-zombies ()
3868 "List all zombie newsgroups in the group buffer."
3870 (if (not gnus-zombie-list)
3871 (message "No zombie groups")
3872 (funcall gnus-group-prepare-function 8 t 8)
3873 (goto-char (point-min)))
3874 (gnus-group-position-cursor))
3876 (defun gnus-group-get-new-news (&optional arg)
3877 "Get newly arrived articles.
3878 If ARG is non-nil, it should be a number between one and nine to
3879 specify which levels you are interested in re-scanning."
3881 (run-hooks 'gnus-get-new-news-hook)
3882 (if (and gnus-read-active-file (not arg))
3884 (gnus-read-active-file)
3885 (gnus-get-unread-articles (or arg 6)))
3886 (let ((gnus-read-active-file nil))
3887 (gnus-get-unread-articles (or arg 6))))
3888 (gnus-group-list-groups nil gnus-have-all-newsgroups))
3890 (defun gnus-group-get-new-news-this-group (n)
3891 "Check for newly arrived news in the current group (and the N-1 next groups).
3892 The difference between N and the number of newsgroup checked is returned.
3893 If N is negative, this group and the N-1 previous groups will be checked."
3895 (let ((way (if (< n 0) -1 1))
3897 (w-p (window-start))
3901 (or (gnus-get-new-news-in-group
3902 (setq group (gnus-group-group-name)))
3905 (message "%s error: %s"
3906 group (gnus-status-message group))))
3908 (zerop (gnus-group-next-group way)))
3910 (if (/= 0 n) (message "No more newsgroups"))
3911 ;; !!! I don't know why the buffer scrolls forward when updating
3912 ;; the first line in the group buffer, but it does. So we set the
3913 ;; window start forcibly.
3914 (set-window-start (get-buffer-window (current-buffer)) w-p)
3917 (defun gnus-get-new-news-in-group (group)
3919 (gnus-activate-newsgroup group)
3921 (gnus-get-unread-articles-in-group
3922 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
3923 (gnus-gethash group gnus-active-hashtb))
3924 (gnus-group-update-group-line)
3927 (defun gnus-group-fetch-faq (group)
3928 "Fetch the FAQ for the current group."
3929 (interactive (list (gnus-group-group-name)))
3930 (or group (error "No group name given"))
3931 (let ((file (concat gnus-group-faq-directory group)))
3932 (if (not (file-exists-p file))
3933 (error "No such file: %s" file)
3936 (defun gnus-group-describe-group (force &optional group)
3937 "Display a description of the current newsgroup."
3939 (and force (setq gnus-description-hashtb nil))
3940 (let ((group (or group (gnus-group-group-name)))
3942 (or group (message "No group name given"))
3943 (and (or gnus-description-hashtb
3944 (setq desc (gnus-group-get-description group))
3945 (gnus-read-descriptions-file))
3947 (or desc (gnus-gethash group gnus-description-hashtb)
3948 "No description available")))))
3950 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3951 (defun gnus-group-describe-all-groups (force)
3952 "Pop up a buffer with descriptons of all newsgroups."
3954 (and force (setq gnus-description-hashtb nil))
3955 (if (not (or gnus-description-hashtb
3956 (gnus-read-descriptions-file)))
3957 (error "Couldn't request descriptions file"))
3958 (let ((buffer-read-only nil)
3964 (insert (format " *: %-20s %s\n" (symbol-name group)
3965 (symbol-value group)))
3966 (add-text-properties
3967 b (1+ b) (list 'gnus-group group
3968 'gnus-unread t 'gnus-marked nil 'gnus-level 6)))
3969 gnus-description-hashtb)
3970 (goto-char (point-min))
3971 (gnus-group-position-cursor)))
3973 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
3974 (defun gnus-group-apropos (regexp &optional search-description)
3975 "List all newsgroups that have names that match a regexp."
3976 (interactive "sGnus apropos (regexp): ")
3978 (obuf (current-buffer))
3980 ;; Go through all newsgroups that are known to Gnus.
3983 (and (string-match regexp (symbol-name group))
3984 (setq groups (cons (symbol-name group) groups))))
3986 ;; Go through all descriptions that are known to Gnus.
3987 (if search-description
3990 (and (string-match regexp (symbol-value group))
3991 (gnus-gethash (symbol-name group) gnus-active-hashtb)
3992 (setq groups (cons (symbol-name group) groups))))
3993 gnus-description-hashtb))
3995 (message "No groups matched \"%s\"." regexp)
3996 ;; Print out all the groups.
3998 (pop-to-buffer (get-buffer-create "*Gnus Help*"))
3999 (buffer-disable-undo (current-buffer))
4001 (setq groups (sort groups 'string<))
4003 ;; Groups may be entered twice into the list of groups.
4004 (if (not (string= (car groups) prev))
4006 (insert (setq prev (car groups)) "\n")
4007 (if (and gnus-description-hashtb
4008 (setq des (gnus-gethash (car groups)
4009 gnus-description-hashtb)))
4010 (insert " " des "\n"))))
4011 (setq groups (cdr groups)))
4013 (pop-to-buffer obuf)))
4015 (defun gnus-group-description-apropos (regexp)
4016 "List all newsgroups that have names or desccriptions that match a regexp."
4017 (interactive "sGnus description apropos (regexp): ")
4018 (if (not (or gnus-description-hashtb
4019 (gnus-read-descriptions-file)))
4020 (error "Couldn't request descriptions file"))
4021 (gnus-group-apropos regexp t))
4023 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4024 (defun gnus-group-list-matching (level regexp &optional all lowest)
4025 "List all groups with unread articles that match REGEXP.
4026 If the prefix LEVEL is non-nil, it should be a number that says which
4027 level to cut off listing groups.
4028 If ALL, also list groups with no unread articles.
4029 If LOWEST, don't list groups with level lower than LOWEST."
4030 (interactive "P\nsList newsgroups matching: ")
4031 (gnus-group-prepare-flat (or level 5) all (or lowest 1) regexp)
4032 (goto-char (point-min))
4033 (gnus-group-position-cursor))
4035 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4036 "List all groups that match REGEXP.
4037 If the prefix LEVEL is non-nil, it should be a number that says which
4038 level to cut off listing groups.
4039 If LOWEST, don't list groups with level lower than LOWEST."
4040 (interactive "P\nsList newsgroups matching: ")
4041 (gnus-group-list-matching (or level 9) regexp t lowest))
4043 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4044 (defun gnus-group-save-newsrc ()
4045 "Save the Gnus startup files."
4047 (gnus-save-newsrc-file))
4049 (defun gnus-group-restart (&optional arg)
4050 "Force Gnus to read the .newsrc file."
4052 (gnus-save-newsrc-file)
4053 (gnus-setup-news 'force)
4054 (gnus-group-list-groups arg gnus-have-all-newsgroups))
4056 (defun gnus-group-read-init-file ()
4057 "Read the Gnus elisp init file."
4059 (gnus-read-init-file))
4061 (defun gnus-group-check-bogus-groups ()
4062 "Check bogus newsgroups."
4064 (gnus-check-bogus-newsgroups (not gnus-expert-user)) ;Require confirmation.
4065 (gnus-group-list-groups nil gnus-have-all-newsgroups))
4067 (defun gnus-group-mail ()
4068 "Start composing a mail."
4072 (defun gnus-group-edit-global-kill (article &optional group)
4073 "Edit the global kill file.
4074 If GROUP, edit that local kill file instead."
4076 (setq gnus-current-kill-article article)
4077 (gnus-kill-file-edit-file group)
4079 (substitute-command-keys
4080 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
4082 (defun gnus-group-edit-local-kill (article group)
4083 "Edit a local kill file."
4084 (interactive (list nil (gnus-group-group-name)))
4085 (gnus-group-edit-global-kill article group))
4087 (defun gnus-group-force-update ()
4088 "Update `.newsrc' file."
4090 (gnus-save-newsrc-file))
4092 (defun gnus-group-suspend ()
4093 "Suspend the current Gnus session.
4094 In fact, cleanup buffers except for group mode buffer.
4095 The hook gnus-suspend-gnus-hook is called before actually suspending."
4097 (run-hooks 'gnus-suspend-gnus-hook)
4098 ;; Kill Gnus buffers except for group mode buffer.
4099 (let ((group-buf (get-buffer gnus-group-buffer)))
4100 (while gnus-buffer-list
4101 (and (not (eq (get-buffer (car gnus-buffer-list)) group-buf))
4102 (not (eq (get-buffer (car gnus-buffer-list)) gnus-dribble-buffer))
4103 (get-buffer (car gnus-buffer-list))
4104 (buffer-name (get-buffer (car gnus-buffer-list)))
4105 (kill-buffer (car gnus-buffer-list)))
4106 (setq gnus-buffer-list (cdr gnus-buffer-list)))
4107 (setq gnus-buffer-list (list group-buf))
4108 (bury-buffer group-buf)
4109 (delete-windows-on group-buf t)))
4111 (defun gnus-group-clear-dribble ()
4112 "Clear all information from the dribble buffer."
4114 (gnus-dribble-clear))
4116 (defun gnus-group-exit ()
4117 "Quit reading news after updating .newsrc.eld and .newsrc.
4118 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4120 (if (or noninteractive ;For gnus-batch-kill
4121 (zerop (buffer-size)) ;No news is good news.
4122 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
4123 (not gnus-interactive-exit) ;Without confirmation
4125 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4127 (run-hooks 'gnus-exit-gnus-hook)
4128 (gnus-save-newsrc-file)
4129 (gnus-close-backends)
4130 (gnus-clear-system))))
4132 (defun gnus-close-backends ()
4133 ;; Send a close request to all backends that support such a request.
4134 (let ((methods gnus-valid-select-methods)
4137 (if (fboundp (setq func (intern (concat (car (car methods))
4138 "-request-close"))))
4140 (setq methods (cdr methods)))))
4142 (defun gnus-group-quit ()
4143 "Quit reading news without updating .newsrc.eld or .newsrc.
4144 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4146 (if (or noninteractive ;For gnus-batch-kill
4147 (zerop (buffer-size))
4148 (not (gnus-server-opened gnus-select-method))
4150 (not gnus-current-startup-file)
4152 (format "Quit reading news without saving %s? "
4153 (file-name-nondirectory gnus-current-startup-file))))
4155 (run-hooks 'gnus-exit-gnus-hook)
4157 (gnus-close-backends)
4158 (gnus-clear-system))))
4160 (defun gnus-group-describe-briefly ()
4161 "Give a one line description of the group mode commands."
4164 (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")))
4166 (defun gnus-group-browse-foreign-server (method)
4167 "Browse a foreign news server.
4168 If called interactively, this function will ask for a select method
4169 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4170 If not, METHOD should be a list where the first element is the method
4171 and the second element is the address."
4173 (list (list (intern (completing-read
4175 gnus-valid-select-methods nil t "nntp"))
4176 ;; Suggested by mapjph@bath.ac.uk.
4179 (mapcar (lambda (server) (list server))
4180 gnus-secondary-servers)))))
4181 (gnus-browse-foreign-server method))
4185 ;;; Browse Server Mode
4188 (defvar gnus-browse-server-mode-hook nil)
4189 (defvar gnus-browse-server-mode-map nil)
4190 (put 'gnus-browse-server-mode 'mode-class 'special)
4192 (if gnus-browse-server-mode-map
4194 (setq gnus-browse-server-mode-map (make-keymap))
4195 (suppress-keymap gnus-browse-server-mode-map)
4196 (define-key gnus-browse-server-mode-map " " 'gnus-browse-read-group)
4197 (define-key gnus-browse-server-mode-map "=" 'gnus-browse-read-group)
4198 (define-key gnus-browse-server-mode-map "n" 'gnus-browse-next-group)
4199 (define-key gnus-browse-server-mode-map "p" 'gnus-browse-prev-group)
4200 (define-key gnus-browse-server-mode-map "\177" 'gnus-browse-prev-group)
4201 (define-key gnus-browse-server-mode-map "N" 'gnus-browse-next-group)
4202 (define-key gnus-browse-server-mode-map "P" 'gnus-browse-prev-group)
4203 (define-key gnus-browse-server-mode-map "\M-n" 'gnus-browse-next-group)
4204 (define-key gnus-browse-server-mode-map "\M-p" 'gnus-browse-prev-group)
4205 (define-key gnus-browse-server-mode-map "\r" 'gnus-browse-read-group)
4206 (define-key gnus-browse-server-mode-map "u" 'gnus-browse-unsubscribe-current-group)
4207 (define-key gnus-browse-server-mode-map "l" 'gnus-browse-exit)
4208 (define-key gnus-browse-server-mode-map "L" 'gnus-browse-exit)
4209 (define-key gnus-browse-server-mode-map "q" 'gnus-browse-exit)
4210 (define-key gnus-browse-server-mode-map "Q" 'gnus-browse-exit)
4211 (define-key gnus-browse-server-mode-map "\C-c\C-c" 'gnus-browse-exit)
4212 (define-key gnus-browse-server-mode-map "?" 'gnus-browse-describe-briefly)
4213 (define-key gnus-browse-server-mode-map "\C-c\C-i" 'gnus-info-find-node)
4216 (defvar gnus-browse-current-method nil)
4218 (defun gnus-browse-foreign-server (method)
4219 (setq gnus-browse-current-method method)
4220 (let ((gnus-select-method method)
4222 (message "Connecting to %s..." (nth 1 method))
4223 (or (gnus-server-opened method)
4224 (gnus-open-server method)
4225 (error "Unable to contact server: %s" (gnus-status-message method)))
4226 (or (gnus-request-list method)
4227 (error "Couldn't request list: %s" (gnus-status-message method)))
4228 (set-buffer (get-buffer-create "*Gnus Browse Server*"))
4229 (gnus-add-current-to-buffer-list)
4230 (buffer-disable-undo (current-buffer))
4231 (let ((buffer-read-only nil))
4233 (gnus-browse-server-mode)
4234 (setq mode-line-buffer-identification
4236 "(ding) Browse Server {%s:%s}" (car method) (car (cdr method))))
4238 (set-buffer nntp-server-buffer)
4239 (let ((cur (current-buffer)))
4241 (delete-matching-lines gnus-ignored-newsgroups)
4242 (while (re-search-forward
4243 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
4244 (goto-char (match-end 1))
4245 (setq groups (cons (cons (buffer-substring (match-beginning 1)
4247 (- (read cur) (read cur)))
4249 (setq groups (sort groups
4251 (string< (car l1) (car l2)))))
4252 (let ((buffer-read-only nil))
4254 (setq group (car groups))
4256 (format "K%7d: %s\n" (cdr group) (car group)))
4257 (setq groups (cdr groups))))
4258 (switch-to-buffer (current-buffer))
4260 (gnus-group-position-cursor)))
4262 (defun gnus-browse-server-mode ()
4263 "Major mode for browsing a foreign server."
4265 (kill-all-local-variables)
4266 (setq mode-line-modified "-- ")
4267 (make-local-variable 'mode-line-format)
4268 (setq mode-line-format (copy-sequence mode-line-format))
4269 (and (equal (nth 3 mode-line-format) " ")
4270 (setcar (nthcdr 3 mode-line-format) ""))
4271 (setq major-mode 'gnus-browse-server-mode)
4272 (setq mode-name "Browse Server")
4273 (setq mode-line-process nil)
4274 (use-local-map gnus-browse-server-mode-map)
4275 (buffer-disable-undo (current-buffer))
4276 (setq truncate-lines t)
4277 (setq buffer-read-only t)
4278 (run-hooks 'gnus-browse-server-mode-hook))
4280 (defun gnus-browse-read-group ()
4281 "Not implemented, and will probably never be."
4283 (error "You can't read while browsing"))
4285 (defun gnus-browse-next-group (n)
4286 "Go to the next group."
4290 (gnus-group-position-cursor)))
4292 (defun gnus-browse-prev-group (n)
4293 "Go to the next group."
4295 (gnus-browse-next-group (- n)))
4297 (defun gnus-browse-unsubscribe-current-group (arg)
4298 "(Un)subscribe to the next ARG groups."
4301 (error "No group at current line."))
4302 (let ((ward (if (< arg 0) -1 1))
4304 (while (and (> arg 0)
4306 (gnus-browse-unsubscribe-group)
4307 (zerop (gnus-browse-next-group ward)))
4308 (setq arg (1- arg)))
4309 (gnus-group-position-cursor)
4310 (if (/= 0 arg) (message "No more newsgroups"))
4313 (defun gnus-browse-unsubscribe-group ()
4315 (buffer-read-only nil)
4319 (if (= (following-char) ?K) (setq sub t))
4320 (re-search-forward ": \\(.*\\)$" nil t)
4321 (setq group (gnus-group-prefixed-name
4322 (buffer-substring (match-beginning 1) (match-end 1))
4323 gnus-browse-current-method))
4328 (gnus-group-change-level
4329 (list t group 3 nil nil gnus-browse-current-method) 3 9
4330 (gnus-gethash (car (nth 1 gnus-newsrc-assoc)) gnus-newsrc-hashtb)
4333 (gnus-group-change-level group 9 3)
4337 (defun gnus-browse-exit ()
4338 "Quit browsing and return to the group buffer."
4340 (if (eq major-mode 'gnus-browse-server-mode)
4341 (kill-buffer (current-buffer)))
4342 (switch-to-buffer gnus-group-buffer)
4343 (gnus-group-list-groups nil))
4345 (defun gnus-browse-describe-briefly ()
4346 "Give a one line description of the group mode commands."
4349 (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")))
4353 ;;; Gnus summary mode
4356 (defvar gnus-summary-mode-map nil)
4357 (defvar gnus-summary-mark-map nil)
4358 (defvar gnus-summary-mscore-map nil)
4359 (defvar gnus-summary-send-map nil)
4360 (defvar gnus-summary-extract-map nil)
4361 (defvar gnus-summary-extract-view-map nil)
4362 (defvar gnus-summary-article-map nil)
4363 (defvar gnus-summary-thread-map nil)
4364 (defvar gnus-summary-goto-map nil)
4365 (defvar gnus-summary-exit-map nil)
4366 (defvar gnus-summary-various-map nil)
4367 (defvar gnus-summary-interest-map nil)
4368 (defvar gnus-summary-process-map nil)
4369 (defvar gnus-summary-score-map nil)
4370 (defvar gnus-summary-sort-map nil)
4371 (defvar gnus-summary-mgroup-map nil)
4372 (defvar gnus-summary-vsave-map nil)
4373 (defvar gnus-summary-increase-map nil)
4374 (defvar gnus-summary-inc-subject-map nil)
4375 (defvar gnus-summary-inc-author-map nil)
4376 (defvar gnus-summary-inc-body-map nil)
4377 (defvar gnus-summary-inc-id-map nil)
4378 (defvar gnus-summary-inc-xref-map nil)
4379 (defvar gnus-summary-inc-thread-map nil)
4380 (defvar gnus-summary-inc-fol-map nil)
4381 (defvar gnus-summary-lower-map nil)
4382 (defvar gnus-summary-low-subject-map nil)
4383 (defvar gnus-summary-low-author-map nil)
4384 (defvar gnus-summary-low-body-map nil)
4385 (defvar gnus-summary-low-id-map nil)
4386 (defvar gnus-summary-low-xref-map nil)
4387 (defvar gnus-summary-low-thread-map nil)
4388 (defvar gnus-summary-low-fol-map nil)
4389 (put 'gnus-summary-mode 'mode-class 'special)
4391 (if gnus-summary-mode-map
4393 (setq gnus-summary-mode-map (make-keymap))
4394 (suppress-keymap gnus-summary-mode-map)
4396 ;; Non-orthogonal keys
4398 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
4399 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
4400 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
4401 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
4402 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
4403 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
4404 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
4405 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
4406 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
4407 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
4408 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
4409 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
4410 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
4411 (define-key gnus-summary-mode-map "\M-s" 'gnus-summary-search-article-forward)
4412 (define-key gnus-summary-mode-map "\M-r" 'gnus-summary-search-article-backward)
4413 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
4414 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
4415 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
4416 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
4417 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
4418 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
4419 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
4420 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
4421 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
4422 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
4423 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
4424 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
4425 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
4426 (define-key gnus-summary-mode-map "k" 'gnus-summary-kill-same-subject-and-select)
4427 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
4428 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
4429 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
4430 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
4431 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
4432 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
4433 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
4434 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
4435 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
4436 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
4437 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
4438 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
4439 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
4440 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
4441 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
4442 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
4443 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
4444 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
4445 (define-key gnus-summary-mode-map "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
4446 (define-key gnus-summary-mode-map "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
4447 (define-key gnus-summary-mode-map "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
4448 (define-key gnus-summary-mode-map "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
4449 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
4450 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
4451 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
4452 (define-key gnus-summary-mode-map "\C-x\C-s" 'gnus-summary-reselect-current-group)
4453 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
4454 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
4455 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
4456 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
4457 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
4458 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
4459 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
4460 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
4461 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
4462 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
4463 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
4464 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
4465 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
4466 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
4467 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
4468 (define-key gnus-summary-mode-map "V" 'gnus-version)
4469 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
4470 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
4471 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
4472 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
4473 (define-key gnus-summary-mode-map
4474 (if gnus-xemacs [button2] [mouse-2]) 'gnus-mouse-pick-article)
4475 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
4476 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
4477 (define-key gnus-summary-mode-map "x" 'gnus-summary-remove-lines-marked-as-read)
4478 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
4479 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
4480 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
4481 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
4482 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
4483 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
4484 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
4485 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
4488 ;; Sort of orthogonal keymap
4489 (define-prefix-command 'gnus-summary-mark-map)
4490 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
4491 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
4492 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
4493 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
4494 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
4495 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
4496 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
4497 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
4498 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
4499 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
4500 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
4501 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
4502 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
4503 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
4504 (define-key gnus-summary-mark-map "\M-r" 'gnus-summary-remove-lines-marked-as-read)
4505 (define-key gnus-summary-mark-map "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
4506 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
4507 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
4508 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
4509 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
4510 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
4511 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
4512 (define-key gnus-summary-mark-map "k" 'gnus-summary-kill-same-subject-and-select)
4513 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
4515 (define-prefix-command 'gnus-summary-mscore-map)
4516 (define-key gnus-summary-mark-map "s" 'gnus-summary-mscore-map)
4517 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
4518 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
4519 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
4520 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
4522 (define-prefix-command 'gnus-summary-process-map)
4523 (define-key gnus-summary-mark-map "p" 'gnus-summary-process-map)
4524 (define-key gnus-summary-process-map "p" 'gnus-summary-mark-as-processable)
4525 (define-key gnus-summary-process-map "u" 'gnus-summary-unmark-as-processable)
4526 (define-key gnus-summary-process-map "U" 'gnus-summary-unmark-all-processable)
4527 (define-key gnus-summary-process-map "s" 'gnus-uu-mark-series)
4528 (define-key gnus-summary-process-map "r" 'gnus-uu-mark-region)
4529 (define-key gnus-summary-process-map "R" 'gnus-uu-mark-by-regexp)
4530 (define-key gnus-summary-process-map "t" 'gnus-uu-mark-thread)
4531 (define-key gnus-summary-process-map "a" 'gnus-uu-mark-all)
4532 (define-key gnus-summary-process-map "S" 'gnus-uu-mark-sparse)
4535 (define-prefix-command 'gnus-summary-send-map)
4536 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
4537 (define-key gnus-summary-send-map "p" 'gnus-summary-post-news)
4538 (define-key gnus-summary-send-map "f" 'gnus-summary-followup)
4539 (define-key gnus-summary-send-map "F" 'gnus-summary-followup-with-original)
4540 (define-key gnus-summary-send-map "b" 'gnus-summary-followup-and-reply)
4541 (define-key gnus-summary-send-map "B" 'gnus-summary-followup-and-reply-with-original)
4542 (define-key gnus-summary-send-map "c" 'gnus-summary-cancel-article)
4543 (define-key gnus-summary-send-map "s" 'gnus-summary-supersede-article)
4544 (define-key gnus-summary-send-map "r" 'gnus-summary-reply)
4545 (define-key gnus-summary-send-map "R" 'gnus-summary-reply-with-original)
4546 (define-key gnus-summary-send-map "\C-f" 'gnus-summary-mail-forward)
4547 (define-key gnus-summary-send-map "m" 'gnus-summary-mail-other-window)
4548 (define-key gnus-summary-send-map "u" 'gnus-uu-post-news)
4549 (define-key gnus-summary-send-map "\M-f" 'gnus-uu-digest-and-forward)
4552 (define-prefix-command 'gnus-summary-goto-map)
4553 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
4554 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
4555 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
4556 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
4557 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
4558 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
4559 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
4560 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
4561 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
4562 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
4563 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
4564 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
4565 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
4566 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
4569 (define-prefix-command 'gnus-summary-thread-map)
4570 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
4571 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
4572 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
4573 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
4574 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
4575 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
4576 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
4577 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
4578 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
4579 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
4580 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
4581 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
4582 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
4583 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
4586 (define-prefix-command 'gnus-summary-exit-map)
4587 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
4588 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
4589 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
4590 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
4591 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
4592 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
4593 (define-key gnus-summary-exit-map "n" 'gnus-summary-catchup-and-goto-next-group)
4596 (define-prefix-command 'gnus-summary-article-map)
4597 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
4598 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
4599 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
4600 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
4601 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
4602 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
4603 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
4604 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
4605 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
4606 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
4607 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
4608 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
4609 (define-key gnus-summary-article-map "w" 'gnus-summary-stop-page-breaking)
4610 (define-key gnus-summary-article-map "c" 'gnus-summary-caesar-message)
4611 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
4612 (define-key gnus-summary-article-map "t" 'gnus-summary-toggle-header)
4613 (define-key gnus-summary-article-map "hh" 'gnus-article-hide-headers)
4614 (define-key gnus-summary-article-map "hs" 'gnus-article-hide-signature)
4615 (define-key gnus-summary-article-map "hc" 'gnus-article-hide-citation)
4616 (define-key gnus-summary-article-map "ho" 'gnus-article-treat-overstrike)
4617 (define-key gnus-summary-article-map "hw" 'gnus-article-word-wrap)
4618 (define-key gnus-summary-article-map "hd" 'gnus-article-remove-cr)
4619 (define-key gnus-summary-article-map "hq" 'gnus-article-de-quoted-unreadable)
4620 (define-key gnus-summary-article-map "hf" 'gnus-article-display-x-face)
4621 (define-key gnus-summary-article-map "m" 'gnus-summary-toggle-mime)
4622 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
4625 (define-prefix-command 'gnus-summary-extract-map)
4626 (define-key gnus-summary-mode-map "X" 'gnus-summary-extract-map)
4627 ; (define-key gnus-summary-extract-map "x" 'gnus-summary-extract-any)
4628 ; (define-key gnus-summary-extract-map "m" 'gnus-summary-extract-mime)
4629 (define-key gnus-summary-extract-map "u" 'gnus-uu-decode-uu)
4630 (define-key gnus-summary-extract-map "U" 'gnus-uu-decode-uu-and-save)
4631 (define-key gnus-summary-extract-map "s" 'gnus-uu-decode-unshar)
4632 (define-key gnus-summary-extract-map "S" 'gnus-uu-decode-unshar-and-save)
4633 (define-key gnus-summary-extract-map "o" 'gnus-uu-decode-save)
4634 (define-key gnus-summary-extract-map "O" 'gnus-uu-decode-save)
4635 (define-key gnus-summary-extract-map "b" 'gnus-uu-decode-binhex)
4636 (define-key gnus-summary-extract-map "B" 'gnus-uu-decode-binhex)
4638 (define-prefix-command 'gnus-summary-extract-view-map)
4639 (define-key gnus-summary-extract-map "v" 'gnus-summary-extract-view-map)
4640 (define-key gnus-summary-extract-view-map "u" 'gnus-uu-decode-uu-view)
4641 (define-key gnus-summary-extract-view-map "U" 'gnus-uu-decode-uu-and-save-view)
4642 (define-key gnus-summary-extract-view-map "s" 'gnus-uu-decode-unshar-view)
4643 (define-key gnus-summary-extract-view-map "S" 'gnus-uu-decode-unshar-and-save-view)
4644 (define-key gnus-summary-extract-view-map "o" 'gnus-uu-decode-save-view)
4645 (define-key gnus-summary-extract-view-map "O" 'gnus-uu-decode-save-view)
4646 (define-key gnus-summary-extract-view-map "b" 'gnus-uu-decode-binhex-view)
4647 (define-key gnus-summary-extract-view-map "B" 'gnus-uu-decode-binhex-view)
4650 (define-prefix-command 'gnus-summary-various-map)
4651 (define-key gnus-summary-mode-map "V" 'gnus-summary-various-map)
4652 (define-key gnus-summary-various-map "u" 'gnus-summary-universal-argument)
4653 (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
4654 (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
4655 (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
4656 (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
4657 (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
4658 (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
4659 (define-key gnus-summary-various-map "S" 'gnus-summary-reselect-current-group)
4660 (define-key gnus-summary-various-map "g" 'gnus-summary-rescan-group)
4661 (define-key gnus-summary-various-map "V" 'gnus-version)
4662 (define-key gnus-summary-various-map "f" 'gnus-summary-fetch-faq)
4663 (define-key gnus-summary-various-map "d" 'gnus-summary-describe-group)
4664 (define-key gnus-summary-various-map "?" 'gnus-summary-describe-briefly)
4665 (define-key gnus-summary-various-map "i" 'gnus-info-find-node)
4666 (define-key gnus-summary-various-map "D" 'gnus-summary-enter-digest-group)
4667 (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
4668 (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
4670 (define-prefix-command 'gnus-summary-vsave-map)
4671 (define-key gnus-summary-various-map "o" 'gnus-summary-vsave-map)
4672 (define-key gnus-summary-vsave-map "o" 'gnus-summary-save-article)
4673 (define-key gnus-summary-vsave-map "m" 'gnus-summary-save-article-mail)
4674 (define-key gnus-summary-vsave-map "r" 'gnus-summary-save-article-rmail)
4675 (define-key gnus-summary-vsave-map "f" 'gnus-summary-save-article-file)
4676 (define-key gnus-summary-vsave-map "h" 'gnus-summary-save-article-folder)
4677 (define-key gnus-summary-vsave-map "p" 'gnus-summary-pipe-output)
4679 (define-prefix-command 'gnus-summary-score-map)
4680 (define-key gnus-summary-various-map "S" 'gnus-summary-score-map)
4681 (define-key gnus-summary-score-map "s" 'gnus-summary-set-score)
4682 (define-key gnus-summary-score-map "c" 'gnus-score-change-score-file)
4683 (define-key gnus-summary-score-map "m" 'gnus-score-set-mark-below)
4684 (define-key gnus-summary-score-map "x" 'gnus-score-set-expunge-below)
4685 (define-key gnus-summary-score-map "e" 'gnus-score-edit-alist)
4686 (define-key gnus-summary-score-map "f" 'gnus-score-edit-file)
4688 (define-prefix-command 'gnus-summary-sort-map)
4689 (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
4690 (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
4691 (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
4692 (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
4693 (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
4694 (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
4696 (define-prefix-command 'gnus-summary-mgroup-map)
4697 (define-key gnus-summary-various-map "m" 'gnus-summary-mgroup-map)
4698 (define-key gnus-summary-mgroup-map "e" 'gnus-summary-expire-articles)
4699 (define-key gnus-summary-mgroup-map "\177" 'gnus-summary-delete-article)
4700 (define-key gnus-summary-mgroup-map "m" 'gnus-summary-move-article)
4701 (define-key gnus-summary-mgroup-map "r" 'gnus-summary-respool-article)
4702 (define-key gnus-summary-mgroup-map "w" 'gnus-summary-edit-article)
4703 (define-key gnus-summary-mgroup-map "c" 'gnus-summary-copy-article)
4706 (define-prefix-command 'gnus-summary-increase-map)
4707 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-map)
4708 (define-key gnus-summary-increase-map "i" 'gnus-summary-raise-same-subject-and-select)
4709 (define-key gnus-summary-increase-map "I" 'gnus-summary-raise-same-subject)
4710 (define-key gnus-summary-increase-map "\C-i" 'gnus-summary-raise-score)
4712 (define-prefix-command 'gnus-summary-inc-subject-map)
4713 (define-key gnus-summary-increase-map "s" 'gnus-summary-inc-subject-map)
4714 (define-key gnus-summary-increase-map "S" 'gnus-summary-temporarily-raise-by-subject)
4715 (define-key gnus-summary-inc-subject-map "s" 'gnus-summary-temporarily-raise-by-subject)
4716 (define-key gnus-summary-inc-subject-map "S" 'gnus-summary-raise-by-subject)
4717 (define-key gnus-summary-inc-subject-map "t" 'gnus-summary-temporarily-raise-by-subject)
4718 (define-key gnus-summary-inc-subject-map "p" 'gnus-summary-raise-by-subject)
4720 (define-prefix-command 'gnus-summary-inc-author-map)
4721 (define-key gnus-summary-increase-map "a" 'gnus-summary-inc-author-map)
4722 (define-key gnus-summary-increase-map "A" 'gnus-summary-temporarily-raise-by-author)
4723 (define-key gnus-summary-inc-author-map "a" 'gnus-summary-temporarily-raise-by-author)
4724 (define-key gnus-summary-inc-author-map "A" 'gnus-summary-raise-by-author)
4725 (define-key gnus-summary-inc-author-map "t" 'gnus-summary-temporarily-raise-by-author)
4726 (define-key gnus-summary-inc-author-map "p" 'gnus-summary-raise-by-author)
4728 (define-prefix-command 'gnus-summary-inc-body-map)
4729 (define-key gnus-summary-increase-map "b" 'gnus-summary-inc-body-map)
4730 (define-key gnus-summary-increase-map "B" 'gnus-summary-temporarily-raise-by-body)
4731 (define-key gnus-summary-inc-body-map "b" 'gnus-summary-temporarily-raise-by-body)
4732 (define-key gnus-summary-inc-body-map "B" 'gnus-summary-raise-by-body)
4733 (define-key gnus-summary-inc-body-map "t" 'gnus-summary-temporarily-raise-by-body)
4734 (define-key gnus-summary-inc-body-map "p" 'gnus-summary-raise-by-body)
4736 (define-prefix-command 'gnus-summary-inc-id-map)
4737 (define-key gnus-summary-increase-map "i" 'gnus-summary-inc-id-map)
4738 (define-key gnus-summary-increase-map "I" 'gnus-summary-temporarily-raise-by-id)
4739 (define-key gnus-summary-inc-id-map "i" 'gnus-summary-temporarily-raise-by-id)
4740 (define-key gnus-summary-inc-id-map "I" 'gnus-summary-raise-by-id)
4741 (define-key gnus-summary-inc-id-map "t" 'gnus-summary-temporarily-raise-by-id)
4742 (define-key gnus-summary-inc-id-map "p" 'gnus-summary-raise-by-id)
4744 (define-prefix-command 'gnus-summary-inc-thread-map)
4745 (define-key gnus-summary-increase-map "t" 'gnus-summary-inc-thread-map)
4746 (define-key gnus-summary-increase-map "T" 'gnus-summary-temporarily-raise-by-thread)
4747 (define-key gnus-summary-inc-thread-map "t" 'gnus-summary-temporarily-raise-by-thread)
4748 (define-key gnus-summary-inc-thread-map "T" 'gnus-summary-raise-by-thread)
4749 (define-key gnus-summary-inc-thread-map "t" 'gnus-summary-temporarily-raise-by-thread)
4750 (define-key gnus-summary-inc-thread-map "p" 'gnus-summary-raise-by-thread)
4752 (define-prefix-command 'gnus-summary-inc-xref-map)
4753 (define-key gnus-summary-increase-map "x" 'gnus-summary-inc-xref-map)
4754 (define-key gnus-summary-increase-map "X" 'gnus-summary-temporarily-raise-by-xref)
4755 (define-key gnus-summary-inc-xref-map "x" 'gnus-summary-temporarily-raise-by-xref)
4756 (define-key gnus-summary-inc-xref-map "X" 'gnus-summary-raise-by-xref)
4757 (define-key gnus-summary-inc-xref-map "t" 'gnus-summary-temporarily-raise-by-xref)
4758 (define-key gnus-summary-inc-xref-map "p" 'gnus-summary-raise-by-xref)
4760 (define-prefix-command 'gnus-summary-inc-fol-map)
4761 (define-key gnus-summary-increase-map "f" 'gnus-summary-inc-fol-map)
4762 (define-key gnus-summary-increase-map "F" 'gnus-summary-raise-followups-to-author)
4763 (define-key gnus-summary-inc-fol-map "f" 'gnus-summary-raise-followups-to-author)
4764 (define-key gnus-summary-inc-fol-map "F" 'gnus-summary-raise-followups-to-author)
4765 (define-key gnus-summary-inc-fol-map "t" 'gnus-summary-raise-followups-to-author)
4766 (define-key gnus-summary-inc-fol-map "p" 'gnus-summary-raise-followups-to-author)
4768 (define-prefix-command 'gnus-summary-lower-map)
4769 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-map)
4770 (define-key gnus-summary-lower-map "l" 'gnus-summary-lower-same-subject-and-select)
4771 (define-key gnus-summary-lower-map "L" 'gnus-summary-lower-same-subject)
4772 (define-key gnus-summary-lower-map "\C-l" 'gnus-summary-lower-score)
4774 (define-prefix-command 'gnus-summary-low-subject-map)
4775 (define-key gnus-summary-lower-map "s" 'gnus-summary-low-subject-map)
4776 (define-key gnus-summary-lower-map "S" 'gnus-summary-temporarily-lower-by-subject)
4777 (define-key gnus-summary-low-subject-map "s" 'gnus-summary-temporarily-lower-by-subject)
4778 (define-key gnus-summary-low-subject-map "S" 'gnus-summary-lower-by-subject)
4779 (define-key gnus-summary-low-subject-map "t" 'gnus-summary-temporarily-lower-by-subject)
4780 (define-key gnus-summary-low-subject-map "p" 'gnus-summary-lower-by-subject)
4782 (define-prefix-command 'gnus-summary-low-body-map)
4783 (define-key gnus-summary-lower-map "b" 'gnus-summary-low-body-map)
4784 (define-key gnus-summary-lower-map "B" 'gnus-summary-temporarily-lower-by-body)
4785 (define-key gnus-summary-low-body-map "b" 'gnus-summary-temporarily-lower-by-body)
4786 (define-key gnus-summary-low-body-map "B" 'gnus-summary-lower-by-body)
4787 (define-key gnus-summary-low-body-map "t" 'gnus-summary-temporarily-lower-by-body)
4788 (define-key gnus-summary-low-body-map "p" 'gnus-summary-lower-by-body)
4790 (define-prefix-command 'gnus-summary-low-author-map)
4791 (define-key gnus-summary-lower-map "a" 'gnus-summary-low-author-map)
4792 (define-key gnus-summary-lower-map "A" 'gnus-summary-temporarily-lower-by-author)
4793 (define-key gnus-summary-low-author-map "a" 'gnus-summary-temporarily-lower-by-author)
4794 (define-key gnus-summary-low-author-map "A" 'gnus-summary-lower-by-author)
4795 (define-key gnus-summary-low-author-map "t" 'gnus-summary-temporarily-lower-by-author)
4796 (define-key gnus-summary-low-author-map "p" 'gnus-summary-lower-by-author)
4798 (define-prefix-command 'gnus-summary-low-id-map)
4799 (define-key gnus-summary-lower-map "i" 'gnus-summary-low-id-map)
4800 (define-key gnus-summary-lower-map "I" 'gnus-summary-temporarily-lower-by-id)
4801 (define-key gnus-summary-low-id-map "i" 'gnus-summary-temporarily-lower-by-id)
4802 (define-key gnus-summary-low-id-map "I" 'gnus-summary-lower-by-id)
4803 (define-key gnus-summary-low-id-map "t" 'gnus-summary-temporarily-lower-by-id)
4804 (define-key gnus-summary-low-id-map "p" 'gnus-summary-lower-by-id)
4806 (define-prefix-command 'gnus-summary-low-thread-map)
4807 (define-key gnus-summary-lower-map "t" 'gnus-summary-low-thread-map)
4808 (define-key gnus-summary-lower-map "T" 'gnus-summary-temporarily-lower-by-thread)
4809 (define-key gnus-summary-low-thread-map "t" 'gnus-summary-temporarily-lower-by-thread)
4810 (define-key gnus-summary-low-thread-map "T" 'gnus-summary-lower-by-thread)
4811 (define-key gnus-summary-low-thread-map "t" 'gnus-summary-temporarily-lower-by-thread)
4812 (define-key gnus-summary-low-thread-map "p" 'gnus-summary-lower-by-thread)
4814 (define-prefix-command 'gnus-summary-low-xref-map)
4815 (define-key gnus-summary-lower-map "x" 'gnus-summary-low-xref-map)
4816 (define-key gnus-summary-lower-map "X" 'gnus-summary-temporarily-lower-by-xref)
4817 (define-key gnus-summary-low-xref-map "x" 'gnus-summary-temporarily-lower-by-xref)
4818 (define-key gnus-summary-low-xref-map "X" 'gnus-summary-lower-by-xref)
4819 (define-key gnus-summary-low-xref-map "t" 'gnus-summary-temporarily-lower-by-xref)
4820 (define-key gnus-summary-low-xref-map "p" 'gnus-summary-lower-by-xref)
4822 (define-prefix-command 'gnus-summary-low-fol-map)
4823 (define-key gnus-summary-lower-map "f" 'gnus-summary-low-fol-map)
4824 (define-key gnus-summary-lower-map "F" 'gnus-summary-lower-followups-to-author)
4825 (define-key gnus-summary-low-fol-map "f" 'gnus-summary-lower-followups-to-author)
4826 (define-key gnus-summary-low-fol-map "F" 'gnus-summary-lower-followups-to-author)
4827 (define-key gnus-summary-low-fol-map "t" 'gnus-summary-lower-followups-to-author)
4828 (define-key gnus-summary-low-fol-map "p" 'gnus-summary-lower-followups-to-author)
4834 (defun gnus-summary-mode ()
4835 "Major mode for reading articles.
4837 All normal editing commands are switched off.
4838 \\<gnus-summary-mode-map>
4839 Each line in this buffer represents one article. To read an
4840 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
4841 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
4844 You can also post articles and send mail from this buffer. To
4845 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
4846 of an article, type `\\[gnus-summary-reply]'.
4848 There are approx. one gazillion commands you can execute in this
4849 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
4851 The following commands are available:
4853 \\{gnus-summary-mode-map}"
4855 (if gnus-visual (gnus-summary-make-menu-bar))
4856 (kill-all-local-variables)
4857 (let ((locals gnus-summary-local-variables))
4859 (if (consp (car locals))
4861 (make-local-variable (car (car locals)))
4862 (set (car (car locals)) (eval (cdr (car locals)))))
4863 (make-local-variable (car locals))
4864 (set (car locals) nil))
4865 (setq locals (cdr locals))))
4866 (gnus-update-format-specifications)
4867 (setq mode-line-modified "-- ")
4868 (make-local-variable 'mode-line-format)
4869 (setq mode-line-format (copy-sequence mode-line-format))
4870 (and (equal (nth 3 mode-line-format) " ")
4871 (setcar (nthcdr 3 mode-line-format) ""))
4872 (setq major-mode 'gnus-summary-mode)
4873 (setq mode-name "Summary")
4874 (make-local-variable 'minor-mode-alist)
4875 (gnus-set-mode-line 'summary)
4876 (use-local-map gnus-summary-mode-map)
4877 (buffer-disable-undo (current-buffer))
4878 (setq buffer-read-only t) ;Disable modification
4879 (setq truncate-lines t)
4880 (setq selective-display t)
4881 (setq selective-display-ellipses t) ;Display `...'
4882 (run-hooks 'gnus-summary-mode-hook))
4884 (defun gnus-summary-clear-local-variables ()
4885 (let ((locals gnus-summary-local-variables))
4887 (if (consp (car locals))
4888 (set (car (car locals)) nil)
4889 (set (car locals) nil))
4890 (setq locals (cdr locals)))))
4892 (defun gnus-mouse-pick-article (e)
4895 (gnus-summary-next-page nil t))
4897 (defun gnus-summary-setup-buffer (group)
4898 "Initialize summary buffer."
4899 (let ((buffer (concat "*Summary " group "*")))
4900 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
4901 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
4902 (gnus-add-current-to-buffer-list)
4903 (gnus-summary-mode)))
4905 (defun gnus-set-global-variables ()
4906 ;; Set the global equivalents of the summary buffer-local variables
4907 ;; to the latest values they had. These reflect the summary buffer
4908 ;; that was in action when the last article was fetched.
4909 (if (eq major-mode 'gnus-summary-mode)
4911 (setq gnus-summary-buffer (current-buffer))
4912 (let ((name gnus-newsgroup-name)
4913 (marked gnus-newsgroup-marked)
4914 (unread gnus-newsgroup-unreads)
4915 (headers gnus-current-headers))
4917 (set-buffer gnus-group-buffer)
4918 (setq gnus-newsgroup-name name)
4919 (setq gnus-newsgroup-marked marked)
4920 (setq gnus-newsgroup-unreads unread)
4921 (setq gnus-current-headers headers))))))
4923 (defun gnus-summary-insert-dummy-line (sformat subject number)
4925 (setq sformat gnus-summary-dummy-line-format-spec))
4929 (insert (eval sformat))
4930 (add-text-properties
4932 (list 'gnus-subject (gnus-simplify-subject-re subject)
4937 (defun gnus-summary-insert-line
4938 (sformat header level current unread replied expirable subject-or-nil
4939 &optional dummy score)
4940 (or sformat (setq sformat gnus-summary-line-format-spec))
4942 (make-string (* level gnus-thread-indent-level) ? ))
4943 (lines (or (header-lines header) 0))
4944 (score (or score gnus-summary-default-score 0))
4945 (score-char (if (or (null gnus-summary-default-score)
4946 (= score gnus-summary-default-score)) ?
4947 (if (< score gnus-summary-default-score)
4948 gnus-score-below-mark gnus-score-over-mark)))
4949 (replied (if replied gnus-replied-mark ? ))
4950 (from (header-from header))
4951 (name-address (funcall gnus-extract-address-components from))
4952 (address (car (cdr name-address)))
4953 (name (or (car name-address) (car (cdr name-address))))
4954 (number (header-number header))
4955 (subject (header-subject header))
4956 (buffer-read-only nil)
4957 (opening-bracket (if dummy ?\< ?\[))
4958 (closing-bracket (if dummy ?\> ?\]))
4960 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
4961 (if (not (numberp lines)) (setq lines 0))
4964 (insert (eval sformat))
4965 (add-text-properties
4967 (list 'gnus-subject (gnus-simplify-subject-re subject)
4969 'gnus-mark (or unread gnus-unread-mark ? )
4970 'gnus-thread level))))
4972 (defun gnus-summary-update-line (&optional dont-update)
4973 ;; Update summary line after change.
4974 (or (not gnus-summary-default-score)
4975 gnus-summary-inhibit-highlight
4976 (let ((gnus-summary-inhibit-highlight t)
4977 (article (gnus-summary-article-number)))
4980 (if (and gnus-summary-mark-below
4981 (< (gnus-summary-article-score)
4982 gnus-summary-mark-below))
4983 (and (not (memq article gnus-newsgroup-marked))
4984 (not (memq article gnus-newsgroup-dormant))
4985 (memq article gnus-newsgroup-unreads)
4986 (gnus-summary-mark-article nil gnus-low-score-mark))
4987 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
4988 (gnus-summary-mark-article nil gnus-unread-mark))))
4990 (run-hooks 'gnus-visual-summary-update-hook))))))
4992 (defun gnus-summary-update-lines ()
4993 ;; Rehighlight summary buffer according to `gnus-summary-highlight'.
4994 (and (save-excursion
4995 (set-buffer gnus-summary-buffer)
4996 (goto-char (point-min))
4998 (gnus-summary-update-line)
4999 (forward-line 1)))))
5001 (defun gnus-summary-number-of-articles-in-thread (thread)
5002 ;; Sum up all elements (and sub-elements) in a list.
5004 (apply '+ (mapcar 'gnus-summary-number-of-articles-in-thread thread))
5007 (defun gnus-summary-read-group (group &optional show-all no-article kill-buffer)
5008 "Start reading news in newsgroup GROUP.
5009 If SHOW-ALL is non-nil, already read articles are also listed.
5010 If NO-ARTICLE is non-nil, no article is selected initially."
5011 (message "Retrieving newsgroup: %s..." group)
5012 (gnus-summary-setup-buffer group)
5013 (if (gnus-select-newsgroup group show-all)
5015 (gnus-set-global-variables)
5016 ;; Save the active value in effect when the group was entered.
5017 (setq gnus-newsgroup-active
5019 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5020 ;; You can change the subjects in this hook.
5021 (run-hooks 'gnus-select-group-hook)
5022 ;; Do score processing.
5023 (gnus-score-headers)
5024 ;; Update the format specifiers.
5025 (gnus-update-format-specifications)
5026 ;; Generate the summary buffer.
5027 (gnus-summary-prepare)
5028 (if (zerop (buffer-size))
5029 (cond (gnus-newsgroup-dormant
5030 (gnus-summary-show-all-dormant))
5031 ((and gnus-newsgroup-scored show-all)
5032 (gnus-summary-show-all-expunged))))
5033 ;; Function `gnus-apply-kill-file' must be called in this hook.
5034 (run-hooks 'gnus-apply-kill-hook)
5035 (if (zerop (buffer-size))
5037 ;; This newsgroup is empty.
5038 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
5039 (message "No unread news")
5041 (get-buffer kill-buffer)
5042 (buffer-name (get-buffer kill-buffer))
5043 (kill-buffer kill-buffer)))
5046 (let ((gnus-summary-buffer kill-buffer))
5047 (gnus-configure-windows 'newsgroups t))))
5048 ;; Hide conversation thread subtrees. We cannot do this in
5049 ;; gnus-summary-prepare-hook since kill processing may not
5050 ;; work with hidden articles.
5051 (and gnus-show-threads
5052 gnus-thread-hide-subtree
5053 (gnus-summary-hide-all-threads))
5054 ;; Show first unread article if requested.
5055 (goto-char (point-min))
5056 (if (and (not no-article)
5057 gnus-auto-select-first
5058 (gnus-summary-first-unread-article))
5059 (gnus-configure-windows 'article)
5060 (gnus-configure-windows 'summary))
5061 (pop-to-buffer gnus-summary-buffer)
5062 (gnus-set-mode-line 'summary)
5063 (gnus-summary-position-cursor)
5064 (if (and kill-buffer
5065 (get-buffer kill-buffer)
5066 (buffer-name (get-buffer kill-buffer)))
5067 (kill-buffer kill-buffer))))
5068 ;; Cannot select newsgroup GROUP.
5069 (message "Couldn't select newsgroup")
5070 (and (eq major-mode 'gnus-summary-mode)
5071 (kill-buffer (current-buffer)))
5072 (switch-to-buffer gnus-group-buffer)))
5074 (defun gnus-summary-prepare ()
5075 "Prepare summary list of current newsgroup in summary buffer."
5076 (let ((buffer-read-only nil))
5078 (gnus-summary-prepare-threads
5079 (if gnus-show-threads
5080 (gnus-gather-threads
5082 (if gnus-summary-expunge-below
5083 (gnus-make-threads-and-expunge)
5084 (gnus-make-threads))))
5085 gnus-newsgroup-headers)
5087 ;; Erase header retrieval message.
5088 (gnus-summary-update-lines)
5090 ;; Call hooks for modifying summary buffer.
5091 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
5092 (goto-char (point-min))
5093 (run-hooks 'gnus-summary-prepare-hook)))
5095 (defun gnus-gather-threads (threads)
5096 "Gather threads that have lost their roots."
5097 (if (not gnus-summary-make-false-root)
5099 (let ((hashtb (gnus-make-hashtable 1023))
5102 thread subject hthread unre-subject whole-subject)
5104 (setq subject (header-subject (car (car threads)))
5105 whole-subject subject)
5106 (and gnus-summary-gather-subject-limit
5107 (or (and (numberp gnus-summary-gather-subject-limit)
5108 (> (length subject) gnus-summary-gather-subject-limit)
5110 (substring subject 0
5111 gnus-summary-gather-subject-limit)))
5112 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
5113 (setq subject (gnus-simplify-subject-fuzzy subject)))))
5116 (setq unre-subject (gnus-simplify-subject-re subject))
5119 (or (stringp (car (car hthread)))
5120 (setcar hthread (list whole-subject (car hthread))))
5121 (setcdr (car hthread) (nconc (cdr (car hthread))
5122 (list (car threads))))
5123 (setcdr prev (cdr threads))
5124 (setq threads prev))
5125 (gnus-sethash unre-subject threads hashtb))
5127 (setq threads (cdr threads)))
5130 (defun gnus-make-threads ()
5131 ;; This function takes the dependencies already made by
5132 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5133 ;; through the dependecies in the hash table and finds all the
5134 ;; roots. Roots do not refer back to any valid articles.
5136 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5137 (gnus-build-old-threads))
5140 (if (not (car (symbol-value refs)))
5141 (setq roots (append (cdr (symbol-value refs)) roots))
5142 ;; Ok, these refer back to valid articles, but if
5143 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5144 ;; the root has the same subject as its children. The children
5145 ;; that do not are made into roots and removed from the list
5147 (or gnus-thread-ignore-subject
5148 (let* ((prev (symbol-value refs))
5149 (subject (gnus-simplify-subject-re
5150 (header-subject (car prev))))
5151 (headers (cdr prev)))
5153 (if (not (string= subject
5154 (gnus-simplify-subject-re
5155 (header-subject (car headers)))))
5157 (setq roots (cons (car headers) roots))
5158 (setcdr prev (cdr headers)))
5159 (setq prev headers))
5160 (setq headers (cdr headers)))))))
5161 gnus-newsgroup-dependencies)
5163 (mapcar 'gnus-trim-thread
5165 (mapcar 'gnus-cut-thread
5166 (mapcar 'gnus-make-sub-thread roots))))))
5168 (defun gnus-make-threads-and-expunge ()
5169 ;; This function takes the dependencies already made by
5170 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5171 ;; through the dependecies in the hash table and finds all the
5172 ;; roots. Roots do not refer back to any valid articles.
5174 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5175 (gnus-build-old-threads))
5178 (if (not (car (symbol-value refs)))
5179 (if (and gnus-summary-expunge-below
5180 (not gnus-fetch-old-headers))
5181 (let ((headers (cdr (symbol-value refs))))
5183 (if (not (< (or (cdr (assq (header-number (car headers))
5184 gnus-newsgroup-scored))
5185 gnus-summary-default-score 0)
5186 gnus-summary-expunge-below))
5187 (setq roots (cons (car headers) roots))
5188 (setq gnus-newsgroup-unreads
5189 (delq (header-number (car headers))
5190 gnus-newsgroup-unreads)))
5191 (setq headers (cdr headers))))
5192 (setq roots (append (cdr (symbol-value refs)) roots)))
5193 ;; Ok, these refer back to valid articles, but if
5194 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5195 ;; the root has the same subject as its children. The children
5196 ;; that do not are made into roots and removed from the list
5198 (or gnus-thread-ignore-subject
5199 (let* ((prev (symbol-value refs))
5200 (subject (gnus-simplify-subject-re
5201 (header-subject (car prev))))
5202 (headers (cdr prev)))
5204 (if (not (string= subject
5205 (gnus-simplify-subject-re
5206 (header-subject (car headers)))))
5208 (setq roots (cons (car headers) roots))
5209 (setcdr prev (cdr headers)))
5210 (setq prev headers))
5211 (setq headers (cdr headers)))))
5212 (and gnus-summary-expunge-below
5213 (not gnus-fetch-old-headers)
5214 (let* ((prev (symbol-value refs))
5215 (headers (cdr prev))
5218 (if (not (< (or (cdr (assq (header-number (car headers))
5219 gnus-newsgroup-scored))
5220 gnus-summary-default-score 0)
5221 gnus-summary-expunge-below))
5222 (setq prev (cdr prev))
5223 (setq gnus-newsgroup-unreads
5224 (delq (header-number (car headers))
5225 gnus-newsgroup-unreads))
5226 (setcdr prev (cdr headers))
5227 (setq id (gnus-gethash (header-id (car headers))
5228 gnus-newsgroup-dependencies))
5231 (if (not (< (or (cdr (assq (header-number (car h))
5232 gnus-newsgroup-scored))
5233 gnus-summary-default-score 0)
5234 gnus-summary-expunge-below))
5235 (setq roots (cons (car h) roots)))
5237 (setq headers (cdr headers)))))))
5238 gnus-newsgroup-dependencies)
5240 (mapcar 'gnus-trim-thread
5242 (mapcar 'gnus-cut-thread
5243 (mapcar 'gnus-make-sub-thread roots))))))
5245 (defun gnus-cut-thread (thread)
5246 ;; Remove leaf dormant or ancient articles from THREAD.
5247 (let ((head (car thread))
5248 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
5249 (if (and (null tail)
5250 (let ((number (header-number head)))
5251 (or (memq number gnus-newsgroup-ancient)
5252 (memq number gnus-newsgroup-dormant)
5253 (and gnus-summary-expunge-below
5254 (eq gnus-fetch-old-headers 'some)
5255 (< (or (cdr (assq number gnus-newsgroup-scored))
5256 gnus-summary-default-score 0)
5257 gnus-summary-expunge-below)
5259 (setq gnus-newsgroup-unreads
5260 (delq number gnus-newsgroup-unreads))
5263 (list (cons head tail)))))
5265 (defun gnus-trim-thread (thread)
5266 ;; Remove root ancient articles with only one child from THREAD.
5267 (if (and (eq gnus-fetch-old-headers 'some)
5268 (memq (header-number (car thread)) gnus-newsgroup-ancient)
5269 (= (length thread) 2))
5270 (gnus-trim-thread (nth 1 thread))
5273 (defun gnus-make-sub-thread (root)
5274 ;; This function makes a sub-tree for a node in the tree.
5275 (let ((children (reverse (cdr (gnus-gethash (downcase (header-id root))
5276 gnus-newsgroup-dependencies)))))
5277 (cons root (mapcar 'gnus-make-sub-thread children))))
5279 (defun gnus-build-old-threads ()
5280 ;; Look at all the articles that refer back to old articles, and
5281 ;; fetch the headers for the articles that aren't there. This will
5282 ;; build complete threads - if the roots haven't been expired by the
5287 (if (not (car (symbol-value refs)))
5289 (setq heads (cdr (symbol-value refs)))
5291 (if (not (memq (header-number (car heads))
5292 gnus-newsgroup-dormant))
5294 (setq id (symbol-name refs))
5295 (while (and (setq id (gnus-build-get-header id))
5296 (not (car (gnus-gethash
5297 id gnus-newsgroup-dependencies)))))
5299 (setq heads (cdr heads)))))))
5300 gnus-newsgroup-dependencies)))
5302 (defun gnus-build-get-header (id)
5303 ;; Look through the buffer of NOV lines and find the header to
5304 ;; ID. Enter this line into the dependencies hash table, and return
5305 ;; the id of the parent article (if any).
5306 (let ((deps gnus-newsgroup-dependencies)
5310 (set-buffer nntp-server-buffer)
5311 (goto-char (point-min))
5312 (while (and (not found) (search-forward id nil t))
5314 (setq found (looking-at (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
5315 (regexp-quote id))))
5316 (or found (beginning-of-line 2)))
5321 (setq header (gnus-nov-parse-line
5322 (read (current-buffer)) deps))
5323 (setq ref (header-references header))
5324 (string-match "\\(<[^>]+>\\) *$" ref)
5325 (substring ref (match-beginning 1) (match-end 1))))))
5327 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
5328 gnus-newsgroup-ancient (cons (header-number header)
5329 gnus-newsgroup-ancient))))))
5331 (defun gnus-sort-threads (threads)
5332 ;; Sort threads as specified in `gnus-thread-sort-functions'.
5333 (let ((fun gnus-thread-sort-functions))
5335 (setq threads (sort threads (car fun))
5339 (defun gnus-thread-header (thread)
5340 ;; Return header of first article in THREAD.
5342 (if (stringp (car thread))
5343 (car (car (cdr thread)))
5347 (defun gnus-thread-sort-by-number (h1 h2)
5348 "Sort threads by root article number."
5349 (let ((h1 (gnus-thread-header h1))
5350 (h2 (gnus-thread-header h2)))
5351 (< (header-number h1) (header-number h2))))
5353 (defun gnus-thread-sort-by-author (h1 h2)
5354 "Sort threads by root author."
5355 (let ((h1 (gnus-thread-header h1))
5356 (h2 (gnus-thread-header h2)))
5358 (let ((extract (funcall
5359 gnus-extract-address-components (header-from h1))))
5360 (or (car extract) (cdr extract)))
5361 (let ((extract (funcall
5362 gnus-extract-address-components (header-from h2))))
5363 (or (car extract) (cdr extract))))))
5365 (defun gnus-thread-sort-by-subject (h1 h2)
5366 "Sort threads by root subject."
5367 (let ((h1 (gnus-thread-header h1))
5368 (h2 (gnus-thread-header h2)))
5370 (downcase (gnus-simplify-subject (header-subject h1)))
5371 (downcase (gnus-simplify-subject (header-subject h2))))))
5373 (defun gnus-thread-sort-by-date (h1 h2)
5374 "Sort threads by root article date."
5375 (let ((h1 (gnus-thread-header h1))
5376 (h2 (gnus-thread-header h2)))
5378 (gnus-sortable-date (header-date h1))
5379 (gnus-sortable-date (header-date h2)))))
5381 (defun gnus-thread-sort-by-score (h1 h2)
5382 "Sort threads by root article score.
5383 Unscored articles will be counted as havin a score of zero."
5384 (let ((h1 (gnus-thread-header h1))
5385 (h2 (gnus-thread-header h2)))
5386 (let ((s1 (assq (header-number h1) gnus-newsgroup-scored))
5387 (s2 (assq (header-number h2) gnus-newsgroup-scored)))
5388 (> (or (cdr s1) gnus-summary-default-score 0)
5389 (or (cdr s2) gnus-summary-default-score 0)))))
5391 (defun gnus-thread-sort-by-total-score (h1 h2)
5392 "Sort threads by the sum of all scores in the thread.
5393 Unscored articles will be counted as havin a score of zero."
5394 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5396 (defun gnus-thread-total-score (thread)
5397 ;; This function find the total score of THREAD.
5399 (if (stringp (car thread))
5400 (apply gnus-thread-score-function 0
5401 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5402 (gnus-thread-total-score-1 thread))
5403 (gnus-thread-total-score-1 (list thread))))
5405 (defun gnus-thread-total-score-1 (root)
5406 ;; This function find the total score of the thread below ROOT.
5407 (setq root (car root))
5408 (apply gnus-thread-score-function
5409 (or (cdr (assq (header-number root) gnus-newsgroup-scored))
5410 gnus-summary-default-score 0)
5411 (mapcar 'gnus-thread-total-score
5412 (cdr (gnus-gethash (downcase (header-id root))
5413 gnus-newsgroup-dependencies)))))
5415 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5416 (defvar gnus-tmp-prev-subject "")
5418 ;; Basic ideas by Paul Dworkin <paul@media-lab.media.mit.edu>.
5419 (defun gnus-summary-prepare-threads
5420 (threads level &optional not-child no-subject cull)
5421 "Prepare summary buffer from THREADS and indentation LEVEL.
5422 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5423 or a straight list of headers."
5424 (let (thread header number subject clevel)
5426 (setq thread (car threads)
5427 threads (cdr threads))
5428 ;; If `thread' is a cons, hierarchical threads are used. If not,
5429 ;; `thread' is the header.
5431 (setq header (car thread))
5432 (setq header thread)
5434 (or (memq (setq number (header-number header))
5435 gnus-newsgroup-dormant)
5436 (and gnus-summary-expunge-below
5437 (< (or (cdr (assq number gnus-newsgroup-scored))
5438 gnus-summary-default-score 0)
5439 gnus-summary-expunge-below)))
5442 (setq gnus-newsgroup-unreads
5443 (delq number gnus-newsgroup-unreads)))))
5446 ;; The header is a dummy root.
5447 (cond ((eq gnus-summary-make-false-root 'adopt)
5448 ;; We let the first article adopt the rest.
5449 (gnus-summary-prepare-threads (list (car (cdr thread))) 0)
5450 (setq thread (cdr (cdr thread)))
5452 (gnus-summary-prepare-threads (list (car thread)) 1 t)
5453 (setq thread (cdr thread))))
5454 ((eq gnus-summary-make-false-root 'dummy)
5455 ;; We output a dummy root.
5456 (gnus-summary-insert-dummy-line
5457 nil header (header-number (car (car (cdr thread)))))
5459 ((eq gnus-summary-make-false-root 'empty)
5460 ;; We print the articles with empty subject fields.
5461 (gnus-summary-prepare-threads (list (car (cdr thread))) 0)
5462 (setq thread (cdr (cdr thread)))
5464 (gnus-summary-prepare-threads
5465 (list (car thread)) 0 nil
5466 (not (and (eq gnus-summary-gather-subject-limit 'fuzzy)
5468 (gnus-simplify-subject-re
5469 (header-subject (car (car thread))))
5470 (gnus-simplify-subject-re header))))))
5471 (setq thread (cdr thread))))
5473 ;; We do not make a root for the gathered
5474 ;; sub-threads at all.
5476 ;; Print the sub-threads.
5477 (and (consp thread) (cdr thread)
5478 (gnus-summary-prepare-threads (cdr thread) clevel)))
5479 ;; The header is a real article.
5481 (setq number (header-number header)
5482 subject (header-subject header))
5483 (gnus-summary-insert-line
5484 nil header level nil
5485 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
5486 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
5487 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
5488 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
5489 (t gnus-ancient-mark))
5490 (memq number gnus-newsgroup-replied)
5491 (memq number gnus-newsgroup-expirable)
5493 gnus-summary-same-subject
5494 (if (or (zerop level)
5495 (and gnus-thread-ignore-subject
5497 (gnus-simplify-subject-re gnus-tmp-prev-subject)
5498 (gnus-simplify-subject-re subject)))))
5500 gnus-summary-same-subject))
5502 (cdr (assq number gnus-newsgroup-scored)))
5503 (setq gnus-tmp-prev-subject subject)
5504 ;; Recursively print subthreads.
5505 (and (consp thread) (cdr thread)
5506 (gnus-summary-prepare-threads (cdr thread) (1+ level))))))))
5508 (defun gnus-select-newsgroup (group &optional read-all)
5509 "Select newsgroup GROUP.
5510 If READ-ALL is non-nil, all articles in the group are selected."
5511 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5512 (info (nth 2 entry))
5513 articles header-marks)
5514 (gnus-check-news-server
5515 (setq gnus-current-select-method (gnus-find-method-for-group group)))
5517 (or (gnus-server-opened gnus-current-select-method)
5518 (gnus-open-server gnus-current-select-method)
5519 (error "Couldn't open server"))
5521 (or (and (eq (car entry) t)
5522 (gnus-activate-newsgroup (car info)))
5523 (gnus-request-group group t)
5525 (kill-buffer (current-buffer))
5526 (error "Couldn't request group %s: %s"
5527 group (gnus-status-message group))))
5529 (setq gnus-newsgroup-name group)
5530 (setq gnus-newsgroup-unselected nil)
5531 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5533 (if (not (setq articles (gnus-articles-to-read group read-all)))
5535 ;; Init the dependencies hash table.
5536 (setq gnus-newsgroup-dependencies
5537 (gnus-make-hashtable (length articles)))
5538 ;; Retrieve the headers and read them in.
5539 (setq gnus-newsgroup-headers
5540 (if (eq 'nov (setq gnus-headers-retrieved-by
5541 (gnus-retrieve-headers
5542 (if gnus-fetch-old-headers
5543 (cons 1 articles) articles)
5544 gnus-newsgroup-name)))
5546 (gnus-get-newsgroup-headers-xover articles))
5547 (gnus-get-newsgroup-headers)))
5548 ;; If we were to fetch old headers, but the backend didn't
5549 ;; support XOVER, then it is possible we fetched one article
5550 ;; that we shouldn't have. If that's the case, we pop it off the
5552 (and (not (eq gnus-headers-retrieved-by 'nov))
5553 gnus-fetch-old-headers
5554 gnus-newsgroup-headers
5555 (/= (header-number (car gnus-newsgroup-headers)) (car articles))
5556 (setq gnus-newsgroup-headers (cdr gnus-newsgroup-headers)))
5557 ;; Remove cancelled articles from the list of unread articles.
5558 (setq gnus-newsgroup-unreads
5559 (gnus-set-sorted-intersection
5560 gnus-newsgroup-unreads
5561 (mapcar (lambda (headers) (header-number headers))
5562 gnus-newsgroup-headers)))
5563 ;; Adjust and set lists of article marks.
5566 (gnus-adjust-marked-articles info)
5567 (setq gnus-newsgroup-marked
5568 (cdr (assq 'tick (setq marked (nth 3 info)))))
5569 (setq gnus-newsgroup-replied (cdr (assq 'reply marked)))
5570 (setq gnus-newsgroup-expirable (cdr (assq 'expire marked)))
5571 (setq gnus-newsgroup-killed (cdr (assq 'killed marked)))
5572 (setq gnus-newsgroup-bookmarks (cdr (assq 'bookmark marked)))
5573 (setq gnus-newsgroup-dormant (cdr (assq 'dormant marked)))
5574 (setq gnus-newsgroup-scored (cdr (assq 'score marked)))
5575 (setq gnus-newsgroup-processable nil)))
5576 ;; Check whether auto-expire is to be done in this group.
5577 (setq gnus-newsgroup-auto-expire
5578 (or (and (stringp gnus-auto-expirable-newsgroups)
5579 (string-match gnus-auto-expirable-newsgroups group))
5580 (memq 'auto-expire gnus-current-select-method)))
5581 ;; First and last article in this newsgroup.
5582 (and gnus-newsgroup-headers
5583 (setq gnus-newsgroup-begin
5584 (header-number (car gnus-newsgroup-headers)))
5585 (setq gnus-newsgroup-end
5586 (header-number (gnus-last-element gnus-newsgroup-headers))))
5587 (setq gnus-reffed-article-number -1)
5588 ;; GROUP is successfully selected.
5589 (or gnus-newsgroup-headers t))))
5591 (defun gnus-articles-to-read (group read-all)
5592 ;; Find out what articles the user wants to read.
5594 ;; Select all articles if `read-all' is non-nil, or if all the
5595 ;; unread articles are dormant articles.
5597 (= (length gnus-newsgroup-unreads)
5598 (length gnus-newsgroup-dormant)))
5599 (gnus-uncompress-range
5600 (gnus-gethash group gnus-active-hashtb))
5601 gnus-newsgroup-unreads))
5602 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5603 (scored (length scored-list))
5604 (number (length articles))
5605 (marked (+ (length gnus-newsgroup-marked)
5606 (length gnus-newsgroup-dormant)))
5609 (cond ((and (or (<= scored marked)
5611 (numberp gnus-large-newsgroup)
5612 (> number gnus-large-newsgroup))
5616 "How many articles from %s (default %d): "
5617 gnus-newsgroup-name number))))
5618 (if (string-equal input "")
5620 ((and (> scored marked) (< scored number))
5624 "%s %s (%d scored, %d total): "
5625 "How many articles from"
5626 group scored number))))
5627 (if (string-equal input "")
5632 (setq select (if (numberp select) select (string-to-number select)))
5635 (if (and (not (zerop scored)) (<= (abs select) scored))
5637 (setq articles (sort scored-list '<))
5638 (setq number (length articles)))
5639 (setq articles (copy-sequence articles)))
5641 (setq total-articles articles)
5643 (if (< (abs select) number)
5645 ;; Select the N oldest articles.
5646 (setcdr (nthcdr (1- (abs select)) articles) nil)
5647 ;; Select the N most recent articles.
5648 (setq articles (nthcdr (- number select) articles))))
5649 (setq gnus-newsgroup-unselected
5650 (gnus-sorted-intersection
5651 gnus-newsgroup-unreads
5652 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
5655 (defun gnus-killed-articles (killed articles)
5658 (if (inline (gnus-member-of-range (car articles) killed))
5659 (setq out (cons (car articles) out)))
5660 (setq articles (cdr articles)))
5663 (defun gnus-adjust-marked-articles (info &optional active)
5664 "Remove all marked articles that are no longer legal."
5665 (let ((marked-lists (nth 3 info))
5666 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
5668 ;; There are many types of marked articles.
5670 (setq m (cdr (setq prev (car marked-lists))))
5671 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
5672 ;; Make sure that all ticked articles are a subset of the
5673 ;; unread/unselected articles.
5675 (if (or (memq (car m) gnus-newsgroup-unreads)
5676 (memq (car m) gnus-newsgroup-unselected))
5678 (setcdr prev (cdr m)))
5680 ((eq 'score (car prev))
5681 ;; Scored articles should be a subset of
5682 ;; unread/unselected articles.
5684 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
5685 (memq (car (car m)) gnus-newsgroup-unreads))
5687 (setcdr prev (cdr m)))
5689 ((eq 'bookmark (car prev))
5690 ;; Bookmarks should be a subset of active articles.
5692 (if (< (car (car m)) (car active))
5693 (setcdr prev (cdr m))
5696 ((eq 'killed (car prev))
5697 ;; Articles that have been through the kill process are
5698 ;; to be a subset of active articles.
5699 (while (and m (< (or (and (numberp (car m)) (car m))
5702 (setcdr prev (cdr m))
5704 (if (and m (< (or (and (numberp (car m)) (car m))
5707 (setcar (if (numberp (car m)) m (car m)) (car active))))
5708 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
5709 ;; The replied and expirable articles have to be articles
5712 (if (< (car m) (car active))
5713 (setcdr prev (cdr m))
5716 (setq marked-lists (cdr marked-lists)))
5717 ;; Remove all lists that are empty.
5718 (setq marked-lists (nth 3 info))
5721 (while (= 1 (length (car marked-lists)))
5722 (setq marked-lists (cdr marked-lists)))
5723 (setq m (cdr (setq prev marked-lists)))
5725 (if (= 1 (length (car m)))
5726 (setcdr prev (cdr m))
5729 (setcar (nthcdr 3 info) marked-lists)))
5730 ;; Finally, if there are no marked lists at all left, and if there
5731 ;; are no elements after the lists in the info list, we just chop
5732 ;; the info list off before the marked lists.
5733 (and (null marked-lists)
5734 (not (nthcdr 4 info))
5735 (setcdr (nthcdr 2 info) nil)))
5738 (defun gnus-set-marked-articles
5739 (info ticked replied expirable killed dormant bookmark score)
5740 "Enter the various lists of marked articles into the newsgroup info list."
5742 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
5743 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
5744 (and expirable (setq newmarked (cons (cons 'expire expirable)
5746 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
5747 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
5748 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
5750 (and score (setq newmarked (cons (cons 'score score) newmarked)))
5753 (setcar (nthcdr 3 info) newmarked)
5754 (if (not (nthcdr 4 info))
5755 (setcdr (nthcdr 2 info) nil)
5756 (setcar (nthcdr 3 info) nil)))
5758 (setcdr (nthcdr 2 info) (cons newmarked nil))))))
5760 (defun gnus-add-marked-articles (group type articles &optional info force)
5761 ;; Add ARTICLES of TYPE to the info of GROUP.
5762 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
5763 ;; add, but replace marked articles of TYPE with ARTICLES.
5764 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
5767 (and (not (setq marked (nthcdr 3 info)))
5768 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
5769 (and (not (setq m (assq type (car marked))))
5770 (setcar marked (cons (cons type articles) (car marked))))
5773 (nconc m articles)))))
5775 (defun gnus-set-mode-line (where)
5776 "This function sets the mode line of the article or summary buffers.
5777 If WHERE is `summary', the summary mode line format will be used."
5778 (if (memq where gnus-updated-mode-lines)
5781 (set-buffer gnus-summary-buffer)
5782 (let* ((mformat (if (eq where 'article)
5783 gnus-article-mode-line-format-spec
5784 gnus-summary-mode-line-format-spec))
5785 (group-name gnus-newsgroup-name)
5786 (article-number (or gnus-current-article 0))
5787 (unread (- (length gnus-newsgroup-unreads)
5788 (length gnus-newsgroup-dormant)))
5789 (unread-and-unticked
5790 (- unread (length gnus-newsgroup-marked)))
5791 (unselected (length gnus-newsgroup-unselected))
5792 (unread-and-unselected
5793 (cond ((and (zerop unread-and-unticked)
5794 (zerop unselected)) "")
5796 (format "{%d more}" unread-and-unticked))
5797 (t (format "{%d(+%d) more}"
5798 unread-and-unticked unselected))))
5800 (if gnus-current-headers
5801 (header-subject gnus-current-headers) ""))
5802 (max-len (- (frame-width) gnus-mode-non-string-length)))
5803 (setq mode-string (eval mformat))
5804 (if (> (length mode-string) max-len)
5806 (concat (substring mode-string 0 (- max-len 3)) "...")))
5807 (setq mode-string (format (format "%%-%ds" max-len 5)
5809 (setq mode-line-buffer-identification mode-string)
5810 (set-buffer-modified-p t))))
5812 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5813 "Go through the HEADERS list and add all Xrefs to a hash table.
5814 The resulting hash table is returned, or nil if no Xrefs were found."
5815 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
5817 (gnus-group-foreign-p from-newsgroup)
5819 (assoc (symbol-name (car from-method))
5820 gnus-valid-select-methods))))
5821 (gnus-group-real-prefix from-newsgroup)))
5822 (xref-hashtb (make-vector 63 0))
5823 start group entry number xrefs header)
5825 (setq header (car headers))
5826 (if (and (setq xrefs (header-xref header))
5827 (not (memq (header-number header) unreads)))
5830 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
5831 (setq start (match-end 0))
5832 (setq group (concat prefix (substring xrefs (match-beginning 1)
5835 (string-to-int (substring xrefs (match-beginning 2)
5837 (if (setq entry (gnus-gethash group xref-hashtb))
5838 (setcdr entry (cons number (cdr entry)))
5839 (gnus-sethash group (cons number nil) xref-hashtb)))))
5840 (setq headers (cdr headers)))
5841 (if start xref-hashtb nil)))
5843 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
5844 "Look through all the headers and mark the Xrefs as read."
5845 (let ((virtual (memq 'virtual
5846 (assoc (symbol-name (car (gnus-find-method-for-group
5848 gnus-valid-select-methods)))
5849 name entry read info xref-hashtb idlist active num range exps method
5852 (set-buffer gnus-group-buffer)
5853 (if (setq xref-hashtb
5854 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5857 (if (string= from-newsgroup (setq name (symbol-name group)))
5859 (setq idlist (symbol-value group))
5860 ;; Dead groups are not updated.
5862 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5864 (if (stringp (setq nth4 (nth 4 info)))
5865 (setq nth4 (gnus-server-to-method nth4))))
5866 ;; Only do the xrefs if the group has the same
5867 ;; select method as the group we have just read.
5868 (or (gnus-methods-equal-p
5869 nth4 (gnus-find-method-for-group from-newsgroup))
5872 (setq method (gnus-find-method-for-group
5874 (and (equal (car nth4) (car method))
5875 (equal (nth 1 nth4) (nth 1 method))))
5876 gnus-use-cross-reference
5877 (or (not (eq gnus-use-cross-reference t))
5879 ;; Only do cross-references on subscribed
5880 ;; groups, if that is what is wanted.
5881 (<= (nth 1 info) 5)))
5884 ;; Set the new list of read articles in this group.
5885 (setq active (gnus-gethash name gnus-active-hashtb))
5886 ;; First peel off all illegal article numbers.
5889 (ticked (cdr (assq 'tick (nth 3 info))))
5890 (dormant (cdr (assq 'dormant (nth 3 info))))
5895 (if (or (> id (cdr active))
5899 (setq idlist (delq id idlist)))
5900 (and (memq id expirable)
5901 (setq exps (cons id exps)))
5902 (setq ids (cdr ids)))))
5903 ;; Update expirable articles.
5904 (gnus-add-marked-articles nil 'expirable exps info)
5905 (and (null (nth 2 info))
5907 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
5908 (setcar (nthcdr 2 info)
5912 (setq idlist (sort idlist '<)))))
5913 ;; Then we have to re-compute how many unread
5914 ;; articles there are in this group.
5919 (setq num (- (1+ (cdr active)) (car active))))
5920 ((not (listp (cdr range)))
5921 (setq num (- (cdr active) (- (1+ (cdr range))
5925 (if (numberp (car range))
5927 (setq num (+ num (- (1+ (cdr (car range)))
5928 (car (car range))))))
5929 (setq range (cdr range)))
5930 (setq num (- (cdr active) num))))
5931 ;; Update the number of unread articles.
5935 (length (cdr (assq 'tick (nth 3 info))))
5937 (cdr (assq 'dormant (nth 3 info)))))))
5938 ;; Update the group buffer.
5939 (gnus-group-update-group name t)))))))
5942 (defun gnus-methods-equal-p (m1 m2)
5943 (let ((m1 (or m1 gnus-select-method))
5944 (m2 (or m2 gnus-select-method)))
5946 (and (eq (car m1) (car m2))
5947 (or (not (memq 'address (assoc (symbol-name (car m1))
5948 gnus-valid-select-methods)))
5949 (equal (nth 1 m1) (nth 1 m2)))))))
5951 (defsubst gnus-header-value ()
5952 (buffer-substring (match-end 0) (save-excursion (end-of-line) (point))))
5954 (defun gnus-get-newsgroup-headers ()
5955 (setq gnus-article-internal-prepare-hook nil)
5956 (let ((cur nntp-server-buffer)
5957 (dependencies gnus-newsgroup-dependencies)
5959 headers char article id dep end)
5961 (set-buffer nntp-server-buffer)
5963 ;; Search to the beginning of the next header. Error messages
5964 ;; do not begin with 2 or 3.
5965 (while (re-search-forward "^[23][0-9]+ " nil t)
5966 (let ((header (make-vector 9 nil))
5967 (c (following-char))
5968 (case-fold-search t)
5970 from subject in-reply-to references ref)
5976 (header-set-number header (setq article (read cur)))
5977 ;; This implementation of this function, with nine
5978 ;; search-forwards instead of the one re-search-forward and
5979 ;; a case (which basically was the old function) is actually
5980 ;; about twice as fast, even though it looks messier. You
5981 ;; can't have everything, I guess. Speed and elegance
5982 ;; doesn't always come hand in hand.
5984 (narrow-to-region (point) (save-excursion
5985 (search-forward "\n.\n" nil t)))
5986 (if (search-forward "\nfrom: " nil t)
5987 (header-set-from header (gnus-header-value))
5988 (header-set-from header "(nobody)"))
5990 (if (search-forward "\nsubject: " nil t)
5991 (header-set-subject header (gnus-header-value))
5992 (header-set-subject header "(none)"))
5994 (and (search-forward "\nxref: " nil t)
5995 (header-set-xref header (gnus-header-value)))
5997 (and (search-forward "\nlines: " nil t)
5998 (header-set-lines header (read cur)))
6000 (and (search-forward "\ndate: " nil t)
6001 (header-set-date header (gnus-header-value)))
6003 (if (search-forward "\nmessage-id: " nil t)
6004 (header-set-id header (setq id (gnus-header-value)))
6005 ;; If there was no message-id, we just fake one to make
6006 ;; subsequent routines simpler.
6009 (setq id (concat "none+" (int-to-string
6010 (setq none-id (1+ none-id)))))))
6012 (if (search-forward "\nreferences: " nil t)
6014 (header-set-references header (gnus-header-value))
6015 (setq end (match-end 0))
6022 (search-backward ">" end t)
6025 (search-backward "<" end t)
6027 ;; Get the references from the in-reply-to header if there
6028 ;; ware no references and the in-reply-to header looks
6030 (if (and (search-forward "\nin-reply-to: " nil t)
6031 (setq in-reply-to (gnus-header-value))
6032 (string-match "<[^>]+>" in-reply-to))
6034 (header-set-references
6036 (setq ref (substring in-reply-to (match-beginning 0)
6038 (setq ref (downcase ref)))
6040 ;; We do some threading while we read the headers. The
6041 ;; message-id and the last reference are both entered into
6042 ;; the same hash table. Some tippy-toeing around has to be
6043 ;; done in case an article has arrived before the article
6044 ;; which it refers to.
6045 (if (boundp (setq dep (intern (downcase id) dependencies)))
6046 (if (car (symbol-value dep))
6047 ;; An article with this Message-ID has already
6048 ;; been seen, so we ignore this one, except we add
6049 ;; any additional Xrefs (in case the two articles
6050 ;; came from different servers.
6053 (car (symbol-value dep))
6054 (concat (or (header-xref (car (symbol-value dep))) "")
6055 (or (header-xref header) "")))
6057 (setcar (symbol-value dep) header))
6058 (set dep (list header)))
6061 (if (boundp (setq dep (intern ref dependencies)))
6062 (setcdr (symbol-value dep)
6063 (cons header (cdr (symbol-value dep))))
6064 (set dep (list nil header)))
6065 (setq headers (cons header headers))))
6066 (goto-char (point-max))))))
6067 (nreverse headers)))
6069 ;; The following macros and functions were written by Felix Lee
6070 ;; <flee@cse.psu.edu>.
6072 ;; This is almost 4x faster than (string-to-int (buffer-substring ... ))
6073 ;; primarily because of garbage collection. -jwz
6074 (defmacro gnus-read-integer (&optional point move-p)
6075 (` ((, (if move-p 'progn 'save-excursion))
6076 (,@ (if point (list (list 'goto-char point))))
6077 (if (and (<= (following-char) ?9)
6078 (>= (following-char) ?0))
6079 (read (current-buffer))
6082 (defmacro gnus-nov-skip-field ()
6083 '(search-forward "\t" eol 'end))
6085 (defmacro gnus-nov-field ()
6088 (progn (gnus-nov-skip-field) (1- (point)))))
6090 ;; Goes through the xover lines and returns a list of vectors
6091 (defun gnus-get-newsgroup-headers-xover (sequence)
6092 "Parse the news overview data in the server buffer, and return a
6093 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
6094 ;; Get the Xref when the users reads the articles since most/some
6095 ;; NNTP servers do not include Xrefs when using XOVER.
6096 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6097 (let ((cur nntp-server-buffer)
6098 (dependencies gnus-newsgroup-dependencies)
6100 number headers header)
6102 (set-buffer nntp-server-buffer)
6103 (goto-char (point-min))
6104 (while (and sequence (not (eobp)))
6105 (setq number (read cur))
6106 (while (and sequence (< (car sequence) number))
6107 (setq sequence (cdr sequence)))
6109 (eq number (car sequence))
6111 (setq sequence (cdr sequence))
6113 (inline (gnus-nov-parse-line number dependencies)))
6114 (setq headers (cons header headers)))))
6116 (setq headers (nreverse headers)))
6119 (defun gnus-nov-parse-line (number dependencies)
6120 "Point has to be after the number on the beginning of the line."
6122 header eol ref id dep)
6127 ;; overview: [num subject from date id refs chars lines misc]
6129 (narrow-to-region (point) eol)
6134 (gnus-nov-field) ; subject
6135 (gnus-nov-field) ; from
6136 (gnus-nov-field) ; date
6137 (setq id (or (gnus-nov-field)
6140 (setq none (1+ none)))))) ; id
6143 (let ((beg (point)))
6144 (search-forward "\t" eol)
6145 (if (search-backward ">" beg t)
6151 (search-backward "<" beg t)
6154 (gnus-nov-field)) ; refs
6155 (read (current-buffer)) ; chars
6156 (read (current-buffer)) ; lines
6157 (if (/= (following-char) ?\t)
6160 (gnus-nov-field)) ; misc
6165 ;; We build the thread tree.
6167 (if (boundp (setq dep (intern (downcase id) dependencies)))
6168 (if (car (symbol-value dep))
6169 ;; An article with this Message-ID has already been seen,
6170 ;; so we ignore this one, except we add any additional
6171 ;; Xrefs (in case the two articles came from different
6175 (car (symbol-value dep))
6176 (concat (or (header-xref (car (symbol-value dep))) "")
6177 (or (header-xref header) "")))
6179 (setcar (symbol-value dep) header))
6180 (set dep (list header))))
6183 (if (boundp (setq dep (intern (or ref "none")
6185 (setcdr (symbol-value dep)
6186 (cons header (cdr (symbol-value dep))))
6187 (set dep (list nil header)))))
6190 (defun gnus-article-get-xrefs ()
6191 "Fill in the Xref value in `gnus-current-headers', if necessary.
6192 This is meant to be called in `gnus-article-internal-prepare-hook'."
6193 (or (not gnus-use-cross-reference)
6194 (header-xref gnus-current-headers)
6195 (let ((case-fold-search t)
6198 (gnus-narrow-to-headers)
6199 (goto-char (point-min))
6200 (if (or (and (eq (downcase (following-char)) ?x)
6201 (looking-at "Xref:"))
6202 (search-forward "\nXref:" nil t))
6204 (goto-char (1+ (match-end 0)))
6205 (setq xref (buffer-substring (point)
6206 (progn (end-of-line) (point))))
6208 (set-buffer gnus-summary-buffer)
6209 (header-set-xref gnus-current-headers xref))))))))
6211 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
6212 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
6214 ;; Return a header specified by a NUMBER.
6215 (defun gnus-get-header-by-number (number)
6217 (set-buffer gnus-summary-buffer)
6218 (or gnus-newsgroup-headers-hashtb-by-number
6219 (gnus-make-headers-hashtable-by-number))
6220 (gnus-gethash (int-to-string number)
6221 gnus-newsgroup-headers-hashtb-by-number)))
6223 (defun gnus-make-headers-hashtable-by-number ()
6224 "Make hashtable for the variable gnus-newsgroup-headers by number."
6226 (set-buffer gnus-summary-buffer)
6227 (let ((headers gnus-newsgroup-headers)
6229 (setq gnus-newsgroup-headers-hashtb-by-number
6230 (gnus-make-hashtable (length headers)))
6232 (setq header (car headers))
6233 (gnus-sethash (int-to-string (header-number header))
6234 header gnus-newsgroup-headers-hashtb-by-number)
6235 (setq headers (cdr headers))))))
6237 (defun gnus-more-header-backward ()
6238 "Find new header backward."
6239 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6240 (artnum gnus-newsgroup-begin)
6242 (while (and (not header)
6244 (setq artnum (1- artnum))
6245 (setq header (gnus-read-header artnum)))
6248 (defun gnus-more-header-forward (&optional backward)
6249 "Find new header forward.
6250 If BACKWARD, find new header backward instead."
6252 (gnus-more-header-backward)
6253 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6254 (artnum gnus-newsgroup-end)
6256 (while (and (not header)
6258 (setq artnum (1+ artnum))
6259 (setq header (gnus-read-header artnum)))
6262 (defun gnus-extend-newsgroup (header &optional backward)
6263 "Extend newsgroup selection with HEADER.
6264 Optional argument BACKWARD means extend toward backward."
6266 (let ((artnum (header-number header)))
6267 (setq gnus-newsgroup-headers
6269 (cons header gnus-newsgroup-headers)
6270 (nconc gnus-newsgroup-headers (list header))))
6271 (setq gnus-newsgroup-unselected
6272 (delq artnum gnus-newsgroup-unselected))
6273 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
6274 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
6276 (defun gnus-summary-work-articles (n)
6277 "Return a list of articles to be worked upon. The prefix argument,
6278 the list of process marked articles, and the current article will be
6279 taken into consideration."
6281 (if (and n (numberp n))
6282 (let ((backward (< n 0))
6286 (setq articles (cons (gnus-summary-article-number)
6288 (gnus-summary-search-forward nil nil backward))
6290 (sort articles (function <)))
6291 (or (reverse gnus-newsgroup-processable)
6292 (list (gnus-summary-article-number))))))
6294 (defun gnus-summary-search-group (&optional backward use-level)
6295 "Search for next unread newsgroup.
6296 If optional argument BACKWARD is non-nil, search backward instead."
6298 (set-buffer gnus-group-buffer)
6300 ;; We don't want to alter current point of group mode buffer.
6301 (if (gnus-group-search-forward
6303 (if use-level (gnus-group-group-level) nil))
6304 (gnus-group-group-name)))))
6306 (defun gnus-summary-best-group (&optional exclude-group)
6307 "Find the name of the best unread group.
6308 If EXCLUDE-GROUP, do not go to this group."
6310 (set-buffer gnus-group-buffer)
6312 (gnus-group-best-unread-group exclude-group))))
6314 (defun gnus-summary-search-subject (&optional backward unread subject)
6315 "Search for article forward.
6316 If BACKWARD is non-nil, search backward.
6317 If UNREAD is non-nil, only unread articles are selected.
6318 If SUBJECT is non-nil, the article which has the same subject will be
6320 (let ((func (if backward 'previous-single-property-change
6321 'next-single-property-change))
6326 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
6327 (while (and (setq pos (funcall func (point) 'gnus-number))
6328 (goto-char (if backward (1- pos) pos))
6330 (not (and (or (not unread)
6331 (eq (get-text-property (point) 'gnus-mark)
6334 (equal (gnus-simplify-subject-re
6336 (gnus-simplify-subject-re
6339 'gnus-subject)))))))
6340 (if backward (if (bobp) nil (forward-char -1) t)
6341 (if (eobp) nil (forward-char 1) t))))
6343 (progn (goto-char beg) nil)
6345 (get-text-property (point) 'gnus-number)
6346 (gnus-summary-position-cursor)))))
6348 (defun gnus-summary-search-forward (&optional unread subject backward)
6349 "Search for article forward.
6350 If UNREAD is non-nil, only unread articles are selected.
6351 If SUBJECT is non-nil, the article which has the same subject will be
6353 If BACKWARD is non-nil, the search will be performed backwards instead."
6354 (gnus-summary-search-subject backward unread subject))
6356 (defun gnus-summary-search-backward (&optional unread subject)
6357 "Search for article backward.
6358 If 1st optional argument UNREAD is non-nil, only unread article is selected.
6359 If 2nd optional argument SUBJECT is non-nil, the article which has
6360 the same subject will be searched for."
6361 (gnus-summary-search-forward unread subject t))
6363 (defun gnus-summary-article-number (&optional number-or-nil)
6364 "The article number of the article on the current line.
6365 If there isn's an article number here, then we return the current
6368 (number (get-text-property
6369 (progn (beginning-of-line) (prog1 (point) (goto-char p)))
6371 (if number-or-nil number (or number gnus-current-article))))
6373 (defun gnus-summary-thread-level ()
6374 "The thread level of the article on the current line."
6375 (or (get-text-property
6376 (save-excursion (beginning-of-line) (point)) 'gnus-thread)
6379 (defun gnus-summary-pseudo-article ()
6380 "The thread level of the article on the current line."
6382 (save-excursion (beginning-of-line) (point)) 'gnus-pseudo))
6384 (defun gnus-summary-article-mark ()
6385 "The mark on the current line."
6386 (get-text-property (save-excursion (beginning-of-line) (point)) 'gnus-mark))
6388 (defun gnus-summary-subject-string ()
6389 "Return current subject string or nil if nothing."
6391 (save-excursion (beginning-of-line) (point)) 'gnus-subject))
6393 (defalias 'gnus-summary-score 'gnus-summary-article-score)
6394 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
6395 (defun gnus-summary-article-score ()
6396 "Return current article score."
6397 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
6398 gnus-summary-default-score 0))
6400 (defun gnus-summary-recenter ()
6401 "Center point in the summary window.
6402 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6403 displayed, no centering will be performed."
6404 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6405 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6406 (let ((top (cond ((< (window-height) 4) 0)
6407 ((< (window-height) 6) 1)
6410 ;; The user has to want it,
6411 gnus-auto-center-summary
6412 ;; the article buffer must be displayed,
6413 (get-buffer-window gnus-article-buffer)
6414 ;; there must be lines left to scroll forward,
6415 (zerop (save-excursion (forward-line (- (window-height) 1 top))))
6418 (get-buffer-window (current-buffer))
6419 (save-excursion (forward-line (- top)) (point))))))
6421 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
6422 (defun gnus-short-group-name (newsgroup)
6423 "Convert a long group name to an initialized form.
6424 The last part of the name is left intact: \"rec.arts.anime\" becomes
6428 (if (string-match "\\." newsgroup)
6430 (setq name (concat name (substring newsgroup 0 1))
6431 newsgroup (substring newsgroup (match-end 0))
6432 name (concat name ".")))
6433 (setq name (concat name newsgroup)
6438 (defun gnus-summary-jump-to-group (newsgroup)
6439 "Move point to NEWSGROUP in group mode buffer."
6440 ;; Keep update point of group mode buffer if visible.
6441 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6442 (save-window-excursion
6443 ;; Take care of tree window mode.
6444 (if (get-buffer-window gnus-group-buffer)
6445 (pop-to-buffer gnus-group-buffer))
6446 (gnus-group-jump-to-group newsgroup))
6448 ;; Take care of tree window mode.
6449 (if (get-buffer-window gnus-group-buffer)
6450 (pop-to-buffer gnus-group-buffer)
6451 (set-buffer gnus-group-buffer))
6452 (gnus-group-jump-to-group newsgroup))))
6454 ;; This function returns a list of article numbers based on the
6455 ;; difference between the ranges of read articles in this group and
6456 ;; the range of active articles.
6457 (defun gnus-list-of-unread-articles (group)
6458 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6459 (active (gnus-gethash group gnus-active-hashtb))
6461 unread first nlast unread)
6462 ;; If none are read, then all are unread.
6464 (setq first (car active))
6465 ;; If the range of read articles is a single range, then the
6466 ;; first unread article is the article after the last read
6467 ;; article. Sounds logical, doesn't it?
6468 (if (not (listp (cdr read)))
6469 (setq first (1+ (cdr read)))
6470 ;; `read' is a list of ranges.
6471 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
6472 (car (car read)))) 1)
6476 (while (< first nlast)
6477 (setq unread (cons first unread))
6478 (setq first (1+ first))))
6479 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
6480 (setq nlast (if (atom (car (cdr read)))
6482 (car (car (cdr read)))))
6483 (setq read (cdr read)))))
6484 ;; And add the last unread articles.
6485 (while (<= first last)
6486 (setq unread (cons first unread))
6487 (setq first (1+ first)))
6488 ;; Return the list of unread articles.
6492 ;; Various summary commands
6494 (defun gnus-summary-universal-argument ()
6495 "Perform any operation on all articles marked with the process mark."
6497 (gnus-set-global-variables)
6498 (let ((articles (reverse gnus-newsgroup-processable))
6500 (or articles (error "No articles marked"))
6501 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
6502 (error "Undefined key"))
6504 (gnus-summary-goto-subject (car articles))
6505 (command-execute func)
6506 (gnus-summary-remove-process-mark (car articles))
6507 (setq articles (cdr articles)))))
6509 (defun gnus-summary-toggle-truncation (arg)
6510 "Toggle truncation of summary lines.
6511 With arg, turn line truncation on iff arg is positive."
6513 (setq truncate-lines
6514 (if (null arg) (not truncate-lines)
6515 (> (prefix-numeric-value arg) 0)))
6518 (defun gnus-summary-reselect-current-group (all)
6519 "Once exit and then reselect the current newsgroup.
6520 The prefix argument ALL means to select all articles."
6522 (gnus-set-global-variables)
6523 (let ((current-subject (gnus-summary-article-number)))
6524 (gnus-summary-exit t)
6525 ;; We have to adjust the point of group mode buffer because the
6526 ;; current point was moved to the next unread newsgroup by
6528 (gnus-summary-jump-to-group gnus-newsgroup-name)
6529 (gnus-group-read-group all t)
6530 (gnus-summary-goto-subject current-subject)))
6532 (defun gnus-summary-rescan-group (all)
6533 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6535 (gnus-set-global-variables)
6536 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
6537 (let ((group gnus-newsgroup-name))
6538 (gnus-summary-exit t)
6539 (gnus-summary-jump-to-group group)
6541 (set-buffer gnus-group-buffer)
6542 (gnus-group-get-new-news-this-group 1))
6543 (gnus-summary-jump-to-group group)
6544 (gnus-group-read-group all)))
6546 (defun gnus-summary-exit (&optional temporary)
6547 "Exit reading current newsgroup, and then return to group selection mode.
6548 gnus-exit-group-hook is called with no arguments if that value is non-nil."
6550 (gnus-set-global-variables)
6551 (gnus-kill-save-kill-buffer)
6552 (let* ((group gnus-newsgroup-name)
6553 (quit-buffer (cdr (assoc 'quit-buffer (gnus-find-method-for-group
6554 gnus-newsgroup-name))))
6556 (method (car (gnus-find-method-for-group group)))
6557 (buf (current-buffer)))
6558 (if gnus-newsgroup-kill-headers
6559 (setq gnus-newsgroup-killed
6560 (gnus-compress-sequence
6562 (gnus-set-sorted-intersection
6563 (gnus-uncompress-range gnus-newsgroup-killed)
6564 (setq gnus-newsgroup-unselected
6565 (sort gnus-newsgroup-unselected '<)))
6566 (setq gnus-newsgroup-unreads
6567 (sort gnus-newsgroup-unreads '<))) t)))
6568 (or (listp (cdr gnus-newsgroup-killed))
6569 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6571 (headers gnus-newsgroup-headers))
6572 (gnus-close-group group)
6573 (run-hooks 'gnus-exit-group-hook)
6575 (gnus-update-read-articles
6576 group gnus-newsgroup-unreads gnus-newsgroup-unselected
6577 gnus-newsgroup-marked
6578 t gnus-newsgroup-replied gnus-newsgroup-expirable
6579 gnus-newsgroup-killed gnus-newsgroup-dormant
6580 gnus-newsgroup-bookmarks
6581 (and gnus-save-score gnus-newsgroup-scored))
6582 (and gnus-use-cross-reference
6583 (gnus-mark-xrefs-as-read
6584 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
6585 ;; Do not switch windows but change the buffer to work.
6586 (set-buffer gnus-group-buffer)
6587 (or (eq 'nndigest method)
6588 (gnus-group-update-group group)))
6589 ;; Make sure where I was, and go to next newsgroup.
6590 (if (eq method 'nndigest)
6592 (gnus-group-jump-to-group group)
6593 (gnus-group-next-unread-group 1))
6595 ;; If exiting temporary, caller should adjust group mode
6596 ;; buffer point by itself.
6598 ;; We set all buffer-local variables to nil. It is unclear why
6599 ;; this is needed, but if we don't, buffer-local variables are
6600 ;; not garbage-collected, it seems. This would the lead to en
6601 ;; ever-growing Emacs.
6603 (gnus-summary-clear-local-variables)
6604 ;; We clear the global counterparts of the buffer-local
6605 ;; variables as well, just to be on the safe side.
6606 (set-buffer gnus-group-buffer)
6607 (gnus-summary-clear-local-variables)
6608 (gnus-configure-windows 'newsgroups t)
6609 ;; Return to group mode buffer.
6610 (and (get-buffer buf)
6611 (eq mode 'gnus-summary-mode)
6613 (if (get-buffer gnus-article-buffer)
6614 (bury-buffer gnus-article-buffer))
6615 (setq gnus-current-select-method gnus-select-method)
6616 (pop-to-buffer gnus-group-buffer)
6617 (if (and quit-buffer (buffer-name quit-buffer))
6619 (switch-to-buffer quit-buffer)
6620 (gnus-set-global-variables)
6621 (gnus-configure-windows 'summary))))))
6623 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6624 (defun gnus-summary-exit-no-update (&optional no-questions)
6625 "Quit reading current newsgroup without updating read article info."
6627 (let* ((group gnus-newsgroup-name)
6628 (quit-buffer (cdr (assoc 'quit-buffer
6629 (gnus-find-method-for-group group)))))
6630 (if (or no-questions
6632 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
6634 (gnus-close-group group)
6635 (gnus-summary-clear-local-variables)
6636 (set-buffer gnus-group-buffer)
6637 (gnus-summary-clear-local-variables)
6638 ;; Return to group selection mode.
6639 (gnus-configure-windows 'newsgroups)
6640 (if (get-buffer gnus-summary-buffer)
6641 (kill-buffer gnus-summary-buffer))
6642 (if (get-buffer gnus-article-buffer)
6643 (bury-buffer gnus-article-buffer))
6644 (pop-to-buffer gnus-group-buffer)
6645 (gnus-group-jump-to-group group)
6646 (gnus-group-next-group 1)
6647 (if (and quit-buffer (buffer-name quit-buffer))
6649 (switch-to-buffer quit-buffer)
6650 (gnus-configure-windows 'summary)))))))
6652 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6653 (defun gnus-summary-fetch-faq (group)
6654 "Fetch the FAQ for the current group."
6655 (interactive (list gnus-newsgroup-name))
6656 (gnus-configure-windows 'article)
6657 (pop-to-buffer gnus-article-buffer)
6658 (find-file (concat gnus-group-faq-directory group)))
6660 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6661 (defun gnus-summary-describe-group (force)
6662 "Describe the current newsgroup."
6664 (gnus-group-describe-group force gnus-newsgroup-name))
6666 (defun gnus-summary-describe-briefly ()
6667 "Describe summary mode commands briefly."
6670 (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")))
6672 ;; Walking around group mode buffer from summary mode.
6674 (defun gnus-summary-next-group (&optional no-article group backward)
6675 "Exit current newsgroup and then select next unread newsgroup.
6676 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
6677 If BACKWARD, go to previous group instead."
6679 (gnus-set-global-variables)
6680 (let ((ingroup gnus-newsgroup-name)
6681 (sumbuf (current-buffer))
6683 (gnus-summary-exit t) ;Update all information.
6685 (or (and (numberp (setq num (car (gnus-gethash
6686 group gnus-newsrc-hashtb))))
6690 (gnus-group-jump-to-group group)
6692 (gnus-group-jump-to-group ingroup))
6693 (let ((group (or group (gnus-summary-search-group backward)))
6694 (buf gnus-summary-buffer))
6696 (gnus-summary-exit-no-update t)
6697 (message "Selecting %s..." group)
6698 ;; We are now in group mode buffer.
6699 ;; Make sure group mode buffer point is on GROUP.
6700 (gnus-group-jump-to-group group)
6702 (gnus-summary-read-group group nil no-article buf)
6703 (and (string= gnus-newsgroup-name ingroup)
6704 (bufferp sumbuf) (buffer-name sumbuf)
6706 (set-buffer (setq gnus-summary-buffer sumbuf))
6707 (gnus-summary-exit-no-update t))))))))
6709 (defun gnus-summary-prev-group (no-article)
6710 "Exit current newsgroup and then select previous unread newsgroup.
6711 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6713 (gnus-summary-next-group no-article nil t))
6715 ;; Walking around summary lines.
6717 (defun gnus-summary-first-subject (unread)
6718 "Go to the first unread subject.
6719 If UNREAD is non-nil, go to the first unread article.
6720 Returns nil if there are no unread articles."
6722 (let ((begin (point)))
6724 (if (not (gnus-goto-char
6725 (text-property-any (point-min) (point-max)
6726 'gnus-mark gnus-unread-mark)))
6728 ;; If there is no unread articles, stay where you are.
6730 (message "No more unread articles")
6733 (goto-char (point-min)))))
6735 (defun gnus-summary-next-subject (n &optional unread)
6736 "Go to next N'th summary line.
6737 If N is negative, go to the previous N'th subject line.
6738 If UNREAD is non-nil, only unread articles are selected.
6739 The difference between N and the actual number of steps taken is
6742 (let ((backward (< n 0))
6745 (gnus-summary-search-forward unread nil backward))
6747 (gnus-summary-recenter)
6748 (if (/= 0 n) (message "No more%s articles" (if unread " unread" "")))
6749 (gnus-summary-position-cursor)
6752 (defun gnus-summary-next-unread-subject (n)
6753 "Go to next N'th unread summary line."
6755 (gnus-summary-next-subject n t))
6757 (defun gnus-summary-prev-subject (n &optional unread)
6758 "Go to previous N'th summary line.
6759 If optional argument UNREAD is non-nil, only unread article is selected."
6761 (gnus-summary-next-subject (- n) unread))
6763 (defun gnus-summary-prev-unread-subject (n)
6764 "Go to previous N'th unread summary line."
6766 (gnus-summary-next-subject (- n) t))
6768 (defun gnus-summary-goto-subject (article)
6769 "Go the subject line of ARTICLE."
6773 (completing-read "Article number: "
6777 (int-to-string (header-number headers))))
6778 gnus-newsgroup-headers)
6779 nil 'require-match))))
6780 (or article (error "No article number"))
6781 (if (or (eq article (gnus-summary-article-number t))
6784 (point-min) (point-max) 'gnus-number article)))
6787 ;; Walking around summary lines with displaying articles.
6789 (defun gnus-summary-expand-window ()
6790 "Expand summary window to show headers full window."
6792 (gnus-set-global-variables)
6793 (gnus-configure-windows 'summary)
6794 (pop-to-buffer gnus-summary-buffer))
6796 (defun gnus-summary-display-article (article &optional all-header)
6797 "Display ARTICLE in article buffer."
6798 (gnus-set-global-variables)
6801 (gnus-article-prepare article all-header)
6802 (if (eq (gnus-summary-article-mark) ?Z)
6805 (gnus-summary-position-cursor)))
6806 (run-hooks 'gnus-select-article-hook)
6807 (gnus-summary-recenter)
6808 ; (set-window-point (get-buffer-window (current-buffer)) (point-max))
6810 (gnus-summary-goto-subject article)
6811 ;; Successfully display article.
6812 (gnus-summary-update-line)
6815 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6816 "Select the current article.
6817 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6818 non-nil, the article will be re-fetched even if it already present in
6819 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6821 (and (not pseudo) (gnus-summary-pseudo-article)
6822 (error "This is a pseudo-article."))
6823 (let ((article (or article (gnus-summary-article-number)))
6824 (all-headers (not (not all-headers)))) ;Must be T or NIL.
6825 (if (or (null gnus-current-article)
6826 (null gnus-article-current)
6827 (/= article (cdr gnus-article-current))
6828 (not (equal (car gnus-article-current) gnus-newsgroup-name))
6830 ;; The requested article is different from the current article.
6832 (gnus-summary-display-article article all-headers)
6834 (if all-headers (gnus-article-show-all-headers))
6835 (gnus-configure-windows 'article)
6836 (pop-to-buffer gnus-summary-buffer)
6839 (defun gnus-summary-set-current-mark (&optional current-mark)
6840 "Obsolete function."
6843 (defun gnus-summary-next-article (unread &optional subject backward)
6844 "Select the next article.
6845 If UNREAD, only unread articles are selected.
6846 If SUBJECT, only articles with SUBJECT are selected.
6847 If BACKWARD, the previous article is selected instead of the next."
6849 (let ((opoint (point))
6850 (method (car (gnus-find-method-for-group gnus-newsgroup-name)))
6853 ;; Is there such an article?
6854 ((gnus-summary-display-article
6855 (gnus-summary-search-forward unread subject backward))
6856 (gnus-summary-position-cursor))
6857 ;; If not, we try the first unread, if that is wanted.
6859 gnus-auto-select-same
6860 (gnus-summary-first-unread-article))
6861 (message "Wrapped"))
6862 ;; Try to get next/previous article not displayed in this group.
6863 ((and gnus-auto-extend-newsgroup
6864 (not unread) (not subject)
6865 (setq header (gnus-more-header-forward backward)))
6866 (gnus-extend-newsgroup header backward)
6867 (let ((buffer-read-only nil))
6868 (goto-char (if backward (point-min) (point-max)))
6869 (gnus-summary-prepare-threads (list header) 0))
6870 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
6871 gnus-newsgroup-end)))
6872 ;; Go to next/previous group.
6874 (gnus-summary-jump-to-group gnus-newsgroup-name)
6875 (let ((cmd (aref (this-command-keys) 0))
6877 (if (eq gnus-keep-same-level 'best)
6878 (gnus-summary-best-group gnus-newsgroup-name)
6879 (gnus-summary-search-group backward gnus-keep-same-level))))
6880 ;; Keep just the event type of CMD.
6881 (and (listp cmd) (setq cmd (car cmd)))
6882 ;; Select next unread newsgroup automagically.
6884 ((not gnus-auto-select-next)
6885 (message "No more%s articles" (if unread " unread" "")))
6886 ((eq gnus-auto-select-next 'quietly)
6888 (if (eq method 'nndigest)
6890 (message "No more%s articles (%s)..."
6891 (if unread " unread" "")
6892 (if group (concat "selecting " group)
6894 (gnus-summary-next-group nil group backward)))
6896 (let ((keystrokes '(?\C-n ?\C-p))
6898 (while (or (null key) (memq key keystrokes))
6900 "No more%s articles%s" (if unread " unread" "")
6901 (if (and group (not (eq method 'nndigest)))
6902 (format " (Type %s for %s [%s])"
6903 (single-key-description cmd) group
6904 (car (gnus-gethash group gnus-newsrc-hashtb)))
6905 (format " (Type %s to exit %s)"
6906 (single-key-description cmd)
6907 gnus-newsgroup-name)))
6908 ;; Confirm auto selection.
6909 (let* ((event (read-event)))
6910 (setq key (if (listp event) (car event) event))
6911 (if (member key keystrokes)
6912 (let ((obuf (current-buffer)))
6913 (switch-to-buffer gnus-group-buffer)
6914 (gnus-group-jump-to-group group)
6915 (execute-kbd-macro (char-to-string key))
6916 (setq group (gnus-group-group-name))
6917 (switch-to-buffer obuf)))))
6919 (if (or (not group) (eq method 'nndigest))
6921 (gnus-summary-next-group nil group backward))
6922 (setq unread-command-events (list key)))))))))))
6924 (defun gnus-summary-next-unread-article ()
6925 "Select unread article after current one."
6927 (gnus-summary-next-article t (and gnus-auto-select-same
6928 (gnus-summary-subject-string))))
6930 (defun gnus-summary-prev-article (unread &optional subject)
6931 "Select the article after the current one.
6932 If UNREAD is non-nil, only unread articles are selected."
6934 (gnus-summary-next-article unread subject t))
6936 (defun gnus-summary-prev-unread-article ()
6937 "Select unred article before current one."
6939 (gnus-summary-prev-article t (and gnus-auto-select-same
6940 (gnus-summary-subject-string))))
6942 (defun gnus-summary-next-page (lines &optional circular)
6943 "Show next page of selected article.
6944 If end of article, select next article.
6945 Argument LINES specifies lines to be scrolled up.
6946 If CIRCULAR is non-nil, go to the start of the article instead of
6947 instead of selecting the next article when reaching the end of the
6950 (setq gnus-summary-buffer (current-buffer))
6951 (let ((article (gnus-summary-article-number))
6953 (if (or (null gnus-current-article)
6954 (null gnus-article-current)
6955 (/= article (cdr gnus-article-current))
6956 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6957 ;; Selected subject is different from current article's.
6958 (gnus-summary-display-article article)
6959 (gnus-configure-windows 'article)
6960 (pop-to-buffer gnus-summary-buffer)
6961 (gnus-eval-in-buffer-window
6963 (setq endp (gnus-article-next-page lines)))
6966 (gnus-summary-beginning-of-article))
6968 (message "End of message"))
6970 (gnus-summary-next-unread-article))))))
6971 (gnus-summary-position-cursor))
6973 (defun gnus-summary-prev-page (lines)
6974 "Show previous page of selected article.
6975 Argument LINES specifies lines to be scrolled down."
6977 (let ((article (gnus-summary-article-number)))
6978 (if (or (null gnus-current-article)
6979 (null gnus-article-current)
6980 (/= article (cdr gnus-article-current))
6981 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6982 ;; Selected subject is different from current article's.
6983 (gnus-summary-display-article article)
6984 (gnus-configure-windows 'article)
6985 (pop-to-buffer gnus-summary-buffer)
6986 (gnus-eval-in-buffer-window gnus-article-buffer
6987 (gnus-article-prev-page lines))))
6988 (gnus-summary-position-cursor))
6990 (defun gnus-summary-scroll-up (lines)
6991 "Scroll up (or down) one line current article.
6992 Argument LINES specifies lines to be scrolled up (or down if negative)."
6994 (or (gnus-summary-select-article nil nil 'pseudo)
6995 (gnus-eval-in-buffer-window
6998 (if (gnus-article-next-page lines)
6999 (message "End of message")))
7001 (gnus-article-prev-page (- lines))))))
7002 (gnus-summary-position-cursor))
7004 (defun gnus-summary-next-same-subject ()
7005 "Select next article which has the same subject as current one."
7007 (gnus-summary-next-article nil (gnus-summary-subject-string)))
7009 (defun gnus-summary-prev-same-subject ()
7010 "Select previous article which has the same subject as current one."
7012 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
7014 (defun gnus-summary-next-unread-same-subject ()
7015 "Select next unread article which has the same subject as current one."
7017 (gnus-summary-next-article t (gnus-summary-subject-string)))
7019 (defun gnus-summary-prev-unread-same-subject ()
7020 "Select previous unread article which has the same subject as current one."
7022 (gnus-summary-prev-article t (gnus-summary-subject-string)))
7024 (defun gnus-summary-first-unread-article ()
7025 "Select the first unread article.
7026 Return nil if there are no unread articles."
7029 (if (gnus-summary-first-subject t)
7030 (gnus-summary-display-article (gnus-summary-article-number)))
7031 (gnus-summary-position-cursor)))
7033 (defun gnus-summary-best-unread-article ()
7034 "Select the unread article with the highest score."
7036 (gnus-set-global-variables)
7037 (let ((scored gnus-newsgroup-scored)
7041 (or (> best (cdr (car scored)))
7042 (and (memq (setq art (car (car scored))) gnus-newsgroup-unreads)
7043 (not (memq art gnus-newsgroup-marked))
7044 (not (memq art gnus-newsgroup-dormant))
7045 (if (= best (cdr (car scored)))
7046 (setq article (min art article))
7048 (setq best (cdr (car scored))))))
7049 (setq scored (cdr scored)))
7051 (gnus-summary-goto-article article)
7052 (gnus-summary-first-unread-article))
7053 (gnus-summary-position-cursor)))
7055 (defun gnus-summary-goto-article (article &optional all-headers)
7056 "Fetch ARTICLE and display it if it exists.
7057 If ALL-HEADERS is non-nil, no header lines are hidden."
7063 (mapcar (lambda (headers) (list (int-to-string (header-number headers))))
7064 gnus-newsgroup-headers)
7065 nil 'require-match))))
7066 (if (gnus-summary-goto-subject article)
7067 (gnus-summary-display-article article all-headers))
7068 (gnus-summary-position-cursor))
7070 (defun gnus-summary-goto-last-article ()
7071 "Go to the last article."
7073 (if gnus-last-article
7074 (gnus-summary-goto-article gnus-last-article))
7075 (gnus-summary-position-cursor))
7077 (defun gnus-summary-pop-article (number)
7078 "Pop one article off the history and go to the previous.
7079 NUMBER articles will be popped off."
7082 (setq gnus-newsgroup-history
7083 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7085 (gnus-summary-goto-article (car to))
7086 (error "Article history empty")))
7087 (gnus-summary-position-cursor))
7089 ;; Summary article oriented commands
7091 (defun gnus-summary-refer-parent-article (n)
7092 "Refer parent article N times.
7093 The difference between N and the number of articles fetched is returned."
7095 (gnus-set-global-variables)
7099 (let ((ref (header-references (gnus-get-header-by-number
7100 (gnus-summary-article-number)))))
7101 (if (and ref (not (equal ref ""))
7102 (string-match "<[^<>]*>[ \t]*$" ref))
7103 (gnus-summary-refer-article
7104 (substring ref (match-beginning 0) (match-end 0))))))
7106 (or (zerop n) (message "No references in article or expired article."))
7107 (gnus-summary-position-cursor)
7110 (defun gnus-summary-refer-article (message-id)
7111 "Refer article specified by MESSAGE-ID.
7112 NOTE: This command only works with newsgroup that use NNTP."
7113 (interactive "sMessage-ID: ")
7114 (if (or (not (stringp message-id))
7115 (zerop (length message-id)))
7117 ;; Construct the correct Message-ID if necessary.
7118 ;; Suggested by tale@pawl.rpi.edu.
7119 (or (string-match "^<" message-id)
7120 (setq message-id (concat "<" message-id)))
7121 (or (string-match ">$" message-id)
7122 (setq message-id (concat message-id ">")))
7123 (let ((header (car (gnus-gethash (downcase message-id)
7124 gnus-newsgroup-dependencies))))
7126 (gnus-summary-goto-article (header-number header))
7127 (let ((gnus-override-method gnus-refer-article-method))
7128 (if (gnus-article-prepare
7129 message-id nil (gnus-read-header message-id))
7131 (gnus-summary-insert-line
7132 nil gnus-current-headers 0 nil gnus-read-mark nil nil
7133 (header-subject gnus-current-headers))
7135 (gnus-summary-position-cursor)
7136 (gnus-summary-update-line)
7138 (message "No such references")
7141 (defun gnus-summary-enter-digest-group ()
7142 "Enter a digest group based on the current article."
7144 (gnus-summary-select-article)
7145 (let ((name (format "%s/%d"
7146 (gnus-group-prefixed-name
7147 gnus-newsgroup-name (list 'nndigest ""))
7148 gnus-current-article))
7149 (buf (current-buffer)))
7150 (set-buffer gnus-group-buffer)
7153 (list t nil (list name 3 nil nil
7154 (list 'nndigest gnus-article-buffer
7155 (cons 'quit-buffer buf))))
7157 (gnus-group-read-group t nil name)))
7159 (defun gnus-summary-isearch-article ()
7160 "Do incremental search forward on current article."
7162 (gnus-summary-select-article)
7163 (gnus-eval-in-buffer-window gnus-article-buffer
7166 (defun gnus-summary-search-article-forward (regexp)
7167 "Search for an article containing REGEXP forward.
7168 gnus-select-article-hook is not called during the search."
7171 (concat "Search forward (regexp): "
7172 (if gnus-last-search-regexp
7173 (concat "(default " gnus-last-search-regexp ") "))))))
7174 (if (string-equal regexp "")
7175 (setq regexp (or gnus-last-search-regexp ""))
7176 (setq gnus-last-search-regexp regexp))
7177 (if (gnus-summary-search-article regexp nil)
7178 (gnus-eval-in-buffer-window
7181 (error "Search failed: \"%s\"" regexp)))
7183 (defun gnus-summary-search-article-backward (regexp)
7184 "Search for an article containing REGEXP backward.
7185 gnus-select-article-hook is not called during the search."
7188 (concat "Search backward (regexp): "
7189 (if gnus-last-search-regexp
7190 (concat "(default " gnus-last-search-regexp ") "))))))
7191 (if (string-equal regexp "")
7192 (setq regexp (or gnus-last-search-regexp ""))
7193 (setq gnus-last-search-regexp regexp))
7194 (if (gnus-summary-search-article regexp t)
7195 (gnus-eval-in-buffer-window
7198 (error "Search failed: \"%s\"" regexp)))
7200 (defun gnus-summary-search-article (regexp &optional backward)
7201 "Search for an article containing REGEXP.
7202 Optional argument BACKWARD means do search for backward.
7203 gnus-select-article-hook is not called during the search."
7204 (let ((gnus-select-article-hook nil) ;Disable hook.
7205 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7208 (function re-search-backward) (function re-search-forward)))
7211 ;; Hidden thread subtrees must be searched for ,too.
7212 (gnus-summary-show-all-threads)
7213 (if (eobp) (forward-line -1))
7214 ;; First of all, search current article.
7215 ;; We don't want to read article again from NNTP server nor reset
7217 (gnus-summary-select-article)
7218 (message "Searching article: %d..." gnus-current-article)
7219 (setq last gnus-current-article)
7220 (gnus-eval-in-buffer-window gnus-article-buffer
7223 ;; Begin search from current point.
7224 (setq found (funcall re-search regexp nil t))))
7225 ;; Then search next articles.
7226 (while (and (not found)
7227 (gnus-summary-display-article
7228 (gnus-summary-search-subject backward nil nil)))
7229 (message "Searching article: %d..." gnus-current-article)
7230 (gnus-eval-in-buffer-window gnus-article-buffer
7233 (goto-char (if backward (point-max) (point-min)))
7234 (setq found (funcall re-search regexp nil t)))))
7236 ;; Adjust article pointer.
7237 (or (eq last gnus-current-article)
7238 (setq gnus-last-article last))
7239 ;; Return T if found such article.
7242 (defun gnus-summary-execute-command (header regexp command &optional backward)
7243 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7244 If HEADER is an empty string (or nil), the match is done on the entire
7245 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7247 (list (let ((completion-ignore-case t))
7250 (mapcar (string) (list string)
7251 '("Number" "Subject" "From" "Lines" "Date"
7252 "Message-ID" "Xref" "References")
7253 nil 'require-match)))
7254 (read-string "Regexp: ")
7255 (read-key-sequence "Command: ")
7256 current-prefix-arg))
7257 ;; Hidden thread subtrees must be searched as well.
7258 (gnus-summary-show-all-threads)
7259 ;; We don't want to change current point nor window configuration.
7261 (save-window-excursion
7262 (message "Executing %s..." (key-description command))
7263 ;; We'd like to execute COMMAND interactively so as to give arguments.
7264 (gnus-execute header regexp
7266 (call-interactively '(, (key-binding command)))))
7268 (message "Executing %s... done" (key-description command)))))
7270 (defun gnus-summary-beginning-of-article ()
7271 "Scroll the article back to the beginning."
7273 (gnus-summary-select-article)
7274 (gnus-eval-in-buffer-window
7277 (goto-char (point-min))
7278 (and gnus-break-pages (gnus-narrow-to-page))))
7280 (defun gnus-summary-end-of-article ()
7281 "Scroll to the end of the article."
7283 (gnus-summary-select-article)
7284 (gnus-eval-in-buffer-window
7287 (goto-char (point-max))
7288 (and gnus-break-pages (gnus-narrow-to-page))))
7290 (defun gnus-summary-show-article ()
7291 "Force re-fetching of the current article."
7293 (gnus-summary-select-article gnus-have-all-headers t t))
7295 (defun gnus-summary-toggle-header (arg)
7296 "Show the headers if they are hidden, or hide them if they are shown.
7297 If ARG is a positive number, show the entire header.
7298 If ARG is a negative number, hide the unwanted header lines."
7300 (gnus-set-global-variables)
7302 (set-buffer gnus-article-buffer)
7303 (let ((buffer-read-only nil))
7305 (if (> arg 0) (remove-text-properties 1 (point-max) '(invisible t))
7306 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
7307 (if (text-property-any 1 (point-max) 'invisible t)
7308 (remove-text-properties 1 (point-max) '(invisible t))
7309 (let ((gnus-have-all-headers nil))
7310 (run-hooks 'gnus-article-display-hook))))
7311 (set-window-point (get-buffer-window (current-buffer)) 1))))
7313 (defun gnus-summary-show-all-headers ()
7314 "Make all header lines visible."
7316 (gnus-article-show-all-headers))
7318 (defun gnus-summary-toggle-mime (arg)
7319 "Toggle MIME processing.
7320 If ARG is a positive number, turn MIME processing on."
7322 (setq gnus-show-mime
7323 (if (null arg) (not gnus-show-mime)
7324 (> (prefix-numeric-value arg) 0)))
7325 (gnus-summary-select-article t 'force))
7327 (defun gnus-summary-caesar-message (rotnum)
7328 "Caesar rotates all letters of current message by 13/47 places.
7329 With prefix arg, specifies the number of places to rotate each letter forward.
7330 Caesar rotates Japanese letters by 47 places in any case."
7332 (gnus-summary-select-article)
7333 (let ((mail-header-separator "")) ; !!! Is this necessary?
7334 (gnus-overload-functions)
7335 (gnus-eval-in-buffer-window
7339 ;; We don't want to jump to the beginning of the message.
7340 ;; `save-excursion' does not do its job.
7341 (move-to-window-line 0)
7342 (let ((last (point)))
7343 (news-caesar-buffer-body rotnum)
7347 (defun gnus-summary-stop-page-breaking ()
7348 "Stop page breaking in the current article."
7350 (gnus-summary-select-article)
7351 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
7353 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
7355 (defun gnus-summary-move-article (n &optional to-newsgroup select-method)
7356 "Move the current article to a different newsgroup.
7357 If N is a positive number, move the N next articles.
7358 If N is a negative number, move the N previous articles.
7359 If N is nil and any articles have been marked with the process mark,
7360 move those articles instead.
7361 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7362 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
7363 re-spool using this method.
7364 For this function to work, both the current newsgroup and the
7365 newsgroup that you want to move to have to support the `request-move'
7366 and `request-accept' functions. (Ie. mail newsgroups at present.)"
7368 (gnus-set-global-variables)
7369 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
7370 (error "The current newsgroup does not support article moving"))
7371 (let ((articles (gnus-summary-work-articles n))
7373 (if (and (not to-newsgroup) (not select-method))
7376 (format "Where do you want to move %s? %s"
7377 (if (> (length articles) 1)
7378 (format "these %d articles" (length articles))
7380 (if gnus-current-move-group
7381 (format "(%s default) " gnus-current-move-group)
7383 gnus-active-hashtb nil nil
7384 (gnus-group-real-prefix gnus-newsgroup-name))))
7385 (if (string= to-newsgroup "")
7386 (setq to-newsgroup (or gnus-current-move-group "")))
7387 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
7388 (error "No such group: %s" to-newsgroup))
7389 (setq gnus-current-move-group to-newsgroup)
7390 (or (gnus-check-backend-function 'request-accept-article
7391 (or select-method to-newsgroup))
7392 (error "%s does not support article moving" to-newsgroup))
7393 (message "Moving to %s: %s..." (or select-method to-newsgroup) articles)
7396 (gnus-request-move-article
7397 (car articles) ; Article to move
7398 gnus-newsgroup-name ; From newsgrouo
7399 (nth 1 (gnus-find-method-for-group
7400 gnus-newsgroup-name)) ; Server
7401 (list 'gnus-request-accept-article
7403 (quote select-method)
7405 (not (cdr articles))) ; Accept form
7406 (not (cdr articles)))) ; Only save nov last time
7407 (let* ((buffer-read-only nil)
7410 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7412 (gnus-group-prefixed-name
7414 (if select-method (list select-method "")
7415 (gnus-find-method-for-group to-newsgroup)))
7416 gnus-newsrc-hashtb)))
7417 (info (nth 2 entry))
7418 (article (car articles))
7419 (marked (nth 3 info)))
7420 (gnus-summary-goto-subject article)
7421 (delete-region (progn (beginning-of-line) (point))
7422 (progn (forward-line 1) (point)))
7423 (if (not (memq article gnus-newsgroup-unreads))
7424 (setcar (cdr (cdr info))
7425 (gnus-add-to-range (nth 2 info)
7426 (list (cdr art-group)))))
7427 ;; Copy any marks over to the new group.
7428 (let ((marks '((tick . gnus-newsgroup-marked)
7429 (dormant . gnus-newsgroup-dormant)
7430 (expire . gnus-newsgroup-expirable)
7431 (bookmark . gnus-newsgroup-bookmarks)
7432 ; (score . gnus-newsgroup-scored)
7433 (reply . gnus-newsgroup-replied)))
7434 (to-article (cdr art-group)))
7436 (if (memq article (symbol-value (cdr (car marks))))
7437 (gnus-add-marked-articles
7438 (car info) (car (car marks)) (list to-article) info))
7439 (setq marks (cdr marks))))
7440 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7441 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7442 (setq gnus-newsgroup-dormant
7443 (delq article gnus-newsgroup-dormant)))
7444 (message "Couldn't move article %s" (car articles)))
7445 (gnus-summary-remove-process-mark (car articles))
7446 (setq articles (cdr articles)))))
7448 (defun gnus-summary-respool-article (n &optional respool-method)
7449 "Respool the current article.
7450 The article will be squeezed through the mail spooling process again,
7451 which means that it will be put in some mail newsgroup or other
7452 depending on `nnmail-split-methods'.
7453 If N is a positive number, respool the N next articles.
7454 If N is a negative number, respool the N previous articles.
7455 If N is nil and any articles have been marked with the process mark,
7456 respool those articles instead.
7458 Respooling can be done both from mail groups and \"real\" newsgroups.
7459 In the former case, the articles in question will be moved from the
7460 current group into whatever groups they are destined to. In the
7461 latter case, they will be copied into the relevant groups."
7463 (gnus-set-global-variables)
7464 (let ((respool-methods (gnus-methods-using 'respool)))
7466 (setq respool-method
7468 "What method do you want to use when respooling? "
7469 respool-methods nil t)))
7470 (if (assoc (symbol-name
7471 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7473 (gnus-summary-copy-article n nil (intern respool-method)))
7474 (gnus-summary-move-article n nil (intern respool-method))))
7476 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
7477 (defun gnus-summary-copy-article (n &optional to-newsgroup select-method)
7478 "Move the current article to a different newsgroup.
7479 If N is a positive number, move the N next articles.
7480 If N is a negative number, move the N previous articles.
7481 If N is nil and any articles have been marked with the process mark,
7482 move those articles instead.
7483 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7484 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
7485 re-spool using this method.
7486 For this function to work, the newsgroup that you want to move to have
7487 to support the `request-move' and `request-accept'
7488 functions. (Ie. mail newsgroups at present.)"
7490 (gnus-set-global-variables)
7491 (let ((articles (gnus-summary-work-articles n))
7492 (copy-buf (get-buffer-create "*copy work*"))
7494 (buffer-disable-undo copy-buf)
7495 (if (and (not to-newsgroup) (not select-method))
7498 (format "Where do you want to copy %s? %s"
7499 (if (> (length articles) 1)
7500 (format "these %d articles" (length articles))
7502 (if gnus-current-move-group
7503 (format "(%s default) " gnus-current-move-group)
7505 gnus-active-hashtb nil nil
7506 (gnus-group-real-prefix gnus-newsgroup-name))))
7507 (if (string= to-newsgroup "")
7508 (setq to-newsgroup (or gnus-current-move-group "")))
7509 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
7510 (error "No such group: %s" to-newsgroup))
7511 (setq gnus-current-move-group to-newsgroup)
7512 (or (gnus-check-backend-function 'request-accept-article
7513 (or select-method to-newsgroup))
7514 (error "%s does not support article copying" to-newsgroup))
7515 (message "Copying to %s: %s..." (or select-method to-newsgroup) articles)
7519 (set-buffer copy-buf)
7520 (gnus-request-article-this-buffer
7521 (car articles) gnus-newsgroup-name)
7522 (gnus-request-accept-article
7523 (if select-method (quote select-method) to-newsgroup)
7524 (not (cdr articles)))))
7527 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7529 (gnus-group-prefixed-name
7531 (if select-method (list select-method "")
7532 (gnus-find-method-for-group to-newsgroup)))
7533 gnus-newsrc-hashtb)))
7534 (info (nth 2 entry))
7535 (article (car articles))
7536 (marked (nth 3 info)))
7537 (if (not (memq article gnus-newsgroup-unreads))
7538 (setcar (cdr (cdr info))
7539 (gnus-add-to-range (nth 2 info)
7540 (list (cdr art-group)))))
7541 ;; Copy any marks over to the new group.
7542 (let ((marks '((tick . gnus-newsgroup-marked)
7543 (dormant . gnus-newsgroup-dormant)
7544 (expire . gnus-newsgroup-expirable)
7545 (bookmark . gnus-newsgroup-bookmarks)
7546 ; (score . gnus-newsgroup-scored)
7547 (reply . gnus-newsgroup-replied)))
7548 (to-article (cdr art-group)))
7550 (if (memq article (symbol-value (cdr (car marks))))
7551 (gnus-add-marked-articles
7552 (car info) (car (car marks)) (list to-article) info))
7553 (setq marks (cdr marks)))))
7554 (message "Couldn't copy article %s" (car articles)))
7555 (gnus-summary-remove-process-mark (car articles))
7556 (setq articles (cdr articles)))
7557 (kill-buffer copy-buf)))
7559 (defun gnus-summary-expire-articles ()
7560 "Expire all articles that are marked as expirable in the current group."
7562 (if (and gnus-newsgroup-expirable
7563 (gnus-check-backend-function
7564 'request-expire-articles gnus-newsgroup-name))
7565 (let ((expirable gnus-newsgroup-expirable))
7566 ;; The list of articles that weren't expired is returned.
7567 (setq gnus-newsgroup-expirable
7568 (gnus-request-expire-articles gnus-newsgroup-expirable
7569 gnus-newsgroup-name))
7570 ;; We go through the old list of expirable, and mark all
7571 ;; really expired articles as non-existant.
7573 (or (memq (car expirable) gnus-newsgroup-expirable)
7574 (gnus-summary-mark-as-read (car expirable) "%"))
7575 (setq expirable (cdr expirable))))))
7577 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7578 (defun gnus-summary-delete-article (n)
7579 "Delete the N next (mail) articles.
7580 This command actually deletes articles. This is not a marking
7581 command. The article will disappear forever from you life, never to
7583 If N is negative, delete backwards.
7584 If N is nil and articles have been marked with the process mark,
7585 delete these instead."
7587 (or (gnus-check-backend-function 'request-expire-articles
7588 gnus-newsgroup-name)
7589 (error "The current newsgroup does not support article deletion."))
7590 ;; Compute the list of articles to delete.
7591 (let ((articles (gnus-summary-work-articles n)))
7592 (if (and gnus-novice-user
7594 (format "Do you really want to delete %s forever? "
7595 (if (> (length articles) 1) "these articles"
7598 ;; Delete the articles.
7599 (setq gnus-newsgroup-expirable
7600 (gnus-request-expire-articles
7601 articles gnus-newsgroup-name 'force))
7603 (gnus-summary-remove-process-mark (car articles))
7604 ;; The backend might not have been able to delete the article
7606 (or (memq (car articles) gnus-newsgroup-expirable)
7607 (gnus-summary-mark-as-read (car articles) gnus-canceled-mark))
7608 (setq articles (cdr articles))))))
7610 (defun gnus-summary-edit-article ()
7611 "Enter into a buffer and edit the current article.
7612 This will have permanent effect only in mail groups."
7614 (or (gnus-check-backend-function
7615 'request-replace-article gnus-newsgroup-name)
7616 (error "The current newsgroup does not support article editing."))
7617 (gnus-summary-select-article t)
7619 (message "C-c C-c to end edits")
7620 (setq buffer-read-only nil)
7622 (use-local-map (copy-keymap (current-local-map)))
7623 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
7625 (search-forward "\n\n" nil t))
7627 (defun gnus-summary-edit-article-done ()
7628 "Make edits to the current article permanent."
7630 (if (not (gnus-request-replace-article
7631 (cdr gnus-article-current) (car gnus-article-current)
7633 (error "Couldn't replace article.")
7635 (use-local-map gnus-article-mode-map)
7636 (setq buffer-read-only t)
7637 (pop-to-buffer gnus-summary-buffer)))
7639 ;; Summary score commands.
7641 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
7643 (defun gnus-summary-raise-score (n)
7644 "Raise the score of the current article by N."
7646 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
7648 (defun gnus-summary-lower-score (n)
7649 "Lower the score of the current article by N."
7651 (gnus-summary-raise-score (- n)))
7653 (defun gnus-summary-set-score (n)
7654 "Set the score of the current article to N."
7656 ;; Skip dummy header line.
7658 (if (eq (gnus-summary-article-mark) ?Z)
7660 (let ((buffer-read-only nil))
7662 (gnus-summary-update-mark
7663 (if (= n (or gnus-summary-default-score 0)) ?
7664 (if (< n (or gnus-summary-default-score 0))
7665 gnus-score-below-mark gnus-score-over-mark)) 'score))
7666 (let* ((article (gnus-summary-article-number))
7667 (score (assq article gnus-newsgroup-scored)))
7668 (if score (setcdr score n)
7669 (setq gnus-newsgroup-scored
7670 (cons (cons article n) gnus-newsgroup-scored))))
7671 (gnus-summary-update-line)))
7673 ;; Summary marking commands.
7675 (defun gnus-summary-raise-same-subject-and-select (score)
7676 "Raise articles which has the same subject with SCORE and select the next."
7678 (let ((subject (gnus-summary-subject-string)))
7679 (gnus-summary-raise-score score)
7680 (while (gnus-summary-search-subject nil nil subject)
7681 (gnus-summary-raise-score score))
7682 (gnus-summary-next-article t)))
7684 (defun gnus-summary-raise-same-subject (score)
7685 "Raise articles which has the same subject with SCORE."
7687 (let ((subject (gnus-summary-subject-string)))
7688 (gnus-summary-raise-score score)
7689 (while (gnus-summary-search-subject nil nil subject)
7690 (gnus-summary-raise-score score))
7691 (gnus-summary-next-subject 1 t)))
7693 (defun gnus-summary-raise-thread (score)
7694 "Raise articles under current thread with SCORE."
7698 (let ((level (gnus-summary-thread-level)))
7699 (gnus-summary-raise-score score)
7700 (while (and (zerop (gnus-summary-next-subject 1))
7701 (> (gnus-summary-thread-level) level))
7702 (gnus-summary-raise-score score))
7704 (or (zerop (gnus-summary-next-subject 1 t))
7706 (gnus-summary-position-cursor)
7707 (gnus-set-mode-line 'summary))
7709 (defun gnus-summary-lower-same-subject-and-select (score)
7710 "Raise articles which has the same subject with SCORE and select the next."
7712 (gnus-summary-raise-same-subject-and-select (- score)))
7714 (defun gnus-summary-lower-same-subject (score)
7715 "Raise articles which has the same subject with SCORE."
7717 (gnus-summary-raise-same-subject (- score)))
7719 (defun gnus-summary-lower-thread (score)
7720 "Raise articles under current thread with SCORE."
7722 (gnus-summary-raise-thread (- score)))
7724 (defun gnus-summary-kill-same-subject-and-select (unmark)
7725 "Mark articles which has the same subject as read, and then select the next.
7726 If UNMARK is positive, remove any kind of mark.
7727 If UNMARK is negative, tick articles."
7730 (setq unmark (prefix-numeric-value unmark)))
7732 (gnus-summary-mark-same-subject
7733 (gnus-summary-subject-string) unmark)))
7734 ;; Select next unread article. If auto-select-same mode, should
7735 ;; select the first unread article.
7736 (gnus-summary-next-article t (and gnus-auto-select-same
7737 (gnus-summary-subject-string)))
7738 (message "%d articles are marked as %s"
7739 count (if unmark "unread" "read"))))
7741 (defun gnus-summary-kill-same-subject (unmark)
7742 "Mark articles which has the same subject as read.
7743 If UNMARK is positive, remove any kind of mark.
7744 If UNMARK is negative, tick articles."
7747 (setq unmark (prefix-numeric-value unmark)))
7749 (gnus-summary-mark-same-subject
7750 (gnus-summary-subject-string) unmark)))
7751 ;; If marked as read, go to next unread subject.
7753 ;; Go to next unread subject.
7754 (gnus-summary-next-subject 1 t))
7755 (message "%d articles are marked as %s"
7756 count (if unmark "unread" "read"))))
7758 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7759 "Mark articles with same SUBJECT as read, and return marked number.
7760 If optional argument UNMARK is positive, remove any kinds of marks.
7761 If optional argument UNMARK is negative, mark articles as unread instead."
7764 (cond ((null unmark)
7765 (gnus-summary-mark-as-read nil gnus-killed-mark))
7767 (gnus-summary-tick-article nil t))
7769 (gnus-summary-tick-article)))
7771 (gnus-summary-search-forward nil subject))
7772 (cond ((null unmark)
7773 (gnus-summary-mark-as-read nil gnus-killed-mark))
7775 (gnus-summary-tick-article nil t))
7777 (gnus-summary-tick-article)))
7778 (setq count (1+ count))))
7779 ;; Hide killed thread subtrees. Does not work properly always.
7780 ;;(and (null unmark)
7781 ;; gnus-thread-hide-killed
7782 ;; (gnus-summary-hide-thread))
7783 ;; Return number of articles marked as read.
7786 (defun gnus-summary-mark-as-processable (n &optional unmark)
7787 "Set the process mark on the next N articles.
7788 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7789 the process mark instead. The difference between N and the actual
7790 number of articles marked is returned."
7792 (let ((backward (< n 0))
7797 (gnus-summary-remove-process-mark (gnus-summary-article-number))
7798 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7799 (zerop (gnus-summary-next-subject (if backward -1 1))))
7801 (if (/= 0 n) (message "No more articles"))
7804 (defun gnus-summary-unmark-as-processable (n)
7805 "Remove the process mark from the next N articles.
7806 If N is negative, mark backward instead. The difference between N and
7807 the actual number of articles marked is returned."
7809 (gnus-summary-mark-as-processable n t))
7811 (defun gnus-summary-unmark-all-processable ()
7812 "Remove the process mark from all articles."
7815 (while gnus-newsgroup-processable
7816 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7817 (gnus-summary-position-cursor))
7819 (defun gnus-summary-mark-as-expirable (n)
7820 "Mark N articles forward as expirable.
7821 If N is negative, mark backward instead. The difference between N and
7822 the actual number of articles marked is returned."
7824 (gnus-summary-mark-forward n gnus-expirable-mark))
7826 (defun gnus-summary-mark-article-as-replied (article)
7827 "Mark ARTICLE replied and update the summary line."
7828 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
7829 (let ((buffer-read-only nil))
7830 (if (gnus-summary-goto-subject article)
7832 (gnus-summary-update-mark gnus-replied-mark 'replied)
7835 (defun gnus-summary-set-bookmark (article)
7836 "Set a bookmark in current article."
7837 (interactive (list (gnus-summary-article-number)))
7838 (if (or (not (get-buffer gnus-article-buffer))
7839 (not gnus-current-article)
7840 (not gnus-article-current)
7841 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7842 (error "No current article selected"))
7843 ;; Remove old bookmark, if one exists.
7844 (let ((old (assq article gnus-newsgroup-bookmarks)))
7845 (if old (setq gnus-newsgroup-bookmarks
7846 (delq old gnus-newsgroup-bookmarks))))
7847 ;; Set the new bookmark, which is on the form
7848 ;; (article-number . line-number-in-body).
7849 (setq gnus-newsgroup-bookmarks
7853 (set-buffer gnus-article-buffer)
7858 (search-forward "\n\n" nil t)
7861 gnus-newsgroup-bookmarks))
7862 (message "A bookmark has been added to the current article."))
7864 (defun gnus-summary-remove-bookmark (article)
7865 "Remove the bookmark from the current article."
7866 (interactive (list (gnus-summary-article-number)))
7867 ;; Remove old bookmark, if one exists.
7868 (let ((old (assq article gnus-newsgroup-bookmarks)))
7871 (setq gnus-newsgroup-bookmarks
7872 (delq old gnus-newsgroup-bookmarks))
7873 (message "Removed bookmark."))
7874 (message "No bookmark in current article."))))
7876 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7877 (defun gnus-summary-mark-as-dormant (n)
7878 "Mark N articles forward as dormant.
7879 If N is negative, mark backward instead. The difference between N and
7880 the actual number of articles marked is returned."
7882 (gnus-summary-mark-forward n gnus-dormant-mark))
7884 (defun gnus-summary-set-process-mark (article)
7885 "Set the process mark on ARTICLE and update the summary line."
7886 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
7887 (let ((buffer-read-only nil))
7888 (if (gnus-summary-goto-subject article)
7890 (and (eq (gnus-summary-article-mark) ?Z)
7892 (gnus-summary-update-mark gnus-process-mark 'replied)
7895 (defun gnus-summary-remove-process-mark (article)
7896 "Remove the process mark from ARTICLE and update the summary line."
7897 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7898 (let ((buffer-read-only nil))
7899 (if (gnus-summary-goto-subject article)
7901 (and (eq (gnus-summary-article-mark) ?Z)
7903 (gnus-summary-update-mark ? 'replied)
7904 (if (memq article gnus-newsgroup-replied)
7905 (gnus-summary-update-mark gnus-replied-mark 'replied))
7908 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7909 "Mark N articles as read forwards.
7910 If N is negative, mark backwards instead.
7911 Mark with MARK. If MARK is ? , ?! or ??, articles will be
7913 The difference between N and the actual number of articles marked is
7916 (gnus-set-global-variables)
7917 (let ((backward (< n 0))
7919 (mark (or mark gnus-dread-mark)))
7921 (gnus-summary-mark-article nil mark no-expire)
7922 (zerop (gnus-summary-next-subject
7923 (if backward -1 1) gnus-summary-goto-unread)))
7925 (if (/= 0 n) (message "No more %sarticles" (if mark "" "unread ")))
7926 (gnus-set-mode-line 'summary)
7929 (defun gnus-summary-mark-article (&optional article mark no-expire)
7930 "Mark ARTICLE with MARK.
7931 MARK can be any character.
7932 Five MARK strings are reserved: ? (unread),
7933 ?! (ticked), ?? (dormant), ?D (read), ?E (expirable).
7934 If MARK is nil, then the default character ?D is used.
7935 If ARTICLE is nil, then the article on the current line will be
7937 ;; If no mark is given, then we check auto-expiring.
7938 (and (not no-expire)
7939 gnus-newsgroup-auto-expire
7941 (and (numberp mark) (or (= mark gnus-killed-mark)
7942 (= mark gnus-dread-mark)
7943 (= mark gnus-catchup-mark)
7944 (= mark gnus-low-score-mark)
7945 (= mark gnus-read-mark))))
7946 (setq mark gnus-expirable-mark))
7947 (let* ((buffer-read-only nil)
7948 (mark (or (and (stringp mark) (aref mark 0)) mark gnus-dread-mark))
7949 (article (or article (gnus-summary-article-number))))
7950 (if (or (= mark gnus-unread-mark)
7951 (= mark gnus-ticked-mark)
7952 (= mark gnus-dormant-mark))
7953 (gnus-mark-article-as-unread article mark)
7954 (gnus-mark-article-as-read article mark))
7955 (if (gnus-summary-goto-subject article)
7957 (gnus-summary-show-thread)
7959 (and (eq (gnus-summary-article-mark) ?Z)
7962 (gnus-summary-update-mark mark 'unread)
7965 (defun gnus-summary-update-mark (mark type)
7967 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7971 (forward-char forward)
7972 (setq plist (text-properties-at (point)))
7974 (and (memq 'gnus-mark plist) (setcar (cdr (memq 'gnus-mark plist)) mark))
7976 (and plist (add-text-properties (1- (point)) (point) plist))
7977 (gnus-summary-update-line (eq mark gnus-unread-mark)))))
7979 (defun gnus-mark-article-as-read (article &optional mark)
7980 "Enter ARTICLE in the pertinent lists and remove it from others."
7981 ;; Make the article expirable.
7982 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-dread-mark)))
7983 (if (= mark gnus-expirable-mark)
7984 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
7985 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7986 ;; Remove from unread and marked lists.
7987 (setq gnus-newsgroup-unreads
7988 (delq article gnus-newsgroup-unreads))
7989 (setq gnus-newsgroup-marked
7990 (delq article gnus-newsgroup-marked))
7991 (setq gnus-newsgroup-dormant
7992 (delq article gnus-newsgroup-dormant))))
7994 (defun gnus-mark-article-as-unread (article &optional mark)
7995 "Enter ARTICLE in the pertinent lists and remove it from others."
7996 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-ticked-mark)))
7997 ;; Add to unread list.
7998 (or (memq article gnus-newsgroup-unreads)
7999 (setq gnus-newsgroup-unreads
8000 (cons article gnus-newsgroup-unreads)))
8001 ;; If CLEAR-MARK is non-nil, the article must be removed from marked
8002 ;; list. Otherwise, it must be added to the list.
8003 (setq gnus-newsgroup-marked
8004 (delq article gnus-newsgroup-marked))
8005 (setq gnus-newsgroup-dormant
8006 (delq article gnus-newsgroup-dormant))
8007 (setq gnus-newsgroup-expirable
8008 (delq article gnus-newsgroup-expirable))
8009 (if (= mark gnus-ticked-mark)
8010 (setq gnus-newsgroup-marked
8011 (cons article gnus-newsgroup-marked)))
8012 (if (= mark gnus-dormant-mark)
8013 (setq gnus-newsgroup-dormant
8014 (cons article gnus-newsgroup-dormant)))))
8016 (defalias 'gnus-summary-mark-as-unread-forward
8017 'gnus-summary-tick-article-forward)
8018 (make-obsolete 'gnus-summary-mark-as-unread-forward
8019 'gnus-summary-tick-article-forward)
8020 (defun gnus-summary-tick-article-forward (n)
8021 "Tick N articles forwards.
8022 If N is negative, tick backwards instead.
8023 The difference between N and the number of articles ticked is returned."
8025 (gnus-summary-mark-forward n gnus-ticked-mark))
8027 (defalias 'gnus-summary-mark-as-unread-backward
8028 'gnus-summary-tick-article-backward)
8029 (make-obsolete 'gnus-summary-mark-as-unread-backward
8030 'gnus-summary-tick-article-backward)
8031 (defun gnus-summary-tick-article-backward (n)
8032 "Tick N articles backwards.
8033 The difference between N and the number of articles ticked is returned."
8035 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8037 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8038 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8039 (defun gnus-summary-tick-article (&optional article clear-mark)
8040 "Mark current article as unread.
8041 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8042 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8043 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8046 (defun gnus-summary-mark-as-read-forward (n)
8047 "Mark N articles as read forwards.
8048 If N is negative, mark backwards instead.
8049 The difference between N and the actual number of articles marked is
8052 (gnus-summary-mark-forward n gnus-dread-mark t))
8054 (defun gnus-summary-mark-as-read-backward (n)
8055 "Mark the N articles as read backwards.
8056 The difference between N and the actual number of articles marked is
8059 (gnus-summary-mark-forward (- n) gnus-dread-mark t))
8061 (defun gnus-summary-mark-as-read (&optional article mark)
8062 "Mark current article as read.
8063 ARTICLE specifies the article to be marked as read.
8064 MARK specifies a string to be inserted at the beginning of the line."
8065 (gnus-summary-mark-article article mark))
8067 (defun gnus-summary-clear-mark-forward (n)
8068 "Clear marks from N articles forward.
8069 If N is negative, clear backward instead.
8070 The difference between N and the number of marks cleared is returned."
8072 (gnus-summary-mark-forward n gnus-unread-mark))
8074 (defun gnus-summary-clear-mark-backward (n)
8075 "Clear marks from N articles backward.
8076 The difference between N and the number of marks cleared is returned."
8078 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8080 (defun gnus-summary-mark-unread-as-read ()
8081 "Intended to be used by `gnus-summary-mark-article-hook'."
8082 (or (memq gnus-current-article gnus-newsgroup-marked)
8083 (memq gnus-current-article gnus-newsgroup-dormant)
8084 (memq gnus-current-article gnus-newsgroup-expirable)
8085 (gnus-summary-mark-as-read gnus-current-article gnus-read-mark)))
8087 (defun gnus-summary-mark-region-as-read (point mark all)
8088 "Mark all unread articles between point and mark as read.
8089 If given a prefix, mark all articles between point and mark as read,
8090 even ticked and dormant ones."
8091 (interactive "r\nP")
8101 (not (memq (gnus-summary-article-number)
8102 gnus-newsgroup-marked))
8103 (not (memq (gnus-summary-article-number)
8104 gnus-newsgroup-dormant))))
8105 (gnus-summary-mark-article
8106 (gnus-summary-article-number) gnus-dread-mark))
8108 (zerop (forward-line 1))))))
8110 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
8111 (defalias 'gnus-summary-delete-marked-as-read
8112 'gnus-summary-remove-lines-marked-as-read)
8113 (make-obsolete 'gnus-summary-delete-marked-as-read
8114 'gnus-summary-remove-lines-marked-as-read)
8115 (defun gnus-summary-remove-lines-marked-as-read ()
8116 "Remove lines that are marked as read."
8118 (gnus-summary-remove-lines-marked-with
8120 (lambda (char) (char-to-string (symbol-value char)))
8121 '(gnus-dread-mark gnus-read-mark
8122 gnus-killed-mark gnus-kill-file-mark
8123 gnus-low-score-mark gnus-expirable-mark)
8126 (defalias 'gnus-summary-delete-marked-with
8127 'gnus-summary-remove-lines-marked-with)
8128 (make-obsolete 'gnus-summary-delete-marked-with
8129 'gnus-summary-remove-lines-marked-with)
8130 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
8131 (defun gnus-summary-remove-lines-marked-with (marks)
8132 "Remove lines that are marked with MARKS (e.g. \"DK\")."
8133 (interactive "sMarks: ")
8134 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
8136 (set-buffer gnus-summary-buffer)
8137 (let ((buffer-read-only nil)
8138 (marks (concat "^[" marks "]")))
8139 (goto-char (point-min))
8140 (while (search-forward-regexp marks (point-max) t)
8141 (delete-region (progn (beginning-of-line) (point))
8142 (progn (forward-line 1) (point)))))
8143 (or (zerop (buffer-size))
8145 (gnus-summary-prev-subject 1)
8146 (gnus-summary-position-cursor)))))
8148 (defun gnus-summary-expunge-below (score)
8149 "Remove articles with score less than SCORE."
8151 (setq score (if score
8152 (prefix-numeric-value score)
8153 (or gnus-summary-default-score 0)))
8155 (set-buffer gnus-summary-buffer)
8156 (goto-char (point-min))
8157 (let ((buffer-read-only nil)
8160 (if (< (gnus-summary-article-score) score)
8164 (delete-region beg (point)))
8167 (or (zerop (buffer-size))
8169 (gnus-summary-prev-subject 1)
8170 (gnus-summary-position-cursor))))))
8172 (defun gnus-summary-mark-below (score mark)
8173 "Mark articles with score less than SCORE with MARK."
8174 (interactive "P\ncMark: ")
8175 (setq score (if score
8176 (prefix-numeric-value score)
8177 (or gnus-summary-default-score 0)))
8179 (set-buffer gnus-summary-buffer)
8180 (goto-char (point-min))
8182 (and (< (gnus-summary-article-score) score)
8183 (gnus-summary-mark-article nil mark))
8186 (defun gnus-summary-kill-below (score)
8187 "Mark articles with score below SCORE as read."
8189 (gnus-summary-mark-below score gnus-killed-mark))
8191 (defun gnus-summary-clear-above (score)
8192 "Clear all marks from articles with score above SCORE."
8194 (gnus-summary-mark-above score gnus-unread-mark))
8196 (defun gnus-summary-tick-above (score)
8197 "Tick all articles with score above SCORE."
8199 (gnus-summary-mark-above score gnus-ticked-mark))
8201 (defun gnus-summary-mark-above (score mark)
8202 "Mark articles with score over SCORE with MARK."
8203 (interactive "P\ncMark: ")
8204 (setq score (if score
8205 (prefix-numeric-value score)
8206 (or gnus-summary-default-score 0)))
8208 (set-buffer gnus-summary-buffer)
8209 (goto-char (point-min))
8211 (if (> (gnus-summary-article-score) score)
8213 (gnus-summary-mark-article nil mark)
8215 (forward-line 1)))))
8217 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8218 (defun gnus-summary-show-all-expunged ()
8219 "Display all the hidden articles that were expunged for low scores."
8221 (let ((buffer-read-only nil))
8222 (let ((scored gnus-newsgroup-scored)
8225 (or (gnus-summary-goto-subject (car (car scored)))
8226 (and (setq h (gnus-get-header-by-number (car (car scored))))
8227 (< (cdr (car scored)) gnus-summary-expunge-below)
8228 (setq headers (cons h headers))))
8229 (setq scored (cdr scored)))
8230 (or headers (error "No expunged articles hidden."))
8231 (goto-char (point-min))
8233 (gnus-summary-prepare-threads (nreverse headers) 0)))
8234 (goto-char (point-min))
8235 (gnus-summary-position-cursor)))
8237 (defun gnus-summary-show-all-dormant ()
8238 "Display all the hidden articles that are marked as dormant."
8240 (let ((buffer-read-only nil))
8241 (goto-char (point-min))
8242 (let ((dormant gnus-newsgroup-dormant)
8245 (or (gnus-summary-goto-subject (car dormant))
8246 (and (setq h (gnus-get-header-by-number (car dormant)))
8247 (setq headers (cons h headers))))
8248 (setq dormant (cdr dormant)))
8249 (or headers (error "No dormant articles hidden."))
8250 (save-excursion (gnus-summary-prepare-threads (nreverse headers) 0)))
8251 (goto-char (point-min))
8252 (gnus-summary-position-cursor)))
8254 (defun gnus-summary-hide-all-dormant ()
8255 "Hide all dormant articles."
8257 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
8258 (gnus-summary-position-cursor))
8260 (defun gnus-summary-catchup (all &optional quietly to-here)
8261 "Mark all articles not marked as unread in this newsgroup as read.
8262 If prefix argument ALL is non-nil, all articles are marked as read.
8263 If QUIETLY is non-nil, no questions will be asked.
8264 If TO-HERE is non-nil, it should be a point in the buffer. All
8265 articles before this point will be marked as read.
8266 The number of articles marked as read is returned."
8270 (not gnus-interactive-catchup) ;Without confirmation?
8274 "Mark absolutely all articles as read? "
8275 "Mark all unread articles as read? ")))
8276 (let ((unreads (length gnus-newsgroup-unreads)))
8277 (if (gnus-summary-first-subject (not all))
8278 (while (and (gnus-summary-mark-as-read nil gnus-catchup-mark)
8279 (if to-here (< (point) to-here) t)
8280 (gnus-summary-search-subject nil (not all)))))
8281 (- unreads (length gnus-newsgroup-unreads))
8283 (setq gnus-newsgroup-unreads gnus-newsgroup-marked))))
8284 (gnus-summary-position-cursor)))
8286 (defun gnus-summary-catchup-to-here (&optional all)
8287 "Mark all unticked articles before the current one as read.
8288 If ALL is non-nil, also mark ticked and dormant articles as read."
8291 (gnus-summary-catchup all t (point))
8292 (gnus-summary-position-cursor))
8294 (defun gnus-summary-catchup-all (&optional quietly)
8295 "Mark all articles in this newsgroup as read."
8297 (gnus-summary-catchup t quietly))
8299 (defun gnus-summary-catchup-and-exit (all &optional quietly)
8300 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8301 If prefix argument ALL is non-nil, all articles are marked as read."
8303 (gnus-summary-catchup all quietly)
8304 ;; Select next newsgroup or exit.
8305 (if (eq gnus-auto-select-next 'quietly)
8306 (gnus-summary-next-group nil)
8307 (gnus-summary-exit)))
8309 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8310 "Mark all articles in this newsgroup as read, and then exit."
8312 (gnus-summary-catchup-and-exit t quietly))
8314 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8315 (defun gnus-summary-catchup-and-goto-next-group (all)
8316 "Mark all articles in this group as read and select the next group.
8317 If given a prefix, mark all articles, unread as well as ticked, as
8320 (gnus-summary-catchup all)
8321 (gnus-summary-next-group))
8323 ;; Thread-based commands.
8325 (defun gnus-summary-toggle-threads (arg)
8326 "Toggle showing conversation threads.
8327 If ARG is positive number, turn showing conversation threads on."
8329 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8330 (setq gnus-show-threads
8331 (if (null arg) (not gnus-show-threads)
8332 (> (prefix-numeric-value arg) 0)))
8333 (gnus-summary-prepare)
8334 (gnus-summary-goto-subject current)
8335 (gnus-summary-position-cursor)))
8337 (defun gnus-summary-show-all-threads ()
8341 (let ((buffer-read-only nil))
8342 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8343 (gnus-summary-position-cursor))
8345 (defun gnus-summary-show-thread ()
8346 "Show thread subtrees.
8347 Returns nil if no thread was there to be shown."
8351 (let ((buffer-read-only nil)
8352 (beg (progn (beginning-of-line) (point)))
8353 (end (save-excursion (end-of-line) (point))))
8355 ;; Any hidden lines here?
8356 (search-forward "\r" end t)
8357 (subst-char-in-region beg end ?\^M ?\n t))))
8358 (gnus-summary-position-cursor)))
8360 (defun gnus-summary-hide-all-threads ()
8361 "Hide all thread subtrees."
8364 (goto-char (point-min))
8365 (gnus-summary-hide-thread)
8366 (while (and (not (eobp)) (zerop (forward-line 1)))
8367 (gnus-summary-hide-thread)))
8368 (gnus-summary-position-cursor))
8370 (defun gnus-summary-hide-thread ()
8371 "Hide thread subtrees.
8372 Returns nil if no threads were there to be hidden."
8374 (let ((buffer-read-only nil)
8376 (level (gnus-summary-thread-level))
8378 ;; Go forward until either the buffer ends or the subthread
8382 (while (and (zerop (forward-line 1))
8383 (> (gnus-summary-thread-level) level))
8388 (search-backward "\n" start t))
8389 (subst-char-in-region start end ?\n ?\^M t)
8390 (forward-line -1)))))
8392 (defun gnus-summary-go-to-next-thread (&optional previous)
8393 "Go to the same level (or less) next thread.
8394 If PREVIOUS is non-nil, go to previous thread instead.
8395 Return the article number moved to, or nil if moving was impossible."
8396 (let ((level (gnus-summary-thread-level))
8397 (article (gnus-summary-article-number)))
8399 (while (and (zerop (gnus-summary-prev-subject 1))
8400 (> (gnus-summary-thread-level) level)))
8401 (while (and (zerop (gnus-summary-next-subject 1))
8402 (> (gnus-summary-thread-level) level))))
8403 (let ((oart (gnus-summary-article-number)))
8404 (and (/= oart article) oart))))
8406 (defun gnus-summary-next-thread (n)
8407 "Go to the same level next N'th thread.
8408 If N is negative, search backward instead.
8409 Returns the difference between N and the number of skips actually
8412 (let ((backward (< n 0))
8415 (gnus-summary-go-to-next-thread backward))
8417 (gnus-summary-position-cursor)
8418 (if (/= 0 n) (message "No more threads"))
8421 (defun gnus-summary-prev-thread (n)
8422 "Go to the same level previous N'th thread.
8423 Returns the difference between N and the number of skips actually
8426 (gnus-summary-next-thread (- n)))
8428 (defun gnus-summary-go-down-thread (&optional same)
8429 "Go down one level in the current thread.
8430 If SAME is non-nil, also move to articles of the same level."
8431 (let ((level (gnus-summary-thread-level))
8433 (if (and (zerop (forward-line 1))
8434 (> (gnus-summary-thread-level) level))
8439 (defun gnus-summary-go-up-thread ()
8440 "Go up one level in the current thread."
8441 (let ((level (gnus-summary-thread-level))
8443 (while (and (zerop (forward-line -1))
8444 (>= (gnus-summary-thread-level) level)))
8445 (if (>= (gnus-summary-thread-level) level)
8451 (defun gnus-summary-down-thread (n)
8452 "Go down thread N steps.
8453 If N is negative, go up instead.
8454 Returns the difference between N and how many steps down that were
8460 (if up (gnus-summary-go-up-thread)
8461 (gnus-summary-go-down-thread)))
8463 (gnus-summary-position-cursor)
8464 (if (/= 0 n) (message "Can't go further"))
8467 (defun gnus-summary-up-thread (n)
8468 "Go up thread N steps.
8469 If N is negative, go up instead.
8470 Returns the difference between N and how many steps down that were
8473 (gnus-summary-down-thread (- n)))
8475 (defun gnus-summary-kill-thread (unmark)
8476 "Mark articles under current thread as read.
8477 If the prefix argument is positive, remove any kinds of marks.
8478 If the prefix argument is negative, tick articles instead."
8481 (setq unmark (prefix-numeric-value unmark)))
8483 (level (gnus-summary-thread-level)))
8486 ;; Mark the article...
8487 (cond ((null unmark) (gnus-summary-mark-as-read nil gnus-killed-mark))
8488 ((> unmark 0) (gnus-summary-tick-article nil t))
8489 (t (gnus-summary-tick-article)))
8490 ;; ...and go forward until either the buffer ends or the subtree
8492 (if (not (and (zerop (forward-line 1))
8493 (> (gnus-summary-thread-level) level)))
8494 (setq killing nil))))
8495 ;; Hide killed subtrees.
8497 gnus-thread-hide-killed
8498 (gnus-summary-hide-thread))
8499 ;; If marked as read, go to next unread subject.
8501 ;; Go to next unread subject.
8502 (gnus-summary-next-subject 1 t)))
8503 (gnus-set-mode-line 'summary))
8505 ;; Summary sorting commands
8507 (defun gnus-summary-sort-by-number (reverse)
8508 "Sort summary buffer by article number.
8509 Argument REVERSE means reverse order."
8512 (cons 'gnus-summary-article-number 'gnus-thread-sort-by-number) reverse))
8514 (defun gnus-summary-sort-by-author (reverse)
8515 "Sort summary buffer by author name alphabetically.
8516 If case-fold-search is non-nil, case of letters is ignored.
8517 Argument REVERSE means reverse order."
8522 (let ((extract (funcall
8523 gnus-extract-address-components
8524 (header-from (gnus-get-header-by-number
8525 (gnus-summary-article-number))))))
8526 (or (car extract) (cdr extract))))
8527 'gnus-thread-sort-by-author)
8530 (defun gnus-summary-sort-by-subject (reverse)
8531 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
8532 If case-fold-search is non-nil, case of letters is ignored.
8533 Argument REVERSE means reverse order."
8538 (downcase (gnus-simplify-subject (gnus-summary-subject-string))))
8539 'gnus-thread-sort-by-subject)
8542 (defun gnus-summary-sort-by-date (reverse)
8543 "Sort summary buffer by date.
8544 Argument REVERSE means reverse order."
8551 (gnus-get-header-by-number (gnus-summary-article-number)))))
8552 'gnus-thread-sort-by-date)
8555 (defun gnus-summary-sort-by-score (reverse)
8556 "Sort summary buffer by score.
8557 Argument REVERSE means reverse order."
8560 (cons 'gnus-summary-article-score 'gnus-thread-sort-by-score)
8563 (defvar gnus-summary-already-sorted nil)
8564 (defun gnus-summary-sort (predicate reverse)
8565 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
8566 (if gnus-summary-already-sorted
8568 (let (buffer-read-only)
8569 (if (not gnus-show-threads)
8571 (goto-char (point-min))
8572 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
8573 (let ((gnus-thread-sort-functions (list (cdr predicate)))
8574 (gnus-summary-already-sorted nil))
8575 (gnus-summary-prepare))))))
8577 (defun gnus-sortable-date (date)
8578 "Make sortable string by string-lessp from DATE.
8579 Timezone package is used."
8580 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
8581 (year (aref date 0))
8582 (month (aref date 1))
8583 (day (aref date 2)))
8584 (timezone-make-sortable-date
8586 (timezone-make-time-string
8587 (aref date 3) (aref date 4) (aref date 5)))))
8590 ;; Summary saving commands.
8592 (defun gnus-summary-save-article (n)
8593 "Save the current article using the default saver function.
8594 If N is a positive number, save the N next articles.
8595 If N is a negative number, save the N previous articles.
8596 If N is nil and any articles have been marked with the process mark,
8597 save those articles instead.
8598 The variable `gnus-default-article-saver' specifies the saver function."
8600 (let (articles process)
8601 (if (and n (numberp n))
8602 (let ((backward (< n 0))
8606 (setq articles (cons (gnus-summary-article-number)
8608 (gnus-summary-search-forward nil nil backward))
8610 (setq articles (sort articles (function <))))
8611 (if gnus-newsgroup-processable
8613 (setq articles (setq gnus-newsgroup-processable
8614 (nreverse gnus-newsgroup-processable)))
8616 (setq articles (list (gnus-summary-article-number)))))
8618 (let ((header (gnus-gethash (int-to-string (car articles))
8619 gnus-newsgroup-headers-hashtb-by-number)))
8620 (if (vectorp header)
8622 (gnus-summary-select-article t nil nil (car articles))
8623 (or gnus-save-all-headers
8624 (gnus-article-hide-headers t))
8625 ;; Remove any X-Gnus lines.
8628 (set-buffer gnus-article-buffer)
8629 (let ((buffer-read-only nil))
8630 (goto-char (point-min))
8631 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
8633 (while (re-search-forward "^X-Gnus" nil t)
8634 (delete-region (progn (beginning-of-line) (point))
8635 (progn (forward-line 1) (point))))
8637 (if gnus-default-article-saver
8638 (funcall gnus-default-article-saver)
8639 (error "No default saver is defined.")))
8640 (if (assq 'name header)
8641 (gnus-copy-file (cdr (assq 'name header)))
8642 (message "Article %d is unsaveable" (car articles)))))
8644 (gnus-summary-remove-process-mark (car articles)))
8645 (setq articles (cdr articles)))
8646 (if process (setq gnus-newsgroup-processable
8647 (nreverse gnus-newsgroup-processable)))
8648 (gnus-summary-position-cursor)
8651 (defun gnus-summary-pipe-output (arg)
8652 "Pipe the current article to a subprocess.
8653 If N is a positive number, pipe the N next articles.
8654 If N is a negative number, pipe the N previous articles.
8655 If N is nil and any articles have been marked with the process mark,
8656 pipe those articles instead."
8658 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8659 (gnus-summary-save-article arg)))
8661 (defun gnus-summary-save-article-mail (arg)
8662 "Append the current article to an mail file.
8663 If N is a positive number, save the N next articles.
8664 If N is a negative number, save the N previous articles.
8665 If N is nil and any articles have been marked with the process mark,
8666 save those articles instead."
8668 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8669 (gnus-summary-save-article arg)))
8671 (defun gnus-summary-save-article-rmail (arg)
8672 "Append the current article to an rmail file.
8673 If N is a positive number, save the N next articles.
8674 If N is a negative number, save the N previous articles.
8675 If N is nil and any articles have been marked with the process mark,
8676 save those articles instead."
8678 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8679 (gnus-summary-save-article arg)))
8681 (defun gnus-summary-save-article-file (arg)
8682 "Append the current article to a file.
8683 If N is a positive number, save the N next articles.
8684 If N is a negative number, save the N previous articles.
8685 If N is nil and any articles have been marked with the process mark,
8686 save those articles instead."
8688 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8689 (gnus-summary-save-article arg)))
8691 (defun gnus-summary-save-article-folder (arg)
8692 "Append the current article to an mh folder.
8693 If N is a positive number, save the N next articles.
8694 If N is a negative number, save the N previous articles.
8695 If N is nil and any articles have been marked with the process mark,
8696 save those articles instead."
8698 (let ((gnus-default-article-saver 'gnus-summary-save-in-folder))
8699 (gnus-summary-save-article arg)))
8701 (defun gnus-read-save-file-name (prompt default-name)
8702 (let ((methods gnus-split-methods)
8704 (if (not gnus-split-methods)
8707 (set-buffer gnus-article-buffer)
8708 (gnus-narrow-to-headers)
8710 (goto-char (point-min))
8711 (and (condition-case ()
8712 (re-search-forward (car (car methods)) nil t)
8714 (setq split-name (cons (nth 1 (car methods)) split-name)))
8715 (setq methods (cdr methods)))
8717 (cond ((null split-name)
8719 (concat prompt " (default "
8720 (file-name-nondirectory default-name) ") ")
8721 (file-name-directory default-name)
8723 ((= 1 (length split-name))
8725 (concat prompt " (default " (car split-name) ") ")
8726 gnus-article-save-directory
8727 (concat gnus-article-save-directory (car split-name))))
8729 (setq split-name (mapcar (lambda (el) (list el))
8730 (nreverse split-name)))
8731 (let ((result (completing-read
8733 split-name nil nil)))
8734 (concat gnus-article-save-directory
8735 (if (string= result "")
8736 (car (car split-name))
8739 (defun gnus-summary-save-in-rmail (&optional filename)
8740 "Append this article to Rmail file.
8741 Optional argument FILENAME specifies file name.
8742 Directory to save to is default to `gnus-article-save-directory' which
8743 is initialized from the SAVEDIR environment variable."
8746 (funcall gnus-rmail-save-name gnus-newsgroup-name
8747 gnus-current-headers gnus-newsgroup-last-rmail)))
8749 (setq filename (gnus-read-save-file-name
8750 "Save in rmail file:" default-name)))
8751 (gnus-make-directory (file-name-directory filename))
8752 (gnus-eval-in-buffer-window
8757 (gnus-output-to-rmail filename))))
8758 ;; Remember the directory name to save articles.
8759 (setq gnus-newsgroup-last-rmail filename)))
8761 (defun gnus-summary-save-in-mail (&optional filename)
8762 "Append this article to Unix mail file.
8763 Optional argument FILENAME specifies file name.
8764 Directory to save to is default to `gnus-article-save-directory' which
8765 is initialized from the SAVEDIR environment variable."
8768 (funcall gnus-mail-save-name gnus-newsgroup-name
8769 gnus-current-headers gnus-newsgroup-last-mail)))
8771 (setq filename (gnus-read-save-file-name
8772 "Save in Unix mail file:" default-name)))
8774 (expand-file-name filename
8776 (file-name-directory default-name))))
8777 (gnus-make-directory (file-name-directory filename))
8778 (gnus-eval-in-buffer-window
8783 (if (and (file-readable-p filename) (rmail-file-p filename))
8784 (gnus-output-to-rmail filename)
8785 (rmail-output filename 1 t t)))))
8786 ;; Remember the directory name to save articles.
8787 (setq gnus-newsgroup-last-mail filename)))
8789 (defun gnus-summary-save-in-file (&optional filename)
8790 "Append this article to file.
8791 Optional argument FILENAME specifies file name.
8792 Directory to save to is default to `gnus-article-save-directory' which
8793 is initialized from the SAVEDIR environment variable."
8796 (funcall gnus-file-save-name gnus-newsgroup-name
8797 gnus-current-headers gnus-newsgroup-last-file)))
8799 (setq filename (gnus-read-save-file-name
8800 "Save in file:" default-name)))
8801 (gnus-make-directory (file-name-directory filename))
8802 (gnus-eval-in-buffer-window
8807 (gnus-output-to-file filename))))
8808 ;; Remember the directory name to save articles.
8809 (setq gnus-newsgroup-last-file filename)))
8811 (defun gnus-summary-save-in-pipe (&optional command)
8812 "Pipe this article to subprocess."
8814 (let ((command (read-string "Shell command on article: "
8815 gnus-last-shell-command)))
8816 (if (string-equal command "")
8817 (setq command gnus-last-shell-command))
8818 (gnus-eval-in-buffer-window
8822 (shell-command-on-region (point-min) (point-max) command nil)))
8823 (setq gnus-last-shell-command command)))
8825 ;; Summary extract commands
8827 (defun gnus-summary-insert-pseudos (pslist)
8828 (let ((buffer-read-only nil)
8829 (article (gnus-summary-article-number))
8831 (or (gnus-summary-goto-subject article)
8832 (error (format "No such article: %d" article)))
8833 (or gnus-newsgroup-headers-hashtb-by-number
8834 (gnus-make-headers-hashtable-by-number))
8835 (gnus-summary-position-cursor)
8836 (if gnus-view-pseudos
8838 (and (assq 'execute (car pslist))
8839 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8840 (eq gnus-view-pseudos 'not-confirm)))
8841 (setq pslist (cdr pslist)))
8844 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
8845 (gnus-summary-article-number)))
8848 (insert " " (file-name-nondirectory
8849 (cdr (assq 'name (car pslist))))
8850 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8851 (add-text-properties
8852 b (1+ b) (list 'gnus-subject (cdr (assq 'name (car pslist)))
8853 'gnus-number gnus-reffed-article-number
8854 'gnus-mark gnus-unread-mark
8855 'gnus-pseudo (car pslist)
8858 (gnus-sethash (int-to-string gnus-reffed-article-number)
8859 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
8860 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8861 (setq pslist (cdr pslist)))))))
8863 (defun gnus-request-pseudo-article (props)
8864 (cond ((assq 'execute props)
8865 (gnus-execute-command (cdr (assq 'execute props)))))
8866 (let ((gnus-current-article (gnus-summary-article-number)))
8867 (run-hooks 'gnus-mark-article-hook)))
8869 (defun gnus-execute-command (command &optional automatic)
8871 (gnus-article-setup-buffer)
8872 (set-buffer gnus-article-buffer)
8873 (let ((command (if automatic command (read-string "Command: " command)))
8874 (buffer-read-only nil))
8876 (insert "$ " command "\n\n")
8877 (if gnus-view-pseudo-asynchronously
8878 (start-process "gnus-execute" nil "sh" "-c" command)
8879 (call-process "sh" nil t nil "-c" command)))))
8881 (defun gnus-copy-file (file &optional to)
8884 (list (read-file-name "Copy file: " default-directory)
8885 (read-file-name "Copy file to: " default-directory)))
8886 (or to (setq to (read-file-name "Copy file to: " default-directory)))
8887 (and (file-directory-p to)
8888 (setq to (concat (file-name-as-directory to)
8889 (file-name-nondirectory file))))
8890 (copy-file file to))
8892 ;; Summary score file commands
8894 ;; Much modification of the kill (ahem, score) code and lots of the
8895 ;; functions are written by Per Abrahamsen <amanda@iesd.auc.dk>.
8897 (defun gnus-summary-header (header)
8898 ;; Return HEADER for current articles, or error.
8899 (let ((article (gnus-summary-article-number)))
8901 (aref (gnus-get-header-by-number article)
8902 (nth 1 (assoc header gnus-header-index)))
8903 (error "No article on current line"))))
8905 (defun gnus-summary-score-entry (header match type score date &optional prompt)
8906 "Enter score file entry.
8907 HEADER is the header being scored.
8908 MATCH is the string we are looking for.
8909 TYPE is a flag indicating if it is a regexp or substring.
8910 SCORE is the score to add.
8911 DATE is the expire date."
8913 (list (completing-read "Header: "
8915 (lambda (x) (fboundp (nth 2 x)))
8917 (read-string "Match: ")
8918 (y-or-n-p "Use regexp match? ")
8919 (prefix-numeric-value current-prefix-arg)
8920 (if (y-or-n-p "Expire kill? ")
8921 (current-time-string)
8923 (let ((score (gnus-score-default score))
8924 (header (downcase header)))
8925 (and prompt (setq match (read-string
8926 (format "Match %s on %s, %s: "
8927 (if date "temp" "permanent")
8929 (if (< score 0) "lower" "raise"))
8931 (and (>= (nth 1 (assoc header gnus-header-index)) 0)
8932 (gnus-summary-score-effect header match type score))
8933 (and (= score gnus-score-interactive-default-score)
8935 (let ((new (cond (type
8936 (list match score (and date (gnus-day-number date)) type))
8938 (list match score (gnus-day-number date)))
8943 (old (gnus-score-get header)))
8946 (if old (cons new old) (list new))))
8947 (gnus-score-set 'touched '(t))))
8949 (defun gnus-summary-score-effect (header match type score)
8950 "Simulate the effect of a score file entry.
8951 HEADER is the header being scored.
8952 MATCH is the string we are looking for.
8953 TYPE is a flag indicating if it is a regexp or substring.
8954 SCORE is the score to add."
8955 (interactive (list (completing-read "Header: "
8957 (lambda (x) (fboundp (nth 2 x)))
8959 (read-string "Match: ")
8960 (y-or-n-p "Use regexp match? ")
8961 (prefix-numeric-value current-prefix-arg)))
8963 (or (and (stringp match) (> (length match) 0))
8965 (goto-char (point-min))
8966 (let ((regexp (if type
8968 (concat "\\`.*" (regexp-quote match) ".*\\'"))))
8970 (let ((content (gnus-summary-header header))
8971 (case-fold-search t))
8973 (if (string-match regexp content)
8974 (gnus-summary-raise-score score))))
8975 (beginning-of-line 2)))))
8977 (defun gnus-summary-score-crossposting (score date)
8978 ;; Enter score file entry for current crossposting.
8979 ;; SCORE is the score to add.
8980 ;; DATE is the expire date.
8981 (let ((xref (gnus-summary-header "xref"))
8984 (or xref (error "This article is not crossposted"))
8985 (while (string-match " \\([^ \t]+\\):" xref start)
8986 (setq start (match-end 0))
8989 (substring xref (match-beginning 1) (match-end 1)))
8990 gnus-newsgroup-name))
8991 (gnus-summary-score-entry
8992 "xref" (concat " " group ":") nil score date t)))))
8994 (defun gnus-summary-temporarily-lower-by-subject (level)
8995 "Temporarily lower score by LEVEL for current subject.
8996 See `gnus-score-expiry-days'."
8998 (gnus-summary-score-entry
8999 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
9000 nil (- (gnus-score-default level))
9001 (current-time-string) t))
9003 (defun gnus-summary-temporarily-lower-by-author (level)
9004 "Temporarily lower score by LEVEL for current author.
9005 See `gnus-score-expiry-days'."
9007 (gnus-summary-score-entry
9008 "from" (gnus-summary-header "from") nil (- (gnus-score-default level))
9009 (current-time-string) t))
9011 (defun gnus-summary-temporarily-lower-by-body (level)
9012 "Temporarily lower score by LEVEL for a match on the body of the article.
9013 See `gnus-score-expiry-days'."
9015 (gnus-summary-score-entry
9016 "body" "" nil (- (gnus-score-default level)) (current-time-string) t))
9018 (defun gnus-summary-temporarily-lower-by-id (level)
9019 "Temporarily lower score by LEVEL for current message-id.
9020 See `gnus-score-expiry-days'."
9022 (gnus-summary-score-entry
9023 "message-id" (gnus-summary-header "message-id")
9024 nil (- (gnus-score-default level))
9025 (current-time-string)))
9027 (defun gnus-summary-temporarily-lower-by-xref (level)
9028 "Temporarily lower score by LEVEL for current xref.
9029 See `gnus-score-expiry-days'."
9031 (gnus-summary-score-crossposting
9032 (- (gnus-score-default level)) (current-time-string)))
9034 (defun gnus-summary-temporarily-lower-by-thread (level)
9035 "Temporarily lower score by LEVEL for current thread.
9036 See `gnus-score-expiry-days'."
9038 (gnus-summary-score-entry
9039 "references" (gnus-summary-header "message-id")
9040 nil (- (gnus-score-default level)) (current-time-string)))
9042 (defun gnus-summary-lower-by-subject (level)
9043 "Lower score by LEVEL for current subject."
9045 (gnus-summary-score-entry
9046 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
9047 nil (- (gnus-score-default level))
9050 (defun gnus-summary-lower-by-author (level)
9051 "Lower score by LEVEL for current author."
9053 (gnus-summary-score-entry
9054 "from" (gnus-summary-header "from") nil
9055 (- (gnus-score-default level)) nil t))
9057 (defun gnus-summary-lower-by-body (level)
9058 "Lower score by LEVEL for a match on the body of the article."
9060 (gnus-summary-score-entry
9061 "body" "" nil (- (gnus-score-default level)) nil t))
9063 (defun gnus-summary-lower-by-id (level)
9064 "Lower score by LEVEL for current message-id."
9066 (gnus-summary-score-entry
9067 "message-id" (gnus-summary-header "message-id") nil
9068 (- (gnus-score-default level)) nil))
9070 (defun gnus-summary-lower-by-xref (level)
9071 "Lower score by LEVEL for current xref."
9073 (gnus-summary-score-crossposting (- (gnus-score-default level)) nil))
9075 (defun gnus-summary-lower-followups-to-author (level)
9076 "Lower score by LEVEL for all followups to the current author."
9078 (gnus-summary-raise-followups-to-author
9079 (- (gnus-score-default level))))
9081 (defun gnus-summary-temporarily-raise-by-subject (level)
9082 "Temporarily raise score by LEVEL for current subject.
9083 See `gnus-score-expiry-days'."
9085 (gnus-summary-score-entry
9086 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
9087 nil level (current-time-string) t))
9089 (defun gnus-summary-temporarily-raise-by-author (level)
9090 "Temporarily raise score by LEVEL for current author.
9091 See `gnus-score-expiry-days'."
9093 (gnus-summary-score-entry
9094 "from" (gnus-summary-header "from") nil level (current-time-string) t))
9096 (defun gnus-summary-temporarily-raise-by-body (level)
9097 "Temporarily raise score by LEVEL for a match on the body of the article.
9098 See `gnus-score-expiry-days'."
9100 (gnus-summary-score-entry "body" "" nil level (current-time-string) t))
9102 (defun gnus-summary-temporarily-raise-by-id (level)
9103 "Temporarily raise score by LEVEL for current message-id.
9104 See `gnus-score-expiry-days'."
9106 (gnus-summary-score-entry
9107 "message-id" (gnus-summary-header "message-id")
9108 nil level (current-time-string)))
9110 (defun gnus-summary-temporarily-raise-by-xref (level)
9111 "Temporarily raise score by LEVEL for current xref.
9112 See `gnus-score-expiry-days'."
9114 (gnus-summary-score-crossposting level (current-time-string)))
9116 (defun gnus-summary-temporarily-raise-by-thread (level)
9117 "Temporarily raise score by LEVEL for current thread.
9118 See `gnus-score-expiry-days'."
9120 (gnus-summary-score-entry
9121 "references" (gnus-summary-header "message-id")
9122 nil level (current-time-string)))
9124 (defun gnus-summary-raise-by-subject (level)
9125 "Raise score by LEVEL for current subject."
9127 (gnus-summary-score-entry
9128 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
9131 (defun gnus-summary-raise-by-author (level)
9132 "Raise score by LEVEL for current author."
9134 (gnus-summary-score-entry
9135 "from" (gnus-summary-header "from") nil level nil t))
9137 (defun gnus-summary-raise-by-body (level)
9138 "Raise score by LEVEL for a match on the body of the article."
9140 (gnus-summary-score-entry "body" "" nil level nil t))
9142 (defun gnus-summary-raise-by-id (level)
9143 "Raise score by LEVEL for current message-id."
9145 (gnus-summary-score-entry
9146 "message-id" (gnus-summary-header "message-id") nil level nil))
9148 (defun gnus-summary-raise-by-xref (level)
9149 "Raise score by LEVEL for current xref."
9151 (gnus-summary-score-crossposting level nil))
9153 (defun gnus-summary-raise-followups-to-author (level)
9154 "Raise score by LEVEL for all followups to the current author."
9156 (let ((article (gnus-summary-article-number)))
9157 (if article (setq gnus-current-headers (gnus-get-header-by-number article))
9158 (error "No article on current line")))
9159 (gnus-kill-file-raise-followups-to-author
9160 (gnus-score-default level)))
9162 ;; Summary kill commands.
9164 (defun gnus-summary-edit-global-kill (article)
9165 "Edit the global score file."
9166 (interactive (list (gnus-summary-article-number)))
9167 (gnus-group-edit-global-kill article))
9169 (defun gnus-summary-edit-local-kill ()
9170 "Edit a local score file applied to the current newsgroup."
9172 (setq gnus-current-headers
9174 (int-to-string (gnus-summary-article-number))
9175 gnus-newsgroup-headers-hashtb-by-number))
9176 (gnus-set-global-variables)
9177 (gnus-group-edit-local-kill
9178 (gnus-summary-article-number) gnus-newsgroup-name))
9182 ;;; Gnus article mode
9185 (put 'gnus-article-mode 'mode-class 'special)
9187 (if gnus-article-mode-map
9189 (setq gnus-article-mode-map (make-keymap))
9190 (suppress-keymap gnus-article-mode-map)
9191 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
9192 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
9193 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
9194 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
9195 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
9196 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
9197 (define-key gnus-article-mode-map "\C-c\C-M" 'gnus-article-mail-with-original)
9198 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
9200 ;; Duplicate almost all summary keystrokes in the article mode map.
9202 (list "#" "\M-#" "\C-c\M-#" "\r" "n" "p"
9203 "N" "P" "\M-\C-n" "\M-\C-p" "." "\M-s" "\M-r"
9204 "<" ">" "l" "j" "^" "\M-^" "-" "u" "U" "d" "D"
9205 "\M-u" "\M-U" "k" "\C-k" "\M-\C-k" "c" "x" "X"
9206 "\M-\C-x" "\M-\177" "b" "B" "$" "w" "\C-c\C-r"
9207 "t" "\M-t" "a" "f" "F" "C" "S" "r" "R" "\C-c\C-f"
9208 "m" "o" "\C-o" "|" "\M-m" "\M-\C-m" "\M-k" "m" "M"
9209 "V" "\C-c\C-d" "q" "Q")))
9211 (define-key gnus-article-mode-map (car commands)
9212 'gnus-article-summary-command)
9213 (setq commands (cdr commands)))))
9216 (defun gnus-article-mode ()
9217 "Major mode for displaying an article.
9219 All normal editing commands are switched off.
9221 The following commands are available:
9223 \\<gnus-article-mode-map>
9224 \\[gnus-article-next-page]\t Scroll the article one page forwards
9225 \\[gnus-article-prev-page]\t Scroll the article one page backwards
9226 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
9227 \\[gnus-article-show-summary]\t Display the summary buffer
9228 \\[gnus-article-mail]\t Send a reply to the address near point
9229 \\[gnus-article-mail-with-original]\t Send a reply to the address near point; include the original article
9230 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
9231 \\[gnus-info-find-node]\t Go to the Gnus info node"
9233 (if gnus-visual (gnus-article-make-menu-bar))
9234 (kill-all-local-variables)
9235 (setq mode-line-modified "-- ")
9236 (make-local-variable 'mode-line-format)
9237 (setq mode-line-format (copy-sequence mode-line-format))
9238 (and (equal (nth 3 mode-line-format) " ")
9239 (setcar (nthcdr 3 mode-line-format) ""))
9240 (setq mode-name "Article")
9241 (setq major-mode 'gnus-article-mode)
9242 (make-local-variable 'minor-mode-alist)
9243 (or (assq 'gnus-show-mime minor-mode-alist)
9244 (setq minor-mode-alist
9245 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
9246 (use-local-map gnus-article-mode-map)
9247 (make-local-variable 'page-delimiter)
9248 (setq page-delimiter gnus-page-delimiter)
9249 (buffer-disable-undo (current-buffer))
9250 (setq buffer-read-only t) ;Disable modification
9251 (run-hooks 'gnus-article-mode-hook))
9253 (defun gnus-article-setup-buffer ()
9254 "Initialize article mode buffer."
9255 (or (get-buffer gnus-article-buffer)
9257 (set-buffer (get-buffer-create gnus-article-buffer))
9258 (gnus-add-current-to-buffer-list)
9259 (gnus-article-mode))))
9261 (defun gnus-request-article-this-buffer (article &optional group)
9262 "Get an article and insert it into this buffer."
9263 (setq group (or group gnus-newsgroup-name))
9264 ;; Using `gnus-request-article' directly will insert the article into
9265 ;; `nntp-server-buffer' - so we'll save some time by not having to
9266 ;; copy it from the server buffer into the article buffer.
9268 ;; We only request an article by message-id when we do not have the
9269 ;; headers for it, so we'll have to get those.
9270 (and (stringp article)
9271 (let ((gnus-override-method gnus-refer-article-method))
9272 (gnus-read-header article)))
9274 ;; If the article number is negative, that means that this article
9275 ;; doesn't belong in this newsgroup (possibly), so we find its
9276 ;; message-id and request it by id instead of number.
9277 (if (and (numberp article) (< article 0))
9279 (set-buffer gnus-summary-buffer)
9280 (let ((header (gnus-gethash (int-to-string article)
9281 gnus-newsgroup-headers-hashtb-by-number)))
9282 (if (vectorp header)
9283 ;; It's a real article.
9284 (setq article (header-id header))
9285 ;; It is an extracted pseudo-article.
9287 (gnus-request-pseudo-article header)))))
9288 ;; Get the article and into the article buffer.
9292 (let ((gnus-override-method
9293 (and (stringp article) gnus-refer-article-method)))
9294 (and (gnus-request-article article group (current-buffer))
9298 (defun gnus-read-header (id)
9299 "Read the headers of article ID and enter them into the Gnus system."
9300 (or gnus-newsgroup-headers-hashtb-by-number
9301 (gnus-make-headers-hashtable-by-number))
9303 (if (not (setq header
9304 (car (if (let ((gnus-nov-is-evil t))
9305 (gnus-retrieve-headers
9306 (list id) gnus-newsgroup-name))
9307 (gnus-get-newsgroup-headers)))))
9310 (header-set-number header gnus-reffed-article-number))
9311 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
9312 (gnus-sethash (int-to-string (header-number header)) header
9313 gnus-newsgroup-headers-hashtb-by-number)
9315 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
9316 (setq gnus-current-headers header)
9319 (defun gnus-article-prepare (article &optional all-headers header)
9320 "Prepare ARTICLE in article mode buffer.
9321 ARTICLE should either be an article number or a Message-ID.
9322 If ARTICLE is an id, HEADER should be the article headers.
9323 If ALL-HEADERS is non-nil, no headers are hidden."
9325 ;; Make sure we start in a summary buffer.
9326 (or (eq major-mode 'gnus-summary-mode)
9327 (set-buffer gnus-summary-buffer))
9328 (setq gnus-summary-buffer (current-buffer))
9329 ;; Make sure the connection to the server is alive.
9330 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
9332 (gnus-check-news-server
9333 (gnus-find-method-for-group gnus-newsgroup-name))
9334 (gnus-request-group gnus-newsgroup-name t)))
9335 (or gnus-newsgroup-headers-hashtb-by-number
9336 (gnus-make-headers-hashtable-by-number))
9337 (let* ((article (if header (header-number header) article))
9338 (summary-buffer (current-buffer))
9339 (internal-hook gnus-article-internal-prepare-hook)
9340 (bookmark (cdr (assq article gnus-newsgroup-bookmarks)))
9341 (group gnus-newsgroup-name)
9344 (gnus-article-setup-buffer)
9345 (set-buffer gnus-article-buffer)
9346 (let ((buffer-read-only nil))
9347 (if (not (setq result (gnus-request-article-this-buffer
9349 ;; There is no such article.
9352 (set-buffer gnus-summary-buffer)
9353 (setq gnus-current-article 0)
9354 (and (numberp article)
9355 (gnus-summary-mark-as-read article gnus-canceled-mark))
9356 (message "No such article (may be canceled)")
9358 (setq gnus-article-current nil)
9360 (if (not (eq result 'article))
9363 (set-buffer summary-buffer)
9364 (setq gnus-last-article gnus-current-article
9365 gnus-newsgroup-history (cons gnus-current-article
9366 gnus-newsgroup-history)
9367 gnus-current-article 0
9368 gnus-current-headers nil
9369 gnus-article-current nil)
9370 (gnus-configure-windows 'article)
9371 (gnus-set-global-variables))
9372 (gnus-set-mode-line 'article))
9373 ;; The result from the `request' was an actual article -
9374 ;; or at least some text that is now displayed in the
9376 (if (and (numberp article)
9377 (not (eq article gnus-current-article)))
9378 ;; Seems like a new article has been selected.
9379 ;; `gnus-current-article' must be an article number.
9381 (set-buffer summary-buffer)
9382 (setq gnus-last-article gnus-current-article
9383 gnus-newsgroup-history (cons gnus-current-article
9384 gnus-newsgroup-history)
9385 gnus-current-article article
9386 gnus-current-headers
9387 (gnus-get-header-by-number gnus-current-article)
9388 gnus-article-current
9389 (cons gnus-newsgroup-name gnus-current-article))
9390 (run-hooks 'gnus-mark-article-hook)
9391 (gnus-set-mode-line 'summary)
9393 (run-hooks 'gnus-visual-mark-article-hook))
9394 ;; Set the global newsgroup variables here.
9395 ;; Suggested by Jim Sisolak
9396 ;; <sisolak@trans4.neep.wisc.edu>.
9397 (gnus-set-global-variables)))
9398 ;; gnus-have-all-headers must be either T or NIL.
9399 (setq gnus-have-all-headers
9400 (not (not (or all-headers gnus-show-all-headers))))
9401 ;; Hooks for getting information from the article.
9402 ;; This hook must be called before being narrowed.
9403 (run-hooks 'internal-hook)
9404 (run-hooks 'gnus-article-prepare-hook)
9405 ;; Decode MIME message.
9406 (if (and gnus-show-mime
9407 (gnus-fetch-field "Mime-Version"))
9408 (funcall gnus-show-mime-method))
9409 ;; Perform the article display hooks.
9410 (let ((buffer-read-only nil))
9411 (run-hooks 'gnus-article-display-hook))
9413 (goto-char (point-min))
9414 (and gnus-break-pages (gnus-narrow-to-page))
9415 (gnus-set-mode-line 'article)
9416 (gnus-configure-windows 'article)
9419 (get-buffer-window gnus-article-buffer) (point-min))
9422 (message "Moved to bookmark")
9423 (search-forward "\n\n" nil t)
9424 (forward-line bookmark)))
9427 (defun gnus-article-show-all-headers ()
9428 "Show all article headers in article mode buffer."
9430 (setq gnus-have-all-headers t)
9431 (gnus-article-setup-buffer)
9432 (set-buffer gnus-article-buffer)
9433 (let ((buffer-read-only nil))
9434 (remove-text-properties 1 (point-max) '(invisible t)))))
9436 (defun gnus-article-hide-headers-if-wanted ()
9437 "Hide unwanted headers if `gnus-have-all-headers' is nil.
9438 Provided for backwards compatability."
9439 (or gnus-have-all-headers
9440 (gnus-article-hide-headers)))
9442 (defun gnus-article-hide-headers (&optional delete)
9443 "Hide unwanted headers and possibly sort them as well."
9446 (set-buffer gnus-article-buffer)
9448 (let ((sorted gnus-sorted-header-list)
9449 (buffer-read-only nil)
9450 want want-list beg want-l)
9451 ;; First we narrow to just the headers.
9454 ;; Hide any "From " lines at the beginning of (mail) articles.
9455 (while (looking-at rmail-unix-mail-delimiter)
9458 (add-text-properties 1 (point) '(invisible t)))
9459 ;; Then treat the rest of the header lines.
9462 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
9463 ;; Then we use the two regular expressions
9464 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
9465 ;; select which header lines is to remain visible in the
9468 (while (re-search-forward "^[^ \t]*:" nil t)
9470 ;; We add the headers we want to keep to a list and delete
9471 ;; them from the buffer.
9472 (if (or (and (stringp gnus-visible-headers)
9473 (looking-at gnus-visible-headers))
9474 (and (not (stringp gnus-visible-headers))
9475 (stringp gnus-ignored-headers)
9476 (not (looking-at gnus-ignored-headers))))
9480 ;; Be sure to get multi-line headers...
9481 (re-search-forward "^[^ \t]*:" nil t)
9484 (cons (buffer-substring beg (point)) want-list))
9485 (delete-region beg (point))
9488 ;; Next we perform the sorting by looking at
9489 ;; `gnus-sorted-header-list'.
9491 (while (and sorted want-list)
9492 (setq want-l want-list)
9494 (not (string-match (car sorted) (car want-l))))
9495 (setq want-l (cdr want-l)))
9498 (insert (car want-l))
9499 (setq want-list (delq (car want-l) want-list))))
9500 (setq sorted (cdr sorted)))
9501 ;; Any headers that were not matched by the sorted list we
9502 ;; just tack on the end of the visible header list.
9504 (insert (car want-list))
9505 (setq want-list (cdr want-list)))
9506 ;; And finally we make the unwanted headers invisible.
9508 (delete-region (point) (point-max))
9509 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
9510 (add-text-properties (point) (point-max) '(invisible t)))))))
9512 (defun gnus-article-hide-signature ()
9513 "Hides the signature in an article.
9514 It does this by hiding everyting after \"^-- *$\", which is what all
9515 signatures should be preceded by. Note that this may mean that parts
9516 of an article may disappear if the article has such a line in the
9517 middle of the text."
9520 (set-buffer gnus-article-buffer)
9521 (let ((buffer-read-only nil))
9522 (goto-char (point-max))
9523 (if (re-search-backward "^-- *$" nil t)
9525 (add-text-properties (point) (point-max) '(invisible t)))))))
9527 (defun gnus-article-hide-citation ()
9528 "Hide all cited text.
9529 This function uses the famous, extremely intelligent \"shoot in foot\"
9530 algorithm - which is simply deleting all lines that start with
9531 \">\". Your mileage may vary. If you come up with anything better,
9532 please do mail it to me."
9535 (set-buffer gnus-article-buffer)
9536 (let ((buffer-read-only nil))
9538 (search-forward "\n\n" nil t)
9540 (if (looking-at ">")
9541 (add-text-properties
9542 (point) (save-excursion (forward-line 1) (point))
9544 (forward-line 1)))))
9546 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
9547 (defun gnus-article-treat-overstrike ()
9548 "Translate overstrikes into bold text."
9551 (set-buffer gnus-article-buffer)
9552 (let ((buffer-read-only nil))
9553 (while (search-forward "\b" nil t)
9554 (let ((next (following-char))
9555 (previous (char-after (- (point) 2))))
9556 (cond ((eq next previous)
9557 (delete-region (- (point) 2) (point))
9558 (put-text-property (point) (1+ (point))
9561 (delete-region (1- (point)) (1+ (point)))
9562 (put-text-property (1- (point)) (point)
9565 (delete-region (- (point) 2) (point))
9566 (put-text-property (point) (1+ (point))
9567 'face 'underline))))))))
9569 (defun gnus-article-word-wrap ()
9570 "Format too long lines."
9573 (set-buffer gnus-article-buffer)
9574 (let ((buffer-read-only nil))
9576 (search-forward "\n\n" nil t)
9578 (let ((paragraph-start "^\\W"))
9580 (and (>= (current-column) (window-width))
9581 (/= (preceding-char) ?:)
9582 (fill-paragraph nil))
9583 (end-of-line 2))))))
9585 (defun gnus-article-remove-cr ()
9586 "Remove carriage returns from an article."
9589 (set-buffer gnus-article-buffer)
9590 (let ((buffer-read-only nil))
9591 (goto-char (point-min))
9592 (while (search-forward "\r" nil t)
9593 (replace-match "")))))
9595 (defun gnus-article-display-x-face ()
9596 "Look for an X-Face header and display it if present."
9599 (set-buffer gnus-article-buffer)
9600 (goto-char (point-min))
9601 (if (or (not gnus-article-x-face-command)
9602 (not (re-search-forward "^X-Face: " nil t)))
9609 (while (and (looking-at "[ \t]")
9610 (zerop (forward-line 1))))
9612 (command gnus-article-x-face-command))
9613 (if (symbolp command)
9614 (and (or (fboundp command) (error "%s is not a function" command))
9615 (funcall command face))
9616 (let ((process (start-process "gnus-x-face" nil "sh" "-c" command)))
9619 (process-send-string process face)
9620 (process-send-eof process))
9621 (error "Couldn't start process"))))))))
9623 (defun gnus-article-de-quoted-unreadable ()
9624 "Do a naive translation of a quoted-printable-encoded article.
9625 This is in no way, shape or form meant as a replacement for real MIME
9626 processing, but is simply a stop-gap measure until MIME support is
9631 (set-buffer gnus-article-buffer)
9632 (let ((buffer-read-only nil))
9634 (goto-char (point-min))
9635 (while (re-search-forward "=[0-9A-F][0-9A-F]" nil t)
9639 (* 16 (gnus-hex-char-to-integer
9640 (char-after (1+ (match-beginning 0)))))
9641 (gnus-hex-char-to-integer
9642 (char-after (1- (match-end 0))))))))))))
9644 ;; Taken from hexl.el.
9645 (defun gnus-hex-char-to-integer (character)
9646 "Take a char and return its value as if it was a hex digit."
9647 (if (and (>= character ?0) (<= character ?9))
9649 (let ((ch (logior character 32)))
9650 (if (and (>= ch ?a) (<= ch ?f))
9652 (error (format "Invalid hex digit `%c'." ch))))))
9656 (defun gnus-output-to-rmail (file-name)
9657 "Append the current article to an Rmail file named FILE-NAME."
9659 ;; Most of these codes are borrowed from rmailout.el.
9660 (setq file-name (expand-file-name file-name))
9661 (setq rmail-default-rmail-file file-name)
9662 (let ((artbuf (current-buffer))
9663 (tmpbuf (get-buffer-create " *Gnus-output*")))
9665 (or (get-file-buffer file-name)
9666 (file-exists-p file-name)
9667 (if (gnus-yes-or-no-p
9668 (concat "\"" file-name "\" does not exist, create it? "))
9669 (let ((file-buffer (create-file-buffer file-name)))
9671 (set-buffer file-buffer)
9672 (rmail-insert-rmail-file-header)
9673 (let ((require-final-newline nil))
9674 (write-region (point-min) (point-max) file-name t 1)))
9675 (kill-buffer file-buffer))
9676 (error "Output file does not exist")))
9678 (buffer-disable-undo (current-buffer))
9680 (insert-buffer-substring artbuf)
9681 (gnus-convert-article-to-rmail)
9682 ;; Decide whether to append to a file or to an Emacs buffer.
9683 (let ((outbuf (get-file-buffer file-name)))
9685 (append-to-file (point-min) (point-max) file-name)
9686 ;; File has been visited, in buffer OUTBUF.
9688 (let ((buffer-read-only nil)
9689 (msg (and (boundp 'rmail-current-message)
9690 rmail-current-message)))
9691 ;; If MSG is non-nil, buffer is in RMAIL mode.
9694 (narrow-to-region (point-max) (point-max))))
9695 (insert-buffer-substring tmpbuf)
9698 (goto-char (point-min))
9700 (search-backward "\^_")
9701 (narrow-to-region (point) (point-max))
9702 (goto-char (1+ (point-min)))
9703 (rmail-count-new-messages t)
9704 (rmail-show-message msg)))))))
9705 (kill-buffer tmpbuf)))
9707 (defun gnus-output-to-file (file-name)
9708 "Append the current article to a file named FILE-NAME."
9709 (setq file-name (expand-file-name file-name))
9710 (let ((artbuf (current-buffer))
9711 (tmpbuf (get-buffer-create " *Gnus-output*")))
9714 (buffer-disable-undo (current-buffer))
9716 (insert-buffer-substring artbuf)
9717 ;; Append newline at end of the buffer as separator, and then
9719 (goto-char (point-max))
9721 (append-to-file (point-min) (point-max) file-name))
9722 (kill-buffer tmpbuf)))
9724 (defun gnus-convert-article-to-rmail ()
9725 "Convert article in current buffer to Rmail message format."
9726 (let ((buffer-read-only nil))
9727 ;; Convert article directly into Babyl format.
9728 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
9729 (goto-char (point-min))
9730 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
9731 (while (search-forward "\n\^_" nil t) ;single char
9732 (replace-match "\n^_")) ;2 chars: "^" and "_"
9733 (goto-char (point-max))
9736 (defun gnus-narrow-to-page (&optional arg)
9737 "Make text outside current page invisible except for page delimiter.
9738 A numeric arg specifies to move forward or backward by that many pages,
9739 thus showing a page other than the one point was originally in."
9741 (setq arg (if arg (prefix-numeric-value arg) 0))
9743 (forward-page -1) ;Beginning of current page.
9748 (forward-page (1- arg))))
9749 ;; Find the end of the page.
9751 ;; If we stopped due to end of buffer, stay there.
9752 ;; If we stopped after a page delimiter, put end of restriction
9753 ;; at the beginning of that line.
9754 ;; These are commented out.
9755 ;; (if (save-excursion (beginning-of-line)
9756 ;; (looking-at page-delimiter))
9757 ;; (beginning-of-line))
9758 (narrow-to-region (point)
9760 ;; Find the top of the page.
9762 ;; If we found beginning of buffer, stay there.
9763 ;; If extra text follows page delimiter on same line,
9765 ;; Otherwise, show text starting with following line.
9766 (if (and (eolp) (not (bobp)))
9770 (defun gnus-gmt-to-local ()
9771 "Rewrite Date header described in GMT to local in current buffer.
9772 Intended to be used with gnus-article-prepare-hook."
9776 (goto-char (point-min))
9777 (narrow-to-region (point-min)
9778 (progn (search-forward "\n\n" nil 'move) (point)))
9779 (goto-char (point-min))
9780 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
9781 (let ((buffer-read-only nil)
9782 (date (buffer-substring (match-beginning 1) (match-end 1))))
9783 (delete-region (match-beginning 1) (match-end 1))
9785 (timezone-make-date-arpa-standard
9786 date nil (current-time-zone))))))))
9789 ;; Article mode commands
9791 (defun gnus-article-next-page (lines)
9792 "Show next page of current article.
9793 If end of article, return non-nil. Otherwise return nil.
9794 Argument LINES specifies lines to be scrolled up."
9796 (move-to-window-line -1)
9797 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
9800 (and (pos-visible-in-window-p) ;Not continuation line.
9802 ;; Nothing in this page.
9803 (if (or (not gnus-break-pages)
9806 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
9808 (gnus-narrow-to-page 1) ;Go to next page.
9810 ;; More in this page.
9814 ;; Long lines may cause an end-of-buffer error.
9815 (goto-char (point-max))))
9818 (defun gnus-article-prev-page (lines)
9819 "Show previous page of current article.
9820 Argument LINES specifies lines to be scrolled down."
9822 (move-to-window-line 0)
9823 (if (and gnus-break-pages
9825 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
9827 (gnus-narrow-to-page -1) ;Go to previous page.
9828 (goto-char (point-max))
9830 (scroll-down lines)))
9832 (defun gnus-article-refer-article ()
9833 "Read article specified by message-id around point."
9835 (search-forward ">" nil t) ;Move point to end of "<....>".
9836 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
9838 (buffer-substring (match-beginning 1) (match-end 1))))
9839 (set-buffer gnus-summary-buffer)
9840 (gnus-summary-refer-article message-id))
9841 (error "No references around point")))
9843 (defun gnus-article-mail (yank)
9844 "Send a reply to the address near point.
9845 If YANK is non-nil, include the original article."
9849 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
9850 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
9853 (switch-to-buffer gnus-summary-buffer)
9854 (funcall gnus-mail-reply-method yank address)))))
9856 (defun gnus-article-mail-with-original ()
9857 "Send a reply to the address near point and include the original article."
9859 (gnus-article-mail 'yank))
9861 (defun gnus-article-show-summary ()
9862 "Reconfigure windows to show summary buffer."
9864 (gnus-configure-windows 'article)
9865 (pop-to-buffer gnus-summary-buffer)
9866 (gnus-summary-goto-subject gnus-current-article))
9868 (defun gnus-article-describe-briefly ()
9869 "Describe article mode commands briefly."
9872 (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")))
9874 (defun gnus-article-summary-command ()
9875 "Execute the last keystroke in the summary buffer."
9878 (let ((obuf (current-buffer))
9879 (owin (current-window-configuration)))
9880 (switch-to-buffer gnus-summary-buffer 'norecord)
9881 (execute-kbd-macro (this-command-keys))
9883 (let ((npoint (point)))
9884 (set-window-configuration owin)
9885 (set-window-start (get-buffer-window (current-buffer)) (point)))))
9887 ;; caesar-region written by phr@prep.ai.mit.edu Nov 86
9888 ;; Modified by tower@prep Nov 86
9889 ;; Modified by umerin@flab.flab.Fujitsu.JUNET for ROT47.
9891 (defun gnus-caesar-region (&optional n)
9892 "Caesar rotation of region by N, default 13, for decrypting netnews.
9893 ROT47 will be performed for Japanese text in any case."
9894 (interactive (if current-prefix-arg ; Was there a prefix arg?
9895 (list (prefix-numeric-value current-prefix-arg))
9897 (cond ((not (numberp n)) (setq n 13))
9898 (t (setq n (mod n 26)))) ;canonicalize N
9899 (if (not (zerop n)) ; no action needed for a rot of 0
9901 (if (or (not (boundp 'caesar-translate-table))
9902 (not caesar-translate-table)
9903 (/= (aref caesar-translate-table ?a) (+ ?a n)))
9905 (lower "abcdefghijklmnopqrstuvwxyz")
9907 (message "Building caesar-translate-table...")
9908 (setq caesar-translate-table (make-vector 256 0))
9910 (aset caesar-translate-table i i)
9912 (setq lower (concat lower lower)
9913 upper (upcase lower)
9916 (aset caesar-translate-table (+ ?a i) (aref lower (+ i n)))
9917 (aset caesar-translate-table (+ ?A i) (aref upper (+ i n)))
9919 ;; ROT47 for Japanese text.
9920 ;; Thanks to ichikawa@flab.fujitsu.junet.
9922 (let ((t1 (logior ?O 128))
9923 (t2 (logior ?! 128))
9924 (t3 (logior ?~ 128)))
9926 (aset caesar-translate-table i
9927 (let ((v (aref caesar-translate-table i)))
9928 (if (<= v t1) (if (< v t2) v (+ v 47))
9929 (if (<= v t3) (- v 47) v))))
9931 (message "Building caesar-translate-table... done")))
9932 (let ((from (region-beginning))
9935 (setq str (buffer-substring from to))
9936 (setq len (length str))
9938 (aset str i (aref caesar-translate-table (aref str i)))
9941 (delete-region from to)
9945 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
9948 (defalias 'gnus-batch-kill 'gnus-batch-score)
9950 (defun gnus-batch-score ()
9951 "Run batched scoring.
9952 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
9953 Newsgroups is a list of strings in Bnews format. If you want to score
9954 the comp hierarchy, you'd say \"comp.all\". If you would not like to
9955 score the alt hierarchy, you'd say \"!alt.all\"."
9958 (gnus-parse-n-options
9959 (apply (function concat)
9960 (mapcar (lambda (g) (concat g " "))
9961 command-line-args-left))))
9962 (gnus-expert-user t)
9963 (nnmail-spool-file nil)
9964 (gnus-use-dribble-file nil)
9965 (yes (car yes-and-no))
9966 (no (cdr yes-and-no))
9967 group subscribed newsrc entry
9968 ;; Disable verbose message.
9969 gnus-novice-user gnus-large-newsgroup)
9970 ;; Eat all arguments.
9971 (setq command-line-args-left nil)
9974 ;; Apply kills to specified newsgroups in command line arguments.
9975 (setq newsrc (cdr gnus-newsrc-assoc))
9977 (setq group (car (car newsrc)))
9978 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
9979 (if (and (<= (nth 1 (car newsrc)) 5)
9981 (or (eq (car entry) t)
9982 (not (zerop (car entry)))))
9983 (if yes (string-match yes group) t)
9984 (or (null no) (not (string-match no group))))
9986 (gnus-summary-read-group group nil t)
9987 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
9988 (gnus-summary-exit))))
9989 (setq newsrc (cdr newsrc)))
9991 (switch-to-buffer gnus-group-buffer)
9992 (gnus-group-save-newsrc)))
9994 (defun gnus-apply-kill-file ()
9995 "Apply a kill file to the current newsgroup.
9996 Returns the number of articles marked as read."
9997 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
9998 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
9999 (gnus-apply-kill-file-internal)
10002 (defun gnus-kill-save-kill-buffer ()
10004 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
10005 (if (get-file-buffer file)
10007 (set-buffer (get-file-buffer file))
10008 (and (buffer-modified-p) (save-buffer))
10009 (kill-buffer (current-buffer)))))))
10011 (defvar gnus-kill-file-name "KILL"
10012 "Suffix of the kill files.")
10014 (defun gnus-newsgroup-kill-file (newsgroup)
10015 "Return the name of a kill file name for NEWSGROUP.
10016 If NEWSGROUP is nil, return the global kill file name instead."
10017 (cond ((or (null newsgroup)
10018 (string-equal newsgroup ""))
10019 ;; The global KILL file is placed at top of the directory.
10020 (expand-file-name gnus-kill-file-name
10021 (or gnus-kill-files-directory "~/News")))
10022 ((gnus-use-long-file-name 'not-kill)
10023 ;; Append ".KILL" to newsgroup name.
10024 (expand-file-name (concat newsgroup "." gnus-kill-file-name)
10025 (or gnus-kill-files-directory "~/News")))
10027 ;; Place "KILL" under the hierarchical directory.
10028 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
10029 "/" gnus-kill-file-name)
10030 (or gnus-kill-files-directory "~/News")))))
10034 ;;; Gnus Score Files
10037 ;; All score code written by Per Abrahamsen <abraham@iesd.auc.dk>.
10039 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10040 (defun gnus-score-set-mark-below (score)
10041 "Automatically mark articles with score below SCORE as read."
10043 (list (or (and current-prefix-arg (prefix-numeric-value current-prefix-arg))
10044 (string-to-int (read-string "Mark below: ")))))
10045 (setq score (or score gnus-summary-default-score 0))
10046 (gnus-score-set 'mark (list score))
10047 (gnus-score-set 'touched '(t))
10048 (setq gnus-summary-mark-below score)
10049 (gnus-summary-update-lines))
10051 (defun gnus-score-set-expunge-below (score)
10052 "Automatically expunge articles with score below SCORE."
10054 (list (or (and current-prefix-arg (prefix-numeric-value current-prefix-arg))
10055 (string-to-int (read-string "Expunge below: ")))))
10056 (setq score (or score gnus-summary-default-score 0))
10057 (gnus-score-set 'expunge (list score))
10058 (gnus-score-set 'touched '(t)))
10060 (defun gnus-score-default (level)
10061 (if level (prefix-numeric-value level)
10062 gnus-score-interactive-default-score))
10064 (defun gnus-score-set (symbol value &optional alist)
10065 ;; Set SYMBOL to VALUE in ALIST.
10070 (gnus-score-load (gnus-score-file-name gnus-newsgroup-name))
10071 gnus-score-alist)))
10072 (entry (assoc symbol alist)))
10073 (cond ((gnus-score-get 'read-only alist)
10074 ;; This is a read-only score file, so we do nothing.
10077 (setcdr entry value))
10079 (error "Empty alist"))
10082 (cons (cons symbol value) (cdr alist)))))))
10084 (defun gnus-score-get (symbol &optional alist)
10085 ;; Get SYMBOL's definition in ALIST.
10091 (gnus-score-file-name gnus-newsgroup-name))
10092 gnus-score-alist)))))
10094 (defun gnus-score-change-score-file (file)
10095 "Change current score alist."
10097 (list (completing-read "Score file: " gnus-score-cache)))
10098 (setq gnus-current-score-file file)
10099 (gnus-score-load-file file))
10101 (defun gnus-score-edit-alist (file)
10102 "Edit the current score alist."
10103 (interactive (list gnus-current-score-file))
10104 (and (buffer-name gnus-summary-buffer) (gnus-score-save))
10105 (setq gnus-winconf-edit-score (current-window-configuration))
10106 (gnus-configure-windows 'article)
10107 (pop-to-buffer (find-file-noselect file))
10108 (message (substitute-command-keys
10109 "\\<gnus-score-mode-map>\\[gnus-score-edit-done] to save edits"))
10112 (defun gnus-score-edit-file (file)
10113 "Edit a score file."
10115 (list (read-file-name "Edit score file: " gnus-kill-files-directory)))
10116 (and (buffer-name gnus-summary-buffer) (gnus-score-save))
10117 (setq gnus-winconf-edit-score (current-window-configuration))
10118 (gnus-configure-windows 'article)
10119 (pop-to-buffer (find-file-noselect file))
10120 (message (substitute-command-keys
10121 "\\<gnus-score-mode-map>\\[gnus-score-edit-done] to save edits"))
10124 (defun gnus-score-load-file (file)
10125 ;; Load score file FILE. Returns a list a retrieved score-alists.
10126 (setq gnus-kill-files-directory (or gnus-kill-files-directory "~/News/"))
10127 (let* ((file (expand-file-name
10128 (or (and (string-match
10129 (concat "^" (expand-file-name
10130 gnus-kill-files-directory))
10131 (expand-file-name file))
10133 (concat gnus-kill-files-directory file))))
10134 (cached (assoc file gnus-score-cache))
10135 (global (member file gnus-internal-global-score-files))
10138 ;; The score file was already loaded.
10139 (setq alist (cdr cached))
10140 ;; We load the score file.
10141 (setq gnus-score-alist nil)
10142 (setq alist (gnus-score-load-score-alist file))
10143 ;; We add '(touched) to the alist to signify that it hasn't been
10145 (or (assq 'touched alist) (setq alist (cons (list 'touched nil) alist)))
10146 ;; If it is a global score file, we make it read-only.
10148 (not (assq 'read-only alist))
10149 (setq alist (cons (list 'read-only t) alist)))
10151 (setq gnus-score-cache
10152 (cons (cons file alist) gnus-score-cache)))
10153 ;; If there are actual scores in the alist, we add it to the
10154 ;; return value of this function.
10155 (if (memq t (mapcar (lambda (e) (stringp (car e))) alist))
10156 (setq lists (list alist)))
10157 ;; Treat the other possible atoms in the score alist.
10158 (let ((mark (car (gnus-score-get 'mark alist)))
10159 (expunge (car (gnus-score-get 'expunge alist)))
10161 (car (gnus-score-get 'mark-and-expunge alist)))
10162 (read-only (gnus-score-get 'read-only alist))
10163 (files (gnus-score-get 'files alist))
10164 (exclude-files (gnus-score-get 'exclude-files alist))
10165 (orphan (gnus-score-get 'orphan alist))
10166 (eval (gnus-score-get 'eval alist)))
10167 ;; We do not respect eval and files atoms from global score
10169 (and files (not global)
10170 (setq lists (apply 'append lists
10171 (mapcar (lambda (file)
10172 (gnus-score-load-file file))
10174 (and eval (not global) (eval eval))
10175 (setq gnus-scores-exclude-files exclude-files)
10176 (if orphan (setq gnus-orphan-score (car orphan)))
10177 (setq gnus-summary-mark-below
10178 (or mark mark-and-expunge gnus-summary-mark-below))
10179 (setq gnus-summary-expunge-below
10180 (or expunge mark-and-expunge gnus-summary-expunge-below)))
10181 (setq gnus-current-score-file file)
10182 (setq gnus-score-alist alist)
10185 (defun gnus-score-load (file)
10186 ;; Load score FILE.
10187 (let ((cache (assoc file gnus-score-cache)))
10189 (setq gnus-score-alist (cdr cache))
10190 (setq gnus-score-alist nil)
10191 (gnus-score-load-score-alist file)
10192 (or gnus-score-alist
10193 (setq gnus-score-alist (copy-alist '((touched nil)))))
10194 (setq gnus-score-cache
10195 (cons (cons file gnus-score-alist) gnus-score-cache)))))
10197 (defun gnus-score-remove-from-cache (file)
10198 (setq gnus-score-cache
10199 (delq (assoc file gnus-score-cache) gnus-score-cache)))
10201 (defun gnus-score-load-score-alist (file)
10203 (if (file-readable-p file)
10206 (set-buffer (get-buffer-create " *gnus work*"))
10207 (buffer-disable-undo (current-buffer))
10209 (insert-file-contents file)
10210 (goto-char (point-min))
10211 ;; Only do the loading if the score file isn't empty.
10212 (if (save-excursion (re-search-forward "[()0-9a-zA-Z]" nil t))
10215 (read (current-buffer))
10218 (message "Problem with score file %s" file)
10222 (if (eq (car alist) 'setq)
10223 (setq gnus-score-alist (gnus-score-transform-old-to-new alist))
10224 (setq gnus-score-alist alist))
10225 (setq gnus-score-alist
10226 (gnus-score-check-syntax gnus-score-alist)))
10227 (setq gnus-score-alist nil))))
10229 (defun gnus-score-check-syntax (alist)
10233 ((not (consp alist))
10234 (message "Score file is not a list: %s" alist)
10240 (while (and a (not err))
10241 (cond ((not (listp (car a)))
10242 (message "Illegal score element: %s" (car a))
10244 ((and (stringp (car (car a)))
10245 (not (listp (nth 1 (car a)))))
10246 (message "Illegal header match: %s" (nth 1 (car a)))
10249 (setq a (cdr a)))))
10256 (defun gnus-score-transform-old-to-new (alist)
10257 (let* ((alist (nth 2 alist))
10259 (if (eq (car alist) 'quote)
10260 (setq alist (nth 1 alist)))
10262 (setq entry (car alist))
10263 (if (stringp (car entry))
10264 (let ((scor (cdr entry)))
10265 (setq out (cons entry out))
10268 (list (car (car scor)) (nth 2 (car scor))
10269 (and (nth 3 (car scor))
10270 (gnus-day-number (nth 3 (car scor))))
10271 (if (nth 1 (car scor)) 'r 's)))
10272 (setq scor (cdr scor))))
10273 (setq out (cons (if (not (listp (cdr entry)))
10274 (list (car entry) (cdr entry))
10277 (setq alist (cdr alist)))
10278 (cons (list 'touched t) (nreverse out))))
10280 (defun gnus-score-save ()
10281 ;; Save all SCORE information.
10282 (let ((cache gnus-score-cache))
10284 (setq gnus-score-alist nil)
10285 (set-buffer (get-buffer-create "*Score*"))
10286 (buffer-disable-undo (current-buffer))
10287 (let (entry score file)
10289 (setq entry (car cache)
10293 (if (or (not (equal (gnus-score-get 'touched score) '(t)))
10294 (gnus-score-get 'read-only score)
10295 (not (file-writable-p file)))
10297 (setq score (delq (assq 'touched score) score))
10299 (let (emacs-lisp-mode-hook)
10300 (pp score (current-buffer)))
10301 (gnus-make-directory (file-name-directory file))
10302 (write-region (point-min) (point-max) file nil 'silent))))
10303 (kill-buffer (current-buffer)))))
10305 (defun gnus-score-headers ()
10306 ;; Score `gnus-newsgroup-headers'.
10307 (let ((func gnus-score-find-score-files-function)
10308 score-files scores)
10309 (and func (not (listp func))
10310 (setq func (list func)))
10311 ;; Go through all the functions for finding score files (or actual
10312 ;; scores) and add them to a list.
10314 (and (symbolp (car func))
10315 (fboundp (car func))
10317 (nconc score-files (funcall (car func) gnus-newsgroup-name))))
10318 (setq func (cdr func)))
10319 ;; PLM: probably this is not the best place to clear orphan-score
10320 (setq gnus-orphan-score nil)
10321 ;; Load the SCORE files.
10323 (if (stringp (car score-files))
10324 ;; It is a string, which means that it's a score file name,
10325 ;; so we load the score file and add the score alist to
10326 ;; the list of alists.
10327 (setq scores (nconc (gnus-score-load-file (car score-files)) scores))
10328 ;; It is an alist, so we just add it to the list directly.
10329 (setq scores (nconc (car score-files) scores)))
10330 (setq score-files (cdr score-files)))
10331 ;; Prune the score files that are to be excluded, if any.
10332 (if (not gnus-scores-exclude-files)
10337 (and (setq c (rassq (car s) gnus-score-cache))
10338 (member (car c) gnus-scores-exclude-files)
10339 (setq scores (delq (car s) scores)))
10340 (setq s (cdr s)))))
10341 (if (not (and gnus-summary-default-score
10343 (> (length gnus-newsgroup-headers)
10344 (length gnus-newsgroup-scored))))
10346 (let* ((entries gnus-header-index)
10347 (now (gnus-day-number (current-time-string)))
10348 (expire (- now gnus-score-expiry-days))
10349 (headers gnus-newsgroup-headers)
10351 (message "Scoring...")
10352 ;; Create articles, an alist of the form `(HEADER . SCORE)'.
10354 (setq header (car headers)
10355 headers (cdr headers))
10356 ;; WARNING: The assq makes the function O(N*S) while it could
10357 ;; be written as O(N+S), where N is (length gnus-newsgroup-headers)
10358 ;; and S is (length gnus-newsgroup-scored).
10359 (or (assq (header-number header) gnus-newsgroup-scored)
10360 (setq gnus-scores-articles ;Total of 2 * N cons-cells used.
10361 (cons (cons header (or gnus-summary-default-score 0))
10362 gnus-scores-articles))))
10365 (set-buffer (get-buffer-create "*Headers*"))
10366 (buffer-disable-undo (current-buffer))
10368 (if gnus-orphan-score
10370 (setq gnus-score-index
10371 (nth 1 (assoc "references" gnus-header-index)))
10372 (gnus-score-orphans gnus-orphan-score)))
10373 ;; Run each header through the score process.
10375 (setq entry (car entries)
10376 header (nth 0 entry)
10377 entries (cdr entries))
10378 (setq gnus-score-index (nth 1 (assoc header gnus-header-index)))
10379 (if (< 0 (apply 'max (mapcar
10381 (length (gnus-score-get header score)))
10383 (funcall (nth 2 entry) scores header now expire)))
10384 ;; Remove the buffer.
10385 (kill-buffer (current-buffer)))
10387 ;; Add articles to `gnus-newsgroup-scored'.
10388 (while gnus-scores-articles
10389 (or (= gnus-summary-default-score (cdr (car gnus-scores-articles)))
10390 (setq gnus-newsgroup-scored
10391 (cons (cons (header-number
10392 (car (car gnus-scores-articles)))
10393 (cdr (car gnus-scores-articles)))
10394 gnus-newsgroup-scored)))
10395 (setq gnus-scores-articles (cdr gnus-scores-articles)))
10397 (message "Scoring...done")))))
10400 (defun gnus-get-new-thread-ids (articles)
10401 (let ((index (nth 1 (assoc "message-id" gnus-header-index)))
10402 (refind gnus-score-index)
10403 id-list art this tref)
10405 (setq art (car articles)
10406 this (aref (car art) index)
10407 tref (aref (car art) refind)
10408 articles (cdr articles))
10409 (if (string-equal tref "") ;no references line
10410 (setq id-list (cons this id-list))))
10413 ;; Orphan functions written by plm@atcmp.nl (Peter Mutsaers).
10414 (defun gnus-score-orphans (score)
10415 (let ((new-thread-ids (gnus-get-new-thread-ids gnus-scores-articles))
10416 (index (nth 1 (assoc "references" gnus-header-index)))
10417 alike articles art arts this last this-id)
10419 (setq gnus-scores-articles (sort gnus-scores-articles 'gnus-score-string<)
10420 articles gnus-scores-articles)
10422 ;;more or less the same as in gnus-score-string
10425 (setq art (car articles)
10426 this (aref (car art) gnus-score-index)
10427 articles (cdr articles))
10428 ;;completely skip if this is empty (not a child, so not an orphan)
10429 (if (not (string= this ""))
10430 (if (equal last this)
10431 ;; O(N*H) cons-cells used here, where H is the number of
10433 (setq alike (cons art alike))
10436 ;; Insert the line, with a text property on the
10437 ;; terminating newline refering to the articles with
10440 (put-text-property (1- (point)) (point) 'articles alike)))
10441 (setq alike (list art)
10443 (and last ; Bwadr, duplicate code.
10446 (put-text-property (1- (point)) (point) 'articles alike)))
10448 ;; PLM: now delete those lines that contain an entry from new-thread-ids
10449 (while new-thread-ids
10450 (setq this-id (car new-thread-ids)
10451 new-thread-ids (cdr new-thread-ids))
10452 (goto-char (point-min))
10453 (while (search-forward this-id nil t)
10454 ;; found a match. remove this line
10456 (beginning-of-line)
10459 ;; now for each line: update its articles with score by moving to
10460 ;; every end-of-line in the buffer and read the articles property
10461 (goto-char (point-min))
10462 (while (eq 0 (progn
10464 (setq arts (get-text-property (point) 'articles))
10466 (setq art (car arts)
10468 (setcdr art (+ score (cdr art))))
10469 (forward-line))))))
10472 (defun gnus-score-integer (scores header now expire)
10473 (let ((gnus-score-index (nth 1 (assoc header gnus-header-index)))
10474 alike last this art entries alist articles)
10478 (setq alist (car scores)
10479 scores (cdr scores)
10480 entries (assoc header alist))
10481 (while (cdr entries) ;First entry is the header index.
10482 (let* ((rest (cdr entries))
10484 (match (nth 0 kill))
10485 (type (or (nth 3 kill) '>))
10486 (score (or (nth 1 kill) gnus-score-interactive-default-score))
10487 (date (nth 2 kill))
10489 (match-func (if (or (eq type '>) (eq type '<) (eq type '<=)
10490 (eq type '>=) (eq type '=))
10492 (error "Illegal match type: %s" type)))
10493 (articles gnus-scores-articles)
10495 ;; Instead of doing all the clever stuff that
10496 ;; `gnus-score-string' does to minimize searches and stuff,
10497 ;; I will assume that people generally will put so few
10498 ;; matches on numbers that any cleverness will take more
10499 ;; time than one would gain.
10501 (and (funcall match-func match
10502 (or (aref (car (car articles)) gnus-score-index) 0))
10505 (setcdr (car articles) (+ score (cdr (car articles))))))
10506 (setq articles (cdr articles)))
10507 ;; Update expire date
10508 (cond ((null date)) ;Permanent entry.
10509 (found ;Match, update date.
10510 (gnus-score-set 'touched '(t) alist)
10511 (setcar (nthcdr 2 kill) now))
10512 ((< date expire) ;Old entry, remove.
10513 (gnus-score-set 'touched '(t) alist)
10514 (setcdr entries (cdr rest))
10515 (setq rest entries)))
10516 (setq entries rest))))))
10518 (defun gnus-score-date (scores header now expire)
10519 (let ((gnus-score-index (nth 1 (assoc header gnus-header-index)))
10520 alike last this art entries alist articles)
10524 (setq alist (car scores)
10525 scores (cdr scores)
10526 entries (assoc header alist))
10527 (while (cdr entries) ;First entry is the header index.
10528 (let* ((rest (cdr entries))
10530 (match (timezone-make-date-sortable (nth 0 kill)))
10531 (type (or (nth 3 kill) 'before))
10532 (score (or (nth 1 kill) gnus-score-interactive-default-score))
10533 (date (nth 2 kill))
10536 (cond ((eq type 'after) 'string<)
10537 ((eq type 'before) 'gnus-string>)
10538 ((eq type 'at) 'string=)
10539 (t (error "Illegal match type: %s" type))))
10540 (articles gnus-scores-articles)
10542 ;; Instead of doing all the clever stuff that
10543 ;; `gnus-score-string' does to minimize searches and stuff,
10544 ;; I will assume that people generally will put so few
10545 ;; matches on numbers that any cleverness will take more
10546 ;; time than one would gain.
10549 (setq l (aref (car (car articles)) gnus-score-index))
10550 (funcall match-func match (timezone-make-date-sortable l))
10553 (setcdr (car articles) (+ score (cdr (car articles))))))
10554 (setq articles (cdr articles)))
10555 ;; Update expire date
10556 (cond ((null date)) ;Permanent entry.
10557 (found ;Match, update date.
10558 (gnus-score-set 'touched '(t) alist)
10559 (setcar (nthcdr 2 kill) now))
10560 ((< date expire) ;Old entry, remove.
10561 (gnus-score-set 'touched '(t) alist)
10562 (setcdr entries (cdr rest))
10563 (setq rest entries)))
10564 (setq entries rest))))))
10566 (defun gnus-score-body (scores header now expire)
10568 (set-buffer nntp-server-buffer)
10570 (let* ((buffer-read-only nil)
10571 (articles gnus-scores-articles)
10572 (all-scores scores)
10573 (request-func (cond ((string= "head" (downcase header))
10574 'gnus-request-head)
10575 ((string= "body" (downcase header))
10576 'gnus-request-body)
10577 (t 'gnus-request-article)))
10578 alike last this art entries alist ofunc article)
10579 ;; Not all backends support partial fetching. In that case,
10580 ;; we just fetch the entire article.
10581 (or (gnus-check-backend-function request-func gnus-newsgroup-name)
10583 (setq ofunc request-func)
10584 (setq request-func 'gnus-request-article)))
10586 (setq article (header-number (car (car articles))))
10587 (message "Scoring on article %s..." article)
10588 (if (not (funcall request-func article gnus-newsgroup-name))
10591 (goto-char (point-min))
10592 ;; If just parts of the article is to be searched, but the
10593 ;; backend didn't support partial fetching, we just narrow
10594 ;; to the relevant parts.
10596 (if (eq ofunc 'gnus-request-head)
10599 (or (search-forward "\n\n" nil t) (point-max)))
10601 (or (search-forward "\n\n" nil t) (point))
10603 (setq scores all-scores)
10606 (setq alist (car scores)
10607 scores (cdr scores)
10608 entries (assoc header alist))
10609 (while (cdr entries) ;First entry is the header index.
10610 (let* ((rest (cdr entries))
10612 (match (nth 0 kill))
10613 (type (or (nth 3 kill) 's))
10614 (score (or (nth 1 kill)
10615 gnus-score-interactive-default-score))
10616 (date (nth 2 kill))
10619 (not (or (eq type 'R) (eq type 'S)
10620 (eq type 'Regexp) (eq type 'String))))
10622 (cond ((or (eq type 'r) (eq type 'R)
10623 (eq type 'regexp) (eq type 'Regexp))
10624 're-search-forward)
10625 ((or (eq type 's) (eq type 'S)
10626 (eq type 'string) (eq type 'String))
10629 (error "Illegal match type: %s" type))))
10631 (goto-char (point-min))
10632 (if (funcall search-func match nil t)
10633 ;; Found a match, update scores.
10635 (setcdr (car articles) (+ score (cdr (car articles))))
10637 ;; Update expire date
10638 (cond ((null date)) ;Permanent entry.
10639 (found ;Match, update date.
10640 (gnus-score-set 'touched '(t) alist)
10641 (setcar (nthcdr 2 kill) now))
10642 ((< date expire) ;Old entry, remove.
10643 (gnus-score-set 'touched '(t) alist)
10644 (setcdr entries (cdr rest))
10645 (setq rest entries)))
10646 (setq entries rest)))))
10647 (setq articles (cdr articles)))))))
10649 (defun gnus-score-string (scores header now expire)
10650 ;; Score ARTICLES according to HEADER in SCORES.
10651 ;; Update matches entries to NOW and remove unmatched entried older
10654 ;; Insert the unique article headers in the buffer.
10655 (let ((gnus-score-index (nth 1 (assoc header gnus-header-index)))
10656 ;; gnus-score-index is used as a free variable.
10657 alike last this art entries alist articles)
10659 ;; Sorting the articles costs os O(N*log N) but will allow us to
10660 ;; only match with each unique header. Thus the actual matching
10661 ;; will be O(M*U) where M is the number of strings to match with,
10662 ;; and U is the number of unique headers. It is assumed (but
10663 ;; untested) this will be a net win because of the large constant
10664 ;; factor involved with string matching.
10665 (setq gnus-scores-articles (sort gnus-scores-articles 'gnus-score-string<)
10666 articles gnus-scores-articles)
10670 (setq art (car articles)
10671 this (aref (car art) gnus-score-index)
10672 articles (cdr articles))
10673 (if (equal last this)
10674 ;; O(N*H) cons-cells used here, where H is the number of
10676 (setq alike (cons art alike))
10679 ;; Insert the line, with a text property on the
10680 ;; terminating newline refering to the articles with
10683 (put-text-property (1- (point)) (point) 'articles alike)))
10684 (setq alike (list art)
10686 (and last ; Bwadr, duplicate code.
10689 (put-text-property (1- (point)) (point) 'articles alike)))
10693 (setq alist (car scores)
10694 scores (cdr scores)
10695 entries (assoc header alist))
10696 (while (cdr entries) ;First entry is the header index.
10697 (let* ((rest (cdr entries))
10699 (match (nth 0 kill))
10700 (type (or (nth 3 kill) 's))
10701 (score (or (nth 1 kill) gnus-score-interactive-default-score))
10702 (date (nth 2 kill))
10705 (not (or (eq type 'R) (eq type 'S)
10706 (eq type 'Regexp) (eq type 'String))))
10707 (search-func (cond ((or (eq type 'r) (eq type 'R)
10708 (eq type 'regexp) (eq type 'Regexp))
10709 're-search-forward)
10710 ((or (eq type 's) (eq type 'S)
10711 (eq type 'string) (eq type 'String))
10714 (error "Illegal match type: %s" type))))
10716 (goto-char (point-min))
10717 (while (funcall search-func match nil t)
10720 arts (get-text-property (point) 'articles))
10721 ;; Found a match, update scores.
10723 (setq art (car arts)
10725 (setcdr art (+ score (cdr art)))))
10726 ;; Update expire date
10727 (cond ((null date)) ;Permanent entry.
10728 (found ;Match, update date.
10729 (gnus-score-set 'touched '(t) alist)
10730 (setcar (nthcdr 2 kill) now))
10731 ((< date expire) ;Old entry, remove.
10732 (gnus-score-set 'touched '(t) alist)
10733 (setcdr entries (cdr rest))
10734 (setq rest entries)))
10735 (setq entries rest))))))
10737 (defun gnus-score-string< (a1 a2)
10738 ;; Compare headers in articles A2 and A2.
10739 ;; The header index used is the free variable `gnus-score-index'.
10740 (string-lessp (aref (car a1) gnus-score-index)
10741 (aref (car a2) gnus-score-index)))
10743 (defun gnus-score-build-cons (article)
10744 ;; Build a `gnus-newsgroup-scored' type cons from ARTICLE.
10745 (cons (header-number (car article)) (cdr article)))
10747 (defconst gnus-header-index
10748 ;; Name to index alist.
10749 '(("number" 0 gnus-score-integer)
10750 ("subject" 1 gnus-score-string)
10751 ("from" 2 gnus-score-string)
10752 ("date" 3 gnus-score-date)
10753 ("message-id" 4 gnus-score-string)
10754 ("references" 5 gnus-score-string)
10755 ("chars" 6 gnus-score-integer)
10756 ("lines" 7 gnus-score-integer)
10757 ("xref" 8 gnus-score-string)
10758 ("head" -1 gnus-score-body)
10759 ("body" -1 gnus-score-body)
10760 ("all" -1 gnus-score-body)))
10762 (defun gnus-score-file-name (newsgroup)
10763 "Return the name of a score file for NEWSGROUP."
10764 (cond ((or (null newsgroup)
10765 (string-equal newsgroup ""))
10766 ;; The global score file is placed at top of the directory.
10767 (expand-file-name gnus-score-file-suffix
10768 (or gnus-kill-files-directory "~/News")))
10769 ((gnus-use-long-file-name 'not-score)
10770 ;; Append ".SCORE" to newsgroup name.
10771 (expand-file-name (concat newsgroup "." gnus-score-file-suffix)
10772 (or gnus-kill-files-directory "~/News")))
10774 ;; Place "SCORE" under the hierarchical directory.
10775 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
10776 "/" gnus-score-file-suffix)
10777 (or gnus-kill-files-directory "~/News")))))
10779 (defun gnus-score-score-files (group)
10780 "Return a list of all possible score files."
10781 (and gnus-global-score-files
10782 (or gnus-internal-global-score-files
10783 (gnus-score-search-global-directories gnus-global-score-files)))
10784 (setq gnus-kill-files-directory
10785 (file-name-as-directory
10786 (or gnus-kill-files-directory "~/News/")))
10787 (if (not (file-readable-p gnus-kill-files-directory))
10788 (setq gnus-score-file-list nil)
10789 (if (gnus-use-long-file-name 'not-score)
10790 (if (or (not gnus-score-file-list)
10791 (gnus-file-newer-than gnus-kill-files-directory
10792 (car gnus-score-file-list)))
10793 (setq gnus-score-file-list
10794 (cons (nth 5 (file-attributes gnus-kill-files-directory))
10797 gnus-kill-files-directory t
10798 (concat gnus-score-file-suffix "$"))))))
10799 (let ((dir (expand-file-name
10800 (concat gnus-kill-files-directory
10801 (gnus-replace-chars-in-string group ?. ?/))))
10802 (mdir (length (expand-file-name gnus-kill-files-directory)))
10804 (if (file-exists-p (concat dir "/" gnus-score-file-suffix))
10805 (setq files (list (concat dir "/" gnus-score-file-suffix))))
10806 (while (>= (1+ (length dir)) mdir)
10807 (and (file-exists-p (concat dir "/all/" gnus-score-file-suffix))
10808 (setq files (cons (concat dir "/all/" gnus-score-file-suffix)
10810 (string-match "/[^/]*$" dir)
10811 (setq dir (substring dir 0 (match-beginning 0))))
10812 (setq gnus-score-file-list
10813 (cons nil (nreverse files)))))
10814 (cdr gnus-score-file-list)))
10816 (defun gnus-score-find-single (group)
10817 "Return list containing the score file for GROUP."
10818 (list (gnus-score-file-name group)))
10820 (defun gnus-score-find-hierarchical (group)
10821 "Return list of score files for GROUP.
10822 This includes the score file for the group and all its parents."
10823 (let ((all (copy-sequence '(nil)))
10825 (while (string-match "\\." group (1+ start))
10826 (setq start (match-beginning 0))
10827 (setq all (cons (substring group 0 start) all)))
10828 (setq all (cons group all))
10829 (mapcar 'gnus-score-file-name (nreverse all))))
10831 (defun gnus-score-find-bnews (group)
10832 "Return a list of score files for GROUP.
10833 The score files are those files in the ~/News directory which matches
10834 GROUP using BNews sys file syntax."
10835 (let* ((sfiles (append (gnus-score-score-files group)
10836 gnus-internal-global-score-files))
10837 (kill-dir (file-name-as-directory
10838 (expand-file-name gnus-kill-files-directory)))
10839 (klen (length kill-dir))
10840 ofiles not-match regexp)
10842 (set-buffer (get-buffer-create "*gnus score files*"))
10843 (buffer-disable-undo (current-buffer))
10844 ;; Go through all score file names and create regexp with them
10848 (insert (car sfiles))
10850 ;; First remove the suffix itself.
10851 (re-search-forward (concat "." gnus-score-file-suffix "$"))
10854 (if (looking-at (regexp-quote kill-dir))
10855 ;; If the file name was just "SCORE", `klen' is one character
10857 (delete-char (min (1- (point-max)) klen))
10858 (goto-char (point-max))
10859 (search-backward "/")
10860 (delete-region (1+ (point)) (point-min)))
10861 ;; Translate "all" to ".*".
10862 (while (search-forward "all" nil t)
10863 (replace-match ".*"))
10865 ;; Deal with "not."s.
10866 (if (looking-at "not.")
10869 (setq regexp (buffer-substring 5 (point-max))))
10870 (setq regexp (buffer-substring 1 (point-max)))
10871 (setq not-match nil))
10872 ;; Finally - if this resulting regexp matches the group name,
10873 ;; we add this score file to the list of score files
10874 ;; applicable to this group.
10875 (if (or (and not-match
10876 (not (string-match regexp group)))
10877 (and (not not-match)
10878 (string-match regexp group)))
10879 (setq ofiles (cons (car sfiles) ofiles)))
10880 (setq sfiles (cdr sfiles)))
10881 (kill-buffer (current-buffer))
10882 ;; Slight kludge here - the last score file returned should be
10883 ;; the local score file, whether it exists or not. This is so
10884 ;; that any score commands the user enters will go to the right
10885 ;; file, and not end up in some global score file.
10888 (if (gnus-use-long-file-name 'not-score)
10889 (concat gnus-kill-files-directory group "."
10890 gnus-score-file-suffix)
10891 (concat gnus-kill-files-directory
10892 (gnus-replace-chars-in-string group ?. ?/)
10893 "/" gnus-score-file-suffix)))))
10894 (and (member localscore ofiles)
10895 (delete localscore ofiles))
10896 (setq ofiles (cons localscore ofiles)))
10897 (nreverse ofiles))))
10899 (defun gnus-score-search-global-directories (files)
10900 "Scan all global score directories for score files."
10901 ;; Set the variable `gnus-internal-global-score-files' to all
10902 ;; available global score files.
10903 (interactive (list gnus-global-score-files))
10906 (if (string-match "/$" (car files))
10907 (setq out (nconc (directory-files
10909 (concat gnus-score-file-suffix "$"))))
10910 (setq out (cons (car files) out)))
10911 (setq files (cdr files)))
10912 (setq gnus-internal-global-score-files out)))
10918 (defvar gnus-score-mode-map nil)
10919 (defvar gnus-score-mode-hook nil)
10921 (if gnus-score-mode-map
10923 (setq gnus-score-mode-map (copy-keymap emacs-lisp-mode-map))
10924 (define-key gnus-score-mode-map "\C-c\C-c" 'gnus-score-edit-done)
10925 (define-key gnus-score-mode-map "\C-c\C-d" 'gnus-score-edit-insert-date))
10927 (defun gnus-score-mode ()
10928 "Mode for editing score files.
10929 This mode is an extended emacs-lisp mode.
10931 \\{gnus-score-mode-map}"
10933 (kill-all-local-variables)
10934 (use-local-map gnus-score-mode-map)
10935 (set-syntax-table emacs-lisp-mode-syntax-table)
10936 (setq major-mode 'gnus-score-mode)
10937 (setq mode-name "Score")
10938 (lisp-mode-variables nil)
10939 (run-hooks 'emacs-lisp-mode-hook 'gnus-score-mode-hook))
10941 (defun gnus-score-edit-insert-date ()
10942 "Insert date in numerical format."
10944 (insert (int-to-string (gnus-day-number (current-time-string)))))
10946 (defun gnus-score-edit-done ()
10947 "Save the score file and return to the summary buffer."
10949 (let ((bufnam (buffer-file-name (current-buffer))))
10951 (kill-buffer (current-buffer))
10952 (and gnus-winconf-edit-score
10953 (set-window-configuration gnus-winconf-edit-score))
10954 (gnus-score-remove-from-cache bufnam)
10955 (gnus-score-load-file bufnam)))
10959 ;;; Gnus Posting Functions
10962 (defvar gnus-organization-file "/usr/lib/news/organization"
10963 "*Local news organization file.")
10965 (defvar gnus-post-news-buffer "*post-news*")
10966 (defvar gnus-winconf-post-news nil)
10968 ;;; Post news commands of Gnus group mode and summary mode
10970 (defun gnus-group-post-news ()
10973 (gnus-set-global-variables)
10974 ;; Save window configuration.
10975 (setq gnus-winconf-post-news (current-window-configuration))
10976 (let ((gnus-newsgroup-name nil))
10978 (gnus-post-news 'post)
10979 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
10980 (not (zerop (buffer-size))))
10981 ;; Restore last window configuration.
10982 (and gnus-winconf-post-news
10983 (set-window-configuration gnus-winconf-post-news)))))
10984 ;; We don't want to return to summary buffer nor article buffer later.
10985 (setq gnus-winconf-post-news nil)
10986 (if (get-buffer gnus-summary-buffer)
10987 (bury-buffer gnus-summary-buffer))
10988 (if (get-buffer gnus-article-buffer)
10989 (bury-buffer gnus-article-buffer)))
10991 (defun gnus-summary-post-news ()
10994 (gnus-set-global-variables)
10995 ;; Save window configuration.
10996 (setq gnus-winconf-post-news (current-window-configuration))
10998 (gnus-post-news 'post gnus-newsgroup-name)
10999 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
11000 (not (zerop (buffer-size))))
11001 ;; Restore last window configuration.
11002 (and gnus-winconf-post-news
11003 (set-window-configuration gnus-winconf-post-news))))
11004 ;; We don't want to return to article buffer later.
11005 (if (get-buffer gnus-article-buffer)
11006 (bury-buffer gnus-article-buffer)))
11008 (defun gnus-summary-followup (yank)
11009 "Compose a followup to an article.
11010 If prefix argument YANK is non-nil, original article is yanked automatically."
11012 (gnus-set-global-variables)
11013 (save-window-excursion
11014 (gnus-summary-select-article t))
11015 (let ((headers gnus-current-headers)
11016 (gnus-newsgroup-name gnus-newsgroup-name))
11017 ;; Check Followup-To: poster.
11018 (set-buffer gnus-article-buffer)
11019 (if (and gnus-use-followup-to
11020 (string-equal "poster" (gnus-fetch-field "followup-to"))
11021 (or (not (eq gnus-use-followup-to t))
11022 (not (gnus-y-or-n-p
11023 "Do you want to ignore `Followup-To: poster'? "))))
11024 ;; Mail to the poster. Gnus is now RFC1036 compliant.
11025 (gnus-summary-reply yank)
11026 ;; Save window configuration.
11027 (setq gnus-winconf-post-news (current-window-configuration))
11029 (gnus-post-news nil gnus-newsgroup-name
11030 headers gnus-article-buffer yank)
11031 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
11032 (not (zerop (buffer-size))))
11033 ;; Restore last window configuration.
11034 (and gnus-winconf-post-news
11035 (set-window-configuration gnus-winconf-post-news))))
11036 ;; We don't want to return to article buffer later.
11037 (bury-buffer gnus-article-buffer)))
11038 (gnus-article-hide-headers-if-wanted))
11040 (defun gnus-summary-followup-with-original ()
11041 "Compose a followup to an article and include the original article."
11043 (gnus-summary-followup t))
11045 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11046 (defun gnus-summary-followup-and-reply (yank)
11047 "Compose a followup and do an auto mail to author."
11049 (let ((gnus-auto-mail-to-author t))
11050 (gnus-summary-followup yank)))
11052 (defun gnus-summary-followup-and-reply-with-original ()
11053 "Compose a followup, include the original, and do an auto mail to author."
11055 (gnus-summary-followup-and-reply t))
11057 (defun gnus-summary-cancel-article ()
11058 "Cancel an article you posted."
11060 (gnus-set-global-variables)
11061 (gnus-summary-select-article t)
11062 (gnus-eval-in-buffer-window gnus-article-buffer (gnus-cancel-news))
11063 (gnus-article-hide-headers-if-wanted))
11065 (defun gnus-summary-supersede-article ()
11066 "Compose an article that will supersede a previous article.
11067 This is done simply by taking the old article and adding a Supersedes
11068 header line with the old Message-ID."
11070 (gnus-set-global-variables)
11073 (downcase (mail-strip-quoted-names
11074 (header-from gnus-current-headers)))
11075 (downcase (mail-strip-quoted-names (gnus-inews-user-name)))))
11076 (error "This article is not yours."))
11077 (gnus-summary-select-article t)
11079 (set-buffer gnus-article-buffer)
11080 (let ((buffer-read-only nil))
11081 (goto-char (point-min))
11082 (search-forward "\n\n" nil t)
11083 (if (not (re-search-backward "^Message-ID: " nil t))
11084 (error "No Message-ID in this article"))))
11085 (if (gnus-post-news 'post gnus-newsgroup-name)
11088 (insert-buffer gnus-article-buffer)
11089 (goto-char (point-min))
11090 (search-forward "\n\n" nil t)
11091 (if (not (re-search-backward "^Message-ID: " nil t))
11092 (error "No Message-ID in this article")
11093 (replace-match "Supersedes: "))
11094 (search-forward "\n\n")
11096 (insert mail-header-separator))))
11100 (fset 'sendnews 'gnus-post-news)
11103 (fset 'postnews 'gnus-post-news)
11105 (defun gnus-post-news (post &optional group header article-buffer yank)
11106 "Begin editing a new USENET news article to be posted.
11107 Type \\[describe-mode] in the buffer to get a list of commands."
11108 (interactive (list t))
11109 (if (or (not gnus-novice-user)
11113 (format "%s" (car (gnus-find-method-for-group
11114 gnus-newsgroup-name)))
11115 gnus-valid-select-methods))))
11116 (assq 'to-address (gnus-find-method-for-group gnus-newsgroup-name))
11117 (gnus-y-or-n-p "Are you sure you want to post to all of USENET? "))
11118 (let ((sumart (if (not post)
11120 (set-buffer gnus-summary-buffer)
11121 (cons (current-buffer) gnus-current-article))))
11122 (from (and header (header-from header)))
11123 subject follow-to real-group)
11124 (and gnus-interactive-post
11125 (not gnus-expert-user)
11129 (completing-read "Group: " gnus-active-hashtb nil t))
11130 (setq subject (read-string "Subject: "))))
11131 (setq mail-reply-buffer article-buffer)
11133 (let ((gnus-newsgroup-name (or group gnus-newsgroup-name "")))
11134 (setq real-group (and group (gnus-group-real-name group)))
11135 (setq gnus-post-news-buffer
11136 (gnus-request-post-buffer
11137 post real-group subject header article-buffer
11138 (nth 2 (and group (gnus-gethash group gnus-newsrc-hashtb)))
11139 (if (and (boundp 'gnus-followup-to-function)
11140 gnus-followup-to-function)
11143 (set-buffer article-buffer)
11144 (funcall gnus-followup-to-function group))))
11145 (eq gnus-use-followup-to t)))
11148 (gnus-configure-windows '(1 0 0))
11149 (switch-to-buffer gnus-post-news-buffer))
11150 (gnus-configure-windows '(0 1 0))
11153 (switch-to-buffer article-buffer)
11154 (pop-to-buffer gnus-post-news-buffer))
11155 (switch-to-buffer gnus-post-news-buffer)))
11156 (gnus-overload-functions)
11157 (make-local-variable 'gnus-article-reply)
11158 (make-local-variable 'gnus-article-check-size)
11159 (setq gnus-article-reply sumart)
11160 ;; Handle `gnus-auto-mail-to-author'.
11161 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11162 (let ((to (if (eq gnus-auto-mail-to-author 'ask)
11163 (and (y-or-n-p "Also send mail to author? ") from)
11164 (and gnus-auto-mail-to-author from))))
11167 (if (mail-fetch-field "To")
11169 (beginning-of-line)
11170 (insert "Cc: " to "\n"))
11171 (mail-position-on-field "To")
11173 ;; Handle author copy using BCC field.
11174 (if (and gnus-mail-self-blind
11175 (not (mail-fetch-field "bcc")))
11177 (mail-position-on-field "Bcc")
11178 (insert (if (stringp gnus-mail-self-blind)
11179 gnus-mail-self-blind
11180 (user-login-name)))))
11181 ;; Handle author copy using FCC field.
11182 (if gnus-author-copy
11184 (mail-position-on-field "Fcc")
11185 (insert gnus-author-copy)))
11186 (goto-char (point-min))
11189 (re-search-forward "^Newsgroup:" nil t)
11192 (re-search-forward "^Subject:" nil t)
11196 (concat "^" (regexp-quote mail-header-separator) "$"))
11199 (concat "^" (regexp-quote mail-header-separator) "$"))
11201 (and yank (save-excursion (news-reply-yank-original nil)))
11202 (if gnus-post-prepare-function
11203 (funcall gnus-post-prepare-function group))))))
11204 (setq gnus-article-check-size (cons (buffer-size) (gnus-article-checksum)))
11208 (defun gnus-inews-news (&optional use-group-method)
11209 "Send a news message.
11210 If given a prefix, and the group is a foreign group, this function
11211 will attempt to use the foreign server to post the article."
11213 ;; Check whether the article is a good Net Citizen.
11214 (if (and gnus-article-check-size (not (gnus-inews-check-post)))
11217 ;; Looks ok, so we do the nasty.
11218 (let* ((case-fold-search nil)
11219 (server-running (gnus-server-opened gnus-select-method))
11220 (reply gnus-article-reply))
11222 ;; Connect to default NNTP server if necessary.
11223 ;; Suggested by yuki@flab.fujitsu.junet.
11224 (gnus-start-news-server) ;Use default server.
11225 ;; NNTP server must be opened before current buffer is modified.
11227 (goto-char (point-min))
11228 (run-hooks 'news-inews-hook)
11233 (goto-char (point-min))
11235 (concat "^" (regexp-quote mail-header-separator) "$"))))
11237 ;; Correct newsgroups field: change sequence of spaces to comma and
11238 ;; eliminate spaces around commas. Eliminate imbedded line breaks.
11239 (goto-char (point-min))
11240 (if (search-forward-regexp "^Newsgroups: +" nil t)
11244 (if (re-search-forward "^[^ \t]" nil 'end)
11245 (match-beginning 0)
11247 (goto-char (point-min))
11248 (replace-regexp "\n[ \t]+" " ") ;No line breaks (too confusing)
11249 (goto-char (point-min))
11250 (replace-regexp "[ \t\n]*,[ \t\n]*\\|[ \t]+" ",")))
11252 ;; Added by Per Abrahamsen <abraham@iesd.auc.dk>.
11253 ;; Help save the the world!
11256 (let ((newsgroups (mail-fetch-field "newsgroups"))
11257 (followup-to (mail-fetch-field "followup-to"))
11259 (if (and (string-match "," newsgroups) (not followup-to))
11261 (while (string-match "," newsgroups)
11263 (cons (list (substring newsgroups
11264 0 (match-beginning 0)))
11266 (setq newsgroups (substring newsgroups (match-end 0))))
11267 (setq groups (nreverse (cons (list newsgroups) groups)))
11270 (completing-read "Followups to: (default all groups) "
11272 (if (> (length to) 0)
11274 (goto-char (point-min))
11275 (insert "Followup-To: " to "\n")))))))
11277 ;; Cleanup Followup-To.
11278 (goto-char (point-min))
11279 (if (search-forward-regexp "^Followup-To: +" nil t)
11283 (if (re-search-forward "^[^ \t]" nil 'end)
11284 (match-beginning 0)
11286 (goto-char (point-min))
11287 (replace-regexp "\n[ \t]+" " ") ;No line breaks (too confusing)
11288 (goto-char (point-min))
11289 (replace-regexp "[ \t\n]*,[ \t\n]*\\|[ \t]+" ",")))
11291 ;; Mail the message too if To:, Bcc:. or Cc: exists.
11292 (if (or (mail-fetch-field "to" nil t)
11293 (mail-fetch-field "bcc" nil t)
11294 (mail-fetch-field "cc" nil t))
11295 (if gnus-mail-send-method
11299 (message "Sending via mail...")
11301 (if gnus-mail-courtesy-message
11303 ;; Insert "courtesy" mail message.
11306 (concat "^" (regexp-quote
11307 mail-header-separator) "$"))
11309 (insert gnus-mail-courtesy-message)
11310 (funcall gnus-mail-send-method)
11312 (search-forward gnus-mail-courtesy-message)
11313 (replace-match ""))
11314 (funcall gnus-mail-send-method))
11316 (message "Sending via mail... done")
11320 1 (re-search-forward
11321 (concat "^" (regexp-quote
11322 mail-header-separator) "$")))
11324 (delete-matching-lines "BCC:.*")))
11326 (message "No mailer defined. To: and/or Cc: fields ignored.")
11329 ;; Send to NNTP server.
11330 (message "Posting to USENET...")
11331 (if (gnus-inews-article use-group-method)
11333 (message "Posting to USENET... done")
11335 (get-buffer (car reply))
11336 (buffer-name (car reply)))
11339 (set-buffer gnus-summary-buffer)
11340 (gnus-summary-mark-article-as-replied
11342 ;; We cannot signal an error.
11343 (ding) (message "Article rejected: %s"
11344 (gnus-status-message gnus-select-method)))
11345 (set-buffer-modified-p nil))
11346 ;; If NNTP server is opened by gnus-inews-news, close it by myself.
11348 (gnus-close-server (gnus-find-method-for-group gnus-newsgroup-name)))
11349 (and (fboundp 'bury-buffer) (bury-buffer))
11350 ;; Restore last window configuration.
11351 (and gnus-winconf-post-news
11352 (set-window-configuration gnus-winconf-post-news))
11353 (setq gnus-winconf-post-news nil))))
11355 (defun gnus-inews-check-post ()
11356 "Check whether the post looks ok."
11358 ;; Check excessive size.
11359 (if (> (buffer-size) 60000)
11360 (gnus-y-or-n-p (format "The article is %d octets long. Really post? "
11363 ;; Check for commands in Subject.
11366 (goto-char (point-min))
11370 (concat "^" (regexp-quote mail-header-separator) "$")))
11371 (if (string-match "^cmsg " (mail-fetch-field "subject"))
11373 "The control code \"cmsg \" is in the subject. Really post? ")
11375 ;; Check for control characters.
11377 (if (re-search-forward "[\000-\007\013\015-\037\200-\237]" nil t)
11379 "The article contains control characters. Really post? ")
11381 ;; Check for multiple identical headers.
11385 (goto-char (point-min))
11389 (concat "^" (regexp-quote mail-header-separator) "$")))
11390 (goto-char (point-min))
11391 (while (and (not found) (re-search-forward "^[^ \t:]+: " nil t))
11393 (or (re-search-forward
11394 (concat "^" (setq found
11395 (buffer-substring (match-beginning 0)
11398 (setq found nil))))
11401 (format "Multiple %s headers. Really post? " found))
11403 ;; Check for version and sendsys.
11406 (goto-char (point-min))
11410 (concat "^" (regexp-quote mail-header-separator) "$")))
11411 (if (re-search-backward "^Sendsys:\\|^Version:" nil t)
11413 (format "The article contains a %s command. Really post? "
11414 (buffer-substring (match-beginning 0) (match-end 0))))
11416 ;; Check the From header.
11419 (goto-char (point-min))
11423 (concat "^" (regexp-quote mail-header-separator) "$")))
11424 (let* ((case-fold-search t)
11425 (from (mail-fetch-field "from")))
11427 (string-match "@" from)
11428 (not (string-match "@[^\\.]*\\." from)))
11430 (format "The domain looks strange: \"%s\". Really post? "
11433 ;; Check for long lines.
11436 (goto-char (point-min))
11440 (concat "^" (regexp-quote mail-header-separator) "$")))
11445 (< (current-column) 80))
11446 (zerop (forward-line 1))))
11450 "You have lines longer than 79 characters. Really post? ")))))
11451 ;; Use the (size . checksum) variable to see whether the
11452 ;; article is empty or has only quoted text.
11453 (if (and (= (buffer-size) (car gnus-article-check-size))
11454 (= (gnus-article-checksum) (cdr gnus-article-check-size)))
11456 "It looks like there's no new text in your article. Really post? ")
11459 (defun gnus-article-checksum ()
11462 (while (not (eobp))
11463 (setq sum (logxor sum (following-char)))
11467 (defun gnus-cancel-news ()
11468 "Cancel an article you posted."
11470 (if (or gnus-expert-user
11471 (gnus-yes-or-no-p "Do you really want to cancel this article? "))
11475 (distribution nil))
11477 ;; Get header info. from original article.
11479 (gnus-article-show-all-headers)
11480 (goto-char (point-min))
11481 (search-forward "\n\n" nil 'move)
11482 (narrow-to-region (point-min) (point))
11483 (setq from (mail-fetch-field "from"))
11484 (setq newsgroups (mail-fetch-field "newsgroups"))
11485 (setq message-id (mail-fetch-field "message-id"))
11486 (setq distribution (mail-fetch-field "distribution")))
11487 ;; Verify if the article is absolutely user's by comparing
11488 ;; user id with value of its From: field.
11491 (downcase (mail-strip-quoted-names from))
11492 (downcase (mail-strip-quoted-names (gnus-inews-user-name)))))
11494 (ding) (message "This article is not yours."))
11495 ;; Make control article.
11496 (set-buffer (get-buffer-create " *Gnus-canceling*"))
11497 (buffer-disable-undo (current-buffer))
11499 (insert "Newsgroups: " newsgroups "\n"
11500 "Subject: cancel " message-id "\n"
11501 "Control: cancel " message-id "\n"
11502 mail-header-separator "\n"
11503 "This is a cancel message from " from ".\n")
11504 ;; Send the control article to NNTP server.
11505 (message "Canceling your article...")
11506 (if (gnus-inews-article)
11507 (message "Canceling your article... done")
11509 (message "Cancel failed; %s"
11510 (gnus-status-message gnus-newsgroup-name)))
11511 ;; Kill the article buffer.
11512 (kill-buffer (current-buffer)))))))
11515 ;;; Lowlevel inews interface
11517 (defun gnus-inews-article (&optional use-group-method)
11518 "Post an article in current buffer using NNTP protocol."
11519 (let ((artbuf (current-buffer))
11520 (tmpbuf (get-buffer-create " *Gnus-posting*")))
11522 (goto-char (point-max))
11523 ;; require a newline at the end for inews to append .signature to
11524 (or (= (preceding-char) ?\n)
11526 ;; Prepare article headers. All message body such as signature
11527 ;; must be inserted before Lines: field is prepared.
11529 (goto-char (point-min))
11534 (concat "^" (regexp-quote mail-header-separator) "$"))
11535 (match-beginning 0)))
11536 (gnus-inews-insert-headers)
11537 (run-hooks gnus-inews-article-header-hook)
11540 (set-buffer tmpbuf)
11541 (buffer-disable-undo (current-buffer))
11543 (insert-buffer-substring artbuf)
11544 ;; Remove the header separator.
11545 (goto-char (point-min))
11547 (concat "^" (regexp-quote mail-header-separator) "$"))
11549 ;; This hook may insert a signature.
11550 (run-hooks 'gnus-prepare-article-hook)
11551 ;; Run final inews hooks. This hook may do FCC.
11552 ;; The article must be saved before being posted because
11553 ;; `gnus-request-post' modifies the buffer.
11554 (run-hooks 'gnus-inews-article-hook)
11555 ;; Post an article to NNTP server.
11556 ;; Return NIL if post failed.
11559 (if use-group-method
11560 (gnus-find-method-for-group gnus-newsgroup-name)
11561 gnus-select-method) use-group-method)
11562 (kill-buffer (current-buffer))))))
11564 (defun gnus-inews-insert-headers ()
11565 "Prepare article headers.
11566 Headers already prepared in the buffer are not modified.
11567 Headers in `gnus-required-headers' will be generated."
11568 (let ((Date (gnus-inews-date))
11569 (Message-ID (gnus-inews-message-id))
11570 (Organization (gnus-inews-organization))
11571 (From (gnus-inews-user-name))
11572 (Path (gnus-inews-path))
11576 (Lines (gnus-inews-lines))
11577 (X-Newsreader gnus-version)
11578 (headers gnus-required-headers)
11579 (case-fold-search t)
11581 ;; First we remove any old Message-IDs. This might be slightly
11582 ;; fascist, but if the user really wants to generate Message-IDs
11583 ;; by herself, she should remove it from the `gnus-required-list'.
11584 (goto-char (point-min))
11585 (and (memq 'Message-ID headers)
11586 (re-search-forward "^Message-ID:" nil t)
11587 (delete-region (progn (beginning-of-line) (point))
11588 (progn (forward-line 1) (point))))
11589 ;; Remove NNTP-posting-host.
11590 (goto-char (point-min))
11591 (and (re-search-forward "^nntp-posting-host:" nil t)
11592 (delete-region (progn (beginning-of-line) (point))
11593 (progn (forward-line 1) (point))))
11594 ;; Insert new Sender if the From is strange.
11595 (let ((from (mail-fetch-field "from")))
11596 (if (and from (not (string= (downcase from) (downcase From))))
11598 (goto-char (point-min))
11599 (and (re-search-forward "^Sender:" nil t)
11600 (delete-region (progn (beginning-of-line) (point))
11601 (progn (forward-line 1) (point))))
11602 (insert "Sender: " From "\n"))))
11603 ;; If there are References, and no "Re: ", then the thread has
11604 ;; changed name. See Son-of-1036.
11605 (if (and (mail-fetch-field "references")
11606 (get-buffer gnus-article-buffer))
11607 (let ((psubject (gnus-simplify-subject-re
11608 (mail-fetch-field "subject")))
11611 (set-buffer (get-buffer gnus-article-buffer))
11613 (gnus-narrow-to-headers)
11614 (if (setq subject (mail-fetch-field "subject"))
11616 (and gnus-summary-gather-subject-limit
11617 (numberp gnus-summary-gather-subject-limit)
11618 (> (length subject) gnus-summary-gather-subject-limit)
11620 (substring subject 0
11621 gnus-summary-gather-subject-limit)))
11622 (setq subject (gnus-simplify-subject-re subject))))))
11623 (or (and psubject subject (string= subject psubject))
11625 (string-match "@" Message-ID)
11627 (concat (substring Message-ID 0 (match-beginning 0))
11629 (substring Message-ID (match-beginning 0))))))))
11630 ;; Go through all the required headers and see if they are in the
11631 ;; articles already. If they are not, or are empty, they are
11632 ;; inserted automatically - except for Subject, Newsgroups and
11635 (goto-char (point-min))
11636 (setq elem (car headers))
11638 (setq header (car elem))
11639 (setq header elem))
11640 (if (or (not (re-search-forward
11641 (concat "^" (downcase (symbol-name header)) ":") nil t))
11643 (if (= (following-char) ? ) (forward-char 1) (insert " "))
11644 (looking-at "[ \t]*$")))
11647 (or (if (consp elem)
11648 ;; The element is a cons. Either the cdr is
11649 ;; a string to be inserted verbatim, or it
11650 ;; is a function, and we insert the value
11651 ;; returned from this function.
11652 (or (and (stringp (cdr elem)) (cdr elem))
11653 (and (fboundp (cdr elem)) (funcall (cdr elem))))
11654 ;; The element is a symbol. We insert the
11655 ;; value of this symbol, if any.
11656 (and (boundp header) (symbol-value header)))
11657 ;; We couldn't generate a value for this header,
11658 ;; so we just ask the user.
11659 (read-from-minibuffer
11660 (format "Empty header for %s; enter value: " header))))
11663 (goto-char (point-max))
11664 (insert (symbol-name header) ": " value "\n"))
11665 (replace-match value))))
11666 (setq headers (cdr headers)))))
11668 (defun gnus-inews-insert-signature ()
11669 "Insert a signature file.
11670 If `gnus-signature-function' is bound and returns a string, this
11671 string is used instead of the variable `gnus-signature-file'.
11672 In either case, if the string is a file name, this file is
11673 inserted. If the string is not a file name, the string itself is
11675 If you never want any signature inserted, set both those variables to
11679 (or (and gnus-signature-function
11680 (fboundp gnus-signature-function)
11681 (funcall gnus-signature-function gnus-newsgroup-name))
11682 gnus-signature-file))
11685 (or (file-exists-p signature)
11686 (string-match " " signature)
11688 "^/[^/]+/" (expand-file-name signature)))))
11690 (goto-char (point-max))
11691 ;; Delete any previous signatures.
11692 (if (and mail-signature (search-backward "\n-- \n" nil t))
11693 (delete-region (1+ (point)) (point-max)))
11695 (and (< 4 (setq b (count-lines
11698 (if (file-exists-p signature)
11699 (insert-file-contents signature)
11700 (insert signature))
11701 (goto-char (point-max))
11702 (or (bolp) (insert "\n"))
11704 (not gnus-expert-user)
11708 "Your .sig is %d lines; it should be max 4. Really post? "
11710 (if (file-exists-p signature)
11711 (error (format "Edit %s." signature))
11712 (error "Trim your signature."))))))))
11714 (defun gnus-inews-do-fcc ()
11715 "Process FCC: fields in current article buffer.
11716 Unless the first character of the field is `|', the article is saved
11717 to the specified file using the function specified by the variable
11718 gnus-author-copy-saver. The default function rmail-output saves in
11719 Unix mailbox format.
11720 If the first character is `|', the contents of the article is send to
11721 a program specified by the rest of the value."
11722 (let ((fcc-list nil)
11724 (case-fold-search t)) ;Should ignore case.
11727 (goto-char (point-min))
11728 (search-forward "\n\n")
11729 (narrow-to-region (point-min) (point))
11730 (goto-char (point-min))
11731 (while (re-search-forward "^FCC:[ \t]*" nil t)
11733 (cons (buffer-substring
11737 (skip-chars-backward " \t")
11740 (delete-region (match-beginning 0)
11741 (progn (forward-line 1) (point))))
11742 ;; Process FCC operations.
11745 (setq fcc-file (car fcc-list))
11746 (setq fcc-list (cdr fcc-list))
11747 (cond ((string-match "^[ \t]*|[ \t]*\\(.*\\)[ \t]*$" fcc-file)
11748 (let ((program (substring fcc-file
11749 (match-beginning 1) (match-end 1))))
11750 ;; Suggested by yuki@flab.fujitsu.junet.
11751 ;; Send article to named program.
11752 (call-process-region (point-min) (point-max) shell-file-name
11753 nil nil nil "-c" program)))
11755 ;; Suggested by hyoko@flab.fujitsu.junet.
11756 ;; Save article in Unix mail format by default.
11757 (if (and gnus-author-copy-saver
11758 (not (eq gnus-author-copy-saver 'rmail-output)))
11759 (funcall gnus-author-copy-saver fcc-file)
11760 (if (and (file-readable-p fcc-file) (rmail-file-p fcc-file))
11761 (gnus-output-to-rmail fcc-file)
11762 (rmail-output fcc-file 1 t t))))))))))
11764 (defun gnus-inews-path ()
11765 "Return uucp path."
11766 (let ((login-name (gnus-inews-login-name)))
11767 (cond ((null gnus-use-generic-path)
11768 (concat (nth 1 gnus-select-method) "!" login-name))
11769 ((stringp gnus-use-generic-path)
11770 ;; Support GENERICPATH. Suggested by vixie@decwrl.dec.com.
11771 (concat gnus-use-generic-path "!" login-name))
11774 (defun gnus-inews-user-name ()
11775 "Return user's network address as \"NAME@DOMAIN (FULL-NAME)\"."
11776 (let ((full-name (gnus-inews-full-name)))
11777 (or gnus-user-from-line
11778 (concat (if (or gnus-user-login-name gnus-use-generic-from
11779 gnus-local-domain (getenv "DOMAINNAME"))
11780 (concat (gnus-inews-login-name) "@"
11781 (gnus-inews-domain-name gnus-use-generic-from))
11783 ;; User's full name.
11784 (cond ((string-equal full-name "") "")
11785 ((string-equal full-name "&") ;Unix hack.
11786 (concat " (" (user-login-name) ")"))
11788 (concat " (" full-name ")")))))))
11790 (defun gnus-inews-login-name ()
11791 "Return login name."
11792 (or gnus-user-login-name (getenv "LOGNAME") (user-login-name)))
11794 (defun gnus-inews-full-name ()
11795 "Return full user name."
11796 (or gnus-user-full-name (getenv "NAME") (user-full-name)))
11798 (defun gnus-inews-domain-name (&optional genericfrom)
11799 "Return user's domain name.
11800 If optional argument GENERICFROM is a string, use it as the domain
11801 name; if it is non-nil, strip off local host name from the domain name.
11802 If the function `system-name' returns full internet name and the
11803 domain is undefined, the domain name is got from it."
11804 (if (or genericfrom gnus-local-domain (getenv "DOMAINNAME"))
11805 (let* ((system-name (system-name))
11807 (or (if (stringp genericfrom) genericfrom)
11808 (getenv "DOMAINNAME")
11810 ;; Function `system-name' may return full internet name.
11811 ;; Suggested by Mike DeCorte <mrd@sun.soe.clarkson.edu>.
11812 (if (string-match "\\." system-name)
11813 (substring system-name (match-end 0)))
11814 (read-string "Domain name (no host): ")))
11815 (host (or (if (string-match "\\." system-name)
11816 (substring system-name 0 (match-beginning 0)))
11818 (if (string-equal "." (substring domain 0 1))
11819 (setq domain (substring domain 1)))
11820 ;; Support GENERICFROM as same as standard Bnews system.
11821 ;; Suggested by ohm@kaba.junet and vixie@decwrl.dec.com.
11822 (cond ((null genericfrom)
11823 (concat host "." domain))
11824 ;;((stringp genericfrom) genericfrom)
11826 (if (string-match "\\." (system-name))
11828 (substring user-mail-address
11829 (1+ (string-match "@" user-mail-address))))))
11831 (defun gnus-inews-full-address ()
11832 (let ((domain (gnus-inews-domain-name))
11833 (system (system-name))
11834 (case-fold-search t))
11835 (if (string-match "\\." system) system
11836 (if (string-match (concat "^" (regexp-quote system)) domain) domain
11837 (concat system "." domain)))))
11839 (defun gnus-inews-message-id ()
11840 "Generate unique Message-ID for user."
11841 ;; Message-ID should not contain a slash and should be terminated by
11842 ;; a number. I don't know the reason why it is so.
11843 (concat "<" (gnus-inews-unique-id) "@" (gnus-inews-full-address) ">"))
11845 (defun gnus-inews-unique-id ()
11846 "Generate unique ID from user name and current time."
11847 (concat (downcase (gnus-inews-login-name))
11849 (lambda (num) (gnus-number-base-x num 3 31))
11850 (current-time) "")))
11852 (defun gnus-inews-date ()
11853 "Current time string."
11854 (timezone-make-date-arpa-standard
11855 (current-time-string) (current-time-zone)))
11857 (defun gnus-inews-organization ()
11858 "Return user's organization.
11859 The ORGANIZATION environment variable is used if defined.
11860 If not, the variable `gnus-local-organization' is used instead.
11861 If it is a function, the function will be called with the current
11862 newsgroup name as the argument.
11863 If this is a file name, the contents of this file will be used as the
11865 (let* ((organization
11866 (or (getenv "ORGANIZATION")
11867 (if gnus-local-organization
11868 (if (and (symbolp gnus-local-organization)
11869 (fboundp gnus-local-organization))
11870 (funcall gnus-local-organization gnus-newsgroup-name)
11871 gnus-local-organization))
11872 gnus-organization-file
11873 "~/.organization")))
11874 (and (stringp organization)
11875 (> (length organization) 0)
11876 (or (file-exists-p organization)
11877 (string-match " " organization)
11878 (not (string-match "^/[^/]+/" (expand-file-name organization))))
11880 (set-buffer (get-buffer-create " *Gnus organization*"))
11881 (buffer-disable-undo (current-buffer))
11883 (if (file-exists-p organization)
11884 (insert-file-contents organization)
11885 (insert organization))
11886 (goto-char (point-min))
11887 (while (re-search-forward " *\n *" nil t)
11888 (replace-match " "))
11889 (buffer-substring (point-min) (point-max))))))
11891 (defun gnus-inews-lines ()
11892 "Count the number of lines and return numeric string."
11896 (goto-char (point-min))
11897 (search-forward "\n\n" nil 'move)
11898 (int-to-string (count-lines (point) (point-max))))))
11902 ;;; Gnus Mail Functions
11905 ;;; Mail reply commands of Gnus summary mode
11907 (defun gnus-summary-reply (yank)
11908 "Reply mail to news author.
11909 If prefix argument YANK is non-nil, original article is yanked automatically.
11910 Customize the variable gnus-mail-reply-method to use another mailer."
11912 ;; Bug fix by jbw@bigbird.bu.edu (Joe Wells)
11913 ;; Stripping headers should be specified with mail-yank-ignored-headers.
11914 (gnus-set-global-variables)
11915 (gnus-summary-select-article t)
11916 (setq gnus-winconf-post-news (current-window-configuration))
11917 (let ((gnus-newsgroup-name gnus-newsgroup-name))
11918 (bury-buffer gnus-article-buffer)
11919 (funcall gnus-mail-reply-method yank))
11920 (gnus-article-hide-headers-if-wanted))
11922 (defun gnus-summary-reply-with-original ()
11923 "Reply mail to news author with original article.
11924 Customize the variable gnus-mail-reply-method to use another mailer."
11926 (gnus-summary-reply t))
11928 (defun gnus-summary-mail-forward ()
11929 "Forward the current message to another user.
11930 Customize the variable gnus-mail-forward-method to use another mailer."
11932 (gnus-summary-select-article t)
11933 (setq gnus-winconf-post-news (current-window-configuration))
11934 (set-buffer gnus-article-buffer)
11935 (let ((gnus-newsgroup-name gnus-newsgroup-name))
11936 (funcall gnus-mail-forward-method))
11937 (gnus-article-hide-headers-if-wanted))
11939 (defun gnus-summary-mail-other-window ()
11940 "Compose mail in other window.
11941 Customize the variable `gnus-mail-other-window-method' to use another
11944 (setq gnus-winconf-post-news (current-window-configuration))
11945 (let ((gnus-newsgroup-name gnus-newsgroup-name))
11946 (funcall gnus-mail-other-window-method)))
11948 (defun gnus-mail-reply-using-mail (&optional yank to-address)
11950 (set-buffer gnus-summary-buffer)
11951 (let ((info (nth 2 (gnus-gethash gnus-newsgroup-name gnus-newsrc-hashtb)))
11952 (group (gnus-group-real-name gnus-newsgroup-name))
11953 (cur (cons (current-buffer) (cdr gnus-article-current)))
11954 from subject date to reply-to message-of
11955 references message-id sender follow-to cc)
11956 (set-buffer (get-buffer-create "*mail*"))
11958 (make-local-variable 'gnus-article-reply)
11959 (setq gnus-article-reply cur)
11960 (use-local-map (copy-keymap mail-mode-map))
11961 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
11962 (if (and (buffer-modified-p)
11963 (> (buffer-size) 0)
11964 (not (gnus-y-or-n-p
11965 "Unsent article being composed; erase it? ")))
11969 (set-buffer gnus-article-buffer)
11970 (let ((buffer-read-only nil))
11971 (goto-char (point-min))
11972 (narrow-to-region (point-min)
11973 (progn (search-forward "\n\n") (point)))
11974 (add-text-properties (point-min) (point-max) '(invisible nil)))
11975 (if (and (boundp 'gnus-reply-to-function)
11976 gnus-reply-to-function)
11979 (gnus-narrow-to-headers)
11980 (setq follow-to (funcall gnus-reply-to-function group)))))
11981 (setq from (mail-fetch-field "from"))
11982 (setq date (mail-fetch-field "date"))
11985 (string-match " *at \\| *@ \\| *(\\| *<" from)))
11987 (concat (if stop-pos (substring from 0 stop-pos) from)
11988 "'s message of " date))))
11989 (setq sender (mail-fetch-field "sender"))
11990 (setq subject (or (mail-fetch-field "subject")
11992 (or (string-match "^[Rr][Ee]:" subject)
11993 (setq subject (concat "Re: " subject)))
11994 (setq cc (mail-fetch-field "cc"))
11995 (setq reply-to (mail-fetch-field "reply-to"))
11996 (setq references (mail-fetch-field "references"))
11997 (setq message-id (mail-fetch-field "message-id"))
11999 (setq news-reply-yank-from from)
12000 (setq news-reply-yank-message-id message-id)
12001 (mail-setup (or to-address
12002 (if (and follow-to (not (stringp follow-to))) ""
12003 (or follow-to reply-to from sender "")))
12004 subject message-of nil gnus-article-buffer nil)
12005 (if (and follow-to (listp follow-to))
12007 (goto-char (point-min))
12009 (insert (car (car follow-to)) ": " (cdr (car follow-to)) "\n")
12010 (setq follow-to (cdr follow-to)))))
12011 ;; Fold long references line to follow RFC1036.
12012 (mail-position-on-field "References")
12013 (let ((begin (- (point) (length "References: ")))
12015 (fill-prefix "\t"))
12016 (if references (insert references))
12017 (if (and references message-id) (insert " "))
12018 (if message-id (insert message-id))
12019 ;; The region must end with a newline to fill the region
12020 ;; without inserting extra newline.
12021 (fill-region-as-paragraph begin (1+ (point))))
12022 (goto-char (point-min))
12024 (concat "^" (regexp-quote mail-header-separator) "$"))
12027 (let ((last (point)))
12028 (run-hooks 'news-reply-header-hook)
12029 (mail-yank-original nil)
12030 (goto-char last))))
12032 (let ((mail (current-buffer)))
12033 (gnus-configure-windows '(0 0 1))
12034 (switch-to-buffer-other-window mail))
12035 (gnus-configure-windows '(0 1 0))
12036 (switch-to-buffer (current-buffer))))))
12038 (defun gnus-mail-yank-original ()
12040 (run-hooks 'news-reply-header-hook)
12041 (mail-yank-original nil))
12043 (defun gnus-mail-send-and-exit ()
12045 (let ((cbuf (current-buffer)))
12046 (mail-send-and-exit nil)
12047 (if (get-buffer gnus-group-buffer)
12051 (let ((reply gnus-article-reply))
12053 (get-buffer (car reply))
12054 (buffer-name (car reply)))
12056 (set-buffer (car reply))
12058 (gnus-summary-mark-article-as-replied
12060 (and gnus-winconf-post-news
12061 (set-window-configuration gnus-winconf-post-news))
12062 (setq gnus-winconf-post-news nil)))))
12064 (defun gnus-mail-forward-using-mail ()
12065 "Forward the current message to another user using mail."
12066 ;; This is almost a carbon copy of rmail-forward in rmail.el.
12067 (let ((forward-buffer (current-buffer))
12069 (concat "[" (if (memq 'mail (assoc (symbol-name
12070 (car (gnus-find-method-for-group
12071 gnus-newsgroup-name)))
12072 gnus-valid-select-methods))
12073 (gnus-fetch-field "From")
12074 gnus-newsgroup-name)
12075 "] " (or (gnus-fetch-field "Subject") "")))
12077 ;; If only one window, use it for the mail buffer.
12078 ;; Otherwise, use another window for the mail buffer
12079 ;; so that the Rmail buffer remains visible
12080 ;; and sending the mail will get back to it.
12081 (if (if (one-window-p t)
12082 (mail nil nil subject)
12083 (mail-other-window nil nil subject))
12085 (use-local-map (copy-keymap emacs-lisp-mode-map))
12086 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
12087 (setq beg (goto-char (point-max)))
12088 (insert "------- Start of forwarded message -------\n")
12089 (insert-buffer forward-buffer)
12090 (goto-char (point-max))
12091 (insert "------- End of forwarded message -------\n")
12092 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
12094 (while (setq beg (next-single-property-change (point) 'invisible))
12096 (delete-region beg (or (next-single-property-change
12097 (point) 'invisible)
12099 ;; You have a chance to arrange the message.
12100 (run-hooks 'gnus-mail-forward-hook)))))
12102 (defun gnus-mail-other-window-using-mail ()
12103 "Compose mail other window using mail."
12104 (mail-other-window nil nil nil nil nil (get-buffer gnus-article-buffer))
12105 (use-local-map (copy-keymap (current-local-map)))
12106 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit))
12113 (defvar gnus-dribble-ignore nil)
12115 (defun gnus-dribble-file-name ()
12116 (concat gnus-startup-file "-dribble"))
12118 (defun gnus-dribble-open ()
12121 (setq gnus-dribble-buffer (find-file-noselect (gnus-dribble-file-name))))
12122 (buffer-disable-undo (current-buffer))
12123 (bury-buffer gnus-dribble-buffer)
12125 (goto-char (point-max))))
12127 (defun gnus-dribble-enter (string)
12128 (if (and (not gnus-dribble-ignore)
12129 gnus-dribble-buffer
12130 (buffer-name gnus-dribble-buffer))
12131 (let ((obuf (current-buffer)))
12132 (set-buffer gnus-dribble-buffer)
12133 (insert string "\n")
12134 (set-window-point (get-buffer-window (current-buffer)) (point-max))
12135 (set-buffer obuf))))
12137 (defun gnus-dribble-read-file ()
12138 (let ((dribble-file (gnus-dribble-file-name)))
12140 (set-buffer (setq gnus-dribble-buffer
12142 (file-name-nondirectory dribble-file))))
12143 (gnus-add-current-to-buffer-list)
12145 (set-visited-file-name dribble-file)
12146 (buffer-disable-undo (current-buffer))
12147 (bury-buffer (current-buffer))
12148 (set-buffer-modified-p nil)
12149 (let ((auto (make-auto-save-file-name))
12150 (gnus-dribble-ignore t))
12151 (if (or (file-exists-p auto) (file-exists-p dribble-file))
12153 (if (file-newer-than-file-p auto dribble-file)
12154 (setq dribble-file auto))
12155 (insert-file-contents dribble-file)
12156 (if (not (zerop (buffer-size)))
12157 (set-buffer-modified-p t))
12159 "Auto-save file exists. Do you want to read it? ")
12161 (message "Reading %s..." dribble-file)
12162 (eval-current-buffer)
12163 (message "Reading %s...done" dribble-file)))))))))
12165 (defun gnus-dribble-delete-file ()
12166 (if (file-exists-p (gnus-dribble-file-name))
12167 (delete-file (gnus-dribble-file-name)))
12168 (if gnus-dribble-buffer
12170 (set-buffer gnus-dribble-buffer)
12171 (let ((auto (make-auto-save-file-name)))
12172 (if (file-exists-p auto)
12173 (delete-file auto))
12175 (set-buffer-modified-p nil)))))
12177 (defun gnus-dribble-save ()
12178 (if (and gnus-dribble-buffer
12179 (buffer-name gnus-dribble-buffer))
12181 (set-buffer gnus-dribble-buffer)
12184 (defun gnus-dribble-clear ()
12186 (if (and gnus-dribble-buffer
12187 (buffer-name (get-buffer gnus-dribble-buffer)))
12189 (set-buffer gnus-dribble-buffer)
12191 (set-buffer-modified-p nil)
12192 (setq buffer-saved-size (buffer-size))))))
12195 ;;; Server Communication
12198 ;; All the Gnus backends have the same interface, and should return
12199 ;; data in a similar format. Below is an overview of what functions
12200 ;; these packages must supply and what results they should return.
12204 ;; `nntp-server-buffer' - All data should be returned to Gnus in this
12207 ;; Functions for the imaginary backend `choke':
12209 ;; `choke-retrieve-headers ARTICLES &optional GROUP SERVER'
12210 ;; Should return all headers for all ARTICLES, or return NOV lines for
12213 ;; `choke-request-group GROUP &optional SERVER DISCARD'
12214 ;; Switch to GROUP. If DISCARD is nil, active information on the group
12215 ;; must be returned.
12217 ;; `choke-close-group GROUP &optional SERVER'
12218 ;; Close group. Most backends won't have to do anything with this
12219 ;; call, but it is an opportunity to clean up, if that is needed. It
12220 ;; is called when Gnus exits a group.
12222 ;; `choke-request-article ARTICLE &optional GROUP SERVER'
12223 ;; Return ARTICLE, which is either an article number or
12224 ;; message-id. Note that not all backends can return articles based on
12227 ;; `choke-request-list SERVER'
12228 ;; Return a list of all newsgroups on SERVER.
12230 ;; `choke-request-list-newsgroups SERVER'
12231 ;; Return a list of descriptions of all newsgroups on SERVER.
12233 ;; `choke-request-newgroups DATE &optional SERVER'
12234 ;; Return a list of all groups that have arrived after DATE on
12235 ;; SERVER. Note that the date doesn't have to be respected - Gnus will
12236 ;; always check whether the groups are old or not. Backends that do
12237 ;; not store date information may just return the entire list of
12238 ;; groups, although this might not be a good idea in general.
12240 ;; `choke-request-post-buffer METHOD HEADER ARTICLE-BUFFER GROUP INFO'
12241 ;; Should return a buffer that is suitable for "posting". nnspool and
12242 ;; nntp return a `*post-buffer*', and nnmail return a `*mail*'
12243 ;; buffer. This function should fill out the appropriate headers.
12245 ;; `choke-request-post &optional SERVER'
12246 ;; Function that will be called from a buffer to be posted.
12248 ;; `choke-open-server SERVER &optional ARGUMENT'
12249 ;; Open a connection to SERVER.
12251 ;; `choke-close-server &optional SERVER'
12252 ;; Close the connection to SERVER.
12254 ;; `choke-server-opened &optional SERVER'
12255 ;; Whether the conenction to SERVER is opened or not.
12257 ;; `choke-server-status &optional SERVER'
12258 ;; Should return a status string (not in the nntp buffer, but as the
12259 ;; result of the function).
12261 ;; The following functions are optional and apply only to backends
12262 ;; that are able to control the contents of their groups totally
12263 ;; (ie. mail backends.) Backends that aren't able to do that
12264 ;; shouldn't define these functions at all. Gnus will check for their
12265 ;; presence before attempting to call them.
12267 ;; `choke-request-expire-articles ARTICLES &optional NEWSGROUP SERVER'
12268 ;; Should expire (according to some aging scheme) all ARTICLES. Most
12269 ;; backends will not be able to expire articles. Should return a list
12270 ;; of all articles that were not expired.
12272 ;; `choke-request-move-article ARTICLE GROUP SERVER ACCEPT-FORM &optional LAST'
12273 ;; Should move ARTICLE from GROUP on SERVER by using ACCEPT-FORM.
12274 ;; Removes any information it has added to the article (extra headers,
12275 ;; whatever - make it as clean as possible), and then passes the
12276 ;; article on by evaling ACCEPT-FORM, which is normally a call to the
12277 ;; function described below. If the ACCEPT-FORM returns a non-nil
12278 ;; value, the article should then be deleted. If LAST is nil, that
12279 ;; means that there will be further calls to this function. This might
12280 ;; be taken as an advice not to save buffers/internal variables just
12281 ;; yet, but wait until the last call to speed things up.
12283 ;; `choke-request-accept-article GROUP &optional LAST'
12284 ;; The contents of the current buffer will be put into GROUP. There
12285 ;; should, of course, be an article in the current buffer. This
12286 ;; function is normally only called by the function described above,
12287 ;; and LAST works the same way as in that function.
12289 ;; `choke-request-replace-article ARTICLE GROUP BUFFER'
12290 ;; Replace ARTICLE in GROUP with the contents of BUFFER.
12291 ;; This provides an easy interface for allowing editing of
12292 ;; articles. Note that even headers may be edited, so the backend has
12293 ;; to update any tables (nov buffers, etc) that it maintains after
12294 ;; replacing the article.
12296 ;; `choke-request-create-group GROUP &optional SERVER'
12297 ;; Create GROUP on SERVER. This might be a new, empty group, or it
12298 ;; might be a group that already exists, but hasn't been registered
12301 ;; All these functions must return nil if they couldn't service the
12302 ;; request. If the optional arguments are not supplied, some "current"
12303 ;; or "default" values should be used. In short, one should emulate an
12304 ;; NNTP server, in a way.
12306 ;; If you want to write a new backend, you just have to supply the
12307 ;; functions listed above. In addition, you must enter the new backend
12308 ;; into the list of valid select methods:
12309 ;; (setq gnus-valid-select-methods
12310 ;; (cons '("choke" mail) gnus-valid-select-methods))
12311 ;; The first element in this list is the name of the backend. Other
12312 ;; elemnets may be `mail' (for mail groups), `post' (for news
12313 ;; groups), `none' (neither), `respool' (for groups that can control
12314 ;; their contents).
12316 (defun gnus-start-news-server (&optional confirm)
12317 "Open a method for getting news.
12318 If CONFIRM is non-nil, the user will be asked for an NNTP server."
12320 (if gnus-current-select-method
12321 ;; Stream is already opened.
12323 ;; Open NNTP server.
12324 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
12327 ;; Read server name with completion.
12328 (setq gnus-nntp-server
12329 (completing-read "NNTP server: "
12330 (mapcar (lambda (server) (list server))
12331 (cons (list gnus-nntp-server)
12332 gnus-secondary-servers))
12333 nil nil gnus-nntp-server))))
12335 (if (and gnus-nntp-server
12336 (stringp gnus-nntp-server)
12337 (not (string= gnus-nntp-server "")))
12338 (setq gnus-select-method
12339 (cond ((or (string= gnus-nntp-server "")
12340 (string= gnus-nntp-server "::"))
12341 (list 'nnspool (system-name)))
12342 ((string-match ":" gnus-nntp-server)
12343 (list 'nnmh gnus-nntp-server))
12345 (list 'nntp gnus-nntp-server)))))
12347 (setq how (car gnus-select-method))
12348 (setq where (car (cdr gnus-select-method)))
12349 (cond ((eq how 'nnspool)
12351 (message "Looking up local news spool..."))
12354 (message "Looking up mh spool..."))
12357 (setq gnus-current-select-method gnus-select-method)
12358 (run-hooks 'gnus-open-server-hook)
12360 ;; gnus-open-server-hook might have opened it
12361 (gnus-server-opened gnus-select-method)
12362 (gnus-open-server gnus-select-method)
12365 "%s server on %s can't be opened. Continue? "
12366 (car gnus-select-method) (nth 1 gnus-select-method)))
12368 (message "Couldn't open server on %s" (nth 1 gnus-select-method))
12372 (defun gnus-check-news-server (method)
12373 "If the news server is down, start it up again."
12374 (let ((method (if method method gnus-select-method)))
12375 (and (stringp method)
12376 (setq method (gnus-server-to-method method)))
12377 (if (gnus-server-opened method)
12378 ;; Stream is already opened.
12381 (message "Opening server %s on %s..." (car method) (nth 1 method))
12382 (run-hooks 'gnus-open-server-hook)
12383 (or (gnus-server-opened method)
12384 (gnus-open-server method))
12387 (defun gnus-nntp-message (&optional message)
12388 "Check the status of the NNTP server.
12389 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
12390 is returned insted of the status string."
12391 (let ((status (gnus-status-message (gnus-find-method-for-group
12392 gnus-newsgroup-name)))
12393 (message (or message "")))
12394 (if (and (stringp status) (> (length status) 0))
12397 (defun gnus-get-function (method function)
12398 (and (stringp method)
12399 (setq method (gnus-server-to-method method)))
12400 (let ((func (intern (format "%s-%s" (car method) function))))
12401 (if (not (fboundp func))
12403 (require (car method))
12404 (if (not (fboundp func))
12405 (error "No such function: %s" func))))
12408 ;;; Interface functions to the backends.
12410 (defun gnus-open-server (method)
12411 (funcall (gnus-get-function method 'open-server)
12412 (nth 1 method) (nthcdr 2 method)))
12414 (defun gnus-close-server (method)
12415 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
12417 (defun gnus-request-list (method)
12418 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
12420 (defun gnus-request-list-newsgroups (method)
12421 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
12423 (defun gnus-request-newgroups (date method)
12424 (funcall (gnus-get-function method 'request-newgroups)
12425 date (nth 1 method)))
12427 (defun gnus-server-opened (method)
12428 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
12430 (defun gnus-status-message (method)
12431 (let ((method (if (stringp method) (gnus-find-method-for-group method)
12433 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
12435 (defun gnus-request-group (group &optional dont-check)
12436 (let ((method (gnus-find-method-for-group group)))
12437 (funcall (gnus-get-function method 'request-group)
12438 (gnus-group-real-name group) (nth 1 method) dont-check)))
12440 (defun gnus-list-active-group (group)
12441 (let ((method (gnus-find-method-for-group group))
12442 (func 'list-active-group))
12443 (and (gnus-check-backend-function func group)
12444 (funcall (gnus-get-function method func)
12445 (gnus-group-real-name group) (nth 1 method)))))
12447 (defun gnus-request-group-description (group)
12448 (let ((method (gnus-find-method-for-group group))
12449 (func 'request-group-description))
12450 (and (gnus-check-backend-function func group)
12451 (funcall (gnus-get-function method func)
12452 (gnus-group-real-name group) (nth 1 method)))))
12454 (defun gnus-close-group (group)
12455 (let ((method (gnus-find-method-for-group group)))
12456 (funcall (gnus-get-function method 'close-group)
12457 (gnus-group-real-name group) (nth 1 method))))
12459 (defun gnus-retrieve-headers (articles group)
12460 (let ((method (gnus-find-method-for-group group)))
12461 (funcall (gnus-get-function method 'retrieve-headers)
12462 articles (gnus-group-real-name group) (nth 1 method))))
12464 (defun gnus-request-article (article group &optional buffer)
12465 (let ((method (gnus-find-method-for-group group)))
12466 (funcall (gnus-get-function method 'request-article)
12467 article (gnus-group-real-name group) (nth 1 method) buffer)))
12469 (defun gnus-request-head (article group)
12470 (let ((method (gnus-find-method-for-group group)))
12471 (funcall (gnus-get-function method 'request-head)
12472 article (gnus-group-real-name group) (nth 1 method))))
12474 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
12475 (defun gnus-request-post-buffer (post group subject header artbuf
12476 info follow-to respect-poster)
12477 (let* ((info (or info (and group (nth 2 (gnus-gethash
12478 group gnus-newsrc-hashtb)))))
12480 (if (and gnus-post-method
12481 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
12483 (format "%s" (car (gnus-find-method-for-group
12484 gnus-newsgroup-name)))
12485 gnus-valid-select-methods)))
12487 (gnus-find-method-for-group gnus-newsgroup-name))))
12488 (let ((mail-self-blind nil)
12489 (mail-archive-file-name nil))
12490 (funcall (gnus-get-function method 'request-post-buffer)
12491 post group subject header artbuf info follow-to
12494 (defun gnus-request-post (method &optional force)
12495 (and (stringp method)
12496 (setq method (gnus-server-to-method method)))
12497 (and (not force) gnus-post-method
12498 (memq 'post (assoc (format "%s" (car method))
12499 gnus-valid-select-methods))
12500 (setq method gnus-post-method))
12501 (funcall (gnus-get-function method 'request-post)
12504 (defun gnus-request-expire-articles (articles group &optional force)
12505 (let ((method (gnus-find-method-for-group group)))
12506 (funcall (gnus-get-function method 'request-expire-articles)
12507 articles (gnus-group-real-name group) (nth 1 method)
12510 (defun gnus-request-move-article
12511 (article group server accept-function &optional last)
12512 (let ((method (gnus-find-method-for-group group)))
12513 (funcall (gnus-get-function method 'request-move-article)
12514 article (gnus-group-real-name group)
12515 (nth 1 method) accept-function last)))
12517 (defun gnus-request-accept-article (group &optional last)
12518 (let ((func (if (symbolp group) group
12519 (car (gnus-find-method-for-group group)))))
12520 (funcall (intern (format "%s-request-accept-article" func))
12521 (if (stringp group) (gnus-group-real-name group) group)
12524 (defun gnus-request-replace-article (article group buffer)
12525 (let ((func (car (gnus-find-method-for-group group))))
12526 (funcall (intern (format "%s-request-replace-article" func))
12527 article (gnus-group-real-name group) buffer)))
12529 (defun gnus-request-create-group (group)
12530 (let ((method (gnus-find-method-for-group group)))
12531 (funcall (gnus-get-function method 'request-create-group)
12532 (gnus-group-real-name group) (nth 1 method))))
12534 (defun gnus-find-method-for-group (group)
12535 (or gnus-override-method
12537 gnus-select-method)
12538 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
12541 (not (setq method (nth 4 info))))
12542 (setq method gnus-select-method)
12544 (cond ((stringp method)
12545 (gnus-server-to-method method))
12546 ((stringp (car method))
12547 (gnus-server-extend-method group method))
12550 (let ((method-name (symbol-name (car method))))
12551 (if (and (memq 'address (assoc method-name
12552 gnus-valid-select-methods))
12553 (not (assq (intern (concat method-name "-address"))
12557 (list (list (intern (concat
12558 method-name "-address"))
12559 (nth 1 method)))))))
12563 (defun gnus-check-backend-function (func group)
12564 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
12566 (fboundp (intern (format "%s-%s" method func)))))
12568 (defun gnus-methods-using (method)
12569 (let ((valids gnus-valid-select-methods)
12572 (if (memq method (car valids))
12573 (setq outs (cons (car valids) outs)))
12574 (setq valids (cdr valids)))
12578 ;;; Active & Newsrc File Handling
12581 ;; Newsrc related functions.
12582 ;; Gnus internal format of gnus-newsrc-assoc:
12583 ;; (("alt.general" 3 (1 . 1))
12584 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
12585 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
12586 ;; The first item is the group name; the second is the subscription
12587 ;; level; the third is either a range of a list of ranges of read
12588 ;; articles, the optional fourth element is a list of marked articles,
12589 ;; the optional fifth element is the select method.
12591 ;; Gnus internal format of gnus-newsrc-hashtb:
12592 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
12593 ;; This is the entry for "alt.misc". The first element is the number
12594 ;; of unread articles in "alt.misc". The cdr of this entry is the
12595 ;; element *before* "alt.misc" in gnus-newsrc-assoc, which makes is
12596 ;; trivial to remove or add new elements into gnus-newsrc-assoc
12597 ;; without scanning the entire list. So, to get the actual information
12598 ;; of "alt.misc", you'd say something like
12599 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
12601 ;; Gnus internal format of gnus-active-hashtb:
12605 ;; The only element in each entry in this hash table is a range of
12606 ;; (possibly) available articles. (Articles in this range may have
12607 ;; been expired or cancelled.)
12609 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
12610 ;; ("alt.misc" "alt.test" "alt.general" ...)
12612 (defun gnus-setup-news (&optional rawfile level)
12613 "Setup news information.
12614 If RAWFILE is non-nil, the .newsrc file will also be read.
12615 If LEVEL is non-nil, the news will be set up at level LEVEL."
12616 (let ((init (not (and gnus-newsrc-assoc gnus-active-hashtb (not rawfile)))))
12617 ;; Clear some variables to re-initialize news information.
12618 (if init (setq gnus-newsrc-assoc nil gnus-active-hashtb nil))
12619 ;; Read the active file and create `gnus-active-hashtb'.
12620 ;; If `gnus-read-active-file' is nil, then we just create an empty
12621 ;; hash table. The partial filling out of the hash table will be
12622 ;; done in `gnus-get-unread-articles'.
12623 (if (and gnus-read-active-file
12625 (gnus-server-opened gnus-select-method))
12626 (gnus-read-active-file)
12627 (setq gnus-active-hashtb (make-vector 4095 0)))
12629 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
12630 (if init (gnus-read-newsrc-file rawfile))
12631 ;; Find the number of unread articles in each non-dead group.
12632 (gnus-get-unread-articles (or level 6))
12633 ;; Find new newsgroups and treat them.
12634 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
12635 (gnus-server-opened gnus-select-method))
12636 (gnus-find-new-newsgroups))
12637 (if (and init gnus-check-bogus-newsgroups
12638 gnus-read-active-file (not level)
12639 (gnus-server-opened gnus-select-method))
12640 (gnus-check-bogus-newsgroups))))
12642 (defun gnus-find-new-newsgroups ()
12643 "Search for new newsgroups and add them.
12644 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
12645 The `-n' option line from .newsrc is respected."
12647 (or (gnus-check-first-time-used)
12648 (if (or (consp gnus-check-new-newsgroups)
12649 (eq gnus-check-new-newsgroups 'ask-server))
12650 (gnus-ask-server-for-new-groups)
12652 group new-newsgroups)
12653 (or gnus-have-read-active-file (gnus-read-active-file))
12654 (setq gnus-newsrc-last-checked-date (current-time-string))
12655 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
12656 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
12657 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
12660 (setq group (symbol-name sym))
12661 (if (or (gnus-gethash group gnus-killed-hashtb)
12662 (gnus-gethash group gnus-newsrc-hashtb))
12664 (let ((do-sub (gnus-matches-options-n group)))
12665 (cond ((eq do-sub 'subscribe)
12666 (setq groups (1+ groups))
12667 (gnus-sethash group group gnus-killed-hashtb)
12669 gnus-subscribe-options-newsgroup-method group))
12670 ((eq do-sub 'ignore)
12673 (setq groups (1+ groups))
12674 (gnus-sethash group group gnus-killed-hashtb)
12675 (if gnus-subscribe-hierarchical-interactive
12676 (setq new-newsgroups (cons group new-newsgroups))
12677 (funcall gnus-subscribe-newsgroup-method group)))))))
12678 gnus-active-hashtb)
12680 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12681 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12683 (message "%d new newsgroup%s arrived."
12684 groups (if (> groups 1) "s have" " has")))))))
12686 (defun gnus-matches-options-n (group)
12687 ;; Returns `subscribe' if the group is to be uncoditionally
12688 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
12689 ;; no match for the group.
12691 ;; First we check the two user variables.
12693 ((and gnus-options-not-subscribe
12694 (string-match gnus-options-not-subscribe group))
12696 ((and gnus-options-subscribe
12697 (string-match gnus-options-subscribe group))
12699 ;; Then we go through the list that was retrieved from the .newsrc
12700 ;; file. This list has elements on the form
12701 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
12702 ;; is in the reverse order of the options line) is returned.
12704 (let ((regs gnus-newsrc-options-n))
12706 (not (string-match (car (car gnus-newsrc-options-n)) group)))
12707 (setq regs (cdr regs)))
12708 (and regs (cdr (car regs)))))))
12710 (defun gnus-ask-server-for-new-groups ()
12711 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
12712 (methods (cons gnus-select-method
12714 (and (consp gnus-check-new-newsgroups)
12715 gnus-check-new-newsgroups)
12716 gnus-secondary-select-methods)))
12718 (new-date (current-time-string))
12719 hashtb group new-newsgroups got-new)
12720 ;; Go thorugh both primary and secondary select methods and
12721 ;; request new newsgroups.
12723 (if (gnus-request-newgroups date (car methods))
12726 (or hashtb (setq hashtb (gnus-make-hashtable
12727 (count-lines (point-min) (point-max)))))
12728 (set-buffer nntp-server-buffer)
12729 ;; Enter all the new groups in a hashtable.
12730 (gnus-active-to-gnus-format (car methods) hashtb)))
12731 (setq methods (cdr methods)))
12732 (and got-new (setq gnus-newsrc-last-checked-date new-date))
12733 ;; Now all new groups from all select methods are in `hashtb'.
12735 (lambda (group-sym)
12736 (setq group (symbol-name group-sym))
12737 (if (or (gnus-gethash group gnus-newsrc-hashtb)
12738 (member group gnus-zombie-list)
12739 (member group gnus-killed-list))
12740 ;; The group is already known.
12742 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb)
12743 (let ((do-sub (gnus-matches-options-n group)))
12744 (cond ((eq do-sub 'subscribe)
12745 (setq groups (1+ groups))
12746 (gnus-sethash group group gnus-killed-hashtb)
12748 gnus-subscribe-options-newsgroup-method group))
12749 ((eq do-sub 'ignore)
12752 (setq groups (1+ groups))
12753 (gnus-sethash group group gnus-killed-hashtb)
12754 (if gnus-subscribe-hierarchical-interactive
12755 (setq new-newsgroups (cons group new-newsgroups))
12756 (funcall gnus-subscribe-newsgroup-method group)))))))
12759 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12760 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12762 (message "%d new newsgroup%s arrived."
12763 groups (if (> groups 1) "s have" " has")))
12766 (defun gnus-check-first-time-used ()
12767 (if (or (> (length gnus-newsrc-assoc) 1)
12768 (file-exists-p gnus-startup-file)
12769 (file-exists-p (concat gnus-startup-file ".el"))
12770 (file-exists-p (concat gnus-startup-file ".eld")))
12772 (message "First time user; subscribing you to default groups")
12773 (or gnus-have-read-active-file (gnus-read-active-file))
12774 (setq gnus-newsrc-last-checked-date (current-time-string))
12775 (let ((groups gnus-default-subscribed-newsgroups)
12779 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
12782 (setq group (symbol-name sym))
12783 (let ((do-sub (gnus-matches-options-n group)))
12784 (cond ((eq do-sub 'subscribe)
12785 (gnus-sethash group group gnus-killed-hashtb)
12787 gnus-subscribe-options-newsgroup-method group))
12788 ((eq do-sub 'ignore)
12791 (setq gnus-killed-list (cons group gnus-killed-list))))))
12792 gnus-active-hashtb)
12794 (if (gnus-gethash (car groups) gnus-active-hashtb)
12795 (gnus-group-change-level (car groups) 3 9))
12796 (setq groups (cdr groups)))
12797 (gnus-group-make-help-group)
12798 (and gnus-novice-user
12799 (message (substitute-command-keys "\\<gnus-group-mode-map>\\[gnus-group-list-killed] to list killed groups")))))))
12801 ;; `gnus-group-change-level' is the fundamental function for changing
12802 ;; subscription levels of newsgroups. This might mean just changing
12803 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
12804 ;; again, which subscribes/unsubscribes a group, which is equally
12805 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
12806 ;; from 8-9 to 1-7 means that you remove the group from the list of
12807 ;; killed (or zombie) groups and add them to the (kinda) subscribed
12808 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
12809 ;; which is trivial.
12810 ;; ENTRY can either be a string (newsgroup name) or a list (if
12811 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
12812 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
12814 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
12815 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
12817 (defun gnus-group-change-level (entry level &optional oldlevel
12818 previous fromkilled)
12819 (let ((pinfo entry)
12820 group info active num)
12821 ;; Glean what info we can from the arguments
12823 (if fromkilled (setq group (nth 1 entry))
12824 (setq group (car (nth 2 entry))))
12825 (setq group entry))
12826 (if (and (stringp entry)
12829 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
12830 (if (and (not oldlevel)
12832 (setq oldlevel (car (cdr (nth 2 entry)))))
12833 (if (stringp previous)
12834 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
12836 (gnus-dribble-enter
12837 (format "(gnus-group-change-level %S %S %S %S %S)"
12838 group level oldlevel (car (nth 2 previous)) fromkilled))
12840 ;; Then we remove the newgroup from any old structures, if needed.
12841 ;; If the group was killed, we remove it from the killed or zombie
12842 ;; list. If not, and it is in fact going to be killed, we remove
12843 ;; it from the newsrc hash table and assoc.
12844 (cond ((>= oldlevel 8)
12846 (setq gnus-zombie-list (delete group gnus-zombie-list))
12847 (setq gnus-killed-list (delete group gnus-killed-list))))
12851 (gnus-sethash (car (nth 2 entry))
12852 nil gnus-newsrc-hashtb)
12854 (setcdr (gnus-gethash (car (nth 3 entry))
12855 gnus-newsrc-hashtb)
12857 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
12859 ;; Finally we enter (if needed) the list where it is supposed to
12860 ;; go, and change the subscription level. If it is to be killed,
12861 ;; we enter it into the killed or zombie list.
12862 (cond ((>= level 8)
12863 (and (string= group (gnus-group-real-name group))
12865 (setq gnus-zombie-list (cons group gnus-zombie-list))
12866 (setq gnus-killed-list (cons group gnus-killed-list)))))
12868 ;; If the list is to be entered into the newsrc assoc, and
12869 ;; it was killed, we have to create an entry in the newsrc
12870 ;; hashtb format and fix the pointers in the newsrc assoc.
12871 (if (>= oldlevel 8)
12875 (setq info (cdr entry))
12876 (setq num (car entry)))
12877 (setq active (gnus-gethash group gnus-active-hashtb))
12878 (setq num (if active (- (1+ (cdr active)) (car active)) t))
12879 ;; Check whether the group is foreign. If so, the
12880 ;; foreign select method has to be entered into the
12882 (let ((method (gnus-group-method-name group)))
12883 (if (eq method gnus-select-method)
12884 (setq info (list group level nil))
12885 (setq info (list group level nil nil method)))))
12886 (setq entry (cons info (if previous (cdr (cdr previous))
12887 (cdr gnus-newsrc-assoc))))
12888 (setcdr (if previous (cdr previous) gnus-newsrc-assoc)
12890 (gnus-sethash group (cons num (if previous (cdr previous)
12891 gnus-newsrc-assoc))
12892 gnus-newsrc-hashtb)
12894 (setcdr (gnus-gethash (car (car (cdr entry)))
12895 gnus-newsrc-hashtb)
12897 ;; It was alive, and it is going to stay alive, so we
12898 ;; just change the level and don't change any pointers or
12899 ;; hash table entries.
12900 (setcar (cdr (car (cdr (cdr entry)))) level))))))
12902 (defun gnus-kill-newsgroup (newsgroup)
12903 "Obsolete function. Kills a newsgroup."
12904 (gnus-group-change-level (gnus-gethash newsgroup gnus-newsrc-hashtb) 9))
12906 (defun gnus-check-bogus-newsgroups (&optional confirm)
12907 "Remove bogus newsgroups.
12908 If CONFIRM is non-nil, the user has to confirm the deletion of every
12910 (let ((newsrc (cdr gnus-newsrc-assoc))
12912 (message "Checking bogus newsgroups...")
12913 (or gnus-have-read-active-file (gnus-read-active-file))
12914 ;; Find all bogus newsgroup that are subscribed.
12916 (setq group (car (car newsrc)))
12917 (if (or (gnus-gethash group gnus-active-hashtb)
12918 (nth 4 (car newsrc))
12920 (not (gnus-y-or-n-p
12921 (format "Remove bogus newsgroup: %s " group)))))
12922 ;; Active newsgroup.
12924 ;; Found a bogus newsgroup.
12925 (setq bogus (cons group bogus)))
12926 (setq newsrc (cdr newsrc)))
12927 ;; Remove all bogus subscribed groups by first killing them, and
12928 ;; then removing them from the list of killed groups.
12930 (gnus-group-change-level
12931 (gnus-gethash (car bogus) gnus-newsrc-hashtb) 9)
12932 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))
12933 (setq bogus (cdr bogus)))
12934 ;; Then we remove all bogus groups from the list of killed and
12935 ;; zombie groups. They are are removed without confirmation.
12936 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
12939 (setq killed (symbol-value (car dead-lists)))
12941 (setq group (car killed))
12942 (or (gnus-gethash group gnus-active-hashtb)
12943 ;; The group is bogus.
12944 (set (car dead-lists)
12945 (delete group (symbol-value (car dead-lists)))))
12946 (setq killed (cdr killed)))
12947 (setq dead-lists (cdr dead-lists))))
12948 (message "Checking bogus newsgroups... done")))
12950 (defun gnus-check-duplicate-killed-groups ()
12951 "Remove duplicates from the list of killed groups."
12953 (let ((killed gnus-killed-list))
12955 (message "%d" (length killed))
12956 (setcdr killed (delete (car killed) (cdr killed)))
12957 (setq killed (cdr killed)))))
12959 ;; Go though `gnus-newsrc-assoc' and compare with `gnus-active-hashtb'
12960 ;; and compute how many unread articles there are in each group.
12961 (defun gnus-get-unread-articles (&optional level)
12962 (let ((newsrc (cdr gnus-newsrc-assoc))
12963 (level (or level 6))
12964 info group active virtuals)
12965 (message "Checking new news...")
12967 (setq info (car newsrc))
12968 (setq group (car info))
12969 (setq active (gnus-gethash group gnus-active-hashtb))
12971 ;; Check newsgroups. If the user doesn't want to check them, or
12972 ;; they can't be checked (for instance, if the news server can't
12973 ;; be reached) we just set the number of unread articles in this
12974 ;; newsgroup to t. This means that Gnus thinks that there are
12975 ;; unread articles, but it has no idea how many.
12977 (if (or (and gnus-activate-foreign-newsgroups
12978 (not (numberp gnus-activate-foreign-newsgroups)))
12979 (and (numberp gnus-activate-foreign-newsgroups)
12980 (<= (nth 1 info) gnus-activate-foreign-newsgroups)
12981 (<= (nth 1 info) level)))
12982 (if (eq (car (nth 4 info)) 'nnvirtual)
12983 (setq virtuals (cons info virtuals))
12984 (setq active (gnus-activate-newsgroup (car info)))))
12985 (if (and (not gnus-read-active-file)
12986 (<= (nth 1 info) level))
12988 (setq active (gnus-activate-newsgroup (car info))))))
12990 (or active (progn (gnus-sethash group nil gnus-active-hashtb)
12991 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
12992 (and active (gnus-get-unread-articles-in-group info active))
12993 (setq newsrc (cdr newsrc)))
12995 ;; Activate the virtual groups. This has to be done after all the
12997 ;; !!! If one virtual group contains another virtual group, even
12998 ;; doing it this way might cause problems.
13000 (and (setq active (gnus-activate-newsgroup (car (car virtuals))))
13001 (gnus-get-unread-articles-in-group (car virtuals) active))
13002 (setq virtuals (cdr virtuals)))
13004 (message "Checking new news... done")))
13006 ;; Create a hash table out of the newsrc alist. The `car's of the
13007 ;; alist elements are used as keys.
13008 (defun gnus-make-hashtable-from-newsrc-alist ()
13009 (let ((alist gnus-newsrc-assoc)
13011 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
13013 (setq prev (setq gnus-newsrc-assoc
13014 (cons (list "dummy.group" 0 nil) alist))))
13016 (gnus-sethash (car (car alist)) (cons nil prev) gnus-newsrc-hashtb)
13018 (setq alist (cdr alist)))))
13020 (defun gnus-make-hashtable-from-killed ()
13021 "Create a hash table from the killed and zombie lists."
13022 (let ((lists '(gnus-killed-list gnus-zombie-list))
13024 (setq gnus-killed-hashtb
13025 (gnus-make-hashtable
13026 (+ (length gnus-killed-list) (length gnus-zombie-list))))
13028 (setq list (symbol-value (car lists)))
13029 (setq lists (cdr lists))
13031 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
13032 (setq list (cdr list))))))
13034 (defun gnus-get-unread-articles-in-group (info active)
13035 (let* ((range (nth 2 info))
13037 (marked (nth 3 info))
13038 srange lowest group highest)
13039 ;; Modify the list of read articles according to what articles
13040 ;; are available; then tally the unread articles and add the
13041 ;; number to the group hash table entry.
13042 (cond ((zerop (cdr active))
13045 (setq num (- (1+ (cdr active)) (car active))))
13046 ((not (listp (cdr range)))
13047 ;; Fix a single (num . num) range according to the
13048 ;; active hash table.
13049 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
13050 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
13051 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
13052 ;; Compute number of unread articles.
13053 (setq num (max 0 (- (cdr active)
13054 (- (1+ (cdr range)) (car range))))))
13056 ;; The read list is a list of ranges. Fix them according to
13057 ;; the active hash table.
13058 ;; First peel off any elements that are below the lower
13060 (while (and (cdr range)
13062 (or (and (atom (car (cdr range))) (car (cdr range)))
13063 (car (car (cdr range))))))
13064 (if (numberp (car range))
13067 (or (and (numberp (car (cdr range)))
13069 (cdr (car (cdr range))))))
13070 (setcdr (car range)
13071 (or (and (numberp (nth 1 range)) (nth 1 range))
13072 (cdr (car (cdr range))))))
13073 (setcdr range (cdr (cdr range))))
13074 ;; Adjust the first element to be the same as the lower limit.
13075 (if (and (not (atom (car range)))
13076 (< (cdr (car range)) (car active)))
13077 (setcdr (car range) (1- (car active))))
13078 ;; Then we want to peel off any elements that are higher
13079 ;; than the upper active limit.
13080 (let ((srange range))
13081 ;; Go past all legal elements.
13082 (while (and (cdr srange)
13083 (<= (or (and (atom (car (cdr srange)))
13084 (car (cdr srange)))
13085 (car (car (cdr srange)))) (cdr active)))
13086 (setq srange (cdr srange)))
13088 ;; Nuke all remaining illegal elements.
13089 (setcdr srange nil))
13091 ;; Adjust the final element.
13092 (if (and (not (atom (car srange)))
13093 (> (cdr (car srange)) (cdr active)))
13094 (setcdr (car srange) (cdr active))))
13095 ;; Compute the number of unread articles.
13097 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
13098 (cdr (car range))))
13099 (or (and (atom (car range)) (car range))
13100 (car (car range))))))
13101 (setq range (cdr range)))
13102 (setq num (max 0 (- (cdr active) num)))))
13105 (and (assq 'tick marked)
13106 (inline (gnus-remove-illegal-marked-articles
13107 (assq 'tick marked) (nth 2 info))))
13108 (and (assq 'dormant marked)
13109 (inline (gnus-remove-illegal-marked-articles
13110 (assq 'dormant marked) (nth 2 info))))
13112 (gnus-gethash (car info) gnus-newsrc-hashtb)
13113 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
13114 (length (cdr (assq 'dormant marked)))))))))
13117 (defun gnus-remove-illegal-marked-articles (marked ranges)
13118 (let ((m (cdr marked)))
13119 ;; Make sure that all ticked articles are a subset of the unread
13122 (if (gnus-member-of-range (car m) ranges)
13123 (setcdr marked (cdr m))
13125 (setq m (cdr m)))))
13127 (defun gnus-activate-newsgroup (group)
13128 (let ((method (gnus-find-method-for-group group))
13130 (and (or (gnus-server-opened method) (gnus-open-server method))
13131 (gnus-request-group group)
13133 (set-buffer nntp-server-buffer)
13135 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
13137 (goto-char (match-beginning 1))
13139 group (setq active (cons (read (current-buffer))
13140 (read (current-buffer))))
13141 gnus-active-hashtb))
13144 (defun gnus-update-read-articles
13145 (group unread unselected ticked &optional domarks replied expirable killed
13146 dormant bookmark score)
13147 "Update the list of read and ticked articles in GROUP using the
13148 UNREAD and TICKED lists.
13149 Note: UNSELECTED has to be sorted over `<'.
13150 Returns whether the updating was successful."
13151 (let* ((active (or gnus-newsgroup-active
13152 (gnus-gethash group gnus-active-hashtb)))
13153 (entry (gnus-gethash group gnus-newsrc-hashtb))
13154 (number (car entry))
13155 (info (nth 2 entry))
13156 (marked (nth 3 info))
13158 (unread (sort (copy-sequence unread) (function <)))
13160 (if (or (not info) (not active))
13161 ;; There is no info on this group if it was, in fact,
13162 ;; killed. Gnus stores no information on killed groups, so
13163 ;; there's nothing to be done.
13164 ;; One could store the information somewhere temporarily,
13165 ;; perhaps... Hmmm...
13167 ;; Remove any negative articles numbers.
13168 (while (and unread (< (car unread) 0))
13169 (setq unread (cdr unread)))
13170 (setq unread (sort (append unselected unread) '<))
13171 ;; Set the number of unread articles in gnus-newsrc-hashtb.
13172 (setcar entry (max 0 (- (length unread) (length ticked)
13173 (length dormant))))
13174 ;; Compute the ranges of read articles by looking at the list of
13175 ;; unread articles.
13177 (if (/= (car unread) prev)
13178 (setq read (cons (if (= prev (1- (car unread))) prev
13179 (cons prev (1- (car unread)))) read)))
13180 (setq prev (1+ (car unread)))
13181 (setq unread (cdr unread)))
13182 (if (<= prev (cdr active))
13183 (setq read (cons (cons prev (cdr active)) read)))
13184 ;; Enter this list into the group info.
13185 (setcar (cdr (cdr info))
13186 (if (> (length read) 1) (nreverse read) read))
13187 ;; Enter the list of ticked articles.
13188 (gnus-set-marked-articles
13190 (if domarks replied (cdr (assq 'reply marked)))
13191 (if domarks expirable (cdr (assq 'expire marked)))
13192 (if domarks killed (cdr (assq 'killed marked)))
13193 (if domarks dormant (cdr (assq 'dormant marked)))
13194 (if domarks bookmark (cdr (assq 'bookmark marked)))
13195 (if domarks score (cdr (assq 'score marked))))
13198 (defun gnus-make-articles-unread (group articles)
13199 "Mark ARTICLES in GROUP as unread."
13200 (let ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
13201 (gnus-gethash (gnus-group-real-name group)
13202 gnus-newsrc-hashtb)))))
13203 (setcar (nthcdr 2 info)
13204 (gnus-remove-from-range (nth 2 info) articles))
13205 (gnus-group-update-group group t)))
13207 (defun gnus-read-active-file ()
13208 "Get active file from NNTP server."
13209 (gnus-group-set-mode-line)
13210 (let ((methods (cons gnus-select-method gnus-secondary-select-methods)))
13211 (setq gnus-have-read-active-file nil)
13213 (let* ((where (nth 1 (car methods)))
13214 (mesg (format "Reading active file%s via %s..."
13215 (if (and where (not (zerop (length where))))
13216 (concat " from " where) "")
13217 (car (car methods)))))
13219 (gnus-check-news-server (car methods))
13220 (if (gnus-request-list (car methods)) ; Get active
13222 (set-buffer nntp-server-buffer)
13223 (gnus-active-to-gnus-format
13224 (and gnus-have-read-active-file (car methods)))
13225 (setq gnus-have-read-active-file t)
13226 (message "%s...done" mesg))
13227 (message "Cannot read active file from %s server."
13228 (car (car methods)))
13230 (setq methods (cdr methods)))))
13232 ;; rewritten by jwz based on ideas from Rick Sladkey <jrs@world.std.com>
13233 ;; Further rewrites by lmi.
13234 (defun gnus-active-to-gnus-format (method &optional hashtb)
13235 "Convert active file format to internal format.
13236 Lines matching `gnus-ignored-newsgroups' are ignored."
13237 (let ((cur (current-buffer))
13241 (setq gnus-active-hashtb
13242 (gnus-make-hashtable
13243 (count-lines (point-min) (point-max))))))))
13244 ;; Delete unnecessary lines.
13245 (goto-char (point-min))
13246 (delete-matching-lines gnus-ignored-newsgroups)
13247 (and method (not (eq method gnus-select-method))
13248 (let ((prefix (gnus-group-prefixed-name "" method)))
13249 (goto-char (point-min))
13250 (while (and (not (eobp))
13251 (null (insert prefix))
13252 (zerop (forward-line 1))))))
13253 (goto-char (point-min))
13254 ;; Store active file in hashtable.
13256 (if (or (re-search-forward "\n.\r?$" nil t)
13257 (goto-char (point-max)))
13259 (beginning-of-line)
13260 (narrow-to-region (point-min) (point))))
13261 (goto-char (point-min))
13262 (if (string-match "%[oO]" gnus-group-line-format)
13263 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
13264 ;; If we want information on moderated groups, we use this
13267 (let ((mod-hashtb (make-vector 7 0))
13269 (while (not (eobp))
13270 (setq group (let ((obarray hashtb))
13272 (setq max (read cur))
13273 (set group (cons (read cur) max))
13274 ;; Enter moderated groups into a list.
13276 (symbol-name (let ((obarray mod-hashtb)) (read cur)))
13278 (setq gnus-moderated-list
13279 (cons (symbol-name group) gnus-moderated-list)))
13282 (progn (ding) (message "Possible error in active file."))))
13283 ;; And if we do not care about moderation, we use this loop,
13284 ;; which is faster.
13287 (while (not (eobp))
13288 ;; group gets set to a symbol interned in the hash table
13290 (setq group (let ((obarray hashtb)) (read cur)))
13291 (setq max (read cur))
13292 (set group (cons (read cur) max))
13295 (progn (ding) (message "Possible error in active file."))))))))
13297 (defun gnus-read-newsrc-file (&optional force)
13298 "Read startup file.
13299 If FORCE is non-nil, the .newsrc file is read."
13300 (setq gnus-current-startup-file (gnus-make-newsrc-file gnus-startup-file))
13301 ;; Reset variables that might be defined in the .newsrc.eld file.
13302 (let ((variables gnus-variable-list))
13304 (set (car variables) nil)
13305 (setq variables (cdr variables))))
13306 (let* ((newsrc-file gnus-current-startup-file)
13307 (quick-file (concat newsrc-file ".el")))
13309 ;; We always load the .newsrc.eld file. If always contains
13310 ;; much information that can not be gotten from the .newsrc
13311 ;; file (ticked articles, killed groups, foreign methods, etc.)
13312 (gnus-read-newsrc-el-file quick-file)
13315 (and (file-newer-than-file-p newsrc-file quick-file)
13316 (file-newer-than-file-p newsrc-file
13317 (concat quick-file "d")))
13318 (not gnus-newsrc-assoc))
13319 ;; We read the .newsrc file. Note that if there if a
13320 ;; .newsrc.eld file exists, it has already been read, and
13321 ;; the `gnus-newsrc-hashtb' has been created. While reading
13322 ;; the .newsrc file, Gnus will only use the information it
13323 ;; can find there for changing the data already read -
13324 ;; ie. reading the .newsrc file will not trash the data
13325 ;; already read (except for read articles).
13327 (message "Reading %s..." newsrc-file)
13328 (set-buffer (find-file-noselect newsrc-file))
13329 (buffer-disable-undo (current-buffer))
13330 (gnus-newsrc-to-gnus-format)
13331 (kill-buffer (current-buffer))
13332 (message "Reading %s... done" newsrc-file)))
13333 (and gnus-use-dribble-file (gnus-dribble-read-file)))))
13335 (defun gnus-read-newsrc-el-file (file)
13336 (let ((ding-file (concat file "d")))
13337 ;; We always, always read the .eld file.
13338 (message "Reading %s..." ding-file)
13339 (condition-case nil
13340 (load ding-file t t t)
13342 (gnus-uncompress-newsrc-assoc)
13343 (gnus-make-hashtable-from-newsrc-alist)
13344 (if (not (file-newer-than-file-p file ding-file))
13346 ;; Old format quick file
13347 (message "Reading %s..." file)
13348 ;; The .el file is newer than the .eld file, so we read that one
13350 (gnus-read-old-newsrc-el-file file))))
13352 ;; Parse the old-style quick startup file
13353 (defun gnus-read-old-newsrc-el-file (file)
13354 (let (newsrc killed marked group g m len info)
13356 (let (gnus-killed-assoc gnus-marked-assoc gnus-newsrc-assoc)
13358 (condition-case nil
13361 (setq newsrc gnus-newsrc-assoc
13362 killed gnus-killed-assoc
13363 marked gnus-marked-assoc)))
13364 (setq gnus-newsrc-assoc nil)
13366 (setq group (car newsrc))
13367 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
13370 (setcar (nthcdr 2 info) (cdr (cdr group)))
13371 (setcar (cdr info) (if (nth 1 group) 3 6))
13372 (setq gnus-newsrc-assoc (cons info gnus-newsrc-assoc)))
13373 (setq gnus-newsrc-assoc
13377 (if (nth 1 group) 3 6) (cdr (cdr group))))
13378 gnus-newsrc-assoc)))
13379 (if (setq m (assoc (car group) marked))
13380 (setcdr (cdr (cdr info)) (cons (list (cons 'tick (cdr m))) nil))))
13381 (setq newsrc (cdr newsrc)))
13382 (setq newsrc killed)
13384 (setcar newsrc (car (car newsrc)))
13385 (setq newsrc (cdr newsrc)))
13386 (setq gnus-killed-list killed))
13387 (setq gnus-newsrc-assoc (nreverse gnus-newsrc-assoc))
13388 (gnus-make-hashtable-from-newsrc-alist)))
13390 (defun gnus-make-newsrc-file (file)
13391 "Make server dependent file name by catenating FILE and server host name."
13392 (let* ((file (expand-file-name file nil))
13393 (real-file (concat file "-" (nth 1 gnus-select-method))))
13394 (if (file-exists-p real-file)
13397 (defun gnus-uncompress-newsrc-assoc ()
13398 ;; Uncompress all lists of marked articles in the newsrc assoc.
13399 (let ((newsrc gnus-newsrc-assoc)
13402 (if (not (setq marked (nth 3 (car newsrc))))
13405 (or (eq 'score (car (car marked)))
13406 (eq 'bookmark (car (car marked)))
13407 (eq 'killed (car (car marked)))
13408 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
13409 (setq marked (cdr marked))))
13410 (setq newsrc (cdr newsrc)))))
13412 (defun gnus-compress-newsrc-assoc ()
13413 ;; Compress all lists of marked articles in the newsrc assoc.
13414 (let ((newsrc gnus-newsrc-assoc)
13417 (if (not (setq marked (nth 3 (car newsrc))))
13420 (or (eq 'score (car (car marked)))
13421 (eq 'bookmark (car (car marked)))
13422 (eq 'killed (car (car marked)))
13423 (setcdr (car marked)
13424 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
13425 (setq marked (cdr marked))))
13426 (setq newsrc (cdr newsrc)))))
13428 ;; jwz: rewrote this function to be much more efficient, and not be
13429 ;; subject to regexp overflow errors when it encounters very long
13430 ;; lines -- the old behavior was to blow off the rest of the *file*
13431 ;; when a line was encountered that was too long to match!! Now it
13432 ;; uses only simple looking-at calls, and doesn't create as many
13433 ;; temporary strings. It also now handles multiple consecutive
13434 ;; options lines (before it only handled the first.)
13435 ;; Tiny rewrite by lmi.
13436 (defun gnus-newsrc-to-gnus-format ()
13437 "Parse current buffer as .newsrc file."
13438 ;; We have to re-initialize these variables (except for
13439 ;; gnus-killed-list) because the quick startup file may contain bogus
13441 (setq gnus-newsrc-options nil)
13442 (setq gnus-newsrc-options-n nil)
13443 (gnus-parse-options-lines)
13444 (gnus-parse-newsrc-body))
13446 (defun gnus-parse-options-lines ()
13447 ;; newsrc.5 seems to indicate that the options line can come anywhere
13448 ;; in the file, and that there can be any number of them:
13450 ;; An options line starts with the word options (left-
13451 ;; justified). Then there are the list of options just as
13452 ;; they would be on the readnews command line. For instance:
13454 ;; options -n all !net.sf-lovers !mod.human-nets -r
13457 ;; A string of lines beginning with a space or tab after the
13458 ;; initial options line will be considered continuation
13461 ;; For now, we only accept it at the beginning of the file.
13463 (goto-char (point-min))
13464 (skip-chars-forward " \t\n")
13465 (setq gnus-newsrc-options nil)
13466 (while (looking-at "^options[ \t]*\\(.*\\)\n")
13467 ;; handle consecutive options lines
13468 (setq gnus-newsrc-options (concat gnus-newsrc-options
13469 (if gnus-newsrc-options "\n\t")
13470 (buffer-substring (match-beginning 1)
13473 (while (looking-at "[ \t]+\\(.*\\)\n")
13474 ;; handle subsequent continuation lines of this options line
13475 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n\t"
13476 (buffer-substring (match-beginning 1)
13479 ;; Gather all "-n" options lines.
13482 (if gnus-newsrc-options
13483 (while (and (string-match "^[ \t]*-n\\([^\n]*\\)$"
13484 gnus-newsrc-options
13486 (setq start (match-end 0)))
13487 (setq result (concat result
13489 (substring gnus-newsrc-options
13490 (match-beginning 1)
13493 (and result (gnus-parse-n-options result))
13496 (defun gnus-parse-newsrc-body ()
13497 ;; Point has been positioned after the options lines. We shouldn't
13498 ;; see any more in here.
13500 (let ((subscribe nil)
13502 (line (1+ (count-lines (point-min) (point))))
13506 (skip-chars-forward " \t")
13507 (while (not (eobp))
13509 ((= (following-char) ?\n)
13510 ;; skip blank lines
13514 (skip-chars-forward "^:!\n")
13515 (if (= (following-char) ?\n)
13516 (error "line %d is unparsable in %s" line (buffer-name)))
13518 (skip-chars-backward " \t")
13520 ;; #### note: we could avoid consing a string here by binding obarray
13521 ;; and reading the newsgroup directly into the gnus-newsrc-hashtb,
13522 ;; then setq'ing newsgroup to symbol-name of that, like we do in
13523 ;; gnus-active-to-gnus-format.
13524 (setq newsgroup (buffer-substring p (point)))
13527 (setq subscribe (= (following-char) ?:))
13528 (setq read-list nil)
13530 (forward-char 1) ; after : or !
13531 (skip-chars-forward " \t")
13532 (while (not (= (following-char) ?\n))
13533 (skip-chars-forward " \t")
13536 ((looking-at "\\([0-9]+\\)-\\([0-9]+\\)") ; a range
13541 ;; faster that buffer-substring/string-to-int
13542 (narrow-to-region (point-min) (match-end 1))
13543 (read (current-buffer)))
13545 (narrow-to-region (point-min) (match-end 2))
13546 (forward-char) ; skip over "-"
13548 (read (current-buffer))
13552 ((looking-at "[0-9]+")
13553 ;; faster that buffer-substring/string-to-int
13554 (narrow-to-region (point-min) (match-end 0))
13555 (setq p (read (current-buffer)))
13557 (setq read-list (cons (cons p p) read-list))
13560 ;; bogus chars in ranges
13563 (goto-char (match-end 0))
13564 (skip-chars-forward " \t")
13565 (cond ((= (following-char) ?,)
13568 ((= (following-char) ?\n)
13571 ;; bogus char after range
13573 ;; if we get here, the parse failed
13575 (end-of-line) ; give up on this line
13577 (message "Ignoring bogus line %d for %s in %s"
13578 line newsgroup (buffer-name))
13580 ;; We have already read .newsrc.eld, so we gently update the
13581 ;; data in the hash table with the information we have just
13583 (let ((info (nth 2 (gnus-gethash newsgroup gnus-newsrc-hashtb))))
13586 (setcar (nthcdr 2 info) (nreverse read-list))
13587 (setcar (cdr info) (if subscribe 3 (if read-list 6 7))))
13588 (setq gnus-newsrc-assoc
13589 (cons (list newsgroup (if subscribe 3 (if read-list 6 7))
13590 (nreverse read-list))
13591 gnus-newsrc-assoc))))))
13592 (setq line (1+ line))
13593 (forward-line 1))))
13594 (setq gnus-newsrc-assoc (cdr gnus-newsrc-assoc))
13595 (gnus-make-hashtable-from-newsrc-alist)
13598 (defun gnus-parse-n-options (options)
13599 "Parse -n NEWSGROUPS options and return a cons of YES and NO regexps."
13600 (let (yes no yes-or-no out newsgroup)
13601 ;; Parse each newsgroup description such as "comp.all". Commas
13602 ;; and white spaces can be a newsgroup separator.
13604 (string-match "^[ \t\n,]*\\(!?\\)\\([^- \t\n,][^ \t\n,]*\\)" options)
13606 (substring options (match-beginning 1) (match-end 1)))
13610 (match-beginning 2) (match-end 2))))
13611 (setq options (substring options (match-end 2)))
13612 ;; Rewrite "all" to ".+" not ".*". ".+" requires at least one
13614 (while (string-match "\\(^\\|\\\\[.]\\)all\\(\\\\[.]\\|$\\)" newsgroup)
13616 (concat (substring newsgroup 0 (match-end 1))
13618 (substring newsgroup (match-beginning 2)))))
13619 ;; It is yes or no.
13620 (setq out (cons (cons (if (string= yes-or-no "!") 'ignore 'subscribe)
13621 (concat "^" newsgroup "$"))
13623 (setq gnus-newsrc-options-n out)))
13625 (defun gnus-save-newsrc-file ()
13626 "Save .newsrc file."
13627 ;; Note: We cannot save .newsrc file if all newsgroups are removed
13628 ;; from the variable gnus-newsrc-assoc.
13629 (and (or gnus-newsrc-assoc gnus-killed-list)
13630 gnus-current-startup-file
13631 (let ((make-backup-files t)
13632 (version-control nil)
13633 (require-final-newline t)) ;Don't ask even if requested.
13634 ;; You can stop or change version control of backup file.
13635 ;; Suggested by jason@violet.berkeley.edu.
13636 (run-hooks 'gnus-save-newsrc-hook)
13638 (if (or (not gnus-dribble-buffer)
13639 (not (buffer-name gnus-dribble-buffer))
13640 (zerop (save-excursion
13641 (set-buffer gnus-dribble-buffer)
13643 (message "(No changes need to be saved)")
13644 (if gnus-save-newsrc-file
13646 (message "Saving %s..." gnus-current-startup-file)
13647 ;; Make backup file of master newsrc.
13648 (gnus-gnus-to-newsrc-format)
13649 (message "Saving %s... done" gnus-current-startup-file)))
13650 ;; Quickly loadable .newsrc.
13651 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
13652 (gnus-add-current-to-buffer-list)
13653 (buffer-disable-undo (current-buffer))
13655 (message "Saving %s.eld..." gnus-current-startup-file)
13656 (gnus-gnus-to-quick-newsrc-format)
13657 (write-region 1 (point-max)
13658 (concat gnus-current-startup-file ".eld")
13660 (kill-buffer (current-buffer))
13661 (message "Saving %s.eld... done" gnus-current-startup-file)
13662 (gnus-dribble-delete-file))))))
13664 (defun gnus-gnus-to-quick-newsrc-format ()
13665 "Insert Gnus variables such as gnus-newsrc-assoc in lisp format."
13666 (insert ";; (ding) Gnus startup file.\n")
13667 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
13668 (insert ";; to read .newsrc.\n")
13669 (let ((variables gnus-variable-list)
13670 (gnus-newsrc-assoc (cdr gnus-newsrc-assoc))
13672 ;; insert lisp expressions.
13673 (gnus-compress-newsrc-assoc)
13675 (setq variable (car variables))
13676 (and (boundp variable)
13677 (symbol-value variable)
13678 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
13679 (insert "(setq " (symbol-name variable) " '"
13680 (prin1-to-string (symbol-value variable))
13682 (setq variables (cdr variables)))
13683 (gnus-uncompress-newsrc-assoc)))
13686 (defun gnus-gnus-to-newsrc-format ()
13687 ;; Generate and save the .newsrc file.
13688 (let ((newsrc (cdr gnus-newsrc-assoc))
13691 (set-buffer (create-file-buffer gnus-startup-file))
13692 (buffer-disable-undo (current-buffer))
13695 (if gnus-newsrc-options (insert "options " gnus-newsrc-options "\n"))
13696 ;; Write subscribed and unsubscribed.
13698 (setq info (car newsrc))
13699 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
13701 (insert (car info) (if (>= (nth 1 info) 6) "!" ":"))
13702 (if (setq ranges (nth 2 info))
13705 (if (not (listp (cdr ranges)))
13706 (if (= (car ranges) (cdr ranges))
13707 (insert (int-to-string (car ranges)))
13708 (insert (int-to-string (car ranges)) "-"
13709 (int-to-string (cdr ranges))))
13711 (setq range (car ranges)
13712 ranges (cdr ranges))
13713 (if (or (atom range) (= (car range) (cdr range)))
13714 (insert (int-to-string
13715 (or (and (atom range) range)
13717 (insert (int-to-string (car range)) "-"
13718 (int-to-string (cdr range))))
13719 (if ranges (insert ","))))))
13721 (setq newsrc (cdr newsrc)))
13722 (write-region 1 (point-max) gnus-current-startup-file nil 'nomesg)
13723 (kill-buffer (current-buffer)))))
13725 (defun gnus-read-descriptions-file ()
13726 (message "Reading descriptions file...")
13727 (if (not (gnus-request-list-newsgroups gnus-select-method))
13729 (message "Couldn't read newsgroups descriptions")
13732 (setq gnus-description-hashtb
13733 (gnus-make-hashtable (length gnus-active-hashtb)))
13736 (set-buffer nntp-server-buffer)
13737 (goto-char (point-min))
13738 (delete-non-matching-lines "^[-\\._+A-Za-z0-9]+[ \t]")
13739 (goto-char (point-min))
13740 (if (or (search-forward "\n.\n" nil t)
13741 (goto-char (point-max)))
13743 (beginning-of-line)
13744 (narrow-to-region (point-min) (point))))
13745 (goto-char (point-min))
13746 (while (not (eobp))
13747 (setq group (let ((obarray gnus-description-hashtb))
13748 (read (current-buffer))))
13749 (skip-chars-forward " \t")
13750 (set group (buffer-substring
13751 (point) (save-excursion (end-of-line) (point))))
13752 (forward-line 1))))
13753 (message "Reading descriptions file...done")
13756 (defun gnus-group-get-description (group)
13757 ;; Get the description of a group by sending XGTITLE to the server.
13758 (and (gnus-request-group-description group)
13760 (set-buffer nntp-server-buffer)
13761 (goto-char (point-min))
13762 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
13763 (buffer-substring (match-beginning 1) (match-end 1))))))
13769 (defvar gnus-server-mode-hook nil
13770 "Hook run in `gnus-server-mode' buffers.")
13772 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
13773 "Format of server lines.
13774 It works along the same lines as a normal formatting string,
13775 with some simple extensions.")
13777 (defvar gnus-server-mode-line-format "(ding) List of servers"
13778 "The format specification for the server mode line.")
13780 (defconst gnus-server-line-format-alist
13781 (list (list ?h 'how ?s)
13783 (list ?w 'where ?s)
13786 (defconst gnus-server-mode-line-format-alist
13787 (list (list ?S 'news-server ?s)
13788 (list ?M 'news-method ?s)
13789 (list ?u 'user-defined ?s)))
13791 (defvar gnus-server-line-format-spec nil)
13792 (defvar gnus-server-mode-line-format-spec nil)
13793 (defvar gnus-server-killed-servers nil)
13795 (defvar gnus-server-mode-map nil)
13796 (put 'gnus-server-mode 'mode-class 'special)
13798 (if gnus-server-mode-map
13800 (setq gnus-server-mode-map (make-sparse-keymap))
13801 (suppress-keymap gnus-server-mode-map)
13802 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
13803 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
13804 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
13805 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
13806 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
13807 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
13808 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
13809 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
13811 (defun gnus-server-mode ()
13812 "Major mode for listing and editing servers.
13814 All normal editing commands are switched off.
13815 \\<gnus-server-mode-map>
13817 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
13819 The following commands are available:
13821 \\{gnus-server-mode-map}"
13823 ; (if gnus-visual (gnus-server-make-menu-bar))
13824 (kill-all-local-variables)
13825 (setq mode-line-modified "-- ")
13826 (make-local-variable 'mode-line-format)
13827 (setq mode-line-format (copy-sequence mode-line-format))
13828 (and (equal (nth 3 mode-line-format) " ")
13829 (setcar (nthcdr 3 mode-line-format) ""))
13830 (setq major-mode 'gnus-server-mode)
13831 (setq mode-name "Server")
13832 ; (gnus-group-set-mode-line)
13833 (setq mode-line-process nil)
13834 (use-local-map gnus-server-mode-map)
13835 (buffer-disable-undo (current-buffer))
13836 (setq truncate-lines t)
13837 (setq buffer-read-only t)
13838 (run-hooks 'gnus-server-mode-hook))
13840 (defun gnus-server-insert-server-line (sformat name method)
13841 (let* ((sformat (or sformat gnus-server-line-format-spec))
13843 (where (nth 1 method))
13845 (beginning-of-line)
13847 ;; Insert the text.
13848 (insert (eval sformat))
13849 (add-text-properties
13850 b (1+ b) (list 'gnus-server (intern name)))))
13852 (defun gnus-server-setup-buffer ()
13853 (if (get-buffer gnus-server-buffer)
13856 (set-buffer (get-buffer-create gnus-server-buffer))
13857 (gnus-server-mode))))
13859 (defun gnus-server-prepare ()
13860 (setq gnus-server-mode-line-format-spec
13861 (gnus-parse-format gnus-server-mode-line-format
13862 gnus-server-mode-line-format-alist))
13863 (setq gnus-server-line-format-spec
13864 (gnus-parse-format gnus-server-line-format
13865 gnus-server-line-format-alist))
13866 (let ((alist gnus-server-alist)
13867 (buffer-read-only nil))
13870 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
13871 (setq alist (cdr alist))))
13872 (goto-char (point-min))
13873 (gnus-server-position-cursor))
13875 (defun gnus-server-server-name ()
13876 (let ((server (get-text-property
13877 (save-excursion (beginning-of-line) (point)) 'gnus-server)))
13878 (and server (symbol-name server))))
13880 (defalias 'gnus-server-position-cursor 'gnus-goto-colon)
13882 (defvar gnus-winconf-edit-server nil)
13883 (defconst gnus-server-edit-buffer "*Gnus edit server*")
13885 (defun gnus-server-update-server (server)
13887 (set-buffer gnus-server-buffer)
13888 (let ((buffer-read-only nil)
13889 (info (cdr (assoc server gnus-server-alist))))
13890 (gnus-dribble-enter
13891 (concat "(gnus-server-set-info \"" server "\" '"
13892 (prin1-to-string info) ")"))
13893 ;; Buffer may be narrowed.
13896 (if (gnus-server-goto-server server)
13897 (delete-region (progn (beginning-of-line) (point))
13898 (progn (forward-line 1) (point))))
13899 (let ((entry (assoc server gnus-server-alist)))
13900 (gnus-server-insert-server-line nil (car entry) (cdr entry))
13901 (gnus-server-position-cursor))))))
13903 (defun gnus-server-set-info (info)
13904 (gnus-dribble-enter
13905 (concat "(gnus-server-set-info '"
13906 (prin1-to-string info) ")"))
13907 (let* ((server (nth 1 info))
13908 (entry (assoc server gnus-server-alist)))
13909 (if entry (setcdr entry info)
13910 (setq gnus-server-alist
13911 (nconc gnus-server-alist (list (cons server info)))))))
13913 (defun gnus-server-to-method (server)
13914 (cdr (assoc server gnus-server-alist)))
13916 (defun gnus-server-extend-method (group method)
13918 (gnus-copy-sequence (cdr (assoc (car method) gnus-server-alist)))))
13919 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
13920 (nconc entry (cdr method))))
13922 (defun gnus-server-get-method (group method)
13923 (cond ((stringp method)
13924 (gnus-server-to-method method))
13925 ((stringp (car method))
13926 (gnus-server-extend-method group method))
13930 ;;; Interactive server functions.
13932 (defun gnus-server-kill-server (server)
13933 "Kill the server on the current line."
13934 (interactive (list (gnus-server-server-name)))
13935 (or (gnus-server-goto-server server)
13936 (if server (error "No such server: %s" server)
13937 (error "No server on the current line")))
13938 (let ((buffer-read-only nil))
13939 (delete-region (progn (beginning-of-line) (point))
13940 (progn (forward-line 1) (point))))
13941 (setq gnus-server-killed-servers
13942 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
13943 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
13944 gnus-server-alist))
13945 (gnus-server-position-cursor))
13947 (defun gnus-server-yank-server ()
13948 "Yank the previously killed server."
13950 (or gnus-server-killed-servers
13951 (error "No killed servers to be yanked"))
13952 (let ((alist gnus-server-alist)
13953 (server (gnus-server-server-name))
13954 (killed (car gnus-server-killed-servers)))
13956 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
13957 (if (string= server (car (car gnus-server-alist)))
13958 (setq gnus-server-alist (cons killed gnus-server-alist))
13959 (while (and (cdr alist)
13960 (not (string= server (car (car (cdr alist))))))
13961 (setq alist (cdr alist)))
13962 (setcdr alist (cons killed (cdr alist)))))
13963 (gnus-server-update-server (car killed))
13964 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
13965 (gnus-server-position-cursor)))
13967 (defun gnus-server-exit ()
13968 "Return to the group buffer."
13970 (kill-buffer (current-buffer))
13971 (switch-to-buffer gnus-group-buffer))
13973 (defun gnus-server-list-servers ()
13974 "List all available servers."
13976 (let ((cur (gnus-server-server-name)))
13977 (gnus-server-prepare)
13978 (if cur (gnus-server-goto-server cur)
13979 (goto-char (point-max))
13981 (gnus-server-position-cursor)))
13983 (defun gnus-server-copy-server (from to)
13986 (or (gnus-server-server-name)
13987 (error "No server on the current line"))
13988 (read-string "Copy to: ")))
13989 (or from (error "No server on current line"))
13990 (or (and to (not (string= to ""))) (error "No name to copy to"))
13991 (and (assoc to gnus-server-alist) (error "%s already exists" to))
13992 (or (assoc from gnus-server-alist)
13993 (error "%s: no such server" from))
13994 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
13995 (setcar to-entry to)
13996 (setcar (nthcdr 2 to-entry) to)
13997 (setq gnus-server-killed-servers
13998 (cons to-entry gnus-server-killed-servers))
13999 (gnus-server-yank-server)))
14001 (defun gnus-server-add-server (how where)
14003 (list (intern (completing-read "Server method: "
14004 gnus-valid-select-methods nil t))
14005 (read-string "Server name: ")))
14006 (setq gnus-server-killed-servers
14007 (cons (list where how where) gnus-server-killed-servers))
14008 (gnus-server-yank-server))
14010 (defun gnus-server-goto-server (server)
14011 "Jump to a server line."
14013 (list (completing-read "Goto server: " gnus-server-alist nil t)))
14014 (let ((to (text-property-any (point-min) (point-max)
14015 'gnus-server (intern server))))
14019 (gnus-server-position-cursor)))))
14021 (defun gnus-server-edit-server (server)
14022 "Edit the server on the current line."
14023 (interactive (list (gnus-server-server-name)))
14025 (error "No server on current line"))
14026 (setq gnus-winconf-edit-server (current-window-configuration))
14027 (pop-to-buffer (get-buffer-create gnus-server-edit-buffer))
14028 (gnus-add-current-to-buffer-list)
14030 (use-local-map (copy-keymap (current-local-map)))
14031 (local-set-key "\C-c\C-c" 'gnus-server-edit-server-done)
14033 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
14034 (insert "(gnus-server-set-info \n "
14035 (pp-to-string (list 'quote (cdr (assoc server gnus-server-alist))))
14038 (defun gnus-server-edit-server-done ()
14040 (set-buffer (get-buffer-create gnus-server-edit-buffer))
14041 (eval-current-buffer)
14042 (kill-buffer (current-buffer))
14043 (and gnus-winconf-edit-server
14044 (set-window-configuration gnus-winconf-edit-server))
14045 (setq gnus-winconf-edit-server nil)
14046 (set-buffer gnus-server-buffer)
14047 (gnus-server-update-server (gnus-server-server-name))
14048 (gnus-server-position-cursor))
14053 ;;; gnus.el ends here