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-group-always-list-unread 5
501 "*Always list groups less than this variable with unread articles.
502 If nil, use parameter to specify.")
504 (defvar gnus-user-login-name nil
505 "*The login name of the user.
506 Got from the function `user-login-name' if undefined.")
508 (defvar gnus-user-full-name nil
509 "*The full name of the user.
510 Got from the NAME environment variable if undefined.")
512 (defvar gnus-user-from-line nil
513 "*Your full, complete e-mail address.
514 Overrides the other Gnus variables if it is non-nil.
516 Here are two example values of this variable:
518 \"Lars Magne Ingebrigtsen <larsi@ifi.uio.no>\"
522 \"larsi@ifi.uio.no (Lars Magne Ingebrigtsen)\"
524 The first version is recommended, but the name has to be quoted if it
525 contains non-alphanumerical characters.")
527 (defvar gnus-show-mime nil
528 "*If non-ni, do mime processing of articles.
529 The articles will simply be fed to the function given by
530 `gnus-show-mime-method'.")
532 (defvar gnus-show-mime-method (function metamail-buffer)
533 "*Function to process a MIME message.
534 The function is called from the article buffer.")
536 (defvar gnus-show-threads t
537 "*If non-nil, display threads in summary mode.")
539 (defvar gnus-thread-hide-subtree nil
540 "*If non-nil, hide all threads initially.
541 If threads are hidden, you have to run the command
542 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
543 to expose hidden threads.")
545 (defvar gnus-thread-hide-killed t
546 "*If non-nil, hide killed threads automatically.")
548 (defvar gnus-thread-ignore-subject nil
549 "*If non-nil, ignore subjects and do all threading based on the Reference header.
550 If nil, which is the default, articles that have different subjects
551 from their parents will start separate threads.")
553 (defvar gnus-thread-indent-level 4
554 "*Number that says how much each sub-thread should be indented.")
556 ;; jwz: nuke newsgroups whose name is all digits - that means that
557 ;; some loser has let articles get into the root of the news spool,
558 ;; which is toxic. Lines beginning with whitespace also tend to be
560 (defvar gnus-ignored-newsgroups
561 (purecopy (mapconcat 'identity
562 '("^to\\." ; not "real" groups
563 "^[0-9. \t]+ " ; all digits in name
564 "[][\"#'() ;\\]" ; bogus characters
567 "*A regexp to match uninteresting newsgroups in the active file.
568 Any lines in the active file matching this regular expression are
569 removed from the newsgroup list before anything else is done to it,
570 thus making them effectively non-existant.")
572 (defvar gnus-ignored-headers
573 "^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:"
574 "*All headers that match this regexp will be hidden.
575 Also see `gnus-visible-headers'.")
577 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
578 "*All headers that do not match this regexp will be hidden.
579 Also see `gnus-ignored-headers'.")
581 (defvar gnus-sorted-header-list
582 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
583 "^Cc:" "^Date:" "^Organization:")
584 "*This variable is a list of regular expressions.
585 If it is non-nil, headers that match the regular expressions will
586 be placed first in the article buffer in the sequence specified by
589 (defvar gnus-required-headers
590 '(From Date Newsgroups Subject Message-ID Organization Lines X-Newsreader)
591 "*Headers to be generated or prompted for when posting an article.
592 RFC977 and RFC1036 require From, Date, Newsgroups, Subject,
593 Message-ID. Organization, Lines and X-Newsreader are optional. If
594 you want Gnus not to insert some header, remove it from this list.")
596 (defvar gnus-show-all-headers nil
597 "*If non-nil, don't hide any headers.")
599 (defvar gnus-save-all-headers t
600 "*If non-nil, don't remove any headers before saving.")
602 (defvar gnus-inhibit-startup-message nil
603 "*If non-nil, the startup message will not be displayed.")
605 (defvar gnus-auto-extend-newsgroup t
606 "*If non-nil, extend newsgroup forward and backward when requested.")
608 (defvar gnus-auto-select-first t
609 "*If non-nil, select the first unread article when entering a group.
610 If you want to prevent automatic selection of the first unread article
611 in some newsgroups, set the variable to nil in
612 `gnus-select-group-hook'.")
614 (defvar gnus-auto-select-next t
615 "*If non-nil, offer to go to the next group from the end of the previous.
616 If the value is t and the next newsgroup is empty, Gnus will exit
617 summary mode and go back to group mode. If the value is neither nil
618 nor t, Gnus will select the following unread newsgroup. In
619 particular, if the value is the symbol `quietly', the next unread
620 newsgroup will be selected without any confirmations.")
622 (defvar gnus-auto-select-same nil
623 "*If non-nil, select the next article with the same subject.")
625 (defvar gnus-auto-center-summary t
626 "*If non-nil, always center the current summary buffer.")
628 (defvar gnus-auto-mail-to-author nil
629 "*If non-nil, mail the authors of articles a copy of your follow-ups.
630 If this variable is `ask', the user will be prompted for whether to
631 mail a copy. The string given by `gnus-mail-courtesy-message' will be
632 inserted at the beginning of the mail copy.
634 Mail is sent using the function specified by the
635 `gnus-mail-send-method' variable.")
637 ;; Added by Ethan Bradford <ethanb@ptolemy.astro.washington.edu>.
638 (defvar gnus-mail-courtesy-message
639 "*The following message is a courtesy copy of an article\nthat has been posted as well.\n\n"
640 "This is inserted at the start of a mailed copy of a posted message.
641 If this variable is nil, no such courtesy message will be added.")
643 (defvar gnus-break-pages t
644 "*If non-nil, do page breaking on articles.
645 The page delimiter is specified by the `gnus-page-delimiter'
648 (defvar gnus-page-delimiter "^\^L"
649 "*Regexp describing what to use as article page delimiters.
650 The default value is \"^\^L\", which is a form linefeed at the
651 beginning of a line.")
653 (defvar gnus-use-full-window t
654 "*If non-nil, use the entire Emacs screen.")
656 (defvar gnus-window-configuration
660 "*Specify window configurations for each action.
661 The format of the variable is either a list of (ACTION (G S A)), where
662 G, S, and A are the relative height of group, summary, and article
663 windows, respectively, or a list of (ACTION FUNCTION), where FUNCTION
664 is a function that will be called with ACTION as an argument. ACTION
665 can be `summary', `newsgroups', or `article'.")
667 (defvar gnus-mail-reply-method (function gnus-mail-reply-using-mail)
668 "*Function to compose a reply.
669 Two pre-made functions are `gnus-mail-reply-using-mail' (sendmail) and
670 `gnus-mail-reply-using-mhe' (MH-E).")
672 (defvar gnus-mail-forward-method (function gnus-mail-forward-using-mail)
673 "*Function to forward the current message to another user.
674 Two pre-made functions are `gnus-mail-forward-using-mail' (sendmail)
675 and `gnus-mail-forward-using-mhe' (MH-E).")
677 (defvar gnus-mail-other-window-method 'gnus-mail-other-window-using-mail
678 "*Function to compose mail in the other window.
679 Two pre-made functions are `gnus-mail-other-window-using-mail'
680 (sendmail) and `gnus-mail-other-window-using-mhe' (MH-E).")
682 (defvar gnus-mail-send-method send-mail-function
683 "*Function to mail a message which is also being posted as an article.
684 The message must have To or Cc header. The default is copied from
685 the variable `send-mail-function'.")
687 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
688 "*Function called with a group name when new group is detected.
689 A few pre-made functions are supplied: `gnus-subscribe-randomly'
690 inserts new groups at the beginning of the list of groups;
691 `gnus-subscribe-alphabetically' inserts new groups in strict
692 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
693 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
696 ;; Suggested by a bug report by Hallvard B Furuseth.
697 ;; <h.b.furuseth@usit.uio.no>.
698 (defvar gnus-subscribe-options-newsgroup-method
699 (function gnus-subscribe-alphabetically)
700 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
701 If, for instance, you want to subscribe to all newsgroups in the
702 \"no\" and \"alt\" hierarchies, you'd put the following in your
705 options -n no.all alt.all
707 Gnus will the subscribe all new newsgroups in these hierarchies with
708 the subscription method in this variable.")
710 (defvar gnus-subscribe-hierarchical-interactive nil
711 "*If non-nil, Gnus will offer to subscribe hierarchically.
712 When a new hierarchy appears, Gnus will ask the user:
714 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
716 If the user pressed `d', Gnus will descend the hierarchy, `y' will
717 subscribe to all newsgroups in the hierarchy and `s' will skip this
718 hierarchy in its entirety.")
720 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
721 "*Function used for sorting the group buffer.
722 This function will be called with group info entries as the arguments
723 for the groups to be sorted. Pre-made functions include
724 `gnus-sort-by-alphabet', `gnus-sort-by-unread' and
725 `gnus-sort-by-level'")
727 ;; Mark variables suggested by Thomas Michanek
728 ;; <Thomas.Michanek@telelogic.se>.
729 (defvar gnus-unread-mark ?
730 "*Mark used for unread articles.")
731 (defvar gnus-ticked-mark ?!
732 "*Mark used for ticked articles.")
733 (defvar gnus-dormant-mark ??
734 "*Mark used for dormant articles.")
735 (defvar gnus-dread-mark ?D
736 "*Mark used for read articles.")
737 (defvar gnus-read-mark ?d
738 "*Mark used for read articles.")
739 (defvar gnus-expirable-mark ?E
740 "*Mark used for expirable articles.")
741 (defvar gnus-killed-mark ?K
742 "*Mark used for killed articles.")
743 (defvar gnus-kill-file-mark ?X
744 "*Mark used for articles killed by kill files.")
745 (defvar gnus-low-score-mark ?Y
746 "*Mark used for articles with a low score.")
747 (defvar gnus-catchup-mark ?C
748 "*Mark used for articles that are caught up.")
749 (defvar gnus-replied-mark ?R
750 "*Mark used for articles that have been replied to.")
751 (defvar gnus-process-mark ?#
753 (defvar gnus-ancient-mark ?A
754 "*Mark used for ancient articles.")
755 (defvar gnus-canceled-mark ?G
756 "*Mark used for cancelled articles.")
757 (defvar gnus-score-over-mark ?+
758 "*Score mark used for articles with high scores.")
759 (defvar gnus-score-below-mark ?-
760 "*Score mark used for articles with low scores.")
762 (defvar gnus-view-pseudo-asynchronously nil
763 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
765 (defvar gnus-view-pseudos nil
766 "*If `automatic', pseudo-articles will be viewed automatically.
767 If `not-confirm', pseudos will be viewed automatically, and the user
768 will not be asked to confirm the command.")
770 (defvar gnus-group-line-format "%M%S%5y: %(%g%)\n"
771 "*Format of group lines.
772 It works along the same lines as a normal formatting string,
773 with some simple extensions.
775 %M Only marked articles (character, \"*\" or \" \")
776 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
777 %L Level of subscribedness (integer, 1-9)
778 %N Number of unread articles (integer)
779 %I Number of dormant articles (integer)
780 %i Number of ticked and dormant (integer)
781 %T Number of ticked articles (integer)
782 %R Number of read articles (integer)
783 %t Total number of articles (integer)
784 %y Number of unread, unticked articles (integer)
785 %G Group name (string)
786 %g Qualified group name (string)
787 %D Group description (string)
788 %s Select method (string)
789 %o Moderated group (char, \"m\")
790 %O Moderated group (string, \"(m)\" or \"\")
791 %n Select from where (string)
792 %z A string that look like `<%s:%n>' if a foreign select method is used
793 %u User defined specifier. The next character in the format string should
794 be a letter. Gnus will call the function gnus-user-format-function-X,
795 where X is the letter following %u. The function will be passed the
796 current header as argument. The function should return a string, which
797 will be inserted into the buffer just like information from any other
800 Text between %( and %) will be highlighted with `gnus-mouse-face' when
801 the mouse point move inside the area. There can only be one such area.
803 Note that this format specification is not always respected. For
804 reasons of efficiency, when listing killed groups, this specification
805 is ignored altogether. If the spec is changed considerably, your
806 output may end up looking strange when listing both alive and killed
809 If you use %o or %O, reading the active file will be slower and quite
810 a bit of extra memory will be used. %D will also worsen performance.
811 Also note that if you change the format specification to include any
812 of these specs, you must probably re-start Gnus to see them go into
815 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
816 "*The format specification of the lines in the summary buffer.
818 It works along the same lines as a normal formatting string,
819 with some simple extensions.
821 %N Article number, left padded with spaces (string)
823 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
824 %n Name of the poster (string)
825 %A Address of the poster (string)
826 %F Contents of the From: header (string)
827 %x Contents of the Xref: header (string)
828 %D Date of the article (string)
829 %M Message-id of the article (string)
830 %r References of the article (string)
831 %c Number of characters in the article (integer)
832 %L Number of lines in the article (integer)
833 %I Indentation based on thread level (a string of spaces)
834 %T A string with two possible values: 80 spaces if the article
835 is on thread level two or larger and 0 spaces on level one
836 %R \"R\" if this article has been replied to, \" \" otherwise (character)
837 %U Status of this article (character, \"D\", \"K\", \"-\" or \" \")
838 %[ Opening bracket (character, \"[\" or \"<\")
839 %] Closing bracket (character, \"]\" or \">\")
840 %> Spaces of length thread-level (string)
841 %< Spaces of length (- 20 thread-level) (string)
842 %i Article score (number)
843 %z Article zcore (character)
844 %t Number of articles under the current thread.
845 %u User defined specifier. The next character in the format string should
846 be a letter. Gnus will call the function gnus-user-format-function-X,
847 where X is the letter following %u. The function will be passed the
848 current header as argument. The function should return a string, which
849 will be inserted into the summary just like information from any other
852 Text between %( and %) will be highlighted with `gnus-mouse-face'
853 when the mouse point is placed inside the area. There can only be one
856 The %U (status), %R (replied) and %z (zcore) specs have to be handled
857 with care. For reasons of efficiency, Gnus will compute what column
858 these characters will end up in, and \"hard-code\" that. This means that
859 it is illegal to have these specs after a variable-length spec. Well,
860 you might not be arrested, but your summary buffer will look strange,
863 The smart choice is to have these specs as for to the left as
866 This restriction may disappear in later versions of Gnus.")
868 (defvar gnus-summary-dummy-line-format "* : : %S\n"
869 "*The format specification for the dummy roots in the summary buffer.
870 It works along the same lines as a normal formatting string,
871 with some simple extensions.
875 (defvar gnus-summary-mode-line-format "(ding) %G/%A %Z"
876 "*The format specification for the summary mode line.")
878 (defvar gnus-article-mode-line-format "(ding) %G/%A %S"
879 "*The format specification for the article mode line.")
881 (defvar gnus-group-mode-line-format "(ding) List of groups {%M:%S} "
882 "*The format specification for the group mode line.")
884 (defvar gnus-valid-select-methods
885 '(("nntp" post address prompt-address)
887 ("nnvirtual" none virtual prompt-address address)
888 ("nnmbox" mail respool)
889 ("nnml" mail respool)
890 ("nnmh" mail respool)
891 ("nndir" none prompt-address address)
893 ("nndoc" none prompt-address)
894 ("nnbabyl" mail respool)
895 ("nnkiboze" none virtual)
896 ("nnfolder" mail respool))
897 "An alist of valid select methods.
898 The first element of each list lists should be a string with the name
899 of the select method. The other elements may be be the category of
900 this method (ie. `post', `mail', `none' or whatever) or other
901 properties that this method has (like being respoolable).
902 If you implement a new select method, all you should have to change is
903 this variable. I think.")
905 (defvar gnus-updated-mode-lines '(group article summary)
906 "*List of buffers that should update their mode lines.
907 The list may contain the symbols `group', `article' and `summary'. If
908 the corresponding symbol is present, Gnus will keep that mode line
909 updated with information that may be pertinent.
910 If this variable is nil, screen refresh may be quicker.")
912 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
913 (defvar gnus-mode-non-string-length 21
914 "*Max length of mode-line non-string contents.
915 If this is nil, Gnus will take space as is needed, leaving the rest
916 of the modeline intact.")
918 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
919 (defvar gnus-mouse-face 'highlight
920 "*Face used for mouse highlighting in Gnus.
921 No mouse highlights will be done if `gnus-visual' is nil.")
923 (defvar gnus-summary-mark-below nil
924 "*Mark all articles with a score below this variable as read.
925 This variable is local to each summary buffer and usually set by the
928 (defvar gnus-orphan-score nil
929 "*All orphans get this score added. Set in the score file.")
931 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
932 "*List of functions used for sorting threads in the summary buffer.
933 By default, threads are sorted by article number.
935 Each function takes two threads and return non-nil if the first thread
936 should be sorted before the other. If you use more than one function,
937 the primary sort function should be the last.
939 Ready-mady functions include `gnus-thread-sort-by-number',
940 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
941 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
942 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
944 The latter two only work on threads that have been scored prior to
945 entering the newsgroup.")
947 (defvar gnus-thread-score-function '+
948 "*Function used for calculating the total score of a thread.
950 The function is called with the scores of the article and each
951 subthread and should then return the score of the thread.
953 Some functions you can use are `+', `max', or `min'.")
955 (defvar gnus-score-find-score-files-function 'gnus-score-find-bnews
956 "*Function used to find SCORE files.
957 The function will be called with the group name as the argument, and
958 should return a list of score files to apply to that group. The score
959 files do not actually have to exist.
961 Predefined values are:
963 gnus-score-find-single: Only apply the group's own SCORE file.
964 gnus-score-find-hierarchical: Also apply SCORE files from parent groups.
965 gnus-score-find-bnews: Apply SCORE files whose names matches.
967 See the documentation to these functions for more information.
969 This variable can also be a list of functions to be called. Each
970 function should either return a list of score files, or a list of
973 (defvar gnus-options-subscribe nil
974 "*All new groups matching this regexp will be subscribed unconditionally.
975 Note that this variable deals only with new newsgroups. This variable
976 does not affect old newsgroups.")
978 (defvar gnus-options-not-subscribe nil
979 "*All new groups matching this regexp will be ignored.
980 Note that this variable deals only with new newsgroups. This variable
981 does not affect old (already subscribed) newsgroups.")
983 (defvar gnus-auto-expirable-newsgroups nil
984 "*Groups in which to automatically mark read articles as expirable.
985 If non-nil, this should be a regexp that should match all groups in
986 which to perform auto-expiry. This only makes sense for mail groups.")
991 (defvar gnus-group-mode-hook nil
992 "*A hook for Gnus group mode.")
994 (defvar gnus-summary-mode-hook nil
995 "*A hook for Gnus summary mode.")
997 (defvar gnus-article-mode-hook nil
998 "*A hook for Gnus article mode.")
1000 (defvar gnus-open-server-hook nil
1001 "*A hook called just before opening connection to the news server.")
1003 (defvar gnus-startup-hook nil
1004 "*A hook called at startup.
1005 This hook is called after Gnus is connected to the NNTP server.")
1007 (defvar gnus-get-new-news-hook nil
1008 "*A hook run just before Gnus checks for new news.")
1010 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1011 "*A function that is called to generate the group buffer.
1012 The function is called with three arguments: The first is a number;
1013 all group with a level less or equal to that number should be listed,
1014 if the second is non-nil, empty groups should also be displayed. If
1015 the third is non-nil, it is a number. No groups with a level lower
1016 than this number should be displayed.
1018 The only current function implemented is `gnus-group-prepare-flat'.")
1020 (defvar gnus-group-prepare-hook nil
1021 "*A hook called after the group buffer has been generated.
1022 If you want to modify the group buffer, you can use this hook.")
1024 (defvar gnus-summary-prepare-hook nil
1025 "*A hook called after the summary buffer has been generated.
1026 If you want to modify the summary buffer, you can use this hook.")
1028 (defvar gnus-article-prepare-hook nil
1029 "*A hook called after an article has been prepared in the article buffer.
1030 If you want to run a special decoding program like nkf, use this hook.")
1032 (defvar gnus-article-display-hook nil
1033 "*A hook called after the article is displayed in the article buffer.
1034 The hook is designed to change the contents of the article
1035 buffer. Typical functions that this hook may contain are
1036 `gnus-article-hide-headers' (hide selected headers),
1037 `gnus-article-hide-signature' (hide signature) and
1038 `gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1039 (add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1040 (add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1042 (defconst gnus-article-x-face-command "uncompface | ikon2xbm | xv -"
1043 "String or function to be executed to display an X-Face header.
1044 If it is a string, the command will be executed in a sub-shell
1045 asynchronously. The compressed face will be piped to this command.")
1047 (defvar gnus-select-group-hook nil
1048 "*A hook called when a newsgroup is selected.
1050 If you'd like to simplify subjects like the
1051 `gnus-summary-next-same-subject' command does, you can use the
1054 (setq gnus-select-group-hook
1057 (mapcar (lambda (header)
1060 (gnus-simplify-subject
1061 (header-subject header) 're-only)))
1062 gnus-newsgroup-headers))))")
1064 (defvar gnus-select-article-hook
1065 '(gnus-summary-show-thread)
1066 "*A hook called when an article is selected.
1067 The default hook shows conversation thread subtrees of the selected
1068 article automatically using `gnus-summary-show-thread'.")
1070 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1071 "*A hook called to apply kill files to a group.
1072 This hook is intended to apply a kill file to the selected newsgroup.
1073 The function `gnus-apply-kill-file' is called by default.
1075 Since a general kill file is too heavy to use only for a few
1076 newsgroups, I recommend you to use a lighter hook function. For
1077 example, if you'd like to apply a kill file to articles which contains
1078 a string `rmgroup' in subject in newsgroup `control', you can use the
1081 \(setq gnus-apply-kill-hook
1084 (cond ((string-match \"control\" gnus-newsgroup-name)
1085 (gnus-kill \"Subject\" \"rmgroup\")
1086 (gnus-expunge \"X\"))))))")
1088 (defvar gnus-visual-mark-article-hook
1089 (list 'gnus-visual-highlight-selected-summary)
1090 "*Hook run after selecting an article in the summary buffer.
1091 It is meant to be used for highlighting the article in some way. It
1092 is not run if `gnus-visual' is nil.")
1094 (defvar gnus-prepare-article-hook (list 'gnus-inews-insert-signature)
1095 "*A hook called after preparing body, but before preparing header headers.
1096 The default hook (`gnus-inews-insert-signature') inserts a signature
1097 file specified by the variable `gnus-signature-file'.")
1099 (defvar gnus-inews-article-hook (list 'gnus-inews-do-fcc)
1100 "*A hook called before finally posting an article.
1101 The default hook (`gnus-inews-do-fcc') does FCC processing (ie. saves
1102 the article to a file).")
1104 (defvar gnus-inews-article-header-hook nil
1105 "*A hook called after inserting the headers in an article to be posted.
1106 The hook is called from the *post-news* buffer, narrowed to the
1109 (defvar gnus-exit-group-hook nil
1110 "*A hook called when exiting (not quitting) summary mode.")
1112 (defvar gnus-suspend-gnus-hook nil
1113 "*A hook called when suspending (not exiting) Gnus.")
1115 (defvar gnus-exit-gnus-hook nil
1116 "*A hook called when exiting Gnus.")
1118 (defvar gnus-save-newsrc-hook nil
1119 "*A hook called when saving the newsrc file.")
1121 (defvar gnus-visual-summary-update-hook
1122 (list 'gnus-visual-summary-highlight-line)
1123 "*A hook called when a summary line is changed.
1124 The hook will not be called if `gnus-visual' is nil.
1126 The default function `gnus-visual-summary-highlight-line' will
1127 highlight the line according to the `gnus-visual-summary-highlight'
1130 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1131 "*A hook called when an article is selected for the first time.
1132 The hook is intended to mark an article as read (or unread)
1133 automatically when it is selected.")
1135 ;; Site dependent variables. These variables should be defined in
1138 (defvar gnus-default-nntp-server nil
1139 "*Specify a default NNTP server.
1140 This variable should be defined in paths.el, and should never be set
1142 If you want to change servers, you should use `gnus-select-method'.
1143 See the documentation to that variable.")
1145 (defconst gnus-backup-default-subscribed-newsgroups
1146 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
1147 "Default default new newsgroups the first time Gnus is run.
1148 Should be set in paths.el, and shouldn't be touched by the user.")
1150 (defvar gnus-local-domain nil
1151 "*Local domain name without a host name.
1152 The DOMAINNAME environment variable is used instead if it is defined.
1153 If the `system-name' function returns the full Internet name, there is
1154 no need to set this variable.")
1156 (defvar gnus-local-organization nil
1157 "*String with a description of what organization (if any) the user belongs to.
1158 The ORGANIZATION environment variable is used instead if it is defined.
1159 If this variable contains a function, this function will be called
1160 with the current newsgroup name as the argument. The function should
1162 In any case, if the string (either in the variable, in the environment
1163 variable, or returned by the function) is a file name, the contents of
1164 this file will be used as the organization.")
1166 (defvar gnus-use-generic-from nil
1167 "*If nil, the full host name will be the system name prepended to the domain name.
1168 If this is a string, the full host name will be this string.
1169 If this is non-nil, non-string, the domain name will be used as the
1172 (defvar gnus-use-generic-path nil
1173 "*If nil, use the NNTP server name in the Path header.
1174 If stringp, use this; if non-nil, use no host name (user name only).")
1177 ;; Internal variables
1179 ;; Avoid highlighting in kill files.
1180 (defvar gnus-summary-inhibit-highlight nil)
1181 (defvar gnus-newsgroup-selected-overlay nil)
1183 (defvar gnus-article-mode-map nil)
1184 (defvar caesar-translate-table nil)
1185 (defvar gnus-dribble-buffer nil)
1186 (defvar gnus-headers-retrieved-by nil)
1187 (defvar gnus-article-reply nil)
1188 (defvar gnus-override-method nil)
1189 (defvar gnus-article-check-size nil)
1190 (defvar gnus-score-file-list nil)
1191 (defvar gnus-internal-global-score-files nil)
1192 (defvar gnus-current-score-file nil)
1194 (defvar gnus-current-move-group nil)
1196 (defvar gnus-score-alist nil
1197 "Alist containing score information.
1198 The keys can be symbols or strings. The following symbols are defined.
1200 touched: If this alist has been modified.
1201 mark: Automatically mark articles below this.
1202 expunge: Automatically expunge articles below this.
1203 files: List of other SCORE files to load when loading this one.
1204 eval: Sexp to be evaluated when the score file is loaded.
1206 String entries have the form (HEADER (MATCH TYPE SCORE DATE) ...)
1207 where HEADER is the header being scored, MATCH is the string we are
1208 looking for, TYPE is a flag indicating whether it should use regexp or
1209 substring matching, SCORE is the score to add and DATE is the date
1210 of the last succesful match.")
1212 (defvar gnus-score-cache nil)
1213 (defvar gnus-scores-articles nil)
1214 (defvar gnus-scores-exclude-files nil)
1215 (defvar gnus-header-index nil)
1216 (defvar gnus-score-index nil)
1218 (defvar gnus-newsgroup-dependencies nil)
1219 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1220 (defvar gnus-default-subscribe-level 2)
1221 (defvar gnus-default-unsubscribe-level 6)
1222 (defvar gnus-default-kill-level 9)
1224 (defconst gnus-group-line-format-alist
1225 (list (list ?M 'marked ?c)
1226 (list ?S 'subscribed ?c)
1228 (list ?N 'number ?s)
1229 (list ?I 'number-of-dormant ?d)
1230 (list ?T 'number-of-ticked ?d)
1231 (list ?R 'number-of-read ?s)
1232 (list ?t 'number-total ?d)
1233 (list ?y 'number-of-unread-unticked ?s)
1234 (list ?i 'number-of-ticked-and-dormant ?d)
1236 (list ?G 'qualified-group ?s)
1237 (list ?D 'newsgroup-description ?s)
1238 (list ?o 'moderated ?c)
1239 (list ?O 'moderated-string ?s)
1240 (list ?s 'news-server ?s)
1241 (list ?n 'news-method ?s)
1242 (list ?z 'news-method-string ?s)
1243 (list ?u 'user-defined ?s)))
1245 (defconst gnus-summary-line-format-alist
1246 (list (list ?N 'number ?s)
1247 (list ?S 'subject ?s)
1248 (list ?s 'subject-or-nil ?s)
1250 (list ?A 'address ?s)
1252 (list ?x (macroexpand '(header-xref header)) ?s)
1253 (list ?D (macroexpand '(header-date header)) ?s)
1254 (list ?M (macroexpand '(header-id header)) ?s)
1255 (list ?r (macroexpand '(header-references header)) ?s)
1256 (list ?c (macroexpand '(header-chars header)) ?d)
1258 (list ?I 'indentation ?s)
1259 (list ?T '(if (< level 1) "" (make-string (frame-width) ? )) ?s)
1260 (list ?R 'replied ?c)
1261 (list ?\[ 'opening-bracket ?c)
1262 (list ?\] 'closing-bracket ?c)
1263 (list ?\> '(make-string level ? ) ?s)
1264 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1266 (list ?z 'score-char ?c)
1267 (list ?U 'unread ?c)
1268 (list ?t '(gnus-summary-number-of-articles-in-thread thread) ?d)
1269 (list ?u 'user-defined ?s))
1270 "An alist of format specifications that can appear in summary lines,
1271 and what variables they correspond with, along with the type of the
1272 variable (string, integer, character, etc).")
1274 (defconst gnus-summary-dummy-line-format-alist
1275 (list (list ?S 'subject ?s)
1276 (list ?N 'number ?d)
1277 (list ?u 'user-defined ?s)))
1279 (defconst gnus-summary-mode-line-format-alist
1280 (list (list ?G 'group-name ?s)
1281 (list ?g '(gnus-short-group-name group-name) ?s)
1282 (list ?A 'article-number ?d)
1283 (list ?Z 'unread-and-unselected ?s)
1284 (list ?V 'gnus-version ?s)
1285 (list ?U 'unread ?d)
1286 (list ?S 'subject ?s)
1287 (list ?e 'unselected ?d)
1288 (list ?u 'user-defined ?s)
1289 (list ?s '(gnus-current-score-file-nondirectory)?s)))
1291 (defconst gnus-group-mode-line-format-alist
1292 (list (list ?S 'news-server ?s)
1293 (list ?M 'news-method ?s)
1294 (list ?u 'user-defined ?s)))
1296 (defvar gnus-have-read-active-file nil)
1298 (defconst gnus-maintainer "Lars Magne Ingebrigtsen <larsi@ifi.uio.no>"
1299 "The mail address of the Gnus maintainer.")
1301 (defconst gnus-version "(ding) Gnus v0.52"
1302 "Version number for this version of Gnus.")
1304 (defvar gnus-info-nodes
1305 '((gnus-group-mode "(gnus)The Group Buffer")
1306 (gnus-summary-mode "(gnus)The Summary Buffer")
1307 (gnus-article-mode "(gnus)The Article Buffer"))
1308 "Assoc list of major modes and related Info nodes.")
1310 (defvar gnus-documentation-group-file "~/dgnus/lisp/doc.txt"
1311 "The location of the (ding) Gnus documentation group.")
1313 (defvar gnus-group-buffer "*Group*")
1314 (defvar gnus-summary-buffer "*Summary*")
1315 (defvar gnus-article-buffer "*Article*")
1316 (defvar gnus-server-buffer "*Server*")
1318 (defvar gnus-buffer-list nil
1319 "Gnus buffers that should be killed on exit.")
1321 (defvar gnus-server-alist nil
1322 "List of available servers.")
1324 (defvar gnus-variable-list
1325 '(gnus-newsrc-options gnus-newsrc-options-n
1326 gnus-newsrc-last-checked-date
1327 gnus-newsrc-assoc gnus-server-alist
1328 gnus-killed-list gnus-zombie-list)
1329 "Gnus variables saved in the quick startup file.")
1331 (defvar gnus-overload-functions
1332 '((news-inews gnus-inews-news "rnewspost")
1333 (caesar-region gnus-caesar-region "rnews"))
1334 "Functions overloaded by gnus.
1335 It is a list of `(original overload &optional file)'.")
1337 (defvar gnus-newsrc-options nil
1338 "Options line in the .newsrc file.")
1340 (defvar gnus-newsrc-options-n nil
1341 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1343 (defvar gnus-newsrc-last-checked-date nil
1344 "Date Gnus last asked server for new newsgroups.")
1346 (defvar gnus-newsrc-assoc nil
1347 "Assoc list of read articles.
1348 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1350 (defvar gnus-newsrc-hashtb nil
1351 "Hashtable of gnus-newsrc-assoc.")
1353 (defvar gnus-killed-list nil
1354 "List of killed newsgroups.")
1356 (defvar gnus-killed-hashtb nil
1357 "Hash table equivalent of gnus-killed-list.")
1359 (defvar gnus-zombie-list nil
1360 "List of almost dead newsgroups.")
1362 (defvar gnus-description-hashtb nil
1363 "Descriptions of newsgroups.")
1365 (defvar gnus-list-of-killed-groups nil
1366 "List of newsgroups that have recently been killed by the user.")
1368 (defvar gnus-active-hashtb nil
1369 "Hashtable of active articles.")
1371 (defvar gnus-moderated-list nil
1372 "List of moderated newsgroups.")
1374 (defvar gnus-current-startup-file nil
1375 "Startup file for the current host.")
1377 (defvar gnus-last-search-regexp nil
1378 "Default regexp for article search command.")
1380 (defvar gnus-last-shell-command nil
1381 "Default shell command on article.")
1383 (defvar gnus-current-select-method nil
1384 "The current method for selecting a newsgroup.")
1386 (defvar gnus-have-all-newsgroups nil)
1388 (defvar gnus-article-internal-prepare-hook nil)
1390 (defvar gnus-newsgroup-name nil)
1391 (defvar gnus-newsgroup-begin nil)
1392 (defvar gnus-newsgroup-end nil)
1393 (defvar gnus-newsgroup-last-rmail nil)
1394 (defvar gnus-newsgroup-last-mail nil)
1395 (defvar gnus-newsgroup-last-folder nil)
1396 (defvar gnus-newsgroup-last-file nil)
1397 (defvar gnus-newsgroup-auto-expire nil)
1398 (defvar gnus-newsgroup-active nil)
1400 (defvar gnus-newsgroup-unreads nil
1401 "List of unread articles in the current newsgroup.")
1403 (defvar gnus-newsgroup-unselected nil
1404 "List of unselected unread articles in the current newsgroup.")
1406 (defvar gnus-newsgroup-marked nil
1407 "List of ticked articles in the current newsgroup (a subset of unread art).")
1409 (defvar gnus-newsgroup-killed nil
1410 "List of ranges of articles that have been through the scoring process.")
1412 (defvar gnus-newsgroup-kill-headers nil)
1414 (defvar gnus-newsgroup-replied nil
1415 "List of articles that have been replied to in the current newsgroup.")
1417 (defvar gnus-newsgroup-expirable nil
1418 "List of articles in the current newsgroup that can be expired.")
1420 (defvar gnus-newsgroup-processable nil
1421 "List of articles in the current newsgroup that can be processed.")
1423 (defvar gnus-newsgroup-bookmarks nil
1424 "List of articles in the current newsgroup that have bookmarks.")
1426 (defvar gnus-newsgroup-dormant nil
1427 "List of dormant articles in the current newsgroup.")
1429 (defvar gnus-newsgroup-scored nil
1430 "List of scored articles in the current newsgroup.")
1432 (defvar gnus-newsgroup-headers nil
1433 "List of article headers in the current newsgroup.")
1434 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1436 (defvar gnus-newsgroup-ancient nil
1437 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1439 (defvar gnus-current-article nil)
1440 (defvar gnus-article-current nil)
1441 (defvar gnus-current-headers nil)
1442 (defvar gnus-have-all-headers nil)
1443 (defvar gnus-last-article nil)
1444 (defvar gnus-newsgroup-history nil)
1445 (defvar gnus-current-kill-article nil)
1447 ;; Save window configuration.
1448 (defvar gnus-winconf-edit-group nil)
1449 (defvar gnus-winconf-edit-score nil)
1452 (defvar gnus-summary-line-format-spec nil)
1453 (defvar gnus-summary-dummy-line-format-spec nil)
1454 (defvar gnus-group-line-format-spec nil)
1455 (defvar gnus-summary-mode-line-format-spec nil)
1456 (defvar gnus-article-mode-line-format-spec nil)
1457 (defvar gnus-group-mode-line-format-spec nil)
1458 (defvar gnus-summary-mark-positions nil)
1460 (defvar gnus-summary-expunge-below nil)
1461 (defvar gnus-reffed-article-number nil)
1463 (defvar rmail-default-file (expand-file-name "~/XMBOX"))
1464 (defvar rmail-default-rmail-file (expand-file-name "~/XNEWS"))
1466 (defconst gnus-summary-local-variables
1467 '(gnus-newsgroup-name
1468 gnus-newsgroup-begin gnus-newsgroup-end
1469 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1470 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1471 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1472 gnus-newsgroup-unselected gnus-newsgroup-marked
1473 gnus-newsgroup-replied gnus-newsgroup-expirable
1474 gnus-newsgroup-processable gnus-newsgroup-killed
1475 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1476 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1477 gnus-current-article gnus-current-headers gnus-have-all-headers
1478 gnus-last-article gnus-article-internal-prepare-hook
1479 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1480 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1481 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1482 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1483 gnus-newsgroup-history gnus-newsgroup-ancient)
1484 "Variables that are buffer-local to the summary buffers.")
1486 ;;; End of variables.
1488 ;; Define some autoload functions Gnus might use.
1490 (autoload 'metamail-buffer "metamail")
1491 (autoload 'Info-goto-node "info")
1493 (autoload 'timezone-make-date-arpa-standard "timezone")
1494 (autoload 'timezone-fix-time "timezone")
1495 (autoload 'timezone-make-sortable-date "timezone")
1496 (autoload 'timezone-make-time-string "timezone")
1498 (autoload 'rmail-output "rmailout")
1499 (autoload 'mail-position-on-field "sendmail")
1500 (autoload 'mail-setup "sendmail")
1501 (autoload 'news-mail-other-window "rnewspost")
1502 (autoload 'news-reply-yank-original "rnewspost")
1504 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1505 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1506 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1507 (autoload 'gnus-summary-save-in-folder "gnus-mh")
1508 (autoload 'gnus-Folder-save-name "gnus-mh")
1509 (autoload 'gnus-folder-save-name "gnus-mh")
1511 (autoload 'gnus-group-make-menu-bar "gnus-visual")
1512 (autoload 'gnus-summary-make-menu-bar "gnus-visual")
1513 (autoload 'gnus-article-make-menu-bar "gnus-visual")
1514 (autoload 'gnus-visual-highlight-selected-summary "gnus-visual")
1515 (autoload 'gnus-visual-summary-highlight-line "gnus-visual")
1517 (autoload 'gnus-uu-mark-by-regexp "gnus-uu")
1518 (autoload 'gnus-uu-mark-region "gnus-uu")
1519 (autoload 'gnus-uu-mark-thread "gnus-uu")
1520 (autoload 'gnus-uu-mark-sparse "gnus-uu")
1521 (autoload 'gnus-uu-mark-series "gnus-uu")
1522 (autoload 'gnus-uu-mark-all "gnus-uu")
1523 (autoload 'gnus-uu-post-news "gnus-uu")
1524 (autoload 'gnus-uu-digest-and-forward "gnus-uu")
1526 (autoload 'gnus-uu-decode-uu "gnus-uu")
1527 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu")
1528 (autoload 'gnus-uu-decode-unshar "gnus-uu")
1529 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu")
1530 (autoload 'gnus-uu-decode-save "gnus-uu")
1531 (autoload 'gnus-uu-decode-binhex "gnus-uu")
1532 (autoload 'gnus-uu-decode-uu-view "gnus-uu")
1533 (autoload 'gnus-uu-decode-uu-and-save-view "gnus-uu")
1534 (autoload 'gnus-uu-decode-unshar-view "gnus-uu")
1535 (autoload 'gnus-uu-decode-unshar-and-save-view "gnus-uu")
1536 (autoload 'gnus-uu-decode-save-view "gnus-uu")
1537 (autoload 'gnus-uu-decode-binhex-view "gnus-uu")
1538 (autoload 'gnus-uu-decode-postscript "gnus-uu")
1539 (autoload 'gnus-uu-decode-postscript-and-save "gnus-uu")
1540 (autoload 'gnus-uu-decode-postscript-view "gnus-uu")
1541 (autoload 'gnus-uu-decode-postscript-and-save-view "gnus-uu")
1543 (autoload 'gnus-kill "gnus-kill")
1544 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1545 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1546 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1547 (autoload 'gnus-execute "gnus-kill")
1550 (autoload 'pp-to-string "pp")
1551 (autoload 'mail-extract-address-components "mail-extr")
1556 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1557 ;; If you want the cursor to go somewhere else, set these two
1558 ;; functions in some startup hook to whatever you want.
1559 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon)
1560 (defalias 'gnus-group-position-cursor 'gnus-goto-colon)
1562 ;; Cruft to make Gnus work under GNU XEmacs.
1563 (defvar gnus-xemacs nil
1564 "Non-nil if Gnus is running under GNU XEmacs.")
1566 (if (not (string-match "XEmacs\\|Lucid" emacs-version))
1568 (setq gnus-xemacs t)
1570 '((or (memq 'underline (list-faces))
1571 (make-face 'underline))
1572 (or (face-differs-from-default-p 'underline)
1573 (set-face-underline-p 'underline t))
1575 (defun set-text-properties (start end props &optional buffer)
1577 (put-text-property start end (car props) (cadr props) buffer)
1578 (remove-text-properties start end ()))))))
1581 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1582 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1583 (` (let ((GnusStartBufferWindow (selected-window)))
1586 (pop-to-buffer (, buffer))
1588 (select-window GnusStartBufferWindow)))))
1590 (defun gnus-make-hashtable (&optional hashsize)
1591 "Make a hash table (default and minimum size is 255).
1592 Optional argument HASHSIZE specifies the table size."
1593 (make-vector (if hashsize
1594 (max (gnus-create-hash-size hashsize) 255)
1597 (defmacro gnus-gethash (string hashtable)
1598 "Get hash value of STRING in HASHTABLE."
1599 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1600 ;;(` (abbrev-expansion (, string) (, hashtable)))
1601 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1603 (defmacro gnus-sethash (string value hashtable)
1604 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1605 ;; We cannot use define-abbrev since it only accepts string as value.
1606 ; (set (intern string hashtable) value))
1607 (` (set (intern (, string) (, hashtable)) (, value))))
1609 (defsubst gnus-buffer-substring (beg end)
1610 (buffer-substring (match-beginning beg) (match-end end)))
1612 (defsubst gnus-simplify-subject-re (subject)
1613 "Remove \"Re:\" from subject lines."
1614 (let ((case-fold-search t))
1615 (if (string-match "^re: *" subject)
1616 (substring subject (match-end 0))
1619 (defsubst gnus-goto-char (point)
1620 (and point (goto-char point)))
1622 (defsubst gnus-point-at-bol ()
1623 "Return point at the beginning of line."
1630 (defsubst gnus-point-at-eol ()
1631 "Return point at the beginning of line."
1640 ;;; Gnus Utility Functions
1643 (defun gnus-extract-address-components (from)
1645 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1646 (setq address (substring from (match-beginning 0) (match-end 0))))
1648 (string-match (concat "<" (regexp-quote address) ">") from)
1649 (setq name (substring from 0 (1- (match-beginning 0)))))
1651 (and (string-match "(.+)" from)
1652 (setq name (substring from (1+ (match-beginning 0))
1653 (1- (match-end 0))))))
1654 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1655 (list (or name from) (or address from))))
1657 (defun gnus-fetch-field (field)
1658 "Return the value of the header FIELD of current article."
1661 (gnus-narrow-to-headers)
1662 (mail-fetch-field field))))
1664 (defun gnus-goto-colon ()
1666 (search-forward ":" (gnus-point-at-eol) t))
1668 (defun gnus-narrow-to-headers ()
1672 (if (search-forward "\n\n")
1673 (narrow-to-region 1 (1- (point))))))
1675 ;; Get a number that is suitable for hashing; bigger than MIN
1676 (defun gnus-create-hash-size (min)
1682 (defun gnus-update-format-specifications ()
1683 (setq gnus-summary-line-format-spec
1685 gnus-summary-line-format gnus-summary-line-format-alist))
1686 (gnus-update-summary-mark-positions)
1687 (setq gnus-summary-dummy-line-format-spec
1688 (gnus-parse-format gnus-summary-dummy-line-format
1689 gnus-summary-dummy-line-format-alist))
1690 (setq gnus-group-line-format-spec
1692 gnus-group-line-format
1693 gnus-group-line-format-alist))
1694 (if (and (string-match "%D" gnus-group-line-format)
1695 (not gnus-description-hashtb)
1696 gnus-read-active-file)
1697 (gnus-read-descriptions-file))
1698 (setq gnus-summary-mode-line-format-spec
1699 (gnus-parse-format gnus-summary-mode-line-format
1700 gnus-summary-mode-line-format-alist))
1701 (setq gnus-article-mode-line-format-spec
1702 (gnus-parse-format gnus-article-mode-line-format
1703 gnus-summary-mode-line-format-alist))
1704 (setq gnus-group-mode-line-format-spec
1705 (gnus-parse-format gnus-group-mode-line-format
1706 gnus-group-mode-line-format-alist)))
1708 (defun gnus-update-summary-mark-positions ()
1710 (let ((gnus-replied-mark 129)
1711 (gnus-score-below-mark 130)
1712 (gnus-score-over-mark 130)
1715 (set-buffer (get-buffer-create " *gnus work*"))
1716 (buffer-disable-undo (current-buffer))
1718 (gnus-summary-insert-line
1719 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1720 (goto-char (point-min))
1721 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1723 (goto-char (point-min))
1724 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1725 (- (point) 2))) pos))
1726 (goto-char (point-min))
1727 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1728 (- (point) 2))) pos))
1729 (setq gnus-summary-mark-positions pos)
1730 (kill-buffer (current-buffer)))))
1732 (defun gnus-format-max-width (var length)
1734 (if (> (length (setq result (eval var))) length)
1735 (format "%s" (substring result 0 length))
1736 (format "%s" result))))
1738 (defun gnus-set-mouse-face (string)
1739 ;; Set mouse face property on STRING.
1741 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string))
1744 (defun gnus-parse-format (format spec-alist)
1745 ;; This function parses the FORMAT string with the help of the
1746 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1747 ;; string. If the FORMAT string contains the specifiers %( and %)
1748 ;; the text between them will have the mouse-face text property.
1749 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1750 (if (and gnus-visual gnus-mouse-face)
1751 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1752 (button (substring format (match-beginning 2) (match-end 2)))
1753 (post (substring format (match-beginning 3) (match-end 3))))
1755 (gnus-parse-simple-format pre spec-alist)
1756 (list 'gnus-set-mouse-face
1757 (gnus-parse-simple-format button spec-alist))
1758 (gnus-parse-simple-format post spec-alist)))
1759 (gnus-parse-simple-format
1760 (concat (substring format (match-beginning 1) (match-end 1))
1761 (substring format (match-beginning 2) (match-end 2))
1762 (substring format (match-beginning 3) (match-end 3)))
1764 (gnus-parse-simple-format format spec-alist)))
1766 (defun gnus-parse-simple-format (format spec-alist)
1767 ;; This function parses the FORMAT string with the help of the
1768 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1769 ;; string. The list will consist of the symbol `format', a format
1770 ;; specification string, and a list of forms depending on the
1773 spec flist fstring b newspec max-width elem beg)
1775 (set-buffer (get-buffer-create " *gnus work*"))
1776 (buffer-disable-undo (current-buffer))
1777 (gnus-add-current-to-buffer-list)
1781 (while (re-search-forward "%[-0-9]*\\(,[0-9]*\\)*\\(.\\)\\(.\\)?" nil t)
1782 (setq spec (string-to-char (buffer-substring (match-beginning 2)
1784 ;; First check if there are any specs that look anything like
1785 ;; "%12,12A", ie. with a "max width specification". These have
1786 ;; to be treated specially.
1787 (if (setq beg (match-beginning 1))
1790 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
1792 (setq beg (match-beginning 2)))
1793 ;; Find the specification from `spec-alist'.
1794 (if (not (setq elem (cdr (assq spec spec-alist))))
1795 (setq elem '("*" ?s)))
1796 ;; Treat user defined format specifiers specially
1797 (and (eq (car elem) 'user-defined)
1800 (list (intern (concat "gnus-user-format-function-"
1806 (delete-region (match-beginning 3) (match-end 3)))
1807 (if (not (zerop max-width))
1808 (let ((el (car elem)))
1809 (cond ((= (car (cdr elem)) ?c)
1810 (setq el (list 'char-to-string el)))
1811 ((= (car (cdr elem)) ?d)
1812 (numberp el) (setq el (list 'int-to-string el))))
1813 (setq flist (cons (list 'gnus-format-max-width
1817 (setq flist (cons (car elem) flist))
1818 (setq newspec (car (cdr elem))))
1819 ;; Remove the old specification (and possibly a ",12" string).
1820 (delete-region beg (match-end 2))
1821 ;; Insert the new specification.
1824 (setq fstring (buffer-substring 1 (point-max))))
1825 (cons 'format (cons fstring (nreverse flist)))))
1827 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
1828 (defun gnus-read-init-file ()
1830 (or (and (file-exists-p gnus-init-file)
1831 ;; Don't try to load a directory.
1832 (not (file-directory-p gnus-init-file)))
1833 (file-exists-p (concat gnus-init-file ".el"))
1834 (file-exists-p (concat gnus-init-file ".elc")))
1835 (load gnus-init-file nil t)))
1837 ;; Article file names when saving.
1839 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
1840 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1841 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
1842 Otherwise, it is like ~/News/news/group/num."
1845 (concat (if (gnus-use-long-file-name 'not-save)
1846 (gnus-capitalize-newsgroup newsgroup)
1847 (gnus-newsgroup-directory-form newsgroup))
1848 "/" (int-to-string (header-number headers)))
1849 (or gnus-article-save-directory "~/News"))))
1851 (string-equal (file-name-directory default)
1852 (file-name-directory last-file))
1853 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1855 (or last-file default))))
1857 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
1858 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1859 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group/num.
1860 Otherwise, it is like ~/News/news/group/num."
1863 (concat (if (gnus-use-long-file-name 'not-save)
1865 (gnus-newsgroup-directory-form newsgroup))
1866 "/" (int-to-string (header-number headers)))
1867 (or gnus-article-save-directory "~/News"))))
1869 (string-equal (file-name-directory default)
1870 (file-name-directory last-file))
1871 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1873 (or last-file default))))
1875 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
1876 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1877 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group.
1878 Otherwise, it is like ~/News/news/group/news."
1881 (if (gnus-use-long-file-name 'not-save)
1882 (gnus-capitalize-newsgroup newsgroup)
1883 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1884 (or gnus-article-save-directory "~/News"))))
1886 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
1887 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1888 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group.
1889 Otherwise, it is like ~/News/news/group/news."
1892 (if (gnus-use-long-file-name 'not-save)
1894 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1895 (or gnus-article-save-directory "~/News"))))
1897 ;; For subscribing new newsgroup
1899 (defun gnus-subscribe-hierarchical-interactive (groups)
1900 (let ((groups (sort groups 'string<))
1901 prefixes prefix start rest ans group starts)
1903 (setq prefixes (list "^"))
1904 (while (and groups prefixes)
1905 (while (not (string-match (car prefixes) (car groups)))
1906 (setq prefixes (cdr prefixes)))
1907 (setq prefix (car prefixes))
1908 (setq start (1- (length prefix)))
1909 (if (and (string-match "[^\\.]\\." (car groups) start)
1912 (concat "^" (substring (car groups) 0 (match-end 0))))
1913 (string-match prefix (car (cdr groups))))
1915 (setq prefixes (cons prefix prefixes))
1916 (message "Descend hierarchy %s? ([y]nsq): "
1917 (substring prefix 1 (1- (length prefix))))
1918 (setq ans (read-char))
1921 (string-match prefix
1922 (setq group (car groups))))
1923 (setq gnus-killed-list
1924 (cons group gnus-killed-list))
1925 (gnus-sethash group group gnus-killed-hashtb)
1926 (setq groups (cdr groups)))
1927 (setq starts (cdr starts)))
1930 (string-match prefix
1931 (setq group (car groups))))
1932 (gnus-sethash group group gnus-killed-hashtb)
1933 (gnus-subscribe-alphabetically (car groups))
1934 (setq groups (cdr groups)))
1935 (setq starts (cdr starts)))
1938 (setq group (car groups))
1939 (setq gnus-killed-list (cons group gnus-killed-list))
1940 (gnus-sethash group group gnus-killed-hashtb)
1941 (setq groups (cdr groups))))
1943 (message "Subscribe %s? ([n]yq)" (car groups))
1944 (setq ans (read-char))
1945 (setq group (car groups))
1947 (gnus-subscribe-alphabetically (car groups))
1948 (gnus-sethash group group gnus-killed-hashtb))
1951 (setq group (car groups))
1952 (setq gnus-killed-list (cons group gnus-killed-list))
1953 (gnus-sethash group group gnus-killed-hashtb)
1954 (setq groups (cdr groups))))
1956 (setq gnus-killed-list (cons group gnus-killed-list))
1957 (gnus-sethash group group gnus-killed-hashtb)))
1958 (setq groups (cdr groups)))))))
1960 (defun gnus-subscribe-randomly (newsgroup)
1961 "Subscribe new NEWSGROUP by making it the first newsgroup."
1962 (gnus-subscribe-newsgroup newsgroup))
1964 (defun gnus-subscribe-alphabetically (newgroup)
1965 "Subscribe new NEWSGROUP and insert it in alphabetical order."
1966 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
1967 (let ((groups (cdr gnus-newsrc-assoc))
1969 (while (and (not before) groups)
1970 (if (string< newgroup (car (car groups)))
1971 (setq before (car (car groups)))
1972 (setq groups (cdr groups))))
1973 (gnus-subscribe-newsgroup newgroup before)))
1975 (defun gnus-subscribe-hierarchically (newgroup)
1976 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
1977 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
1979 (set-buffer (find-file-noselect gnus-current-startup-file))
1980 (let ((groupkey newgroup)
1982 (while (and (not before) groupkey)
1983 (goto-char (point-min))
1985 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
1986 (while (and (re-search-forward groupkey-re nil t)
1988 (setq before (buffer-substring
1989 (match-beginning 1) (match-end 1)))
1990 (string< before newgroup)))))
1991 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
1993 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
1994 (substring groupkey (match-beginning 1) (match-end 1)))))
1995 (gnus-subscribe-newsgroup newgroup before))))
1997 (defun gnus-subscribe-interactively (newsgroup)
1998 "Subscribe new NEWSGROUP interactively.
1999 It is inserted in hierarchical newsgroup order if subscribed. If not,
2001 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
2002 (gnus-subscribe-hierarchically newsgroup)
2003 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
2005 (defun gnus-subscribe-zombies (newsgroup)
2006 "Make new NEWSGROUP a zombie group."
2007 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
2009 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2010 "Subscribe new NEWSGROUP.
2011 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2012 the first newsgroup."
2013 ;; We subscribe the group by changing its level to 3.
2014 (gnus-group-change-level
2015 newsgroup 3 9 (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2016 (message "Subscribe newsgroup: %s" newsgroup))
2020 (defun gnus-newsgroup-directory-form (newsgroup)
2021 "Make hierarchical directory name from NEWSGROUP name."
2022 (let ((newsgroup (substring newsgroup 0)) ;Copy string.
2023 (len (length newsgroup))
2025 ;; Replace all occurrences of `.' with `/'.
2027 (if (= (aref newsgroup idx) ?.)
2028 (aset newsgroup idx ?/))
2029 (setq idx (1+ idx)))
2033 (defun gnus-make-directory (dir)
2034 "Make DIRECTORY recursively."
2035 (let* ((dir (expand-file-name dir default-directory))
2037 (if (string-match "/$" dir)
2038 (setq dir (substring dir 0 (match-beginning 0))))
2039 (while (not (file-exists-p dir))
2040 (setq dirs (cons dir dirs))
2041 (string-match "/[^/]+$" dir)
2042 (setq dir (substring dir 0 (match-beginning 0))))
2044 (make-directory (car dirs))
2045 (setq dirs (cdr dirs)))))
2047 (defun gnus-capitalize-newsgroup (newsgroup)
2048 "Capitalize NEWSGROUP name."
2049 (and (not (zerop (length newsgroup)))
2050 (concat (char-to-string (upcase (aref newsgroup 0)))
2051 (substring newsgroup 1))))
2055 (defun gnus-simplify-subject (subject &optional re-only)
2056 "Remove `Re:' and words in parentheses.
2057 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2058 (let ((case-fold-search t)) ;Ignore case.
2059 ;; Remove `Re:' and `Re^N:'.
2060 (if (string-match "^re:[ \t]*" subject)
2061 (setq subject (substring subject (match-end 0))))
2062 ;; Remove words in parentheses from end.
2064 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2065 (setq subject (substring subject 0 (match-beginning 0)))))
2066 ;; Return subject string.
2069 (defun gnus-simplify-subject-fuzzy (subject)
2070 (let ((case-fold-search t))
2071 (and (string-match "^re:[ \t]*" subject)
2072 (setq subject (substring subject (match-end 0))))
2073 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2074 (setq subject (substring subject 0 (match-beginning 0))))
2077 (while (string-match "[ \t]+" subject beg)
2079 (concat osubject (substring
2080 subject beg (match-beginning 0)) " ")
2082 (setq osubject (concat osubject (substring subject beg)))
2083 (and (string-match " \\'" osubject)
2084 (setq osubject (substring osubject 0 (match-beginning 0))))
2087 (defun gnus-add-current-to-buffer-list ()
2088 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list)))
2090 (defun gnus-string> (s1 s2)
2091 (not (or (string< s1 s2)
2094 ;; Functions accessing headers.
2095 ;; Functions are more convenient than macros in some cases.
2097 (defun gnus-header-number (header)
2098 "Return article number in HEADER."
2099 (header-number header))
2101 (defun gnus-header-subject (header)
2102 "Return subject string in HEADER."
2103 (header-subject header))
2105 (defun gnus-header-from (header)
2106 "Return author string in HEADER."
2107 (header-from header))
2109 (defun gnus-header-xref (header)
2110 "Return xref string in HEADER."
2111 (header-xref header))
2113 (defun gnus-header-lines (header)
2114 "Return lines in HEADER."
2115 (header-lines header))
2117 (defun gnus-header-date (header)
2118 "Return date in HEADER."
2119 (header-date header))
2121 (defun gnus-header-id (header)
2122 "Return Id in HEADER."
2125 (defun gnus-header-references (header)
2126 "Return references in HEADER."
2127 (header-references header))
2129 (defun gnus-clear-system ()
2130 "Clear all variables and buffers."
2131 ;; Clear Gnus variables.
2132 (let ((variables gnus-variable-list))
2134 (set (car variables) nil)
2135 (setq variables (cdr variables))))
2136 ;; Clear other internal variables.
2137 (setq gnus-list-of-killed-groups nil
2138 gnus-have-read-active-file nil
2139 gnus-newsrc-assoc nil
2140 gnus-newsrc-hashtb nil
2141 gnus-killed-list nil
2142 gnus-zombie-list nil
2143 gnus-killed-hashtb nil
2144 gnus-active-hashtb nil
2145 gnus-moderated-list nil
2146 gnus-description-hashtb nil
2147 gnus-newsgroup-headers nil
2148 gnus-score-cache nil
2149 gnus-newsgroup-headers-hashtb-by-number nil
2150 gnus-newsgroup-name nil
2151 gnus-internal-global-score-files nil
2152 gnus-server-alist nil
2153 gnus-current-select-method nil)
2154 ;; Kill the startup file.
2155 (and gnus-current-startup-file
2156 (get-file-buffer gnus-current-startup-file)
2157 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2158 (gnus-dribble-clear)
2159 ;; Kill global KILL file buffer.
2160 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2161 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2162 (and (buffer-name nntp-server-buffer)
2163 (kill-buffer nntp-server-buffer))
2164 ;; Kill Gnus buffers.
2165 (while gnus-buffer-list
2166 (if (and (get-buffer (car gnus-buffer-list))
2167 (buffer-name (get-buffer (car gnus-buffer-list))))
2168 (kill-buffer (car gnus-buffer-list)))
2169 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2171 (defun gnus-configure-windows (action &optional force)
2172 "Configure Gnus windows according to the next ACTION.
2173 The ACTION is either a symbol, such as `summary', or a
2174 configuration list such as `(1 1 2)'. If ACTION is not a list,
2175 configuration list is got from the variable gnus-window-configuration.
2176 If FORCE is non-nil, the updating will be done whether it is necessary
2179 (if (listp action) action
2180 (if (listp gnus-window-configuration)
2181 (car (cdr (assq action gnus-window-configuration)))
2182 gnus-window-configuration)))
2183 (grpwin (get-buffer-window gnus-group-buffer))
2184 (subwin (get-buffer-window gnus-summary-buffer))
2185 (artwin (get-buffer-window gnus-article-buffer))
2192 ;; Make split-window-vertically leave focus in upper window.
2193 (split-window-keep-point t))
2194 (if (and (symbolp windows) (fboundp windows))
2195 (funcall windows action)
2196 (if (and (not force)
2197 (or (null windows) ;No configuration is specified.
2198 (and (eq (null grpwin)
2199 (zerop (nth 0 windows)))
2201 (zerop (nth 1 windows)))
2203 (zerop (nth 2 windows))))))
2204 ;; No need to change window configuration.
2206 (select-window (or grpwin subwin artwin (selected-window)))
2207 ;; First of all, compute the height of each window.
2208 (cond (gnus-use-full-window
2209 ;; Take up the entire screen.
2210 (delete-other-windows)
2211 (setq height (window-height (selected-window))))
2213 (setq height (+ (if grpwin (window-height grpwin) 0)
2214 (if subwin (window-height subwin) 0)
2215 (if artwin (window-height artwin) 0)))))
2216 ;; The group buffer exits always. So, use it to extend the
2217 ;; group window so as to get enough window space.
2218 (switch-to-buffer gnus-group-buffer 'norecord)
2219 (and (get-buffer gnus-summary-buffer)
2220 (delete-windows-on gnus-summary-buffer))
2221 (and (get-buffer gnus-article-buffer)
2222 (delete-windows-on gnus-article-buffer))
2223 ;; Compute expected window height.
2224 (setq winsum (apply (function +) windows))
2225 (if (not (zerop (nth 0 windows)))
2226 (setq grpheight (max window-min-height
2227 (/ (* height (nth 0 windows)) winsum))))
2228 (if (not (zerop (nth 1 windows)))
2229 (setq subheight (max window-min-height
2230 (/ (* height (nth 1 windows)) winsum))))
2231 (if (not (zerop (nth 2 windows)))
2232 (setq artheight (max window-min-height
2233 (/ (* height (nth 2 windows)) winsum))))
2234 (setq height (+ grpheight subheight artheight))
2235 (enlarge-window (max 0 (- height (window-height (selected-window)))))
2236 ;; Then split the window.
2237 (and (not (zerop artheight))
2238 (or (not (zerop grpheight))
2239 (not (zerop subheight)))
2240 (split-window-vertically (+ grpheight subheight)))
2241 (and (not (zerop grpheight))
2242 (not (zerop subheight))
2243 (split-window-vertically grpheight))
2244 ;; Then select buffers in each window.
2245 (or (zerop grpheight)
2247 (switch-to-buffer gnus-group-buffer 'norecord)
2249 (or (zerop subheight)
2251 (switch-to-buffer gnus-summary-buffer 'norecord)
2253 (or (zerop artheight)
2255 ;; If article buffer does not exist, it will be created
2257 (gnus-article-setup-buffer)
2258 (switch-to-buffer gnus-article-buffer 'norecord)
2259 (setq buffer-read-only t) ; !!! Why!?!
2260 (bury-buffer gnus-summary-buffer)
2261 (bury-buffer gnus-group-buffer)))
2262 (or (zerop subheight)
2264 (pop-to-buffer gnus-summary-buffer)
2265 ;; It seems that some code in this function will set
2266 ;; buffer-read-only to nil. I have absolutely no idea
2268 (setq buffer-read-only t))))))) ; !!! Why!?!
2270 (defun gnus-window-configuration-split (action)
2271 (switch-to-buffer gnus-group-buffer t)
2272 (delete-other-windows)
2273 (split-window-horizontally)
2274 (cond ((or (eq action 'newsgoups) (eq action 'summary))
2275 (if (and (get-buffer gnus-summary-buffer)
2276 (buffer-name gnus-summary-buffer))
2277 (switch-to-buffer-other-window gnus-summary-buffer)))
2278 ((eq action 'article)
2279 (switch-to-buffer gnus-summary-buffer t)
2281 (gnus-article-setup-buffer)
2282 (switch-to-buffer gnus-article-buffer t))))
2284 (defun gnus-version ()
2285 "Version numbers of this version of Gnus."
2287 (let ((methods gnus-valid-select-methods)
2290 ;; Go through all the legal select methods and add their version
2291 ;; numbers to the total version string. Only the backends that are
2292 ;; currently in use will have their message numbers taken into
2295 (setq meth (intern (concat (car (car methods)) "-version")))
2297 (stringp (symbol-value meth))
2298 (setq mess (concat mess "; " (symbol-value meth))))
2299 (setq methods (cdr methods)))
2302 (defun gnus-info-find-node ()
2303 "Find Info documentation of Gnus."
2305 ;; Enlarge info window if needed.
2306 (cond ((eq major-mode 'gnus-group-mode)
2307 (gnus-configure-windows '(1 0 0)) ;Take all windows.
2308 (pop-to-buffer gnus-group-buffer))
2309 ((eq major-mode 'gnus-summary-mode)
2310 (gnus-configure-windows '(0 1 0)) ;Take all windows.
2311 (pop-to-buffer gnus-summary-buffer)))
2312 (Info-goto-node (car (cdr (assq major-mode gnus-info-nodes)))))
2315 "Send a bug report to the Gnus maintainers."
2317 (pop-to-buffer "*Gnus Bug*")
2319 (mail-setup gnus-maintainer "[Gnus Bug Report] " nil nil nil nil)
2320 (goto-char (point-min))
2321 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
2323 (insert (format "%s\n%s\n\n" (gnus-version) (emacs-version)))
2328 (defun gnus-debug ()
2329 "Attemps to go through the Gnus source file and report what variables have been changed.
2330 The source file has to be in the Emacs load path."
2332 (let ((dirs load-path)
2335 (if (file-exists-p (setq file (concat (car dirs) "/gnus.el")))
2338 (set-buffer (get-buffer-create "*gnus bug info*"))
2339 (buffer-disable-undo (current-buffer))
2341 (insert-file-contents file)
2342 (goto-char (point-min))
2343 (or (search-forward "\n;; Internal variables" nil t)
2344 (error "Malformed sources"))
2345 (narrow-to-region (point-min) (point))
2346 (goto-char (point-min))
2347 (while (setq expr (condition-case ()
2348 (read (current-buffer)) (error nil)))
2349 (and (eq (car expr) 'defvar)
2350 (stringp (nth 3 expr))
2351 (not (equal (eval (nth 2 expr))
2352 (and (boundp (nth 1 expr))
2353 (symbol-value (nth 1 expr)))))
2354 (setq olist (cons (nth 1 expr) olist))))
2355 (kill-buffer (current-buffer)))
2356 (setq dirs (cdr dirs))))
2358 (insert "(setq " (symbol-name (car olist)) " '"
2359 (prin1-to-string (symbol-value (car olist))) ")\n")
2360 (setq olist (cdr olist)))
2363 (defun gnus-overload-functions (&optional overloads)
2364 "Overload functions specified by optional argument OVERLOADS.
2365 If nothing is specified, use the variable gnus-overload-functions."
2367 (overloads (or overloads gnus-overload-functions)))
2369 (setq defs (car overloads))
2370 (setq overloads (cdr overloads))
2371 ;; Load file before overloading function if necessary. Make
2372 ;; sure we cannot use `require' always.
2373 (and (not (fboundp (car defs)))
2374 (car (cdr (cdr defs)))
2375 (load (car (cdr (cdr defs))) nil 'nomessage))
2376 (fset (car defs) (car (cdr defs))))))
2378 (defun gnus-replace-chars-in-string (string from to)
2379 "Replace characters in STRING from FROM to TO."
2380 (let ((string (substring string 0)) ;Copy string.
2381 (len (length string))
2383 ;; Replace all occurrences of FROM with TO.
2385 (if (= (aref string idx) from)
2386 (aset string idx to))
2387 (setq idx (1+ idx)))
2390 (defun gnus-days-between (date1 date2)
2391 ;; Return the number of days between date1 and date2.
2392 (let ((d1 (mapcar (lambda (s) (and s (string-to-int s)) )
2393 (timezone-parse-date date1)))
2394 (d2 (mapcar (lambda (s) (and s (string-to-int s)) )
2395 (timezone-parse-date date2))))
2396 (- (timezone-absolute-from-gregorian
2397 (nth 1 d1) (nth 2 d1) (car d1))
2398 (timezone-absolute-from-gregorian
2399 (nth 1 d2) (nth 2 d2) (car d2)))))
2401 (defun gnus-day-number (date)
2402 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2403 (timezone-parse-date date))))
2404 (timezone-absolute-from-gregorian
2405 (nth 1 dat) (nth 2 dat) (car dat))))
2407 (defun gnus-file-newer-than (file date)
2408 (let ((fdate (nth 5 (file-attributes file))))
2409 (or (> (car fdate) (car date))
2410 (and (= (car fdate) (car date))
2411 (> (nth 1 fdate) (nth 1 date))))))
2413 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2415 (defun gnus-y-or-n-p (prompt)
2420 (defun gnus-yes-or-no-p (prompt)
2422 (yes-or-no-p prompt)
2425 ;; Return a string of length POS+1 representing NUMber in BASE. The
2426 ;; resulting string will be left padded with zeds.
2427 (defun gnus-number-base-x (num pos base)
2432 (aref "zyxwvutsrqponmlkjihgfedcba9876543210" (/ num (expt base pos))))
2434 (% num (expt base pos)) (1- pos) base))))
2436 ;; Check whether to use long file names.
2437 (defun gnus-use-long-file-name (symbol)
2438 ;; The variable has to be set...
2439 (and gnus-use-long-file-name
2440 ;; If it isn't a list, then we return t.
2441 (or (not (listp gnus-use-long-file-name))
2442 ;; If it is a list, and the list contains `symbol', we
2444 (not (memq symbol gnus-use-long-file-name)))))
2446 ;; List and range functions
2448 (defun gnus-last-element (list)
2449 "Return last element of LIST."
2451 (setq list (cdr list)))
2454 (defun gnus-copy-sequence (list)
2455 "Do a complete, total copy of a list."
2456 (if (and (consp list) (not (consp (cdr list))))
2457 (cons (car list) (cdr list))
2458 (mapcar (lambda (elem) (if (consp elem)
2459 (if (consp (cdr elem))
2460 (gnus-copy-sequence elem)
2461 (cons (car elem) (cdr elem)))
2465 (defun gnus-set-difference (list1 list2)
2466 "Return a list of elements of LIST1 that do not appear in LIST2."
2467 (let ((list1 (copy-sequence list1)))
2469 (setq list1 (delq (car list2) list1))
2470 (setq list2 (cdr list2)))
2473 (defun gnus-sorted-complement (list1 list2)
2474 "Return a list of elements of LIST1 that do not appear in LIST2.
2475 Both lists have to be sorted over <."
2477 (while (and list1 list2)
2478 (cond ((= (car list1) (car list2))
2479 (setq list1 (cdr list1)
2481 ((< (car list1) (car list2))
2482 (setq out (cons (car list1) out))
2483 (setq list1 (cdr list1)))
2485 (setq out (cons (car list2) out))
2486 (setq list2 (cdr list2)))))
2487 (nreverse (append (or list1 list2) out))))
2489 (defun gnus-intersection (list1 list2)
2492 (if (memq (car list2) list1)
2493 (setq result (cons (car list2) result)))
2494 (setq list2 (cdr list2)))
2497 (defun gnus-sorted-intersection (list1 list2)
2498 ;; LIST1 and LIST2 have to be sorted over <.
2500 (while (and list1 list2)
2501 (cond ((= (car list1) (car list2))
2502 (setq out (cons (car list1) out)
2505 ((< (car list1) (car list2))
2506 (setq list1 (cdr list1)))
2508 (setq list2 (cdr list2)))))
2511 (defun gnus-set-sorted-intersection (list1 list2)
2512 ;; LIST1 and LIST2 have to be sorted over <.
2513 ;; This function modifies LIST1.
2514 (let* ((top (cons nil list1))
2516 (while (and list1 list2)
2517 (cond ((= (car list1) (car list2))
2521 ((< (car list1) (car list2))
2522 (setcdr prev (cdr list1))
2523 (setq list1 (cdr list1)))
2525 (setq list2 (cdr list2)))))
2529 (defun gnus-compress-sequence (numbers &optional always-list)
2530 "Convert list of numbers to a list of ranges or a single range.
2531 If ALWAYS-LIST is non-nil, this function will always release a list of
2533 (let* ((first (car numbers))
2534 (last (car numbers))
2538 (if (not (listp (cdr numbers)))
2541 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2542 ((= (1+ last) (car numbers)) ;Still in sequence
2543 (setq last (car numbers)))
2544 (t ;End of one sequence
2546 (cons (if (= first last) first (cons first last)) result))
2547 (setq first (car numbers))
2548 (setq last (car numbers))))
2549 (setq numbers (cdr numbers)))
2550 (if (and (not always-list) (null result))
2551 (if (= first last) first (cons first last))
2552 (nreverse (cons (if (= first last) first (cons first last))
2555 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2556 (defun gnus-uncompress-range (ranges)
2557 "Expand a list of ranges into a list of numbers.
2558 RANGES is either a single range on the form `(num . num)' or a list of
2560 (let (first last result)
2564 ((not (listp (cdr ranges)))
2565 (setq first (car ranges))
2566 (setq last (cdr ranges))
2567 (while (<= first last)
2568 (setq result (cons first result))
2569 (setq first (1+ first)))
2573 (if (atom (car ranges))
2574 (if (numberp (car ranges))
2575 (setq result (cons (car ranges) result)))
2576 (setq first (car (car ranges)))
2577 (setq last (cdr (car ranges)))
2578 (while (<= first last)
2579 (setq result (cons first result))
2580 (setq first (1+ first))))
2581 (setq ranges (cdr ranges)))
2582 (nreverse result)))))
2584 (defun gnus-add-to-range (ranges list)
2585 "Return a list of ranges that has all articles from both RANGES and LIST.
2586 Note: LIST has to be sorted over `<'."
2588 (gnus-compress-sequence list t)
2589 (setq list (copy-sequence list))
2590 (or (listp (cdr ranges))
2591 (setq ranges (list ranges)))
2593 ilist lowest highest temp)
2594 (while (and ranges list)
2596 (setq lowest (or (and (atom (car ranges)) (car ranges))
2597 (car (car ranges))))
2598 (while (and list (cdr list) (< (car (cdr list)) lowest))
2599 (setq list (cdr list)))
2600 (if (< (car ilist) lowest)
2603 (setq list (cdr list))
2605 (setq out (nconc (gnus-compress-sequence ilist t) out))))
2606 (setq highest (or (and (atom (car ranges)) (car ranges))
2607 (cdr (car ranges))))
2608 (while (and list (<= (car list) highest))
2609 (setq list (cdr list)))
2610 (setq ranges (cdr ranges)))
2612 (setq out (nconc (gnus-compress-sequence list t) out)))
2613 (setq out (sort out (lambda (r1 r2)
2614 (< (or (and (atom r1) r1) (car r1))
2615 (or (and (atom r2) r2) (car r2))))))
2618 (if (atom (car ranges))
2620 (if (atom (car (cdr ranges)))
2621 (if (= (1+ (car ranges)) (car (cdr ranges)))
2623 (setcar ranges (cons (car ranges)
2624 (car (cdr ranges))))
2625 (setcdr ranges (cdr (cdr ranges)))))
2626 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
2628 (setcar (car (cdr ranges)) (car ranges))
2629 (setcar ranges (car (cdr ranges)))
2630 (setcdr ranges (cdr (cdr ranges)))))))
2632 (if (atom (car (cdr ranges)))
2633 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
2635 (setcdr (car ranges) (car (cdr ranges)))
2636 (setcdr ranges (cdr (cdr ranges)))))
2637 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
2639 (setcdr (car ranges) (cdr (car (cdr ranges))))
2640 (setcdr ranges (cdr (cdr ranges))))))))
2641 (setq ranges (cdr ranges)))
2644 (defun gnus-add-to-range-new (ranges list)
2645 (gnus-compress-sequence
2646 (sort (nconc (gnus-uncompress-range ranges) list) '<)))
2648 (defun gnus-add-to-range-old (ranges list)
2649 "Return a list of ranges that has all articles from both RANGES and LIST.
2650 Note: LIST has to be sorted over `<'."
2651 (let* ((ranges (if (and ranges (not (listp (cdr ranges))))
2652 (list ranges) ranges))
2655 range nranges first last)
2659 (gnus-compress-sequence list t)
2661 (> (car (car ranges)) 1)
2664 (setq inrange (setq ranges (cons (cons 1 1) ranges)))))
2665 (while (and ranges list)
2666 (setq range (car ranges))
2667 (while (and list (>= (car list) (car range))
2668 (<= (car list) (cdr range)))
2669 (setq list (cdr list)))
2670 (while (and list (= (1- (car list)) (cdr range)))
2671 (setcdr range (car list))
2672 (setq list (cdr list)))
2673 (if (and list (and (> (car list) (cdr range))
2675 (< (car list) (car (car (cdr ranges))))))
2676 (setcdr ranges (cons (cons (car list) (car list)) (cdr ranges))))
2677 (setq ranges (cdr ranges)))
2678 (if (and list (not ranges))
2679 (setq inrange (nconc inrange (gnus-compress-sequence list t))))
2681 (if (eq (cdr (car inrange)) 1)
2682 (setq inrange (cdr inrange))
2683 (setcar (car inrange) 2)))
2684 (setq ranges inrange)
2686 (if (and (cdr ranges) (>= (1+ (cdr (car ranges)))
2687 (car (car (cdr ranges)))))
2689 (setcdr (car ranges) (cdr (car (cdr ranges))))
2690 (setcdr ranges (cdr (cdr ranges))))
2691 (setq ranges (cdr ranges))))
2692 (if (not (cdr inrange))
2696 (defun gnus-remove-from-range (ranges list)
2697 "Return a list of ranges that has all articles from LIST removed from RANGES.
2698 Note: LIST has to be sorted over `<'."
2699 ;; !!! This function shouldn't look like this, but I've got a headache.
2700 (gnus-compress-sequence
2701 (gnus-sorted-complement
2702 (gnus-uncompress-range ranges) list)))
2704 (defun gnus-member-of-range (number ranges)
2705 (if (not (listp (cdr ranges)))
2706 (and (>= number (car ranges))
2707 (<= number (cdr ranges)))
2710 (if (numberp (car ranges))
2711 (>= number (car ranges))
2712 (>= number (car (car ranges))))
2714 (if (if (numberp (car ranges))
2715 (= number (car ranges))
2716 (and (>= number (car (car ranges)))
2717 (<= number (cdr (car ranges)))))
2718 (setq not-stop nil))
2719 (setq ranges (cdr ranges)))
2727 (defvar gnus-group-mode-map nil)
2728 (defvar gnus-group-make-map nil)
2729 (defvar gnus-group-list-map nil)
2730 (defvar gnus-group-sub-map nil)
2731 (put 'gnus-group-mode 'mode-class 'special)
2733 (if gnus-group-mode-map
2735 (setq gnus-group-mode-map (make-keymap))
2736 (suppress-keymap gnus-group-mode-map)
2737 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
2738 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
2739 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
2740 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
2741 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
2742 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
2743 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
2744 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
2745 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
2746 (define-key gnus-group-mode-map "\M-n" 'gnus-group-next-unread-group-same-level)
2747 (define-key gnus-group-mode-map "\M-p" 'gnus-group-prev-unread-group-same-level)
2748 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
2749 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
2750 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
2751 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
2752 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
2753 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
2754 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
2755 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
2756 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
2757 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
2758 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
2759 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
2760 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
2761 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
2762 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
2763 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
2764 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
2765 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
2766 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
2767 (define-key gnus-group-mode-map "\C-c\M-C-a" 'gnus-group-description-apropos)
2768 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
2769 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
2770 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
2771 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
2772 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
2773 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
2774 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
2775 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
2776 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
2777 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
2778 (define-key gnus-group-mode-map "V" 'gnus-version)
2779 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
2780 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
2781 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
2782 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
2783 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
2784 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
2785 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
2786 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
2787 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group)
2788 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
2789 (define-key gnus-group-mode-map
2790 (if gnus-xemacs [button2] [mouse-2]) 'gnus-mouse-pick-group)
2792 (define-prefix-command 'gnus-group-make-map)
2793 (define-key gnus-group-mode-map "M" 'gnus-group-make-map)
2794 (define-key gnus-group-make-map "d" 'gnus-group-make-directory-group)
2795 (define-key gnus-group-make-map "h" 'gnus-group-make-help-group)
2796 (define-key gnus-group-make-map "a" 'gnus-group-make-archive-group)
2797 (define-key gnus-group-make-map "k" 'gnus-group-make-kiboze-group)
2798 (define-key gnus-group-make-map "m" 'gnus-group-make-group)
2799 (define-key gnus-group-make-map "e" 'gnus-group-edit-group)
2801 (define-prefix-command 'gnus-group-list-map)
2802 (define-key gnus-group-mode-map "G" 'gnus-group-list-map)
2803 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
2804 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
2805 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
2806 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
2807 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
2808 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
2809 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
2810 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
2812 (define-prefix-command 'gnus-group-sub-map)
2813 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
2814 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
2815 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
2816 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
2817 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
2818 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
2819 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
2820 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
2822 (defun gnus-group-mode ()
2823 "Major mode for reading news.
2825 All normal editing commands are switched off.
2826 \\<gnus-group-mode-map>
2827 The group buffer lists (some of) the groups available. For instance,
2828 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
2829 lists all zombie groups.
2831 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
2832 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
2834 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
2836 The following commands are available:
2838 \\{gnus-group-mode-map}"
2840 (if gnus-visual (gnus-group-make-menu-bar))
2841 (kill-all-local-variables)
2842 (setq mode-line-modified "-- ")
2843 (make-local-variable 'mode-line-format)
2844 (setq mode-line-format (copy-sequence mode-line-format))
2845 (and (equal (nth 3 mode-line-format) " ")
2846 (setcar (nthcdr 3 mode-line-format) ""))
2847 (setq major-mode 'gnus-group-mode)
2848 (setq mode-name "Group")
2849 (gnus-group-set-mode-line)
2850 (setq mode-line-process nil)
2851 (use-local-map gnus-group-mode-map)
2852 (buffer-disable-undo (current-buffer))
2853 (setq truncate-lines t)
2854 (setq buffer-read-only t)
2855 (run-hooks 'gnus-group-mode-hook))
2857 (defun gnus-mouse-pick-group (e)
2860 (gnus-group-read-group nil))
2863 (defun gnus-no-server (&optional arg)
2865 If ARG is a positive number, Gnus will use that as the
2866 startup level. If ARG is nil, Gnus will be started at level 2.
2867 If ARG is non-nil and not a positive number, Gnus will
2868 prompt the user for the name of an NNTP server to use.
2869 As opposed to `gnus', this command will not connect to the local server."
2871 (gnus (or arg 2) t))
2873 (defalias '\(ding\) 'gnus)
2876 (defun gnus (&optional arg dont-connect)
2878 If ARG is non-nil and a positive number, Gnus will use that as the
2879 startup level. If ARG is non-nil and not a positive number, Gnus will
2880 prompt the user for the name of an NNTP server to use."
2882 (if (get-buffer gnus-group-buffer)
2884 (switch-to-buffer gnus-group-buffer)
2885 (gnus-group-get-new-news))
2887 (gnus-read-init-file)
2888 (let ((level (and arg (numberp arg) (> arg 0) arg))
2892 (switch-to-buffer (get-buffer-create gnus-group-buffer))
2893 (gnus-add-current-to-buffer-list)
2897 (gnus-start-news-server (and arg (not level))))))
2898 (if (and (not dont-connect)
2901 (run-hooks 'gnus-startup-hook)
2902 ;; NNTP server is successfully open.
2903 (gnus-update-format-specifications)
2904 (let ((buffer-read-only nil))
2906 (if (not gnus-inhibit-startup-message)
2908 (gnus-group-startup-message)
2910 (gnus-setup-news nil level)
2911 (and gnus-use-dribble-file (gnus-dribble-open))
2912 (or t (not gnus-novice-user)
2914 (gnus-group-describe-briefly)) ;Show brief help message.
2915 (gnus-group-list-groups level))))))
2917 (defun gnus-group-startup-message (&optional x y)
2918 "Insert startup message in current buffer."
2919 ;; Insert the message.
2936 ;; And then hack it.
2937 ;; 18 is the longest line.
2938 (indent-rigidly (point-min) (point-max)
2939 (/ (max (- (window-width) (or x 28)) 0) 2))
2940 (goto-char (point-min))
2941 ;; +4 is fuzzy factor.
2942 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2)))
2944 (defun gnus-group-setup-buffer ()
2945 (or (get-buffer gnus-group-buffer)
2947 (switch-to-buffer (get-buffer-create gnus-group-buffer))
2948 (gnus-add-current-to-buffer-list)
2949 (gnus-group-mode))))
2951 (defun gnus-group-list-groups (level &optional unread)
2952 "List newsgroups with level LEVEL or lower that have unread alticles.
2953 Default is 5, which lists all subscribed groups.
2954 If argument UNREAD is non-nil, groups with no unread articles are also listed."
2956 (setq level (or level gnus-group-default-list-level 5))
2957 (gnus-group-setup-buffer) ;May call from out of group buffer
2958 (let ((case-fold-search nil)
2959 (group (gnus-group-group-name)))
2960 (funcall gnus-group-prepare-function level unread nil)
2961 (if (zerop (buffer-size))
2962 (message gnus-no-groups-message)
2963 (goto-char (point-min))
2965 ;; Go to the first group with unread articles.
2966 (gnus-group-search-forward nil nil nil t)
2967 ;; Find the right group to put point on. If the current group
2968 ;; has disapeared in the new listing, try to find the next
2969 ;; one. If no next one can be found, just leave point at the
2970 ;; first newsgroup in the buffer.
2971 (if (not (gnus-goto-char
2972 (text-property-any (point-min) (point-max)
2973 'gnus-group (intern group))))
2974 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
2976 (not (gnus-goto-char
2978 (point-min) (point-max) 'gnus-group
2979 (intern (car (car newsrc)))))))
2980 (setq newsrc (cdr newsrc)))
2981 (or newsrc (progn (goto-char (point-max))
2982 (forward-line -1))))))
2983 ;; Adjust cursor point.
2984 (gnus-group-position-cursor))))
2986 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
2987 "List all newsgroups with unread articles of level LEVEL or lower.
2988 If ALL is non-nil, list groups that have no unread articles.
2989 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
2990 If REGEXP, only list groups matching REGEXP."
2991 (set-buffer gnus-group-buffer)
2992 (let ((buffer-read-only nil)
2993 (newsrc (cdr gnus-newsrc-assoc))
2994 (lowest (or lowest 1))
2995 info clevel unread group)
2998 ;; List living groups.
3000 (setq info (car newsrc)
3003 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3004 (and unread ; This group might be bogus
3006 (string-match regexp group))
3007 (<= (setq clevel (car (cdr info))) level)
3009 (or all ; We list all groups?
3010 (eq unread t) ; We list unactivated groups
3011 (> unread 0) ; We list groups with unread articles
3012 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
3013 (gnus-group-insert-group-line
3014 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
3016 ;; List dead groups.
3017 (and (>= level 8) (<= lowest 8)
3018 (gnus-group-prepare-flat-list-dead
3019 (setq gnus-zombie-list (sort gnus-zombie-list 'string<)) 8 ?Z
3021 (and (>= level 9) (<= lowest 9)
3022 (gnus-group-prepare-flat-list-dead
3023 (setq gnus-killed-list (sort gnus-killed-list 'string<)) 9 ?K
3026 (gnus-group-set-mode-line)
3027 (setq gnus-have-all-newsgroups all)
3028 (run-hooks 'gnus-group-prepare-hook)))
3030 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
3031 ;; List zombies and killed lists somehwat faster, which was
3032 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3033 ;; this by ignoring the group format specification altogether.
3036 (setq group (car groups)
3037 groups (cdr groups))
3038 (if (or (not regexp)
3039 (string-match regexp group))
3042 (insert (format " %c *: %s\n" mark group))
3043 (add-text-properties
3045 (list 'gnus-group (intern group)
3047 'gnus-level level)))))))
3049 (defun gnus-group-real-name (group)
3050 "Find the real name of a foreign newsgroup."
3051 (if (string-match "^[^:]+:" group)
3052 (substring group (match-end 0))
3055 (defun gnus-group-prefixed-name (group method)
3056 "Return the whole name from GROUP and METHOD."
3057 (and (stringp method) (setq method (gnus-server-to-method method)))
3058 (concat (format "%s" (car method))
3060 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3061 (not (string= (nth 1 method) "")))
3062 (concat "+" (nth 1 method)))
3065 (defun gnus-group-real-prefix (group)
3066 "Return the prefix of the current group name."
3067 (if (string-match "^[^:]+:" group)
3068 (substring group 0 (match-end 0))
3071 (defun gnus-group-method-name (group)
3072 "Return the method used for selecting GROUP."
3073 (let ((prefix (gnus-group-real-prefix group)))
3074 (if (equal prefix "")
3076 (if (string-match "^[^\\+]+\\+" prefix)
3077 (list (intern (substring prefix 0 (1- (match-end 0))))
3078 (substring prefix (match-end 0) (1- (length prefix))))
3079 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3081 (defun gnus-group-foreign-p (group)
3082 "Return nil if GROUP is native, non-nil if it is foreign."
3083 (string-match ":" group))
3085 (defun gnus-group-set-info (info)
3086 (let ((entry (gnus-gethash (car info) gnus-newsrc-hashtb)))
3088 (if (not (setq marked (nth 3 info)))
3091 (or (eq 'score (car (car marked)))
3092 (eq 'bookmark (car (car marked)))
3093 (eq 'killed (car (car marked)))
3094 (setcdr (car marked)
3095 (gnus-uncompress-range (cdr (car marked)))))
3096 (setq marked (cdr marked)))))
3100 (set-buffer gnus-group-buffer)
3102 (gnus-group-make-group
3103 (gnus-group-real-name (car info))
3104 (prin1-to-string (car (nth 4 info)))
3105 (nth 1 (nth 4 info)))
3106 (gnus-group-make-group
3108 (prin1-to-string (car gnus-select-method))
3109 (nth 1 gnus-select-method)))
3110 (message "Note: New group created")
3112 (gnus-gethash (gnus-group-prefixed-name
3113 (gnus-group-real-name (car info))
3114 (or (nth 4 info) gnus-select-method))
3115 gnus-newsrc-hashtb))))
3118 (setcar (nthcdr 2 entry) info)
3119 (if (and (not (eq (car entry) t))
3120 (gnus-gethash (car info) gnus-active-hashtb))
3121 (let ((marked (nth 3 info)))
3123 (max 0 (- (length (gnus-list-of-unread-articles
3125 (length (cdr (assq 'tick marked)))
3126 (length (cdr (assq 'dormant marked)))))))))
3127 (error "No such group: %s" (car info)))))
3129 (defun gnus-group-update-group-line ()
3130 "This function updates the current line in the newsgroup buffer and
3131 moves the point to the colon."
3132 (let* ((buffer-read-only nil)
3133 (group (gnus-group-group-name))
3134 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3137 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3140 (delete-region (point) (progn (forward-line 1) (point)))
3141 (gnus-group-insert-group-line-info group)
3143 (gnus-group-position-cursor)))
3145 (defun gnus-group-insert-group-line-info (group)
3146 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3150 (setq info (nth 2 entry))
3151 (gnus-group-insert-group-line
3152 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3153 (setq active (gnus-gethash group gnus-active-hashtb))
3154 (gnus-group-insert-group-line
3155 nil group (if (member group gnus-zombie-list) 8 9)
3156 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3158 (defun gnus-group-insert-group-line (gformat group level marked number method)
3159 (let* ((gformat (or gformat gnus-group-line-format-spec))
3160 (active (gnus-gethash group gnus-active-hashtb))
3161 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3162 (number-of-dormant (length (cdr (assq 'dormant marked))))
3163 (number-of-ticked (length (cdr (assq 'tick marked))))
3164 (number-of-ticked-and-dormant
3165 (+ number-of-ticked number-of-dormant))
3166 (number-of-unread-unticked
3167 (if (numberp number) (int-to-string (max 0 number))
3170 (if (numberp number)
3171 (max 0 (- number-total number))
3173 (subscribed (cond ((< level 6) ? )
3177 (qualified-group (gnus-group-real-name group))
3178 (newsgroup-description
3179 (if gnus-description-hashtb
3180 (or (gnus-gethash group gnus-description-hashtb) "")
3182 (moderated (if (member group gnus-moderated-list) ?m ? ))
3183 (moderated-string (if (eq moderated ?m) "(m)" ""))
3184 (method (gnus-server-get-method group method))
3185 (news-server (or (car (cdr method)) ""))
3186 (news-method (or (car method) ""))
3188 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3192 (> number-of-ticked 0))
3194 (number (if (eq number t) "*" (+ number number-of-dormant
3196 (buffer-read-only nil)
3201 (insert (eval gformat))
3203 (add-text-properties
3204 b (1+ b) (list 'gnus-group (intern group)
3205 'gnus-unread (if (numberp number)
3206 (string-to-int number-of-unread-unticked)
3209 'gnus-level level))))
3211 (defun gnus-group-update-group (group &optional visible-only)
3212 "Update newsgroup info of GROUP.
3213 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3215 (set-buffer gnus-group-buffer)
3216 (let ((buffer-read-only nil)
3218 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3221 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3223 ;; Buffer may be narrowed.
3226 ;; Search a line to modify. If the buffer is large, the search
3227 ;; takes long time. In most cases, current point is on the line
3228 ;; we are looking for. So, first of all, check current line.
3231 (eq (get-text-property (point) 'gnus-group)
3236 (point-min) (point-max) 'gnus-group (intern group)))))
3237 ;; GROUP is listed in current buffer. So, delete old line.
3241 (delete-region (point) (progn (forward-line 1) (point))))
3242 ;; No such line in the buffer, find out where it's supposed to
3243 ;; go, and insert it there (or at the end of the buffer).
3244 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3246 (let ((entry (cdr (gnus-gethash group gnus-newsrc-hashtb))))
3251 (point-min) (point-max)
3252 'gnus-group (intern (car (car entry)))))))
3253 (setq entry (cdr entry)))
3254 (or entry (goto-char (point-max)))))))
3255 (if (or visible (not visible-only))
3256 (gnus-group-insert-group-line-info group))
3257 (gnus-group-set-mode-line))))
3259 (defun gnus-group-set-mode-line ()
3260 (if (memq 'group gnus-updated-mode-lines)
3261 (let* ((gformat (or gnus-group-mode-line-format-spec
3262 (setq gnus-group-mode-line-format-spec
3264 gnus-group-mode-line-format
3265 gnus-group-mode-line-format-alist))))
3266 (news-server (car (cdr gnus-select-method)))
3267 (news-method (car gnus-select-method))
3268 (mode-string (eval gformat))
3270 (if (> (length mode-string) max-len)
3271 (setq mode-string (substring mode-string 0 (- max-len 4))))
3272 (setq mode-line-buffer-identification mode-string)
3273 (set-buffer-modified-p t))))
3275 (defun gnus-group-group-name ()
3276 "Get the name of the newsgroup on the current line."
3277 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
3278 (and group (symbol-name group))))
3280 (defun gnus-group-group-level ()
3281 "Get the level of the newsgroup on the current line."
3282 (get-text-property (gnus-point-at-bol) 'gnus-level))
3284 (defun gnus-group-search-forward (&optional backward all level first-too)
3285 "Find the next newsgroup with unread articles.
3286 If BACKWARD is non-nil, find the previous newsgroup instead.
3287 If ALL is non-nil, just find any newsgroup.
3288 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3290 If FIRST-TOO, the current line is also eligeble as a target."
3291 (let ((way (if backward -1 1))
3295 (or first-too (forward-line way))
3303 (get-text-property (point) 'gnus-unread)))
3304 (or (eq unread t) (and unread (> unread 0))))
3305 (let ((lev (get-text-property (point) 'gnus-level)))
3306 (and lev (< (get-text-property (point) 'gnus-level) 6)))))
3308 (let ((lev (get-text-property (point) 'gnus-level)))
3309 (if (and lev (<= lev level))
3314 (setq pos (point))))
3316 (zerop (forward-line way))))
3318 (progn (gnus-group-position-cursor) t)
3319 (if pos (goto-char pos) (goto-char beg))
3322 ;; Gnus group mode commands
3324 (defun gnus-group-read-group (all &optional no-article group)
3325 "Read news in this newsgroup.
3326 If argument ALL is non-nil, already read articles become readable.
3327 If optional argument NO-ARTICLE is non-nil, no article body is displayed."
3329 (let ((group (or group (gnus-group-group-name)))
3330 number active marked entry)
3331 (or group (error "No group on current line"))
3333 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3334 ;; This group might be a dead group. In that case we have to get
3335 ;; the number of unread articles from `gnus-active-hashtb'.
3337 (setq number (car entry))
3338 (if (setq active (gnus-gethash group gnus-active-hashtb))
3339 (setq number (- (1+ (cdr active)) (car active)))))
3340 (gnus-summary-read-group
3341 group (or all (and (numberp number)
3342 (zerop (+ number (length (cdr (assq 'tick marked)))
3343 (length (cdr (assq 'dormant marked)))))))
3346 (defun gnus-group-select-group (all)
3347 "Select this newsgroup.
3348 No article is selected automatically.
3349 If argument ALL is non-nil, already read articles become readable."
3351 (gnus-group-read-group all t))
3353 (defun gnus-group-jump-to-group (group)
3354 "Jump to newsgroup GROUP."
3355 (interactive (list (completing-read "Group: " gnus-active-hashtb nil
3356 (not (not gnus-read-active-file)))))
3358 (if (equal group "")
3359 (error "empty group name"))
3361 (let ((b (text-property-any (point-min) (point-max)
3362 'gnus-group (intern group))))
3364 ;; Either go to the line in the group buffer...
3366 ;; ... or insert the line.
3368 (gnus-gethash group gnus-active-hashtb)
3369 (gnus-activate-newsgroup group)
3370 (error "%s error: %s" group (gnus-status-message group)))
3372 (gnus-group-update-group group)
3373 (goto-char (text-property-any (point-min) (point-max)
3374 'gnus-group (intern group)))))
3375 ;; Adjust cursor point.
3376 (gnus-group-position-cursor))
3378 (defun gnus-group-next-group (n)
3379 "Go to next N'th newsgroup.
3380 If N is negative, search backward instead.
3381 Returns the difference between N and the number of skips actually
3384 (gnus-group-next-unread-group n t))
3386 (defun gnus-group-next-unread-group (n &optional all level)
3387 "Go to next N'th unread newsgroup.
3388 If N is negative, search backward instead.
3389 If ALL is non-nil, choose any newsgroup, unread or not.
3390 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
3391 such group can be found, the next group with a level higher than
3393 Returns the difference between N and the number of skips actually
3396 (let ((backward (< n 0))
3399 (gnus-group-search-forward backward all level))
3401 (if (/= 0 n) (message "No more%s newsgroups%s" (if all "" " unread")
3402 (if level " on this level or higher" "")))
3405 (defun gnus-group-prev-group (n)
3406 "Go to previous N'th newsgroup.
3407 Returns the difference between N and the number of skips actually
3410 (gnus-group-next-unread-group (- n) t))
3412 (defun gnus-group-prev-unread-group (n)
3413 "Go to previous N'th unread newsgroup.
3414 Returns the difference between N and the number of skips actually
3417 (gnus-group-next-unread-group (- n)))
3419 (defun gnus-group-next-unread-group-same-level (n)
3420 "Go to next N'th unread newsgroup on the same level.
3421 If N is negative, search backward instead.
3422 Returns the difference between N and the number of skips actually
3425 (gnus-group-next-unread-group n t (gnus-group-group-level))
3426 (gnus-group-position-cursor))
3428 (defun gnus-group-prev-unread-group-same-level (n)
3429 "Go to next N'th unread newsgroup on the same level.
3430 Returns the difference between N and the number of skips actually
3433 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
3434 (gnus-group-position-cursor))
3436 (defun gnus-group-best-unread-group (&optional exclude-group)
3437 "Go to the group with the highest level.
3438 If EXCLUDE-GROUP, do not go to that group."
3440 (goto-char (point-min))
3443 (while (setq unread (get-text-property (point) 'gnus-unread))
3444 (if (and (numberp unread) (> unread 0))
3446 (or best-point (setq best-point (point)))
3447 (if (and (< (get-text-property (point) 'gnus-level) best)
3448 (or (not exclude-group)
3449 (not (equal exclude-group (gnus-group-group-name)))))
3451 (setq best (get-text-property (point) 'gnus-level))
3452 (setq best-point (point))))))
3454 (if best-point (goto-char best-point))
3455 (gnus-summary-position-cursor)
3456 (and best-point (gnus-group-group-name))))
3458 (defun gnus-group-first-unread-group ()
3459 "Go to the first group with unread articles."
3461 (goto-char (point-min))
3462 (gnus-group-next-unread-group 1))
3464 (defun gnus-group-enter-server-mode ()
3465 "Jump to the server buffer."
3467 (gnus-server-setup-buffer)
3468 (switch-to-buffer gnus-server-buffer)
3469 (gnus-server-prepare))
3471 (defun gnus-group-make-group (name method address)
3472 "Add a new newsgroup.
3473 The user will be prompted for a NAME, for a select METHOD, and an
3477 (read-string "Group name: ")
3480 "Method: " (append gnus-valid-select-methods gnus-server-alist)
3482 (if (assoc method gnus-valid-select-methods)
3484 (if (memq 'prompt-address
3485 (assoc method gnus-valid-select-methods))
3486 (read-string "Address: ")
3488 (list method nil)))))
3490 (let* ((meth (if address (list (intern method) address) method))
3491 (nname (gnus-group-prefixed-name name meth))
3493 (and (gnus-gethash nname gnus-active-hashtb)
3494 (error "Group %s already exists" nname))
3495 (gnus-group-change-level
3496 (setq info (list t nname 3 nil nil meth))
3497 3 9 (gnus-gethash (or (gnus-group-group-name) "dummy.group")
3498 gnus-newsrc-hashtb) t)
3499 (gnus-sethash nname '(0 . 0) gnus-active-hashtb)
3501 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
3502 (gnus-group-insert-group-line-info nname)
3504 (and (gnus-check-backend-function 'request-create-group nname)
3505 (gnus-request-create-group nname))))
3507 (defun gnus-group-edit-group (group)
3508 "Edit the group on the current line."
3509 (interactive (list (gnus-group-group-name)))
3511 (if group (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
3512 (error "No group on current line"))
3513 (setq gnus-winconf-edit-group (current-window-configuration))
3514 (pop-to-buffer (get-buffer-create gnus-group-edit-buffer))
3515 (gnus-add-current-to-buffer-list)
3517 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3518 (use-local-map (copy-keymap emacs-lisp-mode-map))
3519 (local-set-key "\C-c\C-c" 'gnus-group-edit-group-done)
3521 (insert ";; Type `C-c C-c' after you have edited the newsgroup entry.\n\n")
3522 (let ((cinfo (gnus-copy-sequence info))
3524 (if (not (setq marked (nth 3 cinfo)))
3527 (or (eq 'score (car (car marked)))
3528 (eq 'bookmark (car (car marked)))
3529 (eq 'killed (car (car marked)))
3530 (setcdr (car marked)
3531 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
3532 (setq marked (cdr marked))))
3533 (insert (pp-to-string (list 'gnus-group-set-info
3534 (list 'quote cinfo)))))))
3536 (defun gnus-group-edit-group-done ()
3538 (set-buffer (get-buffer-create gnus-group-edit-buffer))
3539 (eval-current-buffer)
3540 (kill-buffer (current-buffer))
3541 (and gnus-winconf-edit-group
3542 (set-window-configuration gnus-winconf-edit-group))
3543 (setq gnus-winconf-edit-group nil)
3544 (set-buffer gnus-group-buffer)
3545 (gnus-group-update-group (gnus-group-group-name))
3546 (gnus-group-position-cursor))
3548 (defun gnus-group-make-help-group ()
3549 "Create the (ding) Gnus documentation group."
3551 (and (gnus-gethash (gnus-group-prefixed-name "gnus-help" '(nndoc ""))
3553 (error "Documentation group already exists"))
3554 (let ((path load-path))
3556 (not (file-exists-p (concat (file-name-as-directory (car path))
3558 (setq path (cdr path)))
3559 (or path (error "Couldn't find doc group"))
3560 (gnus-group-make-group
3562 (concat (file-name-as-directory (car path)) "doc.txt"))
3563 (gnus-group-position-cursor)))
3565 (defun gnus-group-make-archive-group ()
3566 "Create the (ding) Gnus archive group."
3568 (and (gnus-gethash (gnus-group-prefixed-name "ding.archives" '(nndir ""))
3570 (error "Archive group already exists"))
3571 (gnus-group-make-group "ding.archives" "nndir" gnus-group-archive-directory)
3572 (gnus-group-position-cursor))
3574 (defun gnus-group-make-directory-group (dir)
3575 "Create an nndir group.
3576 The user will be prompted for a directory. The contents of this
3577 directory will be used as a newsgroup. The directory should contain
3578 mail messages or news articles in files that have numeric names."
3580 (list (read-file-name "Create group from directory: ")))
3581 (or (file-exists-p dir) (error "No such directory"))
3582 (or (file-directory-p dir) (error "Not a directory"))
3583 (gnus-group-make-group dir "nndir" dir)
3584 (gnus-group-position-cursor))
3586 (defun gnus-group-make-kiboze-group (group address scores)
3587 "Create an nnkiboze group.
3588 The user will be prompted for a name, a regexp to match groups, and
3589 score file entries for articles to include in the group."
3592 (read-string "nnkiboze group name: ")
3593 (read-string "Source groups (regexp): ")
3594 (let ((headers (mapcar (lambda (group) (list group))
3595 '("subject" "from" "number" "date" "message-id"
3596 "references" "chars" "lines" "xref")))
3597 scores header regexp regexps)
3598 (while (not (equal "" (setq header (completing-read
3599 "Match on header: " headers nil t))))
3601 (while (not (equal "" (setq regexp (read-string
3602 (format "Match on %s (string): "
3604 (setq regexps (cons (list regexp nil 1000 nil) regexps)))
3605 (setq scores (cons (cons header regexps) scores)))
3607 (gnus-group-make-group group "nnkiboze" address)
3609 (set-buffer (get-buffer-create " *gnus work*"))
3610 (buffer-disable-undo (current-buffer))
3611 (let (emacs-lisp-mode-hook)
3612 (pp (list 'setq 'gnus-score-alist
3613 (list 'quote (list scores)))
3615 (write-region (point-min) (point-max)
3616 (concat (or gnus-kill-files-directory "~/News")
3617 "nnkiboze:" group "." gnus-score-file-suffix))
3618 (kill-buffer (current-buffer)))
3619 (gnus-group-position-cursor))
3621 ;; Group sorting commands
3622 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
3624 (defun gnus-group-sort-groups ()
3625 "Sort the group buffer using `gnus-group-sort-function'."
3627 (setq gnus-newsrc-assoc
3628 (sort (cdr gnus-newsrc-assoc) gnus-group-sort-function))
3629 (gnus-make-hashtable-from-newsrc-alist)
3630 (gnus-get-unread-articles 6)
3631 (gnus-group-list-groups nil))
3633 (defun gnus-group-sort-by-alphabet (info1 info2)
3634 (string< (car info1) (car info2)))
3636 (defun gnus-group-sort-by-unread (info1 info2)
3637 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
3638 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
3639 (< (or (and (numberp n1) n1) 0)
3640 (or (and (numberp n2) n2) 0))))
3642 (defun gnus-group-sort-by-level (info1 info2)
3643 (< (nth 1 info1) (nth 1 info2)))
3645 ;; Group catching up.
3647 (defun gnus-group-catchup-current (n &optional all)
3648 "Mark all articles not marked as unread in current newsgroup as read.
3649 If prefix argument N is numeric, the ARG next newsgroups will be
3650 caught up. If ALL is non-nil, marked articles will also be marked as
3651 read. Cross references (Xref: header) of articles are ignored.
3652 The difference between N and actual number of newsgroups that were
3653 caught up is returned."
3655 (if (or (not gnus-interactive-catchup) ;Without confirmation?
3659 "Do you really want to mark all articles as read? "
3660 "Mark all unread articles as read? ")))
3666 (gnus-group-catchup (gnus-group-group-name) all)
3667 (gnus-group-update-group-line)
3669 (zerop (gnus-group-next-unread-group 1))))))
3672 (defun gnus-group-catchup-current-all (n)
3673 "Mark all articles in current newsgroup as read.
3674 Cross references (Xref: header) of articles are ignored."
3676 (gnus-group-catchup-current n 'all))
3678 (defun gnus-group-catchup (group &optional all)
3679 "Mark all articles in GROUP as read.
3680 If ALL is non-nil, all articles are marked as read.
3681 The return value is the number of articles that were marked as read,
3682 or nil if no action could be taken."
3683 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3685 (marked (nth 3 (nth 2 entry)))
3687 (if (not (numberp (car entry)))
3688 (message "Can't catch up; non-active group")
3689 ;; Do the updating only if the newsgroup isn't killed
3692 (setq ticked (if all nil (cdr (assq 'tick marked))))
3693 (gnus-update-read-articles group ticked nil ticked)
3694 (if (and all marked)
3695 (setcar (nthcdr 3 (nth 2 entry))
3696 (delq (assq 'dormant marked) marked))))))
3699 (defun gnus-group-expire-articles (newsgroup)
3700 "Expire all expirable articles in the current newsgroup."
3701 (interactive (list (gnus-group-group-name)))
3702 (if (not newsgroup) (error "No current newsgroup"))
3704 (assq 'expire (nth 3 (nth 2 (gnus-gethash newsgroup
3705 gnus-newsrc-hashtb))))))
3707 (gnus-check-backend-function 'request-expire-articles newsgroup)
3709 (gnus-request-expire-articles (cdr expirable) newsgroup)))))
3711 (defun gnus-group-expire-all-groups ()
3712 "Expire all expirable articles in all newsgroups."
3714 (message "Expiring...")
3715 (let ((newsrc (cdr gnus-newsrc-assoc)))
3717 (gnus-group-expire-articles (car (car newsrc)))
3718 (setq newsrc (cdr newsrc))))
3719 (message "Expiring...done"))
3721 (defun gnus-group-set-current-level (n)
3722 "Set the level of the current group to the numeric prefix."
3724 (setq n (or n (string-to-int
3727 (mapcar (lambda (n) (list (char-to-string n))) "123456789")
3729 (let ((group (gnus-group-group-name)))
3730 (if (not group) (error "No newsgroup on current line.")
3731 (if (and (numberp n) (>= n 1) (<= n 9))
3733 (message "Changed level of %s from %d to %d"
3734 group (gnus-group-group-level) n)
3735 (gnus-group-change-level group n (gnus-group-group-level))
3736 (gnus-group-update-group-line))
3737 (error "Illegal level: %s" n))))
3739 (gnus-group-position-cursor))
3741 (defun gnus-group-unsubscribe-current-group (arg)
3742 "Toggle subscribe from/to unsubscribe current group."
3744 (let ((group (gnus-group-group-name)))
3745 (or group (error "No newsgroup on current line"))
3746 (or arg (setq arg (if (<= (gnus-group-group-level) 5) 6 3)))
3747 (gnus-group-unsubscribe-group group arg)
3748 (gnus-group-next-group 1)))
3750 (defun gnus-group-unsubscribe-group (group &optional level)
3751 "Toggle subscribe from/to unsubscribe GROUP.
3752 New newsgroup is added to .newsrc automatically."
3754 (list (completing-read "Group: " gnus-active-hashtb nil
3755 gnus-have-read-active-file)))
3756 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
3758 ;; Toggle subscription flag.
3759 (gnus-group-change-level
3760 newsrc (if level level (if (< (nth 1 (nth 2 newsrc)) 6) 6 4)))
3761 (gnus-group-update-group group))
3762 ((and (stringp group)
3763 (or (not gnus-have-read-active-file)
3764 (gnus-gethash group gnus-active-hashtb)))
3765 ;; Add new newsgroup.
3766 (gnus-group-change-level
3769 (or (and (member group gnus-zombie-list) 8) 9)
3770 (or (and (gnus-group-group-name)
3771 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb))
3772 (gnus-gethash (car (car gnus-newsrc-assoc))
3773 gnus-newsrc-hashtb)))
3774 (gnus-group-update-group group))
3775 (t (error "No such newsgroup: %s" group)))
3776 (gnus-group-position-cursor)))
3778 (defun gnus-group-transpose-groups (arg)
3779 "Exchange current newsgroup and previous newsgroup.
3780 With argument ARG, takes previous newsgroup and moves it past ARG newsgroup."
3782 ;; BUG: last newsgroup and the last but one cannot be transposed
3783 ;; since gnus-group-search-forward does not move forward beyond the
3784 ;; last. If we instead use forward-line, no problem, but I don't
3785 ;; want to use it for later extension.
3787 (gnus-group-search-forward t t)
3788 (gnus-group-kill-group 1)
3789 (gnus-group-search-forward nil t)
3790 (gnus-group-yank-group)
3791 (gnus-group-search-forward nil t)
3792 (setq arg (1- arg))))
3794 (defun gnus-group-kill-all-zombies ()
3795 "Kill all zombie newsgroups."
3797 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
3798 (setq gnus-zombie-list nil)
3799 (funcall gnus-group-prepare-function 5 nil nil)
3800 (goto-char (point-min))
3801 (gnus-group-position-cursor))
3803 (defun gnus-group-kill-region (begin end)
3804 "Kill newsgroups in current region (excluding current point).
3805 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
3808 ;; Exclude a line where current point is on.
3822 (beginning-of-line) ;Important when LINES < 1
3823 (gnus-group-kill-group lines)))
3825 (defun gnus-group-kill-group (n)
3826 "The the next N groups.
3827 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
3828 However, only groups that were alive can be yanked; already killed
3829 groups or zombie groups can't be yanked.
3830 The return value is the name of the (last) newsgroup that was killed."
3832 (let ((buffer-read-only nil)
3834 (while (>= (setq n (1- n)) 0)
3835 (setq group (gnus-group-group-name))
3837 (signal 'end-of-buffer nil))
3838 (setq level (gnus-group-group-level))
3840 (delete-region (point) (progn (forward-line 1) (point)))
3841 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
3842 (setq gnus-list-of-killed-groups
3843 (cons (cons (car entry) (nth 2 entry))
3844 gnus-list-of-killed-groups)))
3845 (gnus-group-change-level (if entry entry group) 9 (if entry nil level)))
3848 (gnus-group-position-cursor)
3851 (defun gnus-group-yank-group (&optional arg)
3852 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
3853 inserting it before the current newsgroup. The numeric ARG specifies
3854 how many newsgroups are to be yanked. The name of the (last)
3855 newsgroup yanked is returned."
3857 (if (not arg) (setq arg 1))
3858 (let (info group prev)
3859 (while (>= (setq arg (1- arg)) 0)
3860 (if (not (setq info (car gnus-list-of-killed-groups)))
3861 (error "No more newsgroups to yank"))
3862 (setq group (nth 2 info))
3863 ;; Find which newsgroup to insert this one before - search
3864 ;; backward until something suitable is found. If there are no
3865 ;; other newsgroups in this buffer, just make this newsgroup the
3867 (while (and (not (setq prev (gnus-group-group-name)))
3868 (zerop (forward-line -1))))
3870 (setq prev (car (car gnus-newsrc-assoc))))
3871 (gnus-group-change-level
3873 (gnus-gethash prev gnus-newsrc-hashtb)
3875 (gnus-group-insert-group-line-info (nth 1 info))
3876 (setq gnus-list-of-killed-groups
3877 (cdr gnus-list-of-killed-groups)))
3879 (gnus-group-position-cursor)
3882 (defun gnus-group-list-all-groups (arg)
3883 "List all newsgroups with level ARG or lower.
3884 Default is 7, which lists all subscribed and most unsubscribed groups."
3886 (setq arg (or arg 7))
3887 (gnus-group-list-groups arg t))
3889 (defun gnus-group-list-killed ()
3890 "List all killed newsgroups in the group buffer."
3892 (if (not gnus-killed-list)
3893 (message "No killed groups")
3894 (funcall gnus-group-prepare-function 9 t 9)
3895 (goto-char (point-min)))
3896 (gnus-group-position-cursor))
3898 (defun gnus-group-list-zombies ()
3899 "List all zombie newsgroups in the group buffer."
3901 (if (not gnus-zombie-list)
3902 (message "No zombie groups")
3903 (funcall gnus-group-prepare-function 8 t 8)
3904 (goto-char (point-min)))
3905 (gnus-group-position-cursor))
3907 (defun gnus-group-get-new-news (&optional arg)
3908 "Get newly arrived articles.
3909 If ARG is non-nil, it should be a number between one and nine to
3910 specify which levels you are interested in re-scanning."
3912 (run-hooks 'gnus-get-new-news-hook)
3913 (if (and gnus-read-active-file (not arg))
3915 (gnus-read-active-file)
3916 (gnus-get-unread-articles (or arg 6)))
3917 (let ((gnus-read-active-file nil))
3918 (gnus-get-unread-articles (or arg 6))))
3919 (gnus-group-list-groups
3920 (or gnus-group-always-list-unread arg 5) gnus-have-all-newsgroups))
3922 (defun gnus-group-get-new-news-this-group (n)
3923 "Check for newly arrived news in the current group (and the N-1 next groups).
3924 The difference between N and the number of newsgroup checked is returned.
3925 If N is negative, this group and the N-1 previous groups will be checked."
3927 (let ((way (if (< n 0) -1 1))
3929 (w-p (window-start))
3933 (or (gnus-get-new-news-in-group
3934 (setq group (gnus-group-group-name)))
3937 (message "%s error: %s"
3938 group (gnus-status-message group))))
3940 (zerop (gnus-group-next-group way)))
3942 (if (/= 0 n) (message "No more newsgroups"))
3943 ;; !!! I don't know why the buffer scrolls forward when updating
3944 ;; the first line in the group buffer, but it does. So we set the
3945 ;; window start forcibly.
3946 (set-window-start (get-buffer-window (current-buffer)) w-p)
3949 (defun gnus-get-new-news-in-group (group)
3951 (gnus-activate-newsgroup group)
3953 (gnus-get-unread-articles-in-group
3954 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
3955 (gnus-gethash group gnus-active-hashtb))
3956 (gnus-group-update-group-line)
3959 (defun gnus-group-fetch-faq (group)
3960 "Fetch the FAQ for the current group."
3961 (interactive (list (gnus-group-group-name)))
3962 (or group (error "No group name given"))
3963 (let ((file (concat gnus-group-faq-directory group)))
3964 (if (not (file-exists-p file))
3965 (error "No such file: %s" file)
3968 (defun gnus-group-describe-group (force &optional group)
3969 "Display a description of the current newsgroup."
3971 (and force (setq gnus-description-hashtb nil))
3972 (let ((group (or group (gnus-group-group-name)))
3974 (or group (message "No group name given"))
3975 (and (or gnus-description-hashtb
3976 (setq desc (gnus-group-get-description group))
3977 (gnus-read-descriptions-file))
3979 (or desc (gnus-gethash group gnus-description-hashtb)
3980 "No description available")))))
3982 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
3983 (defun gnus-group-describe-all-groups (force)
3984 "Pop up a buffer with descriptons of all newsgroups."
3986 (and force (setq gnus-description-hashtb nil))
3987 (if (not (or gnus-description-hashtb
3988 (gnus-read-descriptions-file)))
3989 (error "Couldn't request descriptions file"))
3990 (let ((buffer-read-only nil)
3996 (insert (format " *: %-20s %s\n" (symbol-name group)
3997 (symbol-value group)))
3998 (add-text-properties
3999 b (1+ b) (list 'gnus-group group
4000 'gnus-unread t 'gnus-marked nil 'gnus-level 6)))
4001 gnus-description-hashtb)
4002 (goto-char (point-min))
4003 (gnus-group-position-cursor)))
4005 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
4006 (defun gnus-group-apropos (regexp &optional search-description)
4007 "List all newsgroups that have names that match a regexp."
4008 (interactive "sGnus apropos (regexp): ")
4010 (obuf (current-buffer))
4012 ;; Go through all newsgroups that are known to Gnus.
4015 (and (string-match regexp (symbol-name group))
4016 (setq groups (cons (symbol-name group) groups))))
4018 ;; Go through all descriptions that are known to Gnus.
4019 (if search-description
4022 (and (string-match regexp (symbol-value group))
4023 (gnus-gethash (symbol-name group) gnus-active-hashtb)
4024 (setq groups (cons (symbol-name group) groups))))
4025 gnus-description-hashtb))
4027 (message "No groups matched \"%s\"." regexp)
4028 ;; Print out all the groups.
4030 (pop-to-buffer (get-buffer-create "*Gnus Help*"))
4031 (buffer-disable-undo (current-buffer))
4033 (setq groups (sort groups 'string<))
4035 ;; Groups may be entered twice into the list of groups.
4036 (if (not (string= (car groups) prev))
4038 (insert (setq prev (car groups)) "\n")
4039 (if (and gnus-description-hashtb
4040 (setq des (gnus-gethash (car groups)
4041 gnus-description-hashtb)))
4042 (insert " " des "\n"))))
4043 (setq groups (cdr groups)))
4045 (pop-to-buffer obuf)))
4047 (defun gnus-group-description-apropos (regexp)
4048 "List all newsgroups that have names or desccriptions that match a regexp."
4049 (interactive "sGnus description apropos (regexp): ")
4050 (if (not (or gnus-description-hashtb
4051 (gnus-read-descriptions-file)))
4052 (error "Couldn't request descriptions file"))
4053 (gnus-group-apropos regexp t))
4055 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4056 (defun gnus-group-list-matching (level regexp &optional all lowest)
4057 "List all groups with unread articles that match REGEXP.
4058 If the prefix LEVEL is non-nil, it should be a number that says which
4059 level to cut off listing groups.
4060 If ALL, also list groups with no unread articles.
4061 If LOWEST, don't list groups with level lower than LOWEST."
4062 (interactive "P\nsList newsgroups matching: ")
4063 (gnus-group-prepare-flat (or level 5) all (or lowest 1) regexp)
4064 (goto-char (point-min))
4065 (gnus-group-position-cursor))
4067 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4068 "List all groups that match REGEXP.
4069 If the prefix LEVEL is non-nil, it should be a number that says which
4070 level to cut off listing groups.
4071 If LOWEST, don't list groups with level lower than LOWEST."
4072 (interactive "P\nsList newsgroups matching: ")
4073 (gnus-group-list-matching (or level 9) regexp t lowest))
4075 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4076 (defun gnus-group-save-newsrc ()
4077 "Save the Gnus startup files."
4079 (gnus-save-newsrc-file))
4081 (defun gnus-group-restart (&optional arg)
4082 "Force Gnus to read the .newsrc file."
4084 (gnus-save-newsrc-file)
4085 (gnus-setup-news 'force)
4086 (gnus-group-list-groups arg gnus-have-all-newsgroups))
4088 (defun gnus-group-read-init-file ()
4089 "Read the Gnus elisp init file."
4091 (gnus-read-init-file))
4093 (defun gnus-group-check-bogus-groups ()
4094 "Check bogus newsgroups."
4096 (gnus-check-bogus-newsgroups (not gnus-expert-user)) ;Require confirmation.
4097 (gnus-group-list-groups nil gnus-have-all-newsgroups))
4099 (defun gnus-group-mail ()
4100 "Start composing a mail."
4104 (defun gnus-group-edit-global-kill (article &optional group)
4105 "Edit the global kill file.
4106 If GROUP, edit that local kill file instead."
4108 (setq gnus-current-kill-article article)
4109 (gnus-kill-file-edit-file group)
4111 (substitute-command-keys
4112 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
4114 (defun gnus-group-edit-local-kill (article group)
4115 "Edit a local kill file."
4116 (interactive (list nil (gnus-group-group-name)))
4117 (gnus-group-edit-global-kill article group))
4119 (defun gnus-group-force-update ()
4120 "Update `.newsrc' file."
4122 (gnus-save-newsrc-file))
4124 (defun gnus-group-suspend ()
4125 "Suspend the current Gnus session.
4126 In fact, cleanup buffers except for group mode buffer.
4127 The hook gnus-suspend-gnus-hook is called before actually suspending."
4129 (run-hooks 'gnus-suspend-gnus-hook)
4130 ;; Kill Gnus buffers except for group mode buffer.
4131 (let ((group-buf (get-buffer gnus-group-buffer)))
4132 (while gnus-buffer-list
4133 (and (not (eq (get-buffer (car gnus-buffer-list)) group-buf))
4134 (not (eq (get-buffer (car gnus-buffer-list)) gnus-dribble-buffer))
4135 (get-buffer (car gnus-buffer-list))
4136 (buffer-name (get-buffer (car gnus-buffer-list)))
4137 (kill-buffer (car gnus-buffer-list)))
4138 (setq gnus-buffer-list (cdr gnus-buffer-list)))
4139 (setq gnus-buffer-list (list group-buf))
4140 (bury-buffer group-buf)
4141 (delete-windows-on group-buf t)))
4143 (defun gnus-group-clear-dribble ()
4144 "Clear all information from the dribble buffer."
4146 (gnus-dribble-clear))
4148 (defun gnus-group-exit ()
4149 "Quit reading news after updating .newsrc.eld and .newsrc.
4150 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4152 (if (or noninteractive ;For gnus-batch-kill
4153 (zerop (buffer-size)) ;No news is good news.
4154 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
4155 (not gnus-interactive-exit) ;Without confirmation
4157 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4159 (run-hooks 'gnus-exit-gnus-hook)
4160 (gnus-save-newsrc-file)
4161 (gnus-close-backends)
4162 (gnus-clear-system))))
4164 (defun gnus-close-backends ()
4165 ;; Send a close request to all backends that support such a request.
4166 (let ((methods gnus-valid-select-methods)
4169 (if (fboundp (setq func (intern (concat (car (car methods))
4170 "-request-close"))))
4172 (setq methods (cdr methods)))))
4174 (defun gnus-group-quit ()
4175 "Quit reading news without updating .newsrc.eld or .newsrc.
4176 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4178 (if (or noninteractive ;For gnus-batch-kill
4179 (zerop (buffer-size))
4180 (not (gnus-server-opened gnus-select-method))
4182 (not gnus-current-startup-file)
4184 (format "Quit reading news without saving %s? "
4185 (file-name-nondirectory gnus-current-startup-file))))
4187 (run-hooks 'gnus-exit-gnus-hook)
4189 (gnus-close-backends)
4190 (gnus-clear-system))))
4192 (defun gnus-group-describe-briefly ()
4193 "Give a one line description of the group mode commands."
4196 (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")))
4198 (defun gnus-group-browse-foreign-server (method)
4199 "Browse a foreign news server.
4200 If called interactively, this function will ask for a select method
4201 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4202 If not, METHOD should be a list where the first element is the method
4203 and the second element is the address."
4205 (list (list (intern (completing-read
4207 gnus-valid-select-methods nil t "nntp"))
4208 ;; Suggested by mapjph@bath.ac.uk.
4211 (mapcar (lambda (server) (list server))
4212 gnus-secondary-servers)))))
4213 (gnus-browse-foreign-server method))
4217 ;;; Browse Server Mode
4220 (defvar gnus-browse-server-mode-hook nil)
4221 (defvar gnus-browse-server-mode-map nil)
4222 (put 'gnus-browse-server-mode 'mode-class 'special)
4224 (if gnus-browse-server-mode-map
4226 (setq gnus-browse-server-mode-map (make-keymap))
4227 (suppress-keymap gnus-browse-server-mode-map)
4228 (define-key gnus-browse-server-mode-map " " 'gnus-browse-read-group)
4229 (define-key gnus-browse-server-mode-map "=" 'gnus-browse-read-group)
4230 (define-key gnus-browse-server-mode-map "n" 'gnus-browse-next-group)
4231 (define-key gnus-browse-server-mode-map "p" 'gnus-browse-prev-group)
4232 (define-key gnus-browse-server-mode-map "\177" 'gnus-browse-prev-group)
4233 (define-key gnus-browse-server-mode-map "N" 'gnus-browse-next-group)
4234 (define-key gnus-browse-server-mode-map "P" 'gnus-browse-prev-group)
4235 (define-key gnus-browse-server-mode-map "\M-n" 'gnus-browse-next-group)
4236 (define-key gnus-browse-server-mode-map "\M-p" 'gnus-browse-prev-group)
4237 (define-key gnus-browse-server-mode-map "\r" 'gnus-browse-read-group)
4238 (define-key gnus-browse-server-mode-map "u" 'gnus-browse-unsubscribe-current-group)
4239 (define-key gnus-browse-server-mode-map "l" 'gnus-browse-exit)
4240 (define-key gnus-browse-server-mode-map "L" 'gnus-browse-exit)
4241 (define-key gnus-browse-server-mode-map "q" 'gnus-browse-exit)
4242 (define-key gnus-browse-server-mode-map "Q" 'gnus-browse-exit)
4243 (define-key gnus-browse-server-mode-map "\C-c\C-c" 'gnus-browse-exit)
4244 (define-key gnus-browse-server-mode-map "?" 'gnus-browse-describe-briefly)
4245 (define-key gnus-browse-server-mode-map "\C-c\C-i" 'gnus-info-find-node)
4248 (defvar gnus-browse-current-method nil)
4250 (defun gnus-browse-foreign-server (method)
4251 (setq gnus-browse-current-method method)
4252 (let ((gnus-select-method method)
4254 (message "Connecting to %s..." (nth 1 method))
4255 (or (gnus-server-opened method)
4256 (gnus-open-server method)
4257 (error "Unable to contact server: %s" (gnus-status-message method)))
4258 (or (gnus-request-list method)
4259 (error "Couldn't request list: %s" (gnus-status-message method)))
4260 (set-buffer (get-buffer-create "*Gnus Browse Server*"))
4261 (gnus-add-current-to-buffer-list)
4262 (buffer-disable-undo (current-buffer))
4263 (let ((buffer-read-only nil))
4265 (gnus-browse-server-mode)
4266 (setq mode-line-buffer-identification
4268 "(ding) Browse Server {%s:%s}" (car method) (car (cdr method))))
4270 (set-buffer nntp-server-buffer)
4271 (let ((cur (current-buffer)))
4273 (delete-matching-lines gnus-ignored-newsgroups)
4274 (while (re-search-forward
4275 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
4276 (goto-char (match-end 1))
4277 (setq groups (cons (cons (buffer-substring (match-beginning 1)
4279 (- (read cur) (read cur)))
4281 (setq groups (sort groups
4283 (string< (car l1) (car l2)))))
4284 (let ((buffer-read-only nil))
4286 (setq group (car groups))
4288 (format "K%7d: %s\n" (cdr group) (car group)))
4289 (setq groups (cdr groups))))
4290 (switch-to-buffer (current-buffer))
4292 (gnus-group-position-cursor)))
4294 (defun gnus-browse-server-mode ()
4295 "Major mode for browsing a foreign server."
4297 (kill-all-local-variables)
4298 (setq mode-line-modified "-- ")
4299 (make-local-variable 'mode-line-format)
4300 (setq mode-line-format (copy-sequence mode-line-format))
4301 (and (equal (nth 3 mode-line-format) " ")
4302 (setcar (nthcdr 3 mode-line-format) ""))
4303 (setq major-mode 'gnus-browse-server-mode)
4304 (setq mode-name "Browse Server")
4305 (setq mode-line-process nil)
4306 (use-local-map gnus-browse-server-mode-map)
4307 (buffer-disable-undo (current-buffer))
4308 (setq truncate-lines t)
4309 (setq buffer-read-only t)
4310 (run-hooks 'gnus-browse-server-mode-hook))
4312 (defun gnus-browse-read-group ()
4313 "Not implemented, and will probably never be."
4315 (error "You can't read while browsing"))
4317 (defun gnus-browse-next-group (n)
4318 "Go to the next group."
4322 (gnus-group-position-cursor)))
4324 (defun gnus-browse-prev-group (n)
4325 "Go to the next group."
4327 (gnus-browse-next-group (- n)))
4329 (defun gnus-browse-unsubscribe-current-group (arg)
4330 "(Un)subscribe to the next ARG groups."
4333 (error "No group at current line."))
4334 (let ((ward (if (< arg 0) -1 1))
4336 (while (and (> arg 0)
4338 (gnus-browse-unsubscribe-group)
4339 (zerop (gnus-browse-next-group ward)))
4340 (setq arg (1- arg)))
4341 (gnus-group-position-cursor)
4342 (if (/= 0 arg) (message "No more newsgroups"))
4345 (defun gnus-browse-unsubscribe-group ()
4347 (buffer-read-only nil)
4351 (if (= (following-char) ?K) (setq sub t))
4352 (re-search-forward ": \\(.*\\)$" nil t)
4353 (setq group (gnus-group-prefixed-name
4354 (buffer-substring (match-beginning 1) (match-end 1))
4355 gnus-browse-current-method))
4360 (gnus-group-change-level
4361 (list t group 3 nil nil gnus-browse-current-method) 3 9
4362 (gnus-gethash (car (nth 1 gnus-newsrc-assoc)) gnus-newsrc-hashtb)
4365 (gnus-group-change-level group 9 3)
4369 (defun gnus-browse-exit ()
4370 "Quit browsing and return to the group buffer."
4372 (if (eq major-mode 'gnus-browse-server-mode)
4373 (kill-buffer (current-buffer)))
4374 (switch-to-buffer gnus-group-buffer)
4375 (gnus-group-list-groups nil))
4377 (defun gnus-browse-describe-briefly ()
4378 "Give a one line description of the group mode commands."
4381 (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")))
4385 ;;; Gnus summary mode
4388 (defvar gnus-summary-mode-map nil)
4389 (defvar gnus-summary-mark-map nil)
4390 (defvar gnus-summary-mscore-map nil)
4391 (defvar gnus-summary-send-map nil)
4392 (defvar gnus-summary-extract-map nil)
4393 (defvar gnus-summary-extract-view-map nil)
4394 (defvar gnus-summary-article-map nil)
4395 (defvar gnus-summary-thread-map nil)
4396 (defvar gnus-summary-goto-map nil)
4397 (defvar gnus-summary-exit-map nil)
4398 (defvar gnus-summary-various-map nil)
4399 (defvar gnus-summary-interest-map nil)
4400 (defvar gnus-summary-process-map nil)
4401 (defvar gnus-summary-score-map nil)
4402 (defvar gnus-summary-sort-map nil)
4403 (defvar gnus-summary-mgroup-map nil)
4404 (defvar gnus-summary-vsave-map nil)
4405 (defvar gnus-summary-increase-map nil)
4406 (defvar gnus-summary-inc-subject-map nil)
4407 (defvar gnus-summary-inc-author-map nil)
4408 (defvar gnus-summary-inc-body-map nil)
4409 (defvar gnus-summary-inc-id-map nil)
4410 (defvar gnus-summary-inc-xref-map nil)
4411 (defvar gnus-summary-inc-thread-map nil)
4412 (defvar gnus-summary-inc-fol-map nil)
4413 (defvar gnus-summary-lower-map nil)
4414 (defvar gnus-summary-low-subject-map nil)
4415 (defvar gnus-summary-low-author-map nil)
4416 (defvar gnus-summary-low-body-map nil)
4417 (defvar gnus-summary-low-id-map nil)
4418 (defvar gnus-summary-low-xref-map nil)
4419 (defvar gnus-summary-low-thread-map nil)
4420 (defvar gnus-summary-low-fol-map nil)
4421 (put 'gnus-summary-mode 'mode-class 'special)
4423 (if gnus-summary-mode-map
4425 (setq gnus-summary-mode-map (make-keymap))
4426 (suppress-keymap gnus-summary-mode-map)
4428 ;; Non-orthogonal keys
4430 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
4431 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
4432 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
4433 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
4434 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
4435 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
4436 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
4437 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
4438 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
4439 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
4440 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
4441 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
4442 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
4443 (define-key gnus-summary-mode-map "\M-s" 'gnus-summary-search-article-forward)
4444 (define-key gnus-summary-mode-map "\M-r" 'gnus-summary-search-article-backward)
4445 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
4446 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
4447 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
4448 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
4449 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
4450 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
4451 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
4452 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
4453 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
4454 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
4455 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
4456 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
4457 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
4458 (define-key gnus-summary-mode-map "k" 'gnus-summary-kill-same-subject-and-select)
4459 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
4460 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
4461 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
4462 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
4463 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
4464 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
4465 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
4466 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
4467 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
4468 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
4469 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
4470 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
4471 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
4472 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
4473 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
4474 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
4475 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
4476 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
4477 (define-key gnus-summary-mode-map "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
4478 (define-key gnus-summary-mode-map "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
4479 (define-key gnus-summary-mode-map "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
4480 (define-key gnus-summary-mode-map "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
4481 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
4482 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
4483 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
4484 (define-key gnus-summary-mode-map "\C-x\C-s" 'gnus-summary-reselect-current-group)
4485 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
4486 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
4487 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
4488 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
4489 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
4490 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
4491 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
4492 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
4493 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
4494 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
4495 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
4496 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
4497 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
4498 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
4499 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
4500 (define-key gnus-summary-mode-map "V" 'gnus-version)
4501 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
4502 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
4503 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
4504 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
4505 (define-key gnus-summary-mode-map
4506 (if gnus-xemacs [button2] [mouse-2]) 'gnus-mouse-pick-article)
4507 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
4508 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
4509 (define-key gnus-summary-mode-map "x" 'gnus-summary-remove-lines-marked-as-read)
4510 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
4511 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
4512 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
4513 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
4514 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
4515 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
4516 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
4517 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
4520 ;; Sort of orthogonal keymap
4521 (define-prefix-command 'gnus-summary-mark-map)
4522 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
4523 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
4524 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
4525 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
4526 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
4527 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
4528 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
4529 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
4530 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
4531 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
4532 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
4533 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
4534 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
4535 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
4536 (define-key gnus-summary-mark-map "\M-r" 'gnus-summary-remove-lines-marked-as-read)
4537 (define-key gnus-summary-mark-map "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
4538 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
4539 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
4540 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
4541 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
4542 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
4543 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
4544 (define-key gnus-summary-mark-map "k" 'gnus-summary-kill-same-subject-and-select)
4545 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
4547 (define-prefix-command 'gnus-summary-mscore-map)
4548 (define-key gnus-summary-mark-map "s" 'gnus-summary-mscore-map)
4549 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
4550 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
4551 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
4552 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
4554 (define-prefix-command 'gnus-summary-process-map)
4555 (define-key gnus-summary-mark-map "p" 'gnus-summary-process-map)
4556 (define-key gnus-summary-process-map "p" 'gnus-summary-mark-as-processable)
4557 (define-key gnus-summary-process-map "u" 'gnus-summary-unmark-as-processable)
4558 (define-key gnus-summary-process-map "U" 'gnus-summary-unmark-all-processable)
4559 (define-key gnus-summary-process-map "s" 'gnus-uu-mark-series)
4560 (define-key gnus-summary-process-map "r" 'gnus-uu-mark-region)
4561 (define-key gnus-summary-process-map "R" 'gnus-uu-mark-by-regexp)
4562 (define-key gnus-summary-process-map "t" 'gnus-uu-mark-thread)
4563 (define-key gnus-summary-process-map "a" 'gnus-uu-mark-all)
4564 (define-key gnus-summary-process-map "S" 'gnus-uu-mark-sparse)
4567 (define-prefix-command 'gnus-summary-send-map)
4568 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
4569 (define-key gnus-summary-send-map "p" 'gnus-summary-post-news)
4570 (define-key gnus-summary-send-map "f" 'gnus-summary-followup)
4571 (define-key gnus-summary-send-map "F" 'gnus-summary-followup-with-original)
4572 (define-key gnus-summary-send-map "b" 'gnus-summary-followup-and-reply)
4573 (define-key gnus-summary-send-map "B" 'gnus-summary-followup-and-reply-with-original)
4574 (define-key gnus-summary-send-map "c" 'gnus-summary-cancel-article)
4575 (define-key gnus-summary-send-map "s" 'gnus-summary-supersede-article)
4576 (define-key gnus-summary-send-map "r" 'gnus-summary-reply)
4577 (define-key gnus-summary-send-map "R" 'gnus-summary-reply-with-original)
4578 (define-key gnus-summary-send-map "\C-f" 'gnus-summary-mail-forward)
4579 (define-key gnus-summary-send-map "m" 'gnus-summary-mail-other-window)
4580 (define-key gnus-summary-send-map "u" 'gnus-uu-post-news)
4581 (define-key gnus-summary-send-map "\M-f" 'gnus-uu-digest-and-forward)
4584 (define-prefix-command 'gnus-summary-goto-map)
4585 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
4586 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
4587 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
4588 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
4589 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
4590 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
4591 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
4592 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
4593 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
4594 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
4595 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
4596 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
4597 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
4598 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
4601 (define-prefix-command 'gnus-summary-thread-map)
4602 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
4603 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
4604 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
4605 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
4606 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
4607 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
4608 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
4609 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
4610 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
4611 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
4612 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
4613 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
4614 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
4615 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
4618 (define-prefix-command 'gnus-summary-exit-map)
4619 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
4620 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
4621 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
4622 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
4623 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
4624 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
4625 (define-key gnus-summary-exit-map "n" 'gnus-summary-catchup-and-goto-next-group)
4628 (define-prefix-command 'gnus-summary-article-map)
4629 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
4630 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
4631 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
4632 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
4633 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
4634 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
4635 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
4636 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
4637 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
4638 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
4639 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
4640 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
4641 (define-key gnus-summary-article-map "w" 'gnus-summary-stop-page-breaking)
4642 (define-key gnus-summary-article-map "c" 'gnus-summary-caesar-message)
4643 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
4644 (define-key gnus-summary-article-map "t" 'gnus-summary-toggle-header)
4645 (define-key gnus-summary-article-map "hh" 'gnus-article-hide-headers)
4646 (define-key gnus-summary-article-map "hs" 'gnus-article-hide-signature)
4647 (define-key gnus-summary-article-map "hc" 'gnus-article-hide-citation)
4648 (define-key gnus-summary-article-map "ho" 'gnus-article-treat-overstrike)
4649 (define-key gnus-summary-article-map "hw" 'gnus-article-word-wrap)
4650 (define-key gnus-summary-article-map "hd" 'gnus-article-remove-cr)
4651 (define-key gnus-summary-article-map "hq" 'gnus-article-de-quoted-unreadable)
4652 (define-key gnus-summary-article-map "hf" 'gnus-article-display-x-face)
4653 (define-key gnus-summary-article-map "m" 'gnus-summary-toggle-mime)
4654 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
4657 (define-prefix-command 'gnus-summary-extract-map)
4658 (define-key gnus-summary-mode-map "X" 'gnus-summary-extract-map)
4659 ; (define-key gnus-summary-extract-map "x" 'gnus-summary-extract-any)
4660 ; (define-key gnus-summary-extract-map "m" 'gnus-summary-extract-mime)
4661 (define-key gnus-summary-extract-map "u" 'gnus-uu-decode-uu)
4662 (define-key gnus-summary-extract-map "U" 'gnus-uu-decode-uu-and-save)
4663 (define-key gnus-summary-extract-map "s" 'gnus-uu-decode-unshar)
4664 (define-key gnus-summary-extract-map "S" 'gnus-uu-decode-unshar-and-save)
4665 (define-key gnus-summary-extract-map "o" 'gnus-uu-decode-save)
4666 (define-key gnus-summary-extract-map "O" 'gnus-uu-decode-save)
4667 (define-key gnus-summary-extract-map "b" 'gnus-uu-decode-binhex)
4668 (define-key gnus-summary-extract-map "B" 'gnus-uu-decode-binhex)
4669 (define-key gnus-summary-extract-map "p" 'gnus-uu-decode-postscript)
4670 (define-key gnus-summary-extract-map "P" 'gnus-uu-decode-postscript-and-save)
4673 (define-prefix-command 'gnus-summary-extract-view-map)
4674 (define-key gnus-summary-extract-map "v" 'gnus-summary-extract-view-map)
4675 (define-key gnus-summary-extract-view-map "u" 'gnus-uu-decode-uu-view)
4676 (define-key gnus-summary-extract-view-map "U" 'gnus-uu-decode-uu-and-save-view)
4677 (define-key gnus-summary-extract-view-map "s" 'gnus-uu-decode-unshar-view)
4678 (define-key gnus-summary-extract-view-map "S" 'gnus-uu-decode-unshar-and-save-view)
4679 (define-key gnus-summary-extract-view-map "o" 'gnus-uu-decode-save-view)
4680 (define-key gnus-summary-extract-view-map "O" 'gnus-uu-decode-save-view)
4681 (define-key gnus-summary-extract-view-map "b" 'gnus-uu-decode-binhex-view)
4682 (define-key gnus-summary-extract-view-map "B" 'gnus-uu-decode-binhex-view)
4683 (define-key gnus-summary-extract-view-map "p" 'gnus-uu-decode-postscript-view)
4684 (define-key gnus-summary-extract-view-map "P" 'gnus-uu-decode-postscript-and-save-view)
4687 (define-prefix-command 'gnus-summary-various-map)
4688 (define-key gnus-summary-mode-map "V" 'gnus-summary-various-map)
4689 (define-key gnus-summary-various-map "u" 'gnus-summary-universal-argument)
4690 (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
4691 (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
4692 (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
4693 (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
4694 (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
4695 (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
4696 (define-key gnus-summary-various-map "S" 'gnus-summary-reselect-current-group)
4697 (define-key gnus-summary-various-map "g" 'gnus-summary-rescan-group)
4698 (define-key gnus-summary-various-map "V" 'gnus-version)
4699 (define-key gnus-summary-various-map "f" 'gnus-summary-fetch-faq)
4700 (define-key gnus-summary-various-map "d" 'gnus-summary-describe-group)
4701 (define-key gnus-summary-various-map "?" 'gnus-summary-describe-briefly)
4702 (define-key gnus-summary-various-map "i" 'gnus-info-find-node)
4703 (define-key gnus-summary-various-map "D" 'gnus-summary-enter-digest-group)
4704 (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
4705 (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
4707 (define-prefix-command 'gnus-summary-vsave-map)
4708 (define-key gnus-summary-various-map "o" 'gnus-summary-vsave-map)
4709 (define-key gnus-summary-vsave-map "o" 'gnus-summary-save-article)
4710 (define-key gnus-summary-vsave-map "m" 'gnus-summary-save-article-mail)
4711 (define-key gnus-summary-vsave-map "r" 'gnus-summary-save-article-rmail)
4712 (define-key gnus-summary-vsave-map "f" 'gnus-summary-save-article-file)
4713 (define-key gnus-summary-vsave-map "h" 'gnus-summary-save-article-folder)
4714 (define-key gnus-summary-vsave-map "p" 'gnus-summary-pipe-output)
4716 (define-prefix-command 'gnus-summary-score-map)
4717 (define-key gnus-summary-various-map "S" 'gnus-summary-score-map)
4718 (define-key gnus-summary-score-map "s" 'gnus-summary-set-score)
4719 (define-key gnus-summary-score-map "c" 'gnus-score-change-score-file)
4720 (define-key gnus-summary-score-map "m" 'gnus-score-set-mark-below)
4721 (define-key gnus-summary-score-map "x" 'gnus-score-set-expunge-below)
4722 (define-key gnus-summary-score-map "e" 'gnus-score-edit-alist)
4723 (define-key gnus-summary-score-map "f" 'gnus-score-edit-file)
4725 (define-prefix-command 'gnus-summary-sort-map)
4726 (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
4727 (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
4728 (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
4729 (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
4730 (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
4731 (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
4733 (define-prefix-command 'gnus-summary-mgroup-map)
4734 (define-key gnus-summary-various-map "m" 'gnus-summary-mgroup-map)
4735 (define-key gnus-summary-mgroup-map "e" 'gnus-summary-expire-articles)
4736 (define-key gnus-summary-mgroup-map "\177" 'gnus-summary-delete-article)
4737 (define-key gnus-summary-mgroup-map "m" 'gnus-summary-move-article)
4738 (define-key gnus-summary-mgroup-map "r" 'gnus-summary-respool-article)
4739 (define-key gnus-summary-mgroup-map "w" 'gnus-summary-edit-article)
4740 (define-key gnus-summary-mgroup-map "c" 'gnus-summary-copy-article)
4743 (define-prefix-command 'gnus-summary-increase-map)
4744 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-map)
4745 (define-key gnus-summary-increase-map "i" 'gnus-summary-raise-same-subject-and-select)
4746 (define-key gnus-summary-increase-map "I" 'gnus-summary-raise-same-subject)
4747 (define-key gnus-summary-increase-map "\C-i" 'gnus-summary-raise-score)
4749 (define-prefix-command 'gnus-summary-inc-subject-map)
4750 (define-key gnus-summary-increase-map "s" 'gnus-summary-inc-subject-map)
4751 (define-key gnus-summary-increase-map "S" 'gnus-summary-temporarily-raise-by-subject)
4752 (define-key gnus-summary-inc-subject-map "s" 'gnus-summary-temporarily-raise-by-subject)
4753 (define-key gnus-summary-inc-subject-map "S" 'gnus-summary-raise-by-subject)
4754 (define-key gnus-summary-inc-subject-map "t" 'gnus-summary-temporarily-raise-by-subject)
4755 (define-key gnus-summary-inc-subject-map "p" 'gnus-summary-raise-by-subject)
4757 (define-prefix-command 'gnus-summary-inc-author-map)
4758 (define-key gnus-summary-increase-map "a" 'gnus-summary-inc-author-map)
4759 (define-key gnus-summary-increase-map "A" 'gnus-summary-temporarily-raise-by-author)
4760 (define-key gnus-summary-inc-author-map "a" 'gnus-summary-temporarily-raise-by-author)
4761 (define-key gnus-summary-inc-author-map "A" 'gnus-summary-raise-by-author)
4762 (define-key gnus-summary-inc-author-map "t" 'gnus-summary-temporarily-raise-by-author)
4763 (define-key gnus-summary-inc-author-map "p" 'gnus-summary-raise-by-author)
4765 (define-prefix-command 'gnus-summary-inc-body-map)
4766 (define-key gnus-summary-increase-map "b" 'gnus-summary-inc-body-map)
4767 (define-key gnus-summary-increase-map "B" 'gnus-summary-temporarily-raise-by-body)
4768 (define-key gnus-summary-inc-body-map "b" 'gnus-summary-temporarily-raise-by-body)
4769 (define-key gnus-summary-inc-body-map "B" 'gnus-summary-raise-by-body)
4770 (define-key gnus-summary-inc-body-map "t" 'gnus-summary-temporarily-raise-by-body)
4771 (define-key gnus-summary-inc-body-map "p" 'gnus-summary-raise-by-body)
4773 (define-prefix-command 'gnus-summary-inc-id-map)
4774 (define-key gnus-summary-increase-map "i" 'gnus-summary-inc-id-map)
4775 (define-key gnus-summary-increase-map "I" 'gnus-summary-temporarily-raise-by-id)
4776 (define-key gnus-summary-inc-id-map "i" 'gnus-summary-temporarily-raise-by-id)
4777 (define-key gnus-summary-inc-id-map "I" 'gnus-summary-raise-by-id)
4778 (define-key gnus-summary-inc-id-map "t" 'gnus-summary-temporarily-raise-by-id)
4779 (define-key gnus-summary-inc-id-map "p" 'gnus-summary-raise-by-id)
4781 (define-prefix-command 'gnus-summary-inc-thread-map)
4782 (define-key gnus-summary-increase-map "t" 'gnus-summary-inc-thread-map)
4783 (define-key gnus-summary-increase-map "T" 'gnus-summary-temporarily-raise-by-thread)
4784 (define-key gnus-summary-inc-thread-map "t" 'gnus-summary-temporarily-raise-by-thread)
4785 (define-key gnus-summary-inc-thread-map "T" 'gnus-summary-raise-by-thread)
4786 (define-key gnus-summary-inc-thread-map "t" 'gnus-summary-temporarily-raise-by-thread)
4787 (define-key gnus-summary-inc-thread-map "p" 'gnus-summary-raise-by-thread)
4789 (define-prefix-command 'gnus-summary-inc-xref-map)
4790 (define-key gnus-summary-increase-map "x" 'gnus-summary-inc-xref-map)
4791 (define-key gnus-summary-increase-map "X" 'gnus-summary-temporarily-raise-by-xref)
4792 (define-key gnus-summary-inc-xref-map "x" 'gnus-summary-temporarily-raise-by-xref)
4793 (define-key gnus-summary-inc-xref-map "X" 'gnus-summary-raise-by-xref)
4794 (define-key gnus-summary-inc-xref-map "t" 'gnus-summary-temporarily-raise-by-xref)
4795 (define-key gnus-summary-inc-xref-map "p" 'gnus-summary-raise-by-xref)
4797 (define-prefix-command 'gnus-summary-inc-fol-map)
4798 (define-key gnus-summary-increase-map "f" 'gnus-summary-inc-fol-map)
4799 (define-key gnus-summary-increase-map "F" 'gnus-summary-raise-followups-to-author)
4800 (define-key gnus-summary-inc-fol-map "f" 'gnus-summary-raise-followups-to-author)
4801 (define-key gnus-summary-inc-fol-map "F" 'gnus-summary-raise-followups-to-author)
4802 (define-key gnus-summary-inc-fol-map "t" 'gnus-summary-raise-followups-to-author)
4803 (define-key gnus-summary-inc-fol-map "p" 'gnus-summary-raise-followups-to-author)
4805 (define-prefix-command 'gnus-summary-lower-map)
4806 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-map)
4807 (define-key gnus-summary-lower-map "l" 'gnus-summary-lower-same-subject-and-select)
4808 (define-key gnus-summary-lower-map "L" 'gnus-summary-lower-same-subject)
4809 (define-key gnus-summary-lower-map "\C-l" 'gnus-summary-lower-score)
4811 (define-prefix-command 'gnus-summary-low-subject-map)
4812 (define-key gnus-summary-lower-map "s" 'gnus-summary-low-subject-map)
4813 (define-key gnus-summary-lower-map "S" 'gnus-summary-temporarily-lower-by-subject)
4814 (define-key gnus-summary-low-subject-map "s" 'gnus-summary-temporarily-lower-by-subject)
4815 (define-key gnus-summary-low-subject-map "S" 'gnus-summary-lower-by-subject)
4816 (define-key gnus-summary-low-subject-map "t" 'gnus-summary-temporarily-lower-by-subject)
4817 (define-key gnus-summary-low-subject-map "p" 'gnus-summary-lower-by-subject)
4819 (define-prefix-command 'gnus-summary-low-body-map)
4820 (define-key gnus-summary-lower-map "b" 'gnus-summary-low-body-map)
4821 (define-key gnus-summary-lower-map "B" 'gnus-summary-temporarily-lower-by-body)
4822 (define-key gnus-summary-low-body-map "b" 'gnus-summary-temporarily-lower-by-body)
4823 (define-key gnus-summary-low-body-map "B" 'gnus-summary-lower-by-body)
4824 (define-key gnus-summary-low-body-map "t" 'gnus-summary-temporarily-lower-by-body)
4825 (define-key gnus-summary-low-body-map "p" 'gnus-summary-lower-by-body)
4827 (define-prefix-command 'gnus-summary-low-author-map)
4828 (define-key gnus-summary-lower-map "a" 'gnus-summary-low-author-map)
4829 (define-key gnus-summary-lower-map "A" 'gnus-summary-temporarily-lower-by-author)
4830 (define-key gnus-summary-low-author-map "a" 'gnus-summary-temporarily-lower-by-author)
4831 (define-key gnus-summary-low-author-map "A" 'gnus-summary-lower-by-author)
4832 (define-key gnus-summary-low-author-map "t" 'gnus-summary-temporarily-lower-by-author)
4833 (define-key gnus-summary-low-author-map "p" 'gnus-summary-lower-by-author)
4835 (define-prefix-command 'gnus-summary-low-id-map)
4836 (define-key gnus-summary-lower-map "i" 'gnus-summary-low-id-map)
4837 (define-key gnus-summary-lower-map "I" 'gnus-summary-temporarily-lower-by-id)
4838 (define-key gnus-summary-low-id-map "i" 'gnus-summary-temporarily-lower-by-id)
4839 (define-key gnus-summary-low-id-map "I" 'gnus-summary-lower-by-id)
4840 (define-key gnus-summary-low-id-map "t" 'gnus-summary-temporarily-lower-by-id)
4841 (define-key gnus-summary-low-id-map "p" 'gnus-summary-lower-by-id)
4843 (define-prefix-command 'gnus-summary-low-thread-map)
4844 (define-key gnus-summary-lower-map "t" 'gnus-summary-low-thread-map)
4845 (define-key gnus-summary-lower-map "T" 'gnus-summary-temporarily-lower-by-thread)
4846 (define-key gnus-summary-low-thread-map "t" 'gnus-summary-temporarily-lower-by-thread)
4847 (define-key gnus-summary-low-thread-map "T" 'gnus-summary-lower-by-thread)
4848 (define-key gnus-summary-low-thread-map "t" 'gnus-summary-temporarily-lower-by-thread)
4849 (define-key gnus-summary-low-thread-map "p" 'gnus-summary-lower-by-thread)
4851 (define-prefix-command 'gnus-summary-low-xref-map)
4852 (define-key gnus-summary-lower-map "x" 'gnus-summary-low-xref-map)
4853 (define-key gnus-summary-lower-map "X" 'gnus-summary-temporarily-lower-by-xref)
4854 (define-key gnus-summary-low-xref-map "x" 'gnus-summary-temporarily-lower-by-xref)
4855 (define-key gnus-summary-low-xref-map "X" 'gnus-summary-lower-by-xref)
4856 (define-key gnus-summary-low-xref-map "t" 'gnus-summary-temporarily-lower-by-xref)
4857 (define-key gnus-summary-low-xref-map "p" 'gnus-summary-lower-by-xref)
4859 (define-prefix-command 'gnus-summary-low-fol-map)
4860 (define-key gnus-summary-lower-map "f" 'gnus-summary-low-fol-map)
4861 (define-key gnus-summary-lower-map "F" 'gnus-summary-lower-followups-to-author)
4862 (define-key gnus-summary-low-fol-map "f" 'gnus-summary-lower-followups-to-author)
4863 (define-key gnus-summary-low-fol-map "F" 'gnus-summary-lower-followups-to-author)
4864 (define-key gnus-summary-low-fol-map "t" 'gnus-summary-lower-followups-to-author)
4865 (define-key gnus-summary-low-fol-map "p" 'gnus-summary-lower-followups-to-author)
4871 (defun gnus-summary-mode ()
4872 "Major mode for reading articles.
4874 All normal editing commands are switched off.
4875 \\<gnus-summary-mode-map>
4876 Each line in this buffer represents one article. To read an
4877 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
4878 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
4881 You can also post articles and send mail from this buffer. To
4882 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
4883 of an article, type `\\[gnus-summary-reply]'.
4885 There are approx. one gazillion commands you can execute in this
4886 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
4888 The following commands are available:
4890 \\{gnus-summary-mode-map}"
4892 (if gnus-visual (gnus-summary-make-menu-bar))
4893 (kill-all-local-variables)
4894 (let ((locals gnus-summary-local-variables))
4896 (if (consp (car locals))
4898 (make-local-variable (car (car locals)))
4899 (set (car (car locals)) (eval (cdr (car locals)))))
4900 (make-local-variable (car locals))
4901 (set (car locals) nil))
4902 (setq locals (cdr locals))))
4903 (gnus-update-format-specifications)
4904 (setq mode-line-modified "-- ")
4905 (make-local-variable 'mode-line-format)
4906 (setq mode-line-format (copy-sequence mode-line-format))
4907 (and (equal (nth 3 mode-line-format) " ")
4908 (setcar (nthcdr 3 mode-line-format) ""))
4909 (setq major-mode 'gnus-summary-mode)
4910 (setq mode-name "Summary")
4911 (make-local-variable 'minor-mode-alist)
4912 (gnus-set-mode-line 'summary)
4913 (use-local-map gnus-summary-mode-map)
4914 (buffer-disable-undo (current-buffer))
4915 (setq buffer-read-only t) ;Disable modification
4916 (setq truncate-lines t)
4917 (setq selective-display t)
4918 (setq selective-display-ellipses t) ;Display `...'
4919 (run-hooks 'gnus-summary-mode-hook))
4921 (defun gnus-summary-clear-local-variables ()
4922 (let ((locals gnus-summary-local-variables))
4924 (if (consp (car locals))
4925 (set (car (car locals)) nil)
4926 (set (car locals) nil))
4927 (setq locals (cdr locals)))))
4929 (defun gnus-mouse-pick-article (e)
4932 (gnus-summary-next-page nil t))
4934 (defun gnus-summary-setup-buffer (group)
4935 "Initialize summary buffer."
4936 (let ((buffer (concat "*Summary " group "*")))
4937 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
4938 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
4939 (gnus-add-current-to-buffer-list)
4940 (gnus-summary-mode)))
4942 (defun gnus-set-global-variables ()
4943 ;; Set the global equivalents of the summary buffer-local variables
4944 ;; to the latest values they had. These reflect the summary buffer
4945 ;; that was in action when the last article was fetched.
4946 (if (eq major-mode 'gnus-summary-mode)
4948 (setq gnus-summary-buffer (current-buffer))
4949 (let ((name gnus-newsgroup-name)
4950 (marked gnus-newsgroup-marked)
4951 (unread gnus-newsgroup-unreads)
4952 (headers gnus-current-headers))
4954 (set-buffer gnus-group-buffer)
4955 (setq gnus-newsgroup-name name)
4956 (setq gnus-newsgroup-marked marked)
4957 (setq gnus-newsgroup-unreads unread)
4958 (setq gnus-current-headers headers))))))
4960 (defun gnus-summary-insert-dummy-line (sformat subject number)
4962 (setq sformat gnus-summary-dummy-line-format-spec))
4966 (insert (eval sformat))
4967 (add-text-properties
4969 (list 'gnus-subject (gnus-simplify-subject-re subject)
4974 (defun gnus-summary-insert-line
4975 (sformat header level current unread replied expirable subject-or-nil
4976 &optional dummy score)
4977 (or sformat (setq sformat gnus-summary-line-format-spec))
4979 (make-string (* level gnus-thread-indent-level) ? ))
4980 (lines (or (header-lines header) 0))
4981 (score (or score gnus-summary-default-score 0))
4982 (score-char (if (or (null gnus-summary-default-score)
4983 (= score gnus-summary-default-score)) ?
4984 (if (< score gnus-summary-default-score)
4985 gnus-score-below-mark gnus-score-over-mark)))
4986 (replied (if replied gnus-replied-mark ? ))
4987 (from (header-from header))
4988 (name-address (funcall gnus-extract-address-components from))
4989 (address (car (cdr name-address)))
4990 (name (or (car name-address) (car (cdr name-address))))
4991 (number (header-number header))
4992 (subject (header-subject header))
4993 (buffer-read-only nil)
4994 (opening-bracket (if dummy ?\< ?\[))
4995 (closing-bracket (if dummy ?\> ?\]))
4997 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
4998 (if (not (numberp lines)) (setq lines 0))
5001 (insert (eval sformat))
5002 (add-text-properties
5004 (list 'gnus-subject (gnus-simplify-subject-re subject)
5006 'gnus-mark (or unread gnus-unread-mark ? )
5007 'gnus-thread level))))
5009 (defun gnus-summary-update-line (&optional dont-update)
5010 ;; Update summary line after change.
5011 (or (not gnus-summary-default-score)
5012 gnus-summary-inhibit-highlight
5013 (let ((gnus-summary-inhibit-highlight t)
5014 (article (gnus-summary-article-number)))
5017 (if (and gnus-summary-mark-below
5018 (< (gnus-summary-article-score)
5019 gnus-summary-mark-below))
5020 (and (not (memq article gnus-newsgroup-marked))
5021 (not (memq article gnus-newsgroup-dormant))
5022 (memq article gnus-newsgroup-unreads)
5023 (gnus-summary-mark-article nil gnus-low-score-mark))
5024 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
5025 (gnus-summary-mark-article nil gnus-unread-mark))))
5027 (run-hooks 'gnus-visual-summary-update-hook))))))
5029 (defun gnus-summary-update-lines ()
5030 ;; Rehighlight summary buffer according to `gnus-summary-highlight'.
5031 (and (save-excursion
5032 (set-buffer gnus-summary-buffer)
5033 (goto-char (point-min))
5035 (gnus-summary-update-line)
5036 (forward-line 1)))))
5038 (defun gnus-summary-number-of-articles-in-thread (thread)
5039 ;; Sum up all elements (and sub-elements) in a list.
5041 (apply '+ (mapcar 'gnus-summary-number-of-articles-in-thread thread))
5044 (defun gnus-summary-read-group (group &optional show-all no-article kill-buffer)
5045 "Start reading news in newsgroup GROUP.
5046 If SHOW-ALL is non-nil, already read articles are also listed.
5047 If NO-ARTICLE is non-nil, no article is selected initially."
5048 (message "Retrieving newsgroup: %s..." group)
5049 (gnus-summary-setup-buffer group)
5050 (if (gnus-select-newsgroup group show-all)
5052 (gnus-set-global-variables)
5053 ;; Save the active value in effect when the group was entered.
5054 (setq gnus-newsgroup-active
5056 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5057 ;; You can change the subjects in this hook.
5058 (run-hooks 'gnus-select-group-hook)
5059 ;; Do score processing.
5060 (gnus-score-headers)
5061 ;; Update the format specifiers.
5062 (gnus-update-format-specifications)
5063 ;; Generate the summary buffer.
5064 (gnus-summary-prepare)
5065 (if (zerop (buffer-size))
5066 (cond (gnus-newsgroup-dormant
5067 (gnus-summary-show-all-dormant))
5068 ((and gnus-newsgroup-scored show-all)
5069 (gnus-summary-show-all-expunged))))
5070 ;; Function `gnus-apply-kill-file' must be called in this hook.
5071 (run-hooks 'gnus-apply-kill-hook)
5072 (if (zerop (buffer-size))
5074 ;; This newsgroup is empty.
5075 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
5076 (message "No unread news")
5078 (get-buffer kill-buffer)
5079 (buffer-name (get-buffer kill-buffer))
5080 (kill-buffer kill-buffer)))
5083 (let ((gnus-summary-buffer kill-buffer))
5084 (gnus-configure-windows 'newsgroups t))))
5085 ;; Hide conversation thread subtrees. We cannot do this in
5086 ;; gnus-summary-prepare-hook since kill processing may not
5087 ;; work with hidden articles.
5088 (and gnus-show-threads
5089 gnus-thread-hide-subtree
5090 (gnus-summary-hide-all-threads))
5091 ;; Show first unread article if requested.
5092 (goto-char (point-min))
5093 (if (and (not no-article)
5094 gnus-auto-select-first
5095 (gnus-summary-first-unread-article))
5096 (gnus-configure-windows 'article)
5097 (gnus-configure-windows 'summary))
5098 (pop-to-buffer gnus-summary-buffer)
5099 (gnus-set-mode-line 'summary)
5100 (gnus-summary-position-cursor)
5101 (if (and kill-buffer
5102 (get-buffer kill-buffer)
5103 (buffer-name (get-buffer kill-buffer)))
5104 (kill-buffer kill-buffer))))
5105 ;; Cannot select newsgroup GROUP.
5106 (message "Couldn't select newsgroup")
5107 (and (eq major-mode 'gnus-summary-mode)
5108 (kill-buffer (current-buffer)))
5109 (switch-to-buffer gnus-group-buffer)
5110 (gnus-group-next-unread-group 1)))
5112 (defun gnus-summary-prepare ()
5113 "Prepare summary list of current newsgroup in summary buffer."
5114 (let ((buffer-read-only nil))
5116 (gnus-summary-prepare-threads
5117 (if gnus-show-threads
5118 (gnus-gather-threads
5120 (if gnus-summary-expunge-below
5121 (gnus-make-threads-and-expunge)
5122 (gnus-make-threads))))
5123 gnus-newsgroup-headers)
5125 ;; Erase header retrieval message.
5126 (gnus-summary-update-lines)
5128 ;; Call hooks for modifying summary buffer.
5129 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
5130 (goto-char (point-min))
5131 (run-hooks 'gnus-summary-prepare-hook)))
5133 (defun gnus-gather-threads (threads)
5134 "Gather threads that have lost their roots."
5135 (if (not gnus-summary-make-false-root)
5137 (let ((hashtb (gnus-make-hashtable 1023))
5140 thread subject hthread unre-subject whole-subject)
5142 (setq subject (header-subject (car (car threads)))
5143 whole-subject subject)
5144 (and gnus-summary-gather-subject-limit
5145 (or (and (numberp gnus-summary-gather-subject-limit)
5146 (> (length subject) gnus-summary-gather-subject-limit)
5148 (substring subject 0
5149 gnus-summary-gather-subject-limit)))
5150 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
5151 (setq subject (gnus-simplify-subject-fuzzy subject)))))
5154 (setq unre-subject (gnus-simplify-subject-re subject))
5157 (or (stringp (car (car hthread)))
5158 (setcar hthread (list whole-subject (car hthread))))
5159 (setcdr (car hthread) (nconc (cdr (car hthread))
5160 (list (car threads))))
5161 (setcdr prev (cdr threads))
5162 (setq threads prev))
5163 (gnus-sethash unre-subject threads hashtb))
5165 (setq threads (cdr threads)))
5168 (defun gnus-make-threads ()
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 (setq roots (append (cdr (symbol-value refs)) roots))
5180 ;; Ok, these refer back to valid articles, but if
5181 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5182 ;; the root has the same subject as its children. The children
5183 ;; that do not are made into roots and removed from the list
5185 (or gnus-thread-ignore-subject
5186 (let* ((prev (symbol-value refs))
5187 (subject (gnus-simplify-subject-re
5188 (header-subject (car prev))))
5189 (headers (cdr prev)))
5191 (if (not (string= subject
5192 (gnus-simplify-subject-re
5193 (header-subject (car headers)))))
5195 (setq roots (cons (car headers) roots))
5196 (setcdr prev (cdr headers)))
5197 (setq prev headers))
5198 (setq headers (cdr headers)))))))
5199 gnus-newsgroup-dependencies)
5201 (mapcar 'gnus-trim-thread
5203 (mapcar 'gnus-cut-thread
5204 (mapcar 'gnus-make-sub-thread roots))))))
5206 (defun gnus-make-threads-and-expunge ()
5207 ;; This function takes the dependencies already made by
5208 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5209 ;; through the dependecies in the hash table and finds all the
5210 ;; roots. Roots do not refer back to any valid articles.
5212 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5213 (gnus-build-old-threads))
5216 (if (not (car (symbol-value refs)))
5217 (if (and gnus-summary-expunge-below
5218 (not gnus-fetch-old-headers))
5219 (let ((headers (cdr (symbol-value refs))))
5221 (if (not (< (or (cdr (assq (header-number (car headers))
5222 gnus-newsgroup-scored))
5223 gnus-summary-default-score 0)
5224 gnus-summary-expunge-below))
5225 (setq roots (cons (car headers) roots))
5226 (setq gnus-newsgroup-unreads
5227 (delq (header-number (car headers))
5228 gnus-newsgroup-unreads)))
5229 (setq headers (cdr headers))))
5230 (setq roots (append (cdr (symbol-value refs)) roots)))
5231 ;; Ok, these refer back to valid articles, but if
5232 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5233 ;; the root has the same subject as its children. The children
5234 ;; that do not are made into roots and removed from the list
5236 (or gnus-thread-ignore-subject
5237 (let* ((prev (symbol-value refs))
5238 (subject (gnus-simplify-subject-re
5239 (header-subject (car prev))))
5240 (headers (cdr prev)))
5242 (if (not (string= subject
5243 (gnus-simplify-subject-re
5244 (header-subject (car headers)))))
5246 (setq roots (cons (car headers) roots))
5247 (setcdr prev (cdr headers)))
5248 (setq prev headers))
5249 (setq headers (cdr headers)))))
5250 (and gnus-summary-expunge-below
5251 (not gnus-fetch-old-headers)
5252 (let* ((prev (symbol-value refs))
5253 (headers (cdr prev))
5256 (if (not (< (or (cdr (assq (header-number (car headers))
5257 gnus-newsgroup-scored))
5258 gnus-summary-default-score 0)
5259 gnus-summary-expunge-below))
5260 (setq prev (cdr prev))
5261 (setq gnus-newsgroup-unreads
5262 (delq (header-number (car headers))
5263 gnus-newsgroup-unreads))
5264 (setcdr prev (cdr headers))
5265 (setq id (gnus-gethash (header-id (car headers))
5266 gnus-newsgroup-dependencies))
5269 (if (not (< (or (cdr (assq (header-number (car h))
5270 gnus-newsgroup-scored))
5271 gnus-summary-default-score 0)
5272 gnus-summary-expunge-below))
5273 (setq roots (cons (car h) roots)))
5275 (setq headers (cdr headers)))))))
5276 gnus-newsgroup-dependencies)
5278 (mapcar 'gnus-trim-thread
5280 (mapcar 'gnus-cut-thread
5281 (mapcar 'gnus-make-sub-thread roots))))))
5283 (defun gnus-cut-thread (thread)
5284 ;; Remove leaf dormant or ancient articles from THREAD.
5285 (let ((head (car thread))
5286 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
5287 (if (and (null tail)
5288 (let ((number (header-number head)))
5289 (or (memq number gnus-newsgroup-ancient)
5290 (memq number gnus-newsgroup-dormant)
5291 (and gnus-summary-expunge-below
5292 (eq gnus-fetch-old-headers 'some)
5293 (< (or (cdr (assq number gnus-newsgroup-scored))
5294 gnus-summary-default-score 0)
5295 gnus-summary-expunge-below)
5297 (setq gnus-newsgroup-unreads
5298 (delq number gnus-newsgroup-unreads))
5301 (list (cons head tail)))))
5303 (defun gnus-trim-thread (thread)
5304 ;; Remove root ancient articles with only one child from THREAD.
5305 (if (and (eq gnus-fetch-old-headers 'some)
5306 (memq (header-number (car thread)) gnus-newsgroup-ancient)
5307 (= (length thread) 2))
5308 (gnus-trim-thread (nth 1 thread))
5311 (defun gnus-make-sub-thread (root)
5312 ;; This function makes a sub-tree for a node in the tree.
5313 (let ((children (reverse (cdr (gnus-gethash (downcase (header-id root))
5314 gnus-newsgroup-dependencies)))))
5315 (cons root (mapcar 'gnus-make-sub-thread children))))
5317 (defun gnus-build-old-threads ()
5318 ;; Look at all the articles that refer back to old articles, and
5319 ;; fetch the headers for the articles that aren't there. This will
5320 ;; build complete threads - if the roots haven't been expired by the
5325 (if (not (car (symbol-value refs)))
5327 (setq heads (cdr (symbol-value refs)))
5329 (if (not (memq (header-number (car heads))
5330 gnus-newsgroup-dormant))
5332 (setq id (symbol-name refs))
5333 (while (and (setq id (gnus-build-get-header id))
5334 (not (car (gnus-gethash
5335 id gnus-newsgroup-dependencies)))))
5337 (setq heads (cdr heads)))))))
5338 gnus-newsgroup-dependencies)))
5340 (defun gnus-build-get-header (id)
5341 ;; Look through the buffer of NOV lines and find the header to
5342 ;; ID. Enter this line into the dependencies hash table, and return
5343 ;; the id of the parent article (if any).
5344 (let ((deps gnus-newsgroup-dependencies)
5348 (set-buffer nntp-server-buffer)
5349 (goto-char (point-min))
5350 (while (and (not found) (search-forward id nil t))
5352 (setq found (looking-at (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
5353 (regexp-quote id))))
5354 (or found (beginning-of-line 2)))
5359 (setq header (gnus-nov-parse-line
5360 (read (current-buffer)) deps))
5361 (setq ref (header-references header))
5362 (string-match "\\(<[^>]+>\\) *$" ref)
5363 (substring ref (match-beginning 1) (match-end 1))))))
5365 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
5366 gnus-newsgroup-ancient (cons (header-number header)
5367 gnus-newsgroup-ancient))))))
5369 (defun gnus-sort-threads (threads)
5370 ;; Sort threads as specified in `gnus-thread-sort-functions'.
5371 (let ((fun gnus-thread-sort-functions))
5373 (setq threads (sort threads (car fun))
5377 (defun gnus-thread-header (thread)
5378 ;; Return header of first article in THREAD.
5380 (if (stringp (car thread))
5381 (car (car (cdr thread)))
5385 (defun gnus-thread-sort-by-number (h1 h2)
5386 "Sort threads by root article number."
5387 (let ((h1 (gnus-thread-header h1))
5388 (h2 (gnus-thread-header h2)))
5389 (< (header-number h1) (header-number h2))))
5391 (defun gnus-thread-sort-by-author (h1 h2)
5392 "Sort threads by root author."
5393 (let ((h1 (gnus-thread-header h1))
5394 (h2 (gnus-thread-header h2)))
5396 (let ((extract (funcall
5397 gnus-extract-address-components (header-from h1))))
5398 (or (car extract) (cdr extract)))
5399 (let ((extract (funcall
5400 gnus-extract-address-components (header-from h2))))
5401 (or (car extract) (cdr extract))))))
5403 (defun gnus-thread-sort-by-subject (h1 h2)
5404 "Sort threads by root subject."
5405 (let ((h1 (gnus-thread-header h1))
5406 (h2 (gnus-thread-header h2)))
5408 (downcase (gnus-simplify-subject (header-subject h1)))
5409 (downcase (gnus-simplify-subject (header-subject h2))))))
5411 (defun gnus-thread-sort-by-date (h1 h2)
5412 "Sort threads by root article date."
5413 (let ((h1 (gnus-thread-header h1))
5414 (h2 (gnus-thread-header h2)))
5416 (gnus-sortable-date (header-date h1))
5417 (gnus-sortable-date (header-date h2)))))
5419 (defun gnus-thread-sort-by-score (h1 h2)
5420 "Sort threads by root article score.
5421 Unscored articles will be counted as havin a score of zero."
5422 (let ((h1 (gnus-thread-header h1))
5423 (h2 (gnus-thread-header h2)))
5424 (let ((s1 (assq (header-number h1) gnus-newsgroup-scored))
5425 (s2 (assq (header-number h2) gnus-newsgroup-scored)))
5426 (> (or (cdr s1) gnus-summary-default-score 0)
5427 (or (cdr s2) gnus-summary-default-score 0)))))
5429 (defun gnus-thread-sort-by-total-score (h1 h2)
5430 "Sort threads by the sum of all scores in the thread.
5431 Unscored articles will be counted as havin a score of zero."
5432 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5434 (defun gnus-thread-total-score (thread)
5435 ;; This function find the total score of THREAD.
5437 (if (stringp (car thread))
5438 (apply gnus-thread-score-function 0
5439 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5440 (gnus-thread-total-score-1 thread))
5441 (gnus-thread-total-score-1 (list thread))))
5443 (defun gnus-thread-total-score-1 (root)
5444 ;; This function find the total score of the thread below ROOT.
5445 (setq root (car root))
5446 (apply gnus-thread-score-function
5447 (or (cdr (assq (header-number root) gnus-newsgroup-scored))
5448 gnus-summary-default-score 0)
5449 (mapcar 'gnus-thread-total-score
5450 (cdr (gnus-gethash (downcase (header-id root))
5451 gnus-newsgroup-dependencies)))))
5453 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5454 (defvar gnus-tmp-prev-subject "")
5456 ;; Basic ideas by Paul Dworkin <paul@media-lab.media.mit.edu>.
5457 (defun gnus-summary-prepare-threads
5458 (threads level &optional not-child no-subject cull)
5459 "Prepare summary buffer from THREADS and indentation LEVEL.
5460 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5461 or a straight list of headers."
5462 (let (thread header number subject clevel)
5464 (setq thread (car threads)
5465 threads (cdr threads))
5466 ;; If `thread' is a cons, hierarchical threads are used. If not,
5467 ;; `thread' is the header.
5469 (setq header (car thread))
5470 (setq header thread)
5472 (or (memq (setq number (header-number header))
5473 gnus-newsgroup-dormant)
5474 (and gnus-summary-expunge-below
5475 (< (or (cdr (assq number gnus-newsgroup-scored))
5476 gnus-summary-default-score 0)
5477 gnus-summary-expunge-below)))
5480 (setq gnus-newsgroup-unreads
5481 (delq number gnus-newsgroup-unreads)))))
5484 ;; The header is a dummy root.
5485 (cond ((eq gnus-summary-make-false-root 'adopt)
5486 ;; We let the first article adopt the rest.
5487 (gnus-summary-prepare-threads (list (car (cdr thread))) 0)
5488 (setq thread (cdr (cdr thread)))
5490 (gnus-summary-prepare-threads (list (car thread)) 1 t)
5491 (setq thread (cdr thread))))
5492 ((eq gnus-summary-make-false-root 'dummy)
5493 ;; We output a dummy root.
5494 (gnus-summary-insert-dummy-line
5495 nil header (header-number (car (car (cdr thread)))))
5497 ((eq gnus-summary-make-false-root 'empty)
5498 ;; We print the articles with empty subject fields.
5499 (gnus-summary-prepare-threads (list (car (cdr thread))) 0)
5500 (setq thread (cdr (cdr thread)))
5502 (gnus-summary-prepare-threads
5503 (list (car thread)) 0 nil
5504 (not (and (eq gnus-summary-gather-subject-limit 'fuzzy)
5506 (gnus-simplify-subject-re
5507 (header-subject (car (car thread))))
5508 (gnus-simplify-subject-re header))))))
5509 (setq thread (cdr thread))))
5511 ;; We do not make a root for the gathered
5512 ;; sub-threads at all.
5514 ;; Print the sub-threads.
5515 (and (consp thread) (cdr thread)
5516 (gnus-summary-prepare-threads (cdr thread) clevel)))
5517 ;; The header is a real article.
5519 (setq number (header-number header)
5520 subject (header-subject header))
5521 (gnus-summary-insert-line
5522 nil header level nil
5523 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
5524 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
5525 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
5526 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
5527 (t gnus-ancient-mark))
5528 (memq number gnus-newsgroup-replied)
5529 (memq number gnus-newsgroup-expirable)
5531 gnus-summary-same-subject
5532 (if (or (zerop level)
5533 (and gnus-thread-ignore-subject
5535 (gnus-simplify-subject-re gnus-tmp-prev-subject)
5536 (gnus-simplify-subject-re subject)))))
5538 gnus-summary-same-subject))
5540 (cdr (assq number gnus-newsgroup-scored)))
5541 (setq gnus-tmp-prev-subject subject)
5542 ;; Recursively print subthreads.
5543 (and (consp thread) (cdr thread)
5544 (gnus-summary-prepare-threads (cdr thread) (1+ level))))))))
5546 (defun gnus-select-newsgroup (group &optional read-all)
5547 "Select newsgroup GROUP.
5548 If READ-ALL is non-nil, all articles in the group are selected."
5549 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5550 (info (nth 2 entry))
5551 articles header-marks)
5552 (gnus-check-news-server
5553 (setq gnus-current-select-method (gnus-find-method-for-group group)))
5555 (or (gnus-server-opened gnus-current-select-method)
5556 (gnus-open-server gnus-current-select-method)
5557 (error "Couldn't open server"))
5559 (or (and (eq (car entry) t)
5560 (gnus-activate-newsgroup (car info)))
5561 (gnus-request-group group t)
5563 (kill-buffer (current-buffer))
5564 (error "Couldn't request group %s: %s"
5565 group (gnus-status-message group))))
5567 (setq gnus-newsgroup-name group)
5568 (setq gnus-newsgroup-unselected nil)
5569 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5571 (if (not (setq articles (gnus-articles-to-read group read-all)))
5573 ;; Init the dependencies hash table.
5574 (setq gnus-newsgroup-dependencies
5575 (gnus-make-hashtable (length articles)))
5576 ;; Retrieve the headers and read them in.
5577 (setq gnus-newsgroup-headers
5578 (if (eq 'nov (setq gnus-headers-retrieved-by
5579 (gnus-retrieve-headers
5580 (if gnus-fetch-old-headers
5581 (cons 1 articles) articles)
5582 gnus-newsgroup-name)))
5584 (gnus-get-newsgroup-headers-xover articles))
5585 (gnus-get-newsgroup-headers)))
5586 ;; If we were to fetch old headers, but the backend didn't
5587 ;; support XOVER, then it is possible we fetched one article
5588 ;; that we shouldn't have. If that's the case, we pop it off the
5590 (and (not (eq gnus-headers-retrieved-by 'nov))
5591 gnus-fetch-old-headers
5592 gnus-newsgroup-headers
5593 (/= (header-number (car gnus-newsgroup-headers)) (car articles))
5594 (setq gnus-newsgroup-headers (cdr gnus-newsgroup-headers)))
5595 ;; Remove cancelled articles from the list of unread articles.
5596 (setq gnus-newsgroup-unreads
5597 (gnus-set-sorted-intersection
5598 gnus-newsgroup-unreads
5599 (mapcar (lambda (headers) (header-number headers))
5600 gnus-newsgroup-headers)))
5601 ;; Adjust and set lists of article marks.
5604 (gnus-adjust-marked-articles info)
5605 (setq gnus-newsgroup-marked
5606 (cdr (assq 'tick (setq marked (nth 3 info)))))
5607 (setq gnus-newsgroup-replied (cdr (assq 'reply marked)))
5608 (setq gnus-newsgroup-expirable (cdr (assq 'expire marked)))
5609 (setq gnus-newsgroup-killed (cdr (assq 'killed marked)))
5610 (setq gnus-newsgroup-bookmarks (cdr (assq 'bookmark marked)))
5611 (setq gnus-newsgroup-dormant (cdr (assq 'dormant marked)))
5612 (setq gnus-newsgroup-scored (cdr (assq 'score marked)))
5613 (setq gnus-newsgroup-processable nil)))
5614 ;; Check whether auto-expire is to be done in this group.
5615 (setq gnus-newsgroup-auto-expire
5616 (or (and (stringp gnus-auto-expirable-newsgroups)
5617 (string-match gnus-auto-expirable-newsgroups group))
5618 (memq 'auto-expire gnus-current-select-method)))
5619 ;; First and last article in this newsgroup.
5620 (and gnus-newsgroup-headers
5621 (setq gnus-newsgroup-begin
5622 (header-number (car gnus-newsgroup-headers)))
5623 (setq gnus-newsgroup-end
5624 (header-number (gnus-last-element gnus-newsgroup-headers))))
5625 (setq gnus-reffed-article-number -1)
5626 ;; GROUP is successfully selected.
5627 (or gnus-newsgroup-headers t))))
5629 (defun gnus-articles-to-read (group read-all)
5630 ;; Find out what articles the user wants to read.
5632 ;; Select all articles if `read-all' is non-nil, or if all the
5633 ;; unread articles are dormant articles.
5635 (= (length gnus-newsgroup-unreads)
5636 (length gnus-newsgroup-dormant)))
5637 (gnus-uncompress-range
5638 (gnus-gethash group gnus-active-hashtb))
5639 gnus-newsgroup-unreads))
5640 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5641 (scored (length scored-list))
5642 (number (length articles))
5643 (marked (+ (length gnus-newsgroup-marked)
5644 (length gnus-newsgroup-dormant)))
5647 (cond ((and (or (<= scored marked)
5649 (numberp gnus-large-newsgroup)
5650 (> number gnus-large-newsgroup))
5654 "How many articles from %s (default %d): "
5655 gnus-newsgroup-name number))))
5656 (if (string-equal input "")
5658 ((and (> scored marked) (< scored number))
5662 "%s %s (%d scored, %d total): "
5663 "How many articles from"
5664 group scored number))))
5665 (if (string-equal input "")
5670 (setq select (if (numberp select) select (string-to-number select)))
5673 (if (and (not (zerop scored)) (<= (abs select) scored))
5675 (setq articles (sort scored-list '<))
5676 (setq number (length articles)))
5677 (setq articles (copy-sequence articles)))
5679 (setq total-articles articles)
5681 (if (< (abs select) number)
5683 ;; Select the N oldest articles.
5684 (setcdr (nthcdr (1- (abs select)) articles) nil)
5685 ;; Select the N most recent articles.
5686 (setq articles (nthcdr (- number select) articles))))
5687 (setq gnus-newsgroup-unselected
5688 (gnus-sorted-intersection
5689 gnus-newsgroup-unreads
5690 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
5693 (defun gnus-killed-articles (killed articles)
5696 (if (inline (gnus-member-of-range (car articles) killed))
5697 (setq out (cons (car articles) out)))
5698 (setq articles (cdr articles)))
5701 (defun gnus-adjust-marked-articles (info &optional active)
5702 "Remove all marked articles that are no longer legal."
5703 (let ((marked-lists (nth 3 info))
5704 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
5706 ;; There are many types of marked articles.
5708 (setq m (cdr (setq prev (car marked-lists))))
5709 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
5710 ;; Make sure that all ticked articles are a subset of the
5711 ;; unread/unselected articles.
5713 (if (or (memq (car m) gnus-newsgroup-unreads)
5714 (memq (car m) gnus-newsgroup-unselected))
5716 (setcdr prev (cdr m)))
5718 ((eq 'score (car prev))
5719 ;; Scored articles should be a subset of
5720 ;; unread/unselected articles.
5722 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
5723 (memq (car (car m)) gnus-newsgroup-unreads))
5725 (setcdr prev (cdr m)))
5727 ((eq 'bookmark (car prev))
5728 ;; Bookmarks should be a subset of active articles.
5730 (if (< (car (car m)) (car active))
5731 (setcdr prev (cdr m))
5734 ((eq 'killed (car prev))
5735 ;; Articles that have been through the kill process are
5736 ;; to be a subset of active articles.
5737 (while (and m (< (or (and (numberp (car m)) (car m))
5740 (setcdr prev (cdr m))
5742 (if (and m (< (or (and (numberp (car m)) (car m))
5745 (setcar (if (numberp (car m)) m (car m)) (car active))))
5746 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
5747 ;; The replied and expirable articles have to be articles
5750 (if (< (car m) (car active))
5751 (setcdr prev (cdr m))
5754 (setq marked-lists (cdr marked-lists)))
5755 ;; Remove all lists that are empty.
5756 (setq marked-lists (nth 3 info))
5759 (while (= 1 (length (car marked-lists)))
5760 (setq marked-lists (cdr marked-lists)))
5761 (setq m (cdr (setq prev marked-lists)))
5763 (if (= 1 (length (car m)))
5764 (setcdr prev (cdr m))
5767 (setcar (nthcdr 3 info) marked-lists)))
5768 ;; Finally, if there are no marked lists at all left, and if there
5769 ;; are no elements after the lists in the info list, we just chop
5770 ;; the info list off before the marked lists.
5771 (and (null marked-lists)
5772 (not (nthcdr 4 info))
5773 (setcdr (nthcdr 2 info) nil)))
5776 (defun gnus-set-marked-articles
5777 (info ticked replied expirable killed dormant bookmark score)
5778 "Enter the various lists of marked articles into the newsgroup info list."
5780 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
5781 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
5782 (and expirable (setq newmarked (cons (cons 'expire expirable)
5784 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
5785 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
5786 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
5788 (and score (setq newmarked (cons (cons 'score score) newmarked)))
5791 (setcar (nthcdr 3 info) newmarked)
5792 (if (not (nthcdr 4 info))
5793 (setcdr (nthcdr 2 info) nil)
5794 (setcar (nthcdr 3 info) nil)))
5796 (setcdr (nthcdr 2 info) (cons newmarked nil))))))
5798 (defun gnus-add-marked-articles (group type articles &optional info force)
5799 ;; Add ARTICLES of TYPE to the info of GROUP.
5800 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
5801 ;; add, but replace marked articles of TYPE with ARTICLES.
5802 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
5805 (and (not (setq marked (nthcdr 3 info)))
5806 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
5807 (and (not (setq m (assq type (car marked))))
5808 (setcar marked (cons (cons type articles) (car marked))))
5811 (nconc m articles)))))
5813 (defun gnus-set-mode-line (where)
5814 "This function sets the mode line of the article or summary buffers.
5815 If WHERE is `summary', the summary mode line format will be used."
5816 (if (memq where gnus-updated-mode-lines)
5819 (set-buffer gnus-summary-buffer)
5820 (let* ((mformat (if (eq where 'article)
5821 gnus-article-mode-line-format-spec
5822 gnus-summary-mode-line-format-spec))
5823 (group-name gnus-newsgroup-name)
5824 (article-number (or gnus-current-article 0))
5825 (unread (- (length gnus-newsgroup-unreads)
5826 (length gnus-newsgroup-dormant)))
5827 (unread-and-unticked
5828 (- unread (length gnus-newsgroup-marked)))
5829 (unselected (length gnus-newsgroup-unselected))
5830 (unread-and-unselected
5831 (cond ((and (zerop unread-and-unticked)
5832 (zerop unselected)) "")
5834 (format "{%d more}" unread-and-unticked))
5835 (t (format "{%d(+%d) more}"
5836 unread-and-unticked unselected))))
5838 (if gnus-current-headers
5839 (header-subject gnus-current-headers) ""))
5840 (max-len (- (frame-width) gnus-mode-non-string-length))
5841 header) ;; passed as argument to any user-format-funcs
5842 (setq mode-string (eval mformat))
5843 (and (numberp max-len)
5845 (if (> (length mode-string) max-len)
5847 (concat (substring mode-string 0 (- max-len 3))
5849 (setq mode-string (format (format "%%-%ds" max-len)
5851 (setq mode-line-buffer-identification mode-string)
5852 (set-buffer-modified-p t))))
5854 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5855 "Go through the HEADERS list and add all Xrefs to a hash table.
5856 The resulting hash table is returned, or nil if no Xrefs were found."
5857 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
5859 (gnus-group-foreign-p from-newsgroup)
5861 (assoc (symbol-name (car from-method))
5862 gnus-valid-select-methods))))
5863 (gnus-group-real-prefix from-newsgroup)))
5864 (xref-hashtb (make-vector 63 0))
5865 start group entry number xrefs header)
5867 (setq header (car headers))
5868 (if (and (setq xrefs (header-xref header))
5869 (not (memq (header-number header) unreads)))
5872 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
5873 (setq start (match-end 0))
5874 (setq group (concat prefix (substring xrefs (match-beginning 1)
5877 (string-to-int (substring xrefs (match-beginning 2)
5879 (if (setq entry (gnus-gethash group xref-hashtb))
5880 (setcdr entry (cons number (cdr entry)))
5881 (gnus-sethash group (cons number nil) xref-hashtb)))))
5882 (setq headers (cdr headers)))
5883 (if start xref-hashtb nil)))
5885 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
5886 "Look through all the headers and mark the Xrefs as read."
5887 (let ((virtual (memq 'virtual
5888 (assoc (symbol-name (car (gnus-find-method-for-group
5890 gnus-valid-select-methods)))
5891 name entry read info xref-hashtb idlist active num range exps method
5894 (set-buffer gnus-group-buffer)
5895 (if (setq xref-hashtb
5896 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5899 (if (string= from-newsgroup (setq name (symbol-name group)))
5901 (setq idlist (symbol-value group))
5902 ;; Dead groups are not updated.
5904 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5906 (if (stringp (setq nth4 (nth 4 info)))
5907 (setq nth4 (gnus-server-to-method nth4))))
5908 ;; Only do the xrefs if the group has the same
5909 ;; select method as the group we have just read.
5910 (or (gnus-methods-equal-p
5911 nth4 (gnus-find-method-for-group from-newsgroup))
5914 (setq method (gnus-find-method-for-group
5916 (and (equal (car nth4) (car method))
5917 (equal (nth 1 nth4) (nth 1 method))))
5918 gnus-use-cross-reference
5919 (or (not (eq gnus-use-cross-reference t))
5921 ;; Only do cross-references on subscribed
5922 ;; groups, if that is what is wanted.
5923 (<= (nth 1 info) 5)))
5926 ;; Set the new list of read articles in this group.
5927 (setq active (gnus-gethash name gnus-active-hashtb))
5928 ;; First peel off all illegal article numbers.
5931 (ticked (cdr (assq 'tick (nth 3 info))))
5932 (dormant (cdr (assq 'dormant (nth 3 info))))
5937 (if (or (> id (cdr active))
5941 (setq idlist (delq id idlist)))
5942 (and (memq id expirable)
5943 (setq exps (cons id exps)))
5944 (setq ids (cdr ids)))))
5945 ;; Update expirable articles.
5946 (gnus-add-marked-articles nil 'expirable exps info)
5947 (and (null (nth 2 info))
5949 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
5950 (setcar (nthcdr 2 info)
5954 (setq idlist (sort idlist '<)))))
5955 ;; Then we have to re-compute how many unread
5956 ;; articles there are in this group.
5961 (setq num (- (1+ (cdr active)) (car active))))
5962 ((not (listp (cdr range)))
5963 (setq num (- (cdr active) (- (1+ (cdr range))
5967 (if (numberp (car range))
5969 (setq num (+ num (- (1+ (cdr (car range)))
5970 (car (car range))))))
5971 (setq range (cdr range)))
5972 (setq num (- (cdr active) num))))
5973 ;; Update the number of unread articles.
5977 (length (cdr (assq 'tick (nth 3 info))))
5979 (cdr (assq 'dormant (nth 3 info)))))))
5980 ;; Update the group buffer.
5981 (gnus-group-update-group name t)))))))
5984 (defun gnus-methods-equal-p (m1 m2)
5985 (let ((m1 (or m1 gnus-select-method))
5986 (m2 (or m2 gnus-select-method)))
5988 (and (eq (car m1) (car m2))
5989 (or (not (memq 'address (assoc (symbol-name (car m1))
5990 gnus-valid-select-methods)))
5991 (equal (nth 1 m1) (nth 1 m2)))))))
5993 (defsubst gnus-header-value ()
5994 (buffer-substring (match-end 0) (gnus-point-at-eol)))
5996 (defun gnus-get-newsgroup-headers ()
5997 (setq gnus-article-internal-prepare-hook nil)
5998 (let ((cur nntp-server-buffer)
5999 (dependencies gnus-newsgroup-dependencies)
6001 headers char article id dep end)
6003 (set-buffer nntp-server-buffer)
6005 ;; Search to the beginning of the next header. Error messages
6006 ;; do not begin with 2 or 3.
6007 (while (re-search-forward "^[23][0-9]+ " nil t)
6008 (let ((header (make-vector 9 nil))
6009 (c (following-char))
6010 (case-fold-search t)
6012 from subject in-reply-to references ref)
6018 (header-set-number header (setq article (read cur)))
6019 ;; This implementation of this function, with nine
6020 ;; search-forwards instead of the one re-search-forward and
6021 ;; a case (which basically was the old function) is actually
6022 ;; about twice as fast, even though it looks messier. You
6023 ;; can't have everything, I guess. Speed and elegance
6024 ;; doesn't always come hand in hand.
6026 (narrow-to-region (point) (save-excursion
6027 (search-forward "\n.\n" nil t)))
6028 (if (search-forward "\nfrom: " nil t)
6029 (header-set-from header (gnus-header-value))
6030 (header-set-from header "(nobody)"))
6032 (if (search-forward "\nsubject: " nil t)
6033 (header-set-subject header (gnus-header-value))
6034 (header-set-subject header "(none)"))
6036 (and (search-forward "\nxref: " nil t)
6037 (header-set-xref header (gnus-header-value)))
6039 (and (search-forward "\nlines: " nil t)
6040 (header-set-lines header (read cur)))
6042 (and (search-forward "\ndate: " nil t)
6043 (header-set-date header (gnus-header-value)))
6045 (if (search-forward "\nmessage-id: " nil t)
6046 (header-set-id header (setq id (gnus-header-value)))
6047 ;; If there was no message-id, we just fake one to make
6048 ;; subsequent routines simpler.
6051 (setq id (concat "none+" (int-to-string
6052 (setq none-id (1+ none-id)))))))
6054 (if (search-forward "\nreferences: " nil t)
6056 (header-set-references header (gnus-header-value))
6057 (setq end (match-end 0))
6064 (search-backward ">" end t)
6067 (search-backward "<" end t)
6069 ;; Get the references from the in-reply-to header if there
6070 ;; ware no references and the in-reply-to header looks
6072 (if (and (search-forward "\nin-reply-to: " nil t)
6073 (setq in-reply-to (gnus-header-value))
6074 (string-match "<[^>]+>" in-reply-to))
6076 (header-set-references
6078 (setq ref (substring in-reply-to (match-beginning 0)
6080 (setq ref (downcase ref)))
6082 ;; We do some threading while we read the headers. The
6083 ;; message-id and the last reference are both entered into
6084 ;; the same hash table. Some tippy-toeing around has to be
6085 ;; done in case an article has arrived before the article
6086 ;; which it refers to.
6087 (if (boundp (setq dep (intern (downcase id) dependencies)))
6088 (if (car (symbol-value dep))
6089 ;; An article with this Message-ID has already
6090 ;; been seen, so we ignore this one, except we add
6091 ;; any additional Xrefs (in case the two articles
6092 ;; came from different servers.
6095 (car (symbol-value dep))
6096 (concat (or (header-xref (car (symbol-value dep))) "")
6097 (or (header-xref header) "")))
6099 (setcar (symbol-value dep) header))
6100 (set dep (list header)))
6103 (if (boundp (setq dep (intern ref dependencies)))
6104 (setcdr (symbol-value dep)
6105 (cons header (cdr (symbol-value dep))))
6106 (set dep (list nil header)))
6107 (setq headers (cons header headers))))
6108 (goto-char (point-max))))))
6109 (nreverse headers)))
6111 ;; The following macros and functions were written by Felix Lee
6112 ;; <flee@cse.psu.edu>.
6114 ;; This is almost 4x faster than (string-to-int (buffer-substring ... ))
6115 ;; primarily because of garbage collection. -jwz
6116 (defmacro gnus-read-integer (&optional point move-p)
6117 (` ((, (if move-p 'progn 'save-excursion))
6118 (,@ (if point (list (list 'goto-char point))))
6119 (if (and (<= (following-char) ?9)
6120 (>= (following-char) ?0))
6121 (read (current-buffer))
6124 (defmacro gnus-nov-skip-field ()
6125 '(search-forward "\t" eol 'end))
6127 (defmacro gnus-nov-field ()
6130 (progn (gnus-nov-skip-field) (1- (point)))))
6132 ;; Goes through the xover lines and returns a list of vectors
6133 (defun gnus-get-newsgroup-headers-xover (sequence)
6134 "Parse the news overview data in the server buffer, and return a
6135 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
6136 ;; Get the Xref when the users reads the articles since most/some
6137 ;; NNTP servers do not include Xrefs when using XOVER.
6138 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6139 (let ((cur nntp-server-buffer)
6140 (dependencies gnus-newsgroup-dependencies)
6142 number headers header)
6144 (set-buffer nntp-server-buffer)
6145 (goto-char (point-min))
6146 (while (and sequence (not (eobp)))
6147 (setq number (read cur))
6148 (while (and sequence (< (car sequence) number))
6149 (setq sequence (cdr sequence)))
6151 (eq number (car sequence))
6153 (setq sequence (cdr sequence))
6155 (inline (gnus-nov-parse-line number dependencies)))
6156 (setq headers (cons header headers)))))
6158 (setq headers (nreverse headers)))
6161 (defun gnus-nov-parse-line (number dependencies)
6162 "Point has to be after the number on the beginning of the line."
6164 header (eol (gnus-point-at-eol)) ref id dep)
6166 ;; overview: [num subject from date id refs chars lines misc]
6168 (narrow-to-region (point) eol)
6173 (gnus-nov-field) ; subject
6174 (gnus-nov-field) ; from
6175 (gnus-nov-field) ; date
6176 (setq id (or (gnus-nov-field)
6179 (setq none (1+ none)))))) ; id
6182 (let ((beg (point)))
6183 (search-forward "\t" eol)
6184 (if (search-backward ">" beg t)
6190 (search-backward "<" beg t)
6193 (gnus-nov-field)) ; refs
6194 (read (current-buffer)) ; chars
6195 (read (current-buffer)) ; lines
6196 (if (/= (following-char) ?\t)
6199 (gnus-nov-field)) ; misc
6204 ;; We build the thread tree.
6206 (if (boundp (setq dep (intern (downcase id) dependencies)))
6207 (if (car (symbol-value dep))
6208 ;; An article with this Message-ID has already been seen,
6209 ;; so we ignore this one, except we add any additional
6210 ;; Xrefs (in case the two articles came from different
6214 (car (symbol-value dep))
6215 (concat (or (header-xref (car (symbol-value dep))) "")
6216 (or (header-xref header) "")))
6218 (setcar (symbol-value dep) header))
6219 (set dep (list header))))
6222 (if (boundp (setq dep (intern (or ref "none")
6224 (setcdr (symbol-value dep)
6225 (cons header (cdr (symbol-value dep))))
6226 (set dep (list nil header)))))
6229 (defun gnus-article-get-xrefs ()
6230 "Fill in the Xref value in `gnus-current-headers', if necessary.
6231 This is meant to be called in `gnus-article-internal-prepare-hook'."
6232 (or (not gnus-use-cross-reference)
6233 (header-xref gnus-current-headers)
6234 (let ((case-fold-search t)
6237 (gnus-narrow-to-headers)
6238 (goto-char (point-min))
6239 (if (or (and (eq (downcase (following-char)) ?x)
6240 (looking-at "Xref:"))
6241 (search-forward "\nXref:" nil t))
6243 (goto-char (1+ (match-end 0)))
6244 (setq xref (buffer-substring (point)
6245 (progn (end-of-line) (point))))
6247 (set-buffer gnus-summary-buffer)
6248 (header-set-xref gnus-current-headers xref))))))))
6250 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
6251 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
6253 ;; Return a header specified by a NUMBER.
6254 (defun gnus-get-header-by-number (number)
6256 (set-buffer gnus-summary-buffer)
6257 (or gnus-newsgroup-headers-hashtb-by-number
6258 (gnus-make-headers-hashtable-by-number))
6259 (gnus-gethash (int-to-string number)
6260 gnus-newsgroup-headers-hashtb-by-number)))
6262 (defun gnus-make-headers-hashtable-by-number ()
6263 "Make hashtable for the variable gnus-newsgroup-headers by number."
6265 (set-buffer gnus-summary-buffer)
6266 (let ((headers gnus-newsgroup-headers)
6268 (setq gnus-newsgroup-headers-hashtb-by-number
6269 (gnus-make-hashtable (length headers)))
6271 (setq header (car headers))
6272 (gnus-sethash (int-to-string (header-number header))
6273 header gnus-newsgroup-headers-hashtb-by-number)
6274 (setq headers (cdr headers))))))
6276 (defun gnus-more-header-backward ()
6277 "Find new header backward."
6278 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6279 (artnum gnus-newsgroup-begin)
6281 (while (and (not header)
6283 (setq artnum (1- artnum))
6284 (setq header (gnus-read-header artnum)))
6287 (defun gnus-more-header-forward (&optional backward)
6288 "Find new header forward.
6289 If BACKWARD, find new header backward instead."
6291 (gnus-more-header-backward)
6292 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6293 (artnum gnus-newsgroup-end)
6295 (while (and (not header)
6297 (setq artnum (1+ artnum))
6298 (setq header (gnus-read-header artnum)))
6301 (defun gnus-extend-newsgroup (header &optional backward)
6302 "Extend newsgroup selection with HEADER.
6303 Optional argument BACKWARD means extend toward backward."
6305 (let ((artnum (header-number header)))
6306 (setq gnus-newsgroup-headers
6308 (cons header gnus-newsgroup-headers)
6309 (nconc gnus-newsgroup-headers (list header))))
6310 (setq gnus-newsgroup-unselected
6311 (delq artnum gnus-newsgroup-unselected))
6312 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
6313 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
6315 (defun gnus-summary-work-articles (n)
6316 "Return a list of articles to be worked upon. The prefix argument,
6317 the list of process marked articles, and the current article will be
6318 taken into consideration."
6320 (if (and n (numberp n))
6321 (let ((backward (< n 0))
6325 (setq articles (cons (gnus-summary-article-number)
6327 (gnus-summary-search-forward nil nil backward))
6329 (sort articles (function <)))
6330 (or (reverse gnus-newsgroup-processable)
6331 (list (gnus-summary-article-number))))))
6333 (defun gnus-summary-search-group (&optional backward use-level)
6334 "Search for next unread newsgroup.
6335 If optional argument BACKWARD is non-nil, search backward instead."
6337 (set-buffer gnus-group-buffer)
6339 ;; We don't want to alter current point of group mode buffer.
6340 (if (gnus-group-search-forward
6342 (if use-level (gnus-group-group-level) nil))
6343 (gnus-group-group-name)))))
6345 (defun gnus-summary-best-group (&optional exclude-group)
6346 "Find the name of the best unread group.
6347 If EXCLUDE-GROUP, do not go to this group."
6349 (set-buffer gnus-group-buffer)
6351 (gnus-group-best-unread-group exclude-group))))
6353 (defun gnus-summary-search-subject (&optional backward unread subject)
6354 "Search for article forward.
6355 If BACKWARD is non-nil, search backward.
6356 If UNREAD is non-nil, only unread articles are selected.
6357 If SUBJECT is non-nil, the article which has the same subject will be
6359 (let ((func (if backward 'previous-single-property-change
6360 'next-single-property-change))
6365 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
6366 (while (and (setq pos (funcall func (point) 'gnus-number))
6367 (goto-char (if backward (1- pos) pos))
6369 (not (and (or (not unread)
6370 (eq (get-text-property (point) 'gnus-mark)
6373 (equal (gnus-simplify-subject-re
6375 (gnus-simplify-subject-re
6378 'gnus-subject)))))))
6379 (if backward (if (bobp) nil (forward-char -1) t)
6380 (if (eobp) nil (forward-char 1) t))))
6382 (progn (goto-char beg) nil)
6384 (get-text-property (point) 'gnus-number)
6385 (gnus-summary-position-cursor)))))
6387 (defun gnus-summary-search-forward (&optional unread subject backward)
6388 "Search for article forward.
6389 If UNREAD is non-nil, only unread articles are selected.
6390 If SUBJECT is non-nil, the article which has the same subject will be
6392 If BACKWARD is non-nil, the search will be performed backwards instead."
6393 (gnus-summary-search-subject backward unread subject))
6395 (defun gnus-summary-search-backward (&optional unread subject)
6396 "Search for article backward.
6397 If 1st optional argument UNREAD is non-nil, only unread article is selected.
6398 If 2nd optional argument SUBJECT is non-nil, the article which has
6399 the same subject will be searched for."
6400 (gnus-summary-search-forward unread subject t))
6402 (defun gnus-summary-article-number (&optional number-or-nil)
6403 "The article number of the article on the current line.
6404 If there isn's an article number here, then we return the current
6407 (number (get-text-property
6408 (progn (beginning-of-line) (prog1 (point) (goto-char p)))
6410 (if number-or-nil number (or number gnus-current-article))))
6412 (defun gnus-summary-thread-level ()
6413 "The thread level of the article on the current line."
6414 (or (get-text-property (gnus-point-at-bol) 'gnus-thread)
6417 (defun gnus-summary-pseudo-article ()
6418 "The thread level of the article on the current line."
6419 (get-text-property (gnus-point-at-bol) 'gnus-pseudo))
6421 (defun gnus-summary-article-mark ()
6422 "The mark on the current line."
6423 (get-text-property (gnus-point-at-bol) 'gnus-mark))
6425 (defun gnus-summary-subject-string ()
6426 "Return current subject string or nil if nothing."
6427 (get-text-property (gnus-point-at-bol) 'gnus-subject))
6429 (defalias 'gnus-summary-score 'gnus-summary-article-score)
6430 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
6431 (defun gnus-summary-article-score ()
6432 "Return current article score."
6433 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
6434 gnus-summary-default-score 0))
6436 (defun gnus-summary-recenter ()
6437 "Center point in the summary window.
6438 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6439 displayed, no centering will be performed."
6440 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6441 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6442 (let ((top (cond ((< (window-height) 4) 0)
6443 ((< (window-height) 6) 1)
6446 ;; The user has to want it,
6447 gnus-auto-center-summary
6448 ;; the article buffer must be displayed,
6449 (get-buffer-window gnus-article-buffer)
6450 ;; there must be lines left to scroll forward,
6451 (zerop (save-excursion (forward-line (- (window-height) 1 top))))
6454 (get-buffer-window (current-buffer))
6455 (save-excursion (forward-line (- top)) (point))))))
6457 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
6458 (defun gnus-short-group-name (newsgroup)
6459 "Convert a long group name to an initialized form.
6460 The last part of the name is left intact: \"rec.arts.anime\" becomes
6464 (if (string-match "\\." newsgroup)
6466 (setq name (concat name (substring newsgroup 0 1))
6467 newsgroup (substring newsgroup (match-end 0))
6468 name (concat name ".")))
6469 (setq name (concat name newsgroup)
6474 (defun gnus-summary-jump-to-group (newsgroup)
6475 "Move point to NEWSGROUP in group mode buffer."
6476 ;; Keep update point of group mode buffer if visible.
6477 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6478 (save-window-excursion
6479 ;; Take care of tree window mode.
6480 (if (get-buffer-window gnus-group-buffer)
6481 (pop-to-buffer gnus-group-buffer))
6482 (gnus-group-jump-to-group newsgroup))
6484 ;; Take care of tree window mode.
6485 (if (get-buffer-window gnus-group-buffer)
6486 (pop-to-buffer gnus-group-buffer)
6487 (set-buffer gnus-group-buffer))
6488 (gnus-group-jump-to-group newsgroup))))
6490 ;; This function returns a list of article numbers based on the
6491 ;; difference between the ranges of read articles in this group and
6492 ;; the range of active articles.
6493 (defun gnus-list-of-unread-articles (group)
6494 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6495 (active (gnus-gethash group gnus-active-hashtb))
6497 unread first nlast unread)
6498 ;; If none are read, then all are unread.
6500 (setq first (car active))
6501 ;; If the range of read articles is a single range, then the
6502 ;; first unread article is the article after the last read
6503 ;; article. Sounds logical, doesn't it?
6504 (if (not (listp (cdr read)))
6505 (setq first (1+ (cdr read)))
6506 ;; `read' is a list of ranges.
6507 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
6508 (car (car read)))) 1)
6512 (while (< first nlast)
6513 (setq unread (cons first unread))
6514 (setq first (1+ first))))
6515 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
6516 (setq nlast (if (atom (car (cdr read)))
6518 (car (car (cdr read)))))
6519 (setq read (cdr read)))))
6520 ;; And add the last unread articles.
6521 (while (<= first last)
6522 (setq unread (cons first unread))
6523 (setq first (1+ first)))
6524 ;; Return the list of unread articles.
6528 ;; Various summary commands
6530 (defun gnus-summary-universal-argument ()
6531 "Perform any operation on all articles marked with the process mark."
6533 (gnus-set-global-variables)
6534 (let ((articles (reverse gnus-newsgroup-processable))
6536 (or articles (error "No articles marked"))
6537 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
6538 (error "Undefined key"))
6540 (gnus-summary-goto-subject (car articles))
6541 (command-execute func)
6542 (gnus-summary-remove-process-mark (car articles))
6543 (setq articles (cdr articles)))))
6545 (defun gnus-summary-toggle-truncation (arg)
6546 "Toggle truncation of summary lines.
6547 With arg, turn line truncation on iff arg is positive."
6549 (setq truncate-lines
6550 (if (null arg) (not truncate-lines)
6551 (> (prefix-numeric-value arg) 0)))
6554 (defun gnus-summary-reselect-current-group (all)
6555 "Once exit and then reselect the current newsgroup.
6556 The prefix argument ALL means to select all articles."
6558 (gnus-set-global-variables)
6559 (let ((current-subject (gnus-summary-article-number)))
6560 (gnus-summary-exit t)
6561 ;; We have to adjust the point of group mode buffer because the
6562 ;; current point was moved to the next unread newsgroup by
6564 (gnus-summary-jump-to-group gnus-newsgroup-name)
6565 (gnus-group-read-group all t)
6566 (gnus-summary-goto-subject current-subject)))
6568 (defun gnus-summary-rescan-group (all)
6569 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6571 (gnus-set-global-variables)
6572 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
6573 (let ((group gnus-newsgroup-name))
6574 (gnus-summary-exit t)
6575 (gnus-summary-jump-to-group group)
6577 (set-buffer gnus-group-buffer)
6578 (gnus-group-get-new-news-this-group 1))
6579 (gnus-summary-jump-to-group group)
6580 (gnus-group-read-group all)))
6582 (defun gnus-summary-exit (&optional temporary)
6583 "Exit reading current newsgroup, and then return to group selection mode.
6584 gnus-exit-group-hook is called with no arguments if that value is non-nil."
6586 (gnus-set-global-variables)
6587 (gnus-kill-save-kill-buffer)
6588 (let* ((group gnus-newsgroup-name)
6589 (quit-buffer (cdr (assoc 'quit-buffer (gnus-find-method-for-group
6590 gnus-newsgroup-name))))
6592 (method (car (gnus-find-method-for-group group)))
6593 (buf (current-buffer)))
6594 (if gnus-newsgroup-kill-headers
6595 (setq gnus-newsgroup-killed
6596 (gnus-compress-sequence
6598 (gnus-set-sorted-intersection
6599 (gnus-uncompress-range gnus-newsgroup-killed)
6600 (setq gnus-newsgroup-unselected
6601 (sort gnus-newsgroup-unselected '<)))
6602 (setq gnus-newsgroup-unreads
6603 (sort gnus-newsgroup-unreads '<))) t)))
6604 (or (listp (cdr gnus-newsgroup-killed))
6605 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6607 (headers gnus-newsgroup-headers))
6608 (gnus-close-group group)
6609 (run-hooks 'gnus-exit-group-hook)
6611 (gnus-update-read-articles
6612 group gnus-newsgroup-unreads gnus-newsgroup-unselected
6613 gnus-newsgroup-marked
6614 t gnus-newsgroup-replied gnus-newsgroup-expirable
6615 gnus-newsgroup-killed gnus-newsgroup-dormant
6616 gnus-newsgroup-bookmarks
6617 (and gnus-save-score gnus-newsgroup-scored))
6618 (and gnus-use-cross-reference
6619 (gnus-mark-xrefs-as-read
6620 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
6621 ;; Do not switch windows but change the buffer to work.
6622 (set-buffer gnus-group-buffer)
6623 (or (eq 'nndigest method)
6624 (gnus-group-update-group group)))
6625 ;; Make sure where I was, and go to next newsgroup.
6626 (if (eq method 'nndigest)
6628 (gnus-group-jump-to-group group)
6629 (gnus-group-next-unread-group 1))
6631 ;; If exiting temporary, caller should adjust group mode
6632 ;; buffer point by itself.
6634 ;; We set all buffer-local variables to nil. It is unclear why
6635 ;; this is needed, but if we don't, buffer-local variables are
6636 ;; not garbage-collected, it seems. This would the lead to en
6637 ;; ever-growing Emacs.
6639 (gnus-summary-clear-local-variables)
6640 ;; We clear the global counterparts of the buffer-local
6641 ;; variables as well, just to be on the safe side.
6642 (set-buffer gnus-group-buffer)
6643 (gnus-summary-clear-local-variables)
6644 (gnus-configure-windows 'newsgroups t)
6645 ;; Return to group mode buffer.
6646 (and (get-buffer buf)
6647 (eq mode 'gnus-summary-mode)
6649 (if (get-buffer gnus-article-buffer)
6650 (bury-buffer gnus-article-buffer))
6651 (setq gnus-current-select-method gnus-select-method)
6652 (pop-to-buffer gnus-group-buffer)
6653 (if (and quit-buffer (buffer-name quit-buffer))
6655 (switch-to-buffer quit-buffer)
6656 (gnus-set-global-variables)
6657 (gnus-configure-windows 'summary))))))
6659 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6660 (defun gnus-summary-exit-no-update (&optional no-questions)
6661 "Quit reading current newsgroup without updating read article info."
6663 (let* ((group gnus-newsgroup-name)
6664 (quit-buffer (cdr (assoc 'quit-buffer
6665 (gnus-find-method-for-group group)))))
6666 (if (or no-questions
6668 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
6670 (gnus-close-group group)
6671 (gnus-summary-clear-local-variables)
6672 (set-buffer gnus-group-buffer)
6673 (gnus-summary-clear-local-variables)
6674 ;; Return to group selection mode.
6675 (gnus-configure-windows 'newsgroups)
6676 (if (get-buffer gnus-summary-buffer)
6677 (kill-buffer gnus-summary-buffer))
6678 (if (get-buffer gnus-article-buffer)
6679 (bury-buffer gnus-article-buffer))
6680 (pop-to-buffer gnus-group-buffer)
6681 (gnus-group-jump-to-group group)
6682 (gnus-group-next-group 1)
6683 (if (and quit-buffer (buffer-name quit-buffer))
6685 (switch-to-buffer quit-buffer)
6686 (gnus-configure-windows 'summary)))))))
6688 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6689 (defun gnus-summary-fetch-faq (group)
6690 "Fetch the FAQ for the current group."
6691 (interactive (list gnus-newsgroup-name))
6692 (gnus-configure-windows 'article)
6693 (pop-to-buffer gnus-article-buffer)
6694 (find-file (concat gnus-group-faq-directory group)))
6696 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6697 (defun gnus-summary-describe-group (force)
6698 "Describe the current newsgroup."
6700 (gnus-group-describe-group force gnus-newsgroup-name))
6702 (defun gnus-summary-describe-briefly ()
6703 "Describe summary mode commands briefly."
6706 (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")))
6708 ;; Walking around group mode buffer from summary mode.
6710 (defun gnus-summary-next-group (&optional no-article group backward)
6711 "Exit current newsgroup and then select next unread newsgroup.
6712 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
6713 If BACKWARD, go to previous group instead."
6715 (gnus-set-global-variables)
6716 (let ((ingroup gnus-newsgroup-name)
6717 (sumbuf (current-buffer))
6719 (gnus-summary-exit t) ;Update all information.
6721 (or (and (numberp (setq num (car (gnus-gethash
6722 group gnus-newsrc-hashtb))))
6726 (gnus-group-jump-to-group group)
6728 (gnus-group-jump-to-group ingroup))
6729 (let ((group (or group (gnus-summary-search-group backward)))
6730 (buf gnus-summary-buffer))
6732 (gnus-summary-exit-no-update t)
6733 (message "Selecting %s..." group)
6734 ;; We are now in group mode buffer.
6735 ;; Make sure group mode buffer point is on GROUP.
6736 (gnus-group-jump-to-group group)
6738 (gnus-summary-read-group group nil no-article buf)
6739 (and (string= gnus-newsgroup-name ingroup)
6740 (bufferp sumbuf) (buffer-name sumbuf)
6742 (set-buffer (setq gnus-summary-buffer sumbuf))
6743 (gnus-summary-exit-no-update t))))))))
6745 (defun gnus-summary-prev-group (no-article)
6746 "Exit current newsgroup and then select previous unread newsgroup.
6747 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6749 (gnus-summary-next-group no-article nil t))
6751 ;; Walking around summary lines.
6753 (defun gnus-summary-first-subject (unread)
6754 "Go to the first unread subject.
6755 If UNREAD is non-nil, go to the first unread article.
6756 Returns nil if there are no unread articles."
6758 (let ((begin (point)))
6760 (if (not (gnus-goto-char
6761 (text-property-any (point-min) (point-max)
6762 'gnus-mark gnus-unread-mark)))
6764 ;; If there is no unread articles, stay where you are.
6766 (message "No more unread articles")
6769 (goto-char (point-min)))))
6771 (defun gnus-summary-next-subject (n &optional unread)
6772 "Go to next N'th summary line.
6773 If N is negative, go to the previous N'th subject line.
6774 If UNREAD is non-nil, only unread articles are selected.
6775 The difference between N and the actual number of steps taken is
6778 (let ((backward (< n 0))
6781 (gnus-summary-search-forward unread nil backward))
6783 (gnus-summary-recenter)
6784 (if (/= 0 n) (message "No more%s articles" (if unread " unread" "")))
6785 (gnus-summary-position-cursor)
6788 (defun gnus-summary-next-unread-subject (n)
6789 "Go to next N'th unread summary line."
6791 (gnus-summary-next-subject n t))
6793 (defun gnus-summary-prev-subject (n &optional unread)
6794 "Go to previous N'th summary line.
6795 If optional argument UNREAD is non-nil, only unread article is selected."
6797 (gnus-summary-next-subject (- n) unread))
6799 (defun gnus-summary-prev-unread-subject (n)
6800 "Go to previous N'th unread summary line."
6802 (gnus-summary-next-subject (- n) t))
6804 (defun gnus-summary-goto-subject (article)
6805 "Go the subject line of ARTICLE."
6809 (completing-read "Article number: "
6813 (int-to-string (header-number headers))))
6814 gnus-newsgroup-headers)
6815 nil 'require-match))))
6816 (or article (error "No article number"))
6817 (if (or (eq article (gnus-summary-article-number t))
6820 (point-min) (point-max) 'gnus-number article)))
6823 ;; Walking around summary lines with displaying articles.
6825 (defun gnus-summary-expand-window ()
6826 "Expand summary window to show headers full window."
6828 (gnus-set-global-variables)
6829 (gnus-configure-windows 'summary)
6830 (pop-to-buffer gnus-summary-buffer))
6832 (defun gnus-summary-display-article (article &optional all-header)
6833 "Display ARTICLE in article buffer."
6834 (gnus-set-global-variables)
6837 (gnus-article-prepare article all-header)
6838 (if (eq (gnus-summary-article-mark) ?Z)
6841 (gnus-summary-position-cursor)))
6842 (run-hooks 'gnus-select-article-hook)
6843 (gnus-summary-recenter)
6844 ; (set-window-point (get-buffer-window (current-buffer)) (point-max))
6846 (gnus-summary-goto-subject article)
6847 ;; Successfully display article.
6848 (gnus-summary-update-line)
6851 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6852 "Select the current article.
6853 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6854 non-nil, the article will be re-fetched even if it already present in
6855 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6857 (and (not pseudo) (gnus-summary-pseudo-article)
6858 (error "This is a pseudo-article."))
6859 (let ((article (or article (gnus-summary-article-number)))
6860 (all-headers (not (not all-headers)))) ;Must be T or NIL.
6861 (if (or (null gnus-current-article)
6862 (null gnus-article-current)
6863 (/= article (cdr gnus-article-current))
6864 (not (equal (car gnus-article-current) gnus-newsgroup-name))
6866 ;; The requested article is different from the current article.
6868 (gnus-summary-display-article article all-headers)
6870 (if all-headers (gnus-article-show-all-headers))
6871 (gnus-configure-windows 'article)
6872 (pop-to-buffer gnus-summary-buffer)
6875 (defun gnus-summary-set-current-mark (&optional current-mark)
6876 "Obsolete function."
6879 (defun gnus-summary-next-article (unread &optional subject backward)
6880 "Select the next article.
6881 If UNREAD, only unread articles are selected.
6882 If SUBJECT, only articles with SUBJECT are selected.
6883 If BACKWARD, the previous article is selected instead of the next."
6885 (let ((opoint (point))
6886 (method (car (gnus-find-method-for-group gnus-newsgroup-name)))
6889 ;; Is there such an article?
6890 ((gnus-summary-display-article
6891 (gnus-summary-search-forward unread subject backward))
6892 (gnus-summary-position-cursor))
6893 ;; If not, we try the first unread, if that is wanted.
6895 gnus-auto-select-same
6896 (gnus-summary-first-unread-article))
6897 (message "Wrapped"))
6898 ;; Try to get next/previous article not displayed in this group.
6899 ((and gnus-auto-extend-newsgroup
6900 (not unread) (not subject)
6901 (setq header (gnus-more-header-forward backward)))
6902 (gnus-extend-newsgroup header backward)
6903 (let ((buffer-read-only nil))
6904 (goto-char (if backward (point-min) (point-max)))
6905 (gnus-summary-prepare-threads (list header) 0))
6906 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
6907 gnus-newsgroup-end)))
6908 ;; Go to next/previous group.
6910 (gnus-summary-jump-to-group gnus-newsgroup-name)
6911 (let ((cmd (aref (this-command-keys) 0))
6913 (if (eq gnus-keep-same-level 'best)
6914 (gnus-summary-best-group gnus-newsgroup-name)
6915 (gnus-summary-search-group backward gnus-keep-same-level))))
6916 ;; Keep just the event type of CMD.
6917 (and (listp cmd) (setq cmd (car cmd)))
6918 ;; Select next unread newsgroup automagically.
6920 ((not gnus-auto-select-next)
6921 (message "No more%s articles" (if unread " unread" "")))
6922 ((eq gnus-auto-select-next 'quietly)
6924 (if (eq method 'nndigest)
6926 (message "No more%s articles (%s)..."
6927 (if unread " unread" "")
6928 (if group (concat "selecting " group)
6930 (gnus-summary-next-group nil group backward)))
6932 (let ((keystrokes '(?\C-n ?\C-p))
6934 (while (or (null key) (memq key keystrokes))
6936 "No more%s articles%s" (if unread " unread" "")
6937 (if (and group (not (eq method 'nndigest)))
6938 (format " (Type %s for %s [%s])"
6939 (single-key-description cmd) group
6940 (car (gnus-gethash group gnus-newsrc-hashtb)))
6941 (format " (Type %s to exit %s)"
6942 (single-key-description cmd)
6943 gnus-newsgroup-name)))
6944 ;; Confirm auto selection.
6945 (let* ((event (read-event)))
6946 (setq key (if (listp event) (car event) event))
6947 (if (member key keystrokes)
6948 (let ((obuf (current-buffer)))
6949 (switch-to-buffer gnus-group-buffer)
6950 (gnus-group-jump-to-group group)
6951 (execute-kbd-macro (char-to-string key))
6952 (setq group (gnus-group-group-name))
6953 (switch-to-buffer obuf)))))
6955 (if (or (not group) (eq method 'nndigest))
6957 (gnus-summary-next-group nil group backward))
6958 (setq unread-command-events (list key)))))))))))
6960 (defun gnus-summary-next-unread-article ()
6961 "Select unread article after current one."
6963 (gnus-summary-next-article t (and gnus-auto-select-same
6964 (gnus-summary-subject-string))))
6966 (defun gnus-summary-prev-article (unread &optional subject)
6967 "Select the article after the current one.
6968 If UNREAD is non-nil, only unread articles are selected."
6970 (gnus-summary-next-article unread subject t))
6972 (defun gnus-summary-prev-unread-article ()
6973 "Select unred article before current one."
6975 (gnus-summary-prev-article t (and gnus-auto-select-same
6976 (gnus-summary-subject-string))))
6978 (defun gnus-summary-next-page (lines &optional circular)
6979 "Show next page of selected article.
6980 If end of article, select next article.
6981 Argument LINES specifies lines to be scrolled up.
6982 If CIRCULAR is non-nil, go to the start of the article instead of
6983 instead of selecting the next article when reaching the end of the
6986 (setq gnus-summary-buffer (current-buffer))
6987 (let ((article (gnus-summary-article-number))
6989 (if (or (null gnus-current-article)
6990 (null gnus-article-current)
6991 (/= article (cdr gnus-article-current))
6992 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6993 ;; Selected subject is different from current article's.
6994 (gnus-summary-display-article article)
6995 (gnus-configure-windows 'article)
6996 (pop-to-buffer gnus-summary-buffer)
6997 (gnus-eval-in-buffer-window
6999 (setq endp (gnus-article-next-page lines)))
7002 (gnus-summary-beginning-of-article))
7004 (message "End of message"))
7006 (gnus-summary-next-unread-article))))))
7007 (gnus-summary-position-cursor))
7009 (defun gnus-summary-prev-page (lines)
7010 "Show previous page of selected article.
7011 Argument LINES specifies lines to be scrolled down."
7013 (let ((article (gnus-summary-article-number)))
7014 (if (or (null gnus-current-article)
7015 (null gnus-article-current)
7016 (/= article (cdr gnus-article-current))
7017 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7018 ;; Selected subject is different from current article's.
7019 (gnus-summary-display-article article)
7020 (gnus-configure-windows 'article)
7021 (pop-to-buffer gnus-summary-buffer)
7022 (gnus-eval-in-buffer-window gnus-article-buffer
7023 (gnus-article-prev-page lines))))
7024 (gnus-summary-position-cursor))
7026 (defun gnus-summary-scroll-up (lines)
7027 "Scroll up (or down) one line current article.
7028 Argument LINES specifies lines to be scrolled up (or down if negative)."
7030 (or (gnus-summary-select-article nil nil 'pseudo)
7031 (gnus-eval-in-buffer-window
7034 (if (gnus-article-next-page lines)
7035 (message "End of message")))
7037 (gnus-article-prev-page (- lines))))))
7038 (gnus-summary-position-cursor))
7040 (defun gnus-summary-next-same-subject ()
7041 "Select next article which has the same subject as current one."
7043 (gnus-summary-next-article nil (gnus-summary-subject-string)))
7045 (defun gnus-summary-prev-same-subject ()
7046 "Select previous article which has the same subject as current one."
7048 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
7050 (defun gnus-summary-next-unread-same-subject ()
7051 "Select next unread article which has the same subject as current one."
7053 (gnus-summary-next-article t (gnus-summary-subject-string)))
7055 (defun gnus-summary-prev-unread-same-subject ()
7056 "Select previous unread article which has the same subject as current one."
7058 (gnus-summary-prev-article t (gnus-summary-subject-string)))
7060 (defun gnus-summary-first-unread-article ()
7061 "Select the first unread article.
7062 Return nil if there are no unread articles."
7065 (if (gnus-summary-first-subject t)
7066 (gnus-summary-display-article (gnus-summary-article-number)))
7067 (gnus-summary-position-cursor)))
7069 (defun gnus-summary-best-unread-article ()
7070 "Select the unread article with the highest score."
7072 (gnus-set-global-variables)
7073 (let ((scored gnus-newsgroup-scored)
7077 (or (> best (cdr (car scored)))
7078 (and (memq (setq art (car (car scored))) gnus-newsgroup-unreads)
7079 (not (memq art gnus-newsgroup-marked))
7080 (not (memq art gnus-newsgroup-dormant))
7081 (if (= best (cdr (car scored)))
7082 (setq article (min art article))
7084 (setq best (cdr (car scored))))))
7085 (setq scored (cdr scored)))
7087 (gnus-summary-goto-article article)
7088 (gnus-summary-first-unread-article))
7089 (gnus-summary-position-cursor)))
7091 (defun gnus-summary-goto-article (article &optional all-headers)
7092 "Fetch ARTICLE and display it if it exists.
7093 If ALL-HEADERS is non-nil, no header lines are hidden."
7099 (mapcar (lambda (headers) (list (int-to-string (header-number headers))))
7100 gnus-newsgroup-headers)
7101 nil 'require-match))))
7102 (if (gnus-summary-goto-subject article)
7103 (gnus-summary-display-article article all-headers))
7104 (gnus-summary-position-cursor))
7106 (defun gnus-summary-goto-last-article ()
7107 "Go to the last article."
7109 (if gnus-last-article
7110 (gnus-summary-goto-article gnus-last-article))
7111 (gnus-summary-position-cursor))
7113 (defun gnus-summary-pop-article (number)
7114 "Pop one article off the history and go to the previous.
7115 NUMBER articles will be popped off."
7118 (setq gnus-newsgroup-history
7119 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7121 (gnus-summary-goto-article (car to))
7122 (error "Article history empty")))
7123 (gnus-summary-position-cursor))
7125 ;; Summary article oriented commands
7127 (defun gnus-summary-refer-parent-article (n)
7128 "Refer parent article N times.
7129 The difference between N and the number of articles fetched is returned."
7131 (gnus-set-global-variables)
7135 (let ((ref (header-references (gnus-get-header-by-number
7136 (gnus-summary-article-number)))))
7137 (if (and ref (not (equal ref ""))
7138 (string-match "<[^<>]*>[ \t]*$" ref))
7139 (gnus-summary-refer-article
7140 (substring ref (match-beginning 0) (match-end 0))))))
7142 (or (zerop n) (message "No references in article or expired article."))
7143 (gnus-summary-position-cursor)
7146 (defun gnus-summary-refer-article (message-id)
7147 "Refer article specified by MESSAGE-ID.
7148 NOTE: This command only works with newsgroup that use NNTP."
7149 (interactive "sMessage-ID: ")
7150 (if (or (not (stringp message-id))
7151 (zerop (length message-id)))
7153 ;; Construct the correct Message-ID if necessary.
7154 ;; Suggested by tale@pawl.rpi.edu.
7155 (or (string-match "^<" message-id)
7156 (setq message-id (concat "<" message-id)))
7157 (or (string-match ">$" message-id)
7158 (setq message-id (concat message-id ">")))
7159 (let ((header (car (gnus-gethash (downcase message-id)
7160 gnus-newsgroup-dependencies))))
7162 (gnus-summary-goto-article (header-number header))
7163 (let ((gnus-override-method gnus-refer-article-method))
7164 (if (gnus-article-prepare
7165 message-id nil (gnus-read-header message-id))
7167 (gnus-summary-insert-line
7168 nil gnus-current-headers 0 nil gnus-read-mark nil nil
7169 (header-subject gnus-current-headers))
7171 (gnus-summary-position-cursor)
7172 (gnus-summary-update-line)
7174 (message "No such references")
7177 (defun gnus-summary-enter-digest-group ()
7178 "Enter a digest group based on the current article."
7180 (gnus-summary-select-article)
7181 (let ((name (format "%s/%d"
7182 (gnus-group-prefixed-name
7183 gnus-newsgroup-name (list 'nndigest ""))
7184 gnus-current-article))
7185 (buf (current-buffer)))
7186 (set-buffer gnus-group-buffer)
7189 (list t nil (list name 3 nil nil
7190 (list 'nndigest gnus-article-buffer
7191 (cons 'quit-buffer buf))))
7193 (gnus-group-read-group t nil name)))
7195 (defun gnus-summary-isearch-article ()
7196 "Do incremental search forward on current article."
7198 (gnus-summary-select-article)
7199 (gnus-eval-in-buffer-window gnus-article-buffer
7202 (defun gnus-summary-search-article-forward (regexp)
7203 "Search for an article containing REGEXP forward.
7204 gnus-select-article-hook is not called during the search."
7207 (concat "Search forward (regexp): "
7208 (if gnus-last-search-regexp
7209 (concat "(default " gnus-last-search-regexp ") "))))))
7210 (if (string-equal regexp "")
7211 (setq regexp (or gnus-last-search-regexp ""))
7212 (setq gnus-last-search-regexp regexp))
7213 (if (gnus-summary-search-article regexp nil)
7214 (gnus-eval-in-buffer-window
7217 (error "Search failed: \"%s\"" regexp)))
7219 (defun gnus-summary-search-article-backward (regexp)
7220 "Search for an article containing REGEXP backward.
7221 gnus-select-article-hook is not called during the search."
7224 (concat "Search backward (regexp): "
7225 (if gnus-last-search-regexp
7226 (concat "(default " gnus-last-search-regexp ") "))))))
7227 (if (string-equal regexp "")
7228 (setq regexp (or gnus-last-search-regexp ""))
7229 (setq gnus-last-search-regexp regexp))
7230 (if (gnus-summary-search-article regexp t)
7231 (gnus-eval-in-buffer-window
7234 (error "Search failed: \"%s\"" regexp)))
7236 (defun gnus-summary-search-article (regexp &optional backward)
7237 "Search for an article containing REGEXP.
7238 Optional argument BACKWARD means do search for backward.
7239 gnus-select-article-hook is not called during the search."
7240 (let ((gnus-select-article-hook nil) ;Disable hook.
7241 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7244 (function re-search-backward) (function re-search-forward)))
7247 ;; Hidden thread subtrees must be searched for ,too.
7248 (gnus-summary-show-all-threads)
7249 (if (eobp) (forward-line -1))
7250 ;; First of all, search current article.
7251 ;; We don't want to read article again from NNTP server nor reset
7253 (gnus-summary-select-article)
7254 (message "Searching article: %d..." gnus-current-article)
7255 (setq last gnus-current-article)
7256 (gnus-eval-in-buffer-window gnus-article-buffer
7259 ;; Begin search from current point.
7260 (setq found (funcall re-search regexp nil t))))
7261 ;; Then search next articles.
7262 (while (and (not found)
7263 (gnus-summary-display-article
7264 (gnus-summary-search-subject backward nil nil)))
7265 (message "Searching article: %d..." gnus-current-article)
7266 (gnus-eval-in-buffer-window gnus-article-buffer
7269 (goto-char (if backward (point-max) (point-min)))
7270 (setq found (funcall re-search regexp nil t)))))
7272 ;; Adjust article pointer.
7273 (or (eq last gnus-current-article)
7274 (setq gnus-last-article last))
7275 ;; Return T if found such article.
7278 (defun gnus-summary-execute-command (header regexp command &optional backward)
7279 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7280 If HEADER is an empty string (or nil), the match is done on the entire
7281 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7283 (list (let ((completion-ignore-case t))
7286 (mapcar (string) (list string)
7287 '("Number" "Subject" "From" "Lines" "Date"
7288 "Message-ID" "Xref" "References")
7289 nil 'require-match)))
7290 (read-string "Regexp: ")
7291 (read-key-sequence "Command: ")
7292 current-prefix-arg))
7293 ;; Hidden thread subtrees must be searched as well.
7294 (gnus-summary-show-all-threads)
7295 ;; We don't want to change current point nor window configuration.
7297 (save-window-excursion
7298 (message "Executing %s..." (key-description command))
7299 ;; We'd like to execute COMMAND interactively so as to give arguments.
7300 (gnus-execute header regexp
7302 (call-interactively '(, (key-binding command)))))
7304 (message "Executing %s... done" (key-description command)))))
7306 (defun gnus-summary-beginning-of-article ()
7307 "Scroll the article back to the beginning."
7309 (gnus-summary-select-article)
7310 (gnus-eval-in-buffer-window
7313 (goto-char (point-min))
7314 (and gnus-break-pages (gnus-narrow-to-page))))
7316 (defun gnus-summary-end-of-article ()
7317 "Scroll to the end of the article."
7319 (gnus-summary-select-article)
7320 (gnus-eval-in-buffer-window
7323 (goto-char (point-max))
7324 (and gnus-break-pages (gnus-narrow-to-page))))
7326 (defun gnus-summary-show-article ()
7327 "Force re-fetching of the current article."
7329 (gnus-summary-select-article gnus-have-all-headers t t))
7331 (defun gnus-summary-toggle-header (arg)
7332 "Show the headers if they are hidden, or hide them if they are shown.
7333 If ARG is a positive number, show the entire header.
7334 If ARG is a negative number, hide the unwanted header lines."
7336 (gnus-set-global-variables)
7338 (set-buffer gnus-article-buffer)
7339 (let ((buffer-read-only nil))
7341 (if (> arg 0) (remove-text-properties 1 (point-max) '(invisible t))
7342 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
7343 (if (text-property-any 1 (point-max) 'invisible t)
7344 (remove-text-properties 1 (point-max) '(invisible t))
7345 (let ((gnus-have-all-headers nil))
7346 (run-hooks 'gnus-article-display-hook))))
7347 (set-window-point (get-buffer-window (current-buffer)) 1))))
7349 (defun gnus-summary-show-all-headers ()
7350 "Make all header lines visible."
7352 (gnus-article-show-all-headers))
7354 (defun gnus-summary-toggle-mime (arg)
7355 "Toggle MIME processing.
7356 If ARG is a positive number, turn MIME processing on."
7358 (setq gnus-show-mime
7359 (if (null arg) (not gnus-show-mime)
7360 (> (prefix-numeric-value arg) 0)))
7361 (gnus-summary-select-article t 'force))
7363 (defun gnus-summary-caesar-message (rotnum)
7364 "Caesar rotates all letters of current message by 13/47 places.
7365 With prefix arg, specifies the number of places to rotate each letter forward.
7366 Caesar rotates Japanese letters by 47 places in any case."
7368 (gnus-summary-select-article)
7369 (let ((mail-header-separator "")) ; !!! Is this necessary?
7370 (gnus-overload-functions)
7371 (gnus-eval-in-buffer-window
7375 ;; We don't want to jump to the beginning of the message.
7376 ;; `save-excursion' does not do its job.
7377 (move-to-window-line 0)
7378 (let ((last (point)))
7379 (news-caesar-buffer-body rotnum)
7383 (defun gnus-summary-stop-page-breaking ()
7384 "Stop page breaking in the current article."
7386 (gnus-summary-select-article)
7387 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
7389 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
7391 (defun gnus-summary-move-article (n &optional to-newsgroup select-method)
7392 "Move the current article to a different newsgroup.
7393 If N is a positive number, move the N next articles.
7394 If N is a negative number, move the N previous articles.
7395 If N is nil and any articles have been marked with the process mark,
7396 move those articles instead.
7397 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7398 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
7399 re-spool using this method.
7400 For this function to work, both the current newsgroup and the
7401 newsgroup that you want to move to have to support the `request-move'
7402 and `request-accept' functions. (Ie. mail newsgroups at present.)"
7404 (gnus-set-global-variables)
7405 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
7406 (error "The current newsgroup does not support article moving"))
7407 (let ((articles (gnus-summary-work-articles n))
7408 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7410 (if (and (not to-newsgroup) (not select-method))
7413 (format "Where do you want to move %s? %s"
7414 (if (> (length articles) 1)
7415 (format "these %d articles" (length articles))
7417 (if gnus-current-move-group
7418 (format "(%s default) " gnus-current-move-group)
7420 gnus-active-hashtb nil nil prefix)))
7421 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
7422 (setq to-newsgroup (or gnus-current-move-group "")))
7423 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
7424 (error "No such group: %s" to-newsgroup))
7425 (setq gnus-current-move-group to-newsgroup)
7426 (or (gnus-check-backend-function 'request-accept-article
7427 (or select-method to-newsgroup))
7428 (error "%s does not support article moving" to-newsgroup))
7429 (message "Moving to %s: %s..." (or select-method to-newsgroup) articles)
7432 (gnus-request-move-article
7433 (car articles) ; Article to move
7434 gnus-newsgroup-name ; From newsgrouo
7435 (nth 1 (gnus-find-method-for-group
7436 gnus-newsgroup-name)) ; Server
7437 (list 'gnus-request-accept-article
7439 (quote select-method)
7441 (not (cdr articles))) ; Accept form
7442 (not (cdr articles)))) ; Only save nov last time
7443 (let* ((buffer-read-only nil)
7446 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7448 (gnus-group-prefixed-name
7450 (if select-method (list select-method "")
7451 (gnus-find-method-for-group to-newsgroup)))
7452 gnus-newsrc-hashtb)))
7453 (info (nth 2 entry))
7454 (article (car articles))
7455 (marked (nth 3 info)))
7456 (gnus-summary-goto-subject article)
7458 (delete-region (point)
7459 (progn (forward-line 1) (point)))
7460 (if (not (memq article gnus-newsgroup-unreads))
7461 (setcar (cdr (cdr info))
7462 (gnus-add-to-range (nth 2 info)
7463 (list (cdr art-group)))))
7464 ;; Copy any marks over to the new group.
7465 (let ((marks '((tick . gnus-newsgroup-marked)
7466 (dormant . gnus-newsgroup-dormant)
7467 (expire . gnus-newsgroup-expirable)
7468 (bookmark . gnus-newsgroup-bookmarks)
7469 ; (score . gnus-newsgroup-scored)
7470 (reply . gnus-newsgroup-replied)))
7471 (to-article (cdr art-group)))
7473 (if (memq article (symbol-value (cdr (car marks))))
7474 (gnus-add-marked-articles
7475 (car info) (car (car marks)) (list to-article) info))
7476 (setq marks (cdr marks))))
7477 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7478 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7479 (setq gnus-newsgroup-dormant
7480 (delq article gnus-newsgroup-dormant)))
7481 (message "Couldn't move article %s" (car articles)))
7482 (gnus-summary-remove-process-mark (car articles))
7483 (setq articles (cdr articles)))))
7485 (defun gnus-summary-respool-article (n &optional respool-method)
7486 "Respool the current article.
7487 The article will be squeezed through the mail spooling process again,
7488 which means that it will be put in some mail newsgroup or other
7489 depending on `nnmail-split-methods'.
7490 If N is a positive number, respool the N next articles.
7491 If N is a negative number, respool the N previous articles.
7492 If N is nil and any articles have been marked with the process mark,
7493 respool those articles instead.
7495 Respooling can be done both from mail groups and \"real\" newsgroups.
7496 In the former case, the articles in question will be moved from the
7497 current group into whatever groups they are destined to. In the
7498 latter case, they will be copied into the relevant groups."
7500 (gnus-set-global-variables)
7501 (let ((respool-methods (gnus-methods-using 'respool)))
7503 (setq respool-method
7505 "What method do you want to use when respooling? "
7506 respool-methods nil t)))
7507 (if (assoc (symbol-name
7508 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7510 (gnus-summary-copy-article n nil (intern respool-method)))
7511 (gnus-summary-move-article n nil (intern respool-method))))
7513 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
7514 (defun gnus-summary-copy-article (n &optional to-newsgroup select-method)
7515 "Move the current article to a different newsgroup.
7516 If N is a positive number, move the N next articles.
7517 If N is a negative number, move the N previous articles.
7518 If N is nil and any articles have been marked with the process mark,
7519 move those articles instead.
7520 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7521 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
7522 re-spool using this method.
7523 For this function to work, the newsgroup that you want to move to have
7524 to support the `request-move' and `request-accept'
7525 functions. (Ie. mail newsgroups at present.)"
7527 (gnus-set-global-variables)
7528 (let ((articles (gnus-summary-work-articles n))
7529 (copy-buf (get-buffer-create "*copy work*"))
7530 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7532 (buffer-disable-undo copy-buf)
7533 (if (and (not to-newsgroup) (not select-method))
7536 (format "Where do you want to copy %s? %s"
7537 (if (> (length articles) 1)
7538 (format "these %d articles" (length articles))
7540 (if gnus-current-move-group
7541 (format "(%s default) " gnus-current-move-group)
7543 gnus-active-hashtb nil nil prefix)))
7544 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
7545 (setq to-newsgroup (or gnus-current-move-group "")))
7546 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
7547 (error "No such group: %s" to-newsgroup))
7548 (setq gnus-current-move-group to-newsgroup)
7549 (or (gnus-check-backend-function 'request-accept-article
7550 (or select-method to-newsgroup))
7551 (error "%s does not support article copying" to-newsgroup))
7552 (message "Copying to %s: %s..." (or select-method to-newsgroup) articles)
7556 (set-buffer copy-buf)
7557 (gnus-request-article-this-buffer
7558 (car articles) gnus-newsgroup-name)
7559 (gnus-request-accept-article
7560 (if select-method (quote select-method) to-newsgroup)
7561 (not (cdr articles)))))
7564 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7566 (gnus-group-prefixed-name
7568 (if select-method (list select-method "")
7569 (gnus-find-method-for-group to-newsgroup)))
7570 gnus-newsrc-hashtb)))
7571 (info (nth 2 entry))
7572 (article (car articles))
7573 (marked (nth 3 info)))
7574 (if (not (memq article gnus-newsgroup-unreads))
7575 (setcar (cdr (cdr info))
7576 (gnus-add-to-range (nth 2 info)
7577 (list (cdr art-group)))))
7578 ;; Copy any marks over to the new group.
7579 (let ((marks '((tick . gnus-newsgroup-marked)
7580 (dormant . gnus-newsgroup-dormant)
7581 (expire . gnus-newsgroup-expirable)
7582 (bookmark . gnus-newsgroup-bookmarks)
7583 ; (score . gnus-newsgroup-scored)
7584 (reply . gnus-newsgroup-replied)))
7585 (to-article (cdr art-group)))
7587 (if (memq article (symbol-value (cdr (car marks))))
7588 (gnus-add-marked-articles
7589 (car info) (car (car marks)) (list to-article) info))
7590 (setq marks (cdr marks)))))
7591 (message "Couldn't copy article %s" (car articles)))
7592 (gnus-summary-remove-process-mark (car articles))
7593 (setq articles (cdr articles)))
7594 (kill-buffer copy-buf)))
7596 (defun gnus-summary-expire-articles ()
7597 "Expire all articles that are marked as expirable in the current group."
7599 (if (and gnus-newsgroup-expirable
7600 (gnus-check-backend-function
7601 'request-expire-articles gnus-newsgroup-name))
7602 (let ((expirable gnus-newsgroup-expirable))
7603 ;; The list of articles that weren't expired is returned.
7604 (setq gnus-newsgroup-expirable
7605 (gnus-request-expire-articles gnus-newsgroup-expirable
7606 gnus-newsgroup-name))
7607 ;; We go through the old list of expirable, and mark all
7608 ;; really expired articles as non-existant.
7610 (or (memq (car expirable) gnus-newsgroup-expirable)
7611 (gnus-summary-mark-as-read (car expirable) "%"))
7612 (setq expirable (cdr expirable))))))
7614 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7615 (defun gnus-summary-delete-article (n)
7616 "Delete the N next (mail) articles.
7617 This command actually deletes articles. This is not a marking
7618 command. The article will disappear forever from you life, never to
7620 If N is negative, delete backwards.
7621 If N is nil and articles have been marked with the process mark,
7622 delete these instead."
7624 (or (gnus-check-backend-function 'request-expire-articles
7625 gnus-newsgroup-name)
7626 (error "The current newsgroup does not support article deletion."))
7627 ;; Compute the list of articles to delete.
7628 (let ((articles (gnus-summary-work-articles n)))
7629 (if (and gnus-novice-user
7631 (format "Do you really want to delete %s forever? "
7632 (if (> (length articles) 1) "these articles"
7635 ;; Delete the articles.
7636 (setq gnus-newsgroup-expirable
7637 (gnus-request-expire-articles
7638 articles gnus-newsgroup-name 'force))
7640 (gnus-summary-remove-process-mark (car articles))
7641 ;; The backend might not have been able to delete the article
7643 (or (memq (car articles) gnus-newsgroup-expirable)
7644 (gnus-summary-mark-as-read (car articles) gnus-canceled-mark))
7645 (setq articles (cdr articles))))))
7647 (defun gnus-summary-edit-article ()
7648 "Enter into a buffer and edit the current article.
7649 This will have permanent effect only in mail groups."
7651 (or (gnus-check-backend-function
7652 'request-replace-article gnus-newsgroup-name)
7653 (error "The current newsgroup does not support article editing."))
7654 (gnus-summary-select-article t)
7656 (message "C-c C-c to end edits")
7657 (setq buffer-read-only nil)
7659 (use-local-map (copy-keymap (current-local-map)))
7660 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
7662 (search-forward "\n\n" nil t))
7664 (defun gnus-summary-edit-article-done ()
7665 "Make edits to the current article permanent."
7667 (if (not (gnus-request-replace-article
7668 (cdr gnus-article-current) (car gnus-article-current)
7670 (error "Couldn't replace article.")
7672 (use-local-map gnus-article-mode-map)
7673 (setq buffer-read-only t)
7674 (pop-to-buffer gnus-summary-buffer)))
7676 ;; Summary score commands.
7678 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
7680 (defun gnus-summary-raise-score (n)
7681 "Raise the score of the current article by N."
7683 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
7685 (defun gnus-summary-lower-score (n)
7686 "Lower the score of the current article by N."
7688 (gnus-summary-raise-score (- n)))
7690 (defun gnus-summary-set-score (n)
7691 "Set the score of the current article to N."
7693 ;; Skip dummy header line.
7695 (if (eq (gnus-summary-article-mark) ?Z)
7697 (let ((buffer-read-only nil))
7699 (gnus-summary-update-mark
7700 (if (= n (or gnus-summary-default-score 0)) ?
7701 (if (< n (or gnus-summary-default-score 0))
7702 gnus-score-below-mark gnus-score-over-mark)) 'score))
7703 (let* ((article (gnus-summary-article-number))
7704 (score (assq article gnus-newsgroup-scored)))
7705 (if score (setcdr score n)
7706 (setq gnus-newsgroup-scored
7707 (cons (cons article n) gnus-newsgroup-scored))))
7708 (gnus-summary-update-line)))
7710 ;; Summary marking commands.
7712 (defun gnus-summary-raise-same-subject-and-select (score)
7713 "Raise articles which has the same subject with SCORE and select the next."
7715 (let ((subject (gnus-summary-subject-string)))
7716 (gnus-summary-raise-score score)
7717 (while (gnus-summary-search-subject nil nil subject)
7718 (gnus-summary-raise-score score))
7719 (gnus-summary-next-article t)))
7721 (defun gnus-summary-raise-same-subject (score)
7722 "Raise articles which has the same subject with SCORE."
7724 (let ((subject (gnus-summary-subject-string)))
7725 (gnus-summary-raise-score score)
7726 (while (gnus-summary-search-subject nil nil subject)
7727 (gnus-summary-raise-score score))
7728 (gnus-summary-next-subject 1 t)))
7730 (defun gnus-summary-raise-thread (score)
7731 "Raise articles under current thread with SCORE."
7735 (let ((level (gnus-summary-thread-level)))
7736 (gnus-summary-raise-score score)
7737 (while (and (zerop (gnus-summary-next-subject 1))
7738 (> (gnus-summary-thread-level) level))
7739 (gnus-summary-raise-score score))
7741 (or (zerop (gnus-summary-next-subject 1 t))
7743 (gnus-summary-position-cursor)
7744 (gnus-set-mode-line 'summary))
7746 (defun gnus-summary-lower-same-subject-and-select (score)
7747 "Raise articles which has the same subject with SCORE and select the next."
7749 (gnus-summary-raise-same-subject-and-select (- score)))
7751 (defun gnus-summary-lower-same-subject (score)
7752 "Raise articles which has the same subject with SCORE."
7754 (gnus-summary-raise-same-subject (- score)))
7756 (defun gnus-summary-lower-thread (score)
7757 "Raise articles under current thread with SCORE."
7759 (gnus-summary-raise-thread (- score)))
7761 (defun gnus-summary-kill-same-subject-and-select (unmark)
7762 "Mark articles which has the same subject as read, and then select the next.
7763 If UNMARK is positive, remove any kind of mark.
7764 If UNMARK is negative, tick articles."
7767 (setq unmark (prefix-numeric-value unmark)))
7769 (gnus-summary-mark-same-subject
7770 (gnus-summary-subject-string) unmark)))
7771 ;; Select next unread article. If auto-select-same mode, should
7772 ;; select the first unread article.
7773 (gnus-summary-next-article t (and gnus-auto-select-same
7774 (gnus-summary-subject-string)))
7775 (message "%d articles are marked as %s"
7776 count (if unmark "unread" "read"))))
7778 (defun gnus-summary-kill-same-subject (unmark)
7779 "Mark articles which has the same subject as read.
7780 If UNMARK is positive, remove any kind of mark.
7781 If UNMARK is negative, tick articles."
7784 (setq unmark (prefix-numeric-value unmark)))
7786 (gnus-summary-mark-same-subject
7787 (gnus-summary-subject-string) unmark)))
7788 ;; If marked as read, go to next unread subject.
7790 ;; Go to next unread subject.
7791 (gnus-summary-next-subject 1 t))
7792 (message "%d articles are marked as %s"
7793 count (if unmark "unread" "read"))))
7795 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7796 "Mark articles with same SUBJECT as read, and return marked number.
7797 If optional argument UNMARK is positive, remove any kinds of marks.
7798 If optional argument UNMARK is negative, mark articles as unread instead."
7801 (cond ((null unmark)
7802 (gnus-summary-mark-as-read nil gnus-killed-mark))
7804 (gnus-summary-tick-article nil t))
7806 (gnus-summary-tick-article)))
7808 (gnus-summary-search-forward nil subject))
7809 (cond ((null unmark)
7810 (gnus-summary-mark-as-read nil gnus-killed-mark))
7812 (gnus-summary-tick-article nil t))
7814 (gnus-summary-tick-article)))
7815 (setq count (1+ count))))
7816 ;; Hide killed thread subtrees. Does not work properly always.
7817 ;;(and (null unmark)
7818 ;; gnus-thread-hide-killed
7819 ;; (gnus-summary-hide-thread))
7820 ;; Return number of articles marked as read.
7823 (defun gnus-summary-mark-as-processable (n &optional unmark)
7824 "Set the process mark on the next N articles.
7825 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7826 the process mark instead. The difference between N and the actual
7827 number of articles marked is returned."
7829 (let ((backward (< n 0))
7834 (gnus-summary-remove-process-mark (gnus-summary-article-number))
7835 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7836 (zerop (gnus-summary-next-subject (if backward -1 1))))
7838 (if (/= 0 n) (message "No more articles"))
7841 (defun gnus-summary-unmark-as-processable (n)
7842 "Remove the process mark from the next N articles.
7843 If N is negative, mark backward instead. The difference between N and
7844 the actual number of articles marked is returned."
7846 (gnus-summary-mark-as-processable n t))
7848 (defun gnus-summary-unmark-all-processable ()
7849 "Remove the process mark from all articles."
7852 (while gnus-newsgroup-processable
7853 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7854 (gnus-summary-position-cursor))
7856 (defun gnus-summary-mark-as-expirable (n)
7857 "Mark N articles forward as expirable.
7858 If N is negative, mark backward instead. The difference between N and
7859 the actual number of articles marked is returned."
7861 (gnus-summary-mark-forward n gnus-expirable-mark))
7863 (defun gnus-summary-mark-article-as-replied (article)
7864 "Mark ARTICLE replied and update the summary line."
7865 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
7866 (let ((buffer-read-only nil))
7867 (if (gnus-summary-goto-subject article)
7869 (gnus-summary-update-mark gnus-replied-mark 'replied)
7872 (defun gnus-summary-set-bookmark (article)
7873 "Set a bookmark in current article."
7874 (interactive (list (gnus-summary-article-number)))
7875 (if (or (not (get-buffer gnus-article-buffer))
7876 (not gnus-current-article)
7877 (not gnus-article-current)
7878 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7879 (error "No current article selected"))
7880 ;; Remove old bookmark, if one exists.
7881 (let ((old (assq article gnus-newsgroup-bookmarks)))
7882 (if old (setq gnus-newsgroup-bookmarks
7883 (delq old gnus-newsgroup-bookmarks))))
7884 ;; Set the new bookmark, which is on the form
7885 ;; (article-number . line-number-in-body).
7886 (setq gnus-newsgroup-bookmarks
7890 (set-buffer gnus-article-buffer)
7895 (search-forward "\n\n" nil t)
7898 gnus-newsgroup-bookmarks))
7899 (message "A bookmark has been added to the current article."))
7901 (defun gnus-summary-remove-bookmark (article)
7902 "Remove the bookmark from the current article."
7903 (interactive (list (gnus-summary-article-number)))
7904 ;; Remove old bookmark, if one exists.
7905 (let ((old (assq article gnus-newsgroup-bookmarks)))
7908 (setq gnus-newsgroup-bookmarks
7909 (delq old gnus-newsgroup-bookmarks))
7910 (message "Removed bookmark."))
7911 (message "No bookmark in current article."))))
7913 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7914 (defun gnus-summary-mark-as-dormant (n)
7915 "Mark N articles forward as dormant.
7916 If N is negative, mark backward instead. The difference between N and
7917 the actual number of articles marked is returned."
7919 (gnus-summary-mark-forward n gnus-dormant-mark))
7921 (defun gnus-summary-set-process-mark (article)
7922 "Set the process mark on ARTICLE and update the summary line."
7923 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
7924 (let ((buffer-read-only nil))
7925 (if (gnus-summary-goto-subject article)
7927 (and (eq (gnus-summary-article-mark) ?Z)
7929 (gnus-summary-update-mark gnus-process-mark 'replied)
7932 (defun gnus-summary-remove-process-mark (article)
7933 "Remove the process mark from ARTICLE and update the summary line."
7934 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7935 (let ((buffer-read-only nil))
7936 (if (gnus-summary-goto-subject article)
7938 (and (eq (gnus-summary-article-mark) ?Z)
7940 (gnus-summary-update-mark ? 'replied)
7941 (if (memq article gnus-newsgroup-replied)
7942 (gnus-summary-update-mark gnus-replied-mark 'replied))
7945 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7946 "Mark N articles as read forwards.
7947 If N is negative, mark backwards instead.
7948 Mark with MARK. If MARK is ? , ?! or ??, articles will be
7950 The difference between N and the actual number of articles marked is
7953 (gnus-set-global-variables)
7954 (let ((backward (< n 0))
7956 (mark (or mark gnus-dread-mark)))
7958 (gnus-summary-mark-article nil mark no-expire)
7959 (zerop (gnus-summary-next-subject
7960 (if backward -1 1) gnus-summary-goto-unread)))
7962 (if (/= 0 n) (message "No more %sarticles" (if mark "" "unread ")))
7963 (gnus-set-mode-line 'summary)
7966 (defun gnus-summary-mark-article (&optional article mark no-expire)
7967 "Mark ARTICLE with MARK.
7968 MARK can be any character.
7969 Five MARK strings are reserved: ? (unread),
7970 ?! (ticked), ?? (dormant), ?D (read), ?E (expirable).
7971 If MARK is nil, then the default character ?D is used.
7972 If ARTICLE is nil, then the article on the current line will be
7974 ;; If no mark is given, then we check auto-expiring.
7975 (and (not no-expire)
7976 gnus-newsgroup-auto-expire
7978 (and (numberp mark) (or (= mark gnus-killed-mark)
7979 (= mark gnus-dread-mark)
7980 (= mark gnus-catchup-mark)
7981 (= mark gnus-low-score-mark)
7982 (= mark gnus-read-mark))))
7983 (setq mark gnus-expirable-mark))
7984 (let* ((buffer-read-only nil)
7985 (mark (or (and (stringp mark) (aref mark 0)) mark gnus-dread-mark))
7986 (article (or article (gnus-summary-article-number))))
7987 (if (or (= mark gnus-unread-mark)
7988 (= mark gnus-ticked-mark)
7989 (= mark gnus-dormant-mark))
7990 (gnus-mark-article-as-unread article mark)
7991 (gnus-mark-article-as-read article mark))
7992 (if (gnus-summary-goto-subject article)
7994 (gnus-summary-show-thread)
7996 (and (eq (gnus-summary-article-mark) ?Z)
7999 (gnus-summary-update-mark mark 'unread)
8002 (defun gnus-summary-update-mark (mark type)
8004 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8008 (forward-char forward)
8009 (setq plist (text-properties-at (point)))
8011 (and (memq 'gnus-mark plist) (setcar (cdr (memq 'gnus-mark plist)) mark))
8013 (and plist (add-text-properties (1- (point)) (point) plist))
8014 (gnus-summary-update-line (eq mark gnus-unread-mark)))))
8016 (defun gnus-mark-article-as-read (article &optional mark)
8017 "Enter ARTICLE in the pertinent lists and remove it from others."
8018 ;; Make the article expirable.
8019 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-dread-mark)))
8020 (if (= mark gnus-expirable-mark)
8021 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
8022 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8023 ;; Remove from unread and marked lists.
8024 (setq gnus-newsgroup-unreads
8025 (delq article gnus-newsgroup-unreads))
8026 (setq gnus-newsgroup-marked
8027 (delq article gnus-newsgroup-marked))
8028 (setq gnus-newsgroup-dormant
8029 (delq article gnus-newsgroup-dormant))))
8031 (defun gnus-mark-article-as-unread (article &optional mark)
8032 "Enter ARTICLE in the pertinent lists and remove it from others."
8033 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-ticked-mark)))
8034 ;; Add to unread list.
8035 (or (memq article gnus-newsgroup-unreads)
8036 (setq gnus-newsgroup-unreads
8037 (cons article gnus-newsgroup-unreads)))
8038 ;; If CLEAR-MARK is non-nil, the article must be removed from marked
8039 ;; list. Otherwise, it must be added to the list.
8040 (setq gnus-newsgroup-marked
8041 (delq article gnus-newsgroup-marked))
8042 (setq gnus-newsgroup-dormant
8043 (delq article gnus-newsgroup-dormant))
8044 (setq gnus-newsgroup-expirable
8045 (delq article gnus-newsgroup-expirable))
8046 (if (= mark gnus-ticked-mark)
8047 (setq gnus-newsgroup-marked
8048 (cons article gnus-newsgroup-marked)))
8049 (if (= mark gnus-dormant-mark)
8050 (setq gnus-newsgroup-dormant
8051 (cons article gnus-newsgroup-dormant)))))
8053 (defalias 'gnus-summary-mark-as-unread-forward
8054 'gnus-summary-tick-article-forward)
8055 (make-obsolete 'gnus-summary-mark-as-unread-forward
8056 'gnus-summary-tick-article-forward)
8057 (defun gnus-summary-tick-article-forward (n)
8058 "Tick N articles forwards.
8059 If N is negative, tick backwards instead.
8060 The difference between N and the number of articles ticked is returned."
8062 (gnus-summary-mark-forward n gnus-ticked-mark))
8064 (defalias 'gnus-summary-mark-as-unread-backward
8065 'gnus-summary-tick-article-backward)
8066 (make-obsolete 'gnus-summary-mark-as-unread-backward
8067 'gnus-summary-tick-article-backward)
8068 (defun gnus-summary-tick-article-backward (n)
8069 "Tick N articles backwards.
8070 The difference between N and the number of articles ticked is returned."
8072 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8074 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8075 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8076 (defun gnus-summary-tick-article (&optional article clear-mark)
8077 "Mark current article as unread.
8078 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8079 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8080 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8083 (defun gnus-summary-mark-as-read-forward (n)
8084 "Mark N articles as read forwards.
8085 If N is negative, mark backwards instead.
8086 The difference between N and the actual number of articles marked is
8089 (gnus-summary-mark-forward n gnus-dread-mark t))
8091 (defun gnus-summary-mark-as-read-backward (n)
8092 "Mark the N articles as read backwards.
8093 The difference between N and the actual number of articles marked is
8096 (gnus-summary-mark-forward (- n) gnus-dread-mark t))
8098 (defun gnus-summary-mark-as-read (&optional article mark)
8099 "Mark current article as read.
8100 ARTICLE specifies the article to be marked as read.
8101 MARK specifies a string to be inserted at the beginning of the line."
8102 (gnus-summary-mark-article article mark))
8104 (defun gnus-summary-clear-mark-forward (n)
8105 "Clear marks from N articles forward.
8106 If N is negative, clear backward instead.
8107 The difference between N and the number of marks cleared is returned."
8109 (gnus-summary-mark-forward n gnus-unread-mark))
8111 (defun gnus-summary-clear-mark-backward (n)
8112 "Clear marks from N articles backward.
8113 The difference between N and the number of marks cleared is returned."
8115 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8117 (defun gnus-summary-mark-unread-as-read ()
8118 "Intended to be used by `gnus-summary-mark-article-hook'."
8119 (or (memq gnus-current-article gnus-newsgroup-marked)
8120 (memq gnus-current-article gnus-newsgroup-dormant)
8121 (memq gnus-current-article gnus-newsgroup-expirable)
8122 (gnus-summary-mark-as-read gnus-current-article gnus-read-mark)))
8124 (defun gnus-summary-mark-region-as-read (point mark all)
8125 "Mark all unread articles between point and mark as read.
8126 If given a prefix, mark all articles between point and mark as read,
8127 even ticked and dormant ones."
8128 (interactive "r\nP")
8138 (not (memq (gnus-summary-article-number)
8139 gnus-newsgroup-marked))
8140 (not (memq (gnus-summary-article-number)
8141 gnus-newsgroup-dormant))))
8142 (gnus-summary-mark-article
8143 (gnus-summary-article-number) gnus-dread-mark))
8145 (zerop (forward-line 1))))))
8147 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
8148 (defalias 'gnus-summary-delete-marked-as-read
8149 'gnus-summary-remove-lines-marked-as-read)
8150 (make-obsolete 'gnus-summary-delete-marked-as-read
8151 'gnus-summary-remove-lines-marked-as-read)
8152 (defun gnus-summary-remove-lines-marked-as-read ()
8153 "Remove lines that are marked as read."
8155 (gnus-summary-remove-lines-marked-with
8157 (lambda (char) (char-to-string (symbol-value char)))
8158 '(gnus-dread-mark gnus-read-mark
8159 gnus-killed-mark gnus-kill-file-mark
8160 gnus-low-score-mark gnus-expirable-mark)
8163 (defalias 'gnus-summary-delete-marked-with
8164 'gnus-summary-remove-lines-marked-with)
8165 (make-obsolete 'gnus-summary-delete-marked-with
8166 'gnus-summary-remove-lines-marked-with)
8167 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
8168 (defun gnus-summary-remove-lines-marked-with (marks)
8169 "Remove lines that are marked with MARKS (e.g. \"DK\")."
8170 (interactive "sMarks: ")
8171 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
8173 (set-buffer gnus-summary-buffer)
8174 (let ((buffer-read-only nil)
8175 (marks (concat "^[" marks "]")))
8176 (goto-char (point-min))
8177 (while (search-forward-regexp marks (point-max) t)
8179 (delete-region (point)
8180 (progn (forward-line 1) (point)))))
8181 (or (zerop (buffer-size))
8183 (gnus-summary-prev-subject 1)
8184 (gnus-summary-position-cursor)))))
8186 (defun gnus-summary-expunge-below (score)
8187 "Remove articles with score less than SCORE."
8189 (setq score (if score
8190 (prefix-numeric-value score)
8191 (or gnus-summary-default-score 0)))
8193 (set-buffer gnus-summary-buffer)
8194 (goto-char (point-min))
8195 (let ((buffer-read-only nil)
8198 (if (< (gnus-summary-article-score) score)
8202 (delete-region beg (point)))
8205 (or (zerop (buffer-size))
8207 (gnus-summary-prev-subject 1)
8208 (gnus-summary-position-cursor))))))
8210 (defun gnus-summary-mark-below (score mark)
8211 "Mark articles with score less than SCORE with MARK."
8212 (interactive "P\ncMark: ")
8213 (setq score (if score
8214 (prefix-numeric-value score)
8215 (or gnus-summary-default-score 0)))
8217 (set-buffer gnus-summary-buffer)
8218 (goto-char (point-min))
8220 (and (< (gnus-summary-article-score) score)
8221 (gnus-summary-mark-article nil mark))
8224 (defun gnus-summary-kill-below (score)
8225 "Mark articles with score below SCORE as read."
8227 (gnus-summary-mark-below score gnus-killed-mark))
8229 (defun gnus-summary-clear-above (score)
8230 "Clear all marks from articles with score above SCORE."
8232 (gnus-summary-mark-above score gnus-unread-mark))
8234 (defun gnus-summary-tick-above (score)
8235 "Tick all articles with score above SCORE."
8237 (gnus-summary-mark-above score gnus-ticked-mark))
8239 (defun gnus-summary-mark-above (score mark)
8240 "Mark articles with score over SCORE with MARK."
8241 (interactive "P\ncMark: ")
8242 (setq score (if score
8243 (prefix-numeric-value score)
8244 (or gnus-summary-default-score 0)))
8246 (set-buffer gnus-summary-buffer)
8247 (goto-char (point-min))
8249 (if (> (gnus-summary-article-score) score)
8251 (gnus-summary-mark-article nil mark)
8253 (forward-line 1)))))
8255 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8256 (defun gnus-summary-show-all-expunged ()
8257 "Display all the hidden articles that were expunged for low scores."
8259 (let ((buffer-read-only nil))
8260 (let ((scored gnus-newsgroup-scored)
8263 (or (gnus-summary-goto-subject (car (car scored)))
8264 (and (setq h (gnus-get-header-by-number (car (car scored))))
8265 (< (cdr (car scored)) gnus-summary-expunge-below)
8266 (setq headers (cons h headers))))
8267 (setq scored (cdr scored)))
8268 (or headers (error "No expunged articles hidden."))
8269 (goto-char (point-min))
8271 (gnus-summary-prepare-threads (nreverse headers) 0)))
8272 (goto-char (point-min))
8273 (gnus-summary-position-cursor)))
8275 (defun gnus-summary-show-all-dormant ()
8276 "Display all the hidden articles that are marked as dormant."
8278 (let ((buffer-read-only nil))
8279 (goto-char (point-min))
8280 (let ((dormant gnus-newsgroup-dormant)
8283 (or (gnus-summary-goto-subject (car dormant))
8284 (and (setq h (gnus-get-header-by-number (car dormant)))
8285 (setq headers (cons h headers))))
8286 (setq dormant (cdr dormant)))
8287 (or headers (error "No dormant articles hidden."))
8288 (save-excursion (gnus-summary-prepare-threads (nreverse headers) 0)))
8289 (goto-char (point-min))
8290 (gnus-summary-position-cursor)))
8292 (defun gnus-summary-hide-all-dormant ()
8293 "Hide all dormant articles."
8295 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
8296 (gnus-summary-position-cursor))
8298 (defun gnus-summary-catchup (all &optional quietly to-here)
8299 "Mark all articles not marked as unread in this newsgroup as read.
8300 If prefix argument ALL is non-nil, all articles are marked as read.
8301 If QUIETLY is non-nil, no questions will be asked.
8302 If TO-HERE is non-nil, it should be a point in the buffer. All
8303 articles before this point will be marked as read.
8304 The number of articles marked as read is returned."
8308 (not gnus-interactive-catchup) ;Without confirmation?
8312 "Mark absolutely all articles as read? "
8313 "Mark all unread articles as read? ")))
8314 (let ((unreads (length gnus-newsgroup-unreads)))
8315 (if (gnus-summary-first-subject (not all))
8316 (while (and (gnus-summary-mark-as-read nil gnus-catchup-mark)
8317 (if to-here (< (point) to-here) t)
8318 (gnus-summary-search-subject nil (not all)))))
8319 (- unreads (length gnus-newsgroup-unreads))
8321 (setq gnus-newsgroup-unreads gnus-newsgroup-marked))))
8322 (gnus-summary-position-cursor)))
8324 (defun gnus-summary-catchup-to-here (&optional all)
8325 "Mark all unticked articles before the current one as read.
8326 If ALL is non-nil, also mark ticked and dormant articles as read."
8329 (gnus-summary-catchup all t (point))
8330 (gnus-summary-position-cursor))
8332 (defun gnus-summary-catchup-all (&optional quietly)
8333 "Mark all articles in this newsgroup as read."
8335 (gnus-summary-catchup t quietly))
8337 (defun gnus-summary-catchup-and-exit (all &optional quietly)
8338 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8339 If prefix argument ALL is non-nil, all articles are marked as read."
8341 (gnus-summary-catchup all quietly)
8342 ;; Select next newsgroup or exit.
8343 (if (eq gnus-auto-select-next 'quietly)
8344 (gnus-summary-next-group nil)
8345 (gnus-summary-exit)))
8347 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8348 "Mark all articles in this newsgroup as read, and then exit."
8350 (gnus-summary-catchup-and-exit t quietly))
8352 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8353 (defun gnus-summary-catchup-and-goto-next-group (all)
8354 "Mark all articles in this group as read and select the next group.
8355 If given a prefix, mark all articles, unread as well as ticked, as
8358 (gnus-summary-catchup all)
8359 (gnus-summary-next-group))
8361 ;; Thread-based commands.
8363 (defun gnus-summary-toggle-threads (arg)
8364 "Toggle showing conversation threads.
8365 If ARG is positive number, turn showing conversation threads on."
8367 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8368 (setq gnus-show-threads
8369 (if (null arg) (not gnus-show-threads)
8370 (> (prefix-numeric-value arg) 0)))
8371 (gnus-summary-prepare)
8372 (gnus-summary-goto-subject current)
8373 (gnus-summary-position-cursor)))
8375 (defun gnus-summary-show-all-threads ()
8379 (let ((buffer-read-only nil))
8380 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8381 (gnus-summary-position-cursor))
8383 (defun gnus-summary-show-thread ()
8384 "Show thread subtrees.
8385 Returns nil if no thread was there to be shown."
8389 (let ((buffer-read-only nil)
8390 ;; first goto end then to beg, to have point at beg after let
8391 (end (progn (end-of-line) (point)))
8392 (beg (progn (beginning-of-line) (point))))
8394 ;; Any hidden lines here?
8395 (search-forward "\r" end t)
8396 (subst-char-in-region beg end ?\^M ?\n t))))
8397 (gnus-summary-position-cursor)))
8399 (defun gnus-summary-hide-all-threads ()
8400 "Hide all thread subtrees."
8403 (goto-char (point-min))
8404 (gnus-summary-hide-thread)
8405 (while (and (not (eobp)) (zerop (forward-line 1)))
8406 (gnus-summary-hide-thread)))
8407 (gnus-summary-position-cursor))
8409 (defun gnus-summary-hide-thread ()
8410 "Hide thread subtrees.
8411 Returns nil if no threads were there to be hidden."
8413 (let ((buffer-read-only nil)
8415 (level (gnus-summary-thread-level))
8417 ;; Go forward until either the buffer ends or the subthread
8421 (while (and (zerop (forward-line 1))
8422 (> (gnus-summary-thread-level) level))
8427 (search-backward "\n" start t))
8428 (subst-char-in-region start end ?\n ?\^M t)
8429 (forward-line -1)))))
8431 (defun gnus-summary-go-to-next-thread (&optional previous)
8432 "Go to the same level (or less) next thread.
8433 If PREVIOUS is non-nil, go to previous thread instead.
8434 Return the article number moved to, or nil if moving was impossible."
8435 (let ((level (gnus-summary-thread-level))
8436 (article (gnus-summary-article-number)))
8438 (while (and (zerop (gnus-summary-prev-subject 1))
8439 (> (gnus-summary-thread-level) level)))
8440 (while (and (zerop (gnus-summary-next-subject 1))
8441 (> (gnus-summary-thread-level) level))))
8442 (let ((oart (gnus-summary-article-number)))
8443 (and (/= oart article) oart))))
8445 (defun gnus-summary-next-thread (n)
8446 "Go to the same level next N'th thread.
8447 If N is negative, search backward instead.
8448 Returns the difference between N and the number of skips actually
8451 (let ((backward (< n 0))
8454 (gnus-summary-go-to-next-thread backward))
8456 (gnus-summary-position-cursor)
8457 (if (/= 0 n) (message "No more threads"))
8460 (defun gnus-summary-prev-thread (n)
8461 "Go to the same level previous N'th thread.
8462 Returns the difference between N and the number of skips actually
8465 (gnus-summary-next-thread (- n)))
8467 (defun gnus-summary-go-down-thread (&optional same)
8468 "Go down one level in the current thread.
8469 If SAME is non-nil, also move to articles of the same level."
8470 (let ((level (gnus-summary-thread-level))
8472 (if (and (zerop (forward-line 1))
8473 (> (gnus-summary-thread-level) level))
8478 (defun gnus-summary-go-up-thread ()
8479 "Go up one level in the current thread."
8480 (let ((level (gnus-summary-thread-level))
8482 (while (and (zerop (forward-line -1))
8483 (>= (gnus-summary-thread-level) level)))
8484 (if (>= (gnus-summary-thread-level) level)
8490 (defun gnus-summary-down-thread (n)
8491 "Go down thread N steps.
8492 If N is negative, go up instead.
8493 Returns the difference between N and how many steps down that were
8499 (if up (gnus-summary-go-up-thread)
8500 (gnus-summary-go-down-thread)))
8502 (gnus-summary-position-cursor)
8503 (if (/= 0 n) (message "Can't go further"))
8506 (defun gnus-summary-up-thread (n)
8507 "Go up thread N steps.
8508 If N is negative, go up instead.
8509 Returns the difference between N and how many steps down that were
8512 (gnus-summary-down-thread (- n)))
8514 (defun gnus-summary-kill-thread (unmark)
8515 "Mark articles under current thread as read.
8516 If the prefix argument is positive, remove any kinds of marks.
8517 If the prefix argument is negative, tick articles instead."
8520 (setq unmark (prefix-numeric-value unmark)))
8522 (level (gnus-summary-thread-level)))
8525 ;; Mark the article...
8526 (cond ((null unmark) (gnus-summary-mark-as-read nil gnus-killed-mark))
8527 ((> unmark 0) (gnus-summary-tick-article nil t))
8528 (t (gnus-summary-tick-article)))
8529 ;; ...and go forward until either the buffer ends or the subtree
8531 (if (not (and (zerop (forward-line 1))
8532 (> (gnus-summary-thread-level) level)))
8533 (setq killing nil))))
8534 ;; Hide killed subtrees.
8536 gnus-thread-hide-killed
8537 (gnus-summary-hide-thread))
8538 ;; If marked as read, go to next unread subject.
8540 ;; Go to next unread subject.
8541 (gnus-summary-next-subject 1 t)))
8542 (gnus-set-mode-line 'summary))
8544 ;; Summary sorting commands
8546 (defun gnus-summary-sort-by-number (reverse)
8547 "Sort summary buffer by article number.
8548 Argument REVERSE means reverse order."
8551 (cons 'gnus-summary-article-number 'gnus-thread-sort-by-number) reverse))
8553 (defun gnus-summary-sort-by-author (reverse)
8554 "Sort summary buffer by author name alphabetically.
8555 If case-fold-search is non-nil, case of letters is ignored.
8556 Argument REVERSE means reverse order."
8561 (let ((extract (funcall
8562 gnus-extract-address-components
8563 (header-from (gnus-get-header-by-number
8564 (gnus-summary-article-number))))))
8565 (or (car extract) (cdr extract))))
8566 'gnus-thread-sort-by-author)
8569 (defun gnus-summary-sort-by-subject (reverse)
8570 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
8571 If case-fold-search is non-nil, case of letters is ignored.
8572 Argument REVERSE means reverse order."
8577 (downcase (gnus-simplify-subject (gnus-summary-subject-string))))
8578 'gnus-thread-sort-by-subject)
8581 (defun gnus-summary-sort-by-date (reverse)
8582 "Sort summary buffer by date.
8583 Argument REVERSE means reverse order."
8590 (gnus-get-header-by-number (gnus-summary-article-number)))))
8591 'gnus-thread-sort-by-date)
8594 (defun gnus-summary-sort-by-score (reverse)
8595 "Sort summary buffer by score.
8596 Argument REVERSE means reverse order."
8599 (cons 'gnus-summary-article-score 'gnus-thread-sort-by-score)
8602 (defvar gnus-summary-already-sorted nil)
8603 (defun gnus-summary-sort (predicate reverse)
8604 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
8605 (if gnus-summary-already-sorted
8607 (let (buffer-read-only)
8608 (if (not gnus-show-threads)
8610 (goto-char (point-min))
8611 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
8612 (let ((gnus-thread-sort-functions (list (cdr predicate)))
8613 (gnus-summary-already-sorted nil))
8614 (gnus-summary-prepare))))))
8616 (defun gnus-sortable-date (date)
8617 "Make sortable string by string-lessp from DATE.
8618 Timezone package is used."
8619 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
8620 (year (aref date 0))
8621 (month (aref date 1))
8622 (day (aref date 2)))
8623 (timezone-make-sortable-date
8625 (timezone-make-time-string
8626 (aref date 3) (aref date 4) (aref date 5)))))
8629 ;; Summary saving commands.
8631 (defun gnus-summary-save-article (n)
8632 "Save the current article using the default saver function.
8633 If N is a positive number, save the N next articles.
8634 If N is a negative number, save the N previous articles.
8635 If N is nil and any articles have been marked with the process mark,
8636 save those articles instead.
8637 The variable `gnus-default-article-saver' specifies the saver function."
8639 (let (articles process)
8640 (if (and n (numberp n))
8641 (let ((backward (< n 0))
8645 (setq articles (cons (gnus-summary-article-number)
8647 (gnus-summary-search-forward nil nil backward))
8649 (setq articles (sort articles (function <))))
8650 (if gnus-newsgroup-processable
8652 (setq articles (setq gnus-newsgroup-processable
8653 (nreverse gnus-newsgroup-processable)))
8655 (setq articles (list (gnus-summary-article-number)))))
8657 (let ((header (gnus-gethash (int-to-string (car articles))
8658 gnus-newsgroup-headers-hashtb-by-number)))
8659 (if (vectorp header)
8661 (gnus-summary-select-article t nil nil (car articles))
8662 (or gnus-save-all-headers
8663 (gnus-article-hide-headers t))
8664 ;; Remove any X-Gnus lines.
8667 (set-buffer gnus-article-buffer)
8668 (let ((buffer-read-only nil))
8669 (goto-char (point-min))
8670 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
8672 (while (re-search-forward "^X-Gnus" nil t)
8674 (delete-region (point)
8675 (progn (forward-line 1) (point))))
8677 (if gnus-default-article-saver
8678 (funcall gnus-default-article-saver)
8679 (error "No default saver is defined.")))
8680 (if (assq 'name header)
8681 (gnus-copy-file (cdr (assq 'name header)))
8682 (message "Article %d is unsaveable" (car articles)))))
8684 (gnus-summary-remove-process-mark (car articles)))
8685 (setq articles (cdr articles)))
8686 (if process (setq gnus-newsgroup-processable
8687 (nreverse gnus-newsgroup-processable)))
8688 (gnus-summary-position-cursor)
8691 (defun gnus-summary-pipe-output (arg)
8692 "Pipe the current article to a subprocess.
8693 If N is a positive number, pipe the N next articles.
8694 If N is a negative number, pipe the N previous articles.
8695 If N is nil and any articles have been marked with the process mark,
8696 pipe those articles instead."
8698 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8699 (gnus-summary-save-article arg)))
8701 (defun gnus-summary-save-article-mail (arg)
8702 "Append the current article to an mail file.
8703 If N is a positive number, save the N next articles.
8704 If N is a negative number, save the N previous articles.
8705 If N is nil and any articles have been marked with the process mark,
8706 save those articles instead."
8708 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8709 (gnus-summary-save-article arg)))
8711 (defun gnus-summary-save-article-rmail (arg)
8712 "Append the current article to an rmail file.
8713 If N is a positive number, save the N next articles.
8714 If N is a negative number, save the N previous articles.
8715 If N is nil and any articles have been marked with the process mark,
8716 save those articles instead."
8718 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8719 (gnus-summary-save-article arg)))
8721 (defun gnus-summary-save-article-file (arg)
8722 "Append the current article to a file.
8723 If N is a positive number, save the N next articles.
8724 If N is a negative number, save the N previous articles.
8725 If N is nil and any articles have been marked with the process mark,
8726 save those articles instead."
8728 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8729 (gnus-summary-save-article arg)))
8731 (defun gnus-summary-save-article-folder (arg)
8732 "Append the current article to an mh folder.
8733 If N is a positive number, save the N next articles.
8734 If N is a negative number, save the N previous articles.
8735 If N is nil and any articles have been marked with the process mark,
8736 save those articles instead."
8738 (let ((gnus-default-article-saver 'gnus-summary-save-in-folder))
8739 (gnus-summary-save-article arg)))
8741 (defun gnus-read-save-file-name (prompt default-name)
8742 (let ((methods gnus-split-methods)
8744 (if (not gnus-split-methods)
8747 (set-buffer gnus-article-buffer)
8748 (gnus-narrow-to-headers)
8750 (goto-char (point-min))
8751 (and (condition-case ()
8752 (re-search-forward (car (car methods)) nil t)
8754 (setq split-name (cons (nth 1 (car methods)) split-name)))
8755 (setq methods (cdr methods)))
8757 (cond ((null split-name)
8759 (concat prompt " (default "
8760 (file-name-nondirectory default-name) ") ")
8761 (file-name-directory default-name)
8763 ((= 1 (length split-name))
8765 (concat prompt " (default " (car split-name) ") ")
8766 gnus-article-save-directory
8767 (concat gnus-article-save-directory (car split-name))))
8769 (setq split-name (mapcar (lambda (el) (list el))
8770 (nreverse split-name)))
8771 (let ((result (completing-read
8773 split-name nil nil)))
8774 (concat gnus-article-save-directory
8775 (if (string= result "")
8776 (car (car split-name))
8779 (defun gnus-summary-save-in-rmail (&optional filename)
8780 "Append this article to Rmail file.
8781 Optional argument FILENAME specifies file name.
8782 Directory to save to is default to `gnus-article-save-directory' which
8783 is initialized from the SAVEDIR environment variable."
8786 (funcall gnus-rmail-save-name gnus-newsgroup-name
8787 gnus-current-headers gnus-newsgroup-last-rmail)))
8789 (setq filename (gnus-read-save-file-name
8790 "Save in rmail file:" default-name)))
8791 (gnus-make-directory (file-name-directory filename))
8792 (gnus-eval-in-buffer-window
8797 (gnus-output-to-rmail filename))))
8798 ;; Remember the directory name to save articles.
8799 (setq gnus-newsgroup-last-rmail filename)))
8801 (defun gnus-summary-save-in-mail (&optional filename)
8802 "Append this article to Unix mail file.
8803 Optional argument FILENAME specifies file name.
8804 Directory to save to is default to `gnus-article-save-directory' which
8805 is initialized from the SAVEDIR environment variable."
8808 (funcall gnus-mail-save-name gnus-newsgroup-name
8809 gnus-current-headers gnus-newsgroup-last-mail)))
8811 (setq filename (gnus-read-save-file-name
8812 "Save in Unix mail file:" default-name)))
8814 (expand-file-name filename
8816 (file-name-directory default-name))))
8817 (gnus-make-directory (file-name-directory filename))
8818 (gnus-eval-in-buffer-window
8823 (if (and (file-readable-p filename) (rmail-file-p filename))
8824 (gnus-output-to-rmail filename)
8825 (rmail-output filename 1 t t)))))
8826 ;; Remember the directory name to save articles.
8827 (setq gnus-newsgroup-last-mail filename)))
8829 (defun gnus-summary-save-in-file (&optional filename)
8830 "Append this article to file.
8831 Optional argument FILENAME specifies file name.
8832 Directory to save to is default to `gnus-article-save-directory' which
8833 is initialized from the SAVEDIR environment variable."
8836 (funcall gnus-file-save-name gnus-newsgroup-name
8837 gnus-current-headers gnus-newsgroup-last-file)))
8839 (setq filename (gnus-read-save-file-name
8840 "Save in file:" default-name)))
8841 (gnus-make-directory (file-name-directory filename))
8842 (gnus-eval-in-buffer-window
8847 (gnus-output-to-file filename))))
8848 ;; Remember the directory name to save articles.
8849 (setq gnus-newsgroup-last-file filename)))
8851 (defun gnus-summary-save-in-pipe (&optional command)
8852 "Pipe this article to subprocess."
8854 (let ((command (read-string "Shell command on article: "
8855 gnus-last-shell-command)))
8856 (if (string-equal command "")
8857 (setq command gnus-last-shell-command))
8858 (gnus-eval-in-buffer-window
8862 (shell-command-on-region (point-min) (point-max) command nil)))
8863 (setq gnus-last-shell-command command)))
8865 ;; Summary extract commands
8867 (defun gnus-summary-insert-pseudos (pslist)
8868 (let ((buffer-read-only nil)
8869 (article (gnus-summary-article-number))
8871 (or (gnus-summary-goto-subject article)
8872 (error (format "No such article: %d" article)))
8873 (or gnus-newsgroup-headers-hashtb-by-number
8874 (gnus-make-headers-hashtable-by-number))
8875 (gnus-summary-position-cursor)
8876 (if gnus-view-pseudos
8878 (and (assq 'execute (car pslist))
8879 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8880 (eq gnus-view-pseudos 'not-confirm)))
8881 (setq pslist (cdr pslist)))
8884 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
8885 (gnus-summary-article-number)))
8888 (insert " " (file-name-nondirectory
8889 (cdr (assq 'name (car pslist))))
8890 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8891 (add-text-properties
8892 b (1+ b) (list 'gnus-subject (cdr (assq 'name (car pslist)))
8893 'gnus-number gnus-reffed-article-number
8894 'gnus-mark gnus-unread-mark
8895 'gnus-pseudo (car pslist)
8898 (gnus-sethash (int-to-string gnus-reffed-article-number)
8899 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
8900 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8901 (setq pslist (cdr pslist)))))))
8903 (defun gnus-request-pseudo-article (props)
8904 (cond ((assq 'execute props)
8905 (gnus-execute-command (cdr (assq 'execute props)))))
8906 (let ((gnus-current-article (gnus-summary-article-number)))
8907 (run-hooks 'gnus-mark-article-hook)))
8909 (defun gnus-execute-command (command &optional automatic)
8911 (gnus-article-setup-buffer)
8912 (set-buffer gnus-article-buffer)
8913 (let ((command (if automatic command (read-string "Command: " command)))
8914 (buffer-read-only nil))
8916 (insert "$ " command "\n\n")
8917 (if gnus-view-pseudo-asynchronously
8918 (start-process "gnus-execute" nil "sh" "-c" command)
8919 (call-process "sh" nil t nil "-c" command)))))
8921 (defun gnus-copy-file (file &optional to)
8924 (list (read-file-name "Copy file: " default-directory)
8925 (read-file-name "Copy file to: " default-directory)))
8926 (or to (setq to (read-file-name "Copy file to: " default-directory)))
8927 (and (file-directory-p to)
8928 (setq to (concat (file-name-as-directory to)
8929 (file-name-nondirectory file))))
8930 (copy-file file to))
8932 ;; Summary score file commands
8934 ;; Much modification of the kill (ahem, score) code and lots of the
8935 ;; functions are written by Per Abrahamsen <amanda@iesd.auc.dk>.
8937 (defun gnus-summary-header (header)
8938 ;; Return HEADER for current articles, or error.
8939 (let ((article (gnus-summary-article-number)))
8941 (aref (gnus-get-header-by-number article)
8942 (nth 1 (assoc header gnus-header-index)))
8943 (error "No article on current line"))))
8945 (defun gnus-summary-score-entry (header match type score date &optional prompt)
8946 "Enter score file entry.
8947 HEADER is the header being scored.
8948 MATCH is the string we are looking for.
8949 TYPE is a flag indicating if it is a regexp or substring.
8950 SCORE is the score to add.
8951 DATE is the expire date."
8953 (list (completing-read "Header: "
8955 (lambda (x) (fboundp (nth 2 x)))
8957 (read-string "Match: ")
8958 (y-or-n-p "Use regexp match? ")
8959 (prefix-numeric-value current-prefix-arg)
8960 (if (y-or-n-p "Expire kill? ")
8961 (current-time-string)
8963 (let ((score (gnus-score-default score))
8964 (header (downcase header)))
8965 (and prompt (setq match (read-string
8966 (format "Match %s on %s, %s: "
8967 (if date "temp" "permanent")
8969 (if (< score 0) "lower" "raise"))
8971 (and (>= (nth 1 (assoc header gnus-header-index)) 0)
8972 (gnus-summary-score-effect header match type score))
8973 (and (= score gnus-score-interactive-default-score)
8975 (let ((new (cond (type
8976 (list match score (and date (gnus-day-number date)) type))
8978 (list match score (gnus-day-number date)))
8983 (old (gnus-score-get header)))
8986 (if old (cons new old) (list new))))
8987 (gnus-score-set 'touched '(t))))
8989 (defun gnus-summary-score-effect (header match type score)
8990 "Simulate the effect of a score file entry.
8991 HEADER is the header being scored.
8992 MATCH is the string we are looking for.
8993 TYPE is a flag indicating if it is a regexp or substring.
8994 SCORE is the score to add."
8995 (interactive (list (completing-read "Header: "
8997 (lambda (x) (fboundp (nth 2 x)))
8999 (read-string "Match: ")
9000 (y-or-n-p "Use regexp match? ")
9001 (prefix-numeric-value current-prefix-arg)))
9003 (or (and (stringp match) (> (length match) 0))
9005 (goto-char (point-min))
9006 (let ((regexp (if type
9008 (concat "\\`.*" (regexp-quote match) ".*\\'"))))
9010 (let ((content (gnus-summary-header header))
9011 (case-fold-search t))
9013 (if (string-match regexp content)
9014 (gnus-summary-raise-score score))))
9015 (beginning-of-line 2)))))
9017 (defun gnus-summary-score-crossposting (score date)
9018 ;; Enter score file entry for current crossposting.
9019 ;; SCORE is the score to add.
9020 ;; DATE is the expire date.
9021 (let ((xref (gnus-summary-header "xref"))
9024 (or xref (error "This article is not crossposted"))
9025 (while (string-match " \\([^ \t]+\\):" xref start)
9026 (setq start (match-end 0))
9029 (substring xref (match-beginning 1) (match-end 1)))
9030 gnus-newsgroup-name))
9031 (gnus-summary-score-entry
9032 "xref" (concat " " group ":") nil score date t)))))
9034 (defun gnus-summary-temporarily-lower-by-subject (level)
9035 "Temporarily lower score by LEVEL for current subject.
9036 See `gnus-score-expiry-days'."
9038 (gnus-summary-score-entry
9039 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
9040 nil (- (gnus-score-default level))
9041 (current-time-string) t))
9043 (defun gnus-summary-temporarily-lower-by-author (level)
9044 "Temporarily lower score by LEVEL for current author.
9045 See `gnus-score-expiry-days'."
9047 (gnus-summary-score-entry
9048 "from" (gnus-summary-header "from") nil (- (gnus-score-default level))
9049 (current-time-string) t))
9051 (defun gnus-summary-temporarily-lower-by-body (level)
9052 "Temporarily lower score by LEVEL for a match on the body of the article.
9053 See `gnus-score-expiry-days'."
9055 (gnus-summary-score-entry
9056 "body" "" nil (- (gnus-score-default level)) (current-time-string) t))
9058 (defun gnus-summary-temporarily-lower-by-id (level)
9059 "Temporarily lower score by LEVEL for current message-id.
9060 See `gnus-score-expiry-days'."
9062 (gnus-summary-score-entry
9063 "message-id" (gnus-summary-header "message-id")
9064 nil (- (gnus-score-default level))
9065 (current-time-string)))
9067 (defun gnus-summary-temporarily-lower-by-xref (level)
9068 "Temporarily lower score by LEVEL for current xref.
9069 See `gnus-score-expiry-days'."
9071 (gnus-summary-score-crossposting
9072 (- (gnus-score-default level)) (current-time-string)))
9074 (defun gnus-summary-temporarily-lower-by-thread (level)
9075 "Temporarily lower score by LEVEL for current thread.
9076 See `gnus-score-expiry-days'."
9078 (gnus-summary-score-entry
9079 "references" (gnus-summary-header "message-id")
9080 nil (- (gnus-score-default level)) (current-time-string)))
9082 (defun gnus-summary-lower-by-subject (level)
9083 "Lower score by LEVEL for current subject."
9085 (gnus-summary-score-entry
9086 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
9087 nil (- (gnus-score-default level))
9090 (defun gnus-summary-lower-by-author (level)
9091 "Lower score by LEVEL for current author."
9093 (gnus-summary-score-entry
9094 "from" (gnus-summary-header "from") nil
9095 (- (gnus-score-default level)) nil t))
9097 (defun gnus-summary-lower-by-body (level)
9098 "Lower score by LEVEL for a match on the body of the article."
9100 (gnus-summary-score-entry
9101 "body" "" nil (- (gnus-score-default level)) nil t))
9103 (defun gnus-summary-lower-by-id (level)
9104 "Lower score by LEVEL for current message-id."
9106 (gnus-summary-score-entry
9107 "message-id" (gnus-summary-header "message-id") nil
9108 (- (gnus-score-default level)) nil))
9110 (defun gnus-summary-lower-by-xref (level)
9111 "Lower score by LEVEL for current xref."
9113 (gnus-summary-score-crossposting (- (gnus-score-default level)) nil))
9115 (defun gnus-summary-lower-followups-to-author (level)
9116 "Lower score by LEVEL for all followups to the current author."
9118 (gnus-summary-raise-followups-to-author
9119 (- (gnus-score-default level))))
9121 (defun gnus-summary-temporarily-raise-by-subject (level)
9122 "Temporarily raise score by LEVEL for current subject.
9123 See `gnus-score-expiry-days'."
9125 (gnus-summary-score-entry
9126 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
9127 nil level (current-time-string) t))
9129 (defun gnus-summary-temporarily-raise-by-author (level)
9130 "Temporarily raise score by LEVEL for current author.
9131 See `gnus-score-expiry-days'."
9133 (gnus-summary-score-entry
9134 "from" (gnus-summary-header "from") nil level (current-time-string) t))
9136 (defun gnus-summary-temporarily-raise-by-body (level)
9137 "Temporarily raise score by LEVEL for a match on the body of the article.
9138 See `gnus-score-expiry-days'."
9140 (gnus-summary-score-entry "body" "" nil level (current-time-string) t))
9142 (defun gnus-summary-temporarily-raise-by-id (level)
9143 "Temporarily raise score by LEVEL for current message-id.
9144 See `gnus-score-expiry-days'."
9146 (gnus-summary-score-entry
9147 "message-id" (gnus-summary-header "message-id")
9148 nil level (current-time-string)))
9150 (defun gnus-summary-temporarily-raise-by-xref (level)
9151 "Temporarily raise score by LEVEL for current xref.
9152 See `gnus-score-expiry-days'."
9154 (gnus-summary-score-crossposting level (current-time-string)))
9156 (defun gnus-summary-temporarily-raise-by-thread (level)
9157 "Temporarily raise score by LEVEL for current thread.
9158 See `gnus-score-expiry-days'."
9160 (gnus-summary-score-entry
9161 "references" (gnus-summary-header "message-id")
9162 nil level (current-time-string)))
9164 (defun gnus-summary-raise-by-subject (level)
9165 "Raise score by LEVEL for current subject."
9167 (gnus-summary-score-entry
9168 "subject" (gnus-simplify-subject-re (gnus-summary-header "subject"))
9171 (defun gnus-summary-raise-by-author (level)
9172 "Raise score by LEVEL for current author."
9174 (gnus-summary-score-entry
9175 "from" (gnus-summary-header "from") nil level nil t))
9177 (defun gnus-summary-raise-by-body (level)
9178 "Raise score by LEVEL for a match on the body of the article."
9180 (gnus-summary-score-entry "body" "" nil level nil t))
9182 (defun gnus-summary-raise-by-id (level)
9183 "Raise score by LEVEL for current message-id."
9185 (gnus-summary-score-entry
9186 "message-id" (gnus-summary-header "message-id") nil level nil))
9188 (defun gnus-summary-raise-by-xref (level)
9189 "Raise score by LEVEL for current xref."
9191 (gnus-summary-score-crossposting level nil))
9193 (defun gnus-summary-raise-followups-to-author (level)
9194 "Raise score by LEVEL for all followups to the current author."
9196 (let ((article (gnus-summary-article-number)))
9197 (if article (setq gnus-current-headers (gnus-get-header-by-number article))
9198 (error "No article on current line")))
9199 (gnus-kill-file-raise-followups-to-author
9200 (gnus-score-default level)))
9202 ;; Summary kill commands.
9204 (defun gnus-summary-edit-global-kill (article)
9205 "Edit the global score file."
9206 (interactive (list (gnus-summary-article-number)))
9207 (gnus-group-edit-global-kill article))
9209 (defun gnus-summary-edit-local-kill ()
9210 "Edit a local score file applied to the current newsgroup."
9212 (setq gnus-current-headers
9214 (int-to-string (gnus-summary-article-number))
9215 gnus-newsgroup-headers-hashtb-by-number))
9216 (gnus-set-global-variables)
9217 (gnus-group-edit-local-kill
9218 (gnus-summary-article-number) gnus-newsgroup-name))
9222 ;;; Gnus article mode
9225 (put 'gnus-article-mode 'mode-class 'special)
9227 (if gnus-article-mode-map
9229 (setq gnus-article-mode-map (make-keymap))
9230 (suppress-keymap gnus-article-mode-map)
9231 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
9232 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
9233 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
9234 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
9235 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
9236 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
9237 (define-key gnus-article-mode-map "\C-c\C-M" 'gnus-article-mail-with-original)
9238 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
9240 ;; Duplicate almost all summary keystrokes in the article mode map.
9242 (list "#" "\M-#" "\C-c\M-#" "\r" "n" "p"
9243 "N" "P" "\M-\C-n" "\M-\C-p" "." "\M-s" "\M-r"
9244 "<" ">" "l" "j" "^" "\M-^" "-" "u" "U" "d" "D"
9245 "\M-u" "\M-U" "k" "\C-k" "\M-\C-k" "c" "x" "X"
9246 "\M-\C-x" "\M-\177" "b" "B" "$" "w" "\C-c\C-r"
9247 "t" "\M-t" "a" "f" "F" "C" "S" "r" "R" "\C-c\C-f"
9248 "m" "o" "\C-o" "|" "\M-m" "\M-\C-m" "\M-k" "m" "M"
9249 "V" "\C-c\C-d" "q" "Q")))
9251 (define-key gnus-article-mode-map (car commands)
9252 'gnus-article-summary-command)
9253 (setq commands (cdr commands)))))
9256 (defun gnus-article-mode ()
9257 "Major mode for displaying an article.
9259 All normal editing commands are switched off.
9261 The following commands are available:
9263 \\<gnus-article-mode-map>
9264 \\[gnus-article-next-page]\t Scroll the article one page forwards
9265 \\[gnus-article-prev-page]\t Scroll the article one page backwards
9266 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
9267 \\[gnus-article-show-summary]\t Display the summary buffer
9268 \\[gnus-article-mail]\t Send a reply to the address near point
9269 \\[gnus-article-mail-with-original]\t Send a reply to the address near point; include the original article
9270 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
9271 \\[gnus-info-find-node]\t Go to the Gnus info node"
9273 (if gnus-visual (gnus-article-make-menu-bar))
9274 (kill-all-local-variables)
9275 (setq mode-line-modified "-- ")
9276 (make-local-variable 'mode-line-format)
9277 (setq mode-line-format (copy-sequence mode-line-format))
9278 (and (equal (nth 3 mode-line-format) " ")
9279 (setcar (nthcdr 3 mode-line-format) ""))
9280 (setq mode-name "Article")
9281 (setq major-mode 'gnus-article-mode)
9282 (make-local-variable 'minor-mode-alist)
9283 (or (assq 'gnus-show-mime minor-mode-alist)
9284 (setq minor-mode-alist
9285 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
9286 (use-local-map gnus-article-mode-map)
9287 (make-local-variable 'page-delimiter)
9288 (setq page-delimiter gnus-page-delimiter)
9289 (buffer-disable-undo (current-buffer))
9290 (setq buffer-read-only t) ;Disable modification
9291 (run-hooks 'gnus-article-mode-hook))
9293 (defun gnus-article-setup-buffer ()
9294 "Initialize article mode buffer."
9295 (or (get-buffer gnus-article-buffer)
9297 (set-buffer (get-buffer-create gnus-article-buffer))
9298 (gnus-add-current-to-buffer-list)
9299 (gnus-article-mode))))
9301 (defun gnus-request-article-this-buffer (article &optional group)
9302 "Get an article and insert it into this buffer."
9303 (setq group (or group gnus-newsgroup-name))
9304 ;; Using `gnus-request-article' directly will insert the article into
9305 ;; `nntp-server-buffer' - so we'll save some time by not having to
9306 ;; copy it from the server buffer into the article buffer.
9308 ;; We only request an article by message-id when we do not have the
9309 ;; headers for it, so we'll have to get those.
9310 (and (stringp article)
9311 (let ((gnus-override-method gnus-refer-article-method))
9312 (gnus-read-header article)))
9314 ;; If the article number is negative, that means that this article
9315 ;; doesn't belong in this newsgroup (possibly), so we find its
9316 ;; message-id and request it by id instead of number.
9317 (if (and (numberp article) (< article 0))
9319 (set-buffer gnus-summary-buffer)
9320 (let ((header (gnus-gethash (int-to-string article)
9321 gnus-newsgroup-headers-hashtb-by-number)))
9322 (if (vectorp header)
9323 ;; It's a real article.
9324 (setq article (header-id header))
9325 ;; It is an extracted pseudo-article.
9327 (gnus-request-pseudo-article header)))))
9328 ;; Get the article and into the article buffer.
9332 (let ((gnus-override-method
9333 (and (stringp article) gnus-refer-article-method)))
9334 (and (gnus-request-article article group (current-buffer))
9338 (defun gnus-read-header (id)
9339 "Read the headers of article ID and enter them into the Gnus system."
9340 (or gnus-newsgroup-headers-hashtb-by-number
9341 (gnus-make-headers-hashtable-by-number))
9343 (if (not (setq header
9344 (car (if (let ((gnus-nov-is-evil t))
9345 (gnus-retrieve-headers
9346 (list id) gnus-newsgroup-name))
9347 (gnus-get-newsgroup-headers)))))
9350 (header-set-number header gnus-reffed-article-number))
9351 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
9352 (gnus-sethash (int-to-string (header-number header)) header
9353 gnus-newsgroup-headers-hashtb-by-number)
9355 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
9356 (setq gnus-current-headers header)
9359 (defun gnus-article-prepare (article &optional all-headers header)
9360 "Prepare ARTICLE in article mode buffer.
9361 ARTICLE should either be an article number or a Message-ID.
9362 If ARTICLE is an id, HEADER should be the article headers.
9363 If ALL-HEADERS is non-nil, no headers are hidden."
9365 ;; Make sure we start in a summary buffer.
9366 (or (eq major-mode 'gnus-summary-mode)
9367 (set-buffer gnus-summary-buffer))
9368 (setq gnus-summary-buffer (current-buffer))
9369 ;; Make sure the connection to the server is alive.
9370 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
9372 (gnus-check-news-server
9373 (gnus-find-method-for-group gnus-newsgroup-name))
9374 (gnus-request-group gnus-newsgroup-name t)))
9375 (or gnus-newsgroup-headers-hashtb-by-number
9376 (gnus-make-headers-hashtable-by-number))
9377 (let* ((article (if header (header-number header) article))
9378 (summary-buffer (current-buffer))
9379 (internal-hook gnus-article-internal-prepare-hook)
9380 (bookmark (cdr (assq article gnus-newsgroup-bookmarks)))
9381 (group gnus-newsgroup-name)
9384 (gnus-article-setup-buffer)
9385 (set-buffer gnus-article-buffer)
9386 (let ((buffer-read-only nil))
9387 (if (not (setq result (gnus-request-article-this-buffer
9389 ;; There is no such article.
9392 (set-buffer gnus-summary-buffer)
9393 (setq gnus-current-article 0)
9394 (and (numberp article)
9395 (gnus-summary-mark-as-read article gnus-canceled-mark))
9396 (message "No such article (may be canceled)")
9398 (setq gnus-article-current nil)
9400 (if (not (eq result 'article))
9403 (set-buffer summary-buffer)
9404 (setq gnus-last-article gnus-current-article
9405 gnus-newsgroup-history (cons gnus-current-article
9406 gnus-newsgroup-history)
9407 gnus-current-article 0
9408 gnus-current-headers nil
9409 gnus-article-current nil)
9410 (gnus-configure-windows 'article)
9411 (gnus-set-global-variables))
9412 (gnus-set-mode-line 'article))
9413 ;; The result from the `request' was an actual article -
9414 ;; or at least some text that is now displayed in the
9416 (if (and (numberp article)
9417 (not (eq article gnus-current-article)))
9418 ;; Seems like a new article has been selected.
9419 ;; `gnus-current-article' must be an article number.
9421 (set-buffer summary-buffer)
9422 (setq gnus-last-article gnus-current-article
9423 gnus-newsgroup-history (cons gnus-current-article
9424 gnus-newsgroup-history)
9425 gnus-current-article article
9426 gnus-current-headers
9427 (gnus-get-header-by-number gnus-current-article)
9428 gnus-article-current
9429 (cons gnus-newsgroup-name gnus-current-article))
9430 (run-hooks 'gnus-mark-article-hook)
9431 (gnus-set-mode-line 'summary)
9433 (run-hooks 'gnus-visual-mark-article-hook))
9434 ;; Set the global newsgroup variables here.
9435 ;; Suggested by Jim Sisolak
9436 ;; <sisolak@trans4.neep.wisc.edu>.
9437 (gnus-set-global-variables)))
9438 ;; gnus-have-all-headers must be either T or NIL.
9439 (setq gnus-have-all-headers
9440 (not (not (or all-headers gnus-show-all-headers))))
9441 ;; Hooks for getting information from the article.
9442 ;; This hook must be called before being narrowed.
9443 (run-hooks 'internal-hook)
9444 (run-hooks 'gnus-article-prepare-hook)
9445 ;; Decode MIME message.
9446 (if (and gnus-show-mime
9447 (gnus-fetch-field "Mime-Version"))
9448 (funcall gnus-show-mime-method))
9449 ;; Perform the article display hooks.
9450 (let ((buffer-read-only nil))
9451 (run-hooks 'gnus-article-display-hook))
9453 (goto-char (point-min))
9454 (and gnus-break-pages (gnus-narrow-to-page))
9455 (gnus-set-mode-line 'article)
9456 (gnus-configure-windows 'article)
9459 (get-buffer-window gnus-article-buffer) (point-min))
9462 (message "Moved to bookmark")
9463 (search-forward "\n\n" nil t)
9464 (forward-line bookmark)))
9467 (defun gnus-article-show-all-headers ()
9468 "Show all article headers in article mode buffer."
9470 (setq gnus-have-all-headers t)
9471 (gnus-article-setup-buffer)
9472 (set-buffer gnus-article-buffer)
9473 (let ((buffer-read-only nil))
9474 (remove-text-properties 1 (point-max) '(invisible t)))))
9476 (defun gnus-article-hide-headers-if-wanted ()
9477 "Hide unwanted headers if `gnus-have-all-headers' is nil.
9478 Provided for backwards compatability."
9479 (or gnus-have-all-headers
9480 (gnus-article-hide-headers)))
9482 (defun gnus-article-hide-headers (&optional delete)
9483 "Hide unwanted headers and possibly sort them as well."
9486 (set-buffer gnus-article-buffer)
9488 (let ((sorted gnus-sorted-header-list)
9489 (buffer-read-only nil)
9490 want want-list beg want-l)
9491 ;; First we narrow to just the headers.
9494 ;; Hide any "From " lines at the beginning of (mail) articles.
9495 (while (looking-at rmail-unix-mail-delimiter)
9498 (add-text-properties 1 (point) '(invisible t)))
9499 ;; Then treat the rest of the header lines.
9502 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
9503 ;; Then we use the two regular expressions
9504 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
9505 ;; select which header lines is to remain visible in the
9508 (while (re-search-forward "^[^ \t]*:" nil t)
9510 ;; We add the headers we want to keep to a list and delete
9511 ;; them from the buffer.
9512 (if (or (and (stringp gnus-visible-headers)
9513 (looking-at gnus-visible-headers))
9514 (and (not (stringp gnus-visible-headers))
9515 (stringp gnus-ignored-headers)
9516 (not (looking-at gnus-ignored-headers))))
9520 ;; Be sure to get multi-line headers...
9521 (re-search-forward "^[^ \t]*:" nil t)
9524 (cons (buffer-substring beg (point)) want-list))
9525 (delete-region beg (point))
9528 ;; Next we perform the sorting by looking at
9529 ;; `gnus-sorted-header-list'.
9531 (while (and sorted want-list)
9532 (setq want-l want-list)
9534 (not (string-match (car sorted) (car want-l))))
9535 (setq want-l (cdr want-l)))
9538 (insert (car want-l))
9539 (setq want-list (delq (car want-l) want-list))))
9540 (setq sorted (cdr sorted)))
9541 ;; Any headers that were not matched by the sorted list we
9542 ;; just tack on the end of the visible header list.
9544 (insert (car want-list))
9545 (setq want-list (cdr want-list)))
9546 ;; And finally we make the unwanted headers invisible.
9548 (delete-region (point) (point-max))
9549 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
9550 (add-text-properties (point) (point-max) '(invisible t)))))))
9552 (defun gnus-article-hide-signature ()
9553 "Hides the signature in an article.
9554 It does this by hiding everyting after \"^-- *$\", which is what all
9555 signatures should be preceded by. Note that this may mean that parts
9556 of an article may disappear if the article has such a line in the
9557 middle of the text."
9560 (set-buffer gnus-article-buffer)
9561 (let ((buffer-read-only nil))
9562 (goto-char (point-max))
9563 (if (re-search-backward "^-- *$" nil t)
9565 (add-text-properties (point) (point-max) '(invisible t)))))))
9567 (defun gnus-article-hide-citation ()
9568 "Hide all cited text.
9569 This function uses the famous, extremely intelligent \"shoot in foot\"
9570 algorithm - which is simply deleting all lines that start with
9571 \">\". Your mileage may vary. If you come up with anything better,
9572 please do mail it to me."
9575 (set-buffer gnus-article-buffer)
9576 (let ((buffer-read-only nil))
9578 (search-forward "\n\n" nil t)
9580 (if (looking-at ">")
9581 (add-text-properties
9582 (point) (save-excursion (forward-line 1) (point))
9584 (forward-line 1)))))
9586 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
9587 (defun gnus-article-treat-overstrike ()
9588 "Translate overstrikes into bold text."
9591 (set-buffer gnus-article-buffer)
9592 (let ((buffer-read-only nil))
9593 (while (search-forward "\b" nil t)
9594 (let ((next (following-char))
9595 (previous (char-after (- (point) 2))))
9596 (cond ((eq next previous)
9597 (delete-region (- (point) 2) (point))
9598 (put-text-property (point) (1+ (point))
9601 (delete-region (1- (point)) (1+ (point)))
9602 (put-text-property (1- (point)) (point)
9605 (delete-region (- (point) 2) (point))
9606 (put-text-property (point) (1+ (point))
9607 'face 'underline))))))))
9609 (defun gnus-article-word-wrap ()
9610 "Format too long lines."
9613 (set-buffer gnus-article-buffer)
9614 (let ((buffer-read-only nil))
9616 (search-forward "\n\n" nil t)
9618 (let ((paragraph-start "^\\W"))
9620 (and (>= (current-column) (window-width))
9621 (/= (preceding-char) ?:)
9622 (fill-paragraph nil))
9623 (end-of-line 2))))))
9625 (defun gnus-article-remove-cr ()
9626 "Remove carriage returns from an article."
9629 (set-buffer gnus-article-buffer)
9630 (let ((buffer-read-only nil))
9631 (goto-char (point-min))
9632 (while (search-forward "\r" nil t)
9633 (replace-match "")))))
9635 (defun gnus-article-display-x-face ()
9636 "Look for an X-Face header and display it if present."
9639 (set-buffer gnus-article-buffer)
9640 (goto-char (point-min))
9641 (if (or (not gnus-article-x-face-command)
9642 (not (re-search-forward "^X-Face: " nil t)))
9649 (while (and (looking-at "[ \t]")
9650 (zerop (forward-line 1))))
9652 (command gnus-article-x-face-command))
9653 (if (symbolp command)
9654 (and (or (fboundp command) (error "%s is not a function" command))
9655 (funcall command face))
9656 (let ((process (start-process "gnus-x-face" nil "sh" "-c" command)))
9659 (process-send-string process face)
9660 (process-send-eof process))
9661 (error "Couldn't start process"))))))))
9663 (defun gnus-article-de-quoted-unreadable ()
9664 "Do a naive translation of a quoted-printable-encoded article.
9665 This is in no way, shape or form meant as a replacement for real MIME
9666 processing, but is simply a stop-gap measure until MIME support is
9671 (set-buffer gnus-article-buffer)
9672 (let ((buffer-read-only nil))
9674 (goto-char (point-min))
9675 (while (re-search-forward "=[0-9A-F][0-9A-F]" nil t)
9679 (* 16 (gnus-hex-char-to-integer
9680 (char-after (1+ (match-beginning 0)))))
9681 (gnus-hex-char-to-integer
9682 (char-after (1- (match-end 0))))))))))))
9684 ;; Taken from hexl.el.
9685 (defun gnus-hex-char-to-integer (character)
9686 "Take a char and return its value as if it was a hex digit."
9687 (if (and (>= character ?0) (<= character ?9))
9689 (let ((ch (logior character 32)))
9690 (if (and (>= ch ?a) (<= ch ?f))
9692 (error (format "Invalid hex digit `%c'." ch))))))
9696 (defun gnus-output-to-rmail (file-name)
9697 "Append the current article to an Rmail file named FILE-NAME."
9699 ;; Most of these codes are borrowed from rmailout.el.
9700 (setq file-name (expand-file-name file-name))
9701 (setq rmail-default-rmail-file file-name)
9702 (let ((artbuf (current-buffer))
9703 (tmpbuf (get-buffer-create " *Gnus-output*")))
9705 (or (get-file-buffer file-name)
9706 (file-exists-p file-name)
9707 (if (gnus-yes-or-no-p
9708 (concat "\"" file-name "\" does not exist, create it? "))
9709 (let ((file-buffer (create-file-buffer file-name)))
9711 (set-buffer file-buffer)
9712 (rmail-insert-rmail-file-header)
9713 (let ((require-final-newline nil))
9714 (write-region (point-min) (point-max) file-name t 1)))
9715 (kill-buffer file-buffer))
9716 (error "Output file does not exist")))
9718 (buffer-disable-undo (current-buffer))
9720 (insert-buffer-substring artbuf)
9721 (gnus-convert-article-to-rmail)
9722 ;; Decide whether to append to a file or to an Emacs buffer.
9723 (let ((outbuf (get-file-buffer file-name)))
9725 (append-to-file (point-min) (point-max) file-name)
9726 ;; File has been visited, in buffer OUTBUF.
9728 (let ((buffer-read-only nil)
9729 (msg (and (boundp 'rmail-current-message)
9730 rmail-current-message)))
9731 ;; If MSG is non-nil, buffer is in RMAIL mode.
9734 (narrow-to-region (point-max) (point-max))))
9735 (insert-buffer-substring tmpbuf)
9738 (goto-char (point-min))
9740 (search-backward "\^_")
9741 (narrow-to-region (point) (point-max))
9742 (goto-char (1+ (point-min)))
9743 (rmail-count-new-messages t)
9744 (rmail-show-message msg)))))))
9745 (kill-buffer tmpbuf)))
9747 (defun gnus-output-to-file (file-name)
9748 "Append the current article to a file named FILE-NAME."
9749 (setq file-name (expand-file-name file-name))
9750 (let ((artbuf (current-buffer))
9751 (tmpbuf (get-buffer-create " *Gnus-output*")))
9754 (buffer-disable-undo (current-buffer))
9756 (insert-buffer-substring artbuf)
9757 ;; Append newline at end of the buffer as separator, and then
9759 (goto-char (point-max))
9761 (append-to-file (point-min) (point-max) file-name))
9762 (kill-buffer tmpbuf)))
9764 (defun gnus-convert-article-to-rmail ()
9765 "Convert article in current buffer to Rmail message format."
9766 (let ((buffer-read-only nil))
9767 ;; Convert article directly into Babyl format.
9768 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
9769 (goto-char (point-min))
9770 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
9771 (while (search-forward "\n\^_" nil t) ;single char
9772 (replace-match "\n^_")) ;2 chars: "^" and "_"
9773 (goto-char (point-max))
9776 (defun gnus-narrow-to-page (&optional arg)
9777 "Make text outside current page invisible except for page delimiter.
9778 A numeric arg specifies to move forward or backward by that many pages,
9779 thus showing a page other than the one point was originally in."
9781 (setq arg (if arg (prefix-numeric-value arg) 0))
9783 (forward-page -1) ;Beginning of current page.
9788 (forward-page (1- arg))))
9789 ;; Find the end of the page.
9791 ;; If we stopped due to end of buffer, stay there.
9792 ;; If we stopped after a page delimiter, put end of restriction
9793 ;; at the beginning of that line.
9794 ;; These are commented out.
9795 ;; (if (save-excursion (beginning-of-line)
9796 ;; (looking-at page-delimiter))
9797 ;; (beginning-of-line))
9798 (narrow-to-region (point)
9800 ;; Find the top of the page.
9802 ;; If we found beginning of buffer, stay there.
9803 ;; If extra text follows page delimiter on same line,
9805 ;; Otherwise, show text starting with following line.
9806 (if (and (eolp) (not (bobp)))
9810 (defun gnus-gmt-to-local ()
9811 "Rewrite Date header described in GMT to local in current buffer.
9812 Intended to be used with gnus-article-prepare-hook."
9816 (goto-char (point-min))
9817 (narrow-to-region (point-min)
9818 (progn (search-forward "\n\n" nil 'move) (point)))
9819 (goto-char (point-min))
9820 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
9821 (let ((buffer-read-only nil)
9822 (date (buffer-substring (match-beginning 1) (match-end 1))))
9823 (delete-region (match-beginning 1) (match-end 1))
9825 (timezone-make-date-arpa-standard
9826 date nil (current-time-zone))))))))
9829 ;; Article mode commands
9831 (defun gnus-article-next-page (lines)
9832 "Show next page of current article.
9833 If end of article, return non-nil. Otherwise return nil.
9834 Argument LINES specifies lines to be scrolled up."
9836 (move-to-window-line -1)
9837 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
9840 (and (pos-visible-in-window-p) ;Not continuation line.
9842 ;; Nothing in this page.
9843 (if (or (not gnus-break-pages)
9846 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
9848 (gnus-narrow-to-page 1) ;Go to next page.
9850 ;; More in this page.
9854 ;; Long lines may cause an end-of-buffer error.
9855 (goto-char (point-max))))
9858 (defun gnus-article-prev-page (lines)
9859 "Show previous page of current article.
9860 Argument LINES specifies lines to be scrolled down."
9862 (move-to-window-line 0)
9863 (if (and gnus-break-pages
9865 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
9867 (gnus-narrow-to-page -1) ;Go to previous page.
9868 (goto-char (point-max))
9870 (scroll-down lines)))
9872 (defun gnus-article-refer-article ()
9873 "Read article specified by message-id around point."
9875 (search-forward ">" nil t) ;Move point to end of "<....>".
9876 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
9878 (buffer-substring (match-beginning 1) (match-end 1))))
9879 (set-buffer gnus-summary-buffer)
9880 (gnus-summary-refer-article message-id))
9881 (error "No references around point")))
9883 (defun gnus-article-mail (yank)
9884 "Send a reply to the address near point.
9885 If YANK is non-nil, include the original article."
9889 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
9890 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
9893 (switch-to-buffer gnus-summary-buffer)
9894 (funcall gnus-mail-reply-method yank address)))))
9896 (defun gnus-article-mail-with-original ()
9897 "Send a reply to the address near point and include the original article."
9899 (gnus-article-mail 'yank))
9901 (defun gnus-article-show-summary ()
9902 "Reconfigure windows to show summary buffer."
9904 (gnus-configure-windows 'article)
9905 (pop-to-buffer gnus-summary-buffer)
9906 (gnus-summary-goto-subject gnus-current-article))
9908 (defun gnus-article-describe-briefly ()
9909 "Describe article mode commands briefly."
9912 (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")))
9914 (defun gnus-article-summary-command ()
9915 "Execute the last keystroke in the summary buffer."
9918 (let ((obuf (current-buffer))
9919 (owin (current-window-configuration)))
9920 (switch-to-buffer gnus-summary-buffer 'norecord)
9921 (execute-kbd-macro (this-command-keys))
9923 (let ((npoint (point)))
9924 (set-window-configuration owin)
9925 (set-window-start (get-buffer-window (current-buffer)) (point)))))
9927 ;; caesar-region written by phr@prep.ai.mit.edu Nov 86
9928 ;; Modified by tower@prep Nov 86
9929 ;; Modified by umerin@flab.flab.Fujitsu.JUNET for ROT47.
9931 (defun gnus-caesar-region (&optional n)
9932 "Caesar rotation of region by N, default 13, for decrypting netnews.
9933 ROT47 will be performed for Japanese text in any case."
9934 (interactive (if current-prefix-arg ; Was there a prefix arg?
9935 (list (prefix-numeric-value current-prefix-arg))
9937 (cond ((not (numberp n)) (setq n 13))
9938 (t (setq n (mod n 26)))) ;canonicalize N
9939 (if (not (zerop n)) ; no action needed for a rot of 0
9941 (if (or (not (boundp 'caesar-translate-table))
9942 (not caesar-translate-table)
9943 (/= (aref caesar-translate-table ?a) (+ ?a n)))
9945 (lower "abcdefghijklmnopqrstuvwxyz")
9947 (message "Building caesar-translate-table...")
9948 (setq caesar-translate-table (make-vector 256 0))
9950 (aset caesar-translate-table i i)
9952 (setq lower (concat lower lower)
9953 upper (upcase lower)
9956 (aset caesar-translate-table (+ ?a i) (aref lower (+ i n)))
9957 (aset caesar-translate-table (+ ?A i) (aref upper (+ i n)))
9959 ;; ROT47 for Japanese text.
9960 ;; Thanks to ichikawa@flab.fujitsu.junet.
9962 (let ((t1 (logior ?O 128))
9963 (t2 (logior ?! 128))
9964 (t3 (logior ?~ 128)))
9966 (aset caesar-translate-table i
9967 (let ((v (aref caesar-translate-table i)))
9968 (if (<= v t1) (if (< v t2) v (+ v 47))
9969 (if (<= v t3) (- v 47) v))))
9971 (message "Building caesar-translate-table... done")))
9972 (let ((from (region-beginning))
9975 (setq str (buffer-substring from to))
9976 (setq len (length str))
9978 (aset str i (aref caesar-translate-table (aref str i)))
9981 (delete-region from to)
9985 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
9988 (defalias 'gnus-batch-kill 'gnus-batch-score)
9990 (defun gnus-batch-score ()
9991 "Run batched scoring.
9992 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
9993 Newsgroups is a list of strings in Bnews format. If you want to score
9994 the comp hierarchy, you'd say \"comp.all\". If you would not like to
9995 score the alt hierarchy, you'd say \"!alt.all\"."
9998 (gnus-parse-n-options
9999 (apply (function concat)
10000 (mapcar (lambda (g) (concat g " "))
10001 command-line-args-left))))
10002 (gnus-expert-user t)
10003 (nnmail-spool-file nil)
10004 (gnus-use-dribble-file nil)
10005 (yes (car yes-and-no))
10006 (no (cdr yes-and-no))
10007 group subscribed newsrc entry
10008 ;; Disable verbose message.
10009 gnus-novice-user gnus-large-newsgroup)
10010 ;; Eat all arguments.
10011 (setq command-line-args-left nil)
10014 ;; Apply kills to specified newsgroups in command line arguments.
10015 (setq newsrc (cdr gnus-newsrc-assoc))
10017 (setq group (car (car newsrc)))
10018 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
10019 (if (and (<= (nth 1 (car newsrc)) 5)
10021 (or (eq (car entry) t)
10022 (not (zerop (car entry)))))
10023 (if yes (string-match yes group) t)
10024 (or (null no) (not (string-match no group))))
10026 (gnus-summary-read-group group nil t)
10027 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
10028 (gnus-summary-exit))))
10029 (setq newsrc (cdr newsrc)))
10031 (switch-to-buffer gnus-group-buffer)
10032 (gnus-group-save-newsrc)))
10034 (defun gnus-apply-kill-file ()
10035 "Apply a kill file to the current newsgroup.
10036 Returns the number of articles marked as read."
10037 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
10038 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
10039 (gnus-apply-kill-file-internal)
10042 (defun gnus-kill-save-kill-buffer ()
10044 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
10045 (if (get-file-buffer file)
10047 (set-buffer (get-file-buffer file))
10048 (and (buffer-modified-p) (save-buffer))
10049 (kill-buffer (current-buffer)))))))
10051 (defvar gnus-kill-file-name "KILL"
10052 "Suffix of the kill files.")
10054 (defun gnus-newsgroup-kill-file (newsgroup)
10055 "Return the name of a kill file name for NEWSGROUP.
10056 If NEWSGROUP is nil, return the global kill file name instead."
10057 (cond ((or (null newsgroup)
10058 (string-equal newsgroup ""))
10059 ;; The global KILL file is placed at top of the directory.
10060 (expand-file-name gnus-kill-file-name
10061 (or gnus-kill-files-directory "~/News")))
10062 ((gnus-use-long-file-name 'not-kill)
10063 ;; Append ".KILL" to newsgroup name.
10064 (expand-file-name (concat newsgroup "." gnus-kill-file-name)
10065 (or gnus-kill-files-directory "~/News")))
10067 ;; Place "KILL" under the hierarchical directory.
10068 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
10069 "/" gnus-kill-file-name)
10070 (or gnus-kill-files-directory "~/News")))))
10074 ;;; Gnus Score Files
10077 ;; All score code written by Per Abrahamsen <abraham@iesd.auc.dk>.
10079 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10080 (defun gnus-score-set-mark-below (score)
10081 "Automatically mark articles with score below SCORE as read."
10083 (list (or (and current-prefix-arg (prefix-numeric-value current-prefix-arg))
10084 (string-to-int (read-string "Mark below: ")))))
10085 (setq score (or score gnus-summary-default-score 0))
10086 (gnus-score-set 'mark (list score))
10087 (gnus-score-set 'touched '(t))
10088 (setq gnus-summary-mark-below score)
10089 (gnus-summary-update-lines))
10091 (defun gnus-score-set-expunge-below (score)
10092 "Automatically expunge articles with score below SCORE."
10094 (list (or (and current-prefix-arg (prefix-numeric-value current-prefix-arg))
10095 (string-to-int (read-string "Expunge below: ")))))
10096 (setq score (or score gnus-summary-default-score 0))
10097 (gnus-score-set 'expunge (list score))
10098 (gnus-score-set 'touched '(t)))
10100 (defun gnus-score-default (level)
10101 (if level (prefix-numeric-value level)
10102 gnus-score-interactive-default-score))
10104 (defun gnus-score-set (symbol value &optional alist)
10105 ;; Set SYMBOL to VALUE in ALIST.
10110 (gnus-score-load (gnus-score-file-name gnus-newsgroup-name))
10111 gnus-score-alist)))
10112 (entry (assoc symbol alist)))
10113 (cond ((gnus-score-get 'read-only alist)
10114 ;; This is a read-only score file, so we do nothing.
10117 (setcdr entry value))
10119 (error "Empty alist"))
10122 (cons (cons symbol value) (cdr alist)))))))
10124 (defun gnus-score-get (symbol &optional alist)
10125 ;; Get SYMBOL's definition in ALIST.
10131 (gnus-score-file-name gnus-newsgroup-name))
10132 gnus-score-alist)))))
10134 (defun gnus-score-change-score-file (file)
10135 "Change current score alist."
10137 (list (completing-read "Score file: " gnus-score-cache)))
10138 (setq gnus-current-score-file file)
10139 (gnus-score-load-file file)
10140 (gnus-set-mode-line 'summary))
10142 (defun gnus-score-edit-alist (file)
10143 "Edit the current score alist."
10144 (interactive (list gnus-current-score-file))
10145 (and (buffer-name gnus-summary-buffer) (gnus-score-save))
10146 (setq gnus-winconf-edit-score (current-window-configuration))
10147 (gnus-configure-windows 'article)
10148 (pop-to-buffer (find-file-noselect file))
10149 (message (substitute-command-keys
10150 "\\<gnus-score-mode-map>\\[gnus-score-edit-done] to save edits"))
10153 (defun gnus-score-edit-file (file)
10154 "Edit a score file."
10156 (list (read-file-name "Edit score file: " gnus-kill-files-directory)))
10157 (and (buffer-name gnus-summary-buffer) (gnus-score-save))
10158 (setq gnus-winconf-edit-score (current-window-configuration))
10159 (gnus-configure-windows 'article)
10160 (pop-to-buffer (find-file-noselect file))
10161 (message (substitute-command-keys
10162 "\\<gnus-score-mode-map>\\[gnus-score-edit-done] to save edits"))
10165 (defun gnus-score-load-file (file)
10166 ;; Load score file FILE. Returns a list a retrieved score-alists.
10167 (setq gnus-kill-files-directory (or gnus-kill-files-directory "~/News/"))
10168 (let* ((file (expand-file-name
10169 (or (and (string-match
10170 (concat "^" (expand-file-name
10171 gnus-kill-files-directory))
10172 (expand-file-name file))
10174 (concat gnus-kill-files-directory file))))
10175 (cached (assoc file gnus-score-cache))
10176 (global (member file gnus-internal-global-score-files))
10179 ;; The score file was already loaded.
10180 (setq alist (cdr cached))
10181 ;; We load the score file.
10182 (setq gnus-score-alist nil)
10183 (setq alist (gnus-score-load-score-alist file))
10184 ;; We add '(touched) to the alist to signify that it hasn't been
10186 (or (assq 'touched alist) (setq alist (cons (list 'touched nil) alist)))
10187 ;; If it is a global score file, we make it read-only.
10189 (not (assq 'read-only alist))
10190 (setq alist (cons (list 'read-only t) alist)))
10192 (setq gnus-score-cache
10193 (cons (cons file alist) gnus-score-cache)))
10194 ;; If there are actual scores in the alist, we add it to the
10195 ;; return value of this function.
10196 (if (memq t (mapcar (lambda (e) (stringp (car e))) alist))
10197 (setq lists (list alist)))
10198 ;; Treat the other possible atoms in the score alist.
10199 (let ((mark (car (gnus-score-get 'mark alist)))
10200 (expunge (car (gnus-score-get 'expunge alist)))
10202 (car (gnus-score-get 'mark-and-expunge alist)))
10203 (read-only (gnus-score-get 'read-only alist))
10204 (files (gnus-score-get 'files alist))
10205 (exclude-files (gnus-score-get 'exclude-files alist))
10206 (orphan (gnus-score-get 'orphan alist))
10207 (eval (gnus-score-get 'eval alist)))
10208 ;; We do not respect eval and files atoms from global score
10210 (and files (not global)
10211 (setq lists (apply 'append lists
10212 (mapcar (lambda (file)
10213 (gnus-score-load-file file))
10215 (and eval (not global) (eval eval))
10216 (setq gnus-scores-exclude-files exclude-files)
10217 (if orphan (setq gnus-orphan-score (car orphan)))
10218 (setq gnus-summary-mark-below
10219 (or mark mark-and-expunge gnus-summary-mark-below))
10220 (setq gnus-summary-expunge-below
10221 (or expunge mark-and-expunge gnus-summary-expunge-below)))
10222 (setq gnus-current-score-file file)
10223 (setq gnus-score-alist alist)
10226 (defun gnus-score-load (file)
10227 ;; Load score FILE.
10228 (let ((cache (assoc file gnus-score-cache)))
10230 (setq gnus-score-alist (cdr cache))
10231 (setq gnus-score-alist nil)
10232 (gnus-score-load-score-alist file)
10233 (or gnus-score-alist
10234 (setq gnus-score-alist (copy-alist '((touched nil)))))
10235 (setq gnus-score-cache
10236 (cons (cons file gnus-score-alist) gnus-score-cache)))))
10238 (defun gnus-score-remove-from-cache (file)
10239 (setq gnus-score-cache
10240 (delq (assoc file gnus-score-cache) gnus-score-cache)))
10242 (defun gnus-score-load-score-alist (file)
10244 (if (file-readable-p file)
10247 (set-buffer (get-buffer-create " *gnus work*"))
10248 (buffer-disable-undo (current-buffer))
10250 (insert-file-contents file)
10251 (goto-char (point-min))
10252 ;; Only do the loading if the score file isn't empty.
10253 (if (save-excursion (re-search-forward "[()0-9a-zA-Z]" nil t))
10256 (read (current-buffer))
10259 (message "Problem with score file %s" file)
10263 (if (eq (car alist) 'setq)
10264 (setq gnus-score-alist (gnus-score-transform-old-to-new alist))
10265 (setq gnus-score-alist alist))
10266 (setq gnus-score-alist
10267 (gnus-score-check-syntax gnus-score-alist)))
10268 (setq gnus-score-alist nil))))
10270 (defun gnus-score-check-syntax (alist)
10274 ((not (consp alist))
10275 (message "Score file is not a list: %s" alist)
10281 (while (and a (not err))
10282 (cond ((not (listp (car a)))
10283 (message "Illegal score element: %s" (car a))
10285 ((and (stringp (car (car a)))
10286 (not (listp (nth 1 (car a)))))
10287 (message "Illegal header match: %s" (nth 1 (car a)))
10290 (setq a (cdr a)))))
10297 (defun gnus-score-transform-old-to-new (alist)
10298 (let* ((alist (nth 2 alist))
10300 (if (eq (car alist) 'quote)
10301 (setq alist (nth 1 alist)))
10303 (setq entry (car alist))
10304 (if (stringp (car entry))
10305 (let ((scor (cdr entry)))
10306 (setq out (cons entry out))
10309 (list (car (car scor)) (nth 2 (car scor))
10310 (and (nth 3 (car scor))
10311 (gnus-day-number (nth 3 (car scor))))
10312 (if (nth 1 (car scor)) 'r 's)))
10313 (setq scor (cdr scor))))
10314 (setq out (cons (if (not (listp (cdr entry)))
10315 (list (car entry) (cdr entry))
10318 (setq alist (cdr alist)))
10319 (cons (list 'touched t) (nreverse out))))
10321 (defun gnus-score-save ()
10322 ;; Save all SCORE information.
10323 (let ((cache gnus-score-cache))
10325 (setq gnus-score-alist nil)
10326 (set-buffer (get-buffer-create "*Score*"))
10327 (buffer-disable-undo (current-buffer))
10328 (let (entry score file)
10330 (setq entry (car cache)
10334 (if (or (not (equal (gnus-score-get 'touched score) '(t)))
10335 (gnus-score-get 'read-only score)
10336 (not (file-writable-p file)))
10338 (setq score (delq (assq 'touched score) score))
10340 (let (emacs-lisp-mode-hook)
10341 (pp score (current-buffer)))
10342 (gnus-make-directory (file-name-directory file))
10343 (write-region (point-min) (point-max) file nil 'silent))))
10344 (kill-buffer (current-buffer)))))
10346 (defun gnus-score-headers ()
10347 ;; Score `gnus-newsgroup-headers'.
10348 (let ((func gnus-score-find-score-files-function)
10349 score-files scores)
10350 (and func (not (listp func))
10351 (setq func (list func)))
10352 ;; Go through all the functions for finding score files (or actual
10353 ;; scores) and add them to a list.
10355 (and (symbolp (car func))
10356 (fboundp (car func))
10358 (nconc score-files (funcall (car func) gnus-newsgroup-name))))
10359 (setq func (cdr func)))
10360 ;; PLM: probably this is not the best place to clear orphan-score
10361 (setq gnus-orphan-score nil)
10362 ;; Load the SCORE files.
10364 (if (stringp (car score-files))
10365 ;; It is a string, which means that it's a score file name,
10366 ;; so we load the score file and add the score alist to
10367 ;; the list of alists.
10368 (setq scores (nconc (gnus-score-load-file (car score-files)) scores))
10369 ;; It is an alist, so we just add it to the list directly.
10370 (setq scores (nconc (car score-files) scores)))
10371 (setq score-files (cdr score-files)))
10372 ;; Prune the score files that are to be excluded, if any.
10373 (if (not gnus-scores-exclude-files)
10378 (and (setq c (rassq (car s) gnus-score-cache))
10379 (member (car c) gnus-scores-exclude-files)
10380 (setq scores (delq (car s) scores)))
10381 (setq s (cdr s)))))
10382 (if (not (and gnus-summary-default-score
10384 (> (length gnus-newsgroup-headers)
10385 (length gnus-newsgroup-scored))))
10387 (let* ((entries gnus-header-index)
10388 (now (gnus-day-number (current-time-string)))
10389 (expire (- now gnus-score-expiry-days))
10390 (headers gnus-newsgroup-headers)
10392 (message "Scoring...")
10393 ;; Create articles, an alist of the form `(HEADER . SCORE)'.
10395 (setq header (car headers)
10396 headers (cdr headers))
10397 ;; WARNING: The assq makes the function O(N*S) while it could
10398 ;; be written as O(N+S), where N is (length gnus-newsgroup-headers)
10399 ;; and S is (length gnus-newsgroup-scored).
10400 (or (assq (header-number header) gnus-newsgroup-scored)
10401 (setq gnus-scores-articles ;Total of 2 * N cons-cells used.
10402 (cons (cons header (or gnus-summary-default-score 0))
10403 gnus-scores-articles))))
10406 (set-buffer (get-buffer-create "*Headers*"))
10407 (buffer-disable-undo (current-buffer))
10409 (if gnus-orphan-score
10411 (setq gnus-score-index
10412 (nth 1 (assoc "references" gnus-header-index)))
10413 (gnus-score-orphans gnus-orphan-score)))
10414 ;; Run each header through the score process.
10416 (setq entry (car entries)
10417 header (nth 0 entry)
10418 entries (cdr entries))
10419 (setq gnus-score-index (nth 1 (assoc header gnus-header-index)))
10420 (if (< 0 (apply 'max (mapcar
10422 (length (gnus-score-get header score)))
10424 (funcall (nth 2 entry) scores header now expire)))
10425 ;; Remove the buffer.
10426 (kill-buffer (current-buffer)))
10428 ;; Add articles to `gnus-newsgroup-scored'.
10429 (while gnus-scores-articles
10430 (or (= gnus-summary-default-score (cdr (car gnus-scores-articles)))
10431 (setq gnus-newsgroup-scored
10432 (cons (cons (header-number
10433 (car (car gnus-scores-articles)))
10434 (cdr (car gnus-scores-articles)))
10435 gnus-newsgroup-scored)))
10436 (setq gnus-scores-articles (cdr gnus-scores-articles)))
10438 (message "Scoring...done")))))
10441 (defun gnus-get-new-thread-ids (articles)
10442 (let ((index (nth 1 (assoc "message-id" gnus-header-index)))
10443 (refind gnus-score-index)
10444 id-list art this tref)
10446 (setq art (car articles)
10447 this (aref (car art) index)
10448 tref (aref (car art) refind)
10449 articles (cdr articles))
10450 (if (string-equal tref "") ;no references line
10451 (setq id-list (cons this id-list))))
10454 ;; Orphan functions written by plm@atcmp.nl (Peter Mutsaers).
10455 (defun gnus-score-orphans (score)
10456 (let ((new-thread-ids (gnus-get-new-thread-ids gnus-scores-articles))
10457 (index (nth 1 (assoc "references" gnus-header-index)))
10458 alike articles art arts this last this-id)
10460 (setq gnus-scores-articles (sort gnus-scores-articles 'gnus-score-string<)
10461 articles gnus-scores-articles)
10463 ;;more or less the same as in gnus-score-string
10466 (setq art (car articles)
10467 this (aref (car art) gnus-score-index)
10468 articles (cdr articles))
10469 ;;completely skip if this is empty (not a child, so not an orphan)
10470 (if (not (string= this ""))
10471 (if (equal last this)
10472 ;; O(N*H) cons-cells used here, where H is the number of
10474 (setq alike (cons art alike))
10477 ;; Insert the line, with a text property on the
10478 ;; terminating newline refering to the articles with
10481 (put-text-property (1- (point)) (point) 'articles alike)))
10482 (setq alike (list art)
10484 (and last ; Bwadr, duplicate code.
10487 (put-text-property (1- (point)) (point) 'articles alike)))
10489 ;; PLM: now delete those lines that contain an entry from new-thread-ids
10490 (while new-thread-ids
10491 (setq this-id (car new-thread-ids)
10492 new-thread-ids (cdr new-thread-ids))
10493 (goto-char (point-min))
10494 (while (search-forward this-id nil t)
10495 ;; found a match. remove this line
10496 (beginning-of-line)
10499 ;; now for each line: update its articles with score by moving to
10500 ;; every end-of-line in the buffer and read the articles property
10501 (goto-char (point-min))
10502 (while (eq 0 (progn
10504 (setq arts (get-text-property (point) 'articles))
10506 (setq art (car arts)
10508 (setcdr art (+ score (cdr art))))
10509 (forward-line))))))
10512 (defun gnus-score-integer (scores header now expire)
10513 (let ((gnus-score-index (nth 1 (assoc header gnus-header-index)))
10514 alike last this art entries alist articles)
10518 (setq alist (car scores)
10519 scores (cdr scores)
10520 entries (assoc header alist))
10521 (while (cdr entries) ;First entry is the header index.
10522 (let* ((rest (cdr entries))
10524 (match (nth 0 kill))
10525 (type (or (nth 3 kill) '>))
10526 (score (or (nth 1 kill) gnus-score-interactive-default-score))
10527 (date (nth 2 kill))
10529 (match-func (if (or (eq type '>) (eq type '<) (eq type '<=)
10530 (eq type '>=) (eq type '=))
10532 (error "Illegal match type: %s" type)))
10533 (articles gnus-scores-articles)
10535 ;; Instead of doing all the clever stuff that
10536 ;; `gnus-score-string' does to minimize searches and stuff,
10537 ;; I will assume that people generally will put so few
10538 ;; matches on numbers that any cleverness will take more
10539 ;; time than one would gain.
10541 (and (funcall match-func match
10542 (or (aref (car (car articles)) gnus-score-index) 0))
10545 (setcdr (car articles) (+ score (cdr (car articles))))))
10546 (setq articles (cdr articles)))
10547 ;; Update expire date
10548 (cond ((null date)) ;Permanent entry.
10549 (found ;Match, update date.
10550 (gnus-score-set 'touched '(t) alist)
10551 (setcar (nthcdr 2 kill) now))
10552 ((< date expire) ;Old entry, remove.
10553 (gnus-score-set 'touched '(t) alist)
10554 (setcdr entries (cdr rest))
10555 (setq rest entries)))
10556 (setq entries rest))))))
10558 (defun gnus-score-date (scores header now expire)
10559 (let ((gnus-score-index (nth 1 (assoc header gnus-header-index)))
10560 alike last this art entries alist articles)
10564 (setq alist (car scores)
10565 scores (cdr scores)
10566 entries (assoc header alist))
10567 (while (cdr entries) ;First entry is the header index.
10568 (let* ((rest (cdr entries))
10570 (match (timezone-make-date-sortable (nth 0 kill)))
10571 (type (or (nth 3 kill) 'before))
10572 (score (or (nth 1 kill) gnus-score-interactive-default-score))
10573 (date (nth 2 kill))
10576 (cond ((eq type 'after) 'string<)
10577 ((eq type 'before) 'gnus-string>)
10578 ((eq type 'at) 'string=)
10579 (t (error "Illegal match type: %s" type))))
10580 (articles gnus-scores-articles)
10582 ;; Instead of doing all the clever stuff that
10583 ;; `gnus-score-string' does to minimize searches and stuff,
10584 ;; I will assume that people generally will put so few
10585 ;; matches on numbers that any cleverness will take more
10586 ;; time than one would gain.
10589 (setq l (aref (car (car articles)) gnus-score-index))
10590 (funcall match-func match (timezone-make-date-sortable l))
10593 (setcdr (car articles) (+ score (cdr (car articles))))))
10594 (setq articles (cdr articles)))
10595 ;; Update expire date
10596 (cond ((null date)) ;Permanent entry.
10597 (found ;Match, update date.
10598 (gnus-score-set 'touched '(t) alist)
10599 (setcar (nthcdr 2 kill) now))
10600 ((< date expire) ;Old entry, remove.
10601 (gnus-score-set 'touched '(t) alist)
10602 (setcdr entries (cdr rest))
10603 (setq rest entries)))
10604 (setq entries rest))))))
10606 (defun gnus-score-body (scores header now expire)
10608 (set-buffer nntp-server-buffer)
10610 (let* ((buffer-read-only nil)
10611 (articles gnus-scores-articles)
10612 (all-scores scores)
10613 (request-func (cond ((string= "head" (downcase header))
10614 'gnus-request-head)
10615 ((string= "body" (downcase header))
10616 'gnus-request-body)
10617 (t 'gnus-request-article)))
10618 alike last this art entries alist ofunc article)
10619 ;; Not all backends support partial fetching. In that case,
10620 ;; we just fetch the entire article.
10621 (or (gnus-check-backend-function request-func gnus-newsgroup-name)
10623 (setq ofunc request-func)
10624 (setq request-func 'gnus-request-article)))
10626 (setq article (header-number (car (car articles))))
10627 (message "Scoring on article %s..." article)
10628 (if (not (funcall request-func article gnus-newsgroup-name))
10631 (goto-char (point-min))
10632 ;; If just parts of the article is to be searched, but the
10633 ;; backend didn't support partial fetching, we just narrow
10634 ;; to the relevant parts.
10636 (if (eq ofunc 'gnus-request-head)
10639 (or (search-forward "\n\n" nil t) (point-max)))
10641 (or (search-forward "\n\n" nil t) (point))
10643 (setq scores all-scores)
10646 (setq alist (car scores)
10647 scores (cdr scores)
10648 entries (assoc header alist))
10649 (while (cdr entries) ;First entry is the header index.
10650 (let* ((rest (cdr entries))
10652 (match (nth 0 kill))
10653 (type (or (nth 3 kill) 's))
10654 (score (or (nth 1 kill)
10655 gnus-score-interactive-default-score))
10656 (date (nth 2 kill))
10659 (not (or (eq type 'R) (eq type 'S)
10660 (eq type 'Regexp) (eq type 'String))))
10662 (cond ((or (eq type 'r) (eq type 'R)
10663 (eq type 'regexp) (eq type 'Regexp))
10664 're-search-forward)
10665 ((or (eq type 's) (eq type 'S)
10666 (eq type 'string) (eq type 'String))
10669 (error "Illegal match type: %s" type))))
10671 (goto-char (point-min))
10672 (if (funcall search-func match nil t)
10673 ;; Found a match, update scores.
10675 (setcdr (car articles) (+ score (cdr (car articles))))
10677 ;; Update expire date
10678 (cond ((null date)) ;Permanent entry.
10679 (found ;Match, update date.
10680 (gnus-score-set 'touched '(t) alist)
10681 (setcar (nthcdr 2 kill) now))
10682 ((< date expire) ;Old entry, remove.
10683 (gnus-score-set 'touched '(t) alist)
10684 (setcdr entries (cdr rest))
10685 (setq rest entries)))
10686 (setq entries rest)))))
10687 (setq articles (cdr articles)))))))
10689 (defun gnus-score-string (scores header now expire)
10690 ;; Score ARTICLES according to HEADER in SCORES.
10691 ;; Update matches entries to NOW and remove unmatched entried older
10694 ;; Insert the unique article headers in the buffer.
10695 (let ((gnus-score-index (nth 1 (assoc header gnus-header-index)))
10696 ;; gnus-score-index is used as a free variable.
10697 alike last this art entries alist articles)
10699 ;; Sorting the articles costs os O(N*log N) but will allow us to
10700 ;; only match with each unique header. Thus the actual matching
10701 ;; will be O(M*U) where M is the number of strings to match with,
10702 ;; and U is the number of unique headers. It is assumed (but
10703 ;; untested) this will be a net win because of the large constant
10704 ;; factor involved with string matching.
10705 (setq gnus-scores-articles (sort gnus-scores-articles 'gnus-score-string<)
10706 articles gnus-scores-articles)
10710 (setq art (car articles)
10711 this (aref (car art) gnus-score-index)
10712 articles (cdr articles))
10713 (if (equal last this)
10714 ;; O(N*H) cons-cells used here, where H is the number of
10716 (setq alike (cons art alike))
10719 ;; Insert the line, with a text property on the
10720 ;; terminating newline refering to the articles with
10723 (put-text-property (1- (point)) (point) 'articles alike)))
10724 (setq alike (list art)
10726 (and last ; Bwadr, duplicate code.
10729 (put-text-property (1- (point)) (point) 'articles alike)))
10733 (setq alist (car scores)
10734 scores (cdr scores)
10735 entries (assoc header alist))
10736 (while (cdr entries) ;First entry is the header index.
10737 (let* ((rest (cdr entries))
10739 (match (nth 0 kill))
10740 (type (or (nth 3 kill) 's))
10741 (score (or (nth 1 kill) gnus-score-interactive-default-score))
10742 (date (nth 2 kill))
10745 (not (or (eq type 'R) (eq type 'S)
10746 (eq type 'Regexp) (eq type 'String))))
10747 (search-func (cond ((or (eq type 'r) (eq type 'R)
10748 (eq type 'regexp) (eq type 'Regexp))
10749 're-search-forward)
10750 ((or (eq type 's) (eq type 'S)
10751 (eq type 'string) (eq type 'String))
10754 (error "Illegal match type: %s" type))))
10756 (goto-char (point-min))
10757 (while (funcall search-func match nil t)
10760 arts (get-text-property (point) 'articles))
10761 ;; Found a match, update scores.
10763 (setq art (car arts)
10765 (setcdr art (+ score (cdr art)))))
10766 ;; Update expire date
10767 (cond ((null date)) ;Permanent entry.
10768 (found ;Match, update date.
10769 (gnus-score-set 'touched '(t) alist)
10770 (setcar (nthcdr 2 kill) now))
10771 ((< date expire) ;Old entry, remove.
10772 (gnus-score-set 'touched '(t) alist)
10773 (setcdr entries (cdr rest))
10774 (setq rest entries)))
10775 (setq entries rest))))))
10777 (defun gnus-score-string< (a1 a2)
10778 ;; Compare headers in articles A2 and A2.
10779 ;; The header index used is the free variable `gnus-score-index'.
10780 (string-lessp (aref (car a1) gnus-score-index)
10781 (aref (car a2) gnus-score-index)))
10783 (defun gnus-score-build-cons (article)
10784 ;; Build a `gnus-newsgroup-scored' type cons from ARTICLE.
10785 (cons (header-number (car article)) (cdr article)))
10787 (defconst gnus-header-index
10788 ;; Name to index alist.
10789 '(("number" 0 gnus-score-integer)
10790 ("subject" 1 gnus-score-string)
10791 ("from" 2 gnus-score-string)
10792 ("date" 3 gnus-score-date)
10793 ("message-id" 4 gnus-score-string)
10794 ("references" 5 gnus-score-string)
10795 ("chars" 6 gnus-score-integer)
10796 ("lines" 7 gnus-score-integer)
10797 ("xref" 8 gnus-score-string)
10798 ("head" -1 gnus-score-body)
10799 ("body" -1 gnus-score-body)
10800 ("all" -1 gnus-score-body)))
10802 (defun gnus-score-file-name (newsgroup)
10803 "Return the name of a score file for NEWSGROUP."
10804 (cond ((or (null newsgroup)
10805 (string-equal newsgroup ""))
10806 ;; The global score file is placed at top of the directory.
10807 (expand-file-name gnus-score-file-suffix
10808 (or gnus-kill-files-directory "~/News")))
10809 ((gnus-use-long-file-name 'not-score)
10810 ;; Append ".SCORE" to newsgroup name.
10811 (expand-file-name (concat newsgroup "." gnus-score-file-suffix)
10812 (or gnus-kill-files-directory "~/News")))
10814 ;; Place "SCORE" under the hierarchical directory.
10815 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
10816 "/" gnus-score-file-suffix)
10817 (or gnus-kill-files-directory "~/News")))))
10819 (defun gnus-score-score-files (group)
10820 "Return a list of all possible score files."
10821 (and gnus-global-score-files
10822 (or gnus-internal-global-score-files
10823 (gnus-score-search-global-directories gnus-global-score-files)))
10824 (setq gnus-kill-files-directory
10825 (file-name-as-directory
10826 (or gnus-kill-files-directory "~/News/")))
10827 (if (not (file-readable-p gnus-kill-files-directory))
10828 (setq gnus-score-file-list nil)
10829 (if (gnus-use-long-file-name 'not-score)
10830 (if (or (not gnus-score-file-list)
10831 (gnus-file-newer-than gnus-kill-files-directory
10832 (car gnus-score-file-list)))
10833 (setq gnus-score-file-list
10834 (cons (nth 5 (file-attributes gnus-kill-files-directory))
10837 gnus-kill-files-directory t
10838 (concat gnus-score-file-suffix "$"))))))
10839 (let ((dir (expand-file-name
10840 (concat gnus-kill-files-directory
10841 (gnus-replace-chars-in-string group ?. ?/))))
10842 (mdir (length (expand-file-name gnus-kill-files-directory)))
10844 (if (file-exists-p (concat dir "/" gnus-score-file-suffix))
10845 (setq files (list (concat dir "/" gnus-score-file-suffix))))
10846 (while (>= (1+ (length dir)) mdir)
10847 (and (file-exists-p (concat dir "/all/" gnus-score-file-suffix))
10848 (setq files (cons (concat dir "/all/" gnus-score-file-suffix)
10850 (string-match "/[^/]*$" dir)
10851 (setq dir (substring dir 0 (match-beginning 0))))
10852 (setq gnus-score-file-list
10853 (cons nil (nreverse files)))))
10854 (cdr gnus-score-file-list)))
10856 (defun gnus-score-find-single (group)
10857 "Return list containing the score file for GROUP."
10858 (list (gnus-score-file-name group)))
10860 (defun gnus-score-find-hierarchical (group)
10861 "Return list of score files for GROUP.
10862 This includes the score file for the group and all its parents."
10863 (let ((all (copy-sequence '(nil)))
10865 (while (string-match "\\." group (1+ start))
10866 (setq start (match-beginning 0))
10867 (setq all (cons (substring group 0 start) all)))
10868 (setq all (cons group all))
10869 (mapcar 'gnus-score-file-name (nreverse all))))
10871 (defun gnus-score-find-bnews (group)
10872 "Return a list of score files for GROUP.
10873 The score files are those files in the ~/News directory which matches
10874 GROUP using BNews sys file syntax."
10875 (let* ((sfiles (append (gnus-score-score-files group)
10876 gnus-internal-global-score-files))
10877 (kill-dir (file-name-as-directory
10878 (expand-file-name gnus-kill-files-directory)))
10879 (klen (length kill-dir))
10880 ofiles not-match regexp)
10882 (set-buffer (get-buffer-create "*gnus score files*"))
10883 (buffer-disable-undo (current-buffer))
10884 ;; Go through all score file names and create regexp with them
10888 (insert (car sfiles))
10890 ;; First remove the suffix itself.
10891 (re-search-forward (concat "." gnus-score-file-suffix "$"))
10894 (if (looking-at (regexp-quote kill-dir))
10895 ;; If the file name was just "SCORE", `klen' is one character
10897 (delete-char (min (1- (point-max)) klen))
10898 (goto-char (point-max))
10899 (search-backward "/")
10900 (delete-region (1+ (point)) (point-min)))
10901 ;; Translate "all" to ".*".
10902 (while (search-forward "all" nil t)
10903 (replace-match ".*"))
10905 ;; Deal with "not."s.
10906 (if (looking-at "not.")
10909 (setq regexp (buffer-substring 5 (point-max))))
10910 (setq regexp (buffer-substring 1 (point-max)))
10911 (setq not-match nil))
10912 ;; Finally - if this resulting regexp matches the group name,
10913 ;; we add this score file to the list of score files
10914 ;; applicable to this group.
10915 (if (or (and not-match
10916 (not (string-match regexp group)))
10917 (and (not not-match)
10918 (string-match regexp group)))
10919 (setq ofiles (cons (car sfiles) ofiles)))
10920 (setq sfiles (cdr sfiles)))
10921 (kill-buffer (current-buffer))
10922 ;; Slight kludge here - the last score file returned should be
10923 ;; the local score file, whether it exists or not. This is so
10924 ;; that any score commands the user enters will go to the right
10925 ;; file, and not end up in some global score file.
10928 (if (gnus-use-long-file-name 'not-score)
10929 (concat gnus-kill-files-directory group "."
10930 gnus-score-file-suffix)
10931 (concat gnus-kill-files-directory
10932 (gnus-replace-chars-in-string group ?. ?/)
10933 "/" gnus-score-file-suffix)))))
10934 (and (member localscore ofiles)
10935 (delete localscore ofiles))
10936 (setq ofiles (cons localscore ofiles)))
10937 (nreverse ofiles))))
10939 (defun gnus-score-search-global-directories (files)
10940 "Scan all global score directories for score files."
10941 ;; Set the variable `gnus-internal-global-score-files' to all
10942 ;; available global score files.
10943 (interactive (list gnus-global-score-files))
10946 (if (string-match "/$" (car files))
10947 (setq out (nconc (directory-files
10949 (concat gnus-score-file-suffix "$"))))
10950 (setq out (cons (car files) out)))
10951 (setq files (cdr files)))
10952 (setq gnus-internal-global-score-files out)))
10954 (defun gnus-current-score-file-nondirectory (&optional score-file)
10955 (let ((score-file (or score-file gnus-current-score-file)))
10957 (gnus-short-group-name (file-name-nondirectory score-file))
10964 (defvar gnus-score-mode-map nil)
10965 (defvar gnus-score-mode-hook nil)
10967 (if gnus-score-mode-map
10969 (setq gnus-score-mode-map (copy-keymap emacs-lisp-mode-map))
10970 (define-key gnus-score-mode-map "\C-c\C-c" 'gnus-score-edit-done)
10971 (define-key gnus-score-mode-map "\C-c\C-d" 'gnus-score-edit-insert-date))
10973 (defun gnus-score-mode ()
10974 "Mode for editing score files.
10975 This mode is an extended emacs-lisp mode.
10977 \\{gnus-score-mode-map}"
10979 (kill-all-local-variables)
10980 (use-local-map gnus-score-mode-map)
10981 (set-syntax-table emacs-lisp-mode-syntax-table)
10982 (setq major-mode 'gnus-score-mode)
10983 (setq mode-name "Score")
10984 (lisp-mode-variables nil)
10985 (run-hooks 'emacs-lisp-mode-hook 'gnus-score-mode-hook))
10987 (defun gnus-score-edit-insert-date ()
10988 "Insert date in numerical format."
10990 (insert (int-to-string (gnus-day-number (current-time-string)))))
10992 (defun gnus-score-edit-done ()
10993 "Save the score file and return to the summary buffer."
10995 (let ((bufnam (buffer-file-name (current-buffer))))
10997 (kill-buffer (current-buffer))
10998 (and gnus-winconf-edit-score
10999 (set-window-configuration gnus-winconf-edit-score))
11000 (gnus-score-remove-from-cache bufnam)
11001 (gnus-score-load-file bufnam)))
11005 ;;; Gnus Posting Functions
11008 (defvar gnus-organization-file "/usr/lib/news/organization"
11009 "*Local news organization file.")
11011 (defvar gnus-post-news-buffer "*post-news*")
11012 (defvar gnus-winconf-post-news nil)
11014 ;;; Post news commands of Gnus group mode and summary mode
11016 (defun gnus-group-post-news ()
11019 (gnus-set-global-variables)
11020 ;; Save window configuration.
11021 (setq gnus-winconf-post-news (current-window-configuration))
11022 (let ((gnus-newsgroup-name nil))
11024 (gnus-post-news 'post)
11025 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
11026 (not (zerop (buffer-size))))
11027 ;; Restore last window configuration.
11028 (and gnus-winconf-post-news
11029 (set-window-configuration gnus-winconf-post-news)))))
11030 ;; We don't want to return to summary buffer nor article buffer later.
11031 (setq gnus-winconf-post-news nil)
11032 (if (get-buffer gnus-summary-buffer)
11033 (bury-buffer gnus-summary-buffer))
11034 (if (get-buffer gnus-article-buffer)
11035 (bury-buffer gnus-article-buffer)))
11037 (defun gnus-summary-post-news ()
11040 (gnus-set-global-variables)
11041 ;; Save window configuration.
11042 (setq gnus-winconf-post-news (current-window-configuration))
11044 (gnus-post-news 'post gnus-newsgroup-name)
11045 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
11046 (not (zerop (buffer-size))))
11047 ;; Restore last window configuration.
11048 (and gnus-winconf-post-news
11049 (set-window-configuration gnus-winconf-post-news))))
11050 ;; We don't want to return to article buffer later.
11051 (if (get-buffer gnus-article-buffer)
11052 (bury-buffer gnus-article-buffer)))
11054 (defun gnus-summary-followup (yank)
11055 "Compose a followup to an article.
11056 If prefix argument YANK is non-nil, original article is yanked automatically."
11058 (gnus-set-global-variables)
11059 (save-window-excursion
11060 (gnus-summary-select-article t))
11061 (let ((headers gnus-current-headers)
11062 (gnus-newsgroup-name gnus-newsgroup-name))
11063 ;; Check Followup-To: poster.
11064 (set-buffer gnus-article-buffer)
11065 (if (and gnus-use-followup-to
11066 (string-equal "poster" (gnus-fetch-field "followup-to"))
11067 (or (not (eq gnus-use-followup-to t))
11068 (not (gnus-y-or-n-p
11069 "Do you want to ignore `Followup-To: poster'? "))))
11070 ;; Mail to the poster. Gnus is now RFC1036 compliant.
11071 (gnus-summary-reply yank)
11072 ;; Save window configuration.
11073 (setq gnus-winconf-post-news (current-window-configuration))
11075 (gnus-post-news nil gnus-newsgroup-name
11076 headers gnus-article-buffer yank)
11077 (or (and (eq (current-buffer) (get-buffer gnus-post-news-buffer))
11078 (not (zerop (buffer-size))))
11079 ;; Restore last window configuration.
11080 (and gnus-winconf-post-news
11081 (set-window-configuration gnus-winconf-post-news))))
11082 ;; We don't want to return to article buffer later.
11083 (bury-buffer gnus-article-buffer)))
11084 (gnus-article-hide-headers-if-wanted))
11086 (defun gnus-summary-followup-with-original ()
11087 "Compose a followup to an article and include the original article."
11089 (gnus-summary-followup t))
11091 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11092 (defun gnus-summary-followup-and-reply (yank)
11093 "Compose a followup and do an auto mail to author."
11095 (let ((gnus-auto-mail-to-author t))
11096 (gnus-summary-followup yank)))
11098 (defun gnus-summary-followup-and-reply-with-original ()
11099 "Compose a followup, include the original, and do an auto mail to author."
11101 (gnus-summary-followup-and-reply t))
11103 (defun gnus-summary-cancel-article ()
11104 "Cancel an article you posted."
11106 (gnus-set-global-variables)
11107 (gnus-summary-select-article t)
11108 (gnus-eval-in-buffer-window gnus-article-buffer (gnus-cancel-news))
11109 (gnus-article-hide-headers-if-wanted))
11111 (defun gnus-summary-supersede-article ()
11112 "Compose an article that will supersede a previous article.
11113 This is done simply by taking the old article and adding a Supersedes
11114 header line with the old Message-ID."
11116 (gnus-set-global-variables)
11119 (downcase (mail-strip-quoted-names
11120 (header-from gnus-current-headers)))
11121 (downcase (mail-strip-quoted-names (gnus-inews-user-name)))))
11122 (error "This article is not yours."))
11123 (gnus-summary-select-article t)
11125 (set-buffer gnus-article-buffer)
11126 (let ((buffer-read-only nil))
11127 (goto-char (point-min))
11128 (search-forward "\n\n" nil t)
11129 (if (not (re-search-backward "^Message-ID: " nil t))
11130 (error "No Message-ID in this article"))))
11131 (if (gnus-post-news 'post gnus-newsgroup-name)
11134 (insert-buffer gnus-article-buffer)
11135 (goto-char (point-min))
11136 (search-forward "\n\n" nil t)
11137 (if (not (re-search-backward "^Message-ID: " nil t))
11138 (error "No Message-ID in this article")
11139 (replace-match "Supersedes: "))
11140 (search-forward "\n\n")
11142 (insert mail-header-separator))))
11146 (fset 'sendnews 'gnus-post-news)
11149 (fset 'postnews 'gnus-post-news)
11151 (defun gnus-post-news (post &optional group header article-buffer yank)
11152 "Begin editing a new USENET news article to be posted.
11153 Type \\[describe-mode] in the buffer to get a list of commands."
11154 (interactive (list t))
11155 (if (or (not gnus-novice-user)
11159 (format "%s" (car (gnus-find-method-for-group
11160 gnus-newsgroup-name)))
11161 gnus-valid-select-methods))))
11162 (assq 'to-address (gnus-find-method-for-group gnus-newsgroup-name))
11163 (gnus-y-or-n-p "Are you sure you want to post to all of USENET? "))
11164 (let ((sumart (if (not post)
11166 (set-buffer gnus-summary-buffer)
11167 (cons (current-buffer) gnus-current-article))))
11168 (from (and header (header-from header)))
11169 subject follow-to real-group)
11170 (and gnus-interactive-post
11171 (not gnus-expert-user)
11175 (completing-read "Group: " gnus-active-hashtb nil t))
11176 (setq subject (read-string "Subject: "))))
11177 (setq mail-reply-buffer article-buffer)
11179 (let ((gnus-newsgroup-name (or group gnus-newsgroup-name "")))
11180 (setq real-group (and group (gnus-group-real-name group)))
11181 (setq gnus-post-news-buffer
11182 (gnus-request-post-buffer
11183 post real-group subject header article-buffer
11184 (nth 2 (and group (gnus-gethash group gnus-newsrc-hashtb)))
11185 (if (and (boundp 'gnus-followup-to-function)
11186 gnus-followup-to-function)
11189 (set-buffer article-buffer)
11190 (funcall gnus-followup-to-function group))))
11191 (eq gnus-use-followup-to t)))
11194 (gnus-configure-windows '(1 0 0))
11195 (switch-to-buffer gnus-post-news-buffer))
11196 (gnus-configure-windows '(0 1 0))
11199 (switch-to-buffer article-buffer)
11200 (pop-to-buffer gnus-post-news-buffer))
11201 (switch-to-buffer gnus-post-news-buffer)))
11202 (gnus-overload-functions)
11203 (make-local-variable 'gnus-article-reply)
11204 (make-local-variable 'gnus-article-check-size)
11205 (setq gnus-article-reply sumart)
11206 ;; Handle `gnus-auto-mail-to-author'.
11207 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11208 (let ((to (if (eq gnus-auto-mail-to-author 'ask)
11209 (and (y-or-n-p "Also send mail to author? ") from)
11210 (and gnus-auto-mail-to-author from))))
11213 (if (mail-fetch-field "To")
11215 (beginning-of-line)
11216 (insert "Cc: " to "\n"))
11217 (mail-position-on-field "To")
11219 ;; Handle author copy using BCC field.
11220 (if (and gnus-mail-self-blind
11221 (not (mail-fetch-field "bcc")))
11223 (mail-position-on-field "Bcc")
11224 (insert (if (stringp gnus-mail-self-blind)
11225 gnus-mail-self-blind
11226 (user-login-name)))))
11227 ;; Handle author copy using FCC field.
11228 (if gnus-author-copy
11230 (mail-position-on-field "Fcc")
11231 (insert gnus-author-copy)))
11232 (goto-char (point-min))
11235 (re-search-forward "^Newsgroup:" nil t)
11238 (re-search-forward "^Subject:" nil t)
11242 (concat "^" (regexp-quote mail-header-separator) "$"))
11245 (concat "^" (regexp-quote mail-header-separator) "$"))
11247 (and yank (save-excursion (news-reply-yank-original nil)))
11248 (if gnus-post-prepare-function
11249 (funcall gnus-post-prepare-function group))))))
11250 (setq gnus-article-check-size (cons (buffer-size) (gnus-article-checksum)))
11254 (defun gnus-inews-news (&optional use-group-method)
11255 "Send a news message.
11256 If given a prefix, and the group is a foreign group, this function
11257 will attempt to use the foreign server to post the article."
11259 ;; Check whether the article is a good Net Citizen.
11260 (if (and gnus-article-check-size (not (gnus-inews-check-post)))
11263 ;; Looks ok, so we do the nasty.
11264 (let* ((case-fold-search nil)
11265 (server-running (gnus-server-opened gnus-select-method))
11266 (reply gnus-article-reply))
11268 ;; Connect to default NNTP server if necessary.
11269 ;; Suggested by yuki@flab.fujitsu.junet.
11270 (gnus-start-news-server) ;Use default server.
11271 ;; NNTP server must be opened before current buffer is modified.
11273 (goto-char (point-min))
11274 (run-hooks 'news-inews-hook)
11279 (goto-char (point-min))
11281 (concat "^" (regexp-quote mail-header-separator) "$"))))
11283 ;; Correct newsgroups field: change sequence of spaces to comma and
11284 ;; eliminate spaces around commas. Eliminate imbedded line breaks.
11285 (goto-char (point-min))
11286 (if (search-forward-regexp "^Newsgroups: +" nil t)
11290 (if (re-search-forward "^[^ \t]" nil 'end)
11291 (match-beginning 0)
11293 (goto-char (point-min))
11294 (replace-regexp "\n[ \t]+" " ") ;No line breaks (too confusing)
11295 (goto-char (point-min))
11296 (replace-regexp "[ \t\n]*,[ \t\n]*\\|[ \t]+" ",")))
11298 ;; Added by Per Abrahamsen <abraham@iesd.auc.dk>.
11299 ;; Help save the the world!
11302 (let ((newsgroups (mail-fetch-field "newsgroups"))
11303 (followup-to (mail-fetch-field "followup-to"))
11305 (if (and (string-match "," newsgroups) (not followup-to))
11307 (while (string-match "," newsgroups)
11309 (cons (list (substring newsgroups
11310 0 (match-beginning 0)))
11312 (setq newsgroups (substring newsgroups (match-end 0))))
11313 (setq groups (nreverse (cons (list newsgroups) groups)))
11316 (completing-read "Followups to: (default all groups) "
11318 (if (> (length to) 0)
11320 (goto-char (point-min))
11321 (insert "Followup-To: " to "\n")))))))
11323 ;; Cleanup Followup-To.
11324 (goto-char (point-min))
11325 (if (search-forward-regexp "^Followup-To: +" nil t)
11329 (if (re-search-forward "^[^ \t]" nil 'end)
11330 (match-beginning 0)
11332 (goto-char (point-min))
11333 (replace-regexp "\n[ \t]+" " ") ;No line breaks (too confusing)
11334 (goto-char (point-min))
11335 (replace-regexp "[ \t\n]*,[ \t\n]*\\|[ \t]+" ",")))
11337 ;; Mail the message too if To:, Bcc:. or Cc: exists.
11338 (if (or (mail-fetch-field "to" nil t)
11339 (mail-fetch-field "bcc" nil t)
11340 (mail-fetch-field "cc" nil t))
11341 (if gnus-mail-send-method
11345 (message "Sending via mail...")
11347 (if gnus-mail-courtesy-message
11349 ;; Insert "courtesy" mail message.
11352 (concat "^" (regexp-quote
11353 mail-header-separator) "$"))
11355 (insert gnus-mail-courtesy-message)
11356 (funcall gnus-mail-send-method)
11358 (search-forward gnus-mail-courtesy-message)
11359 (replace-match ""))
11360 (funcall gnus-mail-send-method))
11362 (message "Sending via mail... done")
11366 1 (re-search-forward
11367 (concat "^" (regexp-quote
11368 mail-header-separator) "$")))
11370 (delete-matching-lines "BCC:.*")))
11372 (message "No mailer defined. To: and/or Cc: fields ignored.")
11375 ;; Send to NNTP server.
11376 (message "Posting to USENET...")
11377 (if (gnus-inews-article use-group-method)
11379 (message "Posting to USENET... done")
11381 (get-buffer (car reply))
11382 (buffer-name (car reply)))
11385 (set-buffer gnus-summary-buffer)
11386 (gnus-summary-mark-article-as-replied
11388 ;; We cannot signal an error.
11389 (ding) (message "Article rejected: %s"
11390 (gnus-status-message gnus-select-method)))
11391 (set-buffer-modified-p nil))
11392 ;; If NNTP server is opened by gnus-inews-news, close it by myself.
11394 (gnus-close-server (gnus-find-method-for-group gnus-newsgroup-name)))
11395 (and (fboundp 'bury-buffer) (bury-buffer))
11396 ;; Restore last window configuration.
11397 (and gnus-winconf-post-news
11398 (set-window-configuration gnus-winconf-post-news))
11399 (setq gnus-winconf-post-news nil))))
11401 (defun gnus-inews-check-post ()
11402 "Check whether the post looks ok."
11404 ;; Check excessive size.
11405 (if (> (buffer-size) 60000)
11406 (gnus-y-or-n-p (format "The article is %d octets long. Really post? "
11409 ;; Check for commands in Subject.
11412 (goto-char (point-min))
11416 (concat "^" (regexp-quote mail-header-separator) "$")))
11417 (if (string-match "^cmsg " (mail-fetch-field "subject"))
11419 "The control code \"cmsg \" is in the subject. Really post? ")
11421 ;; Check for control characters.
11423 (if (re-search-forward "[\000-\007\013\015-\037\200-\237]" nil t)
11425 "The article contains control characters. Really post? ")
11427 ;; Check for multiple identical headers.
11431 (goto-char (point-min))
11435 (concat "^" (regexp-quote mail-header-separator) "$")))
11436 (goto-char (point-min))
11437 (while (and (not found) (re-search-forward "^[^ \t:]+: " nil t))
11439 (or (re-search-forward
11440 (concat "^" (setq found
11441 (buffer-substring (match-beginning 0)
11444 (setq found nil))))
11447 (format "Multiple %s headers. Really post? " found))
11449 ;; Check for version and sendsys.
11452 (goto-char (point-min))
11456 (concat "^" (regexp-quote mail-header-separator) "$")))
11457 (if (re-search-backward "^Sendsys:\\|^Version:" nil t)
11459 (format "The article contains a %s command. Really post? "
11460 (buffer-substring (match-beginning 0) (match-end 0))))
11462 ;; Check the From header.
11465 (goto-char (point-min))
11469 (concat "^" (regexp-quote mail-header-separator) "$")))
11470 (let* ((case-fold-search t)
11471 (from (mail-fetch-field "from")))
11473 (string-match "@" from)
11474 (not (string-match "@[^\\.]*\\." from)))
11476 (format "The domain looks strange: \"%s\". Really post? "
11479 ;; Check for long lines.
11482 (goto-char (point-min))
11486 (concat "^" (regexp-quote mail-header-separator) "$")))
11491 (< (current-column) 80))
11492 (zerop (forward-line 1))))
11496 "You have lines longer than 79 characters. Really post? ")))))
11497 ;; Use the (size . checksum) variable to see whether the
11498 ;; article is empty or has only quoted text.
11499 (if (and (= (buffer-size) (car gnus-article-check-size))
11500 (= (gnus-article-checksum) (cdr gnus-article-check-size)))
11502 "It looks like there's no new text in your article. Really post? ")
11505 (defun gnus-article-checksum ()
11508 (while (not (eobp))
11509 (setq sum (logxor sum (following-char)))
11513 (defun gnus-cancel-news ()
11514 "Cancel an article you posted."
11516 (if (or gnus-expert-user
11517 (gnus-yes-or-no-p "Do you really want to cancel this article? "))
11521 (distribution nil))
11523 ;; Get header info. from original article.
11525 (gnus-article-show-all-headers)
11526 (goto-char (point-min))
11527 (search-forward "\n\n" nil 'move)
11528 (narrow-to-region (point-min) (point))
11529 (setq from (mail-fetch-field "from"))
11530 (setq newsgroups (mail-fetch-field "newsgroups"))
11531 (setq message-id (mail-fetch-field "message-id"))
11532 (setq distribution (mail-fetch-field "distribution")))
11533 ;; Verify if the article is absolutely user's by comparing
11534 ;; user id with value of its From: field.
11537 (downcase (mail-strip-quoted-names from))
11538 (downcase (mail-strip-quoted-names (gnus-inews-user-name)))))
11540 (ding) (message "This article is not yours."))
11541 ;; Make control article.
11542 (set-buffer (get-buffer-create " *Gnus-canceling*"))
11543 (buffer-disable-undo (current-buffer))
11545 (insert "Newsgroups: " newsgroups "\n"
11546 "Subject: cancel " message-id "\n"
11547 "Control: cancel " message-id "\n"
11548 mail-header-separator "\n"
11549 "This is a cancel message from " from ".\n")
11550 ;; Send the control article to NNTP server.
11551 (message "Canceling your article...")
11552 (if (gnus-inews-article)
11553 (message "Canceling your article... done")
11555 (message "Cancel failed; %s"
11556 (gnus-status-message gnus-newsgroup-name)))
11557 ;; Kill the article buffer.
11558 (kill-buffer (current-buffer)))))))
11561 ;;; Lowlevel inews interface
11563 (defun gnus-inews-article (&optional use-group-method)
11564 "Post an article in current buffer using NNTP protocol."
11565 (let ((artbuf (current-buffer))
11566 (tmpbuf (get-buffer-create " *Gnus-posting*")))
11568 (goto-char (point-max))
11569 ;; require a newline at the end for inews to append .signature to
11570 (or (= (preceding-char) ?\n)
11572 ;; Prepare article headers. All message body such as signature
11573 ;; must be inserted before Lines: field is prepared.
11575 (goto-char (point-min))
11580 (concat "^" (regexp-quote mail-header-separator) "$"))
11581 (match-beginning 0)))
11582 (gnus-inews-insert-headers)
11583 (run-hooks gnus-inews-article-header-hook)
11586 (set-buffer tmpbuf)
11587 (buffer-disable-undo (current-buffer))
11589 (insert-buffer-substring artbuf)
11590 ;; Remove the header separator.
11591 (goto-char (point-min))
11593 (concat "^" (regexp-quote mail-header-separator) "$"))
11595 ;; This hook may insert a signature.
11596 (run-hooks 'gnus-prepare-article-hook)
11597 ;; Run final inews hooks. This hook may do FCC.
11598 ;; The article must be saved before being posted because
11599 ;; `gnus-request-post' modifies the buffer.
11600 (run-hooks 'gnus-inews-article-hook)
11601 ;; Post an article to NNTP server.
11602 ;; Return NIL if post failed.
11605 (if use-group-method
11606 (gnus-find-method-for-group gnus-newsgroup-name)
11607 gnus-select-method) use-group-method)
11608 (kill-buffer (current-buffer))))))
11610 (defun gnus-inews-insert-headers ()
11611 "Prepare article headers.
11612 Headers already prepared in the buffer are not modified.
11613 Headers in `gnus-required-headers' will be generated."
11614 (let ((Date (gnus-inews-date))
11615 (Message-ID (gnus-inews-message-id))
11616 (Organization (gnus-inews-organization))
11617 (From (gnus-inews-user-name))
11618 (Path (gnus-inews-path))
11622 (Lines (gnus-inews-lines))
11623 (X-Newsreader gnus-version)
11624 (headers gnus-required-headers)
11625 (case-fold-search t)
11627 ;; First we remove any old Message-IDs. This might be slightly
11628 ;; fascist, but if the user really wants to generate Message-IDs
11629 ;; by herself, she should remove it from the `gnus-required-list'.
11630 (goto-char (point-min))
11631 (and (memq 'Message-ID headers)
11632 (re-search-forward "^Message-ID:" nil t)
11633 (delete-region (progn (beginning-of-line) (point))
11634 (progn (forward-line 1) (point))))
11635 ;; Remove NNTP-posting-host.
11636 (goto-char (point-min))
11637 (and (re-search-forward "^nntp-posting-host:" nil t)
11638 (delete-region (progn (beginning-of-line) (point))
11639 (progn (forward-line 1) (point))))
11640 ;; Insert new Sender if the From is strange.
11641 (let ((from (mail-fetch-field "from")))
11642 (if (and from (not (string= (downcase from) (downcase From))))
11644 (goto-char (point-min))
11645 (and (re-search-forward "^Sender:" nil t)
11646 (delete-region (progn (beginning-of-line) (point))
11647 (progn (forward-line 1) (point))))
11648 (insert "Sender: " From "\n"))))
11649 ;; If there are References, and no "Re: ", then the thread has
11650 ;; changed name. See Son-of-1036.
11651 (if (and (mail-fetch-field "references")
11652 (get-buffer gnus-article-buffer))
11653 (let ((psubject (gnus-simplify-subject-re
11654 (mail-fetch-field "subject")))
11657 (set-buffer (get-buffer gnus-article-buffer))
11659 (gnus-narrow-to-headers)
11660 (if (setq subject (mail-fetch-field "subject"))
11662 (and gnus-summary-gather-subject-limit
11663 (numberp gnus-summary-gather-subject-limit)
11664 (> (length subject) gnus-summary-gather-subject-limit)
11666 (substring subject 0
11667 gnus-summary-gather-subject-limit)))
11668 (setq subject (gnus-simplify-subject-re subject))))))
11669 (or (and psubject subject (string= subject psubject))
11671 (string-match "@" Message-ID)
11673 (concat (substring Message-ID 0 (match-beginning 0))
11675 (substring Message-ID (match-beginning 0))))))))
11676 ;; Go through all the required headers and see if they are in the
11677 ;; articles already. If they are not, or are empty, they are
11678 ;; inserted automatically - except for Subject, Newsgroups and
11681 (goto-char (point-min))
11682 (setq elem (car headers))
11684 (setq header (car elem))
11685 (setq header elem))
11686 (if (or (not (re-search-forward
11687 (concat "^" (downcase (symbol-name header)) ":") nil t))
11689 (if (= (following-char) ? ) (forward-char 1) (insert " "))
11690 (looking-at "[ \t]*$")))
11693 (or (if (consp elem)
11694 ;; The element is a cons. Either the cdr is
11695 ;; a string to be inserted verbatim, or it
11696 ;; is a function, and we insert the value
11697 ;; returned from this function.
11698 (or (and (stringp (cdr elem)) (cdr elem))
11699 (and (fboundp (cdr elem)) (funcall (cdr elem))))
11700 ;; The element is a symbol. We insert the
11701 ;; value of this symbol, if any.
11702 (and (boundp header) (symbol-value header)))
11703 ;; We couldn't generate a value for this header,
11704 ;; so we just ask the user.
11705 (read-from-minibuffer
11706 (format "Empty header for %s; enter value: " header))))
11709 (goto-char (point-max))
11710 (insert (symbol-name header) ": " value "\n"))
11711 (replace-match value))))
11712 (setq headers (cdr headers)))))
11714 (defun gnus-inews-insert-signature ()
11715 "Insert a signature file.
11716 If `gnus-signature-function' is bound and returns a string, this
11717 string is used instead of the variable `gnus-signature-file'.
11718 In either case, if the string is a file name, this file is
11719 inserted. If the string is not a file name, the string itself is
11721 If you never want any signature inserted, set both those variables to
11725 (or (and gnus-signature-function
11726 (fboundp gnus-signature-function)
11727 (funcall gnus-signature-function gnus-newsgroup-name))
11728 gnus-signature-file))
11731 (or (file-exists-p signature)
11732 (string-match " " signature)
11734 "^/[^/]+/" (expand-file-name signature)))))
11736 (goto-char (point-max))
11737 ;; Delete any previous signatures.
11738 (if (and mail-signature (search-backward "\n-- \n" nil t))
11739 (delete-region (1+ (point)) (point-max)))
11741 (and (< 4 (setq b (count-lines
11744 (if (file-exists-p signature)
11745 (insert-file-contents signature)
11746 (insert signature))
11747 (goto-char (point-max))
11748 (or (bolp) (insert "\n"))
11750 (not gnus-expert-user)
11754 "Your .sig is %d lines; it should be max 4. Really post? "
11756 (if (file-exists-p signature)
11757 (error (format "Edit %s." signature))
11758 (error "Trim your signature."))))))))
11760 (defun gnus-inews-do-fcc ()
11761 "Process FCC: fields in current article buffer.
11762 Unless the first character of the field is `|', the article is saved
11763 to the specified file using the function specified by the variable
11764 gnus-author-copy-saver. The default function rmail-output saves in
11765 Unix mailbox format.
11766 If the first character is `|', the contents of the article is send to
11767 a program specified by the rest of the value."
11768 (let ((fcc-list nil)
11770 (case-fold-search t)) ;Should ignore case.
11773 (goto-char (point-min))
11774 (search-forward "\n\n")
11775 (narrow-to-region (point-min) (point))
11776 (goto-char (point-min))
11777 (while (re-search-forward "^FCC:[ \t]*" nil t)
11779 (cons (buffer-substring
11783 (skip-chars-backward " \t")
11786 (delete-region (match-beginning 0)
11787 (progn (forward-line 1) (point))))
11788 ;; Process FCC operations.
11791 (setq fcc-file (car fcc-list))
11792 (setq fcc-list (cdr fcc-list))
11793 (cond ((string-match "^[ \t]*|[ \t]*\\(.*\\)[ \t]*$" fcc-file)
11794 (let ((program (substring fcc-file
11795 (match-beginning 1) (match-end 1))))
11796 ;; Suggested by yuki@flab.fujitsu.junet.
11797 ;; Send article to named program.
11798 (call-process-region (point-min) (point-max) shell-file-name
11799 nil nil nil "-c" program)))
11801 ;; Suggested by hyoko@flab.fujitsu.junet.
11802 ;; Save article in Unix mail format by default.
11803 (if (and gnus-author-copy-saver
11804 (not (eq gnus-author-copy-saver 'rmail-output)))
11805 (funcall gnus-author-copy-saver fcc-file)
11806 (if (and (file-readable-p fcc-file) (rmail-file-p fcc-file))
11807 (gnus-output-to-rmail fcc-file)
11808 (rmail-output fcc-file 1 t t))))))))))
11810 (defun gnus-inews-path ()
11811 "Return uucp path."
11812 (let ((login-name (gnus-inews-login-name)))
11813 (cond ((null gnus-use-generic-path)
11814 (concat (nth 1 gnus-select-method) "!" login-name))
11815 ((stringp gnus-use-generic-path)
11816 ;; Support GENERICPATH. Suggested by vixie@decwrl.dec.com.
11817 (concat gnus-use-generic-path "!" login-name))
11820 (defun gnus-inews-user-name ()
11821 "Return user's network address as \"NAME@DOMAIN (FULL-NAME)\"."
11822 (let ((full-name (gnus-inews-full-name)))
11823 (or gnus-user-from-line
11824 (concat (if (or gnus-user-login-name gnus-use-generic-from
11825 gnus-local-domain (getenv "DOMAINNAME"))
11826 (concat (gnus-inews-login-name) "@"
11827 (gnus-inews-domain-name gnus-use-generic-from))
11829 ;; User's full name.
11830 (cond ((string-equal full-name "") "")
11831 ((string-equal full-name "&") ;Unix hack.
11832 (concat " (" (user-login-name) ")"))
11834 (concat " (" full-name ")")))))))
11836 (defun gnus-inews-login-name ()
11837 "Return login name."
11838 (or gnus-user-login-name (getenv "LOGNAME") (user-login-name)))
11840 (defun gnus-inews-full-name ()
11841 "Return full user name."
11842 (or gnus-user-full-name (getenv "NAME") (user-full-name)))
11844 (defun gnus-inews-domain-name (&optional genericfrom)
11845 "Return user's domain name.
11846 If optional argument GENERICFROM is a string, use it as the domain
11847 name; if it is non-nil, strip off local host name from the domain name.
11848 If the function `system-name' returns full internet name and the
11849 domain is undefined, the domain name is got from it."
11850 (if (or genericfrom gnus-local-domain (getenv "DOMAINNAME"))
11851 (let* ((system-name (system-name))
11853 (or (if (stringp genericfrom) genericfrom)
11854 (getenv "DOMAINNAME")
11856 ;; Function `system-name' may return full internet name.
11857 ;; Suggested by Mike DeCorte <mrd@sun.soe.clarkson.edu>.
11858 (if (string-match "\\." system-name)
11859 (substring system-name (match-end 0)))
11860 (read-string "Domain name (no host): ")))
11861 (host (or (if (string-match "\\." system-name)
11862 (substring system-name 0 (match-beginning 0)))
11864 (if (string-equal "." (substring domain 0 1))
11865 (setq domain (substring domain 1)))
11866 ;; Support GENERICFROM as same as standard Bnews system.
11867 ;; Suggested by ohm@kaba.junet and vixie@decwrl.dec.com.
11868 (cond ((null genericfrom)
11869 (concat host "." domain))
11870 ;;((stringp genericfrom) genericfrom)
11872 (if (string-match "\\." (system-name))
11874 (substring user-mail-address
11875 (1+ (string-match "@" user-mail-address))))))
11877 (defun gnus-inews-full-address ()
11878 (let ((domain (gnus-inews-domain-name))
11879 (system (system-name))
11880 (case-fold-search t))
11881 (if (string-match "\\." system) system
11882 (if (string-match (concat "^" (regexp-quote system)) domain) domain
11883 (concat system "." domain)))))
11885 (defun gnus-inews-message-id ()
11886 "Generate unique Message-ID for user."
11887 ;; Message-ID should not contain a slash and should be terminated by
11888 ;; a number. I don't know the reason why it is so.
11889 (concat "<" (gnus-inews-unique-id) "@" (gnus-inews-full-address) ">"))
11891 (defun gnus-inews-unique-id ()
11892 "Generate unique ID from user name and current time."
11893 (concat (downcase (gnus-inews-login-name))
11895 (lambda (num) (gnus-number-base-x num 3 31))
11896 (current-time) "")))
11898 (defun gnus-inews-date ()
11899 "Current time string."
11900 (timezone-make-date-arpa-standard
11901 (current-time-string) (current-time-zone)))
11903 (defun gnus-inews-organization ()
11904 "Return user's organization.
11905 The ORGANIZATION environment variable is used if defined.
11906 If not, the variable `gnus-local-organization' is used instead.
11907 If it is a function, the function will be called with the current
11908 newsgroup name as the argument.
11909 If this is a file name, the contents of this file will be used as the
11911 (let* ((organization
11912 (or (getenv "ORGANIZATION")
11913 (if gnus-local-organization
11914 (if (and (symbolp gnus-local-organization)
11915 (fboundp gnus-local-organization))
11916 (funcall gnus-local-organization gnus-newsgroup-name)
11917 gnus-local-organization))
11918 gnus-organization-file
11919 "~/.organization")))
11920 (and (stringp organization)
11921 (> (length organization) 0)
11922 (or (file-exists-p organization)
11923 (string-match " " organization)
11924 (not (string-match "^/[^/]+/" (expand-file-name organization))))
11926 (set-buffer (get-buffer-create " *Gnus organization*"))
11927 (buffer-disable-undo (current-buffer))
11929 (if (file-exists-p organization)
11930 (insert-file-contents organization)
11931 (insert organization))
11932 (goto-char (point-min))
11933 (while (re-search-forward " *\n *" nil t)
11934 (replace-match " "))
11935 (buffer-substring (point-min) (point-max))))))
11937 (defun gnus-inews-lines ()
11938 "Count the number of lines and return numeric string."
11942 (goto-char (point-min))
11943 (search-forward "\n\n" nil 'move)
11944 (int-to-string (count-lines (point) (point-max))))))
11948 ;;; Gnus Mail Functions
11951 ;;; Mail reply commands of Gnus summary mode
11953 (defun gnus-summary-reply (yank)
11954 "Reply mail to news author.
11955 If prefix argument YANK is non-nil, original article is yanked automatically.
11956 Customize the variable gnus-mail-reply-method to use another mailer."
11958 ;; Bug fix by jbw@bigbird.bu.edu (Joe Wells)
11959 ;; Stripping headers should be specified with mail-yank-ignored-headers.
11960 (gnus-set-global-variables)
11961 (gnus-summary-select-article t)
11962 (setq gnus-winconf-post-news (current-window-configuration))
11963 (let ((gnus-newsgroup-name gnus-newsgroup-name))
11964 (bury-buffer gnus-article-buffer)
11965 (funcall gnus-mail-reply-method yank))
11966 (gnus-article-hide-headers-if-wanted))
11968 (defun gnus-summary-reply-with-original ()
11969 "Reply mail to news author with original article.
11970 Customize the variable gnus-mail-reply-method to use another mailer."
11972 (gnus-summary-reply t))
11974 (defun gnus-summary-mail-forward ()
11975 "Forward the current message to another user.
11976 Customize the variable gnus-mail-forward-method to use another mailer."
11978 (gnus-summary-select-article t)
11979 (setq gnus-winconf-post-news (current-window-configuration))
11980 (set-buffer gnus-article-buffer)
11981 (let ((gnus-newsgroup-name gnus-newsgroup-name))
11982 (funcall gnus-mail-forward-method))
11983 (gnus-article-hide-headers-if-wanted))
11985 (defun gnus-summary-mail-other-window ()
11986 "Compose mail in other window.
11987 Customize the variable `gnus-mail-other-window-method' to use another
11990 (setq gnus-winconf-post-news (current-window-configuration))
11991 (let ((gnus-newsgroup-name gnus-newsgroup-name))
11992 (funcall gnus-mail-other-window-method)))
11994 (defun gnus-mail-reply-using-mail (&optional yank to-address)
11996 (set-buffer gnus-summary-buffer)
11997 (let ((info (nth 2 (gnus-gethash gnus-newsgroup-name gnus-newsrc-hashtb)))
11998 (group (gnus-group-real-name gnus-newsgroup-name))
11999 (cur (cons (current-buffer) (cdr gnus-article-current)))
12000 from subject date to reply-to message-of
12001 references message-id sender follow-to cc)
12002 (set-buffer (get-buffer-create "*mail*"))
12004 (make-local-variable 'gnus-article-reply)
12005 (setq gnus-article-reply cur)
12006 (use-local-map (copy-keymap mail-mode-map))
12007 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
12008 (if (and (buffer-modified-p)
12009 (> (buffer-size) 0)
12010 (not (gnus-y-or-n-p
12011 "Unsent article being composed; erase it? ")))
12015 (set-buffer gnus-article-buffer)
12016 (let ((buffer-read-only nil))
12017 (goto-char (point-min))
12018 (narrow-to-region (point-min)
12019 (progn (search-forward "\n\n") (point)))
12020 (add-text-properties (point-min) (point-max) '(invisible nil)))
12021 (if (and (boundp 'gnus-reply-to-function)
12022 gnus-reply-to-function)
12025 (gnus-narrow-to-headers)
12026 (setq follow-to (funcall gnus-reply-to-function group)))))
12027 (setq from (mail-fetch-field "from"))
12028 (setq date (mail-fetch-field "date"))
12031 (string-match " *at \\| *@ \\| *(\\| *<" from)))
12033 (concat (if stop-pos (substring from 0 stop-pos) from)
12034 "'s message of " date))))
12035 (setq sender (mail-fetch-field "sender"))
12036 (setq subject (or (mail-fetch-field "subject")
12038 (or (string-match "^[Rr][Ee]:" subject)
12039 (setq subject (concat "Re: " subject)))
12040 (setq cc (mail-fetch-field "cc"))
12041 (setq reply-to (mail-fetch-field "reply-to"))
12042 (setq references (mail-fetch-field "references"))
12043 (setq message-id (mail-fetch-field "message-id"))
12045 (setq news-reply-yank-from from)
12046 (setq news-reply-yank-message-id message-id)
12047 (mail-setup (or to-address
12048 (if (and follow-to (not (stringp follow-to))) ""
12049 (or follow-to reply-to from sender "")))
12050 subject message-of nil gnus-article-buffer nil)
12051 (if (and follow-to (listp follow-to))
12053 (goto-char (point-min))
12055 (insert (car (car follow-to)) ": " (cdr (car follow-to)) "\n")
12056 (setq follow-to (cdr follow-to)))))
12057 ;; Fold long references line to follow RFC1036.
12058 (mail-position-on-field "References")
12059 (let ((begin (- (point) (length "References: ")))
12061 (fill-prefix "\t"))
12062 (if references (insert references))
12063 (if (and references message-id) (insert " "))
12064 (if message-id (insert message-id))
12065 ;; The region must end with a newline to fill the region
12066 ;; without inserting extra newline.
12067 (fill-region-as-paragraph begin (1+ (point))))
12068 (goto-char (point-min))
12070 (concat "^" (regexp-quote mail-header-separator) "$"))
12073 (let ((last (point)))
12074 (run-hooks 'news-reply-header-hook)
12075 (mail-yank-original nil)
12076 (goto-char last))))
12078 (let ((mail (current-buffer)))
12079 (gnus-configure-windows '(0 0 1))
12080 (switch-to-buffer-other-window mail))
12081 (gnus-configure-windows '(0 1 0))
12082 (switch-to-buffer (current-buffer))))))
12084 (defun gnus-mail-yank-original ()
12086 (run-hooks 'news-reply-header-hook)
12087 (mail-yank-original nil))
12089 (defun gnus-mail-send-and-exit ()
12091 (let ((cbuf (current-buffer)))
12092 (mail-send-and-exit nil)
12093 (if (get-buffer gnus-group-buffer)
12097 (let ((reply gnus-article-reply))
12099 (get-buffer (car reply))
12100 (buffer-name (car reply)))
12102 (set-buffer (car reply))
12104 (gnus-summary-mark-article-as-replied
12106 (and gnus-winconf-post-news
12107 (set-window-configuration gnus-winconf-post-news))
12108 (setq gnus-winconf-post-news nil)))))
12110 (defun gnus-mail-forward-using-mail ()
12111 "Forward the current message to another user using mail."
12112 ;; This is almost a carbon copy of rmail-forward in rmail.el.
12113 (let ((forward-buffer (current-buffer))
12115 (concat "[" (if (memq 'mail (assoc (symbol-name
12116 (car (gnus-find-method-for-group
12117 gnus-newsgroup-name)))
12118 gnus-valid-select-methods))
12119 (gnus-fetch-field "From")
12120 gnus-newsgroup-name)
12121 "] " (or (gnus-fetch-field "Subject") "")))
12123 ;; If only one window, use it for the mail buffer.
12124 ;; Otherwise, use another window for the mail buffer
12125 ;; so that the Rmail buffer remains visible
12126 ;; and sending the mail will get back to it.
12127 (if (if (one-window-p t)
12128 (mail nil nil subject)
12129 (mail-other-window nil nil subject))
12131 (use-local-map (copy-keymap emacs-lisp-mode-map))
12132 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit)
12133 (setq beg (goto-char (point-max)))
12134 (insert "------- Start of forwarded message -------\n")
12135 (insert-buffer forward-buffer)
12136 (goto-char (point-max))
12137 (insert "------- End of forwarded message -------\n")
12138 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
12140 (while (setq beg (next-single-property-change (point) 'invisible))
12142 (delete-region beg (or (next-single-property-change
12143 (point) 'invisible)
12145 ;; You have a chance to arrange the message.
12146 (run-hooks 'gnus-mail-forward-hook)))))
12148 (defun gnus-mail-other-window-using-mail ()
12149 "Compose mail other window using mail."
12150 (mail-other-window nil nil nil nil nil (get-buffer gnus-article-buffer))
12151 (use-local-map (copy-keymap (current-local-map)))
12152 (local-set-key "\C-c\C-c" 'gnus-mail-send-and-exit))
12159 (defvar gnus-dribble-ignore nil)
12161 (defun gnus-dribble-file-name ()
12162 (concat gnus-startup-file "-dribble"))
12164 (defun gnus-dribble-open ()
12167 (setq gnus-dribble-buffer (find-file-noselect (gnus-dribble-file-name))))
12168 (buffer-disable-undo (current-buffer))
12169 (bury-buffer gnus-dribble-buffer)
12171 (goto-char (point-max))))
12173 (defun gnus-dribble-enter (string)
12174 (if (and (not gnus-dribble-ignore)
12175 gnus-dribble-buffer
12176 (buffer-name gnus-dribble-buffer))
12177 (let ((obuf (current-buffer)))
12178 (set-buffer gnus-dribble-buffer)
12179 (insert string "\n")
12180 (set-window-point (get-buffer-window (current-buffer)) (point-max))
12181 (set-buffer obuf))))
12183 (defun gnus-dribble-read-file ()
12184 (let ((dribble-file (gnus-dribble-file-name)))
12186 (set-buffer (setq gnus-dribble-buffer
12188 (file-name-nondirectory dribble-file))))
12189 (gnus-add-current-to-buffer-list)
12191 (set-visited-file-name dribble-file)
12192 (buffer-disable-undo (current-buffer))
12193 (bury-buffer (current-buffer))
12194 (set-buffer-modified-p nil)
12195 (let ((auto (make-auto-save-file-name))
12196 (gnus-dribble-ignore t))
12197 (if (or (file-exists-p auto) (file-exists-p dribble-file))
12199 (if (file-newer-than-file-p auto dribble-file)
12200 (setq dribble-file auto))
12201 (insert-file-contents dribble-file)
12202 (if (not (zerop (buffer-size)))
12203 (set-buffer-modified-p t))
12205 "Auto-save file exists. Do you want to read it? ")
12207 (message "Reading %s..." dribble-file)
12208 (eval-current-buffer)
12209 (message "Reading %s...done" dribble-file)))))))))
12211 (defun gnus-dribble-delete-file ()
12212 (if (file-exists-p (gnus-dribble-file-name))
12213 (delete-file (gnus-dribble-file-name)))
12214 (if gnus-dribble-buffer
12216 (set-buffer gnus-dribble-buffer)
12217 (let ((auto (make-auto-save-file-name)))
12218 (if (file-exists-p auto)
12219 (delete-file auto))
12221 (set-buffer-modified-p nil)))))
12223 (defun gnus-dribble-save ()
12224 (if (and gnus-dribble-buffer
12225 (buffer-name gnus-dribble-buffer))
12227 (set-buffer gnus-dribble-buffer)
12230 (defun gnus-dribble-clear ()
12232 (if (and gnus-dribble-buffer
12233 (buffer-name (get-buffer gnus-dribble-buffer)))
12235 (set-buffer gnus-dribble-buffer)
12237 (set-buffer-modified-p nil)
12238 (setq buffer-saved-size (buffer-size))))))
12241 ;;; Server Communication
12244 ;; All the Gnus backends have the same interface, and should return
12245 ;; data in a similar format. Below is an overview of what functions
12246 ;; these packages must supply and what results they should return.
12250 ;; `nntp-server-buffer' - All data should be returned to Gnus in this
12253 ;; Functions for the imaginary backend `choke':
12255 ;; `choke-retrieve-headers ARTICLES &optional GROUP SERVER'
12256 ;; Should return all headers for all ARTICLES, or return NOV lines for
12259 ;; `choke-request-group GROUP &optional SERVER DISCARD'
12260 ;; Switch to GROUP. If DISCARD is nil, active information on the group
12261 ;; must be returned.
12263 ;; `choke-close-group GROUP &optional SERVER'
12264 ;; Close group. Most backends won't have to do anything with this
12265 ;; call, but it is an opportunity to clean up, if that is needed. It
12266 ;; is called when Gnus exits a group.
12268 ;; `choke-request-article ARTICLE &optional GROUP SERVER'
12269 ;; Return ARTICLE, which is either an article number or
12270 ;; message-id. Note that not all backends can return articles based on
12273 ;; `choke-request-list SERVER'
12274 ;; Return a list of all newsgroups on SERVER.
12276 ;; `choke-request-list-newsgroups SERVER'
12277 ;; Return a list of descriptions of all newsgroups on SERVER.
12279 ;; `choke-request-newgroups DATE &optional SERVER'
12280 ;; Return a list of all groups that have arrived after DATE on
12281 ;; SERVER. Note that the date doesn't have to be respected - Gnus will
12282 ;; always check whether the groups are old or not. Backends that do
12283 ;; not store date information may just return the entire list of
12284 ;; groups, although this might not be a good idea in general.
12286 ;; `choke-request-post-buffer METHOD HEADER ARTICLE-BUFFER GROUP INFO'
12287 ;; Should return a buffer that is suitable for "posting". nnspool and
12288 ;; nntp return a `*post-buffer*', and nnmail return a `*mail*'
12289 ;; buffer. This function should fill out the appropriate headers.
12291 ;; `choke-request-post &optional SERVER'
12292 ;; Function that will be called from a buffer to be posted.
12294 ;; `choke-open-server SERVER &optional ARGUMENT'
12295 ;; Open a connection to SERVER.
12297 ;; `choke-close-server &optional SERVER'
12298 ;; Close the connection to SERVER.
12300 ;; `choke-server-opened &optional SERVER'
12301 ;; Whether the conenction to SERVER is opened or not.
12303 ;; `choke-server-status &optional SERVER'
12304 ;; Should return a status string (not in the nntp buffer, but as the
12305 ;; result of the function).
12307 ;; The following functions are optional and apply only to backends
12308 ;; that are able to control the contents of their groups totally
12309 ;; (ie. mail backends.) Backends that aren't able to do that
12310 ;; shouldn't define these functions at all. Gnus will check for their
12311 ;; presence before attempting to call them.
12313 ;; `choke-request-expire-articles ARTICLES &optional NEWSGROUP SERVER'
12314 ;; Should expire (according to some aging scheme) all ARTICLES. Most
12315 ;; backends will not be able to expire articles. Should return a list
12316 ;; of all articles that were not expired.
12318 ;; `choke-request-move-article ARTICLE GROUP SERVER ACCEPT-FORM &optional LAST'
12319 ;; Should move ARTICLE from GROUP on SERVER by using ACCEPT-FORM.
12320 ;; Removes any information it has added to the article (extra headers,
12321 ;; whatever - make it as clean as possible), and then passes the
12322 ;; article on by evaling ACCEPT-FORM, which is normally a call to the
12323 ;; function described below. If the ACCEPT-FORM returns a non-nil
12324 ;; value, the article should then be deleted. If LAST is nil, that
12325 ;; means that there will be further calls to this function. This might
12326 ;; be taken as an advice not to save buffers/internal variables just
12327 ;; yet, but wait until the last call to speed things up.
12329 ;; `choke-request-accept-article GROUP &optional LAST'
12330 ;; The contents of the current buffer will be put into GROUP. There
12331 ;; should, of course, be an article in the current buffer. This
12332 ;; function is normally only called by the function described above,
12333 ;; and LAST works the same way as in that function.
12335 ;; `choke-request-replace-article ARTICLE GROUP BUFFER'
12336 ;; Replace ARTICLE in GROUP with the contents of BUFFER.
12337 ;; This provides an easy interface for allowing editing of
12338 ;; articles. Note that even headers may be edited, so the backend has
12339 ;; to update any tables (nov buffers, etc) that it maintains after
12340 ;; replacing the article.
12342 ;; `choke-request-create-group GROUP &optional SERVER'
12343 ;; Create GROUP on SERVER. This might be a new, empty group, or it
12344 ;; might be a group that already exists, but hasn't been registered
12347 ;; All these functions must return nil if they couldn't service the
12348 ;; request. If the optional arguments are not supplied, some "current"
12349 ;; or "default" values should be used. In short, one should emulate an
12350 ;; NNTP server, in a way.
12352 ;; If you want to write a new backend, you just have to supply the
12353 ;; functions listed above. In addition, you must enter the new backend
12354 ;; into the list of valid select methods:
12355 ;; (setq gnus-valid-select-methods
12356 ;; (cons '("choke" mail) gnus-valid-select-methods))
12357 ;; The first element in this list is the name of the backend. Other
12358 ;; elemnets may be `mail' (for mail groups), `post' (for news
12359 ;; groups), `none' (neither), `respool' (for groups that can control
12360 ;; their contents).
12362 (defun gnus-start-news-server (&optional confirm)
12363 "Open a method for getting news.
12364 If CONFIRM is non-nil, the user will be asked for an NNTP server."
12366 (if gnus-current-select-method
12367 ;; Stream is already opened.
12369 ;; Open NNTP server.
12370 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
12373 ;; Read server name with completion.
12374 (setq gnus-nntp-server
12375 (completing-read "NNTP server: "
12376 (mapcar (lambda (server) (list server))
12377 (cons (list gnus-nntp-server)
12378 gnus-secondary-servers))
12379 nil nil gnus-nntp-server))))
12381 (if (and gnus-nntp-server
12382 (stringp gnus-nntp-server)
12383 (not (string= gnus-nntp-server "")))
12384 (setq gnus-select-method
12385 (cond ((or (string= gnus-nntp-server "")
12386 (string= gnus-nntp-server "::"))
12387 (list 'nnspool (system-name)))
12388 ((string-match ":" gnus-nntp-server)
12389 (list 'nnmh gnus-nntp-server))
12391 (list 'nntp gnus-nntp-server)))))
12393 (setq how (car gnus-select-method))
12394 (setq where (car (cdr gnus-select-method)))
12395 (cond ((eq how 'nnspool)
12397 (message "Looking up local news spool..."))
12400 (message "Looking up mh spool..."))
12403 (setq gnus-current-select-method gnus-select-method)
12404 (run-hooks 'gnus-open-server-hook)
12406 ;; gnus-open-server-hook might have opened it
12407 (gnus-server-opened gnus-select-method)
12408 (gnus-open-server gnus-select-method)
12411 "%s server on %s can't be opened. Continue? "
12412 (car gnus-select-method) (nth 1 gnus-select-method)))
12414 (message "Couldn't open server on %s" (nth 1 gnus-select-method))
12418 (defun gnus-check-news-server (method)
12419 "If the news server is down, start it up again."
12420 (let ((method (if method method gnus-select-method)))
12421 (and (stringp method)
12422 (setq method (gnus-server-to-method method)))
12423 (if (gnus-server-opened method)
12424 ;; Stream is already opened.
12427 (message "Opening server %s on %s..." (car method) (nth 1 method))
12428 (run-hooks 'gnus-open-server-hook)
12429 (or (gnus-server-opened method)
12430 (gnus-open-server method))
12433 (defun gnus-nntp-message (&optional message)
12434 "Check the status of the NNTP server.
12435 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
12436 is returned insted of the status string."
12437 (let ((status (gnus-status-message (gnus-find-method-for-group
12438 gnus-newsgroup-name)))
12439 (message (or message "")))
12440 (if (and (stringp status) (> (length status) 0))
12443 (defun gnus-get-function (method function)
12444 (and (stringp method)
12445 (setq method (gnus-server-to-method method)))
12446 (let ((func (intern (format "%s-%s" (car method) function))))
12447 (if (not (fboundp func))
12449 (require (car method))
12450 (if (not (fboundp func))
12451 (error "No such function: %s" func))))
12454 ;;; Interface functions to the backends.
12456 (defun gnus-open-server (method)
12457 (funcall (gnus-get-function method 'open-server)
12458 (nth 1 method) (nthcdr 2 method)))
12460 (defun gnus-close-server (method)
12461 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
12463 (defun gnus-request-list (method)
12464 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
12466 (defun gnus-request-list-newsgroups (method)
12467 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
12469 (defun gnus-request-newgroups (date method)
12470 (funcall (gnus-get-function method 'request-newgroups)
12471 date (nth 1 method)))
12473 (defun gnus-server-opened (method)
12474 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
12476 (defun gnus-status-message (method)
12477 (let ((method (if (stringp method) (gnus-find-method-for-group method)
12479 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
12481 (defun gnus-request-group (group &optional dont-check)
12482 (let ((method (gnus-find-method-for-group group)))
12483 (funcall (gnus-get-function method 'request-group)
12484 (gnus-group-real-name group) (nth 1 method) dont-check)))
12486 (defun gnus-list-active-group (group)
12487 (let ((method (gnus-find-method-for-group group))
12488 (func 'list-active-group))
12489 (and (gnus-check-backend-function func group)
12490 (funcall (gnus-get-function method func)
12491 (gnus-group-real-name group) (nth 1 method)))))
12493 (defun gnus-request-group-description (group)
12494 (let ((method (gnus-find-method-for-group group))
12495 (func 'request-group-description))
12496 (and (gnus-check-backend-function func group)
12497 (funcall (gnus-get-function method func)
12498 (gnus-group-real-name group) (nth 1 method)))))
12500 (defun gnus-close-group (group)
12501 (let ((method (gnus-find-method-for-group group)))
12502 (funcall (gnus-get-function method 'close-group)
12503 (gnus-group-real-name group) (nth 1 method))))
12505 (defun gnus-retrieve-headers (articles group)
12506 (let ((method (gnus-find-method-for-group group)))
12507 (funcall (gnus-get-function method 'retrieve-headers)
12508 articles (gnus-group-real-name group) (nth 1 method))))
12510 (defun gnus-request-article (article group &optional buffer)
12511 (let ((method (gnus-find-method-for-group group)))
12512 (funcall (gnus-get-function method 'request-article)
12513 article (gnus-group-real-name group) (nth 1 method) buffer)))
12515 (defun gnus-request-head (article group)
12516 (let ((method (gnus-find-method-for-group group)))
12517 (funcall (gnus-get-function method 'request-head)
12518 article (gnus-group-real-name group) (nth 1 method))))
12520 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
12521 (defun gnus-request-post-buffer (post group subject header artbuf
12522 info follow-to respect-poster)
12523 (let* ((info (or info (and group (nth 2 (gnus-gethash
12524 group gnus-newsrc-hashtb)))))
12526 (if (and gnus-post-method
12527 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
12529 (format "%s" (car (gnus-find-method-for-group
12530 gnus-newsgroup-name)))
12531 gnus-valid-select-methods)))
12533 (gnus-find-method-for-group gnus-newsgroup-name))))
12534 (let ((mail-self-blind nil)
12535 (mail-archive-file-name nil))
12536 (funcall (gnus-get-function method 'request-post-buffer)
12537 post group subject header artbuf info follow-to
12540 (defun gnus-request-post (method &optional force)
12541 (and (stringp method)
12542 (setq method (gnus-server-to-method method)))
12543 (and (not force) gnus-post-method
12544 (memq 'post (assoc (format "%s" (car method))
12545 gnus-valid-select-methods))
12546 (setq method gnus-post-method))
12547 (funcall (gnus-get-function method 'request-post)
12550 (defun gnus-request-expire-articles (articles group &optional force)
12551 (let ((method (gnus-find-method-for-group group)))
12552 (funcall (gnus-get-function method 'request-expire-articles)
12553 articles (gnus-group-real-name group) (nth 1 method)
12556 (defun gnus-request-move-article
12557 (article group server accept-function &optional last)
12558 (let ((method (gnus-find-method-for-group group)))
12559 (funcall (gnus-get-function method 'request-move-article)
12560 article (gnus-group-real-name group)
12561 (nth 1 method) accept-function last)))
12563 (defun gnus-request-accept-article (group &optional last)
12564 (let ((func (if (symbolp group) group
12565 (car (gnus-find-method-for-group group)))))
12566 (funcall (intern (format "%s-request-accept-article" func))
12567 (if (stringp group) (gnus-group-real-name group) group)
12570 (defun gnus-request-replace-article (article group buffer)
12571 (let ((func (car (gnus-find-method-for-group group))))
12572 (funcall (intern (format "%s-request-replace-article" func))
12573 article (gnus-group-real-name group) buffer)))
12575 (defun gnus-request-create-group (group)
12576 (let ((method (gnus-find-method-for-group group)))
12577 (funcall (gnus-get-function method 'request-create-group)
12578 (gnus-group-real-name group) (nth 1 method))))
12580 (defun gnus-find-method-for-group (group)
12581 (or gnus-override-method
12583 gnus-select-method)
12584 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
12587 (not (setq method (nth 4 info))))
12588 (setq method gnus-select-method)
12590 (cond ((stringp method)
12591 (gnus-server-to-method method))
12592 ((stringp (car method))
12593 (gnus-server-extend-method group method))
12596 (let ((method-name (symbol-name (car method))))
12597 (if (and (memq 'address (assoc method-name
12598 gnus-valid-select-methods))
12599 (not (assq (intern (concat method-name "-address"))
12603 (list (list (intern (concat
12604 method-name "-address"))
12605 (nth 1 method)))))))
12609 (defun gnus-check-backend-function (func group)
12610 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
12612 (fboundp (intern (format "%s-%s" method func)))))
12614 (defun gnus-methods-using (method)
12615 (let ((valids gnus-valid-select-methods)
12618 (if (memq method (car valids))
12619 (setq outs (cons (car valids) outs)))
12620 (setq valids (cdr valids)))
12624 ;;; Active & Newsrc File Handling
12627 ;; Newsrc related functions.
12628 ;; Gnus internal format of gnus-newsrc-assoc:
12629 ;; (("alt.general" 3 (1 . 1))
12630 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
12631 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
12632 ;; The first item is the group name; the second is the subscription
12633 ;; level; the third is either a range of a list of ranges of read
12634 ;; articles, the optional fourth element is a list of marked articles,
12635 ;; the optional fifth element is the select method.
12637 ;; Gnus internal format of gnus-newsrc-hashtb:
12638 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
12639 ;; This is the entry for "alt.misc". The first element is the number
12640 ;; of unread articles in "alt.misc". The cdr of this entry is the
12641 ;; element *before* "alt.misc" in gnus-newsrc-assoc, which makes is
12642 ;; trivial to remove or add new elements into gnus-newsrc-assoc
12643 ;; without scanning the entire list. So, to get the actual information
12644 ;; of "alt.misc", you'd say something like
12645 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
12647 ;; Gnus internal format of gnus-active-hashtb:
12651 ;; The only element in each entry in this hash table is a range of
12652 ;; (possibly) available articles. (Articles in this range may have
12653 ;; been expired or cancelled.)
12655 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
12656 ;; ("alt.misc" "alt.test" "alt.general" ...)
12658 (defun gnus-setup-news (&optional rawfile level)
12659 "Setup news information.
12660 If RAWFILE is non-nil, the .newsrc file will also be read.
12661 If LEVEL is non-nil, the news will be set up at level LEVEL."
12662 (let ((init (not (and gnus-newsrc-assoc gnus-active-hashtb (not rawfile)))))
12663 ;; Clear some variables to re-initialize news information.
12664 (if init (setq gnus-newsrc-assoc nil gnus-active-hashtb nil))
12665 ;; Read the active file and create `gnus-active-hashtb'.
12666 ;; If `gnus-read-active-file' is nil, then we just create an empty
12667 ;; hash table. The partial filling out of the hash table will be
12668 ;; done in `gnus-get-unread-articles'.
12669 (if (and gnus-read-active-file
12671 (gnus-server-opened gnus-select-method))
12672 (gnus-read-active-file)
12673 (setq gnus-active-hashtb (make-vector 4095 0)))
12675 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
12676 (if init (gnus-read-newsrc-file rawfile))
12677 ;; Find the number of unread articles in each non-dead group.
12678 (gnus-get-unread-articles (or level 6))
12679 ;; Find new newsgroups and treat them.
12680 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
12681 (gnus-server-opened gnus-select-method))
12682 (gnus-find-new-newsgroups))
12683 (if (and init gnus-check-bogus-newsgroups
12684 gnus-read-active-file (not level)
12685 (gnus-server-opened gnus-select-method))
12686 (gnus-check-bogus-newsgroups))))
12688 (defun gnus-find-new-newsgroups ()
12689 "Search for new newsgroups and add them.
12690 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
12691 The `-n' option line from .newsrc is respected."
12693 (or (gnus-check-first-time-used)
12694 (if (or (consp gnus-check-new-newsgroups)
12695 (eq gnus-check-new-newsgroups 'ask-server))
12696 (gnus-ask-server-for-new-groups)
12698 group new-newsgroups)
12699 (or gnus-have-read-active-file (gnus-read-active-file))
12700 (setq gnus-newsrc-last-checked-date (current-time-string))
12701 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
12702 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
12703 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
12706 (setq group (symbol-name sym))
12707 (if (or (gnus-gethash group gnus-killed-hashtb)
12708 (gnus-gethash group gnus-newsrc-hashtb))
12710 (let ((do-sub (gnus-matches-options-n group)))
12711 (cond ((eq do-sub 'subscribe)
12712 (setq groups (1+ groups))
12713 (gnus-sethash group group gnus-killed-hashtb)
12715 gnus-subscribe-options-newsgroup-method group))
12716 ((eq do-sub 'ignore)
12719 (setq groups (1+ groups))
12720 (gnus-sethash group group gnus-killed-hashtb)
12721 (if gnus-subscribe-hierarchical-interactive
12722 (setq new-newsgroups (cons group new-newsgroups))
12723 (funcall gnus-subscribe-newsgroup-method group)))))))
12724 gnus-active-hashtb)
12726 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12727 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12729 (message "%d new newsgroup%s arrived."
12730 groups (if (> groups 1) "s have" " has")))))))
12732 (defun gnus-matches-options-n (group)
12733 ;; Returns `subscribe' if the group is to be uncoditionally
12734 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
12735 ;; no match for the group.
12737 ;; First we check the two user variables.
12739 ((and gnus-options-not-subscribe
12740 (string-match gnus-options-not-subscribe group))
12742 ((and gnus-options-subscribe
12743 (string-match gnus-options-subscribe group))
12745 ;; Then we go through the list that was retrieved from the .newsrc
12746 ;; file. This list has elements on the form
12747 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
12748 ;; is in the reverse order of the options line) is returned.
12750 (let ((regs gnus-newsrc-options-n))
12752 (not (string-match (car (car gnus-newsrc-options-n)) group)))
12753 (setq regs (cdr regs)))
12754 (and regs (cdr (car regs)))))))
12756 (defun gnus-ask-server-for-new-groups ()
12757 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
12758 (methods (cons gnus-select-method
12760 (and (consp gnus-check-new-newsgroups)
12761 gnus-check-new-newsgroups)
12762 gnus-secondary-select-methods)))
12764 (new-date (current-time-string))
12765 hashtb group new-newsgroups got-new)
12766 ;; Go thorugh both primary and secondary select methods and
12767 ;; request new newsgroups.
12769 (if (gnus-request-newgroups date (car methods))
12772 (or hashtb (setq hashtb (gnus-make-hashtable
12773 (count-lines (point-min) (point-max)))))
12774 (set-buffer nntp-server-buffer)
12775 ;; Enter all the new groups in a hashtable.
12776 (gnus-active-to-gnus-format (car methods) hashtb)))
12777 (setq methods (cdr methods)))
12778 (and got-new (setq gnus-newsrc-last-checked-date new-date))
12779 ;; Now all new groups from all select methods are in `hashtb'.
12781 (lambda (group-sym)
12782 (setq group (symbol-name group-sym))
12783 (if (or (gnus-gethash group gnus-newsrc-hashtb)
12784 (member group gnus-zombie-list)
12785 (member group gnus-killed-list))
12786 ;; The group is already known.
12788 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb)
12789 (let ((do-sub (gnus-matches-options-n group)))
12790 (cond ((eq do-sub 'subscribe)
12791 (setq groups (1+ groups))
12792 (gnus-sethash group group gnus-killed-hashtb)
12794 gnus-subscribe-options-newsgroup-method group))
12795 ((eq do-sub 'ignore)
12798 (setq groups (1+ groups))
12799 (gnus-sethash group group gnus-killed-hashtb)
12800 (if gnus-subscribe-hierarchical-interactive
12801 (setq new-newsgroups (cons group new-newsgroups))
12802 (funcall gnus-subscribe-newsgroup-method group)))))))
12805 (gnus-subscribe-hierarchical-interactive new-newsgroups))
12806 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
12808 (message "%d new newsgroup%s arrived."
12809 groups (if (> groups 1) "s have" " has")))
12812 (defun gnus-check-first-time-used ()
12813 (if (or (> (length gnus-newsrc-assoc) 1)
12814 (file-exists-p gnus-startup-file)
12815 (file-exists-p (concat gnus-startup-file ".el"))
12816 (file-exists-p (concat gnus-startup-file ".eld")))
12818 (message "First time user; subscribing you to default groups")
12819 (or gnus-have-read-active-file (gnus-read-active-file))
12820 (setq gnus-newsrc-last-checked-date (current-time-string))
12821 (let ((groups gnus-default-subscribed-newsgroups)
12825 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
12828 (setq group (symbol-name sym))
12829 (let ((do-sub (gnus-matches-options-n group)))
12830 (cond ((eq do-sub 'subscribe)
12831 (gnus-sethash group group gnus-killed-hashtb)
12833 gnus-subscribe-options-newsgroup-method group))
12834 ((eq do-sub 'ignore)
12837 (setq gnus-killed-list (cons group gnus-killed-list))))))
12838 gnus-active-hashtb)
12840 (if (gnus-gethash (car groups) gnus-active-hashtb)
12841 (gnus-group-change-level (car groups) 3 9))
12842 (setq groups (cdr groups)))
12843 (gnus-group-make-help-group)
12844 (and gnus-novice-user
12845 (message (substitute-command-keys "\\<gnus-group-mode-map>\\[gnus-group-list-killed] to list killed groups")))))))
12847 ;; `gnus-group-change-level' is the fundamental function for changing
12848 ;; subscription levels of newsgroups. This might mean just changing
12849 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
12850 ;; again, which subscribes/unsubscribes a group, which is equally
12851 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
12852 ;; from 8-9 to 1-7 means that you remove the group from the list of
12853 ;; killed (or zombie) groups and add them to the (kinda) subscribed
12854 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
12855 ;; which is trivial.
12856 ;; ENTRY can either be a string (newsgroup name) or a list (if
12857 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
12858 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
12860 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
12861 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
12863 (defun gnus-group-change-level (entry level &optional oldlevel
12864 previous fromkilled)
12865 (let ((pinfo entry)
12866 group info active num)
12867 ;; Glean what info we can from the arguments
12869 (if fromkilled (setq group (nth 1 entry))
12870 (setq group (car (nth 2 entry))))
12871 (setq group entry))
12872 (if (and (stringp entry)
12875 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
12876 (if (and (not oldlevel)
12878 (setq oldlevel (car (cdr (nth 2 entry)))))
12879 (if (stringp previous)
12880 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
12882 (gnus-dribble-enter
12883 (format "(gnus-group-change-level %S %S %S %S %S)"
12884 group level oldlevel (car (nth 2 previous)) fromkilled))
12886 ;; Then we remove the newgroup from any old structures, if needed.
12887 ;; If the group was killed, we remove it from the killed or zombie
12888 ;; list. If not, and it is in fact going to be killed, we remove
12889 ;; it from the newsrc hash table and assoc.
12890 (cond ((>= oldlevel 8)
12892 (setq gnus-zombie-list (delete group gnus-zombie-list))
12893 (setq gnus-killed-list (delete group gnus-killed-list))))
12897 (gnus-sethash (car (nth 2 entry))
12898 nil gnus-newsrc-hashtb)
12900 (setcdr (gnus-gethash (car (nth 3 entry))
12901 gnus-newsrc-hashtb)
12903 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
12905 ;; Finally we enter (if needed) the list where it is supposed to
12906 ;; go, and change the subscription level. If it is to be killed,
12907 ;; we enter it into the killed or zombie list.
12908 (cond ((>= level 8)
12909 (and (string= group (gnus-group-real-name group))
12911 (setq gnus-zombie-list (cons group gnus-zombie-list))
12912 (setq gnus-killed-list (cons group gnus-killed-list)))))
12914 ;; If the list is to be entered into the newsrc assoc, and
12915 ;; it was killed, we have to create an entry in the newsrc
12916 ;; hashtb format and fix the pointers in the newsrc assoc.
12917 (if (>= oldlevel 8)
12921 (setq info (cdr entry))
12922 (setq num (car entry)))
12923 (setq active (gnus-gethash group gnus-active-hashtb))
12924 (setq num (if active (- (1+ (cdr active)) (car active)) t))
12925 ;; Check whether the group is foreign. If so, the
12926 ;; foreign select method has to be entered into the
12928 (let ((method (gnus-group-method-name group)))
12929 (if (eq method gnus-select-method)
12930 (setq info (list group level nil))
12931 (setq info (list group level nil nil method)))))
12932 (setq entry (cons info (if previous (cdr (cdr previous))
12933 (cdr gnus-newsrc-assoc))))
12934 (setcdr (if previous (cdr previous) gnus-newsrc-assoc)
12936 (gnus-sethash group (cons num (if previous (cdr previous)
12937 gnus-newsrc-assoc))
12938 gnus-newsrc-hashtb)
12940 (setcdr (gnus-gethash (car (car (cdr entry)))
12941 gnus-newsrc-hashtb)
12943 ;; It was alive, and it is going to stay alive, so we
12944 ;; just change the level and don't change any pointers or
12945 ;; hash table entries.
12946 (setcar (cdr (car (cdr (cdr entry)))) level))))))
12948 (defun gnus-kill-newsgroup (newsgroup)
12949 "Obsolete function. Kills a newsgroup."
12950 (gnus-group-change-level (gnus-gethash newsgroup gnus-newsrc-hashtb) 9))
12952 (defun gnus-check-bogus-newsgroups (&optional confirm)
12953 "Remove bogus newsgroups.
12954 If CONFIRM is non-nil, the user has to confirm the deletion of every
12956 (let ((newsrc (cdr gnus-newsrc-assoc))
12958 (message "Checking bogus newsgroups...")
12959 (or gnus-have-read-active-file (gnus-read-active-file))
12960 ;; Find all bogus newsgroup that are subscribed.
12962 (setq group (car (car newsrc)))
12963 (if (or (gnus-gethash group gnus-active-hashtb)
12964 (nth 4 (car newsrc))
12966 (not (gnus-y-or-n-p
12967 (format "Remove bogus newsgroup: %s " group)))))
12968 ;; Active newsgroup.
12970 ;; Found a bogus newsgroup.
12971 (setq bogus (cons group bogus)))
12972 (setq newsrc (cdr newsrc)))
12973 ;; Remove all bogus subscribed groups by first killing them, and
12974 ;; then removing them from the list of killed groups.
12976 (gnus-group-change-level
12977 (gnus-gethash (car bogus) gnus-newsrc-hashtb) 9)
12978 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))
12979 (setq bogus (cdr bogus)))
12980 ;; Then we remove all bogus groups from the list of killed and
12981 ;; zombie groups. They are are removed without confirmation.
12982 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
12985 (setq killed (symbol-value (car dead-lists)))
12987 (setq group (car killed))
12988 (or (gnus-gethash group gnus-active-hashtb)
12989 ;; The group is bogus.
12990 (set (car dead-lists)
12991 (delete group (symbol-value (car dead-lists)))))
12992 (setq killed (cdr killed)))
12993 (setq dead-lists (cdr dead-lists))))
12994 (message "Checking bogus newsgroups... done")))
12996 (defun gnus-check-duplicate-killed-groups ()
12997 "Remove duplicates from the list of killed groups."
12999 (let ((killed gnus-killed-list))
13001 (message "%d" (length killed))
13002 (setcdr killed (delete (car killed) (cdr killed)))
13003 (setq killed (cdr killed)))))
13005 ;; Go though `gnus-newsrc-assoc' and compare with `gnus-active-hashtb'
13006 ;; and compute how many unread articles there are in each group.
13007 (defun gnus-get-unread-articles (&optional level)
13008 (let ((newsrc (cdr gnus-newsrc-assoc))
13009 (level (or level 6))
13010 info group active virtuals)
13011 (message "Checking new news...")
13013 (setq info (car newsrc))
13014 (setq group (car info))
13015 (setq active (gnus-gethash group gnus-active-hashtb))
13017 ;; Check newsgroups. If the user doesn't want to check them, or
13018 ;; they can't be checked (for instance, if the news server can't
13019 ;; be reached) we just set the number of unread articles in this
13020 ;; newsgroup to t. This means that Gnus thinks that there are
13021 ;; unread articles, but it has no idea how many.
13023 (if (or (and gnus-activate-foreign-newsgroups
13024 (not (numberp gnus-activate-foreign-newsgroups)))
13025 (and (numberp gnus-activate-foreign-newsgroups)
13026 (<= (nth 1 info) gnus-activate-foreign-newsgroups)
13027 (<= (nth 1 info) level)))
13028 (if (eq (car (nth 4 info)) 'nnvirtual)
13029 (setq virtuals (cons info virtuals))
13030 (setq active (gnus-activate-newsgroup (car info)))))
13031 (if (and (not gnus-read-active-file)
13032 (<= (nth 1 info) level))
13034 (setq active (gnus-activate-newsgroup (car info))))))
13036 (or active (progn (gnus-sethash group nil gnus-active-hashtb)
13037 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
13038 (and active (gnus-get-unread-articles-in-group info active))
13039 (setq newsrc (cdr newsrc)))
13041 ;; Activate the virtual groups. This has to be done after all the
13043 ;; !!! If one virtual group contains another virtual group, even
13044 ;; doing it this way might cause problems.
13046 (and (setq active (gnus-activate-newsgroup (car (car virtuals))))
13047 (gnus-get-unread-articles-in-group (car virtuals) active))
13048 (setq virtuals (cdr virtuals)))
13050 (message "Checking new news... done")))
13052 ;; Create a hash table out of the newsrc alist. The `car's of the
13053 ;; alist elements are used as keys.
13054 (defun gnus-make-hashtable-from-newsrc-alist ()
13055 (let ((alist gnus-newsrc-assoc)
13057 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
13059 (setq prev (setq gnus-newsrc-assoc
13060 (cons (list "dummy.group" 0 nil) alist))))
13062 (gnus-sethash (car (car alist)) (cons nil prev) gnus-newsrc-hashtb)
13064 (setq alist (cdr alist)))))
13066 (defun gnus-make-hashtable-from-killed ()
13067 "Create a hash table from the killed and zombie lists."
13068 (let ((lists '(gnus-killed-list gnus-zombie-list))
13070 (setq gnus-killed-hashtb
13071 (gnus-make-hashtable
13072 (+ (length gnus-killed-list) (length gnus-zombie-list))))
13074 (setq list (symbol-value (car lists)))
13075 (setq lists (cdr lists))
13077 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
13078 (setq list (cdr list))))))
13080 (defun gnus-get-unread-articles-in-group (info active)
13081 (let* ((range (nth 2 info))
13083 (marked (nth 3 info))
13084 srange lowest group highest)
13085 ;; Modify the list of read articles according to what articles
13086 ;; are available; then tally the unread articles and add the
13087 ;; number to the group hash table entry.
13088 (cond ((zerop (cdr active))
13091 (setq num (- (1+ (cdr active)) (car active))))
13092 ((not (listp (cdr range)))
13093 ;; Fix a single (num . num) range according to the
13094 ;; active hash table.
13095 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
13096 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
13097 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
13098 ;; Compute number of unread articles.
13099 (setq num (max 0 (- (cdr active)
13100 (- (1+ (cdr range)) (car range))))))
13102 ;; The read list is a list of ranges. Fix them according to
13103 ;; the active hash table.
13104 ;; First peel off any elements that are below the lower
13106 (while (and (cdr range)
13108 (or (and (atom (car (cdr range))) (car (cdr range)))
13109 (car (car (cdr range))))))
13110 (if (numberp (car range))
13113 (or (and (numberp (car (cdr range)))
13115 (cdr (car (cdr range))))))
13116 (setcdr (car range)
13117 (or (and (numberp (nth 1 range)) (nth 1 range))
13118 (cdr (car (cdr range))))))
13119 (setcdr range (cdr (cdr range))))
13120 ;; Adjust the first element to be the same as the lower limit.
13121 (if (and (not (atom (car range)))
13122 (< (cdr (car range)) (car active)))
13123 (setcdr (car range) (1- (car active))))
13124 ;; Then we want to peel off any elements that are higher
13125 ;; than the upper active limit.
13126 (let ((srange range))
13127 ;; Go past all legal elements.
13128 (while (and (cdr srange)
13129 (<= (or (and (atom (car (cdr srange)))
13130 (car (cdr srange)))
13131 (car (car (cdr srange)))) (cdr active)))
13132 (setq srange (cdr srange)))
13134 ;; Nuke all remaining illegal elements.
13135 (setcdr srange nil))
13137 ;; Adjust the final element.
13138 (if (and (not (atom (car srange)))
13139 (> (cdr (car srange)) (cdr active)))
13140 (setcdr (car srange) (cdr active))))
13141 ;; Compute the number of unread articles.
13143 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
13144 (cdr (car range))))
13145 (or (and (atom (car range)) (car range))
13146 (car (car range))))))
13147 (setq range (cdr range)))
13148 (setq num (max 0 (- (cdr active) num)))))
13151 (and (assq 'tick marked)
13152 (inline (gnus-remove-illegal-marked-articles
13153 (assq 'tick marked) (nth 2 info))))
13154 (and (assq 'dormant marked)
13155 (inline (gnus-remove-illegal-marked-articles
13156 (assq 'dormant marked) (nth 2 info))))
13158 (gnus-gethash (car info) gnus-newsrc-hashtb)
13159 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
13160 (length (cdr (assq 'dormant marked)))))))))
13163 (defun gnus-remove-illegal-marked-articles (marked ranges)
13164 (let ((m (cdr marked)))
13165 ;; Make sure that all ticked articles are a subset of the unread
13168 (if (gnus-member-of-range (car m) ranges)
13169 (setcdr marked (cdr m))
13171 (setq m (cdr m)))))
13173 (defun gnus-activate-newsgroup (group)
13174 (let ((method (gnus-find-method-for-group group))
13176 (and (or (gnus-server-opened method) (gnus-open-server method))
13177 (gnus-request-group group)
13179 (set-buffer nntp-server-buffer)
13181 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
13183 (goto-char (match-beginning 1))
13185 group (setq active (cons (read (current-buffer))
13186 (read (current-buffer))))
13187 gnus-active-hashtb))
13190 (defun gnus-update-read-articles
13191 (group unread unselected ticked &optional domarks replied expirable killed
13192 dormant bookmark score)
13193 "Update the list of read and ticked articles in GROUP using the
13194 UNREAD and TICKED lists.
13195 Note: UNSELECTED has to be sorted over `<'.
13196 Returns whether the updating was successful."
13197 (let* ((active (or gnus-newsgroup-active
13198 (gnus-gethash group gnus-active-hashtb)))
13199 (entry (gnus-gethash group gnus-newsrc-hashtb))
13200 (number (car entry))
13201 (info (nth 2 entry))
13202 (marked (nth 3 info))
13204 (unread (sort (copy-sequence unread) (function <)))
13206 (if (or (not info) (not active))
13207 ;; There is no info on this group if it was, in fact,
13208 ;; killed. Gnus stores no information on killed groups, so
13209 ;; there's nothing to be done.
13210 ;; One could store the information somewhere temporarily,
13211 ;; perhaps... Hmmm...
13213 ;; Remove any negative articles numbers.
13214 (while (and unread (< (car unread) 0))
13215 (setq unread (cdr unread)))
13216 (setq unread (sort (append unselected unread) '<))
13217 ;; Set the number of unread articles in gnus-newsrc-hashtb.
13218 (setcar entry (max 0 (- (length unread) (length ticked)
13219 (length dormant))))
13220 ;; Compute the ranges of read articles by looking at the list of
13221 ;; unread articles.
13223 (if (/= (car unread) prev)
13224 (setq read (cons (if (= prev (1- (car unread))) prev
13225 (cons prev (1- (car unread)))) read)))
13226 (setq prev (1+ (car unread)))
13227 (setq unread (cdr unread)))
13228 (if (<= prev (cdr active))
13229 (setq read (cons (cons prev (cdr active)) read)))
13230 ;; Enter this list into the group info.
13231 (setcar (cdr (cdr info))
13232 (if (> (length read) 1) (nreverse read) read))
13233 ;; Enter the list of ticked articles.
13234 (gnus-set-marked-articles
13236 (if domarks replied (cdr (assq 'reply marked)))
13237 (if domarks expirable (cdr (assq 'expire marked)))
13238 (if domarks killed (cdr (assq 'killed marked)))
13239 (if domarks dormant (cdr (assq 'dormant marked)))
13240 (if domarks bookmark (cdr (assq 'bookmark marked)))
13241 (if domarks score (cdr (assq 'score marked))))
13244 (defun gnus-make-articles-unread (group articles)
13245 "Mark ARTICLES in GROUP as unread."
13246 (let ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
13247 (gnus-gethash (gnus-group-real-name group)
13248 gnus-newsrc-hashtb)))))
13249 (setcar (nthcdr 2 info)
13250 (gnus-remove-from-range (nth 2 info) articles))
13251 (gnus-group-update-group group t)))
13253 (defun gnus-read-active-file ()
13254 "Get active file from NNTP server."
13255 (gnus-group-set-mode-line)
13256 (let ((methods (cons gnus-select-method gnus-secondary-select-methods)))
13257 (setq gnus-have-read-active-file nil)
13259 (let* ((where (nth 1 (car methods)))
13260 (mesg (format "Reading active file%s via %s..."
13261 (if (and where (not (zerop (length where))))
13262 (concat " from " where) "")
13263 (car (car methods)))))
13265 (gnus-check-news-server (car methods))
13266 (if (gnus-request-list (car methods)) ; Get active
13268 (set-buffer nntp-server-buffer)
13269 (gnus-active-to-gnus-format
13270 (and gnus-have-read-active-file (car methods)))
13271 (setq gnus-have-read-active-file t)
13272 (message "%s...done" mesg))
13273 (message "Cannot read active file from %s server."
13274 (car (car methods)))
13276 (setq methods (cdr methods)))))
13278 ;; rewritten by jwz based on ideas from Rick Sladkey <jrs@world.std.com>
13279 ;; Further rewrites by lmi.
13280 (defun gnus-active-to-gnus-format (method &optional hashtb)
13281 "Convert active file format to internal format.
13282 Lines matching `gnus-ignored-newsgroups' are ignored."
13283 (let ((cur (current-buffer))
13287 (setq gnus-active-hashtb
13288 (gnus-make-hashtable
13289 (count-lines (point-min) (point-max))))))))
13290 ;; Delete unnecessary lines.
13291 (goto-char (point-min))
13292 (delete-matching-lines gnus-ignored-newsgroups)
13293 (and method (not (eq method gnus-select-method))
13294 (let ((prefix (gnus-group-prefixed-name "" method)))
13295 (goto-char (point-min))
13296 (while (and (not (eobp))
13297 (null (insert prefix))
13298 (zerop (forward-line 1))))))
13299 (goto-char (point-min))
13300 ;; Store active file in hashtable.
13302 (if (or (re-search-forward "\n.\r?$" nil t)
13303 (goto-char (point-max)))
13305 (beginning-of-line)
13306 (narrow-to-region (point-min) (point))))
13307 (goto-char (point-min))
13308 (if (string-match "%[oO]" gnus-group-line-format)
13309 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
13310 ;; If we want information on moderated groups, we use this
13313 (let ((mod-hashtb (make-vector 7 0))
13315 (while (not (eobp))
13316 (setq group (let ((obarray hashtb))
13318 (setq max (read cur))
13319 (set group (cons (read cur) max))
13320 ;; Enter moderated groups into a list.
13322 (symbol-name (let ((obarray mod-hashtb)) (read cur)))
13324 (setq gnus-moderated-list
13325 (cons (symbol-name group) gnus-moderated-list)))
13328 (progn (ding) (message "Possible error in active file."))))
13329 ;; And if we do not care about moderation, we use this loop,
13330 ;; which is faster.
13333 (while (not (eobp))
13334 ;; group gets set to a symbol interned in the hash table
13336 (setq group (let ((obarray hashtb)) (read cur)))
13337 (setq max (read cur))
13338 (set group (cons (read cur) max))
13341 (progn (ding) (message "Possible error in active file."))))))))
13343 (defun gnus-read-newsrc-file (&optional force)
13344 "Read startup file.
13345 If FORCE is non-nil, the .newsrc file is read."
13346 (setq gnus-current-startup-file (gnus-make-newsrc-file gnus-startup-file))
13347 ;; Reset variables that might be defined in the .newsrc.eld file.
13348 (let ((variables gnus-variable-list))
13350 (set (car variables) nil)
13351 (setq variables (cdr variables))))
13352 (let* ((newsrc-file gnus-current-startup-file)
13353 (quick-file (concat newsrc-file ".el")))
13355 ;; We always load the .newsrc.eld file. If always contains
13356 ;; much information that can not be gotten from the .newsrc
13357 ;; file (ticked articles, killed groups, foreign methods, etc.)
13358 (gnus-read-newsrc-el-file quick-file)
13361 (and (file-newer-than-file-p newsrc-file quick-file)
13362 (file-newer-than-file-p newsrc-file
13363 (concat quick-file "d")))
13364 (not gnus-newsrc-assoc))
13365 ;; We read the .newsrc file. Note that if there if a
13366 ;; .newsrc.eld file exists, it has already been read, and
13367 ;; the `gnus-newsrc-hashtb' has been created. While reading
13368 ;; the .newsrc file, Gnus will only use the information it
13369 ;; can find there for changing the data already read -
13370 ;; ie. reading the .newsrc file will not trash the data
13371 ;; already read (except for read articles).
13373 (message "Reading %s..." newsrc-file)
13374 (set-buffer (find-file-noselect newsrc-file))
13375 (buffer-disable-undo (current-buffer))
13376 (gnus-newsrc-to-gnus-format)
13377 (kill-buffer (current-buffer))
13378 (message "Reading %s... done" newsrc-file)))
13379 (and gnus-use-dribble-file (gnus-dribble-read-file)))))
13381 (defun gnus-read-newsrc-el-file (file)
13382 (let ((ding-file (concat file "d")))
13383 ;; We always, always read the .eld file.
13384 (message "Reading %s..." ding-file)
13385 (condition-case nil
13386 (load ding-file t t t)
13388 (gnus-uncompress-newsrc-assoc)
13389 (gnus-make-hashtable-from-newsrc-alist)
13390 (if (not (file-newer-than-file-p file ding-file))
13392 ;; Old format quick file
13393 (message "Reading %s..." file)
13394 ;; The .el file is newer than the .eld file, so we read that one
13396 (gnus-read-old-newsrc-el-file file))))
13398 ;; Parse the old-style quick startup file
13399 (defun gnus-read-old-newsrc-el-file (file)
13400 (let (newsrc killed marked group g m len info)
13402 (let (gnus-killed-assoc gnus-marked-assoc gnus-newsrc-assoc)
13404 (condition-case nil
13407 (setq newsrc gnus-newsrc-assoc
13408 killed gnus-killed-assoc
13409 marked gnus-marked-assoc)))
13410 (setq gnus-newsrc-assoc nil)
13412 (setq group (car newsrc))
13413 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
13416 (setcar (nthcdr 2 info) (cdr (cdr group)))
13417 (setcar (cdr info) (if (nth 1 group) 3 6))
13418 (setq gnus-newsrc-assoc (cons info gnus-newsrc-assoc)))
13419 (setq gnus-newsrc-assoc
13423 (if (nth 1 group) 3 6) (cdr (cdr group))))
13424 gnus-newsrc-assoc)))
13425 (if (setq m (assoc (car group) marked))
13426 (setcdr (cdr (cdr info)) (cons (list (cons 'tick (cdr m))) nil))))
13427 (setq newsrc (cdr newsrc)))
13428 (setq newsrc killed)
13430 (setcar newsrc (car (car newsrc)))
13431 (setq newsrc (cdr newsrc)))
13432 (setq gnus-killed-list killed))
13433 (setq gnus-newsrc-assoc (nreverse gnus-newsrc-assoc))
13434 (gnus-make-hashtable-from-newsrc-alist)))
13436 (defun gnus-make-newsrc-file (file)
13437 "Make server dependent file name by catenating FILE and server host name."
13438 (let* ((file (expand-file-name file nil))
13439 (real-file (concat file "-" (nth 1 gnus-select-method))))
13440 (if (file-exists-p real-file)
13443 (defun gnus-uncompress-newsrc-assoc ()
13444 ;; Uncompress all lists of marked articles in the newsrc assoc.
13445 (let ((newsrc gnus-newsrc-assoc)
13448 (if (not (setq marked (nth 3 (car newsrc))))
13451 (or (eq 'score (car (car marked)))
13452 (eq 'bookmark (car (car marked)))
13453 (eq 'killed (car (car marked)))
13454 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
13455 (setq marked (cdr marked))))
13456 (setq newsrc (cdr newsrc)))))
13458 (defun gnus-compress-newsrc-assoc ()
13459 ;; Compress all lists of marked articles in the newsrc assoc.
13460 (let ((newsrc gnus-newsrc-assoc)
13463 (if (not (setq marked (nth 3 (car newsrc))))
13466 (or (eq 'score (car (car marked)))
13467 (eq 'bookmark (car (car marked)))
13468 (eq 'killed (car (car marked)))
13469 (setcdr (car marked)
13470 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
13471 (setq marked (cdr marked))))
13472 (setq newsrc (cdr newsrc)))))
13474 ;; jwz: rewrote this function to be much more efficient, and not be
13475 ;; subject to regexp overflow errors when it encounters very long
13476 ;; lines -- the old behavior was to blow off the rest of the *file*
13477 ;; when a line was encountered that was too long to match!! Now it
13478 ;; uses only simple looking-at calls, and doesn't create as many
13479 ;; temporary strings. It also now handles multiple consecutive
13480 ;; options lines (before it only handled the first.)
13481 ;; Tiny rewrite by lmi.
13482 (defun gnus-newsrc-to-gnus-format ()
13483 "Parse current buffer as .newsrc file."
13484 ;; We have to re-initialize these variables (except for
13485 ;; gnus-killed-list) because the quick startup file may contain bogus
13487 (setq gnus-newsrc-options nil)
13488 (setq gnus-newsrc-options-n nil)
13489 (gnus-parse-options-lines)
13490 (gnus-parse-newsrc-body))
13492 (defun gnus-parse-options-lines ()
13493 ;; newsrc.5 seems to indicate that the options line can come anywhere
13494 ;; in the file, and that there can be any number of them:
13496 ;; An options line starts with the word options (left-
13497 ;; justified). Then there are the list of options just as
13498 ;; they would be on the readnews command line. For instance:
13500 ;; options -n all !net.sf-lovers !mod.human-nets -r
13503 ;; A string of lines beginning with a space or tab after the
13504 ;; initial options line will be considered continuation
13507 ;; For now, we only accept it at the beginning of the file.
13509 (goto-char (point-min))
13510 (skip-chars-forward " \t\n")
13511 (setq gnus-newsrc-options nil)
13512 (while (looking-at "^options[ \t]*\\(.*\\)\n")
13513 ;; handle consecutive options lines
13514 (setq gnus-newsrc-options (concat gnus-newsrc-options
13515 (if gnus-newsrc-options "\n\t")
13516 (buffer-substring (match-beginning 1)
13519 (while (looking-at "[ \t]+\\(.*\\)\n")
13520 ;; handle subsequent continuation lines of this options line
13521 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n\t"
13522 (buffer-substring (match-beginning 1)
13525 ;; Gather all "-n" options lines.
13528 (if gnus-newsrc-options
13529 (while (and (string-match "^[ \t]*-n\\([^\n]*\\)$"
13530 gnus-newsrc-options
13532 (setq start (match-end 0)))
13533 (setq result (concat result
13535 (substring gnus-newsrc-options
13536 (match-beginning 1)
13539 (and result (gnus-parse-n-options result))
13542 (defun gnus-parse-newsrc-body ()
13543 ;; Point has been positioned after the options lines. We shouldn't
13544 ;; see any more in here.
13546 (let ((subscribe nil)
13548 (line (1+ (count-lines (point-min) (point))))
13552 (skip-chars-forward " \t")
13553 (while (not (eobp))
13555 ((= (following-char) ?\n)
13556 ;; skip blank lines
13560 (skip-chars-forward "^:!\n")
13561 (if (= (following-char) ?\n)
13562 (error "line %d is unparsable in %s" line (buffer-name)))
13564 (skip-chars-backward " \t")
13566 ;; #### note: we could avoid consing a string here by binding obarray
13567 ;; and reading the newsgroup directly into the gnus-newsrc-hashtb,
13568 ;; then setq'ing newsgroup to symbol-name of that, like we do in
13569 ;; gnus-active-to-gnus-format.
13570 (setq newsgroup (buffer-substring p (point)))
13573 (setq subscribe (= (following-char) ?:))
13574 (setq read-list nil)
13576 (forward-char 1) ; after : or !
13577 (skip-chars-forward " \t")
13578 (while (not (= (following-char) ?\n))
13579 (skip-chars-forward " \t")
13582 ((looking-at "\\([0-9]+\\)-\\([0-9]+\\)") ; a range
13587 ;; faster that buffer-substring/string-to-int
13588 (narrow-to-region (point-min) (match-end 1))
13589 (read (current-buffer)))
13591 (narrow-to-region (point-min) (match-end 2))
13592 (forward-char) ; skip over "-"
13594 (read (current-buffer))
13598 ((looking-at "[0-9]+")
13599 ;; faster that buffer-substring/string-to-int
13600 (narrow-to-region (point-min) (match-end 0))
13601 (setq p (read (current-buffer)))
13603 (setq read-list (cons (cons p p) read-list))
13606 ;; bogus chars in ranges
13609 (goto-char (match-end 0))
13610 (skip-chars-forward " \t")
13611 (cond ((= (following-char) ?,)
13614 ((= (following-char) ?\n)
13617 ;; bogus char after range
13619 ;; if we get here, the parse failed
13621 (end-of-line) ; give up on this line
13623 (message "Ignoring bogus line %d for %s in %s"
13624 line newsgroup (buffer-name))
13626 ;; We have already read .newsrc.eld, so we gently update the
13627 ;; data in the hash table with the information we have just
13629 (let ((info (nth 2 (gnus-gethash newsgroup gnus-newsrc-hashtb)))
13633 (setcar (nthcdr 2 info) (nreverse read-list))
13634 ;; We update the level very gently. In fact, we
13635 ;; only change it if there's been a status change
13636 ;; from subscribed to unsubscribed, or vice versa.
13637 (setq level (nth 1 info))
13638 (cond ((and (<= level 5) (not subscribe))
13639 (setq level (if read-list 6 7)))
13640 ((and (> level 5) subscribe)
13642 (setcar (cdr info) level))
13643 (setq gnus-newsrc-assoc
13644 (cons (list newsgroup (if subscribe 3 (if read-list 6 7))
13645 (nreverse read-list))
13646 gnus-newsrc-assoc))))))
13647 (setq line (1+ line))
13648 (forward-line 1))))
13649 (setq gnus-newsrc-assoc (cdr gnus-newsrc-assoc))
13650 (gnus-make-hashtable-from-newsrc-alist)
13653 (defun gnus-parse-n-options (options)
13654 "Parse -n NEWSGROUPS options and return a cons of YES and NO regexps."
13655 (let (yes no yes-or-no out newsgroup)
13656 ;; Parse each newsgroup description such as "comp.all". Commas
13657 ;; and white spaces can be a newsgroup separator.
13659 (string-match "^[ \t\n,]*\\(!?\\)\\([^- \t\n,][^ \t\n,]*\\)" options)
13661 (substring options (match-beginning 1) (match-end 1)))
13665 (match-beginning 2) (match-end 2))))
13666 (setq options (substring options (match-end 2)))
13667 ;; Rewrite "all" to ".+" not ".*". ".+" requires at least one
13669 (while (string-match "\\(^\\|\\\\[.]\\)all\\(\\\\[.]\\|$\\)" newsgroup)
13671 (concat (substring newsgroup 0 (match-end 1))
13673 (substring newsgroup (match-beginning 2)))))
13674 ;; It is yes or no.
13675 (setq out (cons (cons (if (string= yes-or-no "!") 'ignore 'subscribe)
13676 (concat "^" newsgroup "$"))
13678 (setq gnus-newsrc-options-n out)))
13680 (defun gnus-save-newsrc-file ()
13681 "Save .newsrc file."
13682 ;; Note: We cannot save .newsrc file if all newsgroups are removed
13683 ;; from the variable gnus-newsrc-assoc.
13684 (and (or gnus-newsrc-assoc gnus-killed-list)
13685 gnus-current-startup-file
13686 (let ((make-backup-files t)
13687 (version-control nil)
13688 (require-final-newline t)) ;Don't ask even if requested.
13689 ;; You can stop or change version control of backup file.
13690 ;; Suggested by jason@violet.berkeley.edu.
13691 (run-hooks 'gnus-save-newsrc-hook)
13693 (if (or (not gnus-dribble-buffer)
13694 (not (buffer-name gnus-dribble-buffer))
13695 (zerop (save-excursion
13696 (set-buffer gnus-dribble-buffer)
13698 (message "(No changes need to be saved)")
13699 (if gnus-save-newsrc-file
13701 (message "Saving %s..." gnus-current-startup-file)
13702 ;; Make backup file of master newsrc.
13703 (gnus-gnus-to-newsrc-format)
13704 (message "Saving %s... done" gnus-current-startup-file)))
13705 ;; Quickly loadable .newsrc.
13706 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
13707 (gnus-add-current-to-buffer-list)
13708 (buffer-disable-undo (current-buffer))
13710 (message "Saving %s.eld..." gnus-current-startup-file)
13711 (gnus-gnus-to-quick-newsrc-format)
13712 (write-region 1 (point-max)
13713 (concat gnus-current-startup-file ".eld")
13715 (kill-buffer (current-buffer))
13716 (message "Saving %s.eld... done" gnus-current-startup-file)
13717 (gnus-dribble-delete-file))))))
13719 (defun gnus-gnus-to-quick-newsrc-format ()
13720 "Insert Gnus variables such as gnus-newsrc-assoc in lisp format."
13721 (insert ";; (ding) Gnus startup file.\n")
13722 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
13723 (insert ";; to read .newsrc.\n")
13724 (let ((variables gnus-variable-list)
13725 (gnus-newsrc-assoc (cdr gnus-newsrc-assoc))
13727 ;; insert lisp expressions.
13728 (gnus-compress-newsrc-assoc)
13730 (setq variable (car variables))
13731 (and (boundp variable)
13732 (symbol-value variable)
13733 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
13734 (insert "(setq " (symbol-name variable) " '"
13735 (prin1-to-string (symbol-value variable))
13737 (setq variables (cdr variables)))
13738 (gnus-uncompress-newsrc-assoc)))
13741 (defun gnus-gnus-to-newsrc-format ()
13742 ;; Generate and save the .newsrc file.
13743 (let ((newsrc (cdr gnus-newsrc-assoc))
13746 (set-buffer (create-file-buffer gnus-startup-file))
13747 (buffer-disable-undo (current-buffer))
13750 (if gnus-newsrc-options (insert "options " gnus-newsrc-options "\n"))
13751 ;; Write subscribed and unsubscribed.
13753 (setq info (car newsrc))
13754 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
13756 (insert (car info) (if (>= (nth 1 info) 6) "!" ":"))
13757 (if (setq ranges (nth 2 info))
13760 (if (not (listp (cdr ranges)))
13761 (if (= (car ranges) (cdr ranges))
13762 (insert (int-to-string (car ranges)))
13763 (insert (int-to-string (car ranges)) "-"
13764 (int-to-string (cdr ranges))))
13766 (setq range (car ranges)
13767 ranges (cdr ranges))
13768 (if (or (atom range) (= (car range) (cdr range)))
13769 (insert (int-to-string
13770 (or (and (atom range) range)
13772 (insert (int-to-string (car range)) "-"
13773 (int-to-string (cdr range))))
13774 (if ranges (insert ","))))))
13776 (setq newsrc (cdr newsrc)))
13777 (write-region 1 (point-max) gnus-current-startup-file nil 'nomesg)
13778 (kill-buffer (current-buffer)))))
13780 (defun gnus-read-descriptions-file ()
13781 (message "Reading descriptions file...")
13782 (if (not (gnus-request-list-newsgroups gnus-select-method))
13784 (message "Couldn't read newsgroups descriptions")
13787 (setq gnus-description-hashtb
13788 (gnus-make-hashtable (length gnus-active-hashtb)))
13791 (set-buffer nntp-server-buffer)
13792 (goto-char (point-min))
13793 (delete-non-matching-lines "^[-\\._+A-Za-z0-9]+[ \t]")
13794 (goto-char (point-min))
13795 (if (or (search-forward "\n.\n" nil t)
13796 (goto-char (point-max)))
13798 (beginning-of-line)
13799 (narrow-to-region (point-min) (point))))
13800 (goto-char (point-min))
13801 (while (not (eobp))
13802 (setq group (let ((obarray gnus-description-hashtb))
13803 (read (current-buffer))))
13804 (skip-chars-forward " \t")
13805 (set group (buffer-substring
13806 (point) (gnus-point-at-eol)))
13807 (forward-line 1))))
13808 (message "Reading descriptions file...done")
13811 (defun gnus-group-get-description (group)
13812 ;; Get the description of a group by sending XGTITLE to the server.
13813 (and (gnus-request-group-description group)
13815 (set-buffer nntp-server-buffer)
13816 (goto-char (point-min))
13817 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
13818 (buffer-substring (match-beginning 1) (match-end 1))))))
13824 (defvar gnus-server-mode-hook nil
13825 "Hook run in `gnus-server-mode' buffers.")
13827 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
13828 "Format of server lines.
13829 It works along the same lines as a normal formatting string,
13830 with some simple extensions.")
13832 (defvar gnus-server-mode-line-format "(ding) List of servers"
13833 "The format specification for the server mode line.")
13835 (defconst gnus-server-line-format-alist
13836 (list (list ?h 'how ?s)
13838 (list ?w 'where ?s)
13841 (defconst gnus-server-mode-line-format-alist
13842 (list (list ?S 'news-server ?s)
13843 (list ?M 'news-method ?s)
13844 (list ?u 'user-defined ?s)))
13846 (defvar gnus-server-line-format-spec nil)
13847 (defvar gnus-server-mode-line-format-spec nil)
13848 (defvar gnus-server-killed-servers nil)
13850 (defvar gnus-server-mode-map nil)
13851 (put 'gnus-server-mode 'mode-class 'special)
13853 (if gnus-server-mode-map
13855 (setq gnus-server-mode-map (make-sparse-keymap))
13856 (suppress-keymap gnus-server-mode-map)
13857 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
13858 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
13859 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
13860 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
13861 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
13862 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
13863 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
13864 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
13866 (defun gnus-server-mode ()
13867 "Major mode for listing and editing servers.
13869 All normal editing commands are switched off.
13870 \\<gnus-server-mode-map>
13872 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
13874 The following commands are available:
13876 \\{gnus-server-mode-map}"
13878 ; (if gnus-visual (gnus-server-make-menu-bar))
13879 (kill-all-local-variables)
13880 (setq mode-line-modified "-- ")
13881 (make-local-variable 'mode-line-format)
13882 (setq mode-line-format (copy-sequence mode-line-format))
13883 (and (equal (nth 3 mode-line-format) " ")
13884 (setcar (nthcdr 3 mode-line-format) ""))
13885 (setq major-mode 'gnus-server-mode)
13886 (setq mode-name "Server")
13887 ; (gnus-group-set-mode-line)
13888 (setq mode-line-process nil)
13889 (use-local-map gnus-server-mode-map)
13890 (buffer-disable-undo (current-buffer))
13891 (setq truncate-lines t)
13892 (setq buffer-read-only t)
13893 (run-hooks 'gnus-server-mode-hook))
13895 (defun gnus-server-insert-server-line (sformat name method)
13896 (let* ((sformat (or sformat gnus-server-line-format-spec))
13898 (where (nth 1 method))
13900 (beginning-of-line)
13902 ;; Insert the text.
13903 (insert (eval sformat))
13904 (add-text-properties
13905 b (1+ b) (list 'gnus-server (intern name)))))
13907 (defun gnus-server-setup-buffer ()
13908 (if (get-buffer gnus-server-buffer)
13911 (set-buffer (get-buffer-create gnus-server-buffer))
13912 (gnus-server-mode))))
13914 (defun gnus-server-prepare ()
13915 (setq gnus-server-mode-line-format-spec
13916 (gnus-parse-format gnus-server-mode-line-format
13917 gnus-server-mode-line-format-alist))
13918 (setq gnus-server-line-format-spec
13919 (gnus-parse-format gnus-server-line-format
13920 gnus-server-line-format-alist))
13921 (let ((alist gnus-server-alist)
13922 (buffer-read-only nil))
13925 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
13926 (setq alist (cdr alist))))
13927 (goto-char (point-min))
13928 (gnus-server-position-cursor))
13930 (defun gnus-server-server-name ()
13931 (let ((server (get-text-property
13932 (save-excursion (beginning-of-line) (point)) 'gnus-server)))
13933 (and server (symbol-name server))))
13935 (defalias 'gnus-server-position-cursor 'gnus-goto-colon)
13937 (defvar gnus-winconf-edit-server nil)
13938 (defconst gnus-server-edit-buffer "*Gnus edit server*")
13940 (defun gnus-server-update-server (server)
13942 (set-buffer gnus-server-buffer)
13943 (let ((buffer-read-only nil)
13944 (info (cdr (assoc server gnus-server-alist))))
13945 (gnus-dribble-enter
13946 (concat "(gnus-server-set-info \"" server "\" '"
13947 (prin1-to-string info) ")"))
13948 ;; Buffer may be narrowed.
13951 (if (gnus-server-goto-server server)
13952 (delete-region (progn (beginning-of-line) (point))
13953 (progn (forward-line 1) (point))))
13954 (let ((entry (assoc server gnus-server-alist)))
13955 (gnus-server-insert-server-line nil (car entry) (cdr entry))
13956 (gnus-server-position-cursor))))))
13958 (defun gnus-server-set-info (info)
13959 (gnus-dribble-enter
13960 (concat "(gnus-server-set-info '"
13961 (prin1-to-string info) ")"))
13962 (let* ((server (nth 1 info))
13963 (entry (assoc server gnus-server-alist)))
13964 (if entry (setcdr entry info)
13965 (setq gnus-server-alist
13966 (nconc gnus-server-alist (list (cons server info)))))))
13968 (defun gnus-server-to-method (server)
13969 (cdr (assoc server gnus-server-alist)))
13971 (defun gnus-server-extend-method (group method)
13973 (gnus-copy-sequence (cdr (assoc (car method) gnus-server-alist)))))
13974 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
13975 (nconc entry (cdr method))))
13977 (defun gnus-server-get-method (group method)
13978 (cond ((stringp method)
13979 (gnus-server-to-method method))
13980 ((stringp (car method))
13981 (gnus-server-extend-method group method))
13985 ;;; Interactive server functions.
13987 (defun gnus-server-kill-server (server)
13988 "Kill the server on the current line."
13989 (interactive (list (gnus-server-server-name)))
13990 (or (gnus-server-goto-server server)
13991 (if server (error "No such server: %s" server)
13992 (error "No server on the current line")))
13993 (let ((buffer-read-only nil))
13994 (delete-region (progn (beginning-of-line) (point))
13995 (progn (forward-line 1) (point))))
13996 (setq gnus-server-killed-servers
13997 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
13998 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
13999 gnus-server-alist))
14000 (gnus-server-position-cursor))
14002 (defun gnus-server-yank-server ()
14003 "Yank the previously killed server."
14005 (or gnus-server-killed-servers
14006 (error "No killed servers to be yanked"))
14007 (let ((alist gnus-server-alist)
14008 (server (gnus-server-server-name))
14009 (killed (car gnus-server-killed-servers)))
14011 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
14012 (if (string= server (car (car gnus-server-alist)))
14013 (setq gnus-server-alist (cons killed gnus-server-alist))
14014 (while (and (cdr alist)
14015 (not (string= server (car (car (cdr alist))))))
14016 (setq alist (cdr alist)))
14017 (setcdr alist (cons killed (cdr alist)))))
14018 (gnus-server-update-server (car killed))
14019 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
14020 (gnus-server-position-cursor)))
14022 (defun gnus-server-exit ()
14023 "Return to the group buffer."
14025 (kill-buffer (current-buffer))
14026 (switch-to-buffer gnus-group-buffer))
14028 (defun gnus-server-list-servers ()
14029 "List all available servers."
14031 (let ((cur (gnus-server-server-name)))
14032 (gnus-server-prepare)
14033 (if cur (gnus-server-goto-server cur)
14034 (goto-char (point-max))
14036 (gnus-server-position-cursor)))
14038 (defun gnus-server-copy-server (from to)
14041 (or (gnus-server-server-name)
14042 (error "No server on the current line"))
14043 (read-string "Copy to: ")))
14044 (or from (error "No server on current line"))
14045 (or (and to (not (string= to ""))) (error "No name to copy to"))
14046 (and (assoc to gnus-server-alist) (error "%s already exists" to))
14047 (or (assoc from gnus-server-alist)
14048 (error "%s: no such server" from))
14049 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
14050 (setcar to-entry to)
14051 (setcar (nthcdr 2 to-entry) to)
14052 (setq gnus-server-killed-servers
14053 (cons to-entry gnus-server-killed-servers))
14054 (gnus-server-yank-server)))
14056 (defun gnus-server-add-server (how where)
14058 (list (intern (completing-read "Server method: "
14059 gnus-valid-select-methods nil t))
14060 (read-string "Server name: ")))
14061 (setq gnus-server-killed-servers
14062 (cons (list where how where) gnus-server-killed-servers))
14063 (gnus-server-yank-server))
14065 (defun gnus-server-goto-server (server)
14066 "Jump to a server line."
14068 (list (completing-read "Goto server: " gnus-server-alist nil t)))
14069 (let ((to (text-property-any (point-min) (point-max)
14070 'gnus-server (intern server))))
14074 (gnus-server-position-cursor)))))
14076 (defun gnus-server-edit-server (server)
14077 "Edit the server on the current line."
14078 (interactive (list (gnus-server-server-name)))
14080 (error "No server on current line"))
14081 (setq gnus-winconf-edit-server (current-window-configuration))
14082 (pop-to-buffer (get-buffer-create gnus-server-edit-buffer))
14083 (gnus-add-current-to-buffer-list)
14085 (use-local-map (copy-keymap (current-local-map)))
14086 (local-set-key "\C-c\C-c" 'gnus-server-edit-server-done)
14088 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
14089 (insert "(gnus-server-set-info \n "
14090 (pp-to-string (list 'quote (cdr (assoc server gnus-server-alist))))
14093 (defun gnus-server-edit-server-done ()
14095 (set-buffer (get-buffer-create gnus-server-edit-buffer))
14096 (eval-current-buffer)
14097 (kill-buffer (current-buffer))
14098 (and gnus-winconf-edit-server
14099 (set-window-configuration gnus-winconf-edit-server))
14100 (setq gnus-winconf-edit-server nil)
14101 (set-buffer gnus-server-buffer)
14102 (gnus-server-update-server (gnus-server-server-name))
14103 (gnus-server-position-cursor))
14108 ;;; gnus.el ends here