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-alist', `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
41 ;; Site dependent variables. These variables should be defined in
44 (defvar gnus-default-nntp-server nil
45 "Specify a default NNTP server.
46 This variable should be defined in paths.el, and should never be set
48 If you want to change servers, you should use `gnus-select-method'.
49 See the documentation to that variable.")
51 (defconst gnus-backup-default-subscribed-newsgroups
52 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
53 "Default default new newsgroups the first time Gnus is run.
54 Should be set in paths.el, and shouldn't be touched by the user.")
56 (defvar gnus-local-domain nil
57 "Local domain name without a host name.
58 The DOMAINNAME environment variable is used instead if it is defined.
59 If the `system-name' function returns the full Internet name, there is
60 no need to set this variable.")
62 (defvar gnus-local-organization nil
63 "String with a description of what organization (if any) the user belongs to.
64 The ORGANIZATION environment variable is used instead if it is defined.
65 If this variable contains a function, this function will be called
66 with the current newsgroup name as the argument. The function should
68 In any case, if the string (either in the variable, in the environment
69 variable, or returned by the function) is a file name, the contents of
70 this file will be used as the organization.")
72 (defvar gnus-use-generic-from nil
73 "If nil, the full host name will be the system name prepended to the domain name.
74 If this is a string, the full host name will be this string.
75 If this is non-nil, non-string, the domain name will be used as the
78 (defvar gnus-use-generic-path nil
79 "If nil, use the NNTP server name in the Path header.
80 If stringp, use this; if non-nil, use no host name (user name only).")
83 ;; Customization variables
85 (defvar gnus-select-method
86 (list 'nntp (or (getenv "NNTPSERVER")
87 (if (and gnus-default-nntp-server
88 (not (string= gnus-default-nntp-server "")))
89 gnus-default-nntp-server)
91 "*Default method for selecting a newsgroup.
92 This variable should be a list, where the first element is how the
93 news is to be fetched, the second is the address.
95 For instance, if you want to get your news via NNTP from
96 \"flab.flab.edu\", you could say:
98 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
100 If you want to use your local spool, say:
102 (setq gnus-select-method (list 'nnspool (system-name)))
104 If you use this variable, you must set `gnus-nntp-server' to nil.
106 There is a lot more to know about select methods and virtual servers -
107 see the manual for details.")
109 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
110 (defvar gnus-post-method nil
111 "*Preferred method for posting USENET news.
112 If this variable is nil, Gnus will use the current method to decide
113 which method to use when posting. If it is non-nil, it will override
114 the current method. This method will not be used in mail groups and
115 the like, only in \"real\" newsgroups.
117 The value must be a valid method as discussed in the documentation of
118 `gnus-select-method'.")
120 (defvar gnus-refer-article-method nil
121 "*Preferred method for fetching an article by Message-ID.
122 If you are reading news from the local spool (with nnspool), fetching
123 articles by Message-ID is painfully slow. By setting this method to an
124 nntp method, you might get acceptable results.
126 The value of this variable must be a valid select method as discussed
127 in the documentation of `gnus-select-method'")
129 (defvar gnus-secondary-select-methods nil
130 "*A list of secondary methods that will be used for reading news.
131 This is a list where each element is a complete select methdod (see
132 `gnus-select-method').
134 If, for instance, you want to read your mail with the nnml backend,
135 you could set this variable:
137 (setq gnus-secondary-select-methods '((nnml \"\"))")
139 (defvar gnus-secondary-servers nil
140 "*List of NNTP servers that the user can choose between interactively.
141 To make Gnus query you for a server, you have to give `gnus' a
142 non-numeric prefix - `C-u M-x gnus', in short.")
144 (defvar gnus-nntp-server nil
145 "*The name of the host running the NNTP server.
146 This variable is semi-obsolete. Use the `gnus-select-method'
149 (defvar gnus-nntp-service "nntp"
150 "*NNTP service name (\"nntp\" or 119).
151 This is an obsolete variable, which is scarcely used. If you use an
152 nntp server for your newsgroup and want to change the port number
153 used to 899, you would say something along these lines:
155 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
157 (defvar gnus-startup-file "~/.newsrc"
158 "*Your `.newsrc' file.
159 `.newsrc-SERVER' will be used instead if that exists.")
161 (defvar gnus-signature-file "~/.signature"
162 "*Your signature file.
163 If the variable is a string that doesn't correspond to a file, the
164 string itself is inserted.")
166 (defvar gnus-signature-function nil
167 "*A function that should return a signature file name.
168 The function will be called with the name of the newsgroup being
170 If the function returns a string that doesn't correspond to a file, the
171 string itself is inserted.
172 If the function returns nil, the `gnus-signature-file' variable will
175 (defvar gnus-init-file "~/.gnus"
176 "*Your Gnus elisp startup file.
177 If a file with the .el or .elc suffixes exist, it will be read
180 (defvar gnus-group-faq-directory
181 "/anonymous@rtfm.mit.edu:/pub/usenet-by-group/"
182 "*Directory where the group FAQs are stored.
183 This will most commonly be on a remote machine, and the file will be
184 fetched by ange-ftp.")
186 (defvar gnus-group-archive-directory
187 "/ftp@sina.tcamc.uh.edu:/pub/emacs/ding-list/"
188 "*The address of the (ding) archives.")
190 (defvar gnus-default-subscribed-newsgroups nil
191 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
192 It should be a list of strings.
193 If it is `t', Gnus will not do anything special the first time it is
194 started; it'll just use the normal newsgroups subscription methods.")
196 (defvar gnus-post-prepare-function nil
197 "*Function that is run after a post buffer has been prepared.
198 It is called with the name of the newsgroup that is posted to. It
199 might be used, for instance, for inserting signatures based on the
200 newsgroup name. (In that case, `gnus-signature-file' and
201 `mail-signature' should both be set to nil).")
203 (defvar gnus-use-cross-reference t
204 "*Non-nil means that cross referenced articles will be marked as read.
205 If nil, ignore cross references. If t, mark articles as read in
206 subscribed newsgroups. If neither t nor nil, mark as read in all
209 (defvar gnus-use-dribble-file t
210 "*Non-nil means that Gnus will use a dribble file to store user updates.
211 If Emacs should crash without saving the .newsrc files, complete
212 information can be restored from the dribble file.")
214 (defvar gnus-use-followup-to 'use
215 "*Specifies what to do with Followup-To header.
216 If nil, ignore the header. If it is t, use its value, but ignore
217 `poster'. If it is neither nil nor t, which is the default, always use
220 (defvar gnus-followup-to-function nil
221 "*A variable that contains a function that returns a followup address.
222 The function will be called in the buffer of the article that is being
223 followed up. The buffer will be narrowed to the headers of the
224 article. To pick header headers, one might use `mail-fetch-field'. The
225 function will be called with the name of the current newsgroup as the
228 Here's an example `gnus-followup-to-function':
230 (setq gnus-followup-to-function
232 (cond ((string= group \"mail.list\")
233 (or (mail-fetch-field \"sender\")
234 (mail-fetch-field \"from\")))
236 (or (mail-fetch-field \"reply-to\")
237 (mail-fetch-field \"from\"))))))")
239 (defvar gnus-reply-to-function nil
240 "*A variable that contains a function that returns a reply address.
241 See the `gnus-followup-to-function' variable for an explanation of how
242 this variable is used.
244 This function should return a string that will be used to fill in the
245 header. This function may also return a list. In that case, every
246 list element should be a cons where the first car should be a string
247 with the header name, and the cdr should be a string with the header
250 (defvar gnus-asynchronous nil
251 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
253 (defvar gnus-asynchronous-article-function nil
254 "*Function for picking articles to pre-fetch, possibly.")
256 (defvar gnus-score-file-suffix "SCORE"
257 "*Suffix of the score files.")
259 (defvar gnus-score-interactive-default-score 1000
260 "*Scoring commands will raise/lower the score with this number as the default.")
262 (defvar gnus-large-newsgroup 200
263 "*The number of articles which indicates a large newsgroup.
264 If the number of articles in a newsgroup is greater than this value,
265 confirmation is required for selecting the newsgroup.")
267 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
268 (defvar gnus-no-groups-message "No news is horrible news"
269 "*Message displayed by Gnus when no groups are available.")
271 (defvar gnus-author-copy (getenv "AUTHORCOPY")
272 "*Save outgoing articles in this file.
273 Initialized from the AUTHORCOPY environment variable.
275 If this variable begins with the character \"|\", outgoing articles
276 will be piped to the named program. It is possible to save an article
277 in an MH folder as follows:
279 \(setq gnus-author-copy \"|/usr/local/lib/mh/rcvstore +Article\")
281 If the first character is not a pipe, articles are saved using the
282 function specified by the `gnus-author-copy-saver' variable.")
284 (defvar gnus-mail-self-blind nil
285 "*Non-nil means insert a BCC header in all outgoing articles.
286 This will result in having a copy of the article mailed to yourself.
287 The BCC header is inserted when the post buffer is initialized, so you
288 can remove or alter the BCC header to override the default.")
290 (defvar gnus-author-copy-saver (function rmail-output)
291 "*A function called to save outgoing articles.
292 This function will be called with the same of the file to store the
293 article in. The default function is `rmail-output' which saves in Unix
296 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
297 "*Non-nil means that the default name of a file to save articles in is the group name.
298 If it's nil, the directory form of the group name is used instead.
300 If this variable is a list, and the list contains the element
301 `not-score', long file names will not be used for score files; if it
302 contains the element `not-save', long file names will not be used for
303 saving; and if it contains the element `not-kill', long file names
304 will not be used for kill files.")
306 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
307 "*Name of the directory articles will be saved in (default \"~/News\").
308 Initialized from the SAVEDIR environment variable.")
310 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
311 "*Name of the directory where kill files will be stored (default \"~/News\").
312 Initialized from the SAVEDIR environment variable.")
314 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
315 "*A function to save articles in your favorite format.
316 The function must be interactively callable (in other words, it must
317 be an Emacs command).
319 Gnus provides the following functions:
321 * gnus-summary-save-in-rmail (Rmail format)
322 * gnus-summary-save-in-mail (Unix mail format)
323 * gnus-summary-save-in-folder (MH folder)
324 * gnus-summary-save-in-file (article format).
325 * gnus-summary-save-in-vm (use VM's folder format).")
327 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
328 "*A function generating a file name to save articles in Rmail format.
329 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
331 (defvar gnus-mail-save-name (function gnus-plain-save-name)
332 "*A function generating a file name to save articles in Unix mail format.
333 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
335 (defvar gnus-folder-save-name (function gnus-folder-save-name)
336 "*A function generating a file name to save articles in MH folder.
337 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
339 (defvar gnus-file-save-name (function gnus-numeric-save-name)
340 "*A function generating a file name to save articles in article format.
341 The function is called with NEWSGROUP, HEADERS, and optional
344 (defvar gnus-split-methods nil
345 "*Variable used to suggest where articles are to be saved.
346 The syntax of this variable is the same as `nnmail-split-methods'.
348 For instance, if you would like to save articles related to Gnus in
349 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
350 you could set this variable to something like:
352 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
353 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))")
355 (defvar gnus-save-score nil
356 "*If non-nil, save group scoring info.")
358 (defvar gnus-use-adaptive-scoring nil
359 "*If non-nil, use some adaptive scoring scheme.")
361 (defvar gnus-use-cache nil
362 "*If non-nil, Gnus will cache (some) articles locally.")
364 (defvar gnus-use-scoring t
365 "*If non-nil, enable scoring.")
367 (defvar gnus-fetch-old-headers nil
368 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
369 If an unread article in the group refers to an older, already read (or
370 just marked as read) article, the old article will not normally be
371 displayed in the Summary buffer. If this variable is non-nil, Gnus
372 will attempt to grab the headers to the old articles, and thereby
373 build complete threads. If it has the value `some', only enough
374 headers to connect otherwise loose threads will be displayed.
376 The server has to support XOVER for any of this to work.")
378 (defvar gnus-visual t
379 "*If non-nil, will do various highlighting.
380 If nil, no mouse highlights (or any other highlights) will be
381 performed. This might speed up Gnus some when generating large group
382 and summary buffers.")
384 (defvar gnus-novice-user t
385 "*Non-nil means that you are a usenet novice.
386 If non-nil, verbose messages may be displayed and confirmations may be
389 (defvar gnus-expert-user nil
390 "*Non-nil means that you will never be asked for confirmation about anything.
391 And that means *anything*.")
393 (defvar gnus-verbose 7
394 "*Integer that says how verbose Gnus should be.
395 The higher the number, the more messages Gnus will flash to say what
396 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
397 display most important messages; and at ten, Gnus will keep on
398 jabbering all the time.")
400 (defvar gnus-keep-same-level nil
401 "*Non-nil means that the next newsgroup after the current will be on the same level.
402 When you type, for instance, `n' after reading the last article in the
403 current newsgroup, you will go to the next newsgroup. If this variable
404 is nil, the next newsgroup will be the next from the group
406 If this variable is non-nil, Gnus will either put you in the
407 next newsgroup with the same level, or, if no such newsgroup is
408 available, the next newsgroup with the lowest possible level higher
409 than the current level.
410 If this variable is `best', Gnus will make the next newsgroup the one
411 with the best level.")
413 (defvar gnus-summary-make-false-root 'adopt
414 "*nil means that Gnus won't gather loose threads.
415 If the root of a thread has expired or been read in a previous
416 session, the information necessary to build a complete thread has been
417 lost. Instead of having many small sub-threads from this original thread
418 scattered all over the summary buffer, Gnus can gather them.
420 If non-nil, Gnus will try to gather all loose sub-threads from an
421 original thread into one large thread.
423 If this variable is non-nil, it should be one of `none', `adopt',
426 If this variable is `none', Gnus will not make a false root, but just
427 present the sub-threads after another.
428 If this variable is `dummy', Gnus will create a dummy root that will
429 have all the sub-threads as children.
430 If this variable is `adopt', Gnus will make one of the \"children\"
431 the parent and mark all the step-children as such.
432 If this variable is `empty', the \"children\" are printed with empty
433 subject fields. (Or rather, they will be printed with a string
434 given by the `gnus-summary-same-subject' variable.)")
436 (defvar gnus-summary-gather-subject-limit nil
437 "*Maximum length of subject comparisons when gathering loose threads.
438 Use nil to compare full subjects. Setting this variable to a low
439 number will help gather threads that have been corrupted by
440 newsreaders chopping off subject lines, but it might also mean that
441 unrelated articles that have subject that happen to begin with the
442 same few characters will be incorrectly gathered.
444 If this variable is `fuzzy', Gnus will use a fuzzy algortihm when
445 comparing subjects.")
447 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
448 (defvar gnus-summary-same-subject ""
449 "*String indicating that the current article has the same subject as the previous.
450 This variable will only be used if the value of
451 `gnus-summary-make-false-root' is `empty'.")
453 (defvar gnus-summary-goto-unread nil
454 "*If non-nil, marking commands will go to the next unread article.")
456 (defvar gnus-group-goto-unread t
457 "*If non-nil, movement commands will go to the next unread and subscribed group.")
459 (defvar gnus-check-new-newsgroups t
460 "*Non-nil means that Gnus will add new newsgroups at startup.
461 If this variable is `ask-server', Gnus will ask the server for new
462 groups since the last time it checked. This means that the killed list
463 is no longer necessary, so you could set `gnus-save-killed-list' to
466 A variant is to have this variable be a list of select methods. Gnus
467 will then use the `ask-server' method on all these select methods to
468 query for new groups from all those servers.
471 (setq gnus-check-new-newsgroups
472 '((nntp \"some.server\") (nntp \"other.server\")))
474 If this variable is nil, then you have to tell Gnus explicitly to
475 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
477 (defvar gnus-check-bogus-newsgroups nil
478 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
479 If this variable is nil, then you have to tell Gnus explicitly to
480 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
482 (defvar gnus-read-active-file t
483 "*Non-nil means that Gnus will read the entire active file at startup.
484 If this variable is nil, Gnus will only know about the groups in your
487 If this variable is `some', Gnus will try to only read the relevant
488 parts of the active file from the server. Not all servers support
489 this, and it might be quite slow with other servers, but this should
490 generally be faster than both the t and nil value.
492 If you set this variable to nil or `some', you probably still want to
493 be told about new newsgroups that arrive. To do that, set
494 `gnus-check-new-newsgroups' to `ask-server'. This may not work
495 properly with all servers.")
497 (defvar gnus-level-subscribed 5
498 "*Groups with levels less than or equal to this variable are subscribed.")
500 (defvar gnus-level-unsubscribed 7
501 "*Groups with levels less than or equal to this variable are unsubscribed.
502 Groups with levels less than `gnus-level-subscribed', which should be
503 less than this variable, are subscribed.")
505 (defvar gnus-level-zombie 8
506 "*Groups with this level are zombie groups.")
508 (defvar gnus-level-killed 9
509 "*Groups with this level are killed.")
511 (defvar gnus-level-default-subscribed 3
512 "*New subscribed groups will be subscribed at this level.")
514 (defvar gnus-level-default-unsubscribed 6
515 "*New unsubscribed groups will be unsubscribed at this level.")
517 (defvar gnus-activate-foreign-newsgroups nil
518 "*If nil, Gnus will not check foreign newsgroups at startup.
519 If it is non-nil, it should be a number between one and nine. Foreign
520 newsgroups that have a level lower or equal to this number will be
521 activated on startup. For instance, if you want to active all
522 subscribed newsgroups, but not the rest, you'd set this variable to
523 `gnus-level-subscribed'.
525 If you subscribe to lots of newsgroups from different servers, startup
526 might take a while. By setting this variable to nil, you'll save time,
527 but you won't be told how many unread articles there are in the
530 (defvar gnus-save-newsrc-file t
531 "*Non-nil means that Gnus will save the `.newsrc' file.
532 Gnus always saves its own startup file, which is called
533 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
534 be readily understood by other newsreaders. If you don't plan on
535 using other newsreaders, set this variable to nil to save some time on
538 (defvar gnus-save-killed-list t
539 "*If non-nil, save the list of killed groups to the startup file.
540 This will save both time (when starting and quitting) and space (both
541 memory and disk), but it will also mean that Gnus has no record of
542 which groups are new and which are old, so the automatic new
543 newsgroups subscription methods become meaningless. You should always
544 set `gnus-check-new-newsgroups' to `ask-server' or nil if you set this
547 (defvar gnus-interactive-catchup t
548 "*If non-nil, require your confirmation when catching up a group.")
550 (defvar gnus-interactive-post t
551 "*If non-nil, group name will be asked for when posting.")
553 (defvar gnus-interactive-exit t
554 "*If non-nil, require your confirmation when exiting Gnus.")
556 (defvar gnus-kill-killed nil
557 "*If non-nil, Gnus will apply kill files to already killed articles.
558 If it is nil, Gnus will never apply kill files to articles that have
559 already been through the scoring process, which might very well save lots
562 (defvar gnus-extract-address-components 'gnus-extract-address-components
563 "*Function for extracting address components from a From header.
564 Two pre-defined function exist: `gnus-extract-address-components',
565 which is the default, quite fast, and too simplistic solution, and
566 `mail-extract-address-components', which works much better, but is
569 (defvar gnus-summary-default-score 0
570 "*Default article score level.
571 If this variable is nil, scoring will be disabled.")
573 (defvar gnus-group-default-list-level gnus-level-subscribed
574 "*Default listing level.")
576 (defvar gnus-group-always-list-unread gnus-level-subscribed
577 "*Always list groups less than this variable with unread articles.
578 If nil, use parameter to specify.")
580 (defvar gnus-user-login-name nil
581 "*The login name of the user.
582 Got from the function `user-login-name' if undefined.")
584 (defvar gnus-user-full-name nil
585 "*The full name of the user.
586 Got from the NAME environment variable if undefined.")
588 (defvar gnus-user-from-line nil
589 "*Your full, complete e-mail address.
590 Overrides the other Gnus variables if it is non-nil.
592 Here are two example values of this variable:
594 \"Lars Magne Ingebrigtsen <larsi@ifi.uio.no>\"
598 \"larsi@ifi.uio.no (Lars Magne Ingebrigtsen)\"
600 The first version is recommended, but the name has to be quoted if it
601 contains non-alphanumerical characters.")
603 (defvar gnus-show-mime nil
604 "*If non-ni, do mime processing of articles.
605 The articles will simply be fed to the function given by
606 `gnus-show-mime-method'.")
608 (defvar gnus-show-mime-method (function metamail-buffer)
609 "*Function to process a MIME message.
610 The function is called from the article buffer.")
612 (defvar gnus-show-threads t
613 "*If non-nil, display threads in summary mode.")
615 (defvar gnus-thread-hide-subtree nil
616 "*If non-nil, hide all threads initially.
617 If threads are hidden, you have to run the command
618 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
619 to expose hidden threads.")
621 (defvar gnus-thread-hide-killed t
622 "*If non-nil, hide killed threads automatically.")
624 (defvar gnus-thread-ignore-subject nil
625 "*If non-nil, ignore subjects and do all threading based on the Reference header.
626 If nil, which is the default, articles that have different subjects
627 from their parents will start separate threads.")
629 (defvar gnus-thread-indent-level 4
630 "*Number that says how much each sub-thread should be indented.")
632 (defvar gnus-ignored-newsgroups
633 (purecopy (mapconcat 'identity
634 '("^to\\." ; not "real" groups
635 "^[0-9]+ " ; all digits in name
636 "[][\"#'();\\]" ; bogus characters
639 "*A regexp to match uninteresting newsgroups in the active file.
640 Any lines in the active file matching this regular expression are
641 removed from the newsgroup list before anything else is done to it,
642 thus making them effectively non-existant.")
644 (defvar gnus-ignored-headers
645 "^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:"
646 "*All headers that match this regexp will be hidden.
647 Also see `gnus-visible-headers'.")
649 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:"
650 "*All headers that do not match this regexp will be hidden.
651 Also see `gnus-ignored-headers'.")
653 (defvar gnus-sorted-header-list
654 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
655 "^Cc:" "^Date:" "^Organization:")
656 "*This variable is a list of regular expressions.
657 If it is non-nil, headers that match the regular expressions will
658 be placed first in the article buffer in the sequence specified by
661 (defvar gnus-required-headers
662 '(From Date Newsgroups Subject Message-ID Organization Lines X-Newsreader)
663 "*Headers to be generated or prompted for when posting an article.
664 RFC977 and RFC1036 require From, Date, Newsgroups, Subject,
665 Message-ID. Organization, Lines and X-Newsreader are optional. If
666 you want Gnus not to insert some header, remove it from this list.")
668 (defvar gnus-show-all-headers nil
669 "*If non-nil, don't hide any headers.")
671 (defvar gnus-save-all-headers t
672 "*If non-nil, don't remove any headers before saving.")
674 (defvar gnus-signature-separator "^-- *$"
675 "Regexp matching signature separator.")
677 (defvar gnus-check-before-posting t
678 "In non-nil, Gnus will attempt to run some checks on outgoing posts.")
680 (defvar gnus-inhibit-startup-message nil
681 "*If non-nil, the startup message will not be displayed.")
683 (defvar gnus-auto-extend-newsgroup t
684 "*If non-nil, extend newsgroup forward and backward when requested.")
686 (defvar gnus-auto-select-first t
687 "*If non-nil, select the first unread article when entering a group.
688 If you want to prevent automatic selection of the first unread article
689 in some newsgroups, set the variable to nil in
690 `gnus-select-group-hook'.")
692 (defvar gnus-auto-select-next t
693 "*If non-nil, offer to go to the next group from the end of the previous.
694 If the value is t and the next newsgroup is empty, Gnus will exit
695 summary mode and go back to group mode. If the value is neither nil
696 nor t, Gnus will select the following unread newsgroup. In
697 particular, if the value is the symbol `quietly', the next unread
698 newsgroup will be selected without any confirmations.")
700 (defvar gnus-auto-select-same nil
701 "*If non-nil, select the next article with the same subject.")
703 (defvar gnus-summary-check-current nil
704 "*If non-nil, consider the current article when moving.
705 The \"unread\" movement commands will stay on the same line if the
706 current article is unread.")
708 (defvar gnus-auto-center-summary t
709 "*If non-nil, always center the current summary buffer.")
711 (defvar gnus-auto-mail-to-author nil
712 "*If non-nil, mail the authors of articles a copy of your follow-ups.
713 If this variable is `ask', the user will be prompted for whether to
714 mail a copy. The string given by `gnus-mail-courtesy-message' will be
715 inserted at the beginning of the mail copy.
717 Mail is sent using the function specified by the
718 `gnus-mail-send-method' variable.")
720 ;; Added by Ethan Bradford <ethanb@ptolemy.astro.washington.edu>.
721 (defvar gnus-mail-courtesy-message
722 "The following message is a courtesy copy of an article\nthat has been posted as well.\n\n"
723 "*This is inserted at the start of a mailed copy of a posted message.
724 If this variable is nil, no such courtesy message will be added.")
726 (defvar gnus-break-pages t
727 "*If non-nil, do page breaking on articles.
728 The page delimiter is specified by the `gnus-page-delimiter'
731 (defvar gnus-page-delimiter "^\^L"
732 "*Regexp describing what to use as article page delimiters.
733 The default value is \"^\^L\", which is a form linefeed at the
734 beginning of a line.")
736 (defvar gnus-use-full-window t
737 "*If non-nil, use the entire Emacs screen.")
739 (defvar gnus-window-configuration nil
740 "Obsolete variable. See `gnus-buffer-configuration'.")
742 (defvar gnus-buffer-configuration
743 '((group ([group 1.0 point]
744 (if gnus-carpal [group-carpal 4])))
745 (summary ([summary 1.0 point]
746 (if gnus-carpal [summary-carpal 4])))
747 (article ([summary 0.25 point]
748 (if gnus-carpal [summary-carpal 4])
750 (server ([server 1.0 point]
751 (if gnus-carpal [server-carpal 2])))
752 (browse ([browse 1.0 point]
753 (if gnus-carpal [browse-carpal 2])))
754 (group-mail ([mail 1.0 point]))
755 (summary-mail ([mail 1.0 point]))
756 (summary-reply ([article 0.5]
758 (info ([nil 1.0 point]))
759 (summary-faq ([summary 0.25]
760 [article 1.0 point]))
761 (edit-group ([group 0.5]
762 [edit-group 1.0 point]))
763 (edit-server ([server 0.5]
764 [edit-server 1.0 point]))
765 (post ([post 1.0 point]))
766 (reply ([article 0.5]
768 (mail-forward ([mail 1.0 point]))
769 (post-forward ([post 1.0 point]))
770 (reply-yank ([mail 1.0 point]))
771 (followup ([article 0.5]
773 (followup-yank ([post 1.0 point])))
774 "Window configuration for all possible Gnus buffers.
775 This variable is a list of lists. Each of these lists has a NAME and
776 a RULE. The NAMEs are commonsense names like `group', which names a
777 rule used when displaying the group buffer; `summary', which names a
778 rule for what happens when you enter a group and do not display an
779 article buffer; and so on. See the value of this variable for a
780 complete list of NAMEs.
782 Each RULE is a list of vectors. The first element in this vector is
783 the name of the buffer to be displayed; the second element is the
784 percentage of the screen this buffer is to occupy (a number in the
785 0.0-0.99 range); the optional third element is `point', which should
786 be present to denote which buffer point is to go to after making this
787 buffer configuration.")
789 (defvar gnus-window-to-buffer
790 '((group . gnus-group-buffer)
791 (summary . gnus-summary-buffer)
792 (article . gnus-article-buffer)
793 (server . gnus-server-buffer)
794 (browse . "*Gnus Browse Server*")
795 (edit-group . gnus-group-edit-buffer)
796 (edit-server . gnus-server-edit-buffer)
797 (group-carpal . gnus-carpal-group-buffer)
798 (summary-carpal . gnus-carpal-summary-buffer)
799 (server-carpal . gnus-carpal-server-buffer)
800 (browse-carpal . gnus-carpal-browse-buffer)
802 (post . gnus-post-news-buffer))
803 "Mapping from short symbols to buffer names or buffer variables.")
805 (defvar gnus-carpal nil
806 "*If non-nil, display clickable icons.")
808 (defvar gnus-mail-reply-method (function gnus-mail-reply-using-mail)
809 "*Function to compose a reply.
810 Three pre-made functions are `gnus-mail-reply-using-mail' (sendmail);
811 `gnus-mail-reply-using-mhe' (MH-E); and `gnus-mail-reply-using-vm'.")
813 (defvar gnus-mail-forward-method (function gnus-mail-forward-using-mail)
814 "*Function to forward the current message to another user.
815 Three pre-made functions are `gnus-mail-forward-using-mail' (sendmail);
816 `gnus-mail-forward-using-mhe' (MH-E); and `gnus-mail-forward-using-vm'.")
818 (defvar gnus-mail-other-window-method 'gnus-mail-other-window-using-mail
819 "*Function to compose mail in the other window.
820 Three pre-made functions are `gnus-mail-other-window-using-mail'
821 (sendmail); `gnus-mail-other-window-using-mhe' (MH-E); and
822 `gnus-mail-other-window-using-vm'.")
824 (defvar gnus-mail-send-method send-mail-function
825 "*Function to mail a message which is also being posted as an article.
826 The message must have To or Cc header. The default is copied from
827 the variable `send-mail-function'.")
829 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
830 "*Function called with a group name when new group is detected.
831 A few pre-made functions are supplied: `gnus-subscribe-randomly'
832 inserts new groups at the beginning of the list of groups;
833 `gnus-subscribe-alphabetically' inserts new groups in strict
834 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
835 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
838 ;; Suggested by a bug report by Hallvard B Furuseth.
839 ;; <h.b.furuseth@usit.uio.no>.
840 (defvar gnus-subscribe-options-newsgroup-method
841 (function gnus-subscribe-alphabetically)
842 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
843 If, for instance, you want to subscribe to all newsgroups in the
844 \"no\" and \"alt\" hierarchies, you'd put the following in your
847 options -n no.all alt.all
849 Gnus will the subscribe all new newsgroups in these hierarchies with
850 the subscription method in this variable.")
852 (defvar gnus-subscribe-hierarchical-interactive nil
853 "*If non-nil, Gnus will offer to subscribe hierarchically.
854 When a new hierarchy appears, Gnus will ask the user:
856 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
858 If the user pressed `d', Gnus will descend the hierarchy, `y' will
859 subscribe to all newsgroups in the hierarchy and `s' will skip this
860 hierarchy in its entirety.")
862 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
863 "*Function used for sorting the group buffer.
864 This function will be called with group info entries as the arguments
865 for the groups to be sorted. Pre-made functions include
866 `gnus-sort-by-alphabet', `gnus-sort-by-unread' and
867 `gnus-sort-by-level'")
869 ;; Mark variables suggested by Thomas Michanek
870 ;; <Thomas.Michanek@telelogic.se>.
871 (defvar gnus-unread-mark ?
872 "*Mark used for unread articles.")
873 (defvar gnus-ticked-mark ?!
874 "*Mark used for ticked articles.")
875 (defvar gnus-dormant-mark ??
876 "*Mark used for dormant articles.")
877 (defvar gnus-del-mark ?D
878 "*Mark used for del'd articles.")
879 (defvar gnus-read-mark ?d
880 "*Mark used for read articles.")
881 (defvar gnus-expirable-mark ?E
882 "*Mark used for expirable articles.")
883 (defvar gnus-killed-mark ?K
884 "*Mark used for killed articles.")
885 (defvar gnus-kill-file-mark ?X
886 "*Mark used for articles killed by kill files.")
887 (defvar gnus-low-score-mark ?Y
888 "*Mark used for articles with a low score.")
889 (defvar gnus-catchup-mark ?C
890 "*Mark used for articles that are caught up.")
891 (defvar gnus-replied-mark ?R
892 "*Mark used for articles that have been replied to.")
893 (defvar gnus-process-mark ?#
895 (defvar gnus-ancient-mark ?A
896 "*Mark used for ancient articles.")
897 (defvar gnus-canceled-mark ?G
898 "*Mark used for cancelled articles.")
899 (defvar gnus-score-over-mark ?+
900 "*Score mark used for articles with high scores.")
901 (defvar gnus-score-below-mark ?-
902 "*Score mark used for articles with low scores.")
903 (defvar gnus-empty-thread-mark ?
904 "*There is no thread under the article.")
905 (defvar gnus-not-empty-thread-mark ?=
906 "*There is a thread under the article.")
908 (defvar gnus-view-pseudo-asynchronously nil
909 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
911 (defvar gnus-view-pseudos nil
912 "*If `automatic', pseudo-articles will be viewed automatically.
913 If `not-confirm', pseudos will be viewed automatically, and the user
914 will not be asked to confirm the command.")
916 (defvar gnus-view-pseudos-separately t
917 "*If non-nil, one pseudo-article will be created for each file to be viewed.
918 If nil, all files that use the same viewing command will be given as a
919 list of parameters to that command.")
921 (defvar gnus-group-line-format "%M%S%5y: %(%g%)\n"
922 "*Format of group lines.
923 It works along the same lines as a normal formatting string,
924 with some simple extensions.
926 %M Only marked articles (character, \"*\" or \" \")
927 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
928 %L Level of subscribedness (integer)
929 %N Number of unread articles (integer)
930 %I Number of dormant articles (integer)
931 %i Number of ticked and dormant (integer)
932 %T Number of ticked articles (integer)
933 %R Number of read articles (integer)
934 %t Total number of articles (integer)
935 %y Number of unread, unticked articles (integer)
936 %G Group name (string)
937 %g Qualified group name (string)
938 %D Group description (string)
939 %s Select method (string)
940 %o Moderated group (char, \"m\")
941 %O Moderated group (string, \"(m)\" or \"\")
942 %n Select from where (string)
943 %z A string that look like `<%s:%n>' if a foreign select method is used
944 %u User defined specifier. The next character in the format string should
945 be a letter. Gnus will call the function gnus-user-format-function-X,
946 where X is the letter following %u. The function will be passed the
947 current header as argument. The function should return a string, which
948 will be inserted into the buffer just like information from any other
951 Text between %( and %) will be highlighted with `gnus-mouse-face' when
952 the mouse point move inside the area. There can only be one such area.
954 Note that this format specification is not always respected. For
955 reasons of efficiency, when listing killed groups, this specification
956 is ignored altogether. If the spec is changed considerably, your
957 output may end up looking strange when listing both alive and killed
960 If you use %o or %O, reading the active file will be slower and quite
961 a bit of extra memory will be used. %D will also worsen performance.
962 Also note that if you change the format specification to include any
963 of these specs, you must probably re-start Gnus to see them go into
966 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
967 "*The format specification of the lines in the summary buffer.
969 It works along the same lines as a normal formatting string,
970 with some simple extensions.
972 %N Article number, left padded with spaces (string)
974 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
975 %n Name of the poster (string)
976 %A Address of the poster (string)
977 %F Contents of the From: header (string)
978 %x Contents of the Xref: header (string)
979 %D Date of the article (string)
980 %d Date of the article (string) in DD-MMM format
981 %M Message-id of the article (string)
982 %r References of the article (string)
983 %c Number of characters in the article (integer)
984 %L Number of lines in the article (integer)
985 %I Indentation based on thread level (a string of spaces)
986 %T A string with two possible values: 80 spaces if the article
987 is on thread level two or larger and 0 spaces on level one
988 %R \"R\" if this article has been replied to, \" \" otherwise (character)
989 %U Status of this article (character, \"D\", \"K\", \"-\" or \" \")
990 %[ Opening bracket (character, \"[\" or \"<\")
991 %] Closing bracket (character, \"]\" or \">\")
992 %> Spaces of length thread-level (string)
993 %< Spaces of length (- 20 thread-level) (string)
994 %i Article score (number)
995 %z Article zcore (character)
996 %t Number of articles under the current thread (number).
997 %e Whether the thread is empty or not (character).
998 %u User defined specifier. The next character in the format string should
999 be a letter. Gnus will call the function gnus-user-format-function-X,
1000 where X is the letter following %u. The function will be passed the
1001 current header as argument. The function should return a string, which
1002 will be inserted into the summary just like information from any other
1005 Text between %( and %) will be highlighted with `gnus-mouse-face'
1006 when the mouse point is placed inside the area. There can only be one
1009 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1010 with care. For reasons of efficiency, Gnus will compute what column
1011 these characters will end up in, and \"hard-code\" that. This means that
1012 it is illegal to have these specs after a variable-length spec. Well,
1013 you might not be arrested, but your summary buffer will look strange,
1014 which is bad enough.
1016 The smart choice is to have these specs as for to the left as
1019 This restriction may disappear in later versions of Gnus.")
1021 (defvar gnus-summary-dummy-line-format "* : : %S\n"
1022 "*The format specification for the dummy roots in the summary buffer.
1023 It works along the same lines as a normal formatting string,
1024 with some simple extensions.
1028 (defvar gnus-summary-mode-line-format "(ding) %G/%A %Z"
1029 "*The format specification for the summary mode line.")
1031 (defvar gnus-article-mode-line-format "(ding) %G/%A %S"
1032 "*The format specification for the article mode line.")
1034 (defvar gnus-group-mode-line-format "(ding) List of groups {%M:%S} "
1035 "*The format specification for the group mode line.")
1037 (defvar gnus-valid-select-methods
1038 '(("nntp" post address prompt-address)
1040 ("nnvirtual" none virtual prompt-address)
1041 ("nnmbox" mail respool)
1042 ("nnml" mail respool)
1043 ("nnmh" mail respool)
1044 ("nndir" none prompt-address address)
1046 ("nndoc" none prompt-address)
1047 ("nnbabyl" mail respool)
1048 ("nnkiboze" none virtual)
1049 ("nnfolder" mail respool))
1050 "An alist of valid select methods.
1051 The first element of each list lists should be a string with the name
1052 of the select method. The other elements may be be the category of
1053 this method (ie. `post', `mail', `none' or whatever) or other
1054 properties that this method has (like being respoolable).
1055 If you implement a new select method, all you should have to change is
1056 this variable. I think.")
1058 (defvar gnus-updated-mode-lines '(group article summary)
1059 "*List of buffers that should update their mode lines.
1060 The list may contain the symbols `group', `article' and `summary'. If
1061 the corresponding symbol is present, Gnus will keep that mode line
1062 updated with information that may be pertinent.
1063 If this variable is nil, screen refresh may be quicker.")
1065 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1066 (defvar gnus-mode-non-string-length 21
1067 "*Max length of mode-line non-string contents.
1068 If this is nil, Gnus will take space as is needed, leaving the rest
1069 of the modeline intact.")
1071 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
1072 (defvar gnus-mouse-face 'highlight
1073 "*Face used for mouse highlighting in Gnus.
1074 No mouse highlights will be done if `gnus-visual' is nil.")
1076 (defvar gnus-summary-mark-below nil
1077 "*Mark all articles with a score below this variable as read.
1078 This variable is local to each summary buffer and usually set by the
1081 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1082 "*List of functions used for sorting threads in the summary buffer.
1083 By default, threads are sorted by article number.
1085 Each function takes two threads and return non-nil if the first thread
1086 should be sorted before the other. If you use more than one function,
1087 the primary sort function should be the last.
1089 Ready-mady functions include `gnus-thread-sort-by-number',
1090 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1091 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1092 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1094 (defvar gnus-thread-score-function '+
1095 "*Function used for calculating the total score of a thread.
1097 The function is called with the scores of the article and each
1098 subthread and should then return the score of the thread.
1100 Some functions you can use are `+', `max', or `min'.")
1102 (defvar gnus-options-subscribe nil
1103 "*All new groups matching this regexp will be subscribed unconditionally.
1104 Note that this variable deals only with new newsgroups. This variable
1105 does not affect old newsgroups.")
1107 (defvar gnus-options-not-subscribe nil
1108 "*All new groups matching this regexp will be ignored.
1109 Note that this variable deals only with new newsgroups. This variable
1110 does not affect old (already subscribed) newsgroups.")
1112 (defvar gnus-auto-expirable-newsgroups nil
1113 "*Groups in which to automatically mark read articles as expirable.
1114 If non-nil, this should be a regexp that should match all groups in
1115 which to perform auto-expiry. This only makes sense for mail groups.")
1120 (defvar gnus-group-mode-hook nil
1121 "*A hook for Gnus group mode.")
1123 (defvar gnus-summary-mode-hook nil
1124 "*A hook for Gnus summary mode.")
1126 (defvar gnus-article-mode-hook nil
1127 "*A hook for Gnus article mode.")
1129 (defvar gnus-open-server-hook nil
1130 "*A hook called just before opening connection to the news server.")
1132 (defvar gnus-startup-hook nil
1133 "*A hook called at startup.
1134 This hook is called after Gnus is connected to the NNTP server.")
1136 (defvar gnus-get-new-news-hook nil
1137 "*A hook run just before Gnus checks for new news.")
1139 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1140 "*A function that is called to generate the group buffer.
1141 The function is called with three arguments: The first is a number;
1142 all group with a level less or equal to that number should be listed,
1143 if the second is non-nil, empty groups should also be displayed. If
1144 the third is non-nil, it is a number. No groups with a level lower
1145 than this number should be displayed.
1147 The only current function implemented is `gnus-group-prepare-flat'.")
1149 (defvar gnus-group-prepare-hook nil
1150 "*A hook called after the group buffer has been generated.
1151 If you want to modify the group buffer, you can use this hook.")
1153 (defvar gnus-summary-prepare-hook nil
1154 "*A hook called after the summary buffer has been generated.
1155 If you want to modify the summary buffer, you can use this hook.")
1157 (defvar gnus-article-prepare-hook nil
1158 "*A hook called after an article has been prepared in the article buffer.
1159 If you want to run a special decoding program like nkf, use this hook.")
1161 (defvar gnus-article-display-hook nil
1162 "*A hook called after the article is displayed in the article buffer.
1163 The hook is designed to change the contents of the article
1164 buffer. Typical functions that this hook may contain are
1165 `gnus-article-hide-headers' (hide selected headers),
1166 `gnus-article-hide-signature' (hide signature) and
1167 `gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1168 (add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1169 (add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1171 (defvar gnus-article-x-face-command
1172 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1173 "String or function to be executed to display an X-Face header.
1174 If it is a string, the command will be executed in a sub-shell
1175 asynchronously. The compressed face will be piped to this command.")
1177 (defvar gnus-select-group-hook nil
1178 "*A hook called when a newsgroup is selected.
1180 If you'd like to simplify subjects like the
1181 `gnus-summary-next-same-subject' command does, you can use the
1184 (setq gnus-select-group-hook
1187 (mapcar (lambda (header)
1190 (gnus-simplify-subject
1191 (header-subject header) 're-only)))
1192 gnus-newsgroup-headers))))")
1194 (defvar gnus-select-article-hook
1195 '(gnus-summary-show-thread)
1196 "*A hook called when an article is selected.
1197 The default hook shows conversation thread subtrees of the selected
1198 article automatically using `gnus-summary-show-thread'.")
1200 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1201 "*A hook called to apply kill files to a group.
1202 This hook is intended to apply a kill file to the selected newsgroup.
1203 The function `gnus-apply-kill-file' is called by default.
1205 Since a general kill file is too heavy to use only for a few
1206 newsgroups, I recommend you to use a lighter hook function. For
1207 example, if you'd like to apply a kill file to articles which contains
1208 a string `rmgroup' in subject in newsgroup `control', you can use the
1211 \(setq gnus-apply-kill-hook
1214 (cond ((string-match \"control\" gnus-newsgroup-name)
1215 (gnus-kill \"Subject\" \"rmgroup\")
1216 (gnus-expunge \"X\"))))))")
1218 (defvar gnus-visual-mark-article-hook
1219 (list 'gnus-highlight-selected-summary)
1220 "*Hook run after selecting an article in the summary buffer.
1221 It is meant to be used for highlighting the article in some way. It
1222 is not run if `gnus-visual' is nil.")
1224 (defvar gnus-prepare-article-hook (list 'gnus-inews-insert-signature)
1225 "*A hook called after preparing body, but before preparing header headers.
1226 The default hook (`gnus-inews-insert-signature') inserts a signature
1227 file specified by the variable `gnus-signature-file'.")
1229 (defvar gnus-inews-article-hook (list 'gnus-inews-do-fcc)
1230 "*A hook called before finally posting an article.
1231 The default hook (`gnus-inews-do-fcc') does FCC processing (ie. saves
1232 the article to a file).")
1234 (defvar gnus-inews-article-header-hook nil
1235 "*A hook called after inserting the headers in an article to be posted.
1236 The hook is called from the *post-news* buffer, narrowed to the
1239 (defvar gnus-exit-group-hook nil
1240 "*A hook called when exiting (not quitting) summary mode.")
1242 (defvar gnus-suspend-gnus-hook nil
1243 "*A hook called when suspending (not exiting) Gnus.")
1245 (defvar gnus-exit-gnus-hook nil
1246 "*A hook called when exiting Gnus.")
1248 (defvar gnus-save-newsrc-hook nil
1249 "*A hook called when saving the newsrc file.")
1251 (defvar gnus-summary-update-hook
1252 (list 'gnus-summary-highlight-line)
1253 "*A hook called when a summary line is changed.
1254 The hook will not be called if `gnus-visual' is nil.
1256 The default function `gnus-summary-highlight-line' will
1257 highlight the line according to the `gnus-summary-highlight'
1260 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1261 "*A hook called when an article is selected for the first time.
1262 The hook is intended to mark an article as read (or unread)
1263 automatically when it is selected.")
1265 (defvar gnus-hidden-properties '(invisible t intangible t)
1266 "Property list to use for hiding text.")
1269 ;; Internal variables
1271 ;; Avoid highlighting in kill files.
1272 (defvar gnus-summary-inhibit-highlight nil)
1273 (defvar gnus-newsgroup-selected-overlay nil)
1275 (defvar gnus-article-mode-map nil)
1276 (defvar caesar-translate-table nil)
1277 (defvar gnus-dribble-buffer nil)
1278 (defvar gnus-headers-retrieved-by nil)
1279 (defvar gnus-article-reply nil)
1280 (defvar gnus-override-method nil)
1281 (defvar gnus-article-check-size nil)
1283 (defvar gnus-current-move-group nil)
1285 (defvar gnus-newsgroup-dependencies nil)
1286 (defvar gnus-newsgroup-threads nil)
1287 (defvar gnus-newsgroup-async nil)
1288 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1290 (defvar gnus-newsgroup-adaptive nil)
1292 (defconst gnus-group-line-format-alist
1293 (list (list ?M 'marked ?c)
1294 (list ?S 'subscribed ?c)
1296 (list ?N 'number ?s)
1297 (list ?I 'number-of-dormant ?d)
1298 (list ?T 'number-of-ticked ?d)
1299 (list ?R 'number-of-read ?s)
1300 (list ?t 'number-total ?d)
1301 (list ?y 'number-of-unread-unticked ?s)
1302 (list ?i 'number-of-ticked-and-dormant ?d)
1304 (list ?G 'qualified-group ?s)
1305 (list ?D 'newsgroup-description ?s)
1306 (list ?o 'moderated ?c)
1307 (list ?O 'moderated-string ?s)
1308 (list ?s 'news-server ?s)
1309 (list ?n 'news-method ?s)
1310 (list ?z 'news-method-string ?s)
1311 (list ?u 'user-defined ?s)))
1313 (defconst gnus-summary-line-format-alist
1314 (list (list ?N 'number ?d)
1315 (list ?S 'subject ?s)
1316 (list ?s 'subject-or-nil ?s)
1318 (list ?A 'address ?s)
1320 (list ?x (macroexpand '(header-xref header)) ?s)
1321 (list ?D (macroexpand '(header-date header)) ?s)
1322 (list ?d '(gnus-dd-mmm (header-date header)) ?s)
1323 (list ?M (macroexpand '(header-id header)) ?s)
1324 (list ?r (macroexpand '(header-references header)) ?s)
1325 (list ?c '(or (header-chars header) 0) ?d)
1327 (list ?I 'indentation ?s)
1328 (list ?T '(if (= level 0) "" (make-string (frame-width) ? )) ?s)
1329 (list ?R 'replied ?c)
1330 (list ?\[ 'opening-bracket ?c)
1331 (list ?\] 'closing-bracket ?c)
1332 (list ?\> '(make-string level ? ) ?s)
1333 (list ?\< '(make-string (max 0 (- 20 level)) ? ) ?s)
1335 (list ?z 'score-char ?c)
1336 (list ?U 'unread ?c)
1337 (list ?t '(gnus-summary-number-of-articles-in-thread
1338 (or gnus-tmp-adopt-thread
1339 (if (boundp 'thread) (symbol-value 'thread)
1342 (list ?e '(gnus-summary-number-of-articles-in-thread
1343 (or gnus-tmp-adopt-thread
1344 (if (boundp 'thread) (symbol-value 'thread)
1347 (list ?u 'user-defined ?s))
1348 "An alist of format specifications that can appear in summary lines,
1349 and what variables they correspond with, along with the type of the
1350 variable (string, integer, character, etc).")
1352 (defconst gnus-summary-dummy-line-format-alist
1353 (list (list ?S 'subject ?s)
1354 (list ?N 'number ?d)
1355 (list ?u 'user-defined ?s)))
1357 (defconst gnus-summary-mode-line-format-alist
1358 (list (list ?G 'group-name ?s)
1359 (list ?g '(gnus-short-group-name group-name) ?s)
1360 (list ?A 'article-number ?d)
1361 (list ?Z 'unread-and-unselected ?s)
1362 (list ?V 'gnus-version ?s)
1363 (list ?U 'unread ?d)
1364 (list ?S 'subject ?s)
1365 (list ?e 'unselected ?d)
1366 (list ?u 'user-defined ?s)
1367 (list ?s '(gnus-current-score-file-nondirectory) ?s)))
1369 (defconst gnus-group-mode-line-format-alist
1370 (list (list ?S 'news-server ?s)
1371 (list ?M 'news-method ?s)
1372 (list ?u 'user-defined ?s)))
1374 (defvar gnus-have-read-active-file nil)
1376 (defconst gnus-maintainer "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls & Boys)"
1377 "The mail address of the Gnus maintainer.")
1379 (defconst gnus-version "(ding) Gnus v0.70"
1380 "Version number for this version of Gnus.")
1382 (defvar gnus-info-nodes
1383 '((gnus-group-mode "(gnus)The Group Buffer")
1384 (gnus-summary-mode "(gnus)The Summary Buffer")
1385 (gnus-article-mode "(gnus)The Article Buffer"))
1386 "Assoc list of major modes and related Info nodes.")
1388 (defvar gnus-documentation-group-file "~/dgnus/lisp/doc.txt"
1389 "The location of the (ding) Gnus documentation group.")
1391 (defvar gnus-group-buffer "*Group*")
1392 (defvar gnus-summary-buffer "*Summary*")
1393 (defvar gnus-article-buffer "*Article*")
1394 (defvar gnus-server-buffer "*Server*")
1396 (defvar gnus-work-buffer " *gnus work*")
1398 (defvar gnus-buffer-list nil
1399 "Gnus buffers that should be killed on exit.")
1401 (defvar gnus-server-alist nil
1402 "List of available servers.")
1404 (defvar gnus-variable-list
1405 '(gnus-newsrc-options gnus-newsrc-options-n
1406 gnus-newsrc-last-checked-date
1407 gnus-newsrc-alist gnus-server-alist
1408 gnus-killed-list gnus-zombie-list)
1409 "Gnus variables saved in the quick startup file.")
1411 (defvar gnus-overload-functions
1412 '((news-inews gnus-inews-news "rnewspost")
1413 (caesar-region gnus-caesar-region "rnews"))
1414 "Functions overloaded by gnus.
1415 It is a list of `(original overload &optional file)'.")
1417 (defvar gnus-newsrc-options nil
1418 "Options line in the .newsrc file.")
1420 (defvar gnus-newsrc-options-n nil
1421 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1423 (defvar gnus-newsrc-last-checked-date nil
1424 "Date Gnus last asked server for new newsgroups.")
1426 (defvar gnus-newsrc-alist nil
1427 "Assoc list of read articles.
1428 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1430 (defvar gnus-newsrc-hashtb nil
1431 "Hashtable of gnus-newsrc-alist.")
1433 (defvar gnus-killed-list nil
1434 "List of killed newsgroups.")
1436 (defvar gnus-killed-hashtb nil
1437 "Hash table equivalent of gnus-killed-list.")
1439 (defvar gnus-zombie-list nil
1440 "List of almost dead newsgroups.")
1442 (defvar gnus-description-hashtb nil
1443 "Descriptions of newsgroups.")
1445 (defvar gnus-list-of-killed-groups nil
1446 "List of newsgroups that have recently been killed by the user.")
1448 (defvar gnus-active-hashtb nil
1449 "Hashtable of active articles.")
1451 (defvar gnus-moderated-list nil
1452 "List of moderated newsgroups.")
1454 (defvar gnus-group-marked nil)
1456 (defvar gnus-current-startup-file nil
1457 "Startup file for the current host.")
1459 (defvar gnus-last-search-regexp nil
1460 "Default regexp for article search command.")
1462 (defvar gnus-last-shell-command nil
1463 "Default shell command on article.")
1465 (defvar gnus-current-select-method nil
1466 "The current method for selecting a newsgroup.")
1468 (defvar gnus-have-all-newsgroups nil)
1470 (defvar gnus-article-internal-prepare-hook nil)
1472 (defvar gnus-newsgroup-name nil)
1473 (defvar gnus-newsgroup-begin nil)
1474 (defvar gnus-newsgroup-end nil)
1475 (defvar gnus-newsgroup-last-rmail nil)
1476 (defvar gnus-newsgroup-last-mail nil)
1477 (defvar gnus-newsgroup-last-folder nil)
1478 (defvar gnus-newsgroup-last-file nil)
1479 (defvar gnus-newsgroup-auto-expire nil)
1480 (defvar gnus-newsgroup-active nil)
1482 (defvar gnus-newsgroup-unreads nil
1483 "List of unread articles in the current newsgroup.")
1485 (defvar gnus-newsgroup-unselected nil
1486 "List of unselected unread articles in the current newsgroup.")
1488 (defvar gnus-newsgroup-marked nil
1489 "List of ticked articles in the current newsgroup (a subset of unread art).")
1491 (defvar gnus-newsgroup-killed nil
1492 "List of ranges of articles that have been through the scoring process.")
1494 (defvar gnus-newsgroup-kill-headers nil)
1496 (defvar gnus-newsgroup-replied nil
1497 "List of articles that have been replied to in the current newsgroup.")
1499 (defvar gnus-newsgroup-expirable nil
1500 "List of articles in the current newsgroup that can be expired.")
1502 (defvar gnus-newsgroup-processable nil
1503 "List of articles in the current newsgroup that can be processed.")
1505 (defvar gnus-newsgroup-bookmarks nil
1506 "List of articles in the current newsgroup that have bookmarks.")
1508 (defvar gnus-newsgroup-dormant nil
1509 "List of dormant articles in the current newsgroup.")
1511 (defvar gnus-newsgroup-scored nil
1512 "List of scored articles in the current newsgroup.")
1514 (defvar gnus-newsgroup-headers nil
1515 "List of article headers in the current newsgroup.")
1516 (defvar gnus-newsgroup-headers-hashtb-by-number nil)
1518 (defvar gnus-newsgroup-ancient nil
1519 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1521 (defvar gnus-current-article nil)
1522 (defvar gnus-article-current nil)
1523 (defvar gnus-current-headers nil)
1524 (defvar gnus-have-all-headers nil)
1525 (defvar gnus-last-article nil)
1526 (defvar gnus-newsgroup-history nil)
1527 (defvar gnus-current-kill-article nil)
1529 ;; Save window configuration.
1530 (defvar gnus-prev-winconf nil)
1533 (defvar gnus-summary-line-format-spec nil)
1534 (defvar gnus-summary-dummy-line-format-spec nil)
1535 (defvar gnus-group-line-format-spec nil)
1536 (defvar gnus-summary-mode-line-format-spec nil)
1537 (defvar gnus-article-mode-line-format-spec nil)
1538 (defvar gnus-group-mode-line-format-spec nil)
1539 (defvar gnus-summary-mark-positions nil)
1541 (defvar gnus-summary-expunge-below nil)
1542 (defvar gnus-reffed-article-number nil)
1544 (defvar rmail-default-file (expand-file-name "~/XMBOX"))
1545 (defvar rmail-default-rmail-file (expand-file-name "~/XNEWS"))
1547 (defconst gnus-summary-local-variables
1548 '(gnus-newsgroup-name
1549 gnus-newsgroup-begin gnus-newsgroup-end
1550 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1551 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1552 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1553 gnus-newsgroup-unselected gnus-newsgroup-marked
1554 gnus-newsgroup-replied gnus-newsgroup-expirable
1555 gnus-newsgroup-processable gnus-newsgroup-killed
1556 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1557 gnus-newsgroup-headers gnus-newsgroup-headers-hashtb-by-number
1558 gnus-current-article gnus-current-headers gnus-have-all-headers
1559 gnus-last-article gnus-article-internal-prepare-hook
1560 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1561 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1562 gnus-newsgroup-threads gnus-newsgroup-async
1563 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1564 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1565 gnus-newsgroup-history gnus-newsgroup-ancient
1566 gnus-newsgroup-adaptive)
1567 "Variables that are buffer-local to the summary buffers.")
1569 ;;; End of variables.
1571 ;; Define some autoload functions Gnus might use.
1575 (autoload 'metamail-buffer "metamail")
1576 (autoload 'Info-goto-node "info")
1577 (autoload 'hexl-hex-string-to-integer "hexl")
1579 (autoload 'pp-to-string "pp")
1580 (autoload 'mail-extract-address-components "mail-extr")
1583 (autoload 'timezone-make-date-arpa-standard "timezone")
1584 (autoload 'timezone-fix-time "timezone")
1585 (autoload 'timezone-make-sortable-date "timezone")
1586 (autoload 'timezone-make-time-string "timezone")
1589 (autoload 'mail-position-on-field "sendmail")
1590 (autoload 'mail-setup "sendmail")
1591 (autoload 'rmail-output "rmailout")
1592 (autoload 'news-mail-other-window "rnewspost")
1593 (autoload 'news-reply-yank-original "rnewspost")
1594 (autoload 'news-caesar-buffer-body "rnewspost")
1595 (autoload 'rmail-insert-rmail-file-header "rmail")
1596 (autoload 'rmail-count-new-messages "rmail")
1597 (autoload 'rmail-show-message "rmail")
1600 (autoload 'gnus-mail-reply-using-mhe "gnus-mh")
1601 (autoload 'gnus-mail-forward-using-mhe "gnus-mh")
1602 (autoload 'gnus-mail-other-window-using-mhe "gnus-mh")
1603 (autoload 'gnus-summary-save-in-folder "gnus-mh")
1604 (autoload 'gnus-Folder-save-name "gnus-mh")
1605 (autoload 'gnus-folder-save-name "gnus-mh")
1608 (autoload 'gnus-group-make-menu-bar "gnus-vis")
1609 (autoload 'gnus-summary-make-menu-bar "gnus-vis")
1610 (autoload 'gnus-server-make-menu-bar "gnus-vis")
1611 (autoload 'gnus-article-make-menu-bar "gnus-vis")
1612 (autoload 'gnus-browse-make-menu-bar "gnus-vis")
1613 (autoload 'gnus-highlight-selected-summary "gnus-vis")
1614 (autoload 'gnus-summary-highlight-line "gnus-vis")
1615 (autoload 'gnus-carpal-setup-buffer "gnus-vis")
1618 (autoload 'gnus-article-push-button "gnus-vis" nil t)
1619 (autoload 'gnus-article-press-button "gnus-vis" nil t)
1620 (autoload 'gnus-article-highlight "gnus-vis" nil t)
1621 (autoload 'gnus-article-hide "gnus-vis" nil t)
1622 (autoload 'gnus-article-hide-signature "gnus-vis" nil t)
1623 (autoload 'gnus-article-highlight-headers "gnus-vis" nil t)
1624 (autoload 'gnus-article-highlight-signature "gnus-vis" nil t)
1625 (autoload 'gnus-article-add-buttons "gnus-vis" nil t)
1626 (autoload 'gnus-article-next-button "gnus-vis" nil t)
1627 (autoload 'gnus-article-add-button "gnus-vis")
1630 (autoload 'gnus-article-highlight-citation "gnus-cite" nil t)
1631 (autoload 'gnus-article-hide-citation-maybe "gnus-cite" nil t)
1632 (autoload 'gnus-article-hide-citation "gnus-cite" nil t)
1635 (autoload 'gnus-kill "gnus-kill")
1636 (autoload 'gnus-apply-kill-file-internal "gnus-kill")
1637 (autoload 'gnus-kill-file-edit-file "gnus-kill")
1638 (autoload 'gnus-kill-file-raise-followups-to-author "gnus-kill")
1639 (autoload 'gnus-execute "gnus-kill")
1640 (autoload 'gnus-expunge "gnus-kill")
1643 (autoload 'gnus-cache-possibly-enter-article "gnus-cache")
1644 (autoload 'gnus-cache-save-buffers "gnus-cache")
1645 (autoload 'gnus-cache-possibly-remove-article "gnus-cache")
1646 (autoload 'gnus-cache-request-article "gnus-cache")
1647 (autoload 'gnus-cache-retrieve-headers "gnus-cache")
1648 (autoload 'gnus-cache-possibly-alter-active "gnus-cache")
1649 (autoload 'gnus-jog-cache "gnus-cache" nil t)
1652 (autoload 'gnus-summary-increase-map "gnus-score" nil nil 'keymap)
1653 (autoload 'gnus-summary-lower-map "gnus-score" nil nil 'keymap)
1654 (autoload 'gnus-summary-score-map "gnus-score" nil nil 'keymap)
1655 (autoload 'gnus-score-save "gnus-score")
1656 (autoload 'gnus-score-headers "gnus-score")
1657 (autoload 'gnus-current-score-file-nondirectory "gnus-score")
1658 (autoload 'gnus-score-adaptive "gnus-score")
1659 (autoload 'gnus-score-remove-lines-adaptive "gnus-score")
1660 (autoload 'gnus-possibly-score-headers "gnus-score")
1663 (autoload 'gnus-uu-extract-map "gnus-uu" nil nil 'keymap)
1664 (autoload 'gnus-uu-mark-map "gnus-uu" nil nil 'keymap)
1665 (autoload 'gnus-uu-digest-mail-forward "gnus-uu" nil t)
1666 (autoload 'gnus-uu-digest-post-forward "gnus-uu" nil t)
1667 (autoload 'gnus-uu-mark-series "gnus-uu" nil t)
1668 (autoload 'gnus-uu-mark-region "gnus-uu" nil t)
1669 (autoload 'gnus-uu-mark-by-regexp "gnus-uu" nil t)
1670 (autoload 'gnus-uu-mark-all "gnus-uu" nil t)
1671 (autoload 'gnus-uu-mark-sparse "gnus-uu" nil t)
1672 (autoload 'gnus-uu-mark-thread "gnus-uu" nil t)
1673 (autoload 'gnus-uu-decode-uu "gnus-uu" nil t)
1674 (autoload 'gnus-uu-decode-uu-and-save "gnus-uu" nil t)
1675 (autoload 'gnus-uu-decode-unshar "gnus-uu" nil t)
1676 (autoload 'gnus-uu-decode-unshar-and-save "gnus-uu" nil t)
1677 (autoload 'gnus-uu-decode-save "gnus-uu" nil t)
1678 (autoload 'gnus-uu-decode-binhex "gnus-uu" nil t)
1681 (autoload 'gnus-summary-send-map "gnus-msg" nil nil 'keymap)
1682 (autoload 'gnus-group-post-news "gnus-msg" nil t)
1683 (autoload 'gnus-summary-post-news "gnus-msg" nil t)
1684 (autoload 'gnus-summary-followup "gnus-msg" nil t)
1685 (autoload 'gnus-summary-followup-with-original "gnus-msg" nil t)
1686 (autoload 'gnus-summary-followup-and-reply "gnus-msg" nil t)
1687 (autoload 'gnus-summary-followup-and-reply-with-original "gnus-msg" nil t)
1688 (autoload 'gnus-summary-cancel-article "gnus-msg" nil t)
1689 (autoload 'gnus-summary-supersede-article "gnus-msg" nil t)
1690 (autoload 'gnus-post-news "gnus-msg" nil t)
1691 (autoload 'gnus-inews-news "gnus-msg" nil t)
1692 (autoload 'gnus-cancel-news "gnus-msg" nil t)
1693 (autoload 'gnus-summary-reply "gnus-msg" nil t)
1694 (autoload 'gnus-summary-reply-with-original "gnus-msg" nil t)
1695 (autoload 'gnus-summary-mail-forward "gnus-msg" nil t)
1696 (autoload 'gnus-summary-mail-other-window "gnus-msg" nil t)
1697 (autoload 'gnus-mail-reply-using-mail "gnus-msg")
1698 (autoload 'gnus-mail-yank-original "gnus-msg")
1699 (autoload 'gnus-mail-send-and-exit "gnus-msg")
1700 (autoload 'gnus-mail-forward-using-mail "gnus-msg")
1701 (autoload 'gnus-mail-other-window-using-mail "gnus-msg")
1704 (autoload 'gnus-summary-save-in-vm "gnus-vm" nil t)
1705 (autoload 'gnus-mail-forward-using-vm "gnus-vm")
1706 (autoload 'gnus-mail-reply-using-vm "gnus-vm")
1707 (autoload 'gnus-mail-other-window-using-vm "gnus-vm" nil t)
1708 (autoload 'gnus-yank-article "gnus-vm" nil t)
1714 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1715 ;; If you want the cursor to go somewhere else, set these two
1716 ;; functions in some startup hook to whatever you want.
1717 (defalias 'gnus-summary-position-cursor 'gnus-goto-colon)
1718 (defalias 'gnus-group-position-cursor 'gnus-goto-colon)
1720 ;;; Various macros and substs.
1722 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1723 "Pop to BUFFER, evaluate FORMS, and then returns to original window."
1724 (` (let ((GnusStartBufferWindow (selected-window)))
1727 (pop-to-buffer (, buffer))
1729 (select-window GnusStartBufferWindow)))))
1731 (defmacro gnus-gethash (string hashtable)
1732 "Get hash value of STRING in HASHTABLE."
1733 ;;(` (symbol-value (abbrev-symbol (, string) (, hashtable))))
1734 ;;(` (abbrev-expansion (, string) (, hashtable)))
1735 (` (symbol-value (intern-soft (, string) (, hashtable)))))
1737 (defmacro gnus-sethash (string value hashtable)
1738 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1739 ;; We cannot use define-abbrev since it only accepts string as value.
1740 ;; (set (intern string hashtable) value))
1741 (` (set (intern (, string) (, hashtable)) (, value))))
1743 (defsubst gnus-buffer-substring (beg end)
1744 (buffer-substring (match-beginning beg) (match-end end)))
1746 (defsubst gnus-simplify-subject-re (subject)
1747 "Remove \"Re:\" from subject lines."
1748 (let ((case-fold-search t))
1749 (if (string-match "^re: *" subject)
1750 (substring subject (match-end 0))
1753 (defsubst gnus-goto-char (point)
1754 (and point (goto-char point)))
1756 (defmacro gnus-buffer-exists-p (buffer)
1758 (funcall (if (stringp (, buffer)) 'get-buffer 'buffer-name)
1761 (defmacro gnus-kill-buffer (buffer)
1762 (` (if (gnus-buffer-exists-p (, buffer))
1763 (kill-buffer (, buffer)))))
1765 (defsubst gnus-point-at-bol ()
1766 "Return point at the beginning of line."
1773 (defsubst gnus-point-at-eol ()
1774 "Return point at the beginning of line."
1783 ;;; Gnus Utility Functions
1786 (defun gnus-extract-address-components (from)
1788 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
1789 (setq address (substring from (match-beginning 0) (match-end 0))))
1791 (string-match (concat "<" (regexp-quote address) ">") from)
1792 (setq name (substring from 0 (1- (match-beginning 0)))))
1794 (and (string-match "(.+)" from)
1795 (setq name (substring from (1+ (match-beginning 0))
1796 (1- (match-end 0))))))
1797 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1798 (list (or name from) (or address from))))
1800 (defun gnus-fetch-field (field)
1801 "Return the value of the header FIELD of current article."
1804 (let ((case-fold-search t))
1805 (gnus-narrow-to-headers)
1806 (mail-fetch-field field)))))
1808 (defun gnus-goto-colon ()
1810 (search-forward ":" (gnus-point-at-eol) t))
1812 (defun gnus-narrow-to-headers ()
1815 (goto-char (point-min))
1816 (if (search-forward "\n\n")
1817 (narrow-to-region 1 (1- (point))))))
1819 (defun gnus-update-format-specifications ()
1820 (gnus-make-thread-indent-array)
1821 (setq gnus-summary-line-format-spec
1823 gnus-summary-line-format gnus-summary-line-format-alist))
1824 (gnus-update-summary-mark-positions)
1825 (setq gnus-summary-dummy-line-format-spec
1826 (gnus-parse-format gnus-summary-dummy-line-format
1827 gnus-summary-dummy-line-format-alist))
1828 (setq gnus-group-line-format-spec
1830 gnus-group-line-format
1831 gnus-group-line-format-alist))
1832 (if (and (string-match "%D" gnus-group-line-format)
1833 (not gnus-description-hashtb)
1834 gnus-read-active-file)
1835 (gnus-read-descriptions-file))
1836 (setq gnus-summary-mode-line-format-spec
1837 (gnus-parse-format gnus-summary-mode-line-format
1838 gnus-summary-mode-line-format-alist))
1839 (setq gnus-article-mode-line-format-spec
1840 (gnus-parse-format gnus-article-mode-line-format
1841 gnus-summary-mode-line-format-alist))
1842 (setq gnus-group-mode-line-format-spec
1843 (gnus-parse-format gnus-group-mode-line-format
1844 gnus-group-mode-line-format-alist)))
1846 (defun gnus-update-summary-mark-positions ()
1848 (let ((gnus-replied-mark 129)
1849 (gnus-score-below-mark 130)
1850 (gnus-score-over-mark 130)
1853 (gnus-set-work-buffer)
1854 (gnus-summary-insert-line
1855 nil [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
1856 (goto-char (point-min))
1857 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
1859 (goto-char (point-min))
1860 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
1861 (- (point) 2))) pos))
1862 (goto-char (point-min))
1863 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
1864 (- (point) 2))) pos))
1865 (setq gnus-summary-mark-positions pos))))
1867 (defun gnus-format-max-width (form length)
1868 (let* ((val (eval form))
1869 (valstr (if (numberp val) (int-to-string val) val)))
1870 (if (> (length valstr) length)
1871 (substring valstr 0 length)
1874 (defun gnus-set-mouse-face (string)
1875 ;; Set mouse face property on STRING.
1876 (put-text-property 0 (length string) 'mouse-face gnus-mouse-face string)
1879 (defun gnus-parse-format (format spec-alist)
1880 ;; This function parses the FORMAT string with the help of the
1881 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1882 ;; string. If the FORMAT string contains the specifiers %( and %)
1883 ;; the text between them will have the mouse-face text property.
1884 (if (string-match "\\`\\(.*\\)%(\\(.*\\)%)\\(.*\n?\\)\\'" format)
1885 (if (and gnus-visual gnus-mouse-face)
1886 (let ((pre (substring format (match-beginning 1) (match-end 1)))
1887 (button (substring format (match-beginning 2) (match-end 2)))
1888 (post (substring format (match-beginning 3) (match-end 3))))
1890 (gnus-parse-simple-format pre spec-alist)
1891 (list 'gnus-set-mouse-face
1892 (gnus-parse-simple-format button spec-alist))
1893 (gnus-parse-simple-format post spec-alist)))
1894 (gnus-parse-simple-format
1895 (concat (substring format (match-beginning 1) (match-end 1))
1896 (substring format (match-beginning 2) (match-end 2))
1897 (substring format (match-beginning 3) (match-end 3)))
1899 (gnus-parse-simple-format format spec-alist)))
1901 (defun gnus-parse-simple-format (format spec-alist)
1902 ;; This function parses the FORMAT string with the help of the
1903 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
1904 ;; string. The list will consist of the symbol `format', a format
1905 ;; specification string, and a list of forms depending on the
1908 spec flist fstring b newspec max-width elem beg)
1910 (gnus-set-work-buffer)
1912 (goto-char (point-min))
1913 (while (re-search-forward "%[-0-9]*\\(,[0-9]*\\)*\\(.\\)\\(.\\)?" nil t)
1914 (setq spec (string-to-char (buffer-substring (match-beginning 2)
1916 ;; First check if there are any specs that look anything like
1917 ;; "%12,12A", ie. with a "max width specification". These have
1918 ;; to be treated specially.
1919 (if (setq beg (match-beginning 1))
1922 (buffer-substring (1+ (match-beginning 1)) (match-end 1))))
1924 (setq beg (match-beginning 2)))
1925 ;; Find the specification from `spec-alist'.
1926 (if (not (setq elem (cdr (assq spec spec-alist))))
1927 (setq elem '("*" ?s)))
1928 ;; Treat user defined format specifiers specially
1929 (and (eq (car elem) 'user-defined)
1932 (list (intern (concat "gnus-user-format-function-"
1938 (delete-region (match-beginning 3) (match-end 3)))
1939 (if (not (zerop max-width))
1940 (let ((el (car elem)))
1941 (cond ((= (car (cdr elem)) ?c)
1942 (setq el (list 'char-to-string el)))
1943 ((= (car (cdr elem)) ?d)
1944 (numberp el) (setq el (list 'int-to-string el))))
1945 (setq flist (cons (list 'gnus-format-max-width el max-width)
1948 (setq flist (cons (car elem) flist))
1949 (setq newspec (car (cdr elem))))
1950 ;; Remove the old specification (and possibly a ",12" string).
1951 (delete-region beg (match-end 2))
1952 ;; Insert the new specification.
1955 (setq fstring (buffer-substring 1 (point-max))))
1956 (cons 'format (cons fstring (nreverse flist)))))
1958 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
1959 (defun gnus-read-init-file ()
1961 (or (and (file-exists-p gnus-init-file)
1962 ;; Don't try to load a directory.
1963 (not (file-directory-p gnus-init-file)))
1964 (file-exists-p (concat gnus-init-file ".el"))
1965 (file-exists-p (concat gnus-init-file ".elc")))
1966 (load gnus-init-file nil t)))
1968 (defun gnus-set-work-buffer ()
1969 (if (get-buffer gnus-work-buffer)
1971 (set-buffer gnus-work-buffer)
1973 (set-buffer (get-buffer-create gnus-work-buffer))
1974 (buffer-disable-undo (current-buffer))
1975 (gnus-add-current-to-buffer-list)))
1977 ;; Article file names when saving.
1979 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
1980 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1981 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
1982 Otherwise, it is like ~/News/news/group/num."
1985 (concat (if (gnus-use-long-file-name 'not-save)
1986 (gnus-capitalize-newsgroup newsgroup)
1987 (gnus-newsgroup-directory-form newsgroup))
1988 "/" (int-to-string (header-number headers)))
1989 (or gnus-article-save-directory "~/News"))))
1991 (string-equal (file-name-directory default)
1992 (file-name-directory last-file))
1993 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1995 (or last-file default))))
1997 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
1998 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1999 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group/num.
2000 Otherwise, it is like ~/News/news/group/num."
2003 (concat (if (gnus-use-long-file-name 'not-save)
2005 (gnus-newsgroup-directory-form newsgroup))
2006 "/" (int-to-string (header-number headers)))
2007 (or gnus-article-save-directory "~/News"))))
2009 (string-equal (file-name-directory default)
2010 (file-name-directory last-file))
2011 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2013 (or last-file default))))
2015 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2016 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2017 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group.
2018 Otherwise, it is like ~/News/news/group/news."
2021 (if (gnus-use-long-file-name 'not-save)
2022 (gnus-capitalize-newsgroup newsgroup)
2023 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2024 (or gnus-article-save-directory "~/News"))))
2026 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2027 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2028 If variable `gnus-use-long-file-name' is nil, it is ~/News/news.group.
2029 Otherwise, it is like ~/News/news/group/news."
2032 (if (gnus-use-long-file-name 'not-save)
2034 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2035 (or gnus-article-save-directory "~/News"))))
2037 ;; For subscribing new newsgroup
2039 (defun gnus-subscribe-hierarchical-interactive (groups)
2040 (let ((groups (sort groups 'string<))
2041 prefixes prefix start rest ans group starts)
2043 (setq prefixes (list "^"))
2044 (while (and groups prefixes)
2045 (while (not (string-match (car prefixes) (car groups)))
2046 (setq prefixes (cdr prefixes)))
2047 (setq prefix (car prefixes))
2048 (setq start (1- (length prefix)))
2049 (if (and (string-match "[^\\.]\\." (car groups) start)
2052 (concat "^" (substring (car groups) 0 (match-end 0))))
2053 (string-match prefix (car (cdr groups))))
2055 (setq prefixes (cons prefix prefixes))
2056 (message "Descend hierarchy %s? ([y]nsq): "
2057 (substring prefix 1 (1- (length prefix))))
2058 (setq ans (read-char))
2061 (string-match prefix
2062 (setq group (car groups))))
2063 (setq gnus-killed-list
2064 (cons group gnus-killed-list))
2065 (gnus-sethash group group gnus-killed-hashtb)
2066 (setq groups (cdr groups)))
2067 (setq starts (cdr starts)))
2070 (string-match prefix
2071 (setq group (car groups))))
2072 (gnus-sethash group group gnus-killed-hashtb)
2073 (gnus-subscribe-alphabetically (car groups))
2074 (setq groups (cdr groups)))
2075 (setq starts (cdr starts)))
2078 (setq group (car groups))
2079 (setq gnus-killed-list (cons group gnus-killed-list))
2080 (gnus-sethash group group gnus-killed-hashtb)
2081 (setq groups (cdr groups))))
2083 (message "Subscribe %s? ([n]yq)" (car groups))
2084 (setq ans (read-char))
2085 (setq group (car groups))
2087 (gnus-subscribe-alphabetically (car groups))
2088 (gnus-sethash group group gnus-killed-hashtb))
2091 (setq group (car groups))
2092 (setq gnus-killed-list (cons group gnus-killed-list))
2093 (gnus-sethash group group gnus-killed-hashtb)
2094 (setq groups (cdr groups))))
2096 (setq gnus-killed-list (cons group gnus-killed-list))
2097 (gnus-sethash group group gnus-killed-hashtb)))
2098 (setq groups (cdr groups)))))))
2100 (defun gnus-subscribe-randomly (newsgroup)
2101 "Subscribe new NEWSGROUP by making it the first newsgroup."
2102 (gnus-subscribe-newsgroup newsgroup))
2104 (defun gnus-subscribe-alphabetically (newgroup)
2105 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2106 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2107 (let ((groups (cdr gnus-newsrc-alist))
2109 (while (and (not before) groups)
2110 (if (string< newgroup (car (car groups)))
2111 (setq before (car (car groups)))
2112 (setq groups (cdr groups))))
2113 (gnus-subscribe-newsgroup newgroup before)))
2115 (defun gnus-subscribe-hierarchically (newgroup)
2116 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2117 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2119 (set-buffer (find-file-noselect gnus-current-startup-file))
2120 (let ((groupkey newgroup)
2122 (while (and (not before) groupkey)
2123 (goto-char (point-min))
2125 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2126 (while (and (re-search-forward groupkey-re nil t)
2128 (setq before (buffer-substring
2129 (match-beginning 1) (match-end 1)))
2130 (string< before newgroup)))))
2131 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2133 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2134 (substring groupkey (match-beginning 1) (match-end 1)))))
2135 (gnus-subscribe-newsgroup newgroup before))))
2137 (defun gnus-subscribe-interactively (newsgroup)
2138 "Subscribe new NEWSGROUP interactively.
2139 It is inserted in hierarchical newsgroup order if subscribed. If not,
2141 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " newsgroup))
2142 (gnus-subscribe-hierarchically newsgroup)
2143 (setq gnus-killed-list (cons newsgroup gnus-killed-list))))
2145 (defun gnus-subscribe-zombies (newsgroup)
2146 "Make new NEWSGROUP a zombie group."
2147 (setq gnus-zombie-list (cons newsgroup gnus-zombie-list)))
2149 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2150 "Subscribe new NEWSGROUP.
2151 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2152 the first newsgroup."
2153 ;; We subscribe the group by changing its level to `subscribed'.
2154 (gnus-group-change-level
2155 newsgroup gnus-level-default-subscribed
2156 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2157 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2161 (defun gnus-newsgroup-directory-form (newsgroup)
2162 "Make hierarchical directory name from NEWSGROUP name."
2163 (let ((newsgroup (substring newsgroup 0)) ;Copy string.
2164 (len (length newsgroup))
2166 ;; Replace all occurrences of `.' with `/'.
2168 (if (= (aref newsgroup idx) ?.)
2169 (aset newsgroup idx ?/))
2170 (setq idx (1+ idx)))
2174 (defun gnus-make-directory (dir)
2175 "Make DIRECTORY recursively."
2176 (let* ((dir (expand-file-name dir default-directory))
2178 (if (string-match "/$" dir)
2179 (setq dir (substring dir 0 (match-beginning 0))))
2180 (while (not (file-exists-p dir))
2181 (setq dirs (cons dir dirs))
2182 (string-match "/[^/]+$" dir)
2183 (setq dir (substring dir 0 (match-beginning 0))))
2185 (make-directory (car dirs))
2186 (setq dirs (cdr dirs)))))
2188 (defun gnus-capitalize-newsgroup (newsgroup)
2189 "Capitalize NEWSGROUP name."
2190 (and (not (zerop (length newsgroup)))
2191 (concat (char-to-string (upcase (aref newsgroup 0)))
2192 (substring newsgroup 1))))
2196 (defun gnus-simplify-subject (subject &optional re-only)
2197 "Remove `Re:' and words in parentheses.
2198 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2199 (let ((case-fold-search t)) ;Ignore case.
2200 ;; Remove `Re:' and `Re^N:'.
2201 (if (string-match "^re:[ \t]*" subject)
2202 (setq subject (substring subject (match-end 0))))
2203 ;; Remove words in parentheses from end.
2205 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2206 (setq subject (substring subject 0 (match-beginning 0)))))
2207 ;; Return subject string.
2210 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2212 (defun gnus-simplify-subject-fuzzy (subject)
2213 (let ((case-fold-search t))
2215 (gnus-set-work-buffer)
2217 (gnus-simplify-buffer-fuzzy)
2220 (defun gnus-simplify-buffer-fuzzy ()
2221 (goto-char (point-min))
2222 (while (re-search-forward "^[ \t]*re:[ \t]*" nil t)
2223 (replace-match "" t t))
2224 (goto-char (point-min))
2225 (while (re-search-forward "[ \t\n]*([^()]*)[ \t\n]*$" nil t)
2226 (replace-match "" t t))
2227 (goto-char (point-min))
2228 (while (re-search-forward "[ \t]+" nil t)
2229 (replace-match " " t t))
2230 (goto-char (point-min))
2231 (while (re-search-forward "[ \t]+$" nil t)
2232 (replace-match "" t t))
2233 (goto-char (point-min))
2234 (while (re-search-forward "^[ \t]+" nil t)
2235 (replace-match "" t t)))
2237 ;; Add the current buffer to the list of buffers to be killed on exit.
2238 (defun gnus-add-current-to-buffer-list ()
2239 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list)))
2241 (defun gnus-string> (s1 s2)
2242 (not (or (string< s1 s2)
2245 ;; Functions accessing headers.
2246 ;; Functions are more convenient than macros in some cases.
2248 (defun gnus-header-number (header)
2249 (header-number header))
2251 (defun gnus-header-subject (header)
2252 (header-subject header))
2254 (defun gnus-header-from (header)
2255 (header-from header))
2257 (defun gnus-header-xref (header)
2258 (header-xref header))
2260 (defun gnus-header-lines (header)
2261 (header-lines header))
2263 (defun gnus-header-date (header)
2264 (header-date header))
2266 (defun gnus-header-id (header)
2269 (defun gnus-header-references (header)
2270 (header-references header))
2272 ;;; General various misc type functions.
2274 (defun gnus-clear-system ()
2275 "Clear all variables and buffers."
2276 ;; Clear Gnus variables.
2277 (let ((variables gnus-variable-list))
2279 (set (car variables) nil)
2280 (setq variables (cdr variables))))
2281 ;; Clear other internal variables.
2282 (setq gnus-list-of-killed-groups nil
2283 gnus-have-read-active-file nil
2284 gnus-newsrc-alist nil
2285 gnus-newsrc-hashtb nil
2286 gnus-killed-list nil
2287 gnus-zombie-list nil
2288 gnus-killed-hashtb nil
2289 gnus-active-hashtb nil
2290 gnus-moderated-list nil
2291 gnus-description-hashtb nil
2292 gnus-newsgroup-headers nil
2293 gnus-newsgroup-headers-hashtb-by-number nil
2294 gnus-newsgroup-name nil
2295 gnus-server-alist nil
2296 gnus-current-select-method nil)
2297 ;; Reset any score variables.
2298 (and (boundp 'gnus-score-cache)
2299 (set 'gnus-score-cache nil))
2300 (and (boundp 'gnus-internal-global-score-files)
2301 (set 'gnus-internal-global-score-files nil))
2302 ;; Kill the startup file.
2303 (and gnus-current-startup-file
2304 (get-file-buffer gnus-current-startup-file)
2305 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2306 ;; Save any cache buffers.
2307 (and gnus-use-cache (gnus-cache-save-buffers))
2308 ;; Clear the dribble buffer.
2309 (gnus-dribble-clear)
2310 ;; Kill global KILL file buffer.
2311 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
2312 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
2313 (gnus-kill-buffer nntp-server-buffer)
2314 ;; Kill Gnus buffers.
2315 (while gnus-buffer-list
2316 (gnus-kill-buffer (car gnus-buffer-list))
2317 (setq gnus-buffer-list (cdr gnus-buffer-list))))
2319 (defun gnus-windows-old-to-new (setting)
2320 (if (symbolp setting)
2322 (cond ((eq setting 'SelectArticle)
2324 ((eq setting 'SelectSubject)
2326 ((eq setting 'SelectNewsgroup)
2329 (if (or (listp setting)
2330 (not (and gnus-window-configuration
2331 (memq setting '(group summary article)))))
2333 (let* ((setting (if (eq setting 'group)
2334 (if (assq 'newsgroup gnus-window-configuration)
2336 'newsgroups) setting))
2337 (elem (car (cdr (assq setting gnus-window-configuration))))
2338 (total (apply '+ elem))
2339 (types '(group summary article))
2340 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
2345 (or (zerop (nth i elem))
2347 (setq perc (/ (* 1.0 (nth 0 elem)) total))
2348 (setq out (cons (if (eq pbuf (nth i types))
2349 (vector (nth i types) perc 'point)
2350 (vector (nth i types) perc))
2353 (list (nreverse out)))))
2355 (defun gnus-configure-windows (setting)
2356 (setq setting (gnus-windows-old-to-new setting))
2357 (let ((r (if (symbolp setting)
2358 (cdr (assq setting gnus-buffer-configuration))
2360 (in-buf (current-buffer))
2361 rule val window w height hor ohor heights sub jump-buffer
2363 (or r (error "No such setting: %s" setting))
2365 ;; Either remove all windows or just remove all Gnus windows.
2366 (if gnus-use-full-window
2367 (delete-other-windows)
2368 (gnus-remove-some-windows)
2369 (switch-to-buffer nntp-server-buffer))
2375 ;; We have to do the (possible) horizontal splitting before the
2377 (if (and (listp (car hor))
2378 (eq (car (car hor)) 'horizontal))
2380 (split-window nil (floor (* (frame-width) (nth 1 (car hor)))) t)
2381 (setq hor (cdr hor))))
2383 ;; Go through the rules and eval the elements that are to be
2386 (if (setq val (if (vectorp (car hor)) (car hor) (eval (car hor))))
2388 ;; Expand short buffer name.
2389 (setq w (aref val 0))
2390 (and (setq w (cdr (assq w gnus-window-to-buffer)))
2392 (setq val (apply 'vector (mapcar (lambda (v) v) val)))
2394 (setq ohor (cons val ohor))))
2395 (setq hor (cdr hor)))
2396 (setq rule (cons (nreverse ohor) rule))
2398 (setq rule (nreverse rule))
2400 ;; We tally the window sizes.
2401 (setq total (window-height))
2403 (setq hor (car rule))
2404 (if (and (listp (car hor)) (eq (car (car hor)) 'horizontal))
2405 (setq hor (cdr hor)))
2408 (setq rel (aref (car hor) 1)
2410 (cond ((and (floatp rel) (= 1.0 rel))
2415 (max (floor (* total rel)) 4)))
2417 sub (+ sub (if (numberp (car heights)) (car heights) 0))
2419 (setq heights (nreverse heights)
2422 ;; We then go through these heighs and create windows for them.
2424 (setq height (car heights)
2425 heights (cdr heights))
2427 (setq height (- total sub)))
2429 (split-window nil height))
2430 (setq to-buf (aref (car hor) 0))
2435 (symbol-value (aref (car hor) 0)))
2437 (aref (car hor) 0))))
2438 (and (> (length (car hor)) 2)
2439 (eq (aref (car hor) 2) 'point)
2440 (setq jump-buffer (current-buffer)))
2442 (setq hor (cdr hor)))
2444 (setq rule (cdr rule)))
2446 ;; Finally, we pop to the buffer that's supposed to have point.
2447 (pop-to-buffer jump-buffer)
2450 (defun gnus-remove-some-windows ()
2451 (let ((buffers gnus-window-to-buffer)
2455 (setq buf (cdr (car buffers)))
2456 (and (symbolp buf) (setq buf (symbol-value buf)))
2457 (and buf (get-buffer-window buf)
2462 (switch-to-buffer nntp-server-buffer)
2464 (delete-window (get-buffer-window buf)))))
2465 (setq buffers (cdr buffers)))
2466 (set-buffer nntp-server-buffer)))
2468 (defun gnus-version ()
2469 "Version numbers of this version of Gnus."
2471 (let ((methods gnus-valid-select-methods)
2474 ;; Go through all the legal select methods and add their version
2475 ;; numbers to the total version string. Only the backends that are
2476 ;; currently in use will have their message numbers taken into
2479 (setq meth (intern (concat (car (car methods)) "-version")))
2481 (stringp (symbol-value meth))
2482 (setq mess (concat mess "; " (symbol-value meth))))
2483 (setq methods (cdr methods)))
2484 (gnus-message 2 mess)))
2486 (defun gnus-info-find-node ()
2487 "Find Info documentation of Gnus."
2489 ;; Enlarge info window if needed.
2490 (let ((mode major-mode))
2491 (gnus-configure-windows 'info)
2492 (Info-goto-node (car (cdr (assq mode gnus-info-nodes))))))
2495 "Send a bug report to the Gnus maintainers."
2497 (let ((winconf (current-window-configuration)))
2498 (pop-to-buffer "*Gnus Bug*")
2501 (mail-setup gnus-maintainer "[Gnus Bug Report] " nil nil nil nil)
2502 (make-local-variable 'gnus-prev-winconf)
2503 (setq gnus-prev-winconf winconf)
2504 (goto-char (point-min))
2505 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "$"))
2507 (insert (format "%s\n%s\n\n\n\n\n" (gnus-version) (emacs-version)))
2510 (goto-char (- b 3)))
2513 (defun gnus-debug ()
2514 "Attemps to go through the Gnus source file and report what variables have been changed.
2515 The source file has to be in the Emacs load path."
2517 (let ((dirs load-path)
2520 (if (file-exists-p (setq file (concat (car dirs) "/gnus.el")))
2523 (set-buffer (get-buffer-create "*gnus bug info*"))
2524 (buffer-disable-undo (current-buffer))
2526 (insert-file-contents file)
2527 (goto-char (point-min))
2528 (or (search-forward "\n;; Internal variables" nil t)
2529 (error "Malformed sources"))
2530 (narrow-to-region (point-min) (point))
2531 (goto-char (point-min))
2532 (while (setq expr (condition-case ()
2533 (read (current-buffer)) (error nil)))
2534 (and (eq (car expr) 'defvar)
2535 (stringp (nth 3 expr))
2536 (not (equal (eval (nth 2 expr))
2537 (and (boundp (nth 1 expr))
2538 (symbol-value (nth 1 expr)))))
2539 (setq olist (cons (nth 1 expr) olist))))
2540 (kill-buffer (current-buffer)))
2541 (setq dirs (cdr dirs))))
2543 (if (boundp (car olist))
2544 (insert "(setq " (symbol-name (car olist)) " '"
2545 (prin1-to-string (symbol-value (car olist))) ")\n")
2546 (insert ";; (makeunbound '" (symbol-name (car olist)) ")\n"))
2547 (setq olist (cdr olist)))
2550 (defun gnus-overload-functions (&optional overloads)
2551 "Overload functions specified by optional argument OVERLOADS.
2552 If nothing is specified, use the variable gnus-overload-functions."
2554 (overloads (or overloads gnus-overload-functions)))
2556 (setq defs (car overloads))
2557 (setq overloads (cdr overloads))
2558 ;; Load file before overloading function if necessary. Make
2559 ;; sure we cannot use `require' always.
2560 (and (not (fboundp (car defs)))
2561 (car (cdr (cdr defs)))
2562 (load (car (cdr (cdr defs))) nil 'nomessage))
2563 (fset (car defs) (car (cdr defs))))))
2565 (defun gnus-replace-chars-in-string (string from to)
2566 "Replace characters in STRING from FROM to TO."
2567 (let ((string (substring string 0)) ;Copy string.
2568 (len (length string))
2570 ;; Replace all occurrences of FROM with TO.
2572 (if (= (aref string idx) from)
2573 (aset string idx to))
2574 (setq idx (1+ idx)))
2577 (defun gnus-days-between (date1 date2)
2578 ;; Return the number of days between date1 and date2.
2579 (- (gnus-day-number date1) (gnus-day-number date2)))
2581 (defun gnus-day-number (date)
2582 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
2583 (timezone-parse-date date))))
2584 (timezone-absolute-from-gregorian
2585 (nth 1 dat) (nth 2 dat) (car dat))))
2587 ;; Returns a floating point number that says how many seconds have
2588 ;; lapsed between Jan 1 12:00:00 1970 and DATE.
2589 (defun gnus-seconds-since-epoch (date)
2590 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2591 (timezone-parse-date date)))
2592 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
2593 (timezone-parse-time
2594 (aref (timezone-parse-date date) 3))))
2595 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
2596 (timezone-parse-date "Jan 1 12:00:00 1970")))
2597 (tday (- (timezone-absolute-from-gregorian
2598 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
2599 (timezone-absolute-from-gregorian
2600 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
2602 (* (nth 1 ttime) 60)
2603 (* 1.0 (nth 0 ttime) 60 60)
2604 (* 1.0 tday 60 60 24))))
2606 (defun gnus-file-newer-than (file date)
2607 (let ((fdate (nth 5 (file-attributes file))))
2608 (or (> (car fdate) (car date))
2609 (and (= (car fdate) (car date))
2610 (> (nth 1 fdate) (nth 1 date))))))
2612 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
2614 (defun gnus-y-or-n-p (prompt)
2619 (defun gnus-yes-or-no-p (prompt)
2621 (yes-or-no-p prompt)
2624 ;; Check whether to use long file names.
2625 (defun gnus-use-long-file-name (symbol)
2626 ;; The variable has to be set...
2627 (and gnus-use-long-file-name
2628 ;; If it isn't a list, then we return t.
2629 (or (not (listp gnus-use-long-file-name))
2630 ;; If it is a list, and the list contains `symbol', we
2632 (not (memq symbol gnus-use-long-file-name)))))
2634 ;; I suspect there's a better way, but I haven't taken the time to do
2635 ;; it yet. -erik selberg@cs.washington.edu
2636 (defun gnus-dd-mmm (messy-date)
2637 "Return a string like DD-MMM from a big messy string"
2638 (let ((datevec (timezone-parse-date messy-date)))
2640 (or (aref datevec 2) "??")
2643 (nth (1- (string-to-number (aref datevec 1)))
2644 timezone-months-assoc))
2647 ;; Make a hash table (default and minimum size is 255).
2648 ;; Optional argument HASHSIZE specifies the table size.
2649 (defun gnus-make-hashtable (&optional hashsize)
2650 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
2652 ;; Make a number that is suitable for hashing; bigger than MIN and one
2654 (defun gnus-create-hash-size (min)
2660 ;; Delete the current line (and the next N lines.);
2661 (defun gnus-delete-line (&optional n)
2663 (delete-region (progn (beginning-of-line) (point))
2664 (progn (forward-line n) (point)))))
2666 ;; Show message if message has a lower level than `gnus-verbose'.
2667 ;; Guide-line for numbers:
2668 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
2669 ;; for things that take a long time, 7 - not very important messages
2670 ;; on stuff, 9 - messages inside loops.
2671 (defun gnus-message (level &rest args)
2672 (if (<= level gnus-verbose)
2673 (apply 'message args)
2674 ;; We have to do this format thingie here even if the result isn't
2675 ;; shown - the return value has to be the same as the return value
2677 (apply 'format args)))
2679 ;;; List and range functions
2681 (defun gnus-last-element (list)
2682 "Return last element of LIST."
2684 (setq list (cdr list)))
2687 (defun gnus-copy-sequence (list)
2688 "Do a complete, total copy of a list."
2689 (if (and (consp list) (not (consp (cdr list))))
2690 (cons (car list) (cdr list))
2691 (mapcar (lambda (elem) (if (consp elem)
2692 (if (consp (cdr elem))
2693 (gnus-copy-sequence elem)
2694 (cons (car elem) (cdr elem)))
2698 (defun gnus-set-difference (list1 list2)
2699 "Return a list of elements of LIST1 that do not appear in LIST2."
2700 (let ((list1 (copy-sequence list1)))
2702 (setq list1 (delq (car list2) list1))
2703 (setq list2 (cdr list2)))
2706 (defun gnus-sorted-complement (list1 list2)
2707 "Return a list of elements of LIST1 that do not appear in LIST2.
2708 Both lists have to be sorted over <."
2710 (if (or (null list1) (null list2))
2712 (while (and list1 list2)
2713 (cond ((= (car list1) (car list2))
2714 (setq list1 (cdr list1)
2716 ((< (car list1) (car list2))
2717 (setq out (cons (car list1) out))
2718 (setq list1 (cdr list1)))
2720 (setq out (cons (car list2) out))
2721 (setq list2 (cdr list2)))))
2722 (nconc (nreverse out) (or list1 list2)))))
2724 (defun gnus-intersection (list1 list2)
2727 (if (memq (car list2) list1)
2728 (setq result (cons (car list2) result)))
2729 (setq list2 (cdr list2)))
2732 (defun gnus-sorted-intersection (list1 list2)
2733 ;; LIST1 and LIST2 have to be sorted over <.
2735 (while (and list1 list2)
2736 (cond ((= (car list1) (car list2))
2737 (setq out (cons (car list1) out)
2740 ((< (car list1) (car list2))
2741 (setq list1 (cdr list1)))
2743 (setq list2 (cdr list2)))))
2746 (defun gnus-set-sorted-intersection (list1 list2)
2747 ;; LIST1 and LIST2 have to be sorted over <.
2748 ;; This function modifies LIST1.
2749 (let* ((top (cons nil list1))
2751 (while (and list1 list2)
2752 (cond ((= (car list1) (car list2))
2756 ((< (car list1) (car list2))
2757 (setcdr prev (cdr list1))
2758 (setq list1 (cdr list1)))
2760 (setq list2 (cdr list2)))))
2764 (defun gnus-compress-sequence (numbers &optional always-list)
2765 "Convert list of numbers to a list of ranges or a single range.
2766 If ALWAYS-LIST is non-nil, this function will always release a list of
2768 (let* ((first (car numbers))
2769 (last (car numbers))
2773 (if (not (listp (cdr numbers)))
2776 (cond ((= last (car numbers)) nil) ;Omit duplicated number
2777 ((= (1+ last) (car numbers)) ;Still in sequence
2778 (setq last (car numbers)))
2779 (t ;End of one sequence
2781 (cons (if (= first last) first
2782 (cons first last)) result))
2783 (setq first (car numbers))
2784 (setq last (car numbers))))
2785 (setq numbers (cdr numbers)))
2786 (if (and (not always-list) (null result))
2787 (if (= first last) (list first) (cons first last))
2788 (nreverse (cons (if (= first last) first (cons first last))
2791 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
2792 (defun gnus-uncompress-range (ranges)
2793 "Expand a list of ranges into a list of numbers.
2794 RANGES is either a single range on the form `(num . num)' or a list of
2796 (let (first last result)
2800 ((not (listp (cdr ranges)))
2801 (setq first (car ranges))
2802 (setq last (cdr ranges))
2803 (while (<= first last)
2804 (setq result (cons first result))
2805 (setq first (1+ first)))
2809 (if (atom (car ranges))
2810 (if (numberp (car ranges))
2811 (setq result (cons (car ranges) result)))
2812 (setq first (car (car ranges)))
2813 (setq last (cdr (car ranges)))
2814 (while (<= first last)
2815 (setq result (cons first result))
2816 (setq first (1+ first))))
2817 (setq ranges (cdr ranges)))
2818 (nreverse result)))))
2820 (defun gnus-add-to-range (ranges list)
2821 "Return a list of ranges that has all articles from both RANGES and LIST.
2822 Note: LIST has to be sorted over `<'."
2824 (gnus-compress-sequence list t)
2825 (setq list (copy-sequence list))
2826 (or (listp (cdr ranges))
2827 (setq ranges (list ranges)))
2829 ilist lowest highest temp)
2830 (while (and ranges list)
2832 (setq lowest (or (and (atom (car ranges)) (car ranges))
2833 (car (car ranges))))
2834 (while (and list (cdr list) (< (car (cdr list)) lowest))
2835 (setq list (cdr list)))
2836 (if (< (car ilist) lowest)
2839 (setq list (cdr list))
2841 (setq out (nconc (gnus-compress-sequence ilist t) out))))
2842 (setq highest (or (and (atom (car ranges)) (car ranges))
2843 (cdr (car ranges))))
2844 (while (and list (<= (car list) highest))
2845 (setq list (cdr list)))
2846 (setq ranges (cdr ranges)))
2848 (setq out (nconc (gnus-compress-sequence list t) out)))
2849 (setq out (sort out (lambda (r1 r2)
2850 (< (or (and (atom r1) r1) (car r1))
2851 (or (and (atom r2) r2) (car r2))))))
2854 (if (atom (car ranges))
2856 (if (atom (car (cdr ranges)))
2857 (if (= (1+ (car ranges)) (car (cdr ranges)))
2859 (setcar ranges (cons (car ranges)
2860 (car (cdr ranges))))
2861 (setcdr ranges (cdr (cdr ranges)))))
2862 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
2864 (setcar (car (cdr ranges)) (car ranges))
2865 (setcar ranges (car (cdr ranges)))
2866 (setcdr ranges (cdr (cdr ranges)))))))
2868 (if (atom (car (cdr ranges)))
2869 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
2871 (setcdr (car ranges) (car (cdr ranges)))
2872 (setcdr ranges (cdr (cdr ranges)))))
2873 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
2875 (setcdr (car ranges) (cdr (car (cdr ranges))))
2876 (setcdr ranges (cdr (cdr ranges))))))))
2877 (setq ranges (cdr ranges)))
2880 (defun gnus-remove-from-range (ranges list)
2881 "Return a list of ranges that has all articles from LIST removed from RANGES.
2882 Note: LIST has to be sorted over `<'."
2883 ;; !!! This function shouldn't look like this, but I've got a headache.
2884 (gnus-compress-sequence
2885 (gnus-sorted-complement
2886 (gnus-uncompress-range ranges) list)))
2888 (defun gnus-member-of-range (number ranges)
2889 (if (not (listp (cdr ranges)))
2890 (and (>= number (car ranges))
2891 (<= number (cdr ranges)))
2894 (if (numberp (car ranges))
2895 (>= number (car ranges))
2896 (>= number (car (car ranges))))
2898 (if (if (numberp (car ranges))
2899 (= number (car ranges))
2900 (and (>= number (car (car ranges)))
2901 (<= number (cdr (car ranges)))))
2902 (setq not-stop nil))
2903 (setq ranges (cdr ranges)))
2911 (defvar gnus-group-mode-map nil)
2912 (defvar gnus-group-group-map nil)
2913 (defvar gnus-group-mark-map nil)
2914 (defvar gnus-group-list-map nil)
2915 (defvar gnus-group-sub-map nil)
2916 (put 'gnus-group-mode 'mode-class 'special)
2918 (if gnus-group-mode-map
2920 (setq gnus-group-mode-map (make-keymap))
2921 (suppress-keymap gnus-group-mode-map)
2922 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
2923 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
2924 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
2925 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
2926 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
2927 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
2928 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
2929 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
2930 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
2931 (define-key gnus-group-mode-map "\M-n" 'gnus-group-next-unread-group-same-level)
2932 (define-key gnus-group-mode-map "\M-p" 'gnus-group-prev-unread-group-same-level)
2933 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
2934 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
2935 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
2936 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
2937 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
2938 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
2939 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
2940 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
2941 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
2942 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
2943 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
2944 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
2945 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
2946 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
2947 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
2948 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
2949 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
2950 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
2951 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
2952 (define-key gnus-group-mode-map "\C-c\M-C-a" 'gnus-group-description-apropos)
2953 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
2954 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
2955 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
2956 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
2957 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
2958 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
2959 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
2960 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
2961 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
2962 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
2963 (define-key gnus-group-mode-map "V" 'gnus-version)
2964 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
2965 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
2966 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
2967 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
2968 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
2969 (define-key gnus-group-mode-map "\M-f" 'gnus-group-fetch-faq)
2970 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
2971 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
2972 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group-method)
2973 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
2974 (define-key gnus-group-mode-map gnus-mouse-2 'gnus-mouse-pick-group)
2975 (define-key gnus-group-mode-map "<" 'beginning-of-buffer)
2976 (define-key gnus-group-mode-map ">" 'end-of-buffer)
2977 (define-key gnus-group-mode-map "\C-c\C-b" 'gnus-bug)
2979 (define-key gnus-group-mode-map "#" 'gnus-group-mark-group)
2980 (define-key gnus-group-mode-map "\M-#" 'gnus-group-unmark-group)
2981 (define-prefix-command 'gnus-group-mark-map)
2982 (define-key gnus-group-mode-map "M" 'gnus-group-mark-map)
2983 (define-key gnus-group-mark-map "m" 'gnus-group-mark-group)
2984 (define-key gnus-group-mark-map "u" 'gnus-group-unmark-group)
2985 (define-key gnus-group-mark-map "w" 'gnus-group-mark-region)
2987 (define-prefix-command 'gnus-group-group-map)
2988 (define-key gnus-group-mode-map "G" 'gnus-group-group-map)
2989 (define-key gnus-group-group-map "d" 'gnus-group-make-directory-group)
2990 (define-key gnus-group-group-map "h" 'gnus-group-make-help-group)
2991 (define-key gnus-group-group-map "a" 'gnus-group-make-archive-group)
2992 (define-key gnus-group-group-map "k" 'gnus-group-make-kiboze-group)
2993 (define-key gnus-group-group-map "m" 'gnus-group-make-group)
2994 (define-key gnus-group-group-map "E" 'gnus-group-edit-group)
2995 (define-key gnus-group-group-map "e" 'gnus-group-edit-group-method)
2996 (define-key gnus-group-group-map "p" 'gnus-group-edit-group-parameters)
2997 (define-key gnus-group-group-map "v" 'gnus-group-add-to-virtual)
2999 (define-prefix-command 'gnus-group-list-map)
3000 (define-key gnus-group-mode-map "A" 'gnus-group-list-map)
3001 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
3002 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
3003 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
3004 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
3005 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
3006 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
3007 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
3008 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
3010 (define-prefix-command 'gnus-group-sub-map)
3011 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
3012 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
3013 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
3014 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
3015 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
3016 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
3017 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
3018 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
3020 (defun gnus-group-mode ()
3021 "Major mode for reading news.
3023 All normal editing commands are switched off.
3024 \\<gnus-group-mode-map>
3025 The group buffer lists (some of) the groups available. For instance,
3026 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
3027 lists all zombie groups.
3029 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
3030 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
3032 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
3034 The following commands are available:
3036 \\{gnus-group-mode-map}"
3038 (if gnus-visual (gnus-group-make-menu-bar))
3039 (kill-all-local-variables)
3040 (setq mode-line-modified "-- ")
3041 (make-local-variable 'mode-line-format)
3042 (setq mode-line-format (copy-sequence mode-line-format))
3043 (and (equal (nth 3 mode-line-format) " ")
3044 (setcar (nthcdr 3 mode-line-format) ""))
3045 (setq major-mode 'gnus-group-mode)
3046 (setq mode-name "Group")
3047 (gnus-group-set-mode-line)
3048 (setq mode-line-process nil)
3049 (use-local-map gnus-group-mode-map)
3050 (buffer-disable-undo (current-buffer))
3051 (setq truncate-lines t)
3052 (setq buffer-read-only t)
3053 (run-hooks 'gnus-group-mode-hook))
3055 (defun gnus-mouse-pick-group (e)
3058 (gnus-group-read-group nil))
3061 (defun gnus-no-server (&optional arg)
3063 If ARG is a positive number, Gnus will use that as the
3064 startup level. If ARG is nil, Gnus will be started at level 2.
3065 If ARG is non-nil and not a positive number, Gnus will
3066 prompt the user for the name of an NNTP server to use.
3067 As opposed to `gnus', this command will not connect to the local server."
3069 (gnus (or arg (1- gnus-level-default-subscribed)) t))
3071 (defalias '\(ding\) 'gnus)
3074 (defun gnus (&optional arg dont-connect)
3076 If ARG is non-nil and a positive number, Gnus will use that as the
3077 startup level. If ARG is non-nil and not a positive number, Gnus will
3078 prompt the user for the name of an NNTP server to use."
3080 (if (get-buffer gnus-group-buffer)
3082 (switch-to-buffer gnus-group-buffer)
3083 (gnus-group-get-new-news))
3085 (gnus-read-init-file)
3086 (let ((level (and arg (numberp arg) (> arg 0) arg))
3090 (gnus-group-setup-buffer)
3093 (gnus-start-news-server (and arg (not level))))))
3094 (if (and (not dont-connect)
3097 (run-hooks 'gnus-startup-hook)
3098 ;; NNTP server is successfully open.
3099 (gnus-update-format-specifications)
3100 (let ((buffer-read-only nil))
3102 (if (not gnus-inhibit-startup-message)
3104 (gnus-group-startup-message)
3106 (gnus-setup-news nil level)
3107 (and gnus-use-dribble-file (gnus-dribble-open))
3108 (gnus-group-list-groups level)
3109 (gnus-configure-windows 'group))))))
3111 (defun gnus-group-startup-message (&optional x y)
3112 "Insert startup message in current buffer."
3113 ;; Insert the message.
3130 ;; And then hack it.
3131 ;; 18 is the longest line.
3132 (indent-rigidly (point-min) (point-max)
3133 (/ (max (- (window-width) (or x 28)) 0) 2))
3134 (goto-char (point-min))
3135 ;; +4 is fuzzy factor.
3136 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2)))
3138 (defun gnus-group-setup-buffer ()
3139 (or (get-buffer gnus-group-buffer)
3141 (switch-to-buffer gnus-group-buffer)
3142 (gnus-add-current-to-buffer-list)
3144 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
3146 (defun gnus-group-list-groups (level &optional unread)
3147 "List newsgroups with level LEVEL or lower that have unread alticles.
3148 Default is all subscribed groups.
3149 If argument UNREAD is non-nil, groups with no unread articles are also listed."
3150 (interactive (list (and current-prefix-arg
3151 (prefix-numeric-value current-prefix-arg))))
3152 (setq level (or level gnus-group-default-list-level gnus-level-subscribed))
3153 (gnus-group-setup-buffer) ;May call from out of group buffer
3154 (let ((case-fold-search nil)
3155 (group (gnus-group-group-name)))
3156 (funcall gnus-group-prepare-function level unread nil)
3157 (if (zerop (buffer-size))
3158 (gnus-message 5 gnus-no-groups-message)
3159 (goto-char (point-min))
3161 ;; Go to the first group with unread articles.
3162 (gnus-group-search-forward nil nil nil t)
3163 ;; Find the right group to put point on. If the current group
3164 ;; has disapeared in the new listing, try to find the next
3165 ;; one. If no next one can be found, just leave point at the
3166 ;; first newsgroup in the buffer.
3167 (if (not (gnus-goto-char
3168 (text-property-any (point-min) (point-max)
3169 'gnus-group (intern group))))
3170 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
3172 (not (gnus-goto-char
3174 (point-min) (point-max) 'gnus-group
3175 (intern (car (car newsrc)))))))
3176 (setq newsrc (cdr newsrc)))
3177 (or newsrc (progn (goto-char (point-max))
3178 (forward-line -1))))))
3179 ;; Adjust cursor point.
3180 (gnus-group-position-cursor))))
3182 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
3183 "List all newsgroups with unread articles of level LEVEL or lower.
3184 If ALL is non-nil, list groups that have no unread articles.
3185 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
3186 If REGEXP, only list groups matching REGEXP."
3187 (set-buffer gnus-group-buffer)
3188 (let ((buffer-read-only nil)
3189 (newsrc (cdr gnus-newsrc-alist))
3190 (lowest (or lowest 1))
3191 info clevel unread group)
3193 (if (< lowest gnus-level-zombie)
3194 ;; List living groups.
3196 (setq info (car newsrc)
3199 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
3200 (and unread ; This group might be bogus
3202 (string-match regexp group))
3203 (<= (setq clevel (car (cdr info))) level)
3205 (or all ; We list all groups?
3206 (eq unread t) ; We list unactivated groups
3207 (> unread 0) ; We list groups with unread articles
3208 (cdr (assq 'tick (nth 3 info)))) ; And groups with tickeds
3209 (gnus-group-insert-group-line
3210 nil group (car (cdr info)) (nth 3 info) unread (nth 4 info)))))
3212 ;; List dead groups.
3213 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
3214 (gnus-group-prepare-flat-list-dead
3215 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
3216 gnus-level-zombie ?Z
3218 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
3219 (gnus-group-prepare-flat-list-dead
3220 (setq gnus-killed-list (sort gnus-killed-list 'string<))
3221 gnus-level-killed ?K regexp))
3223 (gnus-group-set-mode-line)
3224 (setq gnus-have-all-newsgroups all)
3225 (run-hooks 'gnus-group-prepare-hook)))
3227 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
3228 ;; List zombies and killed lists somehwat faster, which was
3229 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
3230 ;; this by ignoring the group format specification altogether.
3233 (setq group (car groups)
3234 groups (cdr groups))
3235 (if (or (not regexp)
3236 (string-match regexp group))
3239 (insert (format " %c *: %s\n" mark group))
3240 (add-text-properties
3242 (list 'gnus-group (intern group)
3244 'gnus-level level)))))))
3246 (defun gnus-group-real-name (group)
3247 "Find the real name of a foreign newsgroup."
3248 (if (string-match "^[^:]+:" group)
3249 (substring group (match-end 0))
3252 (defun gnus-group-prefixed-name (group method)
3253 "Return the whole name from GROUP and METHOD."
3254 (and (stringp method) (setq method (gnus-server-to-method method)))
3255 (concat (format "%s" (car method))
3257 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
3258 (not (string= (nth 1 method) "")))
3259 (concat "+" (nth 1 method)))
3262 (defun gnus-group-real-prefix (group)
3263 "Return the prefix of the current group name."
3264 (if (string-match "^[^:]+:" group)
3265 (substring group 0 (match-end 0))
3268 (defun gnus-group-method-name (group)
3269 "Return the method used for selecting GROUP."
3270 (let ((prefix (gnus-group-real-prefix group)))
3271 (if (equal prefix "")
3273 (if (string-match "^[^\\+]+\\+" prefix)
3274 (list (intern (substring prefix 0 (1- (match-end 0))))
3275 (substring prefix (match-end 0) (1- (length prefix))))
3276 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
3278 (defun gnus-group-foreign-p (group)
3279 "Return nil if GROUP is native, non-nil if it is foreign."
3280 (string-match ":" group))
3282 (defun gnus-group-set-info (info &optional method-only-group part)
3283 (let* ((entry (gnus-gethash
3284 (or method-only-group (car info)) gnus-newsrc-hashtb))
3286 (info (if method-only-group (nth 2 entry) info)))
3287 (if (not method-only-group)
3290 (error "Trying to change non-existant group %s" method-only-group))
3291 ;; We have recevied parts of the actual group info - either the
3292 ;; select method or the group parameters. We first check
3293 ;; whether we have to extend the info, and if so, do that.
3294 (let ((len (length info))
3295 (total (if (eq part 'method) 5 6)))
3297 (setcdr (nthcdr (1- len) info)
3298 (make-list (- total len) nil)))
3299 ;; Then we enter the new info.
3300 (setcar (nthcdr (1- total) info) part-info)))
3301 ;; We uncompress some lists of marked articles.
3303 (if (not (setq marked (nth 3 info)))
3306 (or (eq 'score (car (car marked)))
3307 (eq 'bookmark (car (car marked)))
3308 (eq 'killed (car (car marked)))
3309 (setcdr (car marked)
3310 (gnus-uncompress-range (cdr (car marked)))))
3311 (setq marked (cdr marked)))))
3314 ;; This is a new group, so we just create it.
3316 (set-buffer gnus-group-buffer)
3318 ;; It's a foreign group...
3319 (gnus-group-make-group
3320 (gnus-group-real-name (car info))
3321 (prin1-to-string (car (nth 4 info)))
3322 (nth 1 (nth 4 info)))
3323 ;; It's a native group.
3324 (gnus-group-make-group
3326 (prin1-to-string (car gnus-select-method))
3327 (nth 1 gnus-select-method)))
3328 (gnus-message 6 "Note: New group created")
3330 (gnus-gethash (gnus-group-prefixed-name
3331 (gnus-group-real-name (car info))
3332 (or (nth 4 info) gnus-select-method))
3333 gnus-newsrc-hashtb))))
3334 ;; Whether it was a new group or not, we now have the entry, so we
3335 ;; can do the update.
3338 (setcar (nthcdr 2 entry) info)
3339 (if (and (not (eq (car entry) t))
3340 (gnus-gethash (car info) gnus-active-hashtb))
3341 (let ((marked (nth 3 info)))
3343 (max 0 (- (length (gnus-list-of-unread-articles
3345 (length (cdr (assq 'tick marked)))
3346 (length (cdr (assq 'dormant marked)))))))))
3347 (error "No such group: %s" (car info)))))
3349 (defun gnus-group-set-method-info (group select-method)
3350 (gnus-group-set-info select-method group 'method))
3352 (defun gnus-group-set-params-info (group params)
3353 (gnus-group-set-info params group 'params))
3355 (defun gnus-group-update-group-line ()
3356 "This function updates the current line in the newsgroup buffer and
3357 moves the point to the colon."
3358 (let* ((buffer-read-only nil)
3359 (group (gnus-group-group-name))
3360 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
3363 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3366 (delete-region (point) (progn (forward-line 1) (point)))
3367 (gnus-group-insert-group-line-info group)
3369 (gnus-group-position-cursor)))
3371 (defun gnus-group-insert-group-line-info (group)
3372 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
3376 (setq info (nth 2 entry))
3377 (gnus-group-insert-group-line
3378 nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
3379 (setq active (gnus-gethash group gnus-active-hashtb))
3380 (gnus-group-insert-group-line
3381 nil group (if (member group gnus-zombie-list) gnus-level-zombie
3383 nil (if active (- (1+ (cdr active)) (car active)) 0) nil))))
3385 (defun gnus-group-insert-group-line (gformat group level marked number method)
3386 (let* ((gformat (or gformat gnus-group-line-format-spec))
3387 (active (gnus-gethash group gnus-active-hashtb))
3388 (number-total (if active (1+ (- (cdr active) (car active))) 0))
3389 (number-of-dormant (length (cdr (assq 'dormant marked))))
3390 (number-of-ticked (length (cdr (assq 'tick marked))))
3391 (number-of-ticked-and-dormant
3392 (+ number-of-ticked number-of-dormant))
3393 (number-of-unread-unticked
3394 (if (numberp number) (int-to-string (max 0 number))
3397 (if (numberp number)
3398 (max 0 (- number-total number))
3400 (subscribed (cond ((<= level gnus-level-subscribed) ? )
3401 ((<= level gnus-level-unsubscribed) ?U)
3402 ((= level gnus-level-zombie) ?Z)
3404 (qualified-group (gnus-group-real-name group))
3405 (newsgroup-description
3406 (if gnus-description-hashtb
3407 (or (gnus-gethash group gnus-description-hashtb) "")
3409 (moderated (if (member group gnus-moderated-list) ?m ? ))
3410 (moderated-string (if (eq moderated ?m) "(m)" ""))
3411 (method (gnus-server-get-method group method))
3412 (news-server (or (car (cdr method)) ""))
3413 (news-method (or (car method) ""))
3415 (if method (format "(%s:%s)" (car method) (car (cdr method))) ""))
3419 (> number-of-ticked 0))
3421 (number (if (eq number t) "*" (+ number number-of-dormant
3423 (buffer-read-only nil)
3428 (insert (eval gformat))
3430 (add-text-properties
3431 b (1+ b) (list 'gnus-group (intern group)
3432 'gnus-unread (if (numberp number)
3433 (string-to-int number-of-unread-unticked)
3436 'gnus-level level))))
3438 (defun gnus-group-update-group (group &optional visible-only)
3439 "Update newsgroup info of GROUP.
3440 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't already."
3442 (set-buffer gnus-group-buffer)
3443 (let ((buffer-read-only nil)
3445 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
3448 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
3450 ;; Buffer may be narrowed.
3453 ;; Search a line to modify. If the buffer is large, the search
3454 ;; takes long time. In most cases, current point is on the line
3455 ;; we are looking for. So, first of all, check current line.
3458 (eq (get-text-property (point) 'gnus-group)
3463 (point-min) (point-max) 'gnus-group (intern group)))))
3464 ;; GROUP is listed in current buffer. So, delete old line.
3468 (delete-region (point) (progn (forward-line 1) (point))))
3469 ;; No such line in the buffer, find out where it's supposed to
3470 ;; go, and insert it there (or at the end of the buffer).
3471 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
3473 (let ((entry (cdr (gnus-gethash group gnus-newsrc-hashtb))))
3479 (point-min) (point-max)
3480 'gnus-group (intern (car (car entry)))))))
3481 (setq entry (cdr entry)))
3482 (or entry (goto-char (point-max)))))))
3483 (if (or visible (not visible-only))
3484 (gnus-group-insert-group-line-info group))
3485 (gnus-group-set-mode-line))))
3487 (defun gnus-group-set-mode-line ()
3488 (if (memq 'group gnus-updated-mode-lines)
3489 (let* ((gformat (or gnus-group-mode-line-format-spec
3490 (setq gnus-group-mode-line-format-spec
3492 gnus-group-mode-line-format
3493 gnus-group-mode-line-format-alist))))
3494 (news-server (car (cdr gnus-select-method)))
3495 (news-method (car gnus-select-method))
3496 (mode-string (eval gformat))
3498 (if (> (length mode-string) max-len)
3499 (setq mode-string (substring mode-string 0 (- max-len 4))))
3500 (setq mode-line-buffer-identification mode-string)
3501 (set-buffer-modified-p t))))
3503 (defun gnus-group-group-name ()
3504 "Get the name of the newsgroup on the current line."
3505 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
3506 (and group (symbol-name group))))
3508 (defun gnus-group-group-level ()
3509 "Get the level of the newsgroup on the current line."
3510 (get-text-property (gnus-point-at-bol) 'gnus-level))
3512 (defun gnus-group-search-forward (&optional backward all level first-too)
3513 "Find the next newsgroup with unread articles.
3514 If BACKWARD is non-nil, find the previous newsgroup instead.
3515 If ALL is non-nil, just find any newsgroup.
3516 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
3518 If FIRST-TOO, the current line is also eligeble as a target."
3519 (let ((way (if backward -1 1))
3523 (if (and backward (progn (beginning-of-line)) (bobp))
3525 (or first-too (forward-line way))
3533 (get-text-property (point) 'gnus-unread)))
3534 (or (eq unread t) (and unread (> unread 0))))
3535 (let ((lev (get-text-property
3536 (point) 'gnus-level)))
3537 (and lev (<= (get-text-property
3538 (point) 'gnus-level)
3539 gnus-level-subscribed)))))
3541 (let ((lev (get-text-property (point) 'gnus-level)))
3542 (if (and lev (<= lev level))
3547 (setq pos (point))))
3549 (zerop (forward-line way)))))
3551 (progn (gnus-group-position-cursor) t)
3552 (if pos (goto-char pos) (goto-char beg))
3555 ;;; Gnus group mode commands
3559 (defun gnus-group-mark-group (n &optional unmark)
3560 "Mark the current group."
3562 (let ((buffer-read-only nil)
3566 (setq group (gnus-group-group-name))
3574 (setq gnus-group-marked (delete group gnus-group-marked)))
3576 (setq gnus-group-marked (cons group gnus-group-marked)))
3578 (zerop (gnus-group-next-group 1)))
3580 (gnus-summary-position-cursor)
3583 (defun gnus-group-unmark-group (n)
3584 "Remove the mark from the current group."
3586 (gnus-group-mark-group n 'unmark))
3588 (defun gnus-group-mark-region (unmark beg end)
3589 "Mark all groups between point and mark.
3590 If UNMARK, remove the mark instead."
3591 (interactive "P\nr")
3592 (let ((num (count-lines beg end)))
3595 (- num (gnus-group-mark-group num unmark)))))
3597 (defun gnus-group-remove-mark (group)
3598 (and (gnus-group-goto-group group)
3600 (gnus-group-mark-group 1 'unmark))))
3602 ;; Return a list of groups to work on. Take into consideration N (the
3603 ;; prefix) and the list of marked groups.
3604 (defun gnus-group-process-prefix (n)
3606 (setq n (prefix-numeric-value n))
3607 ;; There is a prefix, so we return a list of the N next
3609 (let ((way (if (< n 0) -1 1))
3614 (setq group (gnus-group-group-name)))
3615 (setq groups (cons group groups))
3617 (forward-line way)))
3620 ;; No prefix, but a list of marked articles.
3621 (reverse gnus-group-marked))
3623 ;; Neither marked articles or a prefix, so we return the
3625 (let ((group (gnus-group-group-name)))
3626 (and group (list group))))))
3630 ;; Selecting groups.
3632 (defun gnus-group-read-group (all &optional no-article group)
3633 "Read news in this newsgroup.
3634 If argument ALL is non-nil, already read articles become readable.
3635 If optional argument NO-ARTICLE is non-nil, no article body is displayed."
3637 (let ((group (or group (gnus-group-group-name)))
3638 number active marked entry)
3639 (or group (error "No group on current line"))
3641 (nth 3 (nth 2 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))))
3642 ;; This group might be a dead group. In that case we have to get
3643 ;; the number of unread articles from `gnus-active-hashtb'.
3645 (setq number (car entry))
3646 (if (setq active (gnus-gethash group gnus-active-hashtb))
3647 (setq number (- (1+ (cdr active)) (car active)))))
3648 (gnus-summary-read-group
3649 group (or all (and (numberp number)
3650 (zerop (+ number (length (cdr (assq 'tick marked)))
3651 (length (cdr (assq 'dormant marked)))))))
3654 (defun gnus-group-select-group (all)
3655 "Select this newsgroup.
3656 No article is selected automatically.
3657 If argument ALL is non-nil, already read articles become readable."
3659 (gnus-group-read-group all t))
3661 (defun gnus-group-jump-to-group (group)
3662 "Jump to newsgroup GROUP."
3663 (interactive (list (completing-read "Group: " gnus-active-hashtb nil
3664 (not (not gnus-read-active-file)))))
3666 (if (equal group "")
3667 (error "empty group name"))
3669 (let ((b (text-property-any (point-min) (point-max)
3670 'gnus-group (intern group))))
3672 ;; Either go to the line in the group buffer...
3674 ;; ... or insert the line.
3676 (gnus-gethash group gnus-active-hashtb)
3677 (gnus-activate-newsgroup group)
3678 (error "%s error: %s" group (gnus-status-message group)))
3680 (gnus-group-update-group group)
3681 (goto-char (text-property-any (point-min) (point-max)
3682 'gnus-group (intern group)))))
3683 ;; Adjust cursor point.
3684 (gnus-group-position-cursor))
3686 (defun gnus-group-goto-group (group)
3687 "Goto to newsgroup GROUP."
3688 (let ((b (text-property-any (point-min) (point-max)
3689 'gnus-group (intern group))))
3690 (and b (goto-char b))))
3692 (defun gnus-group-next-group (n)
3693 "Go to next N'th newsgroup.
3694 If N is negative, search backward instead.
3695 Returns the difference between N and the number of skips actually
3698 (gnus-group-next-unread-group n t))
3700 (defun gnus-group-next-unread-group (n &optional all level)
3701 "Go to next N'th unread newsgroup.
3702 If N is negative, search backward instead.
3703 If ALL is non-nil, choose any newsgroup, unread or not.
3704 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
3705 such group can be found, the next group with a level higher than
3707 Returns the difference between N and the number of skips actually
3710 (let ((backward (< n 0))
3713 (gnus-group-search-forward
3714 backward (or (not gnus-group-goto-unread) all) level))
3716 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
3717 (if level " on this level or higher" "")))
3720 (defun gnus-group-prev-group (n)
3721 "Go to previous N'th newsgroup.
3722 Returns the difference between N and the number of skips actually
3725 (gnus-group-next-unread-group (- n) t))
3727 (defun gnus-group-prev-unread-group (n)
3728 "Go to previous N'th unread newsgroup.
3729 Returns the difference between N and the number of skips actually
3732 (gnus-group-next-unread-group (- n)))
3734 (defun gnus-group-next-unread-group-same-level (n)
3735 "Go to next N'th unread newsgroup on the same level.
3736 If N is negative, search backward instead.
3737 Returns the difference between N and the number of skips actually
3740 (gnus-group-next-unread-group n t (gnus-group-group-level))
3741 (gnus-group-position-cursor))
3743 (defun gnus-group-prev-unread-group-same-level (n)
3744 "Go to next N'th unread newsgroup on the same level.
3745 Returns the difference between N and the number of skips actually
3748 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
3749 (gnus-group-position-cursor))
3751 (defun gnus-group-best-unread-group (&optional exclude-group)
3752 "Go to the group with the highest level.
3753 If EXCLUDE-GROUP, do not go to that group."
3755 (goto-char (point-min))
3758 (while (setq unread (get-text-property (point) 'gnus-unread))
3759 (if (and (numberp unread) (> unread 0))
3761 (or best-point (setq best-point (point)))
3762 (if (and (< (get-text-property (point) 'gnus-level) best)
3763 (or (not exclude-group)
3764 (not (equal exclude-group (gnus-group-group-name)))))
3766 (setq best (get-text-property (point) 'gnus-level))
3767 (setq best-point (point))))))
3769 (if best-point (goto-char best-point))
3770 (gnus-summary-position-cursor)
3771 (and best-point (gnus-group-group-name))))
3773 (defun gnus-group-first-unread-group ()
3774 "Go to the first group with unread articles."
3776 (goto-char (point-min))
3777 (or (not (zerop (or (get-text-property (point) 'gnus-unread) 0)))
3778 (gnus-group-next-unread-group 1))
3779 (gnus-group-position-cursor))
3781 (defun gnus-group-enter-server-mode ()
3782 "Jump to the server buffer."
3784 (gnus-server-setup-buffer)
3785 (gnus-configure-windows 'server)
3786 (gnus-server-prepare))
3788 (defun gnus-group-make-group (name method address)
3789 "Add a new newsgroup.
3790 The user will be prompted for a NAME, for a select METHOD, and an
3794 (read-string "Group name: ")
3797 "Method: " (append gnus-valid-select-methods gnus-server-alist)
3799 (if (assoc method gnus-valid-select-methods)
3801 (if (memq 'prompt-address
3802 (assoc method gnus-valid-select-methods))
3803 (read-string "Address: ")
3805 (list method nil)))))
3807 (let* ((meth (if address (list (intern method) address) method))
3808 (nname (gnus-group-prefixed-name name meth))
3810 (and (gnus-gethash nname gnus-newsrc-hashtb)
3811 (error "Group %s already exists" nname))
3812 (gnus-group-change-level
3813 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
3814 gnus-level-default-subscribed gnus-level-killed
3815 (gnus-gethash (or (gnus-group-group-name) "dummy.group")
3816 gnus-newsrc-hashtb) t)
3817 (gnus-sethash nname '(0 . 0) gnus-active-hashtb)
3819 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")"))
3820 (gnus-group-insert-group-line-info nname)
3822 (and (gnus-check-backend-function 'request-create-group nname)
3823 (gnus-request-create-group nname))))
3825 (defun gnus-group-edit-group (group &optional part)
3826 "Edit the group on the current line."
3827 (interactive (list (gnus-group-group-name)))
3828 (let ((done-func '(lambda ()
3829 "Exit editing mode and update the information."
3831 (gnus-group-edit-group-done 'part 'group)))
3832 (part (or part 'info))
3833 (winconf (current-window-configuration))
3835 (if group (setq info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
3836 (error "No group on current line"))
3837 (set-buffer (get-buffer-create gnus-group-edit-buffer))
3838 (gnus-configure-windows 'edit-group)
3839 (gnus-add-current-to-buffer-list)
3841 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3842 (use-local-map (copy-keymap emacs-lisp-mode-map))
3843 (local-set-key "\C-c\C-c" done-func)
3844 (make-local-variable 'gnus-prev-winconf)
3845 (setq gnus-prev-winconf winconf)
3846 ;; We modify the func to let it know what part it is editing.
3847 (setcar (cdr (nth 4 done-func)) (list 'quote part))
3848 (setcar (cdr (cdr (nth 4 done-func))) group)
3853 ";; Type `C-c C-c' after editing the select method.\n\n")
3855 ";; Type `C-c C-c' after editing the group parameters.\n\n")
3857 ";; Type `C-c C-c' after editing the group info.\n\n")))
3858 (let ((cinfo (gnus-copy-sequence info))
3860 (if (not (setq marked (nth 3 cinfo)))
3863 (or (eq 'score (car (car marked)))
3864 (eq 'bookmark (car (car marked)))
3865 (eq 'killed (car (car marked)))
3866 (setcdr (car marked)
3867 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
3868 (setq marked (cdr marked))))
3871 (cond ((eq part 'method)
3872 (or (nth 4 info) "native"))
3879 (defun gnus-group-edit-group-method (group)
3880 "Edit the select method of GROUP."
3881 (interactive (list (gnus-group-group-name)))
3882 (gnus-group-edit-group group 'method))
3884 (defun gnus-group-edit-group-parameters (group)
3885 "Edit the group parameters of GROUP."
3886 (interactive (list (gnus-group-group-name)))
3887 (gnus-group-edit-group group 'params))
3889 (defun gnus-group-edit-group-done (part group)
3890 "Get info from buffer, update variables and jump to the group buffer."
3891 (set-buffer (get-buffer-create gnus-group-edit-buffer))
3892 (goto-char (point-min))
3893 (let ((form (read (current-buffer)))
3894 (winconf gnus-prev-winconf))
3896 (gnus-group-set-info form)
3897 (gnus-group-set-info form group part))
3898 (kill-buffer (current-buffer))
3899 (and winconf (set-window-configuration winconf))
3900 (set-buffer gnus-group-buffer)
3901 (gnus-group-update-group (gnus-group-group-name))
3902 (gnus-group-position-cursor)))
3904 (defun gnus-group-make-help-group ()
3905 "Create the (ding) Gnus documentation group."
3907 (and (gnus-gethash (gnus-group-prefixed-name "gnus-help" '(nndoc ""))
3909 (error "Documentation group already exists"))
3910 (let ((path load-path))
3912 (not (file-exists-p (concat (file-name-as-directory (car path))
3914 (setq path (cdr path)))
3915 (or path (error "Couldn't find doc group"))
3916 (gnus-group-make-group
3918 (concat (file-name-as-directory (car path)) "doc.txt"))
3919 (gnus-group-position-cursor)))
3921 (defun gnus-group-make-archive-group ()
3922 "Create the (ding) Gnus archive group."
3924 (and (gnus-gethash (gnus-group-prefixed-name "ding.archives" '(nndir ""))
3926 (error "Archive group already exists"))
3927 (gnus-group-make-group "ding.archives" "nndir" gnus-group-archive-directory)
3928 (gnus-group-position-cursor))
3930 (defun gnus-group-make-directory-group (dir)
3931 "Create an nndir group.
3932 The user will be prompted for a directory. The contents of this
3933 directory will be used as a newsgroup. The directory should contain
3934 mail messages or news articles in files that have numeric names."
3936 (list (read-file-name "Create group from directory: ")))
3937 (or (file-exists-p dir) (error "No such directory"))
3938 (or (file-directory-p dir) (error "Not a directory"))
3939 (gnus-group-make-group dir "nndir" dir)
3940 (gnus-group-position-cursor))
3942 (defun gnus-group-make-kiboze-group (group address scores)
3943 "Create an nnkiboze group.
3944 The user will be prompted for a name, a regexp to match groups, and
3945 score file entries for articles to include in the group."
3948 (read-string "nnkiboze group name: ")
3949 (read-string "Source groups (regexp): ")
3950 (let ((headers (mapcar (lambda (group) (list group))
3951 '("subject" "from" "number" "date" "message-id"
3952 "references" "chars" "lines" "xref")))
3953 scores header regexp regexps)
3954 (while (not (equal "" (setq header (completing-read
3955 "Match on header: " headers nil t))))
3957 (while (not (equal "" (setq regexp (read-string
3958 (format "Match on %s (string): "
3960 (setq regexps (cons (list regexp nil 1000 nil) regexps)))
3961 (setq scores (cons (cons header regexps) scores)))
3963 (gnus-group-make-group group "nnkiboze" address)
3965 (gnus-set-work-buffer)
3966 (let (emacs-lisp-mode-hook)
3967 (pp (list 'setq 'gnus-score-alist
3968 (list 'quote (list scores)))
3970 (write-region (point-min) (point-max)
3971 (concat (or gnus-kill-files-directory "~/News")
3972 "nnkiboze:" group "." gnus-score-file-suffix)))
3973 (gnus-group-position-cursor))
3975 (defun gnus-group-add-to-virtual (n vgroup)
3976 "Add the current group to a virtual group."
3978 (list current-prefix-arg
3979 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t)))
3980 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
3981 (error "%s is not an nnvirtual group" vgroup))
3982 (let* ((groups (gnus-group-process-prefix n))
3983 (method (nth 4 (nth 2 (gnus-gethash vgroup gnus-newsrc-hashtb)))))
3984 (setcar (cdr method)
3986 (nth 1 method) "\\|"
3989 (gnus-group-remove-mark s)
3990 (concat "\\(^" (regexp-quote s) "$\\)"))
3993 ;; Group sorting commands
3994 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
3996 (defun gnus-group-sort-groups ()
3997 "Sort the group buffer using `gnus-group-sort-function'."
3999 (setq gnus-newsrc-alist
4000 (sort (cdr gnus-newsrc-alist) gnus-group-sort-function))
4001 (gnus-make-hashtable-from-newsrc-alist)
4002 (gnus-get-unread-articles (1+ gnus-level-subscribed))
4003 (gnus-group-list-groups nil))
4005 (defun gnus-group-sort-by-alphabet (info1 info2)
4006 (string< (car info1) (car info2)))
4008 (defun gnus-group-sort-by-unread (info1 info2)
4009 (let ((n1 (car (gnus-gethash (car info1) gnus-newsrc-hashtb)))
4010 (n2 (car (gnus-gethash (car info2) gnus-newsrc-hashtb))))
4011 (< (or (and (numberp n1) n1) 0)
4012 (or (and (numberp n2) n2) 0))))
4014 (defun gnus-group-sort-by-level (info1 info2)
4015 (< (nth 1 info1) (nth 1 info2)))
4017 ;; Group catching up.
4019 (defun gnus-group-catchup-current (n &optional all)
4020 "Mark all articles not marked as unread in current newsgroup as read.
4021 If prefix argument N is numeric, the ARG next newsgroups will be
4022 caught up. If ALL is non-nil, marked articles will also be marked as
4023 read. Cross references (Xref: header) of articles are ignored.
4024 The difference between N and actual number of newsgroups that were
4025 caught up is returned."
4027 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
4031 "Do you really want to mark all articles as read? "
4032 "Mark all unread articles as read? "))))
4034 (let ((groups (gnus-group-process-prefix n))
4037 (gnus-group-remove-mark (car groups))
4038 (if (not (gnus-group-goto-group (car groups)))
4040 (gnus-group-catchup (car groups) all)
4041 (gnus-group-update-group-line))
4042 (setq groups (cdr groups)))
4043 (gnus-group-next-unread-group 1)
4046 (defun gnus-group-catchup-current-all (n)
4047 "Mark all articles in current newsgroup as read.
4048 Cross references (Xref: header) of articles are ignored."
4050 (gnus-group-catchup-current n 'all))
4052 (defun gnus-group-catchup (group &optional all)
4053 "Mark all articles in GROUP as read.
4054 If ALL is non-nil, all articles are marked as read.
4055 The return value is the number of articles that were marked as read,
4056 or nil if no action could be taken."
4057 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4059 (marked (nth 3 (nth 2 entry)))
4061 (if (not (numberp (car entry)))
4062 (gnus-message 1 "Can't catch up; non-active group")
4063 ;; Do the updating only if the newsgroup isn't killed
4066 (setq ticked (if all nil (cdr (assq 'tick marked))))
4067 (gnus-update-read-articles group ticked nil ticked)
4068 (if (and all marked)
4069 (setcar (nthcdr 3 (nth 2 entry))
4070 (delq (assq 'dormant marked) marked))))))
4073 (defun gnus-group-expire-articles (n)
4074 "Expire all expirable articles in the current newsgroup."
4076 (let ((groups (gnus-group-process-prefix n))
4078 (or groups (error "No groups to expire"))
4080 (setq group (car groups)
4081 groups (cdr groups))
4082 (gnus-group-remove-mark group)
4083 (if (not (gnus-check-backend-function 'request-expire-articles group))
4085 (let* ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
4086 (expirable (if (memq 'total-expire (nth 5 info))
4087 (cons nil (gnus-list-of-read-articles group))
4088 (assq 'expire (nth 3 info)))))
4091 (gnus-request-expire-articles
4092 (cdr expirable) group))))))))
4094 (defun gnus-group-expire-all-groups ()
4095 "Expire all expirable articles in all newsgroups."
4097 (gnus-message 5 "Expiring...")
4098 (let ((gnus-group-marked (mapcar (lambda (info) (car info))
4099 (cdr gnus-newsrc-alist))))
4100 (gnus-group-expire-articles nil))
4101 (gnus-message 5 "Expiring...done"))
4103 (defun gnus-group-set-current-level (n level)
4104 "Set the level of the next N groups to LEVEL."
4105 (interactive "P\nnLevel: ")
4106 (or (and (>= level 1) (<= level gnus-level-killed))
4107 (error "Illegal level: %d" level))
4108 (let ((groups (gnus-group-process-prefix n))
4111 (setq group (car groups)
4112 groups (cdr groups))
4113 (gnus-group-remove-mark group)
4114 (gnus-message 6 "Changed level of %s from %d to %d"
4115 group (gnus-group-group-level) level)
4116 (gnus-group-change-level group level
4117 (gnus-group-group-level))
4118 (gnus-group-update-group-line)))
4119 (gnus-group-position-cursor))
4121 (defun gnus-group-unsubscribe-current-group (arg)
4122 "Toggle subscribe from/to unsubscribe current group."
4124 (let ((group (gnus-group-group-name)))
4125 (or group (error "No newsgroup on current line"))
4126 (or arg (setq arg (if (<= (gnus-group-group-level) gnus-level-subscribed)
4127 gnus-level-default-unsubscribed
4128 gnus-level-default-subscribed)))
4129 (gnus-group-unsubscribe-group group arg)
4130 (gnus-group-next-group 1)))
4132 (defun gnus-group-unsubscribe-group (group &optional level)
4133 "Toggle subscribe from/to unsubscribe GROUP.
4134 New newsgroup is added to .newsrc automatically."
4136 (list (completing-read "Group: " gnus-active-hashtb nil
4137 gnus-have-read-active-file)))
4138 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
4140 ;; Toggle subscription flag.
4141 (gnus-group-change-level
4142 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
4143 gnus-level-subscribed)
4144 (1+ gnus-level-subscribed)
4145 gnus-level-default-subscribed)))
4146 (gnus-group-update-group group))
4147 ((and (stringp group)
4148 (or (not gnus-have-read-active-file)
4149 (gnus-gethash group gnus-active-hashtb)))
4150 ;; Add new newsgroup.
4151 (gnus-group-change-level
4153 (if level level gnus-level-default-subscribed)
4154 (or (and (member group gnus-zombie-list)
4157 (and (gnus-group-group-name)
4158 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
4159 (gnus-group-update-group group))
4160 (t (error "No such newsgroup: %s" group)))
4161 (gnus-group-position-cursor)))
4163 (defun gnus-group-transpose-groups (n)
4164 "Move the current newsgroup up N places.
4165 If given a negative prefix, move down instead. The difference between
4166 N and the number of steps taken is retured."
4168 (or (gnus-group-group-name)
4169 (error "No group on current line"))
4170 (gnus-group-kill-group 1)
4172 (forward-line (- n))
4173 (gnus-group-yank-group)
4174 (gnus-group-position-cursor)))
4176 (defun gnus-group-kill-all-zombies ()
4177 "Kill all zombie newsgroups."
4179 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
4180 (setq gnus-zombie-list nil)
4181 (funcall gnus-group-prepare-function gnus-level-subscribed nil nil)
4182 (goto-char (point-min))
4183 (gnus-group-position-cursor))
4185 (defun gnus-group-kill-region (begin end)
4186 "Kill newsgroups in current region (excluding current point).
4187 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
4190 ;; Exclude a line where current point is on.
4204 (beginning-of-line) ;Important when LINES < 1
4205 (gnus-group-kill-group lines)))
4207 (defun gnus-group-kill-group (n)
4208 "The the next N groups.
4209 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
4210 However, only groups that were alive can be yanked; already killed
4211 groups or zombie groups can't be yanked.
4212 The return value is the name of the (last) group that was killed."
4214 (let ((buffer-read-only nil)
4215 (groups (gnus-group-process-prefix n))
4218 (setq group (car groups)
4219 groups (cdr groups))
4220 (gnus-group-remove-mark group)
4221 (setq level (gnus-group-group-level))
4223 (if (setq entry (gnus-gethash group gnus-newsrc-hashtb))
4224 (setq gnus-list-of-killed-groups
4225 (cons (cons (car entry) (nth 2 entry))
4226 gnus-list-of-killed-groups)))
4227 (gnus-group-change-level
4228 (if entry entry group) gnus-level-killed (if entry nil level)))
4229 (gnus-group-position-cursor)
4232 (defun gnus-group-yank-group (&optional arg)
4233 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
4234 inserting it before the current newsgroup. The numeric ARG specifies
4235 how many newsgroups are to be yanked. The name of the (last)
4236 newsgroup yanked is returned."
4238 (if (not arg) (setq arg 1))
4239 (let (info group prev)
4240 (while (>= (setq arg (1- arg)) 0)
4241 (if (not (setq info (car gnus-list-of-killed-groups)))
4242 (error "No more newsgroups to yank"))
4243 (setq group (nth 2 info))
4244 ;; Find which newsgroup to insert this one before - search
4245 ;; backward until something suitable is found. If there are no
4246 ;; other newsgroups in this buffer, just make this newsgroup the
4248 (setq prev (gnus-group-group-name))
4249 (gnus-group-change-level
4250 info (nth 2 info) gnus-level-killed
4251 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
4253 (gnus-group-insert-group-line-info (nth 1 info))
4254 (setq gnus-list-of-killed-groups
4255 (cdr gnus-list-of-killed-groups)))
4257 (gnus-group-position-cursor)
4260 (defun gnus-group-list-all-groups (arg)
4261 "List all newsgroups with level ARG or lower.
4262 Default is gnus-level-unsubscribed, which lists all subscribed and most
4263 unsubscribed groups."
4265 (setq arg (or arg gnus-level-unsubscribed))
4266 (gnus-group-list-groups arg t))
4268 (defun gnus-group-list-killed ()
4269 "List all killed newsgroups in the group buffer."
4271 (if (not gnus-killed-list)
4272 (gnus-message 6 "No killed groups")
4273 (funcall gnus-group-prepare-function gnus-level-killed t gnus-level-killed)
4274 (goto-char (point-min)))
4275 (gnus-group-position-cursor))
4277 (defun gnus-group-list-zombies ()
4278 "List all zombie newsgroups in the group buffer."
4280 (if (not gnus-zombie-list)
4281 (gnus-message 6 "No zombie groups")
4282 (funcall gnus-group-prepare-function gnus-level-zombie t gnus-level-zombie)
4283 (goto-char (point-min)))
4284 (gnus-group-position-cursor))
4286 (defun gnus-group-get-new-news (&optional arg)
4287 "Get newly arrived articles.
4288 If ARG is non-nil, it should be a number between one and nine to
4289 specify which levels you are interested in re-scanning."
4291 (run-hooks 'gnus-get-new-news-hook)
4293 (if (and gnus-read-active-file (not level))
4295 (gnus-read-active-file)
4296 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed))))
4297 (let ((gnus-read-active-file nil))
4298 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed)))))
4299 (gnus-group-list-groups
4300 (or gnus-group-always-list-unread level gnus-level-subscribed)
4301 gnus-have-all-newsgroups)))
4303 (defun gnus-group-get-new-news-this-group (n)
4304 "Check for newly arrived news in the current group (and the N-1 next groups).
4305 The difference between N and the number of newsgroup checked is returned.
4306 If N is negative, this group and the N-1 previous groups will be checked."
4308 (let* ((groups (gnus-group-process-prefix n))
4309 (ret (if (numberp n) (- n (length groups)) 0))
4310 (w-p (window-start))
4313 (setq group (car groups)
4314 groups (cdr groups))
4315 (gnus-group-remove-mark group)
4316 (or (gnus-get-new-news-in-group group)
4319 (message "%s error: %s" group (gnus-status-message group))
4321 ;; !!! I don't know why the buffer scrolls forward when updating
4322 ;; the first line in the group buffer, but it does. So we set the
4323 ;; window start forcibly.
4324 ; (set-window-start (get-buffer-window (current-buffer)) w-p)
4326 (gnus-summary-position-cursor)
4329 (defun gnus-get-new-news-in-group (group)
4331 (gnus-activate-newsgroup group)
4333 (gnus-get-unread-articles-in-group
4334 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))
4335 (gnus-gethash group gnus-active-hashtb))
4336 (gnus-group-update-group-line)
4339 (defun gnus-group-fetch-faq (group)
4340 "Fetch the FAQ for the current group."
4341 (interactive (list (gnus-group-real-name (gnus-group-group-name))))
4342 (or group (error "No group name given"))
4343 (let ((file (concat gnus-group-faq-directory group)))
4344 (if (not (file-exists-p file))
4345 (error "No such file: %s" file)
4348 (defun gnus-group-describe-group (force &optional group)
4349 "Display a description of the current newsgroup."
4351 (and force (setq gnus-description-hashtb nil))
4352 (let ((group (or group (gnus-group-group-name)))
4354 (or group (error "No group name given"))
4355 (and (or gnus-description-hashtb
4356 (setq desc (gnus-group-get-description group))
4357 (gnus-read-descriptions-file))
4359 (or desc (gnus-gethash group gnus-description-hashtb)
4360 "No description available")))))
4362 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4363 (defun gnus-group-describe-all-groups (force)
4364 "Pop up a buffer with descriptons of all newsgroups."
4366 (and force (setq gnus-description-hashtb nil))
4367 (if (not (or gnus-description-hashtb
4368 (gnus-read-descriptions-file)))
4369 (error "Couldn't request descriptions file"))
4370 (let ((buffer-read-only nil)
4376 (insert (format " *: %-20s %s\n" (symbol-name group)
4377 (symbol-value group)))
4378 (add-text-properties
4379 b (1+ b) (list 'gnus-group group
4380 'gnus-unread t 'gnus-marked nil
4381 'gnus-level (1+ gnus-level-subscribed))))
4382 gnus-description-hashtb)
4383 (goto-char (point-min))
4384 (gnus-group-position-cursor)))
4386 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
4387 (defun gnus-group-apropos (regexp &optional search-description)
4388 "List all newsgroups that have names that match a regexp."
4389 (interactive "sGnus apropos (regexp): ")
4391 (obuf (current-buffer))
4393 ;; Go through all newsgroups that are known to Gnus.
4396 (and (string-match regexp (symbol-name group))
4397 (setq groups (cons (symbol-name group) groups))))
4399 ;; Go through all descriptions that are known to Gnus.
4400 (if search-description
4403 (and (string-match regexp (symbol-value group))
4404 (gnus-gethash (symbol-name group) gnus-active-hashtb)
4405 (setq groups (cons (symbol-name group) groups))))
4406 gnus-description-hashtb))
4408 (gnus-message 3 "No groups matched \"%s\"." regexp)
4409 ;; Print out all the groups.
4411 (pop-to-buffer "*Gnus Help*")
4412 (buffer-disable-undo (current-buffer))
4414 (setq groups (sort groups 'string<))
4416 ;; Groups may be entered twice into the list of groups.
4417 (if (not (string= (car groups) prev))
4419 (insert (setq prev (car groups)) "\n")
4420 (if (and gnus-description-hashtb
4421 (setq des (gnus-gethash (car groups)
4422 gnus-description-hashtb)))
4423 (insert " " des "\n"))))
4424 (setq groups (cdr groups)))
4425 (goto-char (point-min))))
4426 (pop-to-buffer obuf)))
4428 (defun gnus-group-description-apropos (regexp)
4429 "List all newsgroups that have names or desccriptions that match a regexp."
4430 (interactive "sGnus description apropos (regexp): ")
4431 (if (not (or gnus-description-hashtb
4432 (gnus-read-descriptions-file)))
4433 (error "Couldn't request descriptions file"))
4434 (gnus-group-apropos regexp t))
4436 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
4437 (defun gnus-group-list-matching (level regexp &optional all lowest)
4438 "List all groups with unread articles that match REGEXP.
4439 If the prefix LEVEL is non-nil, it should be a number that says which
4440 level to cut off listing groups.
4441 If ALL, also list groups with no unread articles.
4442 If LOWEST, don't list groups with level lower than LOWEST."
4443 (interactive "P\nsList newsgroups matching: ")
4444 (gnus-group-prepare-flat (or level gnus-level-subscribed)
4445 all (or lowest 1) regexp)
4446 (goto-char (point-min))
4447 (gnus-group-position-cursor))
4449 (defun gnus-group-list-all-matching (level regexp &optional lowest)
4450 "List all groups that match REGEXP.
4451 If the prefix LEVEL is non-nil, it should be a number that says which
4452 level to cut off listing groups.
4453 If LOWEST, don't list groups with level lower than LOWEST."
4454 (interactive "P\nsList newsgroups matching: ")
4455 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
4457 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
4458 (defun gnus-group-save-newsrc ()
4459 "Save the Gnus startup files."
4461 (gnus-save-newsrc-file))
4463 (defun gnus-group-restart (&optional arg)
4464 "Force Gnus to read the .newsrc file."
4466 (gnus-save-newsrc-file)
4467 (gnus-setup-news 'force)
4468 (gnus-group-list-groups arg gnus-have-all-newsgroups))
4470 (defun gnus-group-read-init-file ()
4471 "Read the Gnus elisp init file."
4473 (gnus-read-init-file))
4475 (defun gnus-group-check-bogus-groups ()
4476 "Check bogus newsgroups."
4478 (gnus-check-bogus-newsgroups (not gnus-expert-user)) ;Require confirmation.
4479 (gnus-group-list-groups nil gnus-have-all-newsgroups))
4481 (defun gnus-group-mail ()
4482 "Start composing a mail."
4486 (defun gnus-group-edit-global-kill (article &optional group)
4487 "Edit the global kill file.
4488 If GROUP, edit that local kill file instead."
4490 (setq gnus-current-kill-article article)
4491 (gnus-kill-file-edit-file group)
4493 (substitute-command-keys
4494 "Editing a global kill file (Type \\[gnus-kill-file-exit] to exit)")))
4496 (defun gnus-group-edit-local-kill (article group)
4497 "Edit a local kill file."
4498 (interactive (list nil (gnus-group-group-name)))
4499 (gnus-group-edit-global-kill article group))
4501 (defun gnus-group-force-update ()
4502 "Update `.newsrc' file."
4504 (gnus-save-newsrc-file))
4506 (defun gnus-group-suspend ()
4507 "Suspend the current Gnus session.
4508 In fact, cleanup buffers except for group mode buffer.
4509 The hook gnus-suspend-gnus-hook is called before actually suspending."
4511 (run-hooks 'gnus-suspend-gnus-hook)
4512 ;; Kill Gnus buffers except for group mode buffer.
4513 (let ((group-buf (get-buffer gnus-group-buffer)))
4514 ;; Do this on a separate list in case the user does a ^G before we finish
4515 (let ((gnus-buffer-list
4516 (delq group-buf (delq gnus-dribble-buffer
4517 (append gnus-buffer-list nil)))))
4518 (while gnus-buffer-list
4519 (gnus-kill-buffer (car gnus-buffer-list))
4520 (setq gnus-buffer-list (cdr gnus-buffer-list))))
4523 (setq gnus-buffer-list (list group-buf))
4524 (bury-buffer group-buf)
4525 (delete-windows-on group-buf t)))))
4527 (defun gnus-group-clear-dribble ()
4528 "Clear all information from the dribble buffer."
4530 (gnus-dribble-clear))
4532 (defun gnus-group-exit ()
4533 "Quit reading news after updating .newsrc.eld and .newsrc.
4534 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4536 (if (or noninteractive ;For gnus-batch-kill
4537 (zerop (buffer-size)) ;No news is good news.
4538 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
4539 (not gnus-interactive-exit) ;Without confirmation
4541 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
4543 (run-hooks 'gnus-exit-gnus-hook)
4544 (gnus-save-newsrc-file)
4545 (gnus-close-backends)
4546 (gnus-clear-system))))
4548 (defun gnus-close-backends ()
4549 ;; Send a close request to all backends that support such a request.
4550 (let ((methods gnus-valid-select-methods)
4553 (if (fboundp (setq func (intern (concat (car (car methods))
4554 "-request-close"))))
4556 (setq methods (cdr methods)))))
4558 (defun gnus-group-quit ()
4559 "Quit reading news without updating .newsrc.eld or .newsrc.
4560 The hook `gnus-exit-gnus-hook' is called before actually exiting."
4562 (if (or noninteractive ;For gnus-batch-kill
4563 (zerop (buffer-size))
4564 (not (gnus-server-opened gnus-select-method))
4566 (not gnus-current-startup-file)
4568 (format "Quit reading news without saving %s? "
4569 (file-name-nondirectory gnus-current-startup-file))))
4571 (run-hooks 'gnus-exit-gnus-hook)
4573 (gnus-close-backends)
4574 (gnus-clear-system))))
4576 (defun gnus-group-describe-briefly ()
4577 "Give a one line description of the group mode commands."
4580 (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")))
4582 (defun gnus-group-browse-foreign-server (method)
4583 "Browse a foreign news server.
4584 If called interactively, this function will ask for a select method
4585 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
4586 If not, METHOD should be a list where the first element is the method
4587 and the second element is the address."
4589 (list (let ((how (completing-read
4591 (append gnus-valid-select-methods gnus-server-alist)
4593 ;; We either got a backend name or a virtual server name.
4594 ;; If the first, we also need an address.
4595 (if (assoc how gnus-valid-select-methods)
4597 ;; Suggested by mapjph@bath.ac.uk.
4600 (mapcar (lambda (server) (list server))
4601 gnus-secondary-servers)))
4602 ;; We got a server name, so we find the method.
4603 (gnus-server-to-method how)))))
4604 (gnus-browse-foreign-server method))
4608 ;;; Browse Server Mode
4611 (defvar gnus-browse-mode-hook nil)
4612 (defvar gnus-browse-mode-map nil)
4613 (put 'gnus-browse-mode 'mode-class 'special)
4615 (if gnus-browse-mode-map
4617 (setq gnus-browse-mode-map (make-keymap))
4618 (suppress-keymap gnus-browse-mode-map)
4619 (define-key gnus-browse-mode-map " " 'gnus-browse-read-group)
4620 (define-key gnus-browse-mode-map "=" 'gnus-browse-read-group)
4621 (define-key gnus-browse-mode-map "n" 'gnus-browse-next-group)
4622 (define-key gnus-browse-mode-map "p" 'gnus-browse-prev-group)
4623 (define-key gnus-browse-mode-map "\177" 'gnus-browse-prev-group)
4624 (define-key gnus-browse-mode-map "N" 'gnus-browse-next-group)
4625 (define-key gnus-browse-mode-map "P" 'gnus-browse-prev-group)
4626 (define-key gnus-browse-mode-map "\M-n" 'gnus-browse-next-group)
4627 (define-key gnus-browse-mode-map "\M-p" 'gnus-browse-prev-group)
4628 (define-key gnus-browse-mode-map "\r" 'gnus-browse-read-group)
4629 (define-key gnus-browse-mode-map "u" 'gnus-browse-unsubscribe-current-group)
4630 (define-key gnus-browse-mode-map "l" 'gnus-browse-exit)
4631 (define-key gnus-browse-mode-map "L" 'gnus-browse-exit)
4632 (define-key gnus-browse-mode-map "q" 'gnus-browse-exit)
4633 (define-key gnus-browse-mode-map "Q" 'gnus-browse-exit)
4634 (define-key gnus-browse-mode-map "\C-c\C-c" 'gnus-browse-exit)
4635 (define-key gnus-browse-mode-map "?" 'gnus-browse-describe-briefly)
4636 (define-key gnus-browse-mode-map "\C-c\C-i" 'gnus-info-find-node)
4639 (defvar gnus-browse-current-method nil)
4640 (defvar gnus-browse-return-buffer nil)
4642 (defvar gnus-browse-buffer "*Gnus Browse Server*")
4644 (defun gnus-browse-foreign-server (method &optional return-buffer)
4645 (setq gnus-browse-current-method method)
4646 (setq gnus-browse-return-buffer return-buffer)
4647 (let ((gnus-select-method method)
4649 (gnus-message 5 "Connecting to %s..." (nth 1 method))
4650 (or (gnus-server-opened method)
4651 (gnus-open-server method)
4652 (error "Unable to contact server: %s" (gnus-status-message method)))
4653 (or (gnus-request-list method)
4654 (error "Couldn't request list: %s" (gnus-status-message method)))
4655 (get-buffer-create gnus-browse-buffer)
4656 (gnus-add-current-to-buffer-list)
4657 (and gnus-carpal (gnus-carpal-setup-buffer 'browse))
4658 (gnus-configure-windows 'browse)
4659 (buffer-disable-undo (current-buffer))
4660 (let ((buffer-read-only nil))
4663 (setq mode-line-buffer-identification
4665 "(ding) Browse Server {%s:%s}" (car method) (car (cdr method))))
4667 (set-buffer nntp-server-buffer)
4668 (let ((cur (current-buffer)))
4669 (goto-char (point-min))
4670 (delete-matching-lines gnus-ignored-newsgroups)
4671 (while (re-search-forward
4672 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
4673 (goto-char (match-end 1))
4674 (setq groups (cons (cons (buffer-substring (match-beginning 1)
4676 (max 0 (- (1+ (read cur)) (read cur))))
4678 (setq groups (sort groups
4680 (string< (car l1) (car l2)))))
4681 (let ((buffer-read-only nil))
4683 (setq group (car groups))
4685 (format "K%7d: %s\n" (cdr group) (car group)))
4686 (setq groups (cdr groups))))
4687 (switch-to-buffer (current-buffer))
4688 (goto-char (point-min))
4689 (gnus-group-position-cursor)))
4691 (defun gnus-browse-mode ()
4692 "Major mode for browsing a foreign server."
4694 (kill-all-local-variables)
4695 (if gnus-visual (gnus-browse-make-menu-bar))
4696 (setq mode-line-modified "-- ")
4697 (make-local-variable 'mode-line-format)
4698 (setq mode-line-format (copy-sequence mode-line-format))
4699 (and (equal (nth 3 mode-line-format) " ")
4700 (setcar (nthcdr 3 mode-line-format) ""))
4701 (setq major-mode 'gnus-browse-mode)
4702 (setq mode-name "Browse Server")
4703 (setq mode-line-process nil)
4704 (use-local-map gnus-browse-mode-map)
4705 (buffer-disable-undo (current-buffer))
4706 (setq truncate-lines t)
4707 (setq buffer-read-only t)
4708 (run-hooks 'gnus-browse-mode-hook))
4710 (defun gnus-browse-read-group ()
4711 "Not implemented, and will probably never be."
4713 (error "You can't read while browsing"))
4715 (defun gnus-browse-next-group (n)
4716 "Go to the next group."
4720 (gnus-group-position-cursor)))
4722 (defun gnus-browse-prev-group (n)
4723 "Go to the next group."
4725 (gnus-browse-next-group (- n)))
4727 (defun gnus-browse-unsubscribe-current-group (arg)
4728 "(Un)subscribe to the next ARG groups."
4731 (error "No group at current line."))
4732 (let ((ward (if (< arg 0) -1 1))
4734 (while (and (> arg 0)
4736 (gnus-browse-unsubscribe-group)
4737 (zerop (gnus-browse-next-group ward)))
4738 (setq arg (1- arg)))
4739 (gnus-group-position-cursor)
4740 (if (/= 0 arg) (gnus-message 7 "No more newsgroups"))
4743 (defun gnus-browse-unsubscribe-group ()
4745 (buffer-read-only nil)
4749 (if (= (following-char) ?K) (setq sub t))
4750 (re-search-forward ": \\(.*\\)$" nil t)
4751 (setq group (gnus-group-prefixed-name
4752 (buffer-substring (match-beginning 1) (match-end 1))
4753 gnus-browse-current-method))
4758 (gnus-group-change-level
4759 (list t group gnus-level-default-subscribed
4760 nil nil gnus-browse-current-method)
4761 gnus-level-default-subscribed gnus-level-killed
4762 (gnus-gethash (car (nth 1 gnus-newsrc-alist)) gnus-newsrc-hashtb)
4765 (gnus-group-change-level
4766 group gnus-level-killed gnus-level-default-subscribed)
4770 (defun gnus-browse-exit ()
4771 "Quit browsing and return to the group buffer."
4773 (if (eq major-mode 'gnus-browse-mode)
4774 (kill-buffer (current-buffer)))
4775 (if gnus-browse-return-buffer
4776 (gnus-configure-windows 'server)
4777 (gnus-configure-windows 'group)))
4779 (defun gnus-browse-describe-briefly ()
4780 "Give a one line description of the group mode commands."
4783 (substitute-command-keys "\\<gnus-browse-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")))
4787 ;;; Gnus summary mode
4790 (defvar gnus-summary-mode-map nil)
4791 (defvar gnus-summary-mark-map nil)
4792 (defvar gnus-summary-mscore-map nil)
4793 (defvar gnus-summary-article-map nil)
4794 (defvar gnus-summary-thread-map nil)
4795 (defvar gnus-summary-goto-map nil)
4796 (defvar gnus-summary-exit-map nil)
4797 (defvar gnus-summary-various-map nil)
4798 (defvar gnus-summary-interest-map nil)
4799 (defvar gnus-summary-sort-map nil)
4800 (defvar gnus-summary-backend-map nil)
4801 (defvar gnus-summary-save-map nil)
4802 (defvar gnus-summary-wash-map nil)
4803 (defvar gnus-summary-help-map nil)
4805 (put 'gnus-summary-mode 'mode-class 'special)
4807 (if gnus-summary-mode-map
4809 (setq gnus-summary-mode-map (make-keymap))
4810 (suppress-keymap gnus-summary-mode-map)
4812 ;; Non-orthogonal keys
4814 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
4815 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
4816 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
4817 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
4818 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
4819 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
4820 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
4821 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
4822 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
4823 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
4824 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
4825 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
4826 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
4827 (define-key gnus-summary-mode-map "\M-s" 'gnus-summary-search-article-forward)
4828 (define-key gnus-summary-mode-map "\M-r" 'gnus-summary-search-article-backward)
4829 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
4830 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
4831 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-subject)
4832 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
4833 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
4834 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
4835 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
4836 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
4837 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
4838 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
4839 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
4840 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
4841 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
4842 (define-key gnus-summary-mode-map "k" 'gnus-summary-kill-same-subject-and-select)
4843 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
4844 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
4845 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
4846 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
4847 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
4848 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
4849 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
4850 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
4851 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
4852 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
4853 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
4854 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
4855 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
4856 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
4857 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
4858 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
4859 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
4860 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
4861 (define-key gnus-summary-mode-map "\C-c\M-\C-s" 'gnus-summary-show-all-expunged)
4862 (define-key gnus-summary-mode-map "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
4863 (define-key gnus-summary-mode-map "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
4864 (define-key gnus-summary-mode-map "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
4865 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
4866 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
4867 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
4868 (define-key gnus-summary-mode-map "\C-x\C-s" 'gnus-summary-reselect-current-group)
4869 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
4870 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
4871 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
4872 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
4873 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
4874 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
4875 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
4876 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
4877 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
4878 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
4879 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
4880 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
4881 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
4882 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
4883 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
4884 (define-key gnus-summary-mode-map "V" 'gnus-version)
4885 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
4886 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
4887 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
4888 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
4889 (define-key gnus-summary-mode-map gnus-mouse-2 'gnus-mouse-pick-article)
4890 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
4891 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
4892 (define-key gnus-summary-mode-map "x" 'gnus-summary-remove-lines-marked-as-read)
4893 ; (define-key gnus-summary-mode-map "X" 'gnus-summary-remove-lines-marked-with)
4894 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
4895 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
4896 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
4897 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
4898 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
4899 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
4900 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
4903 ;; Sort of orthogonal keymap
4904 (define-prefix-command 'gnus-summary-mark-map)
4905 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
4906 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
4907 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
4908 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
4909 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
4910 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
4911 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
4912 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
4913 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
4914 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
4915 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
4916 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
4917 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
4918 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
4919 (define-key gnus-summary-mark-map "\M-r" 'gnus-summary-remove-lines-marked-as-read)
4920 (define-key gnus-summary-mark-map "\M-\C-r" 'gnus-summary-remove-lines-marked-with)
4921 (define-key gnus-summary-mark-map "D" 'gnus-summary-show-all-dormant)
4922 (define-key gnus-summary-mark-map "\M-D" 'gnus-summary-hide-all-dormant)
4923 (define-key gnus-summary-mark-map "S" 'gnus-summary-show-all-expunged)
4924 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
4925 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
4926 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
4927 (define-key gnus-summary-mark-map "k" 'gnus-summary-kill-same-subject-and-select)
4928 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
4930 (define-prefix-command 'gnus-summary-mscore-map)
4931 (define-key gnus-summary-mark-map "s" 'gnus-summary-mscore-map)
4932 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
4933 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
4934 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
4935 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
4937 (define-key gnus-summary-mark-map "p" 'gnus-uu-mark-map)
4939 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
4941 (define-prefix-command 'gnus-summary-goto-map)
4942 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
4943 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
4944 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
4945 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
4946 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
4947 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
4948 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
4949 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
4950 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
4951 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
4952 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
4953 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
4954 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
4955 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
4958 (define-prefix-command 'gnus-summary-thread-map)
4959 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
4960 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
4961 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
4962 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
4963 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
4964 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
4965 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
4966 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
4967 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
4968 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
4969 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
4970 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
4971 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
4972 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
4975 (define-prefix-command 'gnus-summary-exit-map)
4976 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
4977 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
4978 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
4979 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
4980 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
4981 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
4982 (define-key gnus-summary-exit-map "n" 'gnus-summary-catchup-and-goto-next-group)
4983 (define-key gnus-summary-exit-map "R" 'gnus-summary-reselect-current-group)
4984 (define-key gnus-summary-exit-map "G" 'gnus-summary-rescan-group)
4985 (define-key gnus-summary-exit-map "N" 'gnus-summary-next-group)
4986 (define-key gnus-summary-exit-map "P" 'gnus-summary-prev-group)
4989 (define-prefix-command 'gnus-summary-article-map)
4990 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
4991 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
4992 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
4993 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
4994 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
4995 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
4996 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
4997 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
4998 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
4999 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
5000 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
5001 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
5002 (define-key gnus-summary-article-map "w" 'gnus-summary-stop-page-breaking)
5003 (define-key gnus-summary-article-map "c" 'gnus-summary-caesar-message)
5004 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
5005 (define-key gnus-summary-article-map "t" 'gnus-summary-toggle-header)
5006 (define-key gnus-summary-article-map "m" 'gnus-summary-toggle-mime)
5007 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
5010 (define-prefix-command 'gnus-summary-wash-map)
5011 (define-key gnus-summary-mode-map "W" 'gnus-summary-wash-map)
5012 (define-key gnus-summary-wash-map "h" 'gnus-article-hide-headers)
5013 (define-key gnus-summary-wash-map "s" 'gnus-article-hide-signature)
5014 (define-key gnus-summary-wash-map "c" 'gnus-article-hide-citation)
5015 (define-key gnus-summary-wash-map "o" 'gnus-article-treat-overstrike)
5016 (define-key gnus-summary-wash-map "w" 'gnus-article-word-wrap)
5017 (define-key gnus-summary-wash-map "d" 'gnus-article-remove-cr)
5018 (define-key gnus-summary-wash-map "q" 'gnus-article-de-quoted-unreadable)
5019 (define-key gnus-summary-wash-map "f" 'gnus-article-display-x-face)
5020 (define-key gnus-summary-wash-map "t" 'gnus-article-date-ut)
5021 (define-key gnus-summary-wash-map "\C-t" 'gnus-article-date-local)
5022 (define-key gnus-summary-wash-map "T" 'gnus-article-date-lapsed)
5024 (define-key gnus-summary-wash-map "A" 'gnus-article-highlight)
5025 (define-key gnus-summary-wash-map "a" 'gnus-article-hide)
5026 (define-key gnus-summary-wash-map "H" 'gnus-article-highlight-headers)
5027 (define-key gnus-summary-wash-map "C" 'gnus-article-highlight-citation)
5028 (define-key gnus-summary-wash-map "S" 'gnus-article-highlight-signature)
5029 (define-key gnus-summary-wash-map "b" 'gnus-article-add-buttons)
5032 (define-prefix-command 'gnus-summary-help-map)
5033 (define-key gnus-summary-mode-map "H" 'gnus-summary-help-map)
5034 (define-key gnus-summary-help-map "v" 'gnus-version)
5035 (define-key gnus-summary-help-map "f" 'gnus-summary-fetch-faq)
5036 (define-key gnus-summary-help-map "d" 'gnus-summary-describe-group)
5037 (define-key gnus-summary-help-map "h" 'gnus-summary-describe-briefly)
5038 (define-key gnus-summary-help-map "i" 'gnus-info-find-node)
5041 (define-prefix-command 'gnus-summary-backend-map)
5042 (define-key gnus-summary-mode-map "B" 'gnus-summary-backend-map)
5043 (define-key gnus-summary-backend-map "e" 'gnus-summary-expire-articles)
5044 (define-key gnus-summary-backend-map "\177" 'gnus-summary-delete-article)
5045 (define-key gnus-summary-backend-map "m" 'gnus-summary-move-article)
5046 (define-key gnus-summary-backend-map "r" 'gnus-summary-respool-article)
5047 (define-key gnus-summary-backend-map "w" 'gnus-summary-edit-article)
5048 (define-key gnus-summary-backend-map "c" 'gnus-summary-copy-article)
5051 (define-prefix-command 'gnus-summary-save-map)
5052 (define-key gnus-summary-mode-map "O" 'gnus-summary-save-map)
5053 (define-key gnus-summary-save-map "o" 'gnus-summary-save-article)
5054 (define-key gnus-summary-save-map "m" 'gnus-summary-save-article-mail)
5055 (define-key gnus-summary-save-map "r" 'gnus-summary-save-article-rmail)
5056 (define-key gnus-summary-save-map "f" 'gnus-summary-save-article-file)
5057 (define-key gnus-summary-save-map "h" 'gnus-summary-save-article-folder)
5058 (define-key gnus-summary-save-map "v" 'gnus-summary-save-article-vm)
5059 (define-key gnus-summary-save-map "p" 'gnus-summary-pipe-output)
5061 (define-key gnus-summary-mode-map "X" 'gnus-uu-extract-map)
5063 (define-prefix-command 'gnus-summary-various-map)
5064 (define-key gnus-summary-mode-map "V" 'gnus-summary-various-map)
5065 (define-key gnus-summary-various-map "u" 'gnus-summary-universal-argument)
5066 (define-key gnus-summary-various-map "\C-s" 'gnus-summary-search-article-forward)
5067 (define-key gnus-summary-various-map "\C-r" 'gnus-summary-search-article-backward)
5068 (define-key gnus-summary-various-map "r" 'gnus-summary-refer-article)
5069 (define-key gnus-summary-various-map "&" 'gnus-summary-execute-command)
5070 (define-key gnus-summary-various-map "T" 'gnus-summary-toggle-truncation)
5071 (define-key gnus-summary-various-map "e" 'gnus-summary-expand-window)
5072 (define-key gnus-summary-various-map "D" 'gnus-summary-enter-digest-group)
5073 (define-key gnus-summary-various-map "k" 'gnus-summary-edit-local-kill)
5074 (define-key gnus-summary-various-map "K" 'gnus-summary-edit-global-kill)
5076 (define-key gnus-summary-various-map "S" 'gnus-summary-score-map)
5078 (define-prefix-command 'gnus-summary-sort-map)
5079 (define-key gnus-summary-various-map "s" 'gnus-summary-sort-map)
5080 (define-key gnus-summary-sort-map "n" 'gnus-summary-sort-by-number)
5081 (define-key gnus-summary-sort-map "a" 'gnus-summary-sort-by-author)
5082 (define-key gnus-summary-sort-map "s" 'gnus-summary-sort-by-subject)
5083 (define-key gnus-summary-sort-map "d" 'gnus-summary-sort-by-date)
5084 (define-key gnus-summary-sort-map "i" 'gnus-summary-sort-by-score)
5086 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-map)
5087 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-map)
5093 (defun gnus-summary-mode ()
5094 "Major mode for reading articles.
5096 All normal editing commands are switched off.
5097 \\<gnus-summary-mode-map>
5098 Each line in this buffer represents one article. To read an
5099 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
5100 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
5103 You can also post articles and send mail from this buffer. To
5104 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
5105 of an article, type `\\[gnus-summary-reply]'.
5107 There are approx. one gazillion commands you can execute in this
5108 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
5110 The following commands are available:
5112 \\{gnus-summary-mode-map}"
5114 (if gnus-visual (gnus-summary-make-menu-bar))
5115 (kill-all-local-variables)
5116 (let ((locals gnus-summary-local-variables))
5118 (if (consp (car locals))
5120 (make-local-variable (car (car locals)))
5121 (set (car (car locals)) (eval (cdr (car locals)))))
5122 (make-local-variable (car locals))
5123 (set (car locals) nil))
5124 (setq locals (cdr locals))))
5125 (gnus-make-thread-indent-array)
5126 (gnus-update-format-specifications)
5127 (setq mode-line-modified "-- ")
5128 (make-local-variable 'mode-line-format)
5129 (setq mode-line-format (copy-sequence mode-line-format))
5130 (and (equal (nth 3 mode-line-format) " ")
5131 (setcar (nthcdr 3 mode-line-format) ""))
5132 (setq major-mode 'gnus-summary-mode)
5133 (setq mode-name "Summary")
5134 (make-local-variable 'minor-mode-alist)
5135 (gnus-set-mode-line 'summary)
5136 (use-local-map gnus-summary-mode-map)
5137 (buffer-disable-undo (current-buffer))
5138 (setq buffer-read-only t) ;Disable modification
5139 (setq truncate-lines t)
5140 (setq selective-display t)
5141 (setq selective-display-ellipses t) ;Display `...'
5142 (run-hooks 'gnus-summary-mode-hook))
5144 (defun gnus-summary-clear-local-variables ()
5145 (let ((locals gnus-summary-local-variables))
5147 (if (consp (car locals))
5148 (and (vectorp (car (car locals)))
5149 (set (car (car locals)) nil))
5150 (and (vectorp (car locals))
5151 (set (car locals) nil)))
5152 (setq locals (cdr locals)))))
5154 (defun gnus-mouse-pick-article (e)
5157 (gnus-summary-next-page nil t))
5159 (defun gnus-summary-setup-buffer (group)
5160 "Initialize summary buffer."
5161 (let ((buffer (concat "*Summary " group "*")))
5162 (if (get-buffer buffer)
5165 (not gnus-newsgroup-threads))
5166 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
5167 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
5168 (gnus-add-current-to-buffer-list)
5170 (and gnus-carpal (gnus-carpal-setup-buffer 'summary))
5173 (defun gnus-set-global-variables ()
5174 ;; Set the global equivalents of the summary buffer-local variables
5175 ;; to the latest values they had. These reflect the summary buffer
5176 ;; that was in action when the last article was fetched.
5177 (if (eq major-mode 'gnus-summary-mode)
5179 (setq gnus-summary-buffer (current-buffer))
5180 (let ((name gnus-newsgroup-name)
5181 (marked gnus-newsgroup-marked)
5182 (unread gnus-newsgroup-unreads)
5183 (headers gnus-current-headers))
5185 (set-buffer gnus-group-buffer)
5186 (setq gnus-newsgroup-name name)
5187 (setq gnus-newsgroup-marked marked)
5188 (setq gnus-newsgroup-unreads unread)
5189 (setq gnus-current-headers headers))))))
5191 (defun gnus-summary-insert-dummy-line (sformat subject number)
5193 (setq sformat gnus-summary-dummy-line-format-spec))
5197 (insert (eval sformat))
5198 (add-text-properties
5200 (list 'gnus (list number ?Z 0)))))
5202 (defvar gnus-thread-indent-array nil)
5203 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
5204 (defun gnus-make-thread-indent-array ()
5206 (if (and gnus-thread-indent-array
5207 (= gnus-thread-indent-level gnus-thread-indent-array-level))
5209 (setq gnus-thread-indent-array (make-vector 201 "")
5210 gnus-thread-indent-array-level gnus-thread-indent-level)
5212 (aset gnus-thread-indent-array n
5213 (make-string (* n gnus-thread-indent-level) ? ))
5216 (defun gnus-summary-insert-line
5217 (sformat header level current unread replied expirable subject-or-nil
5218 &optional dummy score)
5219 (or sformat (setq sformat gnus-summary-line-format-spec))
5220 (let* ((indentation (aref gnus-thread-indent-array level))
5221 (lines (header-lines header))
5222 (score (or score gnus-summary-default-score 0))
5223 (score-char (if (or (null gnus-summary-default-score)
5224 (= score gnus-summary-default-score)) ?
5225 (if (< score gnus-summary-default-score)
5226 gnus-score-below-mark gnus-score-over-mark)))
5227 (replied (if replied gnus-replied-mark ? ))
5228 (from (header-from header))
5229 (name-address (funcall gnus-extract-address-components from))
5230 (address (car (cdr name-address)))
5231 (name (or (car name-address) (car (cdr name-address))))
5232 (subject (header-subject header))
5233 (number (header-number header))
5234 (opening-bracket (if dummy ?\< ?\[))
5235 (closing-bracket (if dummy ?\> ?\]))
5236 (buffer-read-only nil)
5237 (b (progn (beginning-of-line) (point))))
5238 (or (numberp lines) (setq lines 0))
5239 (insert (eval sformat))
5240 (add-text-properties
5241 b (1+ b) (list 'gnus (list number (or unread gnus-unread-mark) level)))))
5243 (defun gnus-summary-update-line (&optional dont-update)
5244 ;; Update summary line after change.
5245 (or (not gnus-summary-default-score)
5246 gnus-summary-inhibit-highlight
5247 (let ((gnus-summary-inhibit-highlight t)
5248 (article (gnus-summary-article-number)))
5251 (if (and gnus-summary-mark-below
5252 (< (gnus-summary-article-score)
5253 gnus-summary-mark-below))
5254 (and (not (memq article gnus-newsgroup-marked))
5255 (not (memq article gnus-newsgroup-dormant))
5256 (memq article gnus-newsgroup-unreads)
5257 (gnus-summary-mark-article nil gnus-low-score-mark))
5258 (and (eq (gnus-summary-article-mark) gnus-low-score-mark)
5259 (gnus-summary-mark-article nil gnus-unread-mark))))
5261 (run-hooks 'gnus-summary-update-hook))))))
5263 (defun gnus-summary-update-lines (&optional beg end)
5264 ;; Rehighlight summary buffer according to `gnus-summary-highlight'.
5265 (let ((beg (or beg (point-min)))
5266 (end (or end (point-max))))
5268 (set-buffer gnus-summary-buffer)
5270 (while (and (not (eobp)) (< (point) end))
5271 (gnus-summary-update-line)
5272 (forward-line 1)))))
5274 (defun gnus-summary-number-of-articles-in-thread (thread &optional char)
5275 ;; Sum up all elements (and sub-elements) in a list.
5279 '+ (mapcar 'gnus-summary-number-of-articles-in-thread thread))
5282 (if (> number 1) gnus-not-empty-thread-mark
5283 gnus-empty-thread-mark)
5286 (defun gnus-summary-read-group (group &optional show-all no-article kill-buffer)
5287 "Start reading news in newsgroup GROUP.
5288 If SHOW-ALL is non-nil, already read articles are also listed.
5289 If NO-ARTICLE is non-nil, no article is selected initially."
5290 (gnus-message 5 "Retrieving newsgroup: %s..." group)
5291 (let* ((new-group (gnus-summary-setup-buffer group))
5292 (did-select (and new-group (gnus-select-newsgroup group show-all)))
5293 (method (car (gnus-find-method-for-group group))))
5296 (gnus-set-global-variables)
5297 (gnus-kill-buffer kill-buffer)
5298 (gnus-configure-windows 'summary)
5299 (gnus-set-mode-line 'summary)
5300 (gnus-summary-position-cursor)
5304 (and (eq major-mode 'gnus-summary-mode)
5305 (not (equal (current-buffer) kill-buffer))
5307 (kill-buffer (current-buffer))
5308 (switch-to-buffer gnus-group-buffer)
5309 (gnus-group-next-unread-group 1)))
5311 ((eq did-select 'quit)
5312 (and (eq major-mode 'gnus-summary-mode)
5313 (not (equal (current-buffer) kill-buffer))
5314 (kill-buffer (current-buffer)))
5315 (gnus-kill-buffer kill-buffer)
5316 (gnus-configure-windows 'group)
5317 (gnus-group-next-unread-group 1)
5320 (gnus-set-global-variables)
5321 ;; Save the active value in effect when the group was entered.
5322 (setq gnus-newsgroup-active
5324 (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
5325 ;; You can change the subjects in this hook.
5326 (run-hooks 'gnus-select-group-hook)
5327 ;; Do score processing.
5328 (and gnus-use-scoring (gnus-possibly-score-headers))
5329 ;; Update the format specifiers.
5330 (gnus-update-format-specifications)
5331 ;; Generate the summary buffer.
5332 (gnus-summary-prepare)
5333 (if (zerop (buffer-size))
5334 (cond (gnus-newsgroup-dormant
5335 (gnus-summary-show-all-dormant))
5336 ((and gnus-newsgroup-scored show-all)
5337 (gnus-summary-show-all-expunged))))
5338 ;; Function `gnus-apply-kill-file' must be called in this hook.
5339 (run-hooks 'gnus-apply-kill-hook)
5340 (if (zerop (buffer-size))
5342 ;; This newsgroup is empty.
5343 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
5344 (gnus-message 6 "No unread news")
5345 (gnus-kill-buffer kill-buffer))
5348 (let ((gnus-summary-buffer kill-buffer))
5349 (gnus-configure-windows 'group))))
5350 ;; Hide conversation thread subtrees. We cannot do this in
5351 ;; gnus-summary-prepare-hook since kill processing may not
5352 ;; work with hidden articles.
5353 (and gnus-show-threads
5354 gnus-thread-hide-subtree
5355 (gnus-summary-hide-all-threads))
5356 ;; Show first unread article if requested.
5357 (goto-char (point-min))
5358 (if (and (not no-article)
5359 gnus-auto-select-first
5360 (gnus-summary-first-unread-article))
5361 (gnus-configure-windows 'article)
5362 (gnus-configure-windows 'summary))
5363 (gnus-set-mode-line 'summary)
5364 (gnus-summary-position-cursor)
5365 ;; If in async mode, we send some info to the backend.
5366 (and gnus-newsgroup-async
5367 (setq gnus-newsgroup-threads (nreverse gnus-newsgroup-threads))
5368 (gnus-request-asynchronous
5370 (if (and gnus-asynchronous-article-function
5371 (fboundp gnus-asynchronous-article-function))
5372 (funcall gnus-asynchronous-article-function
5373 gnus-newsgroup-threads)
5374 gnus-newsgroup-threads)))
5375 (gnus-kill-buffer kill-buffer))))))
5377 (defun gnus-summary-prepare ()
5378 ;; Generate the summary buffer.
5379 (let ((buffer-read-only nil))
5381 (gnus-summary-prepare-threads
5382 (if gnus-show-threads
5383 (gnus-gather-threads
5385 (if gnus-summary-expunge-below
5386 (gnus-make-threads-and-expunge)
5387 (gnus-make-threads))))
5388 gnus-newsgroup-headers)
5390 ;; Erase header retrieval message.
5391 (gnus-summary-update-lines)
5393 ;; Call hooks for modifying summary buffer.
5394 ;; Suggested by sven@tde.LTH.Se (Sven Mattisson).
5395 (goto-char (point-min))
5396 (run-hooks 'gnus-summary-prepare-hook)))
5398 (defun gnus-gather-threads (threads)
5399 "Gather threads that have lost their roots."
5400 (if (not gnus-summary-make-false-root)
5402 (let ((hashtb (gnus-make-hashtable 1023))
5405 thread subject hthread unre-subject whole-subject)
5407 (setq subject (header-subject (car (car threads)))
5408 whole-subject subject)
5409 (and gnus-summary-gather-subject-limit
5410 (or (and (numberp gnus-summary-gather-subject-limit)
5411 (> (length subject) gnus-summary-gather-subject-limit)
5413 (substring subject 0
5414 gnus-summary-gather-subject-limit)))
5415 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
5416 (setq subject (gnus-simplify-subject-fuzzy subject)))))
5419 (setq unre-subject (gnus-simplify-subject-re subject))
5422 (or (stringp (car (car hthread)))
5423 (setcar hthread (list whole-subject (car hthread))))
5424 (setcdr (car hthread) (nconc (cdr (car hthread))
5425 (list (car threads))))
5426 (setcdr prev (cdr threads))
5427 (setq threads prev))
5428 (gnus-sethash unre-subject threads hashtb))
5430 (setq threads (cdr threads)))
5433 (defun gnus-make-threads ()
5434 ;; This function takes the dependencies already made by
5435 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5436 ;; through the dependecies in the hash table and finds all the
5437 ;; roots. Roots do not refer back to any valid articles.
5439 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5440 (gnus-build-old-threads))
5443 (if (not (car (symbol-value refs)))
5444 (setq roots (append (cdr (symbol-value refs)) roots))
5445 ;; Ok, these refer back to valid articles, but if
5446 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5447 ;; the root has the same subject as its children. The children
5448 ;; that do not are made into roots and removed from the list
5450 (or gnus-thread-ignore-subject
5451 (let* ((prev (symbol-value refs))
5452 (subject (gnus-simplify-subject-re
5453 (header-subject (car prev))))
5454 (headers (cdr prev)))
5456 (if (not (string= subject
5457 (gnus-simplify-subject-re
5458 (header-subject (car headers)))))
5460 (setq roots (cons (car headers) roots))
5461 (setcdr prev (cdr headers)))
5462 (setq prev headers))
5463 (setq headers (cdr headers)))))))
5464 gnus-newsgroup-dependencies)
5466 (mapcar 'gnus-trim-thread
5468 (mapcar 'gnus-cut-thread
5469 (mapcar 'gnus-make-sub-thread roots))))))
5471 (defun gnus-make-threads-and-expunge ()
5472 ;; This function takes the dependencies already made by
5473 ;; `gnus-get-newsgroup-headers' and builds the trees. First we go
5474 ;; through the dependecies in the hash table and finds all the
5475 ;; roots. Roots do not refer back to any valid articles.
5477 (and gnus-fetch-old-headers (eq gnus-headers-retrieved-by 'nov)
5478 (gnus-build-old-threads))
5481 (if (not (car (symbol-value refs)))
5482 (if (and gnus-summary-expunge-below
5483 (not gnus-fetch-old-headers))
5484 (let ((headers (cdr (symbol-value refs))))
5486 (if (not (< (or (cdr (assq (header-number (car headers))
5487 gnus-newsgroup-scored))
5488 gnus-summary-default-score 0)
5489 gnus-summary-expunge-below))
5490 (setq roots (cons (car headers) roots))
5491 (setq gnus-newsgroup-unreads
5492 (delq (header-number (car headers))
5493 gnus-newsgroup-unreads)))
5494 (setq headers (cdr headers))))
5495 (setq roots (append (cdr (symbol-value refs)) roots)))
5496 ;; Ok, these refer back to valid articles, but if
5497 ;; `gnus-thread-ignore-subject' is nil, we have to check that
5498 ;; the root has the same subject as its children. The children
5499 ;; that do not are made into roots and removed from the list
5501 (or gnus-thread-ignore-subject
5502 (let* ((prev (symbol-value refs))
5503 (subject (gnus-simplify-subject-re
5504 (header-subject (car prev))))
5505 (headers (cdr prev)))
5507 (if (not (string= subject
5508 (gnus-simplify-subject-re
5509 (header-subject (car headers)))))
5511 (if (not (< (or (cdr (assq (header-number (car headers))
5512 gnus-newsgroup-scored))
5513 gnus-summary-default-score 0)
5514 gnus-summary-expunge-below))
5515 (setq roots (cons (car headers) roots))
5516 (setq gnus-newsgroup-unreads
5517 (delq (header-number (car headers))
5518 gnus-newsgroup-unreads)))
5519 (setcdr prev (cdr headers)))
5520 (setq prev headers))
5521 (setq headers (cdr headers)))))
5522 (and gnus-summary-expunge-below
5523 (not gnus-fetch-old-headers)
5524 (let* ((prev (symbol-value refs))
5525 (headers (cdr prev))
5528 (if (not (< (or (cdr (assq (header-number (car headers))
5529 gnus-newsgroup-scored))
5530 gnus-summary-default-score 0)
5531 gnus-summary-expunge-below))
5532 (setq prev (cdr prev))
5533 (setq gnus-newsgroup-unreads
5534 (delq (header-number (car headers))
5535 gnus-newsgroup-unreads))
5536 (setcdr prev (cdr headers))
5537 (setq id (gnus-gethash (header-id (car headers))
5538 gnus-newsgroup-dependencies))
5541 (if (not (< (or (cdr (assq (header-number (car h))
5542 gnus-newsgroup-scored))
5543 gnus-summary-default-score 0)
5544 gnus-summary-expunge-below))
5545 (setq roots (cons (car h) roots)))
5547 (setq headers (cdr headers)))))))
5548 gnus-newsgroup-dependencies)
5550 (mapcar 'gnus-trim-thread
5552 (mapcar 'gnus-cut-thread
5553 (mapcar 'gnus-make-sub-thread roots))))))
5555 (defun gnus-cut-thread (thread)
5556 ;; Remove leaf dormant or ancient articles from THREAD.
5557 (let ((head (car thread))
5558 (tail (apply 'append (mapcar 'gnus-cut-thread (cdr thread)))))
5559 (if (and (null tail)
5560 (let ((number (header-number head)))
5561 (or (memq number gnus-newsgroup-ancient)
5562 (memq number gnus-newsgroup-dormant)
5563 (and gnus-summary-expunge-below
5564 (eq gnus-fetch-old-headers 'some)
5565 (< (or (cdr (assq number gnus-newsgroup-scored))
5566 gnus-summary-default-score 0)
5567 gnus-summary-expunge-below)
5569 (setq gnus-newsgroup-unreads
5570 (delq number gnus-newsgroup-unreads))
5573 (list (cons head tail)))))
5575 (defun gnus-trim-thread (thread)
5576 ;; Remove root ancient articles with only one child from THREAD.
5577 (if (and (eq gnus-fetch-old-headers 'some)
5578 (memq (header-number (car thread)) gnus-newsgroup-ancient)
5579 (= (length thread) 2))
5580 (gnus-trim-thread (nth 1 thread))
5583 (defun gnus-make-sub-thread (root)
5584 ;; This function makes a sub-tree for a node in the tree.
5585 (let ((children (reverse (cdr (gnus-gethash (downcase (header-id root))
5586 gnus-newsgroup-dependencies)))))
5587 (cons root (mapcar 'gnus-make-sub-thread children))))
5589 (defun gnus-build-old-threads ()
5590 ;; Look at all the articles that refer back to old articles, and
5591 ;; fetch the headers for the articles that aren't there. This will
5592 ;; build complete threads - if the roots haven't been expired by the
5597 (if (not (car (symbol-value refs)))
5599 (setq heads (cdr (symbol-value refs)))
5601 (if (not (memq (header-number (car heads))
5602 gnus-newsgroup-dormant))
5604 (setq id (symbol-name refs))
5605 (while (and (setq id (gnus-build-get-header id))
5606 (not (car (gnus-gethash
5607 id gnus-newsgroup-dependencies)))))
5609 (setq heads (cdr heads)))))))
5610 gnus-newsgroup-dependencies)))
5612 (defun gnus-build-get-header (id)
5613 ;; Look through the buffer of NOV lines and find the header to
5614 ;; ID. Enter this line into the dependencies hash table, and return
5615 ;; the id of the parent article (if any).
5616 (let ((deps gnus-newsgroup-dependencies)
5620 (set-buffer nntp-server-buffer)
5621 (goto-char (point-min))
5622 (while (and (not found) (search-forward id nil t))
5624 (setq found (looking-at
5625 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
5626 (regexp-quote id))))
5627 (or found (beginning-of-line 2)))
5632 (setq header (gnus-nov-parse-line
5633 (read (current-buffer)) deps))
5634 (setq ref (header-references header))
5635 (string-match "\\(<[^>]+>\\) *$" ref)
5636 (substring ref (match-beginning 1) (match-end 1))))))
5638 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers)
5639 gnus-newsgroup-ancient (cons (header-number header)
5640 gnus-newsgroup-ancient))))))
5642 ;; Re-build the thread containing ID.
5643 (defun gnus-rebuild-thread (id)
5644 (let ((dep gnus-newsgroup-dependencies)
5645 (buffer-read-only nil)
5646 parent headers refs thread art)
5647 (while (and id (setq headers
5648 (car (setq art (gnus-gethash (downcase id) dep)))))
5650 (setq id (and (setq refs (header-references headers))
5651 (string-match "\\(<[^>]+>\\) *$" refs)
5652 (substring refs (match-beginning 1) (match-end 1)))))
5653 (setq thread (gnus-make-sub-thread (car parent)))
5654 (gnus-rebuild-remove-articles thread)
5655 (let ((beg (point)))
5656 (gnus-summary-prepare-threads (list thread) 0)
5657 (gnus-summary-update-lines beg (point)))))
5659 ;; Delete all lines in the summary buffer that correspond to articles
5661 (defun gnus-rebuild-remove-articles (thread)
5662 (and (gnus-summary-goto-subject (header-number (car thread)))
5664 (mapcar (lambda (th) (gnus-rebuild-remove-articles th)) (cdr thread)))
5666 (defun gnus-sort-threads (threads)
5667 ;; Sort threads as specified in `gnus-thread-sort-functions'.
5668 (let ((fun gnus-thread-sort-functions))
5670 (setq threads (sort threads (car fun))
5674 (defun gnus-thread-header (thread)
5675 ;; Return header of first article in THREAD.
5677 (if (stringp (car thread))
5678 (car (car (cdr thread)))
5682 (defun gnus-thread-sort-by-number (h1 h2)
5683 "Sort threads by root article number."
5684 (let ((h1 (gnus-thread-header h1))
5685 (h2 (gnus-thread-header h2)))
5686 (< (header-number h1) (header-number h2))))
5688 (defun gnus-thread-sort-by-author (h1 h2)
5689 "Sort threads by root author."
5690 (let ((h1 (gnus-thread-header h1))
5691 (h2 (gnus-thread-header h2)))
5693 (let ((extract (funcall
5694 gnus-extract-address-components (header-from h1))))
5695 (or (car extract) (cdr extract)))
5696 (let ((extract (funcall
5697 gnus-extract-address-components (header-from h2))))
5698 (or (car extract) (cdr extract))))))
5700 (defun gnus-thread-sort-by-subject (h1 h2)
5701 "Sort threads by root subject."
5702 (let ((h1 (gnus-thread-header h1))
5703 (h2 (gnus-thread-header h2)))
5705 (downcase (gnus-simplify-subject (header-subject h1)))
5706 (downcase (gnus-simplify-subject (header-subject h2))))))
5708 (defun gnus-thread-sort-by-date (h1 h2)
5709 "Sort threads by root article date."
5710 (let ((h1 (gnus-thread-header h1))
5711 (h2 (gnus-thread-header h2)))
5713 (gnus-sortable-date (header-date h1))
5714 (gnus-sortable-date (header-date h2)))))
5716 (defun gnus-thread-sort-by-score (h1 h2)
5717 "Sort threads by root article score.
5718 Unscored articles will be counted as havin a score of zero."
5719 (let ((h1 (gnus-thread-header h1))
5720 (h2 (gnus-thread-header h2)))
5721 (let ((s1 (assq (header-number h1) gnus-newsgroup-scored))
5722 (s2 (assq (header-number h2) gnus-newsgroup-scored)))
5723 (> (or (cdr s1) gnus-summary-default-score 0)
5724 (or (cdr s2) gnus-summary-default-score 0)))))
5726 (defun gnus-thread-sort-by-total-score (h1 h2)
5727 "Sort threads by the sum of all scores in the thread.
5728 Unscored articles will be counted as havin a score of zero."
5729 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5731 (defun gnus-thread-total-score (thread)
5732 ;; This function find the total score of THREAD.
5734 (if (stringp (car thread))
5735 (apply gnus-thread-score-function 0
5736 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5737 (gnus-thread-total-score-1 thread))
5738 (gnus-thread-total-score-1 (list thread))))
5740 (defun gnus-thread-total-score-1 (root)
5741 ;; This function find the total score of the thread below ROOT.
5742 (setq root (car root))
5743 (apply gnus-thread-score-function
5744 (or (cdr (assq (header-number root) gnus-newsgroup-scored))
5745 gnus-summary-default-score 0)
5746 (mapcar 'gnus-thread-total-score
5747 (cdr (gnus-gethash (downcase (header-id root))
5748 gnus-newsgroup-dependencies)))))
5750 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5751 (defvar gnus-tmp-prev-subject "")
5752 (defvar gnus-tmp-adopt-thread nil)
5754 ;; Basic ideas by Paul Dworkin <paul@media-lab.media.mit.edu>.
5755 (defun gnus-summary-prepare-threads
5756 (threads level &optional not-child no-subject cull)
5757 "Prepare summary buffer from THREADS and indentation LEVEL.
5758 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5759 or a straight list of headers."
5760 (let (thread header number subject clevel)
5762 (setq thread (car threads)
5763 threads (cdr threads))
5764 ;; If `thread' is a cons, hierarchical threads are used. If not,
5765 ;; `thread' is the header.
5767 (setq header (car thread))
5768 (setq header thread)
5770 (or (memq (setq number (header-number header))
5771 gnus-newsgroup-dormant)
5772 (and gnus-summary-expunge-below
5773 (< (or (cdr (assq number gnus-newsgroup-scored))
5774 gnus-summary-default-score 0)
5775 gnus-summary-expunge-below)))
5778 (setq gnus-newsgroup-unreads
5779 (delq number gnus-newsgroup-unreads)))))
5782 ;; The header is a dummy root.
5783 (cond ((eq gnus-summary-make-false-root 'adopt)
5784 ;; We let the first article adopt the rest.
5785 (let ((gnus-tmp-adopt-thread thread))
5786 (gnus-summary-prepare-threads (list (car (cdr thread))) 0))
5787 (setq thread (cdr (cdr thread)))
5789 (gnus-summary-prepare-threads (list (car thread)) 1 t)
5790 (setq thread (cdr thread))))
5791 ((eq gnus-summary-make-false-root 'dummy)
5792 ;; We output a dummy root.
5793 (gnus-summary-insert-dummy-line
5794 nil header (header-number (car (car (cdr thread)))))
5796 ((eq gnus-summary-make-false-root 'empty)
5797 ;; We print the articles with empty subject fields.
5798 (let ((gnus-tmp-adopt-thread thread))
5799 (gnus-summary-prepare-threads (list (car (cdr thread))) 0))
5800 (setq thread (cdr (cdr thread)))
5802 (gnus-summary-prepare-threads
5803 (list (car thread)) 0 nil
5804 (not (and (eq gnus-summary-gather-subject-limit 'fuzzy)
5806 (gnus-simplify-subject-re
5807 (header-subject (car (car thread))))
5808 (gnus-simplify-subject-re header))))))
5809 (setq thread (cdr thread))))
5811 ;; We do not make a root for the gathered
5812 ;; sub-threads at all.
5814 ;; Print the sub-threads.
5815 (and (consp thread) (cdr thread)
5816 (gnus-summary-prepare-threads (cdr thread) clevel)))
5817 ;; The header is a real article.
5819 (setq number (header-number header)
5820 subject (header-subject header))
5821 (and gnus-newsgroup-async
5822 (setq gnus-newsgroup-threads
5823 (cons (cons (header-number header)
5824 (header-lines header)) gnus-newsgroup-threads)))
5825 (gnus-summary-insert-line
5826 nil header level nil
5827 (cond ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
5828 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
5829 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
5830 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
5831 (t gnus-ancient-mark))
5832 (memq number gnus-newsgroup-replied)
5833 (memq number gnus-newsgroup-expirable)
5835 gnus-summary-same-subject
5836 (if (or (zerop level)
5837 (and gnus-thread-ignore-subject
5839 (gnus-simplify-subject-re gnus-tmp-prev-subject)
5840 (gnus-simplify-subject-re subject)))))
5842 gnus-summary-same-subject))
5844 (cdr (assq number gnus-newsgroup-scored)))
5845 (setq gnus-tmp-prev-subject subject)
5846 ;; Recursively print subthreads.
5847 (and (consp thread) (cdr thread)
5848 (gnus-summary-prepare-threads (cdr thread) (1+ level))))))))
5850 (defun gnus-select-newsgroup (group &optional read-all)
5851 "Select newsgroup GROUP.
5852 If READ-ALL is non-nil, all articles in the group are selected."
5853 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5854 (info (nth 2 entry))
5855 articles header-marks)
5856 (gnus-check-news-server
5857 (setq gnus-current-select-method (gnus-find-method-for-group group)))
5859 (or (gnus-server-opened gnus-current-select-method)
5860 (gnus-open-server gnus-current-select-method)
5861 (error "Couldn't open server"))
5863 (or (and (eq (car entry) t)
5864 (gnus-activate-newsgroup (car info)))
5865 (gnus-request-group group t)
5867 (kill-buffer (current-buffer))
5868 (error "Couldn't request group %s: %s"
5869 group (gnus-status-message group))))
5871 (setq gnus-newsgroup-name group)
5872 (setq gnus-newsgroup-unselected nil)
5873 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5875 (and gnus-asynchronous
5876 (gnus-check-backend-function
5877 'request-asynchronous gnus-newsgroup-name)
5878 (setq gnus-newsgroup-async
5879 (gnus-request-asynchronous gnus-newsgroup-name)))
5881 (setq articles (gnus-articles-to-read group read-all))
5885 (gnus-message 3 "Couldn't select newsgroup")
5887 ((eq articles 0) nil)
5889 ;; Init the dependencies hash table.
5890 (setq gnus-newsgroup-dependencies
5891 (gnus-make-hashtable (length articles)))
5892 ;; Retrieve the headers and read them in.
5893 (setq gnus-newsgroup-headers
5894 (if (eq 'nov (setq gnus-headers-retrieved-by
5895 (gnus-retrieve-headers
5896 (if gnus-fetch-old-headers
5897 (cons 1 articles) articles)
5898 gnus-newsgroup-name)))
5900 (gnus-get-newsgroup-headers-xover articles))
5901 (gnus-get-newsgroup-headers)))
5902 ;; If we were to fetch old headers, but the backend didn't
5903 ;; support XOVER, then it is possible we fetched one article
5904 ;; that we shouldn't have. If that's the case, we pop it off the
5906 (and (not (eq gnus-headers-retrieved-by 'nov))
5907 gnus-fetch-old-headers
5908 gnus-newsgroup-headers
5909 (/= (header-number (car gnus-newsgroup-headers)) (car articles))
5910 (setq gnus-newsgroup-headers (cdr gnus-newsgroup-headers)))
5911 ;; Remove cancelled articles from the list of unread articles.
5912 (setq gnus-newsgroup-unreads
5913 (gnus-set-sorted-intersection
5914 gnus-newsgroup-unreads
5915 (mapcar (lambda (headers) (header-number headers))
5916 gnus-newsgroup-headers)))
5917 ;; Adjust and set lists of article marks.
5920 (gnus-adjust-marked-articles info)
5921 (setq gnus-newsgroup-marked
5922 (cdr (assq 'tick (setq marked (nth 3 info)))))
5923 (setq gnus-newsgroup-replied (cdr (assq 'reply marked)))
5924 (setq gnus-newsgroup-expirable (cdr (assq 'expire marked)))
5925 (setq gnus-newsgroup-killed (cdr (assq 'killed marked)))
5926 (setq gnus-newsgroup-bookmarks (cdr (assq 'bookmark marked)))
5927 (setq gnus-newsgroup-dormant (cdr (assq 'dormant marked)))
5928 (setq gnus-newsgroup-scored (cdr (assq 'score marked)))
5929 (setq gnus-newsgroup-processable nil)))
5930 ;; Check whether auto-expire is to be done in this group.
5931 (setq gnus-newsgroup-auto-expire
5932 (or (and (stringp gnus-auto-expirable-newsgroups)
5933 (string-match gnus-auto-expirable-newsgroups group))
5934 (memq 'auto-expire (nth 5 info))))
5935 ;; First and last article in this newsgroup.
5936 (and gnus-newsgroup-headers
5937 (setq gnus-newsgroup-begin
5938 (header-number (car gnus-newsgroup-headers)))
5939 (setq gnus-newsgroup-end
5940 (header-number (gnus-last-element gnus-newsgroup-headers))))
5941 (setq gnus-reffed-article-number -1)
5942 ;; GROUP is successfully selected.
5943 (or gnus-newsgroup-headers t)))))
5945 (defun gnus-articles-to-read (group read-all)
5946 ;; Find out what articles the user wants to read.
5948 ;; Select all articles if `read-all' is non-nil, or if all the
5949 ;; unread articles are dormant articles.
5951 (= (length gnus-newsgroup-unreads)
5952 (length gnus-newsgroup-dormant)))
5953 (gnus-uncompress-range
5954 (gnus-gethash group gnus-active-hashtb))
5955 gnus-newsgroup-unreads))
5956 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5957 (scored (length scored-list))
5958 (number (length articles))
5959 (marked (+ (length gnus-newsgroup-marked)
5960 (length gnus-newsgroup-dormant)))
5963 (cond ((and (or (<= scored marked)
5965 (numberp gnus-large-newsgroup)
5966 (> number gnus-large-newsgroup))
5970 "How many articles from %s (default %d): "
5971 gnus-newsgroup-name number))))
5972 (if (string-equal input "")
5974 ((and (> scored marked) (< scored number))
5978 "%s %s (%d scored, %d total): "
5979 "How many articles from"
5980 group scored number))))
5981 (if (string-equal input "")
5986 (setq select (if (stringp select) (string-to-number select) select))
5987 (if (or (null select) (zerop select))
5989 (if (and (not (zerop scored)) (<= (abs select) scored))
5991 (setq articles (sort scored-list '<))
5992 (setq number (length articles)))
5993 (setq articles (copy-sequence articles)))
5995 (setq total-articles articles)
5997 (if (< (abs select) number)
5999 ;; Select the N oldest articles.
6000 (setcdr (nthcdr (1- (abs select)) articles) nil)
6001 ;; Select the N most recent articles.
6002 (setq articles (nthcdr (- number select) articles))))
6003 (setq gnus-newsgroup-unselected
6004 (gnus-sorted-intersection
6005 gnus-newsgroup-unreads
6006 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
6009 (defun gnus-killed-articles (killed articles)
6012 (if (inline (gnus-member-of-range (car articles) killed))
6013 (setq out (cons (car articles) out)))
6014 (setq articles (cdr articles)))
6017 (defun gnus-adjust-marked-articles (info &optional active)
6018 "Remove all marked articles that are no longer legal."
6019 (let ((marked-lists (nth 3 info))
6020 (active (or active (gnus-gethash (car info) gnus-active-hashtb)))
6022 ;; There are many types of marked articles.
6024 (setq m (cdr (setq prev (car marked-lists))))
6025 (cond ((or (eq 'tick (car prev)) (eq 'dormant (car prev)))
6026 ;; Make sure that all ticked articles are a subset of the
6027 ;; unread/unselected articles.
6029 (if (or (memq (car m) gnus-newsgroup-unreads)
6030 (memq (car m) gnus-newsgroup-unselected))
6032 (setcdr prev (cdr m)))
6034 ((eq 'score (car prev))
6035 ;; Scored articles should be a subset of
6036 ;; unread/unselected articles.
6038 (if (or (memq (car (car m)) gnus-newsgroup-unreads)
6039 (memq (car (car m)) gnus-newsgroup-unreads))
6041 (setcdr prev (cdr m)))
6043 ((eq 'bookmark (car prev))
6044 ;; Bookmarks should be a subset of active articles.
6046 (if (< (car (car m)) (car active))
6047 (setcdr prev (cdr m))
6050 ((eq 'killed (car prev))
6051 ;; Articles that have been through the kill process are
6052 ;; to be a subset of active articles.
6053 (while (and m (< (or (and (numberp (car m)) (car m))
6056 (setcdr prev (cdr m))
6058 (if (and m (< (or (and (numberp (car m)) (car m))
6061 (setcar (if (numberp (car m)) m (car m)) (car active))))
6062 ((or (eq 'reply (car prev)) (eq 'expire (car prev)))
6063 ;; The replied and expirable articles have to be articles
6066 (if (< (car m) (car active))
6067 (setcdr prev (cdr m))
6070 (setq marked-lists (cdr marked-lists)))
6071 ;; Remove all lists that are empty.
6072 (setq marked-lists (nth 3 info))
6075 (while (= 1 (length (car marked-lists)))
6076 (setq marked-lists (cdr marked-lists)))
6077 (setq m (cdr (setq prev marked-lists)))
6079 (if (= 1 (length (car m)))
6080 (setcdr prev (cdr m))
6083 (setcar (nthcdr 3 info) marked-lists)))
6084 ;; Finally, if there are no marked lists at all left, and if there
6085 ;; are no elements after the lists in the info list, we just chop
6086 ;; the info list off before the marked lists.
6087 (and (null marked-lists)
6088 (not (nthcdr 4 info))
6089 (setcdr (nthcdr 2 info) nil)))
6092 (defun gnus-set-marked-articles
6093 (info ticked replied expirable killed dormant bookmark score)
6094 "Enter the various lists of marked articles into the newsgroup info list."
6096 (and ticked (setq newmarked (cons (cons 'tick ticked) nil)))
6097 (and replied (setq newmarked (cons (cons 'reply replied) newmarked)))
6098 (and expirable (setq newmarked (cons (cons 'expire expirable)
6100 (and killed (setq newmarked (cons (cons 'killed killed) newmarked)))
6101 (and dormant (setq newmarked (cons (cons 'dormant dormant) newmarked)))
6102 (and bookmark (setq newmarked (cons (cons 'bookmark bookmark)
6104 (and score (setq newmarked (cons (cons 'score score) newmarked)))
6107 (setcar (nthcdr 3 info) newmarked)
6108 (if (not (nthcdr 4 info))
6109 (setcdr (nthcdr 2 info) nil)
6110 (setcar (nthcdr 3 info) nil)))
6112 (setcdr (nthcdr 2 info) (cons newmarked nil))))))
6114 (defun gnus-add-marked-articles (group type articles &optional info force)
6115 ;; Add ARTICLES of TYPE to the info of GROUP.
6116 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
6117 ;; add, but replace marked articles of TYPE with ARTICLES.
6118 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6121 (and (not (setq marked (nthcdr 3 info)))
6122 (setcdr (nthcdr 2 info) (list (list (cons type articles)))))
6123 (and (not (setq m (assq type (car marked))))
6124 (setcar marked (cons (cons type articles) (car marked))))
6127 (nconc m articles)))))
6129 (defun gnus-set-mode-line (where)
6130 "This function sets the mode line of the article or summary buffers.
6131 If WHERE is `summary', the summary mode line format will be used."
6132 (if (memq where gnus-updated-mode-lines)
6135 (set-buffer gnus-summary-buffer)
6136 (let* ((mformat (if (eq where 'article)
6137 gnus-article-mode-line-format-spec
6138 gnus-summary-mode-line-format-spec))
6139 (group-name gnus-newsgroup-name)
6140 (article-number (or gnus-current-article 0))
6141 (unread (- (length gnus-newsgroup-unreads)
6142 (length gnus-newsgroup-dormant)))
6143 (unread-and-unticked
6144 (- unread (length gnus-newsgroup-marked)))
6145 (unselected (length gnus-newsgroup-unselected))
6146 (unread-and-unselected
6147 (cond ((and (zerop unread-and-unticked)
6148 (zerop unselected)) "")
6150 (format "{%d more}" unread-and-unticked))
6151 (t (format "{%d(+%d) more}"
6152 unread-and-unticked unselected))))
6154 (if gnus-current-headers
6155 (header-subject gnus-current-headers) ""))
6156 (max-len (and gnus-mode-non-string-length
6157 (- (frame-width) gnus-mode-non-string-length)))
6158 header) ;; passed as argument to any user-format-funcs
6159 (setq mode-string (eval mformat))
6160 (or (numberp max-len)
6161 (setq max-len (length mode-string)))
6162 (if (< max-len 4) (setq max-len 4))
6163 (if (> (length mode-string) max-len)
6165 (concat (substring mode-string 0 (- max-len 3))
6167 (setq mode-string (format (format "%%-%ds" max-len)
6169 (setq mode-line-buffer-identification mode-string)
6170 (set-buffer-modified-p t))))
6172 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6173 "Go through the HEADERS list and add all Xrefs to a hash table.
6174 The resulting hash table is returned, or nil if no Xrefs were found."
6175 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
6177 (gnus-group-foreign-p from-newsgroup)
6179 (assoc (symbol-name (car from-method))
6180 gnus-valid-select-methods))))
6181 (gnus-group-real-prefix from-newsgroup)))
6182 (xref-hashtb (make-vector 63 0))
6183 start group entry number xrefs header)
6185 (setq header (car headers))
6186 (if (and (setq xrefs (header-xref header))
6187 (not (memq (header-number header) unreads)))
6190 (while (string-match "\\([^ ]+\\):\\([0-9]+\\)" xrefs start)
6191 (setq start (match-end 0))
6192 (setq group (concat prefix (substring xrefs (match-beginning 1)
6195 (string-to-int (substring xrefs (match-beginning 2)
6197 (if (setq entry (gnus-gethash group xref-hashtb))
6198 (setcdr entry (cons number (cdr entry)))
6199 (gnus-sethash group (cons number nil) xref-hashtb)))))
6200 (setq headers (cdr headers)))
6201 (if start xref-hashtb nil)))
6203 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads expirable)
6204 "Look through all the headers and mark the Xrefs as read."
6205 (let ((virtual (memq 'virtual
6206 (assoc (symbol-name (car (gnus-find-method-for-group
6208 gnus-valid-select-methods)))
6209 name entry read info xref-hashtb idlist active num range exps method
6212 (set-buffer gnus-group-buffer)
6213 (if (setq xref-hashtb
6214 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6217 (if (string= from-newsgroup (setq name (symbol-name group)))
6219 (setq idlist (symbol-value group))
6220 ;; Dead groups are not updated.
6222 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
6224 (if (stringp (setq nth4 (nth 4 info)))
6225 (setq nth4 (gnus-server-to-method nth4))))
6226 ;; Only do the xrefs if the group has the same
6227 ;; select method as the group we have just read.
6228 (or (gnus-methods-equal-p
6229 nth4 (gnus-find-method-for-group from-newsgroup))
6232 (setq method (gnus-find-method-for-group
6234 (and (equal (car nth4) (car method))
6235 (equal (nth 1 nth4) (nth 1 method))))
6236 gnus-use-cross-reference
6237 (or (not (eq gnus-use-cross-reference t))
6239 ;; Only do cross-references on subscribed
6240 ;; groups, if that is what is wanted.
6241 (<= (nth 1 info) gnus-level-subscribed)))
6244 ;; Set the new list of read articles in this group.
6245 (setq active (gnus-gethash name gnus-active-hashtb))
6246 ;; First peel off all illegal article numbers.
6249 (ticked (cdr (assq 'tick (nth 3 info))))
6250 (dormant (cdr (assq 'dormant (nth 3 info))))
6255 (if (or (> id (cdr active))
6259 (setq idlist (delq id idlist)))
6260 (and (memq id expirable)
6261 (setq exps (cons id exps)))
6262 (setq ids (cdr ids)))))
6263 ;; Update expirable articles.
6264 (gnus-add-marked-articles nil 'expirable exps info)
6265 (and (null (nth 2 info))
6267 (setcar (nthcdr 2 info) (cons 1 (1- (car active)))))
6268 (setcar (nthcdr 2 info)
6272 (setq idlist (sort idlist '<)))))
6273 ;; Then we have to re-compute how many unread
6274 ;; articles there are in this group.
6279 (setq num (- (1+ (cdr active)) (car active))))
6280 ((not (listp (cdr range)))
6281 (setq num (- (cdr active) (- (1+ (cdr range))
6285 (if (numberp (car range))
6287 (setq num (+ num (- (1+ (cdr (car range)))
6288 (car (car range))))))
6289 (setq range (cdr range)))
6290 (setq num (- (cdr active) num))))
6291 ;; Update the number of unread articles.
6295 (length (cdr (assq 'tick (nth 3 info))))
6297 (cdr (assq 'dormant (nth 3 info)))))))
6298 ;; Update the group buffer.
6299 (gnus-group-update-group name t)))))))
6302 (defun gnus-methods-equal-p (m1 m2)
6303 (let ((m1 (or m1 gnus-select-method))
6304 (m2 (or m2 gnus-select-method)))
6306 (and (eq (car m1) (car m2))
6307 (or (not (memq 'address (assoc (symbol-name (car m1))
6308 gnus-valid-select-methods)))
6309 (equal (nth 1 m1) (nth 1 m2)))))))
6311 (defsubst gnus-header-value ()
6312 (buffer-substring (match-end 0) (gnus-point-at-eol)))
6314 (defun gnus-get-newsgroup-headers ()
6315 (setq gnus-article-internal-prepare-hook nil)
6316 (let ((cur nntp-server-buffer)
6317 (dependencies gnus-newsgroup-dependencies)
6319 headers char article id dep end)
6321 (set-buffer nntp-server-buffer)
6322 (goto-char (point-min))
6323 ;; Search to the beginning of the next header. Error messages
6324 ;; do not begin with 2 or 3.
6325 (while (re-search-forward "^[23][0-9]+ " nil t)
6326 (let ((header (make-vector 9 nil))
6327 (c (following-char))
6328 (case-fold-search t)
6330 from subject in-reply-to references ref)
6336 (header-set-number header (setq article (read cur)))
6337 ;; This implementation of this function, with nine
6338 ;; search-forwards instead of the one re-search-forward and
6339 ;; a case (which basically was the old function) is actually
6340 ;; about twice as fast, even though it looks messier. You
6341 ;; can't have everything, I guess. Speed and elegance
6342 ;; doesn't always come hand in hand.
6344 (narrow-to-region (point) (save-excursion
6345 (search-forward "\n.\n" nil t)))
6346 (if (search-forward "\nfrom: " nil t)
6347 (header-set-from header (gnus-header-value))
6348 (header-set-from header "(nobody)"))
6350 (if (search-forward "\nsubject: " nil t)
6351 (header-set-subject header (gnus-header-value))
6352 (header-set-subject header "(none)"))
6354 (and (search-forward "\nxref: " nil t)
6355 (header-set-xref header (gnus-header-value)))
6357 (or (numberp (and (search-forward "\nlines: " nil t)
6358 (header-set-lines header (read cur))))
6359 (header-set-lines header 0))
6361 (and (search-forward "\ndate: " nil t)
6362 (header-set-date header (gnus-header-value)))
6364 (if (search-forward "\nmessage-id: " nil t)
6365 (header-set-id header (setq id (gnus-header-value)))
6366 ;; If there was no message-id, we just fake one to make
6367 ;; subsequent routines simpler.
6370 (setq id (concat "none+" (int-to-string
6371 (setq none-id (1+ none-id)))))))
6373 (if (search-forward "\nreferences: " nil t)
6375 (header-set-references header (gnus-header-value))
6376 (setq end (match-end 0))
6383 (search-backward ">" end t)
6386 (search-backward "<" end t)
6388 ;; Get the references from the in-reply-to header if there
6389 ;; ware no references and the in-reply-to header looks
6391 (if (and (search-forward "\nin-reply-to: " nil t)
6392 (setq in-reply-to (gnus-header-value))
6393 (string-match "<[^>]+>" in-reply-to))
6395 (header-set-references
6397 (setq ref (substring in-reply-to (match-beginning 0)
6399 (setq ref (downcase ref)))
6401 ;; We do some threading while we read the headers. The
6402 ;; message-id and the last reference are both entered into
6403 ;; the same hash table. Some tippy-toeing around has to be
6404 ;; done in case an article has arrived before the article
6405 ;; which it refers to.
6406 (if (boundp (setq dep (intern (downcase id) dependencies)))
6407 (if (car (symbol-value dep))
6408 ;; An article with this Message-ID has already
6409 ;; been seen, so we ignore this one, except we add
6410 ;; any additional Xrefs (in case the two articles
6411 ;; came from different servers.
6414 (car (symbol-value dep))
6415 (concat (or (header-xref (car (symbol-value dep))) "")
6416 (or (header-xref header) "")))
6418 (setcar (symbol-value dep) header))
6419 (set dep (list header)))
6422 (if (boundp (setq dep (intern ref dependencies)))
6423 (setcdr (symbol-value dep)
6424 (cons header (cdr (symbol-value dep))))
6425 (set dep (list nil header)))
6426 (setq headers (cons header headers))))
6427 (goto-char (point-max))))))
6428 (nreverse headers)))
6430 ;; The following macros and functions were written by Felix Lee
6431 ;; <flee@cse.psu.edu>.
6433 (defmacro gnus-nov-read-integer ()
6435 (if (= (following-char) ?\t)
6437 (let ((num (read buffer)))
6438 (if (numberp num) num 0)))
6439 (or (eobp) (forward-char 1))))
6441 (defmacro gnus-nov-skip-field ()
6442 '(search-forward "\t" eol 'move))
6444 (defmacro gnus-nov-field ()
6445 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
6447 ;; Goes through the xover lines and returns a list of vectors
6448 (defun gnus-get-newsgroup-headers-xover (sequence)
6449 "Parse the news overview data in the server buffer, and return a
6450 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
6451 ;; Get the Xref when the users reads the articles since most/some
6452 ;; NNTP servers do not include Xrefs when using XOVER.
6453 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6454 (let ((cur nntp-server-buffer)
6455 (dependencies gnus-newsgroup-dependencies)
6457 number headers header)
6459 (set-buffer nntp-server-buffer)
6460 (goto-char (point-min))
6461 (while (and sequence (not (eobp)))
6462 (setq number (read cur))
6463 (while (and sequence (< (car sequence) number))
6464 (setq sequence (cdr sequence)))
6466 (eq number (car sequence))
6468 (setq sequence (cdr sequence))
6470 (inline (gnus-nov-parse-line number dependencies)))
6471 (setq headers (cons header headers)))))
6473 (setq headers (nreverse headers)))
6476 ;; This function has to be called with point after the article number
6477 ;; on the beginning of the line.
6478 (defun gnus-nov-parse-line (number dependencies)
6480 (eol (gnus-point-at-eol))
6481 (buffer (current-buffer))
6484 ;; overview: [num subject from date id refs chars lines misc]
6485 (narrow-to-region (point) eol)
6492 (gnus-nov-field) ; subject
6493 (gnus-nov-field) ; from
6494 (gnus-nov-field) ; date
6495 (setq id (or (gnus-nov-field)
6498 (setq none (1+ none)))))) ; id
6501 (let ((beg (point)))
6502 (search-forward "\t" eol)
6503 (if (search-backward ">" beg t)
6509 (search-backward "<" beg t)
6512 (gnus-nov-field)) ; refs
6513 (gnus-nov-read-integer) ; chars
6514 (gnus-nov-read-integer) ; lines
6515 (if (= (following-char) ?\n)
6517 (gnus-nov-field)) ; misc
6525 ;; We build the thread tree.
6527 (if (boundp (setq dep (intern (downcase id) dependencies)))
6528 (if (car (symbol-value dep))
6529 ;; An article with this Message-ID has already been seen,
6530 ;; so we ignore this one, except we add any additional
6531 ;; Xrefs (in case the two articles came from different
6535 (car (symbol-value dep))
6536 (concat (or (header-xref (car (symbol-value dep))) "")
6537 (or (header-xref header) "")))
6539 (setcar (symbol-value dep) header))
6540 (set dep (list header))))
6543 (if (boundp (setq dep (intern (or ref "none")
6545 (setcdr (symbol-value dep)
6546 (cons header (cdr (symbol-value dep))))
6547 (set dep (list nil header)))))
6550 (defun gnus-article-get-xrefs ()
6551 "Fill in the Xref value in `gnus-current-headers', if necessary.
6552 This is meant to be called in `gnus-article-internal-prepare-hook'."
6553 (or (not gnus-use-cross-reference)
6554 (and (header-xref gnus-current-headers)
6555 (not (string= (header-xref gnus-current-headers) "")))
6556 (let ((case-fold-search t)
6559 (gnus-narrow-to-headers)
6560 (goto-char (point-min))
6561 (if (or (and (eq (downcase (following-char)) ?x)
6562 (looking-at "Xref:"))
6563 (search-forward "\nXref:" nil t))
6565 (goto-char (1+ (match-end 0)))
6566 (setq xref (buffer-substring (point)
6567 (progn (end-of-line) (point))))
6569 (set-buffer gnus-summary-buffer)
6570 (header-set-xref gnus-current-headers xref))))))))
6572 (defalias 'gnus-find-header-by-number 'gnus-get-header-by-number)
6573 (make-obsolete 'gnus-find-header-by-number 'gnus-get-header-by-number)
6575 ;; Return a header specified by a NUMBER.
6576 (defun gnus-get-header-by-number (number)
6578 (set-buffer gnus-summary-buffer)
6579 (or gnus-newsgroup-headers-hashtb-by-number
6580 (gnus-make-headers-hashtable-by-number))
6581 (gnus-gethash (int-to-string number)
6582 gnus-newsgroup-headers-hashtb-by-number)))
6584 (defun gnus-make-headers-hashtable-by-number ()
6585 "Make hashtable for the variable gnus-newsgroup-headers by number."
6587 (set-buffer gnus-summary-buffer)
6588 (let ((headers gnus-newsgroup-headers)
6590 (setq gnus-newsgroup-headers-hashtb-by-number
6591 (gnus-make-hashtable (length headers)))
6593 (setq header (car headers))
6594 (gnus-sethash (int-to-string (header-number header))
6595 header gnus-newsgroup-headers-hashtb-by-number)
6596 (setq headers (cdr headers))))))
6598 (defun gnus-more-header-backward ()
6599 "Find new header backward."
6600 (let ((first (car (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6601 (artnum gnus-newsgroup-begin)
6603 (while (and (not header)
6605 (setq artnum (1- artnum))
6606 (setq header (gnus-read-header artnum)))
6609 (defun gnus-more-header-forward (&optional backward)
6610 "Find new header forward.
6611 If BACKWARD, find new header backward instead."
6613 (gnus-more-header-backward)
6614 (let ((last (cdr (gnus-gethash gnus-newsgroup-name gnus-active-hashtb)))
6615 (artnum gnus-newsgroup-end)
6617 (while (and (not header)
6619 (setq artnum (1+ artnum))
6620 (setq header (gnus-read-header artnum)))
6623 (defun gnus-extend-newsgroup (header &optional backward)
6624 "Extend newsgroup selection with HEADER.
6625 Optional argument BACKWARD means extend toward backward."
6627 (let ((artnum (header-number header)))
6628 (setq gnus-newsgroup-headers
6630 (cons header gnus-newsgroup-headers)
6631 (nconc gnus-newsgroup-headers (list header))))
6632 (setq gnus-newsgroup-unselected
6633 (delq artnum gnus-newsgroup-unselected))
6634 (setq gnus-newsgroup-begin (min gnus-newsgroup-begin artnum))
6635 (setq gnus-newsgroup-end (max gnus-newsgroup-end artnum)))))
6637 (defun gnus-summary-work-articles (n)
6638 "Return a list of articles to be worked upon. The prefix argument,
6639 the list of process marked articles, and the current article will be
6640 taken into consideration."
6642 (if (and n (numberp n))
6643 (let ((backward (< n 0))
6647 (setq articles (cons (gnus-summary-article-number)
6649 (gnus-summary-search-forward nil nil backward))
6651 (sort articles (function <)))
6652 (or (reverse gnus-newsgroup-processable)
6653 (list (gnus-summary-article-number))))))
6655 (defun gnus-summary-search-group (&optional backward use-level)
6656 "Search for next unread newsgroup.
6657 If optional argument BACKWARD is non-nil, search backward instead."
6659 (set-buffer gnus-group-buffer)
6661 ;; We don't want to alter current point of group mode buffer.
6662 (if (gnus-group-search-forward
6664 (if use-level (gnus-group-group-level) nil))
6665 (gnus-group-group-name)))))
6667 (defun gnus-summary-best-group (&optional exclude-group)
6668 "Find the name of the best unread group.
6669 If EXCLUDE-GROUP, do not go to this group."
6671 (set-buffer gnus-group-buffer)
6673 (gnus-group-best-unread-group exclude-group))))
6675 (defun gnus-summary-search-subject (&optional backward unread subject)
6676 "Search for article forward.
6677 If BACKWARD is non-nil, search backward.
6678 If UNREAD is non-nil, only unread articles are selected.
6679 If SUBJECT is non-nil, the article which has the same subject will be
6681 (let ((func (if backward 'previous-single-property-change
6682 'next-single-property-change))
6687 (and gnus-summary-check-current unread
6688 (eq (nth 1 (get-text-property (point) 'gnus)) gnus-unread-mark)
6692 (forward-char (if backward (if (bobp) 0 -1) (if (eobp) 0 1)))
6695 (setq pos (funcall func (point) 'gnus))
6696 (goto-char (if backward (1- pos) pos))
6700 (eq (nth 1 (get-text-property (point) 'gnus))
6703 (equal (gnus-simplify-subject-re subject)
6704 (gnus-simplify-subject-re
6705 (gnus-summary-subject-string)))))))
6706 (if backward (if (bobp) nil (forward-char -1) t)
6707 (if (eobp) nil (forward-char 1) t)))))
6709 (progn (goto-char beg) nil)
6711 (car (get-text-property (point) 'gnus))
6712 (gnus-summary-position-cursor)))))
6714 (defun gnus-summary-search-forward (&optional unread subject backward)
6715 "Search for article forward.
6716 If UNREAD is non-nil, only unread articles are selected.
6717 If SUBJECT is non-nil, the article which has the same subject will be
6719 If BACKWARD is non-nil, the search will be performed backwards instead."
6720 (gnus-summary-search-subject backward unread subject))
6722 (defun gnus-summary-search-backward (&optional unread subject)
6723 "Search for article backward.
6724 If 1st optional argument UNREAD is non-nil, only unread article is selected.
6725 If 2nd optional argument SUBJECT is non-nil, the article which has
6726 the same subject will be searched for."
6727 (gnus-summary-search-forward unread subject t))
6729 (defun gnus-summary-article-number (&optional number-or-nil)
6730 "The article number of the article on the current line.
6731 If there isn's an article number here, then we return the current
6734 (number (car (get-text-property
6735 (progn (beginning-of-line)
6736 (prog1 (point) (goto-char p)))
6738 (if number-or-nil number (or number gnus-current-article))))
6740 (defun gnus-summary-thread-level ()
6741 "The thread level of the article on the current line."
6742 (or (nth 2 (get-text-property (gnus-point-at-bol) 'gnus))
6745 (defun gnus-summary-pseudo-article ()
6746 "The thread level of the article on the current line."
6747 (get-text-property (gnus-point-at-bol) 'gnus-pseudo))
6749 (defun gnus-summary-article-mark ()
6750 "The mark on the current line."
6751 (nth 1 (get-text-property (gnus-point-at-bol) 'gnus)))
6753 (defun gnus-summary-subject-string ()
6754 "Return current subject string or nil if nothing."
6755 (let ((article (gnus-summary-article-number))
6758 (setq header (gnus-get-header-by-number article))
6760 (header-subject header))))
6762 (defalias 'gnus-summary-score 'gnus-summary-article-score)
6763 (make-obsolete 'gnus-summary-score 'gnus-summary-article-score)
6764 (defun gnus-summary-article-score ()
6765 "Return current article score."
6766 (or (cdr (assq (gnus-summary-article-number) gnus-newsgroup-scored))
6767 gnus-summary-default-score 0))
6769 ;; Written by Sudish Joseph <joseph@cis.ohio-state.edu>.
6770 (defun gnus-summary-recenter-new ()
6771 "Center point in the summary window.
6772 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6773 displayed, no centering will be performed."
6774 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6775 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6777 (and gnus-auto-center-summary
6778 (get-buffer-window gnus-article-buffer)
6779 (let* ((height (window-height))
6780 (w-end (window-end))
6781 (top (cond ((< height 4) 0)
6784 (and (= w-end (point-max))
6785 ;; adjust for blank lines at the bottom of the window
6786 (setq top (+ (count-lines (window-start) (point))
6787 (- height (count-lines (window-start) w-end) 2))))
6790 (defun gnus-summary-recenter ()
6791 "Center point in the summary window.
6792 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6793 displayed, no centering will be performed."
6794 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6795 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6796 (let* ((top (cond ((< (window-height) 4) 0)
6797 ((< (window-height) 6) 1)
6799 (height (1- (window-height)))
6800 (bottom (save-excursion (goto-char (point-max))
6801 (forward-line (- height))
6803 (window (get-buffer-window (current-buffer))))
6805 ;; The user has to want it,
6806 gnus-auto-center-summary
6807 ;; the article buffer must be displayed,
6808 (get-buffer-window gnus-article-buffer)
6809 ;; Set the window start to either `bottom', which is the biggest
6810 ;; possible valid number, or the second line from the top,
6811 ;; whichever is the least.
6813 window (min bottom (save-excursion (forward-line (- top)) (point)))))))
6815 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
6816 (defun gnus-short-group-name (newsgroup)
6817 "Convert a long group name to an initialized form.
6818 The last part of the name is left intact: \"rec.arts.anime\" becomes
6822 (if (string-match "\\." newsgroup)
6824 (setq name (concat name (substring newsgroup 0 1))
6825 newsgroup (substring newsgroup (match-end 0))
6826 name (concat name ".")))
6827 (setq name (concat name newsgroup)
6832 (defun gnus-summary-jump-to-group (newsgroup)
6833 "Move point to NEWSGROUP in group mode buffer."
6834 ;; Keep update point of group mode buffer if visible.
6835 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6836 (save-window-excursion
6837 ;; Take care of tree window mode.
6838 (if (get-buffer-window gnus-group-buffer)
6839 (pop-to-buffer gnus-group-buffer))
6840 (gnus-group-jump-to-group newsgroup))
6842 ;; Take care of tree window mode.
6843 (if (get-buffer-window gnus-group-buffer)
6844 (pop-to-buffer gnus-group-buffer)
6845 (set-buffer gnus-group-buffer))
6846 (gnus-group-jump-to-group newsgroup))))
6848 ;; This function returns a list of article numbers based on the
6849 ;; difference between the ranges of read articles in this group and
6850 ;; the range of active articles.
6851 (defun gnus-list-of-unread-articles (group)
6852 (let* ((read (nth 2 (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
6853 (active (gnus-gethash group gnus-active-hashtb))
6855 unread first nlast unread)
6856 ;; If none are read, then all are unread.
6858 (setq first (car active))
6859 ;; If the range of read articles is a single range, then the
6860 ;; first unread article is the article after the last read
6861 ;; article. Sounds logical, doesn't it?
6862 (if (not (listp (cdr read)))
6863 (setq first (1+ (cdr read)))
6864 ;; `read' is a list of ranges.
6865 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
6866 (car (car read)))) 1)
6870 (while (< first nlast)
6871 (setq unread (cons first unread))
6872 (setq first (1+ first))))
6873 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
6874 (setq nlast (if (atom (car (cdr read)))
6876 (car (car (cdr read)))))
6877 (setq read (cdr read)))))
6878 ;; And add the last unread articles.
6879 (while (<= first last)
6880 (setq unread (cons first unread))
6881 (setq first (1+ first)))
6882 ;; Return the list of unread articles.
6885 (defun gnus-list-of-read-articles (group)
6886 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
6887 (active (gnus-gethash group gnus-active-hashtb)))
6889 (gnus-sorted-complement
6890 (gnus-uncompress-range active)
6891 (gnus-list-of-unread-articles (nth 2 info))))))
6893 ;; Various summary commands
6895 (defun gnus-summary-universal-argument ()
6896 "Perform any operation on all articles marked with the process mark."
6898 (gnus-set-global-variables)
6899 (let ((articles (reverse gnus-newsgroup-processable))
6901 (or articles (error "No articles marked"))
6902 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
6903 (error "Undefined key"))
6905 (gnus-summary-goto-subject (car articles))
6906 (command-execute func)
6907 (gnus-summary-remove-process-mark (car articles))
6908 (setq articles (cdr articles)))))
6910 (defun gnus-summary-toggle-truncation (arg)
6911 "Toggle truncation of summary lines.
6912 With arg, turn line truncation on iff arg is positive."
6914 (setq truncate-lines
6915 (if (null arg) (not truncate-lines)
6916 (> (prefix-numeric-value arg) 0)))
6919 (defun gnus-summary-reselect-current-group (all)
6920 "Once exit and then reselect the current newsgroup.
6921 The prefix argument ALL means to select all articles."
6923 (gnus-set-global-variables)
6924 (let ((current-subject (gnus-summary-article-number))
6925 (group gnus-newsgroup-name))
6926 (setq gnus-newsgroup-threads nil)
6927 (gnus-summary-exit t)
6928 ;; We have to adjust the point of group mode buffer because the
6929 ;; current point was moved to the next unread newsgroup by
6931 (gnus-summary-jump-to-group group)
6932 (gnus-group-read-group all t)
6933 (gnus-summary-goto-subject current-subject)))
6935 (defun gnus-summary-rescan-group (all)
6936 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6938 (gnus-set-global-variables)
6939 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
6940 (let ((group gnus-newsgroup-name))
6942 (gnus-summary-jump-to-group group)
6944 (set-buffer gnus-group-buffer)
6945 (gnus-group-get-new-news-this-group 1))
6946 (gnus-summary-jump-to-group group)
6947 (gnus-group-read-group all)))
6949 (defun gnus-summary-update-info ()
6950 (let* ((group gnus-newsgroup-name)
6951 (method (car (gnus-find-method-for-group group))))
6952 (if gnus-newsgroup-kill-headers
6953 (setq gnus-newsgroup-killed
6954 (gnus-compress-sequence
6956 (gnus-set-sorted-intersection
6957 (gnus-uncompress-range gnus-newsgroup-killed)
6958 (setq gnus-newsgroup-unselected
6959 (sort gnus-newsgroup-unselected '<)))
6960 (setq gnus-newsgroup-unreads
6961 (sort gnus-newsgroup-unreads '<))) t)))
6962 (or (listp (cdr gnus-newsgroup-killed))
6963 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6965 (headers gnus-newsgroup-headers))
6966 (gnus-close-group group)
6967 (run-hooks 'gnus-exit-group-hook)
6968 (gnus-update-read-articles
6969 group gnus-newsgroup-unreads gnus-newsgroup-unselected
6970 gnus-newsgroup-marked
6971 t gnus-newsgroup-replied gnus-newsgroup-expirable
6972 gnus-newsgroup-killed gnus-newsgroup-dormant
6973 gnus-newsgroup-bookmarks
6974 (and gnus-save-score gnus-newsgroup-scored))
6975 (and gnus-use-cross-reference
6976 (gnus-mark-xrefs-as-read
6977 group headers gnus-newsgroup-unreads gnus-newsgroup-expirable))
6978 ;; Do adaptive scoring, and possibly save score files.
6979 (and gnus-newsgroup-adaptive
6980 (gnus-score-adaptive))
6981 (and (fboundp 'gnus-score-save)
6982 (funcall 'gnus-score-save))
6983 ;; Do not switch windows but change the buffer to work.
6984 (set-buffer gnus-group-buffer)
6985 (or (eq 'nndigest method)
6986 (gnus-group-update-group group)))))
6988 (defun gnus-summary-exit (&optional temporary)
6989 "Exit reading current newsgroup, and then return to group selection mode.
6990 gnus-exit-group-hook is called with no arguments if that value is non-nil."
6992 (gnus-set-global-variables)
6993 (gnus-kill-save-kill-buffer)
6994 (let* ((group gnus-newsgroup-name)
6995 (quit-buffer (cdr (assoc 'quit-buffer (gnus-find-method-for-group
6996 gnus-newsgroup-name))))
6998 (method (car (gnus-find-method-for-group group)))
6999 (buf (current-buffer)))
7000 (gnus-summary-update-info) ; Make all changes in this group permanent.
7001 ;; Make sure where I was, and go to next newsgroup.
7002 (if (eq method 'nndigest)
7004 (gnus-group-jump-to-group group)
7005 (gnus-group-next-unread-group 1))
7008 ;; We set all buffer-local variables to nil. It is unclear why
7009 ;; this is needed, but if we don't, buffer-local variables are
7010 ;; not garbage-collected, it seems. This would the lead to en
7011 ;; ever-growing Emacs.
7013 (gnus-summary-clear-local-variables)
7014 ;; We clear the global counterparts of the buffer-local
7015 ;; variables as well, just to be on the safe side.
7016 (gnus-configure-windows 'group)
7017 (gnus-summary-clear-local-variables)
7018 ;; Return to group mode buffer.
7019 (if (eq mode 'gnus-summary-mode)
7020 (gnus-kill-buffer buf))
7021 (if (get-buffer gnus-article-buffer)
7022 (bury-buffer gnus-article-buffer))
7023 (setq gnus-current-select-method gnus-select-method)
7024 (pop-to-buffer gnus-group-buffer)
7025 (if (eq method 'nndigest)
7027 (gnus-group-jump-to-group group)
7028 (gnus-group-next-unread-group 1))
7029 (if (gnus-buffer-exists-p quit-buffer)
7031 (switch-to-buffer quit-buffer)
7032 (gnus-set-global-variables)
7033 (gnus-configure-windows 'summary))))))
7035 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7036 (defun gnus-summary-exit-no-update (&optional no-questions)
7037 "Quit reading current newsgroup without updating read article info."
7039 (let* ((group gnus-newsgroup-name)
7040 (quit-buffer (cdr (assoc 'quit-buffer
7041 (gnus-find-method-for-group group)))))
7042 (if (or no-questions
7044 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
7046 (gnus-close-group group)
7047 (gnus-summary-clear-local-variables)
7048 (set-buffer gnus-group-buffer)
7049 (gnus-summary-clear-local-variables)
7050 ;; Return to group selection mode.
7051 (gnus-configure-windows 'group)
7052 (if (get-buffer gnus-summary-buffer)
7053 (kill-buffer gnus-summary-buffer))
7054 (if (get-buffer gnus-article-buffer)
7055 (bury-buffer gnus-article-buffer))
7056 (if (equal (gnus-group-group-name) group)
7057 (gnus-group-next-unread-group 1))
7058 (if (gnus-buffer-exists-p quit-buffer)
7060 (switch-to-buffer quit-buffer)
7061 (gnus-configure-windows 'summary)))))))
7063 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7064 (defun gnus-summary-fetch-faq (group)
7065 "Fetch the FAQ for the current group."
7066 (interactive (list gnus-newsgroup-name))
7067 (gnus-configure-windows 'summary-faq)
7068 (find-file (concat gnus-group-faq-directory group)))
7070 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7071 (defun gnus-summary-describe-group (force)
7072 "Describe the current newsgroup."
7074 (gnus-group-describe-group force gnus-newsgroup-name))
7076 (defun gnus-summary-describe-briefly ()
7077 "Describe summary mode commands briefly."
7080 (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")))
7082 ;; Walking around group mode buffer from summary mode.
7084 (defun gnus-summary-next-group (&optional no-article group backward)
7085 "Exit current newsgroup and then select next unread newsgroup.
7086 If prefix argument NO-ARTICLE is non-nil, no article is selected initially.
7087 If BACKWARD, go to previous group instead."
7089 (gnus-set-global-variables)
7090 (let ((ingroup gnus-newsgroup-name)
7091 (sumbuf (current-buffer))
7093 (gnus-summary-exit t) ;Update all information.
7095 (or (and (numberp (setq num (car (gnus-gethash
7096 group gnus-newsrc-hashtb))))
7100 (gnus-group-jump-to-group group)
7102 (gnus-group-jump-to-group ingroup))
7103 (gnus-summary-search-group backward)
7104 (let ((group (or group (gnus-summary-search-group backward)))
7105 (buf gnus-summary-buffer))
7107 (gnus-summary-exit-no-update t)
7108 (gnus-message 5 "Selecting %s..." group)
7109 ;; We are now in group mode buffer.
7110 ;; Make sure group mode buffer point is on GROUP.
7111 (gnus-group-jump-to-group group)
7112 (if (not (eq gnus-auto-select-next 'quietly))
7114 (gnus-summary-read-group group nil no-article buf)
7115 (and (string= gnus-newsgroup-name ingroup)
7116 (bufferp sumbuf) (buffer-name sumbuf)
7118 (set-buffer (setq gnus-summary-buffer sumbuf))
7119 (gnus-summary-exit-no-update t))))
7120 (gnus-summary-read-group group nil no-article buf)
7121 (while (and (string= gnus-newsgroup-name ingroup)
7122 (bufferp sumbuf) (buffer-name sumbuf))
7123 (set-buffer gnus-group-buffer)
7124 (gnus-group-next-unread-group 1)
7126 (gnus-summary-read-group
7127 (gnus-group-group-name) nil no-article buf)))))))
7129 (defun gnus-summary-prev-group (no-article)
7130 "Exit current newsgroup and then select previous unread newsgroup.
7131 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7133 (gnus-summary-next-group no-article nil t))
7135 ;; Walking around summary lines.
7137 (defun gnus-summary-first-subject (unread)
7138 "Go to the first unread subject.
7139 If UNREAD is non-nil, go to the first unread article.
7140 Returns nil if there are no unread articles."
7142 (let ((begin (point)))
7143 (goto-char (point-min))
7146 (while (and (not (eq (nth 1 (get-text-property (point) 'gnus))
7148 (zerop (forward-line 1))))
7152 ;; If there is no unread articles, stay where you are.
7154 (gnus-message 3 "No more unread articles")
7156 (gnus-summary-position-cursor)))))
7158 (defun gnus-summary-next-subject (n &optional unread dont-display)
7159 "Go to next N'th summary line.
7160 If N is negative, go to the previous N'th subject line.
7161 If UNREAD is non-nil, only unread articles are selected.
7162 The difference between N and the actual number of steps taken is
7165 (let ((backward (< n 0))
7168 (gnus-summary-search-forward unread nil backward))
7170 (if (/= 0 n) (gnus-message 7 "No more%s articles"
7171 (if unread " unread" "")))
7174 (gnus-summary-recenter)
7175 (gnus-summary-position-cursor)))
7178 (defun gnus-summary-next-unread-subject (n)
7179 "Go to next N'th unread summary line."
7181 (gnus-summary-next-subject n t))
7183 (defun gnus-summary-prev-subject (n &optional unread)
7184 "Go to previous N'th summary line.
7185 If optional argument UNREAD is non-nil, only unread article is selected."
7187 (gnus-summary-next-subject (- n) unread))
7189 (defun gnus-summary-prev-unread-subject (n)
7190 "Go to previous N'th unread summary line."
7192 (gnus-summary-next-subject (- n) t))
7194 (defun gnus-summary-goto-subject (article)
7195 "Go the subject line of ARTICLE."
7199 (completing-read "Article number: "
7203 (int-to-string (header-number headers))))
7204 gnus-newsgroup-headers)
7205 nil 'require-match))))
7206 (or article (error "No article number"))
7208 (goto-char (point-min))
7209 (while (and (not (eq (car (get-text-property (point) 'gnus)) article))
7210 (zerop (forward-line 1))))
7211 ;; Skip dummy articles.
7212 (if (eq (gnus-summary-article-mark) ?Z)
7219 (gnus-summary-position-cursor))))
7221 ;; Walking around summary lines with displaying articles.
7223 (defun gnus-summary-expand-window ()
7224 "Expand summary window to show headers full window."
7226 (gnus-set-global-variables)
7227 (gnus-configure-windows 'summary))
7229 (defun gnus-summary-display-article (article &optional all-header)
7230 "Display ARTICLE in article buffer."
7231 (gnus-set-global-variables)
7234 (gnus-article-prepare article all-header)
7235 (if (eq (gnus-summary-article-mark) ?Z)
7238 (gnus-summary-position-cursor)))
7239 (run-hooks 'gnus-select-article-hook)
7240 (gnus-summary-recenter)
7241 ; (set-window-point (get-buffer-window (current-buffer)) (point-max))
7243 (gnus-summary-goto-subject article)
7244 ;; Successfully display article.
7245 (gnus-summary-update-line)
7246 (let ((bookmark (cdr (assq article gnus-newsgroup-bookmarks))))
7248 (get-buffer-window gnus-article-buffer)
7250 (set-buffer gnus-article-buffer)
7251 (goto-char (point-min))
7253 (gnus-message 6 "Moved to bookmark")
7254 (search-forward "\n\n" nil t)
7255 (forward-line bookmark)
7261 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7262 "Select the current article.
7263 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7264 non-nil, the article will be re-fetched even if it already present in
7265 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7267 (and (not pseudo) (gnus-summary-pseudo-article)
7268 (error "This is a pseudo-article."))
7269 (let ((article (or article (gnus-summary-article-number)))
7270 (all-headers (not (not all-headers)))) ;Must be T or NIL.
7273 (set-buffer gnus-summary-buffer)
7274 (if (or (null gnus-current-article)
7275 (null gnus-article-current)
7276 (not (eq article (cdr gnus-article-current)))
7277 (not (equal (car gnus-article-current) gnus-newsgroup-name))
7279 ;; The requested article is different from the current article.
7281 (gnus-summary-display-article article all-headers)
7282 (gnus-configure-windows 'article)
7284 (if all-headers (gnus-article-show-all-headers))
7285 (gnus-configure-windows 'article)
7287 (let ((bookmark (cdr (assq article gnus-newsgroup-bookmarks))))
7289 (get-buffer-window gnus-article-buffer)
7291 (set-buffer gnus-article-buffer)
7292 (goto-char (point-min))
7294 (gnus-message 6 "Moved to bookmark")
7295 (search-forward "\n\n" nil t)
7296 (forward-line bookmark)
7301 (defun gnus-summary-set-current-mark (&optional current-mark)
7302 "Obsolete function."
7305 (defun gnus-summary-next-article (unread &optional subject backward)
7306 "Select the next article.
7307 If UNREAD, only unread articles are selected.
7308 If SUBJECT, only articles with SUBJECT are selected.
7309 If BACKWARD, the previous article is selected instead of the next."
7311 (let ((opoint (point))
7312 (method (car (gnus-find-method-for-group gnus-newsgroup-name)))
7315 ;; Is there such an article?
7316 ((gnus-summary-display-article
7317 (gnus-summary-search-forward unread subject backward))
7318 (gnus-summary-position-cursor))
7319 ;; If not, we try the first unread, if that is wanted.
7321 gnus-auto-select-same
7322 (gnus-summary-first-unread-article))
7323 (gnus-message 6 "Wrapped"))
7324 ;; Try to get next/previous article not displayed in this group.
7325 ((and gnus-auto-extend-newsgroup
7326 (not unread) (not subject)
7327 (setq header (gnus-more-header-forward backward)))
7328 (gnus-extend-newsgroup header backward)
7329 (let ((buffer-read-only nil))
7330 (goto-char (if backward (point-min) (point-max)))
7331 (gnus-summary-prepare-threads (list header) 0))
7332 (gnus-summary-goto-article (if backward gnus-newsgroup-begin
7333 gnus-newsgroup-end)))
7334 ;; Go to next/previous group.
7336 (or (eq method 'nndigest)
7337 (gnus-summary-jump-to-group gnus-newsgroup-name))
7338 (let ((cmd (aref (this-command-keys) 0))
7340 (if (eq gnus-keep-same-level 'best)
7341 (gnus-summary-best-group gnus-newsgroup-name)
7342 (gnus-summary-search-group backward gnus-keep-same-level))))
7343 ;; Keep just the event type of CMD.
7344 (and (listp cmd) (setq cmd (car cmd)))
7345 ;; Select next unread newsgroup automagically.
7347 ((not gnus-auto-select-next)
7348 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7349 ((eq gnus-auto-select-next 'quietly)
7351 (if (eq method 'nndigest)
7353 (gnus-message 7 "No more%s articles (%s)..."
7354 (if unread " unread" "")
7355 (if group (concat "selecting " group)
7357 (gnus-summary-next-group nil group backward)))
7359 (let ((keystrokes '(?\C-n ?\C-p))
7361 (while (or (null key) (memq key keystrokes))
7363 7 "No more%s articles%s" (if unread " unread" "")
7364 (if (and group (not (eq method 'nndigest)))
7365 (format " (Type %s for %s [%s])"
7366 (single-key-description cmd) group
7367 (car (gnus-gethash group gnus-newsrc-hashtb)))
7368 (format " (Type %s to exit %s)"
7369 (single-key-description cmd)
7370 gnus-newsgroup-name)))
7371 ;; Confirm auto selection.
7372 (let* ((event (read-event)))
7373 (setq key (if (listp event) (car event) event))
7374 (if (member key keystrokes)
7375 (let ((obuf (current-buffer)))
7376 (switch-to-buffer gnus-group-buffer)
7377 (gnus-group-jump-to-group group)
7378 (execute-kbd-macro (char-to-string key))
7379 (setq group (gnus-group-group-name))
7380 (switch-to-buffer obuf)))))
7382 (if (or (not group) (eq method 'nndigest))
7384 (gnus-summary-next-group nil group backward))
7385 (setq unread-command-events (list key)))))))))))
7387 (defun gnus-summary-next-unread-article ()
7388 "Select unread article after current one."
7390 (gnus-summary-next-article t (and gnus-auto-select-same
7391 (gnus-summary-subject-string))))
7393 (defun gnus-summary-prev-article (unread &optional subject)
7394 "Select the article after the current one.
7395 If UNREAD is non-nil, only unread articles are selected."
7397 (gnus-summary-next-article unread subject t))
7399 (defun gnus-summary-prev-unread-article ()
7400 "Select unred article before current one."
7402 (gnus-summary-prev-article t (and gnus-auto-select-same
7403 (gnus-summary-subject-string))))
7405 (defun gnus-summary-next-page (lines &optional circular)
7406 "Show next page of selected article.
7407 If end of article, select next article.
7408 Argument LINES specifies lines to be scrolled up.
7409 If CIRCULAR is non-nil, go to the start of the article instead of
7410 instead of selecting the next article when reaching the end of the
7413 (setq gnus-summary-buffer (current-buffer))
7414 (gnus-set-global-variables)
7415 (let ((article (gnus-summary-article-number))
7417 (if (or (null gnus-current-article)
7418 (null gnus-article-current)
7419 (/= article (cdr gnus-article-current))
7420 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7421 ;; Selected subject is different from current article's.
7422 (gnus-summary-display-article article)
7423 (gnus-configure-windows 'article)
7424 (gnus-eval-in-buffer-window
7426 (setq endp (gnus-article-next-page lines)))
7429 (gnus-summary-beginning-of-article))
7431 (gnus-message 3 "End of message"))
7433 (gnus-summary-next-unread-article))))
7434 (and gnus-summary-buffer
7435 (buffer-name gnus-summary-buffer)
7437 (pop-to-buffer gnus-summary-buffer)
7438 (gnus-summary-position-cursor))))))
7440 (defun gnus-summary-prev-page (lines)
7441 "Show previous page of selected article.
7442 Argument LINES specifies lines to be scrolled down."
7444 (let ((article (gnus-summary-article-number)))
7445 (if (or (null gnus-current-article)
7446 (null gnus-article-current)
7447 (/= article (cdr gnus-article-current))
7448 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7449 ;; Selected subject is different from current article's.
7450 (gnus-summary-display-article article)
7451 (gnus-configure-windows 'article)
7452 (gnus-eval-in-buffer-window gnus-article-buffer
7453 (gnus-article-prev-page lines))))
7454 (gnus-summary-position-cursor))
7456 (defun gnus-summary-scroll-up (lines)
7457 "Scroll up (or down) one line current article.
7458 Argument LINES specifies lines to be scrolled up (or down if negative)."
7460 (or (gnus-summary-select-article nil nil 'pseudo)
7461 (gnus-eval-in-buffer-window
7464 (if (gnus-article-next-page lines)
7465 (gnus-message 3 "End of message")))
7467 (gnus-article-prev-page (- lines))))))
7468 (gnus-summary-position-cursor))
7470 (defun gnus-summary-next-same-subject ()
7471 "Select next article which has the same subject as current one."
7473 (gnus-summary-next-article nil (gnus-summary-subject-string)))
7475 (defun gnus-summary-prev-same-subject ()
7476 "Select previous article which has the same subject as current one."
7478 (gnus-summary-prev-article nil (gnus-summary-subject-string)))
7480 (defun gnus-summary-next-unread-same-subject ()
7481 "Select next unread article which has the same subject as current one."
7483 (gnus-summary-next-article t (gnus-summary-subject-string)))
7485 (defun gnus-summary-prev-unread-same-subject ()
7486 "Select previous unread article which has the same subject as current one."
7488 (gnus-summary-prev-article t (gnus-summary-subject-string)))
7490 (defun gnus-summary-first-unread-article ()
7491 "Select the first unread article.
7492 Return nil if there are no unread articles."
7495 (if (gnus-summary-first-subject t)
7496 (gnus-summary-display-article (gnus-summary-article-number)))
7497 (gnus-summary-position-cursor)))
7499 (defun gnus-summary-best-unread-article ()
7500 "Select the unread article with the highest score."
7502 (gnus-set-global-variables)
7503 (let ((scored gnus-newsgroup-scored)
7507 (or (> best (cdr (car scored)))
7508 (and (memq (setq art (car (car scored))) gnus-newsgroup-unreads)
7509 (not (memq art gnus-newsgroup-marked))
7510 (not (memq art gnus-newsgroup-dormant))
7511 (if (= best (cdr (car scored)))
7512 (setq article (min art article))
7514 (setq best (cdr (car scored))))))
7515 (setq scored (cdr scored)))
7517 (gnus-summary-goto-article article)
7518 (gnus-summary-first-unread-article))
7519 (gnus-summary-position-cursor)))
7521 (defun gnus-summary-goto-article (article &optional all-headers)
7522 "Fetch ARTICLE and display it if it exists.
7523 If ALL-HEADERS is non-nil, no header lines are hidden."
7529 (mapcar (lambda (headers) (list (int-to-string (header-number headers))))
7530 gnus-newsgroup-headers)
7531 nil 'require-match))))
7533 (and (gnus-summary-goto-subject article)
7534 (gnus-summary-display-article article all-headers))
7535 (gnus-summary-position-cursor)))
7537 (defun gnus-summary-goto-last-article ()
7538 "Go to the last article."
7541 (and gnus-last-article
7542 (gnus-summary-goto-article gnus-last-article))
7543 (gnus-summary-position-cursor)))
7545 (defun gnus-summary-pop-article (number)
7546 "Pop one article off the history and go to the previous.
7547 NUMBER articles will be popped off."
7550 (setq gnus-newsgroup-history
7551 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7553 (gnus-summary-goto-article (car to))
7554 (error "Article history empty")))
7555 (gnus-summary-position-cursor))
7557 ;; Summary article oriented commands
7559 (defun gnus-summary-refer-parent-article (n)
7560 "Refer parent article N times.
7561 The difference between N and the number of articles fetched is returned."
7563 (gnus-set-global-variables)
7567 (let ((ref (header-references (gnus-get-header-by-number
7568 (gnus-summary-article-number)))))
7569 (if (and ref (not (equal ref ""))
7570 (string-match "<[^<>]*>[ \t]*$" ref))
7571 (gnus-summary-refer-article
7572 (substring ref (match-beginning 0) (match-end 0))))))
7575 (gnus-message 1 "No references in article or expired article."))
7576 (gnus-summary-position-cursor)
7579 (defun gnus-summary-refer-article (message-id)
7580 "Refer article specified by MESSAGE-ID.
7581 NOTE: This command only works with newsgroup that use NNTP."
7582 (interactive "sMessage-ID: ")
7583 (if (or (not (stringp message-id))
7584 (zerop (length message-id)))
7586 ;; Construct the correct Message-ID if necessary.
7587 ;; Suggested by tale@pawl.rpi.edu.
7588 (or (string-match "^<" message-id)
7589 (setq message-id (concat "<" message-id)))
7590 (or (string-match ">$" message-id)
7591 (setq message-id (concat message-id ">")))
7592 (let ((header (car (gnus-gethash (downcase message-id)
7593 gnus-newsgroup-dependencies))))
7595 (or (gnus-summary-goto-article (header-number header))
7596 ;; The header has been read, but the article had been
7597 ;; expunged, so we insert it again.
7599 (gnus-summary-insert-line
7600 nil header 0 nil gnus-read-mark nil nil
7601 (header-subject header))
7603 (header-number header)))
7604 (let ((gnus-override-method gnus-refer-article-method)
7605 (gnus-ancient-mark gnus-read-mark)
7607 (and gnus-refer-article-method
7608 (or (gnus-server-opened gnus-refer-article-method)
7609 (gnus-open-server gnus-refer-article-method)))
7610 (if (gnus-article-prepare
7611 message-id nil (gnus-read-header message-id))
7613 (setq number (header-number gnus-current-headers))
7614 (gnus-rebuild-thread message-id)
7615 (gnus-summary-goto-subject number)
7617 (gnus-message 1 "No such references")
7620 (defun gnus-summary-enter-digest-group ()
7621 "Enter a digest group based on the current article."
7623 (gnus-set-global-variables)
7624 (gnus-summary-select-article)
7625 (let ((name (format "%s/%d"
7626 (gnus-group-prefixed-name
7627 gnus-newsgroup-name (list 'nndigest ""))
7628 gnus-current-article))
7629 (buf (current-buffer)))
7630 (set-buffer gnus-group-buffer)
7633 (list t nil (list name gnus-level-default-subscribed nil nil
7634 (list 'nndigest gnus-article-buffer
7635 (cons 'quit-buffer buf))))
7638 (gnus-group-read-group t nil name)
7641 (if (not (equal major-mode 'gnus-group-mode))
7643 (switch-to-buffer buf)
7644 (gnus-set-global-variables)
7645 (gnus-configure-windows 'summary)
7646 (gnus-message 3 "Article not a digest?"))))
7648 (defun gnus-summary-isearch-article ()
7649 "Do incremental search forward on current article."
7651 (gnus-summary-select-article)
7652 (gnus-eval-in-buffer-window gnus-article-buffer
7655 (defun gnus-summary-search-article-forward (regexp)
7656 "Search for an article containing REGEXP forward.
7657 gnus-select-article-hook is not called during the search."
7660 (concat "Search forward (regexp): "
7661 (if gnus-last-search-regexp
7662 (concat "(default " gnus-last-search-regexp ") "))))))
7663 (if (string-equal regexp "")
7664 (setq regexp (or gnus-last-search-regexp ""))
7665 (setq gnus-last-search-regexp regexp))
7666 (if (gnus-summary-search-article regexp nil)
7667 (gnus-eval-in-buffer-window
7670 (error "Search failed: \"%s\"" regexp)))
7672 (defun gnus-summary-search-article-backward (regexp)
7673 "Search for an article containing REGEXP backward.
7674 gnus-select-article-hook is not called during the search."
7677 (concat "Search backward (regexp): "
7678 (if gnus-last-search-regexp
7679 (concat "(default " gnus-last-search-regexp ") "))))))
7680 (if (string-equal regexp "")
7681 (setq regexp (or gnus-last-search-regexp ""))
7682 (setq gnus-last-search-regexp regexp))
7683 (if (gnus-summary-search-article regexp t)
7684 (gnus-eval-in-buffer-window
7687 (error "Search failed: \"%s\"" regexp)))
7689 (defun gnus-summary-search-article (regexp &optional backward)
7690 "Search for an article containing REGEXP.
7691 Optional argument BACKWARD means do search for backward.
7692 gnus-select-article-hook is not called during the search."
7693 (let ((gnus-select-article-hook nil) ;Disable hook.
7694 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7697 (function re-search-backward) (function re-search-forward)))
7700 ;; Hidden thread subtrees must be searched for ,too.
7701 (gnus-summary-show-all-threads)
7702 (if (eobp) (forward-line -1))
7703 ;; First of all, search current article.
7704 ;; We don't want to read article again from NNTP server nor reset
7706 (gnus-summary-select-article)
7707 (gnus-message 9 "Searching article: %d..." gnus-current-article)
7708 (setq last gnus-current-article)
7709 (gnus-eval-in-buffer-window gnus-article-buffer
7712 ;; Begin search from current point.
7713 (setq found (funcall re-search regexp nil t))))
7714 ;; Then search next articles.
7715 (while (and (not found)
7716 (gnus-summary-display-article
7717 (gnus-summary-search-subject backward nil nil)))
7718 (gnus-message 9 "Searching article: %d..." gnus-current-article)
7719 (gnus-eval-in-buffer-window gnus-article-buffer
7722 (goto-char (if backward (point-max) (point-min)))
7723 (setq found (funcall re-search regexp nil t)))))
7725 ;; Adjust article pointer.
7726 (or (eq last gnus-current-article)
7727 (setq gnus-last-article last))
7728 ;; Return T if found such article.
7731 (defun gnus-summary-execute-command (header regexp command &optional backward)
7732 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7733 If HEADER is an empty string (or nil), the match is done on the entire
7734 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7736 (list (let ((completion-ignore-case t))
7739 (mapcar (lambda (string) (list string))
7740 '("Number" "Subject" "From" "Lines" "Date"
7741 "Message-ID" "Xref" "References"))
7742 nil 'require-match))
7743 (read-string "Regexp: ")
7744 (read-key-sequence "Command: ")
7745 current-prefix-arg))
7746 ;; Hidden thread subtrees must be searched as well.
7747 (gnus-summary-show-all-threads)
7748 ;; We don't want to change current point nor window configuration.
7750 (save-window-excursion
7751 (gnus-message 6 "Executing %s..." (key-description command))
7752 ;; We'd like to execute COMMAND interactively so as to give arguments.
7753 (gnus-execute header regexp
7755 (call-interactively '(, (key-binding command)))))
7757 (gnus-message 6 "Executing %s... done" (key-description command)))))
7759 (defun gnus-summary-beginning-of-article ()
7760 "Scroll the article back to the beginning."
7762 (gnus-summary-select-article)
7763 (gnus-eval-in-buffer-window
7766 (goto-char (point-min))
7767 (and gnus-break-pages (gnus-narrow-to-page))))
7769 (defun gnus-summary-end-of-article ()
7770 "Scroll to the end of the article."
7772 (gnus-summary-select-article)
7773 (gnus-eval-in-buffer-window
7776 (goto-char (point-max))
7777 (and gnus-break-pages (gnus-narrow-to-page))))
7779 (defun gnus-summary-show-article ()
7780 "Force re-fetching of the current article."
7782 (gnus-summary-select-article gnus-have-all-headers t))
7784 (defun gnus-summary-toggle-header (arg)
7785 "Show the headers if they are hidden, or hide them if they are shown.
7786 If ARG is a positive number, show the entire header.
7787 If ARG is a negative number, hide the unwanted header lines."
7789 (gnus-set-global-variables)
7791 (set-buffer gnus-article-buffer)
7792 (let ((buffer-read-only nil))
7794 (if (> arg 0) (remove-text-properties (point-min) (point-max)
7795 gnus-hidden-properties)
7796 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
7797 (if (text-property-any (point-min) (point-max) 'invisible t)
7798 (remove-text-properties (point-min) (point-max)
7799 gnus-hidden-properties)
7800 (let ((gnus-have-all-headers nil))
7801 (run-hooks 'gnus-article-display-hook))))
7802 (set-window-point (get-buffer-window (current-buffer)) (point-min)))))
7804 (defun gnus-summary-show-all-headers ()
7805 "Make all header lines visible."
7807 (gnus-article-show-all-headers))
7809 (defun gnus-summary-toggle-mime (arg)
7810 "Toggle MIME processing.
7811 If ARG is a positive number, turn MIME processing on."
7813 (setq gnus-show-mime
7814 (if (null arg) (not gnus-show-mime)
7815 (> (prefix-numeric-value arg) 0)))
7816 (gnus-summary-select-article t 'force))
7818 (defun gnus-summary-caesar-message (rotnum)
7819 "Caesar rotates all letters of current message by 13/47 places.
7820 With prefix arg, specifies the number of places to rotate each letter forward.
7821 Caesar rotates Japanese letters by 47 places in any case."
7823 (gnus-summary-select-article)
7824 (let ((mail-header-separator "")) ; !!! Is this necessary?
7825 (gnus-overload-functions)
7826 (gnus-eval-in-buffer-window
7830 ;; We don't want to jump to the beginning of the message.
7831 ;; `save-excursion' does not do its job.
7832 (move-to-window-line 0)
7833 (let ((last (point)))
7834 (news-caesar-buffer-body rotnum)
7838 (defun gnus-summary-stop-page-breaking ()
7839 "Stop page breaking in the current article."
7841 (gnus-summary-select-article)
7842 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
7844 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
7846 (defun gnus-summary-move-article (n &optional to-newsgroup select-method)
7847 "Move the current article to a different newsgroup.
7848 If N is a positive number, move the N next articles.
7849 If N is a negative number, move the N previous articles.
7850 If N is nil and any articles have been marked with the process mark,
7851 move those articles instead.
7852 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7853 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
7854 re-spool using this method.
7855 For this function to work, both the current newsgroup and the
7856 newsgroup that you want to move to have to support the `request-move'
7857 and `request-accept' functions. (Ie. mail newsgroups at present.)"
7859 (gnus-set-global-variables)
7860 (or (gnus-check-backend-function 'request-move-article gnus-newsgroup-name)
7861 (error "The current newsgroup does not support article moving"))
7862 (let ((articles (gnus-summary-work-articles n))
7863 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7865 (if (and (not to-newsgroup) (not select-method))
7868 (format "Where do you want to move %s? %s"
7869 (if (> (length articles) 1)
7870 (format "these %d articles" (length articles))
7872 (if gnus-current-move-group
7873 (format "(%s default) " gnus-current-move-group)
7875 gnus-active-hashtb nil nil prefix)))
7878 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
7879 (setq to-newsgroup (or gnus-current-move-group "")))
7880 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
7881 (gnus-activate-newsgroup to-newsgroup)
7882 (error "No such group: %s" to-newsgroup))
7883 (setq gnus-current-move-group to-newsgroup)))
7884 (or (gnus-check-backend-function 'request-accept-article
7885 (or select-method to-newsgroup))
7886 (error "%s does not support article moving" to-newsgroup))
7887 (gnus-message 6 "Moving to %s: %s..."
7888 (or select-method to-newsgroup) articles)
7891 (gnus-request-move-article
7892 (car articles) ; Article to move
7893 gnus-newsgroup-name ; From newsgrouo
7894 (nth 1 (gnus-find-method-for-group
7895 gnus-newsgroup-name)) ; Server
7896 (list 'gnus-request-accept-article
7898 (list 'quote select-method)
7900 (not (cdr articles))) ; Accept form
7901 (not (cdr articles)))) ; Only save nov last time
7902 (let* ((buffer-read-only nil)
7905 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
7907 (gnus-group-prefixed-name
7909 (if select-method (list select-method "")
7910 (gnus-find-method-for-group to-newsgroup)))
7911 gnus-newsrc-hashtb)))
7912 (info (nth 2 entry))
7913 (article (car articles))
7914 (marked (nth 3 info)))
7915 (gnus-summary-goto-subject article)
7917 (delete-region (point)
7918 (progn (forward-line 1) (point)))
7919 (if (not (memq article gnus-newsgroup-unreads))
7920 (setcar (cdr (cdr info))
7921 (gnus-add-to-range (nth 2 info)
7922 (list (cdr art-group)))))
7923 ;; Copy any marks over to the new group.
7924 (let ((marks '((tick . gnus-newsgroup-marked)
7925 (dormant . gnus-newsgroup-dormant)
7926 (expire . gnus-newsgroup-expirable)
7927 (bookmark . gnus-newsgroup-bookmarks)
7928 ; (score . gnus-newsgroup-scored)
7929 (reply . gnus-newsgroup-replied)))
7930 (to-article (cdr art-group)))
7932 (if (memq article (symbol-value (cdr (car marks))))
7933 (gnus-add-marked-articles
7934 (car info) (car (car marks)) (list to-article) info))
7935 (setq marks (cdr marks))))
7936 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7937 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7938 (setq gnus-newsgroup-dormant
7939 (delq article gnus-newsgroup-dormant)))
7940 (gnus-message 1 "Couldn't move article %s" (car articles)))
7941 (gnus-summary-remove-process-mark (car articles))
7942 (setq articles (cdr articles)))))
7944 (defun gnus-summary-respool-article (n &optional respool-method)
7945 "Respool the current article.
7946 The article will be squeezed through the mail spooling process again,
7947 which means that it will be put in some mail newsgroup or other
7948 depending on `nnmail-split-methods'.
7949 If N is a positive number, respool the N next articles.
7950 If N is a negative number, respool the N previous articles.
7951 If N is nil and any articles have been marked with the process mark,
7952 respool those articles instead.
7954 Respooling can be done both from mail groups and \"real\" newsgroups.
7955 In the former case, the articles in question will be moved from the
7956 current group into whatever groups they are destined to. In the
7957 latter case, they will be copied into the relevant groups."
7959 (gnus-set-global-variables)
7960 (let ((respool-methods (gnus-methods-using 'respool))
7962 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
7964 (setq respool-method
7966 "What method do you want to use when respooling? "
7967 respool-methods nil t methname)))
7968 (or (string= respool-method "")
7969 (if (assoc (symbol-name
7970 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7972 (gnus-summary-move-article n nil (intern respool-method))
7973 (gnus-summary-copy-article n nil (intern respool-method))))))
7975 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
7976 (defun gnus-summary-copy-article (n &optional to-newsgroup select-method)
7977 "Move the current article to a different newsgroup.
7978 If N is a positive number, move the N next articles.
7979 If N is a negative number, move the N previous articles.
7980 If N is nil and any articles have been marked with the process mark,
7981 move those articles instead.
7982 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7983 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
7984 re-spool using this method.
7985 For this function to work, the newsgroup that you want to move to have
7986 to support the `request-move' and `request-accept'
7987 functions. (Ie. mail newsgroups at present.)"
7989 (gnus-set-global-variables)
7990 (let ((articles (gnus-summary-work-articles n))
7991 (copy-buf (get-buffer-create "*copy work*"))
7992 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7994 (buffer-disable-undo copy-buf)
7995 (if (and (not to-newsgroup) (not select-method))
7998 (format "Where do you want to copy %s? %s"
7999 (if (> (length articles) 1)
8000 (format "these %d articles" (length articles))
8002 (if gnus-current-move-group
8003 (format "(%s default) " gnus-current-move-group)
8005 gnus-active-hashtb nil nil prefix)))
8008 (if (or (string= to-newsgroup "") (string= to-newsgroup prefix))
8009 (setq to-newsgroup (or gnus-current-move-group "")))
8010 (or (gnus-gethash to-newsgroup gnus-active-hashtb)
8011 (gnus-activate-newsgroup to-newsgroup)
8012 (error "No such group: %s" to-newsgroup))
8013 (setq gnus-current-move-group to-newsgroup)))
8014 (or (gnus-check-backend-function 'request-accept-article
8015 (or select-method to-newsgroup))
8016 (error "%s does not support article copying" to-newsgroup))
8017 (gnus-message 6 "Copying to %s: %s..."
8018 (or select-method to-newsgroup) articles)
8022 (set-buffer copy-buf)
8023 (gnus-request-article-this-buffer
8024 (car articles) gnus-newsgroup-name)
8025 (gnus-request-accept-article
8026 (if select-method (quote select-method) to-newsgroup)
8027 (not (cdr articles)))))
8030 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
8032 (gnus-group-prefixed-name
8034 (if select-method (list select-method "")
8035 (gnus-find-method-for-group to-newsgroup)))
8036 gnus-newsrc-hashtb)))
8037 (info (nth 2 entry))
8038 (article (car articles))
8039 (marked (nth 3 info)))
8040 (if (not (memq article gnus-newsgroup-unreads))
8041 (setcar (cdr (cdr info))
8042 (gnus-add-to-range (nth 2 info)
8043 (list (cdr art-group)))))
8044 ;; Copy any marks over to the new group.
8045 (let ((marks '((tick . gnus-newsgroup-marked)
8046 (dormant . gnus-newsgroup-dormant)
8047 (expire . gnus-newsgroup-expirable)
8048 (bookmark . gnus-newsgroup-bookmarks)
8049 ; (score . gnus-newsgroup-scored)
8050 (reply . gnus-newsgroup-replied)))
8051 (to-article (cdr art-group)))
8053 (if (memq article (symbol-value (cdr (car marks))))
8054 (gnus-add-marked-articles
8055 (car info) (car (car marks)) (list to-article) info))
8056 (setq marks (cdr marks)))))
8057 (gnus-message 1 "Couldn't copy article %s" (car articles)))
8058 (gnus-summary-remove-process-mark (car articles))
8059 (setq articles (cdr articles)))
8060 (kill-buffer copy-buf)))
8062 (defun gnus-summary-expire-articles ()
8063 "Expire all articles that are marked as expirable in the current group."
8065 (if (and gnus-newsgroup-expirable
8066 (gnus-check-backend-function
8067 'request-expire-articles gnus-newsgroup-name))
8068 (let ((expirable gnus-newsgroup-expirable))
8069 ;; The list of articles that weren't expired is returned.
8070 (setq gnus-newsgroup-expirable
8071 (gnus-request-expire-articles gnus-newsgroup-expirable
8072 gnus-newsgroup-name))
8073 ;; We go through the old list of expirable, and mark all
8074 ;; really expired articles as non-existant.
8076 (or (memq (car expirable) gnus-newsgroup-expirable)
8077 (gnus-summary-mark-as-read (car expirable) "%"))
8078 (setq expirable (cdr expirable))))))
8080 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8081 (defun gnus-summary-delete-article (n)
8082 "Delete the N next (mail) articles.
8083 This command actually deletes articles. This is not a marking
8084 command. The article will disappear forever from you life, never to
8086 If N is negative, delete backwards.
8087 If N is nil and articles have been marked with the process mark,
8088 delete these instead."
8090 (or (gnus-check-backend-function 'request-expire-articles
8091 gnus-newsgroup-name)
8092 (error "The current newsgroup does not support article deletion."))
8093 ;; Compute the list of articles to delete.
8094 (let ((articles (gnus-summary-work-articles n)))
8095 (if (and gnus-novice-user
8097 (format "Do you really want to delete %s forever? "
8098 (if (> (length articles) 1) "these articles"
8101 ;; Delete the articles.
8102 (setq gnus-newsgroup-expirable
8103 (gnus-request-expire-articles
8104 articles gnus-newsgroup-name 'force))
8106 (gnus-summary-remove-process-mark (car articles))
8107 ;; The backend might not have been able to delete the article
8109 (or (memq (car articles) gnus-newsgroup-expirable)
8110 (gnus-summary-mark-as-read (car articles) gnus-canceled-mark))
8111 (setq articles (cdr articles)))))
8112 (gnus-summary-position-cursor))
8114 (defun gnus-summary-edit-article ()
8115 "Enter into a buffer and edit the current article.
8116 This will have permanent effect only in mail groups."
8118 (or (gnus-check-backend-function
8119 'request-replace-article gnus-newsgroup-name)
8120 (error "The current newsgroup does not support article editing."))
8121 (gnus-summary-select-article t)
8123 (gnus-message 6 "C-c C-c to end edits")
8124 (setq buffer-read-only nil)
8126 (use-local-map (copy-keymap (current-local-map)))
8127 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
8128 (goto-char (point-min))
8129 (search-forward "\n\n" nil t))
8131 (defun gnus-summary-edit-article-done ()
8132 "Make edits to the current article permanent."
8134 (if (not (gnus-request-replace-article
8135 (cdr gnus-article-current) (car gnus-article-current)
8137 (error "Couldn't replace article.")
8139 (use-local-map gnus-article-mode-map)
8140 (setq buffer-read-only t)
8141 (pop-to-buffer gnus-summary-buffer)))
8143 ;; Summary score commands.
8145 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
8147 (defun gnus-summary-raise-score (n)
8148 "Raise the score of the current article by N."
8150 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
8152 (defun gnus-summary-lower-score (n)
8153 "Lower the score of the current article by N."
8155 (gnus-summary-raise-score (- n)))
8157 (defun gnus-summary-set-score (n)
8158 "Set the score of the current article to N."
8160 ;; Skip dummy header line.
8162 (if (eq (gnus-summary-article-mark) ?Z)
8164 (let ((buffer-read-only nil))
8166 (gnus-summary-update-mark
8167 (if (= n (or gnus-summary-default-score 0)) ?
8168 (if (< n (or gnus-summary-default-score 0))
8169 gnus-score-below-mark gnus-score-over-mark)) 'score))
8170 (let* ((article (gnus-summary-article-number))
8171 (score (assq article gnus-newsgroup-scored)))
8172 (if score (setcdr score n)
8173 (setq gnus-newsgroup-scored
8174 (cons (cons article n) gnus-newsgroup-scored))))
8175 (gnus-summary-update-line)))
8177 ;; Summary marking commands.
8179 (defun gnus-summary-raise-same-subject-and-select (score)
8180 "Raise articles which has the same subject with SCORE and select the next."
8182 (let ((subject (gnus-summary-subject-string)))
8183 (gnus-summary-raise-score score)
8184 (while (gnus-summary-search-subject nil nil subject)
8185 (gnus-summary-raise-score score))
8186 (gnus-summary-next-article t)))
8188 (defun gnus-summary-raise-same-subject (score)
8189 "Raise articles which has the same subject with SCORE."
8191 (let ((subject (gnus-summary-subject-string)))
8192 (gnus-summary-raise-score score)
8193 (while (gnus-summary-search-subject nil nil subject)
8194 (gnus-summary-raise-score score))
8195 (gnus-summary-next-subject 1 t)))
8197 (defun gnus-score-default (level)
8198 (if level (prefix-numeric-value level)
8199 gnus-score-interactive-default-score))
8201 (defun gnus-summary-raise-thread (score)
8202 "Raise articles under current thread with SCORE."
8204 (setq score (1- (gnus-score-default score)))
8207 (let ((level (gnus-summary-thread-level)))
8208 (gnus-summary-raise-score score)
8209 (while (and (zerop (gnus-summary-next-subject 1 nil t))
8210 (> (gnus-summary-thread-level) level))
8211 (gnus-summary-raise-score score))
8213 (let ((gnus-summary-check-current t))
8214 (or (zerop (gnus-summary-next-subject 1 t))
8216 (gnus-summary-recenter)
8217 (gnus-summary-position-cursor)
8218 (gnus-set-mode-line 'summary))
8220 (defun gnus-summary-lower-same-subject-and-select (score)
8221 "Raise articles which has the same subject with SCORE and select the next."
8223 (gnus-summary-raise-same-subject-and-select (- score)))
8225 (defun gnus-summary-lower-same-subject (score)
8226 "Raise articles which has the same subject with SCORE."
8228 (gnus-summary-raise-same-subject (- score)))
8230 (defun gnus-summary-lower-thread (score)
8231 "Raise articles under current thread with SCORE."
8233 (gnus-summary-raise-thread (- (1- (gnus-score-default score)))))
8235 (defun gnus-summary-kill-same-subject-and-select (unmark)
8236 "Mark articles which has the same subject as read, and then select the next.
8237 If UNMARK is positive, remove any kind of mark.
8238 If UNMARK is negative, tick articles."
8241 (setq unmark (prefix-numeric-value unmark)))
8243 (gnus-summary-mark-same-subject
8244 (gnus-summary-subject-string) unmark)))
8245 ;; Select next unread article. If auto-select-same mode, should
8246 ;; select the first unread article.
8247 (gnus-summary-next-article t (and gnus-auto-select-same
8248 (gnus-summary-subject-string)))
8249 (gnus-message 7 "%d articles are marked as %s"
8250 count (if unmark "unread" "read"))))
8252 (defun gnus-summary-kill-same-subject (unmark)
8253 "Mark articles which has the same subject as read.
8254 If UNMARK is positive, remove any kind of mark.
8255 If UNMARK is negative, tick articles."
8258 (setq unmark (prefix-numeric-value unmark)))
8260 (gnus-summary-mark-same-subject
8261 (gnus-summary-subject-string) unmark)))
8262 ;; If marked as read, go to next unread subject.
8264 ;; Go to next unread subject.
8265 (gnus-summary-next-subject 1 t))
8266 (gnus-message 7 "%d articles are marked as %s"
8267 count (if unmark "unread" "read"))))
8269 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8270 "Mark articles with same SUBJECT as read, and return marked number.
8271 If optional argument UNMARK is positive, remove any kinds of marks.
8272 If optional argument UNMARK is negative, mark articles as unread instead."
8275 (cond ((null unmark)
8276 (gnus-summary-mark-as-read nil gnus-killed-mark))
8278 (gnus-summary-tick-article nil t))
8280 (gnus-summary-tick-article)))
8282 (gnus-summary-search-forward nil subject))
8283 (cond ((null unmark)
8284 (gnus-summary-mark-as-read nil gnus-killed-mark))
8286 (gnus-summary-tick-article nil t))
8288 (gnus-summary-tick-article)))
8289 (setq count (1+ count))))
8290 ;; Hide killed thread subtrees. Does not work properly always.
8291 ;;(and (null unmark)
8292 ;; gnus-thread-hide-killed
8293 ;; (gnus-summary-hide-thread))
8294 ;; Return number of articles marked as read.
8297 (defun gnus-summary-mark-as-processable (n &optional unmark)
8298 "Set the process mark on the next N articles.
8299 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8300 the process mark instead. The difference between N and the actual
8301 number of articles marked is returned."
8303 (let ((backward (< n 0))
8308 (gnus-summary-remove-process-mark (gnus-summary-article-number))
8309 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8310 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8312 (if (/= 0 n) (gnus-message 7 "No more articles"))
8313 (gnus-summary-recenter)
8314 (gnus-summary-position-cursor)
8317 (defun gnus-summary-unmark-as-processable (n)
8318 "Remove the process mark from the next N articles.
8319 If N is negative, mark backward instead. The difference between N and
8320 the actual number of articles marked is returned."
8322 (gnus-summary-mark-as-processable n t))
8324 (defun gnus-summary-unmark-all-processable ()
8325 "Remove the process mark from all articles."
8328 (while gnus-newsgroup-processable
8329 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8330 (gnus-summary-position-cursor))
8332 (defun gnus-summary-mark-as-expirable (n)
8333 "Mark N articles forward as expirable.
8334 If N is negative, mark backward instead. The difference between N and
8335 the actual number of articles marked is returned."
8337 (gnus-summary-mark-forward n gnus-expirable-mark))
8339 (defun gnus-summary-mark-article-as-replied (article)
8340 "Mark ARTICLE replied and update the summary line."
8341 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
8342 (let ((buffer-read-only nil))
8343 (if (gnus-summary-goto-subject article)
8345 (gnus-summary-update-mark gnus-replied-mark 'replied)
8348 (defun gnus-summary-set-bookmark (article)
8349 "Set a bookmark in current article."
8350 (interactive (list (gnus-summary-article-number)))
8351 (if (or (not (get-buffer gnus-article-buffer))
8352 (not gnus-current-article)
8353 (not gnus-article-current)
8354 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8355 (error "No current article selected"))
8356 ;; Remove old bookmark, if one exists.
8357 (let ((old (assq article gnus-newsgroup-bookmarks)))
8358 (if old (setq gnus-newsgroup-bookmarks
8359 (delq old gnus-newsgroup-bookmarks))))
8360 ;; Set the new bookmark, which is on the form
8361 ;; (article-number . line-number-in-body).
8362 (setq gnus-newsgroup-bookmarks
8366 (set-buffer gnus-article-buffer)
8370 (goto-char (point-min))
8371 (search-forward "\n\n" nil t)
8374 gnus-newsgroup-bookmarks))
8375 (gnus-message 6 "A bookmark has been added to the current article."))
8377 (defun gnus-summary-remove-bookmark (article)
8378 "Remove the bookmark from the current article."
8379 (interactive (list (gnus-summary-article-number)))
8380 ;; Remove old bookmark, if one exists.
8381 (let ((old (assq article gnus-newsgroup-bookmarks)))
8384 (setq gnus-newsgroup-bookmarks
8385 (delq old gnus-newsgroup-bookmarks))
8386 (gnus-message 6 "Removed bookmark."))
8387 (gnus-message 6 "No bookmark in current article."))))
8389 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8390 (defun gnus-summary-mark-as-dormant (n)
8391 "Mark N articles forward as dormant.
8392 If N is negative, mark backward instead. The difference between N and
8393 the actual number of articles marked is returned."
8395 (gnus-summary-mark-forward n gnus-dormant-mark))
8397 (defun gnus-summary-set-process-mark (article)
8398 "Set the process mark on ARTICLE and update the summary line."
8399 (setq gnus-newsgroup-processable (cons article gnus-newsgroup-processable))
8400 (let ((buffer-read-only nil))
8401 (if (gnus-summary-goto-subject article)
8403 (and (eq (gnus-summary-article-mark) ?Z)
8405 (gnus-summary-update-mark gnus-process-mark 'replied)
8408 (defun gnus-summary-remove-process-mark (article)
8409 "Remove the process mark from ARTICLE and update the summary line."
8410 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8411 (let ((buffer-read-only nil))
8412 (if (gnus-summary-goto-subject article)
8414 (and (eq (gnus-summary-article-mark) ?Z)
8416 (gnus-summary-update-mark ? 'replied)
8417 (if (memq article gnus-newsgroup-replied)
8418 (gnus-summary-update-mark gnus-replied-mark 'replied))
8421 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8422 "Mark N articles as read forwards.
8423 If N is negative, mark backwards instead.
8424 Mark with MARK. If MARK is ? , ?! or ??, articles will be
8426 The difference between N and the actual number of articles marked is
8429 (gnus-set-global-variables)
8430 (let ((backward (< n 0))
8432 (mark (or mark gnus-del-mark)))
8434 (gnus-summary-mark-article nil mark no-expire)
8435 (zerop (gnus-summary-next-subject
8436 (if backward -1 1) gnus-summary-goto-unread t)))
8438 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8439 (gnus-summary-recenter)
8440 (gnus-summary-position-cursor)
8441 (gnus-set-mode-line 'summary)
8444 (defun gnus-summary-mark-article (&optional article mark no-expire)
8445 "Mark ARTICLE with MARK.
8446 MARK can be any character.
8447 Five MARK strings are reserved: ? (unread),
8448 ?! (ticked), ?? (dormant), ?D (read), ?E (expirable).
8449 If MARK is nil, then the default character ?D is used.
8450 If ARTICLE is nil, then the article on the current line will be
8452 ;; If no mark is given, then we check auto-expiring.
8453 (and (not no-expire)
8454 gnus-newsgroup-auto-expire
8456 (and (numberp mark) (or (= mark gnus-killed-mark)
8457 (= mark gnus-del-mark)
8458 (= mark gnus-catchup-mark)
8459 (= mark gnus-low-score-mark)
8460 (= mark gnus-read-mark))))
8461 (setq mark gnus-expirable-mark))
8462 (let* ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-del-mark))
8463 (article (or article (gnus-summary-article-number))))
8464 (if (or (= mark gnus-unread-mark)
8465 (= mark gnus-ticked-mark)
8466 (= mark gnus-dormant-mark))
8467 (gnus-mark-article-as-unread article mark)
8468 (gnus-mark-article-as-read article mark))
8470 ;; See whether the article is to be put in the cache.
8473 (gnus-cache-possibly-enter-article
8474 gnus-newsgroup-name article
8475 (gnus-get-header-by-number article)
8476 (= mark gnus-ticked-mark)
8477 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8479 (if (gnus-summary-goto-subject article)
8480 (let ((buffer-read-only nil))
8481 (gnus-summary-show-thread)
8483 (and (eq (gnus-summary-article-mark) ?Z)
8486 (gnus-summary-update-mark mark 'unread)
8489 (defun gnus-summary-update-mark (mark type)
8491 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8495 (forward-char forward)
8496 (setq plist (text-properties-at (point)))
8498 (and (memq 'gnus plist)
8499 (setcar (cdr (car (cdr (memq 'gnus plist)))) mark))
8501 (and plist (add-text-properties (1- (point)) (point) plist))
8502 (gnus-summary-update-line (eq mark gnus-unread-mark)))))
8504 (defun gnus-mark-article-as-read (article &optional mark)
8505 "Enter ARTICLE in the pertinent lists and remove it from others."
8506 ;; Make the article expirable.
8507 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-del-mark)))
8508 (if (= mark gnus-expirable-mark)
8509 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
8510 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8511 ;; Remove from unread and marked lists.
8512 (setq gnus-newsgroup-unreads
8513 (delq article gnus-newsgroup-unreads))
8514 (setq gnus-newsgroup-marked
8515 (delq article gnus-newsgroup-marked))
8516 (setq gnus-newsgroup-dormant
8517 (delq article gnus-newsgroup-dormant))))
8519 (defun gnus-mark-article-as-unread (article &optional mark)
8520 "Enter ARTICLE in the pertinent lists and remove it from others."
8521 (let ((mark (or (and (stringp mark) (aref mark 0)) mark gnus-ticked-mark)))
8522 ;; Add to unread list.
8523 (or (memq article gnus-newsgroup-unreads)
8524 (setq gnus-newsgroup-unreads
8525 (cons article gnus-newsgroup-unreads)))
8526 ;; If CLEAR-MARK is non-nil, the article must be removed from marked
8527 ;; list. Otherwise, it must be added to the list.
8528 (setq gnus-newsgroup-marked
8529 (delq article gnus-newsgroup-marked))
8530 (setq gnus-newsgroup-dormant
8531 (delq article gnus-newsgroup-dormant))
8532 (setq gnus-newsgroup-expirable
8533 (delq article gnus-newsgroup-expirable))
8534 (if (= mark gnus-ticked-mark)
8535 (setq gnus-newsgroup-marked
8536 (cons article gnus-newsgroup-marked)))
8537 (if (= mark gnus-dormant-mark)
8538 (setq gnus-newsgroup-dormant
8539 (cons article gnus-newsgroup-dormant)))))
8541 (defalias 'gnus-summary-mark-as-unread-forward
8542 'gnus-summary-tick-article-forward)
8543 (make-obsolete 'gnus-summary-mark-as-unread-forward
8544 'gnus-summary-tick-article-forward)
8545 (defun gnus-summary-tick-article-forward (n)
8546 "Tick N articles forwards.
8547 If N is negative, tick backwards instead.
8548 The difference between N and the number of articles ticked is returned."
8550 (gnus-summary-mark-forward n gnus-ticked-mark))
8552 (defalias 'gnus-summary-mark-as-unread-backward
8553 'gnus-summary-tick-article-backward)
8554 (make-obsolete 'gnus-summary-mark-as-unread-backward
8555 'gnus-summary-tick-article-backward)
8556 (defun gnus-summary-tick-article-backward (n)
8557 "Tick N articles backwards.
8558 The difference between N and the number of articles ticked is returned."
8560 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8562 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8563 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8564 (defun gnus-summary-tick-article (&optional article clear-mark)
8565 "Mark current article as unread.
8566 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8567 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8568 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8571 (defun gnus-summary-mark-as-read-forward (n)
8572 "Mark N articles as read forwards.
8573 If N is negative, mark backwards instead.
8574 The difference between N and the actual number of articles marked is
8577 (gnus-summary-mark-forward n gnus-del-mark t))
8579 (defun gnus-summary-mark-as-read-backward (n)
8580 "Mark the N articles as read backwards.
8581 The difference between N and the actual number of articles marked is
8584 (gnus-summary-mark-forward (- n) gnus-del-mark t))
8586 (defun gnus-summary-mark-as-read (&optional article mark)
8587 "Mark current article as read.
8588 ARTICLE specifies the article to be marked as read.
8589 MARK specifies a string to be inserted at the beginning of the line."
8590 (gnus-summary-mark-article article mark))
8592 (defun gnus-summary-clear-mark-forward (n)
8593 "Clear marks from N articles forward.
8594 If N is negative, clear backward instead.
8595 The difference between N and the number of marks cleared is returned."
8597 (gnus-summary-mark-forward n gnus-unread-mark))
8599 (defun gnus-summary-clear-mark-backward (n)
8600 "Clear marks from N articles backward.
8601 The difference between N and the number of marks cleared is returned."
8603 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8605 (defun gnus-summary-mark-unread-as-read ()
8606 "Intended to be used by `gnus-summary-mark-article-hook'."
8607 (or (memq gnus-current-article gnus-newsgroup-marked)
8608 (memq gnus-current-article gnus-newsgroup-dormant)
8609 (memq gnus-current-article gnus-newsgroup-expirable)
8610 (gnus-summary-mark-as-read gnus-current-article gnus-read-mark)))
8612 (defun gnus-summary-mark-region-as-read (point mark all)
8613 "Mark all unread articles between point and mark as read.
8614 If given a prefix, mark all articles between point and mark as read,
8615 even ticked and dormant ones."
8616 (interactive "r\nP")
8626 (not (memq (gnus-summary-article-number)
8627 gnus-newsgroup-marked))
8628 (not (memq (gnus-summary-article-number)
8629 gnus-newsgroup-dormant))))
8630 (gnus-summary-mark-article
8631 (gnus-summary-article-number) gnus-del-mark))
8633 (zerop (forward-line 1))))))
8635 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
8636 (defalias 'gnus-summary-delete-marked-as-read
8637 'gnus-summary-remove-lines-marked-as-read)
8638 (make-obsolete 'gnus-summary-delete-marked-as-read
8639 'gnus-summary-remove-lines-marked-as-read)
8640 (defun gnus-summary-remove-lines-marked-as-read ()
8641 "Remove lines that are marked as read."
8643 (gnus-summary-remove-lines-marked-with
8645 (lambda (char) (char-to-string (symbol-value char)))
8646 '(gnus-del-mark gnus-read-mark gnus-ancient-mark
8647 gnus-killed-mark gnus-kill-file-mark
8648 gnus-low-score-mark gnus-expirable-mark)
8651 (defalias 'gnus-summary-delete-marked-with
8652 'gnus-summary-remove-lines-marked-with)
8653 (make-obsolete 'gnus-summary-delete-marked-with
8654 'gnus-summary-remove-lines-marked-with)
8655 ;; Rewrite by Daniel Quinlan <quinlan@best.com>.
8656 (defun gnus-summary-remove-lines-marked-with (marks)
8657 "Remove lines that are marked with MARKS (e.g. \"DK\")."
8658 (interactive "sMarks: ")
8659 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
8661 (set-buffer gnus-summary-buffer)
8662 (let ((buffer-read-only nil)
8663 (marks (concat "^[" marks "]")))
8664 (goto-char (point-min))
8665 (if gnus-newsgroup-adaptive
8666 (gnus-score-remove-lines-adaptive marks)
8667 (while (re-search-forward marks (point-max) t)
8669 (delete-region (point)
8670 (progn (forward-line 1) (point))))))
8671 (or (zerop (buffer-size))
8673 (gnus-summary-prev-subject 1)
8674 (gnus-summary-position-cursor)))))
8676 (defun gnus-summary-expunge-below (score)
8677 "Remove articles with score less than SCORE."
8679 (setq score (if score
8680 (prefix-numeric-value score)
8681 (or gnus-summary-default-score 0)))
8683 (set-buffer gnus-summary-buffer)
8684 (goto-char (point-min))
8685 (let ((buffer-read-only nil)
8688 (if (< (gnus-summary-article-score) score)
8692 (delete-region beg (point)))
8695 (or (zerop (buffer-size))
8697 (gnus-summary-prev-subject 1)
8698 (gnus-summary-position-cursor))))))
8700 (defun gnus-summary-mark-below (score mark)
8701 "Mark articles with score less than SCORE with MARK."
8702 (interactive "P\ncMark: ")
8703 (setq score (if score
8704 (prefix-numeric-value score)
8705 (or gnus-summary-default-score 0)))
8707 (set-buffer gnus-summary-buffer)
8708 (goto-char (point-min))
8710 (and (< (gnus-summary-article-score) score)
8711 (gnus-summary-mark-article nil mark))
8714 (defun gnus-summary-kill-below (score)
8715 "Mark articles with score below SCORE as read."
8717 (gnus-summary-mark-below score gnus-killed-mark))
8719 (defun gnus-summary-clear-above (score)
8720 "Clear all marks from articles with score above SCORE."
8722 (gnus-summary-mark-above score gnus-unread-mark))
8724 (defun gnus-summary-tick-above (score)
8725 "Tick all articles with score above SCORE."
8727 (gnus-summary-mark-above score gnus-ticked-mark))
8729 (defun gnus-summary-mark-above (score mark)
8730 "Mark articles with score over SCORE with MARK."
8731 (interactive "P\ncMark: ")
8732 (setq score (if score
8733 (prefix-numeric-value score)
8734 (or gnus-summary-default-score 0)))
8736 (set-buffer gnus-summary-buffer)
8737 (goto-char (point-min))
8739 (if (> (gnus-summary-article-score) score)
8741 (gnus-summary-mark-article nil mark)
8743 (forward-line 1)))))
8745 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8746 (defun gnus-summary-show-all-expunged ()
8747 "Display all the hidden articles that were expunged for low scores."
8749 (let ((buffer-read-only nil))
8750 (let ((scored gnus-newsgroup-scored)
8753 (or (gnus-summary-goto-subject (car (car scored)))
8754 (and (setq h (gnus-get-header-by-number (car (car scored))))
8755 (< (cdr (car scored)) gnus-summary-expunge-below)
8756 (setq headers (cons h headers))))
8757 (setq scored (cdr scored)))
8758 (or headers (error "No expunged articles hidden."))
8759 (goto-char (point-min))
8761 (gnus-summary-update-lines
8764 (gnus-summary-prepare-threads (nreverse headers) 0)
8766 (goto-char (point-min))
8767 (gnus-summary-position-cursor)))
8769 (defun gnus-summary-show-all-dormant ()
8770 "Display all the hidden articles that are marked as dormant."
8772 (let ((buffer-read-only nil))
8773 (goto-char (point-min))
8774 (let ((dormant gnus-newsgroup-dormant)
8777 (or (gnus-summary-goto-subject (car dormant))
8778 (and (setq h (gnus-get-header-by-number (car dormant)))
8779 (setq headers (cons h headers))))
8780 (setq dormant (cdr dormant)))
8781 (or headers (error "No dormant articles hidden."))
8783 (gnus-summary-update-lines
8786 (gnus-summary-prepare-threads (nreverse headers) 0)
8788 (goto-char (point-min))
8789 (gnus-summary-position-cursor)))
8791 (defun gnus-summary-hide-all-dormant ()
8792 "Hide all dormant articles."
8794 (gnus-summary-remove-lines-marked-with (char-to-string gnus-dormant-mark))
8795 (gnus-summary-position-cursor))
8797 (defun gnus-summary-catchup (all &optional quietly to-here not-mark)
8798 "Mark all articles not marked as unread in this newsgroup as read.
8799 If prefix argument ALL is non-nil, all articles are marked as read.
8800 If QUIETLY is non-nil, no questions will be asked.
8801 If TO-HERE is non-nil, it should be a point in the buffer. All
8802 articles before this point will be marked as read.
8803 The number of articles marked as read is returned."
8807 (not gnus-interactive-catchup) ;Without confirmation?
8811 "Mark absolutely all articles as read? "
8812 "Mark all unread articles as read? ")))
8813 (if (and not-mark (not gnus-newsgroup-adaptive)
8814 gnus-newsgroup-auto-expire)
8816 (and all (setq gnus-newsgroup-marked nil
8817 gnus-newsgroup-dormant nil))
8818 (setq gnus-newsgroup-unreads gnus-newsgroup-marked))
8819 (let ((unreads (length gnus-newsgroup-unreads)))
8820 (if (gnus-summary-first-subject (not all))
8821 (while (and (gnus-summary-mark-as-read nil gnus-catchup-mark)
8822 (if to-here (< (point) to-here) t)
8823 (gnus-summary-search-subject nil (not all)))))
8824 (- unreads (length gnus-newsgroup-unreads))
8826 (setq gnus-newsgroup-unreads gnus-newsgroup-marked)))))
8827 (gnus-summary-position-cursor)))
8829 (defun gnus-summary-catchup-to-here (&optional all)
8830 "Mark all unticked articles before the current one as read.
8831 If ALL is non-nil, also mark ticked and dormant articles as read."
8834 (gnus-summary-catchup all t (point))
8835 (gnus-summary-position-cursor))
8837 (defun gnus-summary-catchup-all (&optional quietly)
8838 "Mark all articles in this newsgroup as read."
8840 (gnus-summary-catchup t quietly))
8842 (defun gnus-summary-catchup-and-exit (all &optional quietly)
8843 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8844 If prefix argument ALL is non-nil, all articles are marked as read."
8846 (gnus-summary-catchup all quietly nil 'fast)
8847 ;; Select next newsgroup or exit.
8848 (if (eq gnus-auto-select-next 'quietly)
8849 (gnus-summary-next-group nil)
8850 (gnus-summary-exit)))
8852 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8853 "Mark all articles in this newsgroup as read, and then exit."
8855 (gnus-summary-catchup-and-exit t quietly))
8857 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8858 (defun gnus-summary-catchup-and-goto-next-group (all)
8859 "Mark all articles in this group as read and select the next group.
8860 If given a prefix, mark all articles, unread as well as ticked, as
8863 (gnus-summary-catchup all)
8864 (gnus-summary-next-group))
8866 ;; Thread-based commands.
8868 (defun gnus-summary-toggle-threads (arg)
8869 "Toggle showing conversation threads.
8870 If ARG is positive number, turn showing conversation threads on."
8872 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8873 (setq gnus-show-threads
8874 (if (null arg) (not gnus-show-threads)
8875 (> (prefix-numeric-value arg) 0)))
8876 (gnus-summary-prepare)
8877 (gnus-summary-goto-subject current)
8878 (gnus-summary-position-cursor)))
8880 (defun gnus-summary-show-all-threads ()
8884 (let ((buffer-read-only nil))
8885 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8886 (gnus-summary-position-cursor))
8888 (defun gnus-summary-show-thread ()
8889 "Show thread subtrees.
8890 Returns nil if no thread was there to be shown."
8894 (let ((buffer-read-only nil)
8895 ;; first goto end then to beg, to have point at beg after let
8896 (end (progn (end-of-line) (point)))
8897 (beg (progn (beginning-of-line) (point))))
8899 ;; Any hidden lines here?
8900 (search-forward "\r" end t)
8901 (subst-char-in-region beg end ?\^M ?\n t))))
8902 (gnus-summary-position-cursor)))
8904 (defun gnus-summary-hide-all-threads ()
8905 "Hide all thread subtrees."
8908 (goto-char (point-min))
8909 (gnus-summary-hide-thread)
8910 (while (and (not (eobp)) (zerop (forward-line 1)))
8911 (gnus-summary-hide-thread)))
8912 (gnus-summary-position-cursor))
8914 (defun gnus-summary-hide-thread ()
8915 "Hide thread subtrees.
8916 Returns nil if no threads were there to be hidden."
8918 (let ((buffer-read-only nil)
8920 (level (gnus-summary-thread-level))
8922 ;; Go forward until either the buffer ends or the subthread
8926 (while (and (zerop (forward-line 1))
8927 (> (gnus-summary-thread-level) level))
8932 (search-backward "\n" start t))
8933 (subst-char-in-region start end ?\n ?\^M t)
8934 (forward-line -1)))))
8936 (defun gnus-summary-go-to-next-thread (&optional previous)
8937 "Go to the same level (or less) next thread.
8938 If PREVIOUS is non-nil, go to previous thread instead.
8939 Return the article number moved to, or nil if moving was impossible."
8940 (let ((level (gnus-summary-thread-level))
8941 (article (gnus-summary-article-number)))
8943 (while (and (zerop (gnus-summary-prev-subject 1))
8944 (> (gnus-summary-thread-level) level)))
8945 (while (and (zerop (gnus-summary-next-subject 1))
8946 (> (gnus-summary-thread-level) level))))
8947 (gnus-summary-recenter)
8948 (gnus-summary-position-cursor)
8949 (let ((oart (gnus-summary-article-number)))
8950 (and (/= oart article) oart))))
8952 (defun gnus-summary-next-thread (n)
8953 "Go to the same level next N'th thread.
8954 If N is negative, search backward instead.
8955 Returns the difference between N and the number of skips actually
8958 (let ((backward (< n 0))
8961 (gnus-summary-go-to-next-thread backward))
8963 (gnus-summary-position-cursor)
8964 (if (/= 0 n) (gnus-message 7 "No more threads"))
8967 (defun gnus-summary-prev-thread (n)
8968 "Go to the same level previous N'th thread.
8969 Returns the difference between N and the number of skips actually
8972 (gnus-summary-next-thread (- n)))
8974 (defun gnus-summary-go-down-thread (&optional same)
8975 "Go down one level in the current thread.
8976 If SAME is non-nil, also move to articles of the same level."
8977 (let ((level (gnus-summary-thread-level))
8979 (if (and (zerop (forward-line 1))
8980 (> (gnus-summary-thread-level) level))
8985 (defun gnus-summary-go-up-thread ()
8986 "Go up one level in the current thread."
8987 (let ((level (gnus-summary-thread-level))
8989 (while (and (zerop (forward-line -1))
8990 (>= (gnus-summary-thread-level) level)))
8991 (if (>= (gnus-summary-thread-level) level)
8997 (defun gnus-summary-down-thread (n)
8998 "Go down thread N steps.
8999 If N is negative, go up instead.
9000 Returns the difference between N and how many steps down that were
9006 (if up (gnus-summary-go-up-thread)
9007 (gnus-summary-go-down-thread)))
9009 (gnus-summary-position-cursor)
9010 (if (/= 0 n) (gnus-message 7 "Can't go further"))
9013 (defun gnus-summary-up-thread (n)
9014 "Go up thread N steps.
9015 If N is negative, go up instead.
9016 Returns the difference between N and how many steps down that were
9019 (gnus-summary-down-thread (- n)))
9021 (defun gnus-summary-kill-thread (unmark)
9022 "Mark articles under current thread as read.
9023 If the prefix argument is positive, remove any kinds of marks.
9024 If the prefix argument is negative, tick articles instead."
9027 (setq unmark (prefix-numeric-value unmark)))
9029 (level (gnus-summary-thread-level)))
9032 ;; Mark the article...
9033 (cond ((null unmark) (gnus-summary-mark-as-read nil gnus-killed-mark))
9034 ((> unmark 0) (gnus-summary-tick-article nil t))
9035 (t (gnus-summary-tick-article)))
9036 ;; ...and go forward until either the buffer ends or the subtree
9038 (if (not (and (zerop (forward-line 1))
9039 (> (gnus-summary-thread-level) level)))
9040 (setq killing nil))))
9041 ;; Hide killed subtrees.
9043 gnus-thread-hide-killed
9044 (gnus-summary-hide-thread))
9045 ;; If marked as read, go to next unread subject.
9047 ;; Go to next unread subject.
9048 (gnus-summary-next-subject 1 t)))
9049 (gnus-set-mode-line 'summary))
9051 ;; Summary sorting commands
9053 (defun gnus-summary-sort-by-number (&optional reverse)
9054 "Sort summary buffer by article number.
9055 Argument REVERSE means reverse order."
9058 (cons 'gnus-summary-article-number 'gnus-thread-sort-by-number) reverse))
9060 (defun gnus-summary-sort-by-author (&optional reverse)
9061 "Sort summary buffer by author name alphabetically.
9062 If case-fold-search is non-nil, case of letters is ignored.
9063 Argument REVERSE means reverse order."
9068 (let ((extract (funcall
9069 gnus-extract-address-components
9070 (header-from (gnus-get-header-by-number
9071 (gnus-summary-article-number))))))
9072 (or (car extract) (cdr extract))))
9073 'gnus-thread-sort-by-author)
9076 (defun gnus-summary-sort-by-subject (&optional reverse)
9077 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
9078 If case-fold-search is non-nil, case of letters is ignored.
9079 Argument REVERSE means reverse order."
9084 (downcase (gnus-simplify-subject (gnus-summary-subject-string))))
9085 'gnus-thread-sort-by-subject)
9088 (defun gnus-summary-sort-by-date (&optional reverse)
9089 "Sort summary buffer by date.
9090 Argument REVERSE means reverse order."
9097 (gnus-get-header-by-number (gnus-summary-article-number)))))
9098 'gnus-thread-sort-by-date)
9101 (defun gnus-summary-sort-by-score (&optional reverse)
9102 "Sort summary buffer by score.
9103 Argument REVERSE means reverse order."
9106 (cons 'gnus-summary-article-score 'gnus-thread-sort-by-score)
9109 (defvar gnus-summary-already-sorted nil)
9110 (defun gnus-summary-sort (predicate reverse)
9111 ;; Sort summary buffer by PREDICATE. REVERSE means reverse order.
9112 (if gnus-summary-already-sorted
9114 (let (buffer-read-only)
9115 (if (not gnus-show-threads)
9117 (goto-char (point-min))
9118 (sort-subr reverse 'forward-line 'end-of-line (car predicate)))
9119 (let ((gnus-thread-sort-functions (list (cdr predicate)))
9120 (gnus-summary-prepare-hook nil)
9121 (gnus-summary-already-sorted nil))
9122 (gnus-summary-prepare)
9123 (and gnus-show-threads
9124 gnus-thread-hide-subtree
9125 (gnus-summary-hide-all-threads)))))))
9127 (defun gnus-sortable-date (date)
9128 "Make sortable string by string-lessp from DATE.
9129 Timezone package is used."
9130 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
9131 (year (aref date 0))
9132 (month (aref date 1))
9133 (day (aref date 2)))
9134 (timezone-make-sortable-date
9136 (timezone-make-time-string
9137 (aref date 3) (aref date 4) (aref date 5)))))
9140 ;; Summary saving commands.
9142 (defun gnus-summary-save-article (n)
9143 "Save the current article using the default saver function.
9144 If N is a positive number, save the N next articles.
9145 If N is a negative number, save the N previous articles.
9146 If N is nil and any articles have been marked with the process mark,
9147 save those articles instead.
9148 The variable `gnus-default-article-saver' specifies the saver function."
9150 (let ((articles (gnus-summary-work-articles n)))
9152 (let ((header (gnus-get-header-by-number (car articles))))
9153 (if (vectorp header)
9155 (gnus-summary-select-article t nil nil (car articles))
9156 (or gnus-save-all-headers
9157 (gnus-article-hide-headers t))
9158 ;; Remove any X-Gnus lines.
9161 (set-buffer gnus-article-buffer)
9162 (let ((buffer-read-only nil))
9163 (goto-char (point-min))
9164 (narrow-to-region (point) (or (search-forward "\n\n" nil t)
9166 (while (re-search-forward "^X-Gnus" nil t)
9168 (delete-region (point)
9169 (progn (forward-line 1) (point))))
9172 (if gnus-default-article-saver
9173 (funcall gnus-default-article-saver)
9174 (error "No default saver is defined."))))
9175 (if (assq 'name header)
9176 (gnus-copy-file (cdr (assq 'name header)))
9177 (gnus-message 1 "Article %d is unsaveable" (car articles)))))
9178 (gnus-summary-remove-process-mark (car articles))
9179 (setq articles (cdr articles)))
9180 (gnus-summary-position-cursor)
9183 (defun gnus-summary-pipe-output (arg)
9184 "Pipe the current article to a subprocess.
9185 If N is a positive number, pipe the N next articles.
9186 If N is a negative number, pipe the N previous articles.
9187 If N is nil and any articles have been marked with the process mark,
9188 pipe those articles instead."
9190 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9191 (gnus-summary-save-article arg)))
9193 (defun gnus-summary-save-article-mail (arg)
9194 "Append the current article to an mail file.
9195 If N is a positive number, save the N next articles.
9196 If N is a negative number, save the N previous articles.
9197 If N is nil and any articles have been marked with the process mark,
9198 save those articles instead."
9200 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9201 (gnus-summary-save-article arg)))
9203 (defun gnus-summary-save-article-rmail (arg)
9204 "Append the current article to an rmail file.
9205 If N is a positive number, save the N next articles.
9206 If N is a negative number, save the N previous articles.
9207 If N is nil and any articles have been marked with the process mark,
9208 save those articles instead."
9210 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9211 (gnus-summary-save-article arg)))
9213 (defun gnus-summary-save-article-file (arg)
9214 "Append the current article to a file.
9215 If N is a positive number, save the N next articles.
9216 If N is a negative number, save the N previous articles.
9217 If N is nil and any articles have been marked with the process mark,
9218 save those articles instead."
9220 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9221 (gnus-summary-save-article arg)))
9223 (defun gnus-summary-save-article-folder (arg)
9224 "Append the current article to an mh folder.
9225 If N is a positive number, save the N next articles.
9226 If N is a negative number, save the N previous articles.
9227 If N is nil and any articles have been marked with the process mark,
9228 save those articles instead."
9230 (let ((gnus-default-article-saver 'gnus-summary-save-in-folder))
9231 (gnus-summary-save-article arg)))
9233 (defun gnus-summary-save-article-vm (arg)
9234 "Append the current article to a vm folder.
9235 If N is a positive number, save the N next articles.
9236 If N is a negative number, save the N previous articles.
9237 If N is nil and any articles have been marked with the process mark,
9238 save those articles instead."
9240 (let ((gnus-default-article-saver 'gnus-summary-save-in-vm))
9241 (gnus-summary-save-article arg)))
9243 (defun gnus-read-save-file-name (prompt default-name)
9244 (let ((methods gnus-split-methods)
9246 (if (not gnus-split-methods)
9249 (set-buffer gnus-article-buffer)
9250 (gnus-narrow-to-headers)
9252 (goto-char (point-min))
9253 (and (condition-case ()
9254 (re-search-forward (car (car methods)) nil t)
9256 (setq split-name (cons (nth 1 (car methods)) split-name)))
9257 (setq methods (cdr methods)))
9259 (cond ((null split-name)
9261 (concat prompt " (default "
9262 (file-name-nondirectory default-name) ") ")
9263 (file-name-directory default-name)
9265 ((= 1 (length split-name))
9267 (concat prompt " (default " (car split-name) ") ")
9268 gnus-article-save-directory
9269 (concat gnus-article-save-directory (car split-name))))
9271 (setq split-name (mapcar (lambda (el) (list el))
9272 (nreverse split-name)))
9273 (let ((result (completing-read
9275 split-name nil nil)))
9276 (concat gnus-article-save-directory
9277 (if (string= result "")
9278 (car (car split-name))
9281 (defun gnus-summary-save-in-rmail (&optional filename)
9282 "Append this article to Rmail file.
9283 Optional argument FILENAME specifies file name.
9284 Directory to save to is default to `gnus-article-save-directory' which
9285 is initialized from the SAVEDIR environment variable."
9288 (funcall gnus-rmail-save-name gnus-newsgroup-name
9289 gnus-current-headers gnus-newsgroup-last-rmail)))
9291 (setq filename (gnus-read-save-file-name
9292 "Save in rmail file:" default-name)))
9293 (gnus-make-directory (file-name-directory filename))
9294 (gnus-eval-in-buffer-window
9299 (gnus-output-to-rmail filename))))
9300 ;; Remember the directory name to save articles.
9301 (setq gnus-newsgroup-last-rmail filename)))
9303 (defun gnus-summary-save-in-mail (&optional filename)
9304 "Append this article to Unix mail file.
9305 Optional argument FILENAME specifies file name.
9306 Directory to save to is default to `gnus-article-save-directory' which
9307 is initialized from the SAVEDIR environment variable."
9310 (funcall gnus-mail-save-name gnus-newsgroup-name
9311 gnus-current-headers gnus-newsgroup-last-mail)))
9313 (setq filename (gnus-read-save-file-name
9314 "Save in Unix mail file:" default-name)))
9316 (expand-file-name filename
9318 (file-name-directory default-name))))
9319 (gnus-make-directory (file-name-directory filename))
9320 (gnus-eval-in-buffer-window
9325 (if (and (file-readable-p filename) (rmail-file-p filename))
9326 (gnus-output-to-rmail filename)
9327 (rmail-output filename 1 t t)))))
9328 ;; Remember the directory name to save articles.
9329 (setq gnus-newsgroup-last-mail filename)))
9331 (defun gnus-summary-save-in-file (&optional filename)
9332 "Append this article to file.
9333 Optional argument FILENAME specifies file name.
9334 Directory to save to is default to `gnus-article-save-directory' which
9335 is initialized from the SAVEDIR environment variable."
9338 (funcall gnus-file-save-name gnus-newsgroup-name
9339 gnus-current-headers gnus-newsgroup-last-file)))
9341 (setq filename (gnus-read-save-file-name
9342 "Save in file:" default-name)))
9343 (gnus-make-directory (file-name-directory filename))
9344 (gnus-eval-in-buffer-window
9349 (gnus-output-to-file filename))))
9350 ;; Remember the directory name to save articles.
9351 (setq gnus-newsgroup-last-file filename)))
9353 (defun gnus-summary-save-in-pipe (&optional command)
9354 "Pipe this article to subprocess."
9356 (let ((command (read-string "Shell command on article: "
9357 gnus-last-shell-command)))
9358 (if (string-equal command "")
9359 (setq command gnus-last-shell-command))
9360 (gnus-eval-in-buffer-window
9364 (shell-command-on-region (point-min) (point-max) command nil)))
9365 (setq gnus-last-shell-command command)))
9367 ;; Summary extract commands
9369 (defun gnus-summary-insert-pseudos (pslist)
9370 (let ((buffer-read-only nil)
9371 (article (gnus-summary-article-number))
9373 (or (gnus-summary-goto-subject article)
9374 (error (format "No such article: %d" article)))
9375 (or gnus-newsgroup-headers-hashtb-by-number
9376 (gnus-make-headers-hashtable-by-number))
9377 (gnus-summary-position-cursor)
9378 ;; If all commands are to be bunched up on one line, we collect
9380 (if gnus-view-pseudos-separately
9382 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9385 (setq action (cdr (assq 'action (car ps))))
9386 (setq files (list (cdr (assq 'name (car ps)))))
9387 (while (and ps (cdr ps)
9388 (string= (or action "1")
9389 (or (cdr (assq 'action (car (cdr ps)))) "2")))
9390 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
9391 (setcdr ps (cdr (cdr ps))))
9394 (if (not (string-match "%s" action))
9395 (setq files (cons " " files)))
9396 (setq files (cons " " files))
9397 (and (assq 'execute (car ps))
9398 (setcdr (assq 'execute (car ps))
9399 (funcall (if (string-match "%s" action)
9402 (mapconcat (lambda (f) f) files " ")))))
9403 (setq ps (cdr ps)))))
9404 (if gnus-view-pseudos
9406 (and (assq 'execute (car pslist))
9407 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9408 (eq gnus-view-pseudos 'not-confirm)))
9409 (setq pslist (cdr pslist)))
9412 (gnus-summary-goto-subject (or (cdr (assq 'article (car pslist)))
9413 (gnus-summary-article-number)))
9416 (insert " " (file-name-nondirectory
9417 (cdr (assq 'name (car pslist))))
9418 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9419 (add-text-properties
9420 b (1+ b) (list 'gnus (list gnus-reffed-article-number
9422 'gnus-pseudo (car pslist)))
9424 (gnus-sethash (int-to-string gnus-reffed-article-number)
9425 (car pslist) gnus-newsgroup-headers-hashtb-by-number)
9426 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9427 (setq pslist (cdr pslist)))))))
9429 (defun gnus-pseudos< (p1 p2)
9430 (let ((c1 (cdr (assq 'action p1)))
9431 (c2 (cdr (assq 'action p2))))
9432 (and c1 c2 (string< c1 c2))))
9434 (defun gnus-request-pseudo-article (props)
9435 (cond ((assq 'execute props)
9436 (gnus-execute-command (cdr (assq 'execute props)))))
9437 (let ((gnus-current-article (gnus-summary-article-number)))
9438 (run-hooks 'gnus-mark-article-hook)))
9440 (defun gnus-execute-command (command &optional automatic)
9442 (gnus-article-setup-buffer)
9443 (set-buffer gnus-article-buffer)
9444 (let ((command (if automatic command (read-string "Command: " command)))
9445 (buffer-read-only nil))
9447 (insert "$ " command "\n\n")
9448 (if gnus-view-pseudo-asynchronously
9449 (start-process "gnus-execute" nil "sh" "-c" command)
9450 (call-process "sh" nil t nil "-c" command)))))
9452 (defun gnus-copy-file (file &optional to)
9455 (list (read-file-name "Copy file: " default-directory)
9456 (read-file-name "Copy file to: " default-directory)))
9457 (or to (setq to (read-file-name "Copy file to: " default-directory)))
9458 (and (file-directory-p to)
9459 (setq to (concat (file-name-as-directory to)
9460 (file-name-nondirectory file))))
9461 (copy-file file to))
9463 ;; Summary kill commands.
9465 (defun gnus-summary-edit-global-kill (article)
9466 "Edit the \"global\" kill file."
9467 (interactive (list (gnus-summary-article-number)))
9468 (gnus-group-edit-global-kill article))
9470 (defun gnus-summary-edit-local-kill ()
9471 "Edit a local kill file applied to the current newsgroup."
9473 (setq gnus-current-headers
9475 (int-to-string (gnus-summary-article-number))
9476 gnus-newsgroup-headers-hashtb-by-number))
9477 (gnus-set-global-variables)
9478 (gnus-group-edit-local-kill
9479 (gnus-summary-article-number) gnus-newsgroup-name))
9483 ;;; Gnus article mode
9486 (put 'gnus-article-mode 'mode-class 'special)
9488 (if gnus-article-mode-map
9490 (setq gnus-article-mode-map (make-keymap))
9491 (suppress-keymap gnus-article-mode-map)
9492 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
9493 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
9494 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
9495 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
9496 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
9497 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
9498 (define-key gnus-article-mode-map "\C-c\C-M" 'gnus-article-mail-with-original)
9499 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
9500 (define-key gnus-article-mode-map gnus-mouse-2 'gnus-article-push-button)
9501 (define-key gnus-article-mode-map "\r" 'gnus-article-press-button)
9502 (define-key gnus-article-mode-map "\t" 'gnus-article-next-button)
9504 ;; Duplicate almost all summary keystrokes in the article mode map.
9506 (list "#" "\M-#" "\C-c\M-#" "n" "p"
9507 "N" "P" "\M-\C-n" "\M-\C-p" "." "\M-s" "\M-r"
9508 "<" ">" "l" "j" "^" "\M-^" "-" "u" "U" "d" "D"
9509 "\M-u" "\M-U" "k" "\C-k" "\M-\C-k""x" "X"
9510 "\M-\C-x" "\M-\177" "b" "B" "$" "w" "\C-c\C-r"
9512 "m" "o" "\C-o" "|" "\M-m" "\M-\C-m" "\M-k" "M"
9515 (define-key gnus-article-mode-map (car commands)
9516 'gnus-article-summary-command)
9517 (setq commands (cdr commands))))
9519 (let ((commands (list "q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F")))
9521 (define-key gnus-article-mode-map (car commands)
9522 'gnus-article-summary-command-nosave)
9523 (setq commands (cdr commands)))))
9526 (defun gnus-article-mode ()
9527 "Major mode for displaying an article.
9529 All normal editing commands are switched off.
9531 The following commands are available:
9533 \\<gnus-article-mode-map>
9534 \\[gnus-article-next-page]\t Scroll the article one page forwards
9535 \\[gnus-article-prev-page]\t Scroll the article one page backwards
9536 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
9537 \\[gnus-article-show-summary]\t Display the summary buffer
9538 \\[gnus-article-mail]\t Send a reply to the address near point
9539 \\[gnus-article-mail-with-original]\t Send a reply to the address near point; include the original article
9540 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
9541 \\[gnus-info-find-node]\t Go to the Gnus info node"
9543 (if gnus-visual (gnus-article-make-menu-bar))
9544 (kill-all-local-variables)
9545 (setq mode-line-modified "-- ")
9546 (make-local-variable 'mode-line-format)
9547 (setq mode-line-format (copy-sequence mode-line-format))
9548 (and (equal (nth 3 mode-line-format) " ")
9549 (setcar (nthcdr 3 mode-line-format) ""))
9550 (setq mode-name "Article")
9551 (setq major-mode 'gnus-article-mode)
9552 (make-local-variable 'minor-mode-alist)
9553 (or (assq 'gnus-show-mime minor-mode-alist)
9554 (setq minor-mode-alist
9555 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
9556 (use-local-map gnus-article-mode-map)
9557 (make-local-variable 'page-delimiter)
9558 (setq page-delimiter gnus-page-delimiter)
9559 (buffer-disable-undo (current-buffer))
9560 (setq buffer-read-only t) ;Disable modification
9561 (run-hooks 'gnus-article-mode-hook))
9563 (defun gnus-article-setup-buffer ()
9564 "Initialize article mode buffer."
9565 (or (get-buffer gnus-article-buffer)
9567 (set-buffer (get-buffer-create gnus-article-buffer))
9568 (gnus-add-current-to-buffer-list)
9569 (gnus-article-mode))))
9571 (defun gnus-request-article-this-buffer (article group)
9572 "Get an article and insert it into this buffer."
9573 (setq group (or group gnus-newsgroup-name))
9575 ;; Open server if it has closed.
9576 (gnus-check-news-server (gnus-find-method-for-group group))
9578 ;; Using `gnus-request-article' directly will insert the article into
9579 ;; `nntp-server-buffer' - so we'll save some time by not having to
9580 ;; copy it from the server buffer into the article buffer.
9582 ;; We only request an article by message-id when we do not have the
9583 ;; headers for it, so we'll have to get those.
9584 (and (stringp article)
9585 (let ((gnus-override-method gnus-refer-article-method))
9586 (gnus-read-header article)))
9588 ;; If the article number is negative, that means that this article
9589 ;; doesn't belong in this newsgroup (possibly), so we find its
9590 ;; message-id and request it by id instead of number.
9591 (if (and (numberp article) (< article 0))
9593 (set-buffer gnus-summary-buffer)
9594 (let ((header (gnus-gethash (int-to-string article)
9595 gnus-newsgroup-headers-hashtb-by-number)))
9596 (if (vectorp header)
9597 ;; It's a real article.
9598 (setq article (header-id header))
9599 ;; It is an extracted pseudo-article.
9601 (gnus-request-pseudo-article header)))))
9604 (if (and gnus-use-cache
9606 (gnus-cache-request-article article group))
9608 ;; Get the article and into the article buffer.
9612 (let ((gnus-override-method
9613 (and (stringp article) gnus-refer-article-method)))
9614 (and (gnus-request-article article group (current-buffer))
9618 (defun gnus-read-header (id)
9619 "Read the headers of article ID and enter them into the Gnus system."
9620 (or gnus-newsgroup-headers-hashtb-by-number
9621 (gnus-make-headers-hashtable-by-number))
9623 (if (not (setq header
9624 (car (if (let ((gnus-nov-is-evil t))
9625 (gnus-retrieve-headers
9626 (list id) gnus-newsgroup-name))
9627 (gnus-get-newsgroup-headers)))))
9630 (header-set-number header gnus-reffed-article-number))
9631 (setq gnus-newsgroup-headers (cons header gnus-newsgroup-headers))
9632 (gnus-sethash (int-to-string (header-number header)) header
9633 gnus-newsgroup-headers-hashtb-by-number)
9635 (setq gnus-reffed-article-number (1- gnus-reffed-article-number)))
9636 (setq gnus-current-headers header)
9639 (defun gnus-article-prepare (article &optional all-headers header)
9640 "Prepare ARTICLE in article mode buffer.
9641 ARTICLE should either be an article number or a Message-ID.
9642 If ARTICLE is an id, HEADER should be the article headers.
9643 If ALL-HEADERS is non-nil, no headers are hidden."
9645 ;; Make sure we start in a summary buffer.
9646 (or (eq major-mode 'gnus-summary-mode)
9647 (set-buffer gnus-summary-buffer))
9648 (setq gnus-summary-buffer (current-buffer))
9649 ;; Make sure the connection to the server is alive.
9650 (or (gnus-server-opened (gnus-find-method-for-group gnus-newsgroup-name))
9652 (gnus-check-news-server
9653 (gnus-find-method-for-group gnus-newsgroup-name))
9654 (gnus-request-group gnus-newsgroup-name t)))
9655 (or gnus-newsgroup-headers-hashtb-by-number
9656 (gnus-make-headers-hashtable-by-number))
9657 (let* ((article (if header (header-number header) article))
9658 (summary-buffer (current-buffer))
9659 (internal-hook gnus-article-internal-prepare-hook)
9660 (group gnus-newsgroup-name)
9663 (gnus-article-setup-buffer)
9664 (set-buffer gnus-article-buffer)
9665 (let ((buffer-read-only nil))
9666 (if (not (setq result (gnus-request-article-this-buffer
9668 ;; There is no such article.
9671 (set-buffer gnus-summary-buffer)
9672 (setq gnus-current-article 0)
9673 (and (numberp article)
9674 (gnus-summary-mark-as-read article gnus-canceled-mark))
9675 (gnus-message 1 "No such article (may be canceled)")
9676 (and (numberp article)
9677 (setq gnus-current-article article))
9679 (and (numberp article)
9680 (setq gnus-article-current
9681 (cons gnus-newsgroup-name article)))
9683 (if (not (eq result 'article))
9686 (set-buffer summary-buffer)
9687 (setq gnus-last-article gnus-current-article
9688 gnus-newsgroup-history (cons gnus-current-article
9689 gnus-newsgroup-history)
9690 gnus-current-article 0
9691 gnus-current-headers nil
9692 gnus-article-current nil)
9693 (gnus-configure-windows 'article)
9694 (gnus-set-global-variables))
9695 (gnus-set-mode-line 'article))
9696 ;; The result from the `request' was an actual article -
9697 ;; or at least some text that is now displayed in the
9699 (if (and (numberp article)
9700 (not (eq article gnus-current-article)))
9701 ;; Seems like a new article has been selected.
9702 ;; `gnus-current-article' must be an article number.
9704 (set-buffer summary-buffer)
9705 (setq gnus-last-article gnus-current-article
9706 gnus-newsgroup-history (cons gnus-current-article
9707 gnus-newsgroup-history)
9708 gnus-current-article article
9709 gnus-current-headers
9710 (gnus-get-header-by-number gnus-current-article)
9711 gnus-article-current
9712 (cons gnus-newsgroup-name gnus-current-article))
9713 (run-hooks 'gnus-mark-article-hook)
9714 (gnus-set-mode-line 'summary)
9716 (run-hooks 'gnus-visual-mark-article-hook))
9717 ;; Set the global newsgroup variables here.
9718 ;; Suggested by Jim Sisolak
9719 ;; <sisolak@trans4.neep.wisc.edu>.
9720 (gnus-set-global-variables)
9722 (gnus-cache-possibly-enter-article
9724 (gnus-get-header-by-number article)
9725 (memq article gnus-newsgroup-marked)
9726 (memq article gnus-newsgroup-dormant)
9727 (memq article gnus-newsgroup-unreads)))))
9728 ;; gnus-have-all-headers must be either T or NIL.
9729 (setq gnus-have-all-headers
9730 (not (not (or all-headers gnus-show-all-headers))))
9731 ;; Hooks for getting information from the article.
9732 ;; This hook must be called before being narrowed.
9733 (run-hooks 'internal-hook)
9734 (run-hooks 'gnus-article-prepare-hook)
9735 ;; Decode MIME message.
9736 (if (and gnus-show-mime
9737 (gnus-fetch-field "Mime-Version"))
9738 (funcall gnus-show-mime-method))
9739 ;; Perform the article display hooks.
9740 (let ((buffer-read-only nil))
9741 (run-hooks 'gnus-article-display-hook))
9743 (goto-char (point-min))
9744 (and gnus-break-pages (gnus-narrow-to-page))
9745 (gnus-set-mode-line 'article)
9746 (gnus-configure-windows 'article)
9747 (goto-char (point-min))
9750 (defun gnus-article-show-all-headers ()
9751 "Show all article headers in article mode buffer."
9753 (gnus-article-setup-buffer)
9754 (set-buffer gnus-article-buffer)
9755 (let ((buffer-read-only nil))
9756 (remove-text-properties (point-min) (point-max)
9757 gnus-hidden-properties))))
9759 (defun gnus-article-hide-headers-if-wanted ()
9760 "Hide unwanted headers if `gnus-have-all-headers' is nil.
9761 Provided for backwards compatability."
9762 (or gnus-have-all-headers
9763 (gnus-article-hide-headers)))
9765 (defun gnus-article-hide-headers (&optional delete)
9766 "Hide unwanted headers and possibly sort them as well."
9769 (set-buffer gnus-article-buffer)
9771 (let ((sorted gnus-sorted-header-list)
9772 (buffer-read-only nil)
9773 want want-list beg want-l)
9774 ;; First we narrow to just the headers.
9776 (goto-char (point-min))
9777 ;; Hide any "From " lines at the beginning of (mail) articles.
9778 (while (looking-at "From ")
9781 (add-text-properties (point-min) (point) gnus-hidden-properties))
9782 ;; Then treat the rest of the header lines.
9785 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
9786 ;; Then we use the two regular expressions
9787 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
9788 ;; select which header lines is to remain visible in the
9790 (goto-char (point-min))
9791 (while (re-search-forward "^[^ \t]*:" nil t)
9793 ;; We add the headers we want to keep to a list and delete
9794 ;; them from the buffer.
9795 (if (or (and (stringp gnus-visible-headers)
9796 (looking-at gnus-visible-headers))
9797 (and (not (stringp gnus-visible-headers))
9798 (stringp gnus-ignored-headers)
9799 (not (looking-at gnus-ignored-headers))))
9803 ;; Be sure to get multi-line headers...
9804 (re-search-forward "^[^ \t]*:" nil t)
9807 (cons (buffer-substring beg (point)) want-list))
9808 (delete-region beg (point))
9811 ;; Next we perform the sorting by looking at
9812 ;; `gnus-sorted-header-list'.
9813 (goto-char (point-min))
9814 (while (and sorted want-list)
9815 (setq want-l want-list)
9817 (not (string-match (car sorted) (car want-l))))
9818 (setq want-l (cdr want-l)))
9821 (insert (car want-l))
9822 (setq want-list (delq (car want-l) want-list))))
9823 (setq sorted (cdr sorted)))
9824 ;; Any headers that were not matched by the sorted list we
9825 ;; just tack on the end of the visible header list.
9827 (insert (car want-list))
9828 (setq want-list (cdr want-list)))
9829 ;; And finally we make the unwanted headers invisible.
9831 (delete-region (point) (point-max))
9832 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
9833 (add-text-properties (point) (point-max) gnus-hidden-properties))))))
9835 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
9836 (defun gnus-article-treat-overstrike ()
9837 "Translate overstrikes into bold text."
9840 (set-buffer gnus-article-buffer)
9841 (let ((buffer-read-only nil))
9842 (while (search-forward "\b" nil t)
9843 (let ((next (following-char))
9844 (previous (char-after (- (point) 2))))
9845 (cond ((eq next previous)
9846 (delete-region (- (point) 2) (point))
9847 (put-text-property (point) (1+ (point))
9850 (delete-region (1- (point)) (1+ (point)))
9851 (put-text-property (1- (point)) (point)
9854 (delete-region (- (point) 2) (point))
9855 (put-text-property (point) (1+ (point))
9856 'face 'underline))))))))
9858 (defun gnus-article-word-wrap ()
9859 "Format too long lines."
9862 (set-buffer gnus-article-buffer)
9863 (let ((buffer-read-only nil))
9864 (goto-char (point-min))
9865 (search-forward "\n\n" nil t)
9867 (let ((paragraph-start "^\\W"))
9869 (and (>= (current-column) (window-width))
9870 (/= (preceding-char) ?:)
9871 (fill-paragraph nil))
9872 (end-of-line 2))))))
9874 (defun gnus-article-remove-cr ()
9875 "Remove carriage returns from an article."
9878 (set-buffer gnus-article-buffer)
9879 (let ((buffer-read-only nil))
9880 (goto-char (point-min))
9881 (while (search-forward "\r" nil t)
9882 (replace-match "" t t)))))
9884 (defun gnus-article-display-x-face ()
9885 "Look for an X-Face header and display it if present."
9888 (set-buffer gnus-article-buffer)
9889 (goto-char (point-min))
9890 (if (or (not gnus-article-x-face-command)
9891 (and (re-search-forward "^\\($\\|X-Face: \\)" nil t)
9895 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
9896 (if (symbolp gnus-article-x-face-command)
9897 (and (or (fboundp gnus-article-x-face-command)
9898 (error "%s is not a function"
9899 gnus-article-x-face-command))
9900 (funcall gnus-article-x-face-command beg end))
9901 (call-process-region beg end "sh" nil 0 nil
9902 "-c" gnus-article-x-face-command))))))
9904 (defun gnus-article-de-quoted-unreadable (&optional force)
9905 "Do a naïve translation of a quoted-printable-encoded article.
9906 This is in no way, shape or form meant as a replacement for real MIME
9907 processing, but is simply a stop-gap measure until MIME support is
9909 If FORCE, decode the article whether it is marked as quoted-printable
9911 (interactive (list 'force))
9913 (set-buffer gnus-article-buffer)
9914 (let ((case-fold-search t)
9915 (buffer-read-only nil)
9916 (type (gnus-fetch-field "content-transfer-encoding")))
9917 (if (or force (and type (string-match "quoted-printable" type)))
9919 (goto-char (point-min))
9920 (search-forward "\n\n" nil 'move)
9921 (gnus-mime-decode-quoted-printable (point) (point-max)))))))
9923 (defun gnus-mime-decode-quoted-printable (from to)
9924 ;; Decode quoted-printable from region between FROM and TO.
9927 (while (search-forward "=" to t)
9928 (cond ((eq (following-char) ?\n)
9931 ((looking-at "[0-9A-F][0-9A-F]")
9933 (insert (hexl-hex-string-to-integer
9934 (buffer-substring (point) (+ 2 (point)))))
9936 ((gnus-message 3 "Malformed MIME quoted-printable message"))))))
9939 (defun gnus-article-date-ut (&optional type)
9940 "Convert DATE date to universal time in the current article.
9941 If TYPE is `local', convert to local time; if it is `lapsed', output
9942 how much time has lapsed since DATE."
9943 (interactive (list 'ut))
9944 (let ((date (header-date (or gnus-current-headers
9945 (gnus-get-header-by-number
9946 (gnus-summary-article-number))))))
9948 (set-buffer gnus-article-buffer)
9949 (let ((buffer-read-only nil))
9950 (goto-char (point-min))
9951 (if (re-search-forward "^Date: \\|^X-Sent: " nil t)
9952 (delete-region (gnus-point-at-bol)
9953 (progn (forward-line 1) (point)))
9954 (- (search-forward "\n\n") 2))
9958 (concat "Date: " (timezone-make-date-arpa-standard date) "\n"))
9960 (concat "Date: " (timezone-make-date-arpa-standard date nil "UT")
9963 (let* ((sec (- (gnus-seconds-since-epoch
9964 (timezone-make-date-arpa-standard
9965 (current-time-string) (current-time-zone) "UT"))
9966 (gnus-seconds-since-epoch
9967 (timezone-make-date-arpa-standard date nil "UT"))))
9968 (units (list (cons 'year (* 365.25 24 60 60))
9969 (cons 'week (* 7 24 60 60))
9970 (cons 'day (* 24 60 60))
9971 (cons 'hour (* 60 60))
9979 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
9981 (setq sec (- sec (* num (cdr unit))))
9983 (concat (if prev ", " "") (int-to-string (floor num))
9984 " " (symbol-name (car unit))
9985 (if (> num 1) "s" ""))
9990 (error "Unknown conversion type: %s" type))))))))
9992 (defun gnus-article-date-local ()
9993 "Convert the current article date to the local timezone."
9995 (gnus-article-date-ut 'local))
9997 (defun gnus-article-date-lapsed ()
9998 "Convert the current article date to time lapsed since it was sent."
10000 (gnus-article-date-ut 'lapsed))
10002 (defun gnus-article-maybe-highlight ()
10003 (if gnus-visual (gnus-article-highlight)))
10007 (defun gnus-output-to-rmail (file-name)
10008 "Append the current article to an Rmail file named FILE-NAME."
10010 ;; Most of these codes are borrowed from rmailout.el.
10011 (setq file-name (expand-file-name file-name))
10012 (setq rmail-default-rmail-file file-name)
10013 (let ((artbuf (current-buffer))
10014 (tmpbuf (get-buffer-create " *Gnus-output*")))
10016 (or (get-file-buffer file-name)
10017 (file-exists-p file-name)
10018 (if (gnus-yes-or-no-p
10019 (concat "\"" file-name "\" does not exist, create it? "))
10020 (let ((file-buffer (create-file-buffer file-name)))
10022 (set-buffer file-buffer)
10023 (rmail-insert-rmail-file-header)
10024 (let ((require-final-newline nil))
10025 (write-region (point-min) (point-max) file-name t 1)))
10026 (kill-buffer file-buffer))
10027 (error "Output file does not exist")))
10028 (set-buffer tmpbuf)
10029 (buffer-disable-undo (current-buffer))
10031 (insert-buffer-substring artbuf)
10032 (gnus-convert-article-to-rmail)
10033 ;; Decide whether to append to a file or to an Emacs buffer.
10034 (let ((outbuf (get-file-buffer file-name)))
10036 (append-to-file (point-min) (point-max) file-name)
10037 ;; File has been visited, in buffer OUTBUF.
10038 (set-buffer outbuf)
10039 (let ((buffer-read-only nil)
10040 (msg (and (boundp 'rmail-current-message)
10041 (symbol-value 'rmail-current-message))))
10042 ;; If MSG is non-nil, buffer is in RMAIL mode.
10045 (narrow-to-region (point-max) (point-max))))
10046 (insert-buffer-substring tmpbuf)
10049 (goto-char (point-min))
10051 (search-backward "\^_")
10052 (narrow-to-region (point) (point-max))
10053 (goto-char (1+ (point-min)))
10054 (rmail-count-new-messages t)
10055 (rmail-show-message msg)))))))
10056 (kill-buffer tmpbuf)))
10058 (defun gnus-output-to-file (file-name)
10059 "Append the current article to a file named FILE-NAME."
10060 (setq file-name (expand-file-name file-name))
10061 (let ((artbuf (current-buffer))
10062 (tmpbuf (get-buffer-create " *Gnus-output*")))
10064 (set-buffer tmpbuf)
10065 (buffer-disable-undo (current-buffer))
10067 (insert-buffer-substring artbuf)
10068 ;; Append newline at end of the buffer as separator, and then
10069 ;; save it to file.
10070 (goto-char (point-max))
10072 (append-to-file (point-min) (point-max) file-name))
10073 (kill-buffer tmpbuf)))
10075 (defun gnus-convert-article-to-rmail ()
10076 "Convert article in current buffer to Rmail message format."
10077 (let ((buffer-read-only nil))
10078 ;; Convert article directly into Babyl format.
10079 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
10080 (goto-char (point-min))
10081 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
10082 (while (search-forward "\n\^_" nil t) ;single char
10083 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
10084 (goto-char (point-max))
10087 (defun gnus-narrow-to-page (&optional arg)
10088 "Make text outside current page invisible except for page delimiter.
10089 A numeric arg specifies to move forward or backward by that many pages,
10090 thus showing a page other than the one point was originally in."
10092 (setq arg (if arg (prefix-numeric-value arg) 0))
10094 (forward-page -1) ;Beginning of current page.
10099 (forward-page (1- arg))))
10100 ;; Find the end of the page.
10102 ;; If we stopped due to end of buffer, stay there.
10103 ;; If we stopped after a page delimiter, put end of restriction
10104 ;; at the beginning of that line.
10105 ;; These are commented out.
10106 ;; (if (save-excursion (beginning-of-line)
10107 ;; (looking-at page-delimiter))
10108 ;; (beginning-of-line))
10109 (narrow-to-region (point)
10111 ;; Find the top of the page.
10113 ;; If we found beginning of buffer, stay there.
10114 ;; If extra text follows page delimiter on same line,
10116 ;; Otherwise, show text starting with following line.
10117 (if (and (eolp) (not (bobp)))
10121 (defun gnus-gmt-to-local ()
10122 "Rewrite Date header described in GMT to local in current buffer.
10123 Intended to be used with gnus-article-prepare-hook."
10127 (goto-char (point-min))
10128 (narrow-to-region (point-min)
10129 (progn (search-forward "\n\n" nil 'move) (point)))
10130 (goto-char (point-min))
10131 (if (re-search-forward "^Date:[ \t]\\(.*\\)$" nil t)
10132 (let ((buffer-read-only nil)
10133 (date (buffer-substring (match-beginning 1) (match-end 1))))
10134 (delete-region (match-beginning 1) (match-end 1))
10136 (timezone-make-date-arpa-standard
10137 date nil (current-time-zone))))))))
10140 ;; Article mode commands
10142 (defun gnus-article-next-page (lines)
10143 "Show next page of current article.
10144 If end of article, return non-nil. Otherwise return nil.
10145 Argument LINES specifies lines to be scrolled up."
10147 (move-to-window-line -1)
10148 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
10149 (if (save-excursion
10151 (and (pos-visible-in-window-p) ;Not continuation line.
10153 ;; Nothing in this page.
10154 (if (or (not gnus-break-pages)
10157 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
10159 (gnus-narrow-to-page 1) ;Go to next page.
10161 ;; More in this page.
10165 ;; Long lines may cause an end-of-buffer error.
10166 (goto-char (point-max))))
10169 (defun gnus-article-prev-page (lines)
10170 "Show previous page of current article.
10171 Argument LINES specifies lines to be scrolled down."
10173 (move-to-window-line 0)
10174 (if (and gnus-break-pages
10176 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
10178 (gnus-narrow-to-page -1) ;Go to previous page.
10179 (goto-char (point-max))
10181 (scroll-down lines)))
10183 (defun gnus-article-refer-article ()
10184 "Read article specified by message-id around point."
10186 (search-forward ">" nil t) ;Move point to end of "<....>".
10187 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
10189 (buffer-substring (match-beginning 1) (match-end 1))))
10190 (set-buffer gnus-summary-buffer)
10191 (gnus-summary-refer-article message-id))
10192 (error "No references around point")))
10194 (defun gnus-article-mail (yank)
10195 "Send a reply to the address near point.
10196 If YANK is non-nil, include the original article."
10200 (save-excursion (re-search-backward "[ \t\n]" nil t) (1+ (point)))
10201 (save-excursion (re-search-forward "[ \t\n]" nil t) (1- (point))))))
10204 (switch-to-buffer gnus-summary-buffer)
10205 (funcall gnus-mail-reply-method yank address)))))
10207 (defun gnus-article-mail-with-original ()
10208 "Send a reply to the address near point and include the original article."
10210 (gnus-article-mail 'yank))
10212 (defun gnus-article-show-summary ()
10213 "Reconfigure windows to show summary buffer."
10215 (gnus-configure-windows 'article)
10216 (gnus-summary-goto-subject gnus-current-article))
10218 (defun gnus-article-describe-briefly ()
10219 "Describe article mode commands briefly."
10222 (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")))
10224 (defun gnus-article-summary-command ()
10225 "Execute the last keystroke in the summary buffer."
10227 (let ((obuf (current-buffer))
10228 (owin (current-window-configuration)))
10229 (switch-to-buffer gnus-summary-buffer 'norecord)
10230 (execute-kbd-macro (this-command-keys))
10232 (let ((npoint (point)))
10233 (set-window-configuration owin)
10234 (set-window-start (get-buffer-window (current-buffer)) (point)))))
10236 (defun gnus-article-summary-command-nosave ()
10237 "Execute the last keystroke in the summary buffer."
10239 (let ((obuf (current-buffer))
10240 (owin (current-window-configuration)))
10241 (switch-to-buffer gnus-summary-buffer 'norecord)
10242 (execute-kbd-macro (this-command-keys))))
10244 ;; caesar-region written by phr@prep.ai.mit.edu Nov 86
10245 ;; Modified by tower@prep Nov 86
10246 ;; Modified by umerin@flab.flab.Fujitsu.JUNET for ROT47.
10248 (defun gnus-caesar-region (&optional n)
10249 "Caesar rotation of region by N, default 13, for decrypting netnews.
10250 ROT47 will be performed for Japanese text in any case."
10251 (interactive (if current-prefix-arg ; Was there a prefix arg?
10252 (list (prefix-numeric-value current-prefix-arg))
10254 (cond ((not (numberp n)) (setq n 13))
10255 (t (setq n (mod n 26)))) ;canonicalize N
10256 (if (not (zerop n)) ; no action needed for a rot of 0
10258 (if (or (not (boundp 'caesar-translate-table))
10259 (not caesar-translate-table)
10260 (/= (aref caesar-translate-table ?a) (+ ?a n)))
10262 (lower "abcdefghijklmnopqrstuvwxyz")
10264 (gnus-message 9 "Building caesar-translate-table...")
10265 (setq caesar-translate-table (make-vector 256 0))
10267 (aset caesar-translate-table i i)
10269 (setq lower (concat lower lower)
10270 upper (upcase lower)
10273 (aset caesar-translate-table (+ ?a i) (aref lower (+ i n)))
10274 (aset caesar-translate-table (+ ?A i) (aref upper (+ i n)))
10276 ;; ROT47 for Japanese text.
10277 ;; Thanks to ichikawa@flab.fujitsu.junet.
10279 (let ((t1 (logior ?O 128))
10280 (t2 (logior ?! 128))
10281 (t3 (logior ?~ 128)))
10283 (aset caesar-translate-table i
10284 (let ((v (aref caesar-translate-table i)))
10285 (if (<= v t1) (if (< v t2) v (+ v 47))
10286 (if (<= v t3) (- v 47) v))))
10288 (gnus-message 9 "Building caesar-translate-table... done")))
10289 (let ((from (region-beginning))
10292 (setq str (buffer-substring from to))
10293 (setq len (length str))
10295 (aset str i (aref caesar-translate-table (aref str i)))
10298 (delete-region from to)
10302 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
10305 (defalias 'gnus-batch-kill 'gnus-batch-score)
10307 (defun gnus-batch-score ()
10308 "Run batched scoring.
10309 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
10310 Newsgroups is a list of strings in Bnews format. If you want to score
10311 the comp hierarchy, you'd say \"comp.all\". If you would not like to
10312 score the alt hierarchy, you'd say \"!alt.all\"."
10315 (gnus-newsrc-parse-options
10316 (apply (function concat)
10317 (mapcar (lambda (g) (concat g " "))
10318 command-line-args-left))))
10319 (gnus-expert-user t)
10320 (nnmail-spool-file nil)
10321 (gnus-use-dribble-file nil)
10322 (yes (car yes-and-no))
10323 (no (cdr yes-and-no))
10324 group subscribed newsrc entry
10325 ;; Disable verbose message.
10326 gnus-novice-user gnus-large-newsgroup)
10327 ;; Eat all arguments.
10328 (setq command-line-args-left nil)
10331 ;; Apply kills to specified newsgroups in command line arguments.
10332 (setq newsrc (cdr gnus-newsrc-alist))
10334 (setq group (car (car newsrc)))
10335 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
10336 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
10338 (or (eq (car entry) t)
10339 (not (zerop (car entry)))))
10340 (if yes (string-match yes group) t)
10341 (or (null no) (not (string-match no group))))
10343 (gnus-summary-read-group group nil t)
10344 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
10345 (gnus-summary-exit))))
10346 (setq newsrc (cdr newsrc)))
10348 (switch-to-buffer gnus-group-buffer)
10349 (gnus-group-save-newsrc)))
10351 (defun gnus-apply-kill-file ()
10352 "Apply a kill file to the current newsgroup.
10353 Returns the number of articles marked as read."
10354 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
10355 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
10356 (gnus-apply-kill-file-internal)
10359 (defun gnus-kill-save-kill-buffer ()
10361 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
10362 (if (get-file-buffer file)
10364 (set-buffer (get-file-buffer file))
10365 (and (buffer-modified-p) (save-buffer))
10366 (kill-buffer (current-buffer)))))))
10368 (defvar gnus-kill-file-name "KILL"
10369 "Suffix of the kill files.")
10371 (defun gnus-newsgroup-kill-file (newsgroup)
10372 "Return the name of a kill file name for NEWSGROUP.
10373 If NEWSGROUP is nil, return the global kill file name instead."
10374 (cond ((or (null newsgroup)
10375 (string-equal newsgroup ""))
10376 ;; The global KILL file is placed at top of the directory.
10377 (expand-file-name gnus-kill-file-name
10378 (or gnus-kill-files-directory "~/News")))
10379 ((gnus-use-long-file-name 'not-kill)
10380 ;; Append ".KILL" to newsgroup name.
10381 (expand-file-name (concat newsgroup "." gnus-kill-file-name)
10382 (or gnus-kill-files-directory "~/News")))
10384 ;; Place "KILL" under the hierarchical directory.
10385 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
10386 "/" gnus-kill-file-name)
10387 (or gnus-kill-files-directory "~/News")))))
10394 (defvar gnus-dribble-ignore nil)
10396 (defun gnus-dribble-file-name ()
10397 (concat gnus-startup-file "-dribble"))
10399 (defun gnus-dribble-open ()
10402 (setq gnus-dribble-buffer (find-file-noselect (gnus-dribble-file-name))))
10403 (buffer-disable-undo (current-buffer))
10404 (bury-buffer gnus-dribble-buffer)
10406 (goto-char (point-max))))
10408 (defun gnus-dribble-enter (string)
10409 (if (and (not gnus-dribble-ignore)
10410 gnus-dribble-buffer
10411 (buffer-name gnus-dribble-buffer))
10412 (let ((obuf (current-buffer)))
10413 (set-buffer gnus-dribble-buffer)
10414 (insert string "\n")
10415 (set-window-point (get-buffer-window (current-buffer)) (point-max))
10416 (set-buffer obuf))))
10418 (defun gnus-dribble-read-file ()
10419 (let ((dribble-file (gnus-dribble-file-name)))
10421 (set-buffer (setq gnus-dribble-buffer
10423 (file-name-nondirectory dribble-file))))
10424 (gnus-add-current-to-buffer-list)
10426 (set-visited-file-name dribble-file)
10427 (buffer-disable-undo (current-buffer))
10428 (bury-buffer (current-buffer))
10429 (set-buffer-modified-p nil)
10430 (let ((auto (make-auto-save-file-name))
10431 (gnus-dribble-ignore t))
10432 (if (or (file-exists-p auto) (file-exists-p dribble-file))
10434 (if (file-newer-than-file-p auto dribble-file)
10435 (setq dribble-file auto))
10436 (insert-file-contents dribble-file)
10437 (if (not (zerop (buffer-size)))
10438 (set-buffer-modified-p t))
10440 "Auto-save file exists. Do you want to read it? ")
10442 (gnus-message 5 "Reading %s..." dribble-file)
10443 (eval-current-buffer)
10444 (gnus-message 5 "Reading %s...done" dribble-file)))))))))
10446 (defun gnus-dribble-delete-file ()
10447 (if (file-exists-p (gnus-dribble-file-name))
10448 (delete-file (gnus-dribble-file-name)))
10449 (if gnus-dribble-buffer
10451 (set-buffer gnus-dribble-buffer)
10452 (let ((auto (make-auto-save-file-name)))
10453 (if (file-exists-p auto)
10454 (delete-file auto))
10456 (set-buffer-modified-p nil)))))
10458 (defun gnus-dribble-save ()
10459 (if (and gnus-dribble-buffer
10460 (buffer-name gnus-dribble-buffer))
10462 (set-buffer gnus-dribble-buffer)
10465 (defun gnus-dribble-clear ()
10467 (if (gnus-buffer-exists-p gnus-dribble-buffer)
10469 (set-buffer gnus-dribble-buffer)
10471 (set-buffer-modified-p nil)
10472 (setq buffer-saved-size (buffer-size))))))
10475 ;;; Server Communication
10478 ;; All the Gnus backends have the same interface, and should return
10479 ;; data in a similar format. Below is an overview of what functions
10480 ;; these packages must supply and what results they should return.
10484 ;; `nntp-server-buffer' - All data should be returned to Gnus in this
10487 ;; Functions for the imaginary backend `choke':
10489 ;; `choke-retrieve-headers ARTICLES &optional GROUP SERVER'
10490 ;; Should return all headers for all ARTICLES, or return NOV lines for
10493 ;; `choke-request-group GROUP &optional SERVER DISCARD'
10494 ;; Switch to GROUP. If DISCARD is nil, active information on the group
10495 ;; must be returned.
10497 ;; `choke-close-group GROUP &optional SERVER'
10498 ;; Close group. Most backends won't have to do anything with this
10499 ;; call, but it is an opportunity to clean up, if that is needed. It
10500 ;; is called when Gnus exits a group.
10502 ;; `choke-request-article ARTICLE &optional GROUP SERVER'
10503 ;; Return ARTICLE, which is either an article number or
10504 ;; message-id. Note that not all backends can return articles based on
10507 ;; `choke-request-list SERVER'
10508 ;; Return a list of all newsgroups on SERVER.
10510 ;; `choke-request-list-newsgroups SERVER'
10511 ;; Return a list of descriptions of all newsgroups on SERVER.
10513 ;; `choke-request-newgroups DATE &optional SERVER'
10514 ;; Return a list of all groups that have arrived after DATE on
10515 ;; SERVER. Note that the date doesn't have to be respected - Gnus will
10516 ;; always check whether the groups are old or not. Backends that do
10517 ;; not store date information may just return the entire list of
10518 ;; groups, although this might not be a good idea in general.
10520 ;; `choke-request-post-buffer METHOD HEADER ARTICLE-BUFFER GROUP INFO'
10521 ;; Should return a buffer that is suitable for "posting". nnspool and
10522 ;; nntp return a `*post-buffer*', and nnmail return a `*mail*'
10523 ;; buffer. This function should fill out the appropriate headers.
10525 ;; `choke-request-post &optional SERVER'
10526 ;; Function that will be called from a buffer to be posted.
10528 ;; `choke-open-server SERVER &optional ARGUMENT'
10529 ;; Open a connection to SERVER.
10531 ;; `choke-close-server &optional SERVER'
10532 ;; Close the connection to SERVER.
10534 ;; `choke-server-opened &optional SERVER'
10535 ;; Whether the conenction to SERVER is opened or not.
10537 ;; `choke-server-status &optional SERVER'
10538 ;; Should return a status string (not in the nntp buffer, but as the
10539 ;; result of the function).
10541 ;; `choke-retrieve-groups GROUPS &optional SERVER'
10542 ;; Optional function for retrieving active file info on all groups in
10543 ;; GROUPS. Two return formats are supported: The normal active file
10544 ;; format, and a list of GROUP lines. This function should return (as
10545 ;; a function value) either `active' or `group', depending on what
10546 ;; format it returns.
10548 ;; The following functions are optional and apply only to backends
10549 ;; that are able to control the contents of their groups totally
10550 ;; (ie. mail backends.) Backends that aren't able to do that
10551 ;; shouldn't define these functions at all. Gnus will check for their
10552 ;; presence before attempting to call them.
10554 ;; `choke-request-expire-articles ARTICLES &optional NEWSGROUP SERVER'
10555 ;; Should expire (according to some aging scheme) all ARTICLES. Most
10556 ;; backends will not be able to expire articles. Should return a list
10557 ;; of all articles that were not expired.
10559 ;; `choke-request-move-article ARTICLE GROUP SERVER ACCEPT-FORM &optional LAST'
10560 ;; Should move ARTICLE from GROUP on SERVER by using ACCEPT-FORM.
10561 ;; Removes any information it has added to the article (extra headers,
10562 ;; whatever - make it as clean as possible), and then passes the
10563 ;; article on by evaling ACCEPT-FORM, which is normally a call to the
10564 ;; function described below. If the ACCEPT-FORM returns a non-nil
10565 ;; value, the article should then be deleted. If LAST is nil, that
10566 ;; means that there will be further calls to this function. This might
10567 ;; be taken as an advice not to save buffers/internal variables just
10568 ;; yet, but wait until the last call to speed things up.
10570 ;; `choke-request-accept-article GROUP &optional LAST'
10571 ;; The contents of the current buffer will be put into GROUP. There
10572 ;; should, of course, be an article in the current buffer. This
10573 ;; function is normally only called by the function described above,
10574 ;; and LAST works the same way as in that function.
10576 ;; `choke-request-replace-article ARTICLE GROUP BUFFER'
10577 ;; Replace ARTICLE in GROUP with the contents of BUFFER.
10578 ;; This provides an easy interface for allowing editing of
10579 ;; articles. Note that even headers may be edited, so the backend has
10580 ;; to update any tables (nov buffers, etc) that it maintains after
10581 ;; replacing the article.
10583 ;; `choke-request-create-group GROUP &optional SERVER'
10584 ;; Create GROUP on SERVER. This might be a new, empty group, or it
10585 ;; might be a group that already exists, but hasn't been registered
10588 ;; All these functions must return nil if they couldn't service the
10589 ;; request. If the optional arguments are not supplied, some "current"
10590 ;; or "default" values should be used. In short, one should emulate an
10591 ;; NNTP server, in a way.
10593 ;; If you want to write a new backend, you just have to supply the
10594 ;; functions listed above. In addition, you must enter the new backend
10595 ;; into the list of valid select methods:
10596 ;; (setq gnus-valid-select-methods
10597 ;; (cons '("choke" mail) gnus-valid-select-methods))
10598 ;; The first element in this list is the name of the backend. Other
10599 ;; elemnets may be `mail' (for mail groups), `post' (for news
10600 ;; groups), `none' (neither), `respool' (for groups that can control
10601 ;; their contents).
10603 (defun gnus-start-news-server (&optional confirm)
10604 "Open a method for getting news.
10605 If CONFIRM is non-nil, the user will be asked for an NNTP server."
10607 (if gnus-current-select-method
10608 ;; Stream is already opened.
10610 ;; Open NNTP server.
10611 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
10614 ;; Read server name with completion.
10615 (setq gnus-nntp-server
10616 (completing-read "NNTP server: "
10617 (mapcar (lambda (server) (list server))
10618 (cons (list gnus-nntp-server)
10619 gnus-secondary-servers))
10620 nil nil gnus-nntp-server))))
10622 (if (and gnus-nntp-server
10623 (stringp gnus-nntp-server)
10624 (not (string= gnus-nntp-server "")))
10625 (setq gnus-select-method
10626 (cond ((or (string= gnus-nntp-server "")
10627 (string= gnus-nntp-server "::"))
10628 (list 'nnspool (system-name)))
10629 ((string-match "^:" gnus-nntp-server)
10630 (list 'nnmh gnus-nntp-server
10631 (list 'nnmh-directory
10632 (file-name-as-directory
10634 (concat "~/" (substring
10635 gnus-nntp-server 1)))))))
10637 (list 'nntp gnus-nntp-server)))))
10639 (setq how (car gnus-select-method))
10640 (setq where (car (cdr gnus-select-method)))
10641 (cond ((eq how 'nnspool)
10643 (gnus-message 5 "Looking up local news spool..."))
10646 (gnus-message 5 "Looking up mh spool..."))
10649 (setq gnus-current-select-method gnus-select-method)
10650 (run-hooks 'gnus-open-server-hook)
10652 ;; gnus-open-server-hook might have opened it
10653 (gnus-server-opened gnus-select-method)
10654 (gnus-open-server gnus-select-method)
10657 "%s server on %s can't be opened. Continue? "
10658 (car gnus-select-method) (nth 1 gnus-select-method)))
10660 (gnus-message 1 "Couldn't open server on %s"
10661 (nth 1 gnus-select-method))
10665 (defun gnus-check-news-server (&optional method)
10666 "If the news server is down, start it up again."
10667 (let ((method (if method method gnus-select-method)))
10668 (and (stringp method)
10669 (setq method (gnus-server-to-method method)))
10670 (if (gnus-server-opened method)
10671 ;; Stream is already opened.
10674 (gnus-message 5 "Opening server %s on %s..." (car method) (nth 1 method))
10675 (run-hooks 'gnus-open-server-hook)
10676 (or (gnus-server-opened method)
10677 (gnus-open-server method))
10680 (defun gnus-nntp-message (&optional message)
10681 "Check the status of the NNTP server.
10682 If the status of the server is clear and MESSAGE is non-nil, MESSAGE
10683 is returned insted of the status string."
10684 (let ((status (gnus-status-message (gnus-find-method-for-group
10685 gnus-newsgroup-name)))
10686 (message (or message "")))
10687 (if (and (stringp status) (> (length status) 0))
10690 (defun gnus-get-function (method function)
10691 (and (stringp method)
10692 (setq method (gnus-server-to-method method)))
10693 (let ((func (intern (format "%s-%s" (car method) function))))
10694 (if (not (fboundp func))
10696 (require (car method))
10697 (if (not (fboundp func))
10698 (error "No such function: %s" func))))
10701 ;;; Interface functions to the backends.
10703 (defun gnus-open-server (method)
10704 (funcall (gnus-get-function method 'open-server)
10705 (nth 1 method) (nthcdr 2 method)))
10707 (defun gnus-close-server (method)
10708 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
10710 (defun gnus-request-list (method)
10711 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
10713 (defun gnus-request-list-newsgroups (method)
10714 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
10716 (defun gnus-request-newgroups (date method)
10717 (funcall (gnus-get-function method 'request-newgroups)
10718 date (nth 1 method)))
10720 (defun gnus-server-opened (method)
10721 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
10723 (defun gnus-status-message (method)
10724 (let ((method (if (stringp method) (gnus-find-method-for-group method)
10726 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
10728 (defun gnus-request-group (group &optional dont-check)
10729 (let ((method (gnus-find-method-for-group group)))
10730 (funcall (gnus-get-function method 'request-group)
10731 (gnus-group-real-name group) (nth 1 method) dont-check)))
10733 (defun gnus-request-asynchronous (group &optional articles)
10734 (let ((method (gnus-find-method-for-group group)))
10735 (funcall (gnus-get-function method 'request-asynchronous)
10736 (gnus-group-real-name group) (nth 1 method) articles)))
10738 (defun gnus-list-active-group (group)
10739 (let ((method (gnus-find-method-for-group group))
10740 (func 'list-active-group))
10741 (and (gnus-check-backend-function func group)
10742 (funcall (gnus-get-function method func)
10743 (gnus-group-real-name group) (nth 1 method)))))
10745 (defun gnus-request-group-description (group)
10746 (let ((method (gnus-find-method-for-group group))
10747 (func 'request-group-description))
10748 (and (gnus-check-backend-function func group)
10749 (funcall (gnus-get-function method func)
10750 (gnus-group-real-name group) (nth 1 method)))))
10752 (defun gnus-close-group (group)
10753 (let ((method (gnus-find-method-for-group group)))
10754 (funcall (gnus-get-function method 'close-group)
10755 (gnus-group-real-name group) (nth 1 method))))
10757 (defun gnus-retrieve-headers (articles group)
10758 (let ((method (gnus-find-method-for-group group)))
10760 (gnus-cache-retrieve-headers articles group)
10761 (funcall (gnus-get-function method 'retrieve-headers)
10762 articles (gnus-group-real-name group) (nth 1 method)))))
10764 (defun gnus-retrieve-groups (groups method)
10765 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
10767 (defun gnus-request-article (article group &optional buffer)
10768 (let ((method (gnus-find-method-for-group group)))
10769 (funcall (gnus-get-function method 'request-article)
10770 article (gnus-group-real-name group) (nth 1 method) buffer)))
10772 (defun gnus-request-head (article group)
10773 (let ((method (gnus-find-method-for-group group)))
10774 (funcall (gnus-get-function method 'request-head)
10775 article (gnus-group-real-name group) (nth 1 method))))
10777 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
10778 (defun gnus-request-post-buffer (post group subject header artbuf
10779 info follow-to respect-poster)
10780 (let* ((info (or info (and group (nth 2 (gnus-gethash
10781 group gnus-newsrc-hashtb)))))
10783 (if (and gnus-post-method
10784 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>.
10786 (format "%s" (car (gnus-find-method-for-group
10787 gnus-newsgroup-name)))
10788 gnus-valid-select-methods)))
10790 (gnus-find-method-for-group gnus-newsgroup-name))))
10791 (or (gnus-server-opened method)
10792 (gnus-open-server method)
10793 (error "Can't open server %s:%s" (car method) (nth 1 method)))
10794 (let ((mail-self-blind nil)
10795 (mail-archive-file-name nil))
10796 (funcall (gnus-get-function method 'request-post-buffer)
10797 post group subject header artbuf info follow-to
10800 (defun gnus-request-post (method &optional force)
10801 (and (stringp method)
10802 (setq method (gnus-server-to-method method)))
10803 (and (not force) gnus-post-method
10804 (memq 'post (assoc (format "%s" (car method))
10805 gnus-valid-select-methods))
10806 (setq method gnus-post-method))
10807 (funcall (gnus-get-function method 'request-post)
10810 (defun gnus-request-expire-articles (articles group &optional force)
10811 (let ((method (gnus-find-method-for-group group)))
10812 (funcall (gnus-get-function method 'request-expire-articles)
10813 articles (gnus-group-real-name group) (nth 1 method)
10816 (defun gnus-request-move-article
10817 (article group server accept-function &optional last)
10818 (let ((method (gnus-find-method-for-group group)))
10819 (funcall (gnus-get-function method 'request-move-article)
10820 article (gnus-group-real-name group)
10821 (nth 1 method) accept-function last)))
10823 (defun gnus-request-accept-article (group &optional last)
10824 (let ((func (if (symbolp group) group
10825 (car (gnus-find-method-for-group group)))))
10826 (funcall (intern (format "%s-request-accept-article" func))
10827 (if (stringp group) (gnus-group-real-name group) group)
10830 (defun gnus-request-replace-article (article group buffer)
10831 (let ((func (car (gnus-find-method-for-group group))))
10832 (funcall (intern (format "%s-request-replace-article" func))
10833 article (gnus-group-real-name group) buffer)))
10835 (defun gnus-request-create-group (group)
10836 (let ((method (gnus-find-method-for-group group)))
10837 (funcall (gnus-get-function method 'request-create-group)
10838 (gnus-group-real-name group) (nth 1 method))))
10840 (defun gnus-member-of-valid (symbol group)
10841 (memq symbol (assoc
10842 (format "%s" (car (gnus-find-method-for-group group)))
10843 gnus-valid-select-methods)))
10845 (defun gnus-find-method-for-group (group &optional info)
10846 (or gnus-override-method
10848 gnus-select-method)
10849 (let ((info (or info (nth 2 (gnus-gethash group gnus-newsrc-hashtb))))
10852 (not (setq method (nth 4 info))))
10853 (setq method gnus-select-method)
10855 (cond ((stringp method)
10856 (gnus-server-to-method method))
10857 ((stringp (car method))
10858 (gnus-server-extend-method group method))
10861 (gnus-server-add-address method))))
10863 (defun gnus-check-backend-function (func group)
10864 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
10866 (fboundp (intern (format "%s-%s" method func)))))
10868 (defun gnus-methods-using (method)
10869 (let ((valids gnus-valid-select-methods)
10872 (if (memq method (car valids))
10873 (setq outs (cons (car valids) outs)))
10874 (setq valids (cdr valids)))
10878 ;;; Active & Newsrc File Handling
10881 ;; Newsrc related functions.
10882 ;; Gnus internal format of gnus-newsrc-alist:
10883 ;; (("alt.general" 3 (1 . 1))
10884 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
10885 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
10886 ;; The first item is the group name; the second is the subscription
10887 ;; level; the third is either a range of a list of ranges of read
10888 ;; articles, the optional fourth element is a list of marked articles,
10889 ;; the optional fifth element is the select method.
10891 ;; Gnus internal format of gnus-newsrc-hashtb:
10892 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
10893 ;; This is the entry for "alt.misc". The first element is the number
10894 ;; of unread articles in "alt.misc". The cdr of this entry is the
10895 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is
10896 ;; trivial to remove or add new elements into gnus-newsrc-alist
10897 ;; without scanning the entire list. So, to get the actual information
10898 ;; of "alt.misc", you'd say something like
10899 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
10901 ;; Gnus internal format of gnus-active-hashtb:
10905 ;; The only element in each entry in this hash table is a range of
10906 ;; (possibly) available articles. (Articles in this range may have
10907 ;; been expired or cancelled.)
10909 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
10910 ;; ("alt.misc" "alt.test" "alt.general" ...)
10912 (defun gnus-setup-news (&optional rawfile level)
10913 "Setup news information.
10914 If RAWFILE is non-nil, the .newsrc file will also be read.
10915 If LEVEL is non-nil, the news will be set up at level LEVEL."
10916 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
10917 ;; Clear some variables to re-initialize news information.
10918 (if init (setq gnus-newsrc-alist nil gnus-active-hashtb nil))
10920 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
10921 (if init (gnus-read-newsrc-file rawfile))
10923 ;; Read the active file and create `gnus-active-hashtb'.
10924 ;; If `gnus-read-active-file' is nil, then we just create an empty
10925 ;; hash table. The partial filling out of the hash table will be
10926 ;; done in `gnus-get-unread-articles'.
10927 (if (and gnus-read-active-file
10929 (gnus-server-opened gnus-select-method))
10930 (gnus-read-active-file)
10931 (setq gnus-active-hashtb (make-vector 4095 0)))
10933 (and init gnus-use-dribble-file (gnus-dribble-read-file))
10935 ;; Find the number of unread articles in each non-dead group.
10936 (gnus-get-unread-articles (or level (1+ gnus-level-subscribed)))
10937 ;; Find new newsgroups and treat them.
10938 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
10939 (gnus-server-opened gnus-select-method))
10940 (gnus-find-new-newsgroups))
10941 (if (and init gnus-check-bogus-newsgroups
10942 gnus-read-active-file (not level)
10943 (gnus-server-opened gnus-select-method))
10944 (gnus-check-bogus-newsgroups))))
10946 (defun gnus-find-new-newsgroups ()
10947 "Search for new newsgroups and add them.
10948 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
10949 The `-n' option line from .newsrc is respected."
10951 (or (gnus-check-first-time-used)
10952 (if (or (consp gnus-check-new-newsgroups)
10953 (eq gnus-check-new-newsgroups 'ask-server))
10954 (gnus-ask-server-for-new-groups)
10956 group new-newsgroups)
10957 (or gnus-have-read-active-file (gnus-read-active-file))
10958 (setq gnus-newsrc-last-checked-date (current-time-string))
10959 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
10960 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
10961 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
10964 (setq group (symbol-name sym))
10965 (if (or (gnus-gethash group gnus-killed-hashtb)
10966 (gnus-gethash group gnus-newsrc-hashtb))
10968 (let ((do-sub (gnus-matches-options-n group)))
10969 (cond ((eq do-sub 'subscribe)
10970 (setq groups (1+ groups))
10971 (gnus-sethash group group gnus-killed-hashtb)
10973 gnus-subscribe-options-newsgroup-method group))
10974 ((eq do-sub 'ignore)
10977 (setq groups (1+ groups))
10978 (gnus-sethash group group gnus-killed-hashtb)
10979 (if gnus-subscribe-hierarchical-interactive
10980 (setq new-newsgroups (cons group new-newsgroups))
10981 (funcall gnus-subscribe-newsgroup-method group)))))))
10982 gnus-active-hashtb)
10984 (gnus-subscribe-hierarchical-interactive new-newsgroups))
10985 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10987 (gnus-message 6 "%d new newsgroup%s arrived."
10988 groups (if (> groups 1) "s have" " has")))))))
10990 (defun gnus-matches-options-n (group)
10991 ;; Returns `subscribe' if the group is to be uncoditionally
10992 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
10993 ;; no match for the group.
10995 ;; First we check the two user variables.
10997 ((and gnus-options-subscribe
10998 (string-match gnus-options-not-subscribe group))
11000 ((and gnus-options-not-subscribe
11001 (string-match gnus-options-subscribe group))
11003 ;; Then we go through the list that was retrieved from the .newsrc
11004 ;; file. This list has elements on the form
11005 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
11006 ;; is in the reverse order of the options line) is returned.
11008 (let ((regs gnus-newsrc-options-n))
11010 (not (string-match (car (car gnus-newsrc-options-n)) group)))
11011 (setq regs (cdr regs)))
11012 (and regs (cdr (car regs)))))))
11014 (defun gnus-ask-server-for-new-groups ()
11015 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
11016 (methods (cons gnus-select-method
11018 (and (consp gnus-check-new-newsgroups)
11019 gnus-check-new-newsgroups)
11020 gnus-secondary-select-methods)))
11022 (new-date (current-time-string))
11023 hashtb group new-newsgroups got-new)
11024 ;; Go thorugh both primary and secondary select methods and
11025 ;; request new newsgroups.
11027 (if (gnus-request-newgroups date (car methods))
11030 (or hashtb (setq hashtb (gnus-make-hashtable
11031 (count-lines (point-min) (point-max)))))
11032 (set-buffer nntp-server-buffer)
11033 ;; Enter all the new groups in a hashtable.
11034 (gnus-active-to-gnus-format (car methods) hashtb)))
11035 (setq methods (cdr methods)))
11036 (and got-new (setq gnus-newsrc-last-checked-date new-date))
11037 ;; Now all new groups from all select methods are in `hashtb'.
11039 (lambda (group-sym)
11040 (setq group (symbol-name group-sym))
11041 (if (or (gnus-gethash group gnus-newsrc-hashtb)
11042 (member group gnus-zombie-list)
11043 (member group gnus-killed-list))
11044 ;; The group is already known.
11046 (gnus-sethash group (symbol-value group-sym) gnus-active-hashtb)
11047 (let ((do-sub (gnus-matches-options-n group)))
11048 (cond ((eq do-sub 'subscribe)
11049 (setq groups (1+ groups))
11050 (gnus-sethash group group gnus-killed-hashtb)
11052 gnus-subscribe-options-newsgroup-method group))
11053 ((eq do-sub 'ignore)
11056 (setq groups (1+ groups))
11057 (gnus-sethash group group gnus-killed-hashtb)
11058 (if gnus-subscribe-hierarchical-interactive
11059 (setq new-newsgroups (cons group new-newsgroups))
11060 (funcall gnus-subscribe-newsgroup-method group)))))))
11063 (gnus-subscribe-hierarchical-interactive new-newsgroups))
11064 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
11066 (gnus-message 6 "%d new newsgroup%s arrived."
11067 groups (if (> groups 1) "s have" " has")))
11070 (defun gnus-check-first-time-used ()
11071 (if (or (> (length gnus-newsrc-alist) 1)
11072 (file-exists-p gnus-startup-file)
11073 (file-exists-p (concat gnus-startup-file ".el"))
11074 (file-exists-p (concat gnus-startup-file ".eld")))
11076 (gnus-message 6 "First time user; subscribing you to default groups")
11077 (or gnus-have-read-active-file (gnus-read-active-file))
11078 (setq gnus-newsrc-last-checked-date (current-time-string))
11079 (let ((groups gnus-default-subscribed-newsgroups)
11083 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
11086 (setq group (symbol-name sym))
11087 (let ((do-sub (gnus-matches-options-n group)))
11088 (cond ((eq do-sub 'subscribe)
11089 (gnus-sethash group group gnus-killed-hashtb)
11091 gnus-subscribe-options-newsgroup-method group))
11092 ((eq do-sub 'ignore)
11095 (setq gnus-killed-list (cons group gnus-killed-list))))))
11096 gnus-active-hashtb)
11098 (if (gnus-gethash (car groups) gnus-active-hashtb)
11099 (gnus-group-change-level
11100 (car groups) gnus-level-default-subscribed gnus-level-killed))
11101 (setq groups (cdr groups)))
11102 (gnus-group-make-help-group)
11103 (and gnus-novice-user
11104 (gnus-message 7 "`G k' to list killed groups"))))))
11106 ;; `gnus-group-change-level' is the fundamental function for changing
11107 ;; subscription levels of newsgroups. This might mean just changing
11108 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
11109 ;; again, which subscribes/unsubscribes a group, which is equally
11110 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
11111 ;; from 8-9 to 1-7 means that you remove the group from the list of
11112 ;; killed (or zombie) groups and add them to the (kinda) subscribed
11113 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
11114 ;; which is trivial.
11115 ;; ENTRY can either be a string (newsgroup name) or a list (if
11116 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
11117 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
11119 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
11120 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
11122 (defun gnus-group-change-level (entry level &optional oldlevel
11123 previous fromkilled)
11124 (let ((pinfo entry)
11125 group info active num)
11126 ;; Glean what info we can from the arguments
11128 (if fromkilled (setq group (nth 1 entry))
11129 (setq group (car (nth 2 entry))))
11130 (setq group entry))
11131 (if (and (stringp entry)
11133 (< oldlevel gnus-level-zombie))
11134 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
11135 (if (and (not oldlevel)
11137 (setq oldlevel (car (cdr (nth 2 entry)))))
11138 (if (stringp previous)
11139 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
11141 (gnus-dribble-enter
11142 (format "(gnus-group-change-level %S %S %S %S %S)"
11143 group level oldlevel (car (nth 2 previous)) fromkilled))
11145 ;; Then we remove the newgroup from any old structures, if needed.
11146 ;; If the group was killed, we remove it from the killed or zombie
11147 ;; list. If not, and it is in fact going to be killed, we remove
11148 ;; it from the newsrc hash table and assoc.
11149 (cond ((>= oldlevel gnus-level-zombie)
11150 (if (= oldlevel gnus-level-zombie)
11151 (setq gnus-zombie-list (delete group gnus-zombie-list))
11152 (setq gnus-killed-list (delete group gnus-killed-list))))
11154 (if (>= level gnus-level-zombie)
11156 (gnus-sethash (car (nth 2 entry))
11157 nil gnus-newsrc-hashtb)
11159 (setcdr (gnus-gethash (car (nth 3 entry))
11160 gnus-newsrc-hashtb)
11162 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
11164 ;; Finally we enter (if needed) the list where it is supposed to
11165 ;; go, and change the subscription level. If it is to be killed,
11166 ;; we enter it into the killed or zombie list.
11167 (cond ((>= level gnus-level-zombie)
11168 (and (string= group (gnus-group-real-name group))
11169 (if (= level gnus-level-zombie)
11170 (setq gnus-zombie-list (cons group gnus-zombie-list))
11171 (setq gnus-killed-list (cons group gnus-killed-list)))))
11173 ;; If the list is to be entered into the newsrc assoc, and
11174 ;; it was killed, we have to create an entry in the newsrc
11175 ;; hashtb format and fix the pointers in the newsrc assoc.
11176 (if (>= oldlevel gnus-level-zombie)
11180 (setq info (cdr entry))
11181 (setq num (car entry)))
11182 (setq active (gnus-gethash group gnus-active-hashtb))
11183 (setq num (if active (- (1+ (cdr active)) (car active)) t))
11184 ;; Check whether the group is foreign. If so, the
11185 ;; foreign select method has to be entered into the
11187 (let ((method (gnus-group-method-name group)))
11188 (if (eq method gnus-select-method)
11189 (setq info (list group level nil))
11190 (setq info (list group level nil nil method)))))
11193 (let ((p gnus-newsrc-alist))
11194 (while (cdr (cdr p))
11197 (setq entry (cons info (cdr (cdr previous))))
11198 (setcdr (cdr previous) entry)
11199 (gnus-sethash group (cons num (cdr previous))
11200 gnus-newsrc-hashtb)
11202 (setcdr (gnus-gethash (car (car (cdr entry)))
11203 gnus-newsrc-hashtb)
11205 ;; It was alive, and it is going to stay alive, so we
11206 ;; just change the level and don't change any pointers or
11207 ;; hash table entries.
11208 (setcar (cdr (car (cdr (cdr entry)))) level))))))
11210 (defun gnus-kill-newsgroup (newsgroup)
11211 "Obsolete function. Kills a newsgroup."
11212 (gnus-group-change-level
11213 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
11215 (defun gnus-check-bogus-newsgroups (&optional confirm)
11216 "Remove bogus newsgroups.
11217 If CONFIRM is non-nil, the user has to confirm the deletion of every
11219 (let ((newsrc (cdr gnus-newsrc-alist))
11221 (gnus-message 5 "Checking bogus newsgroups...")
11222 (or gnus-have-read-active-file (gnus-read-active-file))
11223 ;; Find all bogus newsgroup that are subscribed.
11225 (setq group (car (car newsrc)))
11226 (if (or (gnus-gethash group gnus-active-hashtb)
11227 (nth 4 (car newsrc))
11229 (not (gnus-y-or-n-p
11230 (format "Remove bogus newsgroup: %s " group)))))
11231 ;; Active newsgroup.
11233 ;; Found a bogus newsgroup.
11234 (setq bogus (cons group bogus)))
11235 (setq newsrc (cdr newsrc)))
11236 ;; Remove all bogus subscribed groups by first killing them, and
11237 ;; then removing them from the list of killed groups.
11239 (gnus-group-change-level
11240 (gnus-gethash (car bogus) gnus-newsrc-hashtb) gnus-level-killed)
11241 (setq gnus-killed-list (delete (car bogus) gnus-killed-list))
11242 (setq bogus (cdr bogus)))
11243 ;; Then we remove all bogus groups from the list of killed and
11244 ;; zombie groups. They are are removed without confirmation.
11245 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
11248 (setq killed (symbol-value (car dead-lists)))
11250 (setq group (car killed))
11251 (or (gnus-gethash group gnus-active-hashtb)
11252 ;; The group is bogus.
11253 (set (car dead-lists)
11254 (delete group (symbol-value (car dead-lists)))))
11255 (setq killed (cdr killed)))
11256 (setq dead-lists (cdr dead-lists))))
11257 (gnus-message 5 "Checking bogus newsgroups... done")))
11259 (defun gnus-check-duplicate-killed-groups ()
11260 "Remove duplicates from the list of killed groups."
11262 (let ((killed gnus-killed-list))
11264 (gnus-message 9 "%d" (length killed))
11265 (setcdr killed (delete (car killed) (cdr killed)))
11266 (setq killed (cdr killed)))))
11268 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
11269 ;; and compute how many unread articles there are in each group.
11270 (defun gnus-get-unread-articles (&optional level)
11271 (let* ((newsrc (cdr gnus-newsrc-alist))
11272 (conditional level)
11273 (level (or level (1+ gnus-level-subscribed)))
11274 info group active virtuals method)
11275 (gnus-message 5 "Checking new news...")
11277 (setq info (car newsrc))
11278 (setq group (car info))
11279 (setq active (gnus-gethash group gnus-active-hashtb))
11281 ;; Check newsgroups. If the user doesn't want to check them, or
11282 ;; they can't be checked (for instance, if the news server can't
11283 ;; be reached) we just set the number of unread articles in this
11284 ;; newsgroup to t. This means that Gnus thinks that there are
11285 ;; unread articles, but it has no idea how many.
11286 (if (and (setq method (nth 4 info))
11287 (not (gnus-server-equal gnus-select-method
11288 (gnus-server-get-method nil method))))
11289 (if (or (and gnus-activate-foreign-newsgroups
11290 (not (numberp gnus-activate-foreign-newsgroups)))
11291 (and (numberp gnus-activate-foreign-newsgroups)
11292 (<= (nth 1 info) gnus-activate-foreign-newsgroups)
11293 (<= (nth 1 info) level)))
11294 (if (eq (car (if (stringp method)
11295 (gnus-server-to-method method)
11296 (nth 4 info))) 'nnvirtual)
11297 (setq virtuals (cons info virtuals))
11298 (setq active (gnus-activate-newsgroup (car info)))))
11299 (if (and (not gnus-read-active-file)
11300 (<= (nth 1 info) level))
11302 (setq active (gnus-activate-newsgroup (car info))))))
11304 (or active (progn (gnus-sethash group nil gnus-active-hashtb)
11305 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
11307 (gnus-get-unread-articles-in-group info active)
11308 ;; Close the groups as we look at them!
11309 (gnus-close-group group))
11310 (setq newsrc (cdr newsrc)))
11312 ;; Activate the virtual groups. This has to be done after all the
11314 ;; !!! If one virtual group contains another virtual group, even
11315 ;; doing it this way might cause problems.
11317 (and (setq active (gnus-activate-newsgroup (car (car virtuals))))
11318 (gnus-get-unread-articles-in-group (car virtuals) active))
11319 (setq virtuals (cdr virtuals)))
11321 (gnus-message 5 "Checking new news... done")))
11323 ;; Create a hash table out of the newsrc alist. The `car's of the
11324 ;; alist elements are used as keys.
11325 (defun gnus-make-hashtable-from-newsrc-alist ()
11326 (let ((alist gnus-newsrc-alist)
11328 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
11330 (setq prev (setq gnus-newsrc-alist
11331 (cons (list "dummy.group" 0 nil) alist))))
11333 (gnus-sethash (car (car alist)) (cons nil prev) gnus-newsrc-hashtb)
11335 (setq alist (cdr alist)))))
11337 (defun gnus-make-hashtable-from-killed ()
11338 "Create a hash table from the killed and zombie lists."
11339 (let ((lists '(gnus-killed-list gnus-zombie-list))
11341 (setq gnus-killed-hashtb
11342 (gnus-make-hashtable
11343 (+ (length gnus-killed-list) (length gnus-zombie-list))))
11345 (setq list (symbol-value (car lists)))
11346 (setq lists (cdr lists))
11348 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
11349 (setq list (cdr list))))))
11351 (defun gnus-get-unread-articles-in-group (info active)
11352 (let* ((range (nth 2 info))
11354 (marked (nth 3 info))
11355 srange lowest group highest)
11356 ;; If a cache is present, we may have to alter the active info.
11357 (and gnus-use-cache
11358 (gnus-cache-possibly-alter-active (car info) active))
11359 ;; Modify the list of read articles according to what articles
11360 ;; are available; then tally the unread articles and add the
11361 ;; number to the group hash table entry.
11362 (cond ((zerop (cdr active))
11365 (setq num (- (1+ (cdr active)) (car active))))
11366 ((not (listp (cdr range)))
11367 ;; Fix a single (num . num) range according to the
11368 ;; active hash table.
11369 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
11370 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
11371 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
11372 ;; Compute number of unread articles.
11373 (setq num (max 0 (- (cdr active)
11374 (- (1+ (cdr range)) (car range))))))
11376 ;; The read list is a list of ranges. Fix them according to
11377 ;; the active hash table.
11378 ;; First peel off any elements that are below the lower
11380 (while (and (cdr range)
11382 (or (and (atom (car (cdr range))) (car (cdr range)))
11383 (car (car (cdr range))))))
11384 (if (numberp (car range))
11387 (or (and (numberp (car (cdr range)))
11389 (cdr (car (cdr range))))))
11390 (setcdr (car range)
11391 (or (and (numberp (nth 1 range)) (nth 1 range))
11392 (cdr (car (cdr range))))))
11393 (setcdr range (cdr (cdr range))))
11394 ;; Adjust the first element to be the same as the lower limit.
11395 (if (and (not (atom (car range)))
11396 (< (cdr (car range)) (car active)))
11397 (setcdr (car range) (1- (car active))))
11398 ;; Then we want to peel off any elements that are higher
11399 ;; than the upper active limit.
11400 (let ((srange range))
11401 ;; Go past all legal elements.
11402 (while (and (cdr srange)
11403 (<= (or (and (atom (car (cdr srange)))
11404 (car (cdr srange)))
11405 (car (car (cdr srange)))) (cdr active)))
11406 (setq srange (cdr srange)))
11408 ;; Nuke all remaining illegal elements.
11409 (setcdr srange nil))
11411 ;; Adjust the final element.
11412 (if (and (not (atom (car srange)))
11413 (> (cdr (car srange)) (cdr active)))
11414 (setcdr (car srange) (cdr active))))
11415 ;; Compute the number of unread articles.
11417 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
11418 (cdr (car range))))
11419 (or (and (atom (car range)) (car range))
11420 (car (car range))))))
11421 (setq range (cdr range)))
11422 (setq num (max 0 (- (cdr active) num)))))
11425 (and (assq 'tick marked)
11426 (inline (gnus-remove-illegal-marked-articles
11427 (assq 'tick marked) (nth 2 info))))
11428 (and (assq 'dormant marked)
11429 (inline (gnus-remove-illegal-marked-articles
11430 (assq 'dormant marked) (nth 2 info))))
11432 (gnus-gethash (car info) gnus-newsrc-hashtb)
11433 (setq num (max 0 (- num (length (cdr (assq 'tick marked)))
11434 (length (cdr (assq 'dormant marked)))))))))
11437 (defun gnus-remove-illegal-marked-articles (marked ranges)
11438 (let ((m (cdr marked)))
11439 ;; Make sure that all ticked articles are a subset of the unread
11442 (if (gnus-member-of-range (car m) ranges)
11443 (setcdr marked (cdr m))
11445 (setq m (cdr m)))))
11447 (defun gnus-activate-newsgroup (group)
11448 (let ((method (gnus-find-method-for-group group))
11450 (and (or (gnus-server-opened method) (gnus-open-server method))
11451 (gnus-request-group group)
11453 (set-buffer nntp-server-buffer)
11454 (goto-char (point-min))
11455 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
11457 (goto-char (match-beginning 1))
11459 group (setq active (cons (read (current-buffer))
11460 (read (current-buffer))))
11461 gnus-active-hashtb))
11464 (defun gnus-update-read-articles
11465 (group unread unselected ticked &optional domarks replied expirable killed
11466 dormant bookmark score)
11467 "Update the list of read and ticked articles in GROUP using the
11468 UNREAD and TICKED lists.
11469 Note: UNSELECTED has to be sorted over `<'.
11470 Returns whether the updating was successful."
11471 (let* ((active (or gnus-newsgroup-active
11472 (gnus-gethash group gnus-active-hashtb)))
11473 (entry (gnus-gethash group gnus-newsrc-hashtb))
11474 (number (car entry))
11475 (info (nth 2 entry))
11476 (marked (nth 3 info))
11478 (unread (sort (copy-sequence unread) (function <)))
11480 (if (or (not info) (not active))
11481 ;; There is no info on this group if it was, in fact,
11482 ;; killed. Gnus stores no information on killed groups, so
11483 ;; there's nothing to be done.
11484 ;; One could store the information somewhere temporarily,
11485 ;; perhaps... Hmmm...
11487 ;; Remove any negative articles numbers.
11488 (while (and unread (< (car unread) 0))
11489 (setq unread (cdr unread)))
11490 (setq unread (sort (append unselected unread) '<))
11491 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11492 (setcar entry (max 0 (- (length unread) (length ticked)
11493 (length dormant))))
11494 ;; Compute the ranges of read articles by looking at the list of
11495 ;; unread articles.
11497 (if (/= (car unread) prev)
11498 (setq read (cons (if (= prev (1- (car unread))) prev
11499 (cons prev (1- (car unread)))) read)))
11500 (setq prev (1+ (car unread)))
11501 (setq unread (cdr unread)))
11502 (if (<= prev (cdr active))
11503 (setq read (cons (cons prev (cdr active)) read)))
11504 ;; Enter this list into the group info.
11505 (setcar (cdr (cdr info))
11506 (if (> (length read) 1) (nreverse read) read))
11507 ;; Enter the list of ticked articles.
11508 (gnus-set-marked-articles
11510 (if domarks replied (cdr (assq 'reply marked)))
11511 (if domarks expirable (cdr (assq 'expire marked)))
11512 (if domarks killed (cdr (assq 'killed marked)))
11513 (if domarks dormant (cdr (assq 'dormant marked)))
11514 (if domarks bookmark (cdr (assq 'bookmark marked)))
11515 (if domarks score (cdr (assq 'score marked))))
11518 (defun gnus-make-articles-unread (group articles)
11519 "Mark ARTICLES in GROUP as unread."
11520 (let ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
11521 (gnus-gethash (gnus-group-real-name group)
11522 gnus-newsrc-hashtb)))))
11523 (setcar (nthcdr 2 info)
11524 (gnus-remove-from-range (nth 2 info) articles))
11525 (gnus-group-update-group group t)))
11527 (defun gnus-read-active-file ()
11528 "Get active file from NNTP server."
11529 (gnus-group-set-mode-line)
11530 (let ((methods (cons gnus-select-method gnus-secondary-select-methods))
11533 (setq gnus-have-read-active-file nil)
11535 (set-buffer nntp-server-buffer)
11537 (let* ((where (nth 1 (car methods)))
11538 (mesg (format "Reading active file%s via %s..."
11539 (if (and where (not (zerop (length where))))
11540 (concat " from " where) "")
11541 (car (car methods)))))
11542 (gnus-message 5 mesg)
11543 (gnus-check-news-server (car methods))
11545 ((and (eq gnus-read-active-file 'some)
11546 (gnus-check-backend-function
11547 'retrieve-groups (car (car methods))))
11548 (let ((newsrc (cdr gnus-newsrc-alist))
11551 (and (gnus-server-equal
11552 (gnus-find-method-for-group
11553 (car (car newsrc)) (car newsrc))
11554 (gnus-server-get-method nil (car methods)))
11555 (setq groups (cons (car (car newsrc)) groups)))
11556 (setq newsrc (cdr newsrc)))
11557 (setq list-type (gnus-retrieve-groups groups (car methods)))
11558 (cond ((not list-type)
11560 1 "Cannot read partial active file from %s server."
11561 (car (car methods)))
11564 ((eq list-type 'active)
11565 (gnus-active-to-gnus-format (and not-first (car methods)))
11566 (setq not-first t))
11568 (gnus-groups-to-gnus-format (and not-first (car methods)))
11569 (setq not-first t)))))
11571 (if (not (gnus-request-list (car methods)))
11573 (gnus-message 1 "Cannot read active file from %s server."
11574 (car (car methods)))
11576 (gnus-active-to-gnus-format
11577 (and gnus-have-read-active-file (car methods)))
11578 (setq gnus-have-read-active-file t)
11579 (gnus-message 5 "%s...done" mesg)))))
11580 (setq methods (cdr methods))))))
11582 ;; rewritten by jwz based on ideas from Rick Sladkey <jrs@world.std.com>
11583 ;; Further rewrites by lmi.
11584 (defun gnus-active-to-gnus-format (method &optional hashtb)
11585 "Convert active file format to internal format.
11586 Lines matching `gnus-ignored-newsgroups' are ignored."
11587 (let ((cur (current-buffer))
11591 (setq gnus-active-hashtb
11592 (gnus-make-hashtable
11593 (count-lines (point-min) (point-max))))))))
11594 ;; Delete unnecessary lines.
11595 (goto-char (point-min))
11596 (delete-matching-lines gnus-ignored-newsgroups)
11597 (and method (not (eq method gnus-select-method))
11598 (let ((prefix (gnus-group-prefixed-name "" method)))
11599 (goto-char (point-min))
11600 (while (and (not (eobp))
11601 (null (insert prefix))
11602 (zerop (forward-line 1))))))
11603 (goto-char (point-min))
11604 ;; Store active file in hashtable.
11606 (if (or (re-search-forward "\n.\r?$" nil t)
11607 (goto-char (point-max)))
11609 (beginning-of-line)
11610 (narrow-to-region (point-min) (point))))
11611 (goto-char (point-min))
11612 (if (string-match "%[oO]" gnus-group-line-format)
11613 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
11614 ;; If we want information on moderated groups, we use this
11617 (let ((mod-hashtb (make-vector 7 0))
11619 (while (not (eobp))
11620 (setq group (let ((obarray hashtb))
11622 (setq max (read cur))
11623 (set group (cons (read cur) max))
11624 ;; Enter moderated groups into a list.
11626 (symbol-name (let ((obarray mod-hashtb)) (read cur)))
11628 (setq gnus-moderated-list
11629 (cons (symbol-name group) gnus-moderated-list)))
11632 (progn (ding) (gnus-message 3 "Possible error in active file."))))
11633 ;; And if we do not care about moderation, we use this loop,
11634 ;; which is faster.
11637 (while (not (eobp))
11638 ;; group gets set to a symbol interned in the hash table
11640 (setq group (let ((obarray hashtb)) (read cur)))
11641 (setq max (read cur))
11642 (set group (cons (read cur) max))
11646 (gnus-message 3 "Possible error in active file."))))))))
11648 (defun gnus-groups-to-gnus-format (method &optional hashtb)
11649 ;; Parse a "groups" active file.
11650 (let ((cur (current-buffer))
11654 (setq gnus-active-hashtb
11655 (gnus-make-hashtable
11656 (count-lines (point-min) (point-max)))))))
11657 (prefix (and method (not (eq method gnus-select-method))
11658 (gnus-group-prefixed-name "" method))))
11660 (goto-char (point-min))
11662 ;; We split this into to separate loops, one with the prefix
11663 ;; and one without to speed the reading up somewhat.
11665 (let (min max opoint)
11666 (while (not (eobp))
11667 (read cur) (read cur)
11668 (setq min (read cur)
11671 (skip-chars-forward " \t")
11674 (set (let ((obarray hashtb)) (read cur))
11677 (let (min max opoint)
11678 (while (not (eobp))
11679 (if (= (following-char) ?2)
11681 (read cur) (read cur)
11682 (setq min (read cur)
11684 (set (let ((obarray hashtb)) (read cur))
11686 (forward-line 1))))
11688 (progn (ding) (gnus-message 3 "Possible error in active file."))))))
11690 (defun gnus-read-newsrc-file (&optional force)
11691 "Read startup file.
11692 If FORCE is non-nil, the .newsrc file is read."
11693 (setq gnus-current-startup-file (gnus-make-newsrc-file gnus-startup-file))
11694 ;; Reset variables that might be defined in the .newsrc.eld file.
11695 (let ((variables gnus-variable-list))
11697 (set (car variables) nil)
11698 (setq variables (cdr variables))))
11699 (let* ((newsrc-file gnus-current-startup-file)
11700 (quick-file (concat newsrc-file ".el")))
11702 ;; We always load the .newsrc.eld file. If always contains
11703 ;; much information that can not be gotten from the .newsrc
11704 ;; file (ticked articles, killed groups, foreign methods, etc.)
11705 (gnus-read-newsrc-el-file quick-file)
11708 (and (file-newer-than-file-p newsrc-file quick-file)
11709 (file-newer-than-file-p newsrc-file
11710 (concat quick-file "d")))
11711 (not gnus-newsrc-alist))
11712 ;; We read the .newsrc file. Note that if there if a
11713 ;; .newsrc.eld file exists, it has already been read, and
11714 ;; the `gnus-newsrc-hashtb' has been created. While reading
11715 ;; the .newsrc file, Gnus will only use the information it
11716 ;; can find there for changing the data already read -
11717 ;; ie. reading the .newsrc file will not trash the data
11718 ;; already read (except for read articles).
11720 (gnus-message 5 "Reading %s..." newsrc-file)
11721 (set-buffer (find-file-noselect newsrc-file))
11722 (buffer-disable-undo (current-buffer))
11723 (gnus-newsrc-to-gnus-format)
11724 (kill-buffer (current-buffer))
11725 (gnus-message 5 "Reading %s... done" newsrc-file))))))
11727 (defun gnus-read-newsrc-el-file (file)
11728 (let ((ding-file (concat file "d")))
11729 ;; We always, always read the .eld file.
11730 (gnus-message 5 "Reading %s..." ding-file)
11731 (let (gnus-newsrc-assoc)
11732 (condition-case nil
11733 (load ding-file t t t)
11735 (and gnus-newsrc-assoc (setq gnus-newsrc-alist gnus-newsrc-assoc)))
11736 (let ((inhibit-quit t))
11737 (gnus-uncompress-newsrc-assoc))
11738 (gnus-make-hashtable-from-newsrc-alist)
11739 (if (not (file-newer-than-file-p file ding-file))
11741 ;; Old format quick file
11742 (gnus-message 5 "Reading %s..." file)
11743 ;; The .el file is newer than the .eld file, so we read that one
11745 (gnus-read-old-newsrc-el-file file))))
11747 ;; Parse the old-style quick startup file
11748 (defun gnus-read-old-newsrc-el-file (file)
11749 (let (newsrc killed marked group g m len info)
11751 (let ((gnus-killed-assoc nil)
11752 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
11754 (condition-case nil
11757 (setq newsrc gnus-newsrc-assoc
11758 killed gnus-killed-assoc
11759 marked gnus-marked-assoc)))
11760 (setq gnus-newsrc-alist nil)
11762 (setq group (car newsrc))
11763 (let ((info (nth 2 (gnus-gethash (car group) gnus-newsrc-hashtb))))
11766 (setcar (nthcdr 2 info) (cdr (cdr group)))
11768 (if (nth 1 group) gnus-level-default-subscribed
11769 gnus-level-default-unsubscribed))
11770 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
11771 (setq gnus-newsrc-alist
11775 (if (nth 1 group) gnus-level-default-subscribed
11776 gnus-level-default-unsubscribed)
11777 (cdr (cdr group))))
11778 gnus-newsrc-alist)))
11779 (if (setq m (assoc (car group) marked))
11780 (setcdr (cdr (cdr info)) (cons (list (cons 'tick (cdr m))) nil))))
11781 (setq newsrc (cdr newsrc)))
11782 (setq newsrc killed)
11784 (setcar newsrc (car (car newsrc)))
11785 (setq newsrc (cdr newsrc)))
11786 (setq gnus-killed-list killed))
11787 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
11788 (gnus-make-hashtable-from-newsrc-alist)))
11790 (defun gnus-make-newsrc-file (file)
11791 "Make server dependent file name by catenating FILE and server host name."
11792 (let* ((file (expand-file-name file nil))
11793 (real-file (concat file "-" (nth 1 gnus-select-method))))
11794 (if (file-exists-p real-file)
11797 (defun gnus-uncompress-newsrc-assoc ()
11798 ;; Uncompress all lists of marked articles in the newsrc assoc.
11799 (let ((newsrc gnus-newsrc-alist)
11802 (if (not (setq marked (nth 3 (car newsrc))))
11805 (or (eq 'score (car (car marked)))
11806 (eq 'bookmark (car (car marked)))
11807 (eq 'killed (car (car marked)))
11808 (setcdr (car marked) (gnus-uncompress-range (cdr (car marked)))))
11809 (setq marked (cdr marked))))
11810 (setq newsrc (cdr newsrc)))))
11812 (defun gnus-compress-newsrc-assoc ()
11813 ;; Compress all lists of marked articles in the newsrc assoc.
11814 (let ((newsrc gnus-newsrc-alist)
11817 (if (not (setq marked (nth 3 (car newsrc))))
11820 (or (eq 'score (car (car marked)))
11821 (eq 'bookmark (car (car marked)))
11822 (eq 'killed (car (car marked)))
11823 (setcdr (car marked)
11824 (gnus-compress-sequence (sort (cdr (car marked)) '<) t)))
11825 (setq marked (cdr marked))))
11826 (setq newsrc (cdr newsrc)))))
11828 (defun gnus-newsrc-to-gnus-format ()
11829 (setq gnus-newsrc-options "")
11830 (or gnus-active-hashtb
11831 (setq gnus-active-hashtb (make-vector 4095 0)))
11832 (let ((buf (current-buffer))
11833 (already-read (> (length gnus-newsrc-alist) 1))
11834 group level subscribed info options-symbol newsrc
11836 (goto-char (point-min))
11837 ;; We intern the symbol `options' in the active hashtb so that we
11838 ;; can `eq' against it later.
11839 (setq options-symbol (intern "options" gnus-active-hashtb))
11841 (while (not (eobp))
11842 ;; We first read the first word on the line by narrowing and
11843 ;; then reading into `gnus-active-hashtb'. Most groups will
11844 ;; already exist in that hashtb, so this will save some string
11848 (progn (skip-chars-forward "^ \t!:\n") (point)))
11849 (goto-char (point-min))
11851 (and (/= (point-min) (point-max))
11852 (let ((obarray gnus-active-hashtb)) (read buf))))
11854 ;; Now, the symbol we have read is either `options' or a group
11855 ;; name. If it is an options line, we just add it to a string.
11857 ((eq symbol options-symbol)
11858 (setq gnus-newsrc-options
11859 ;; This concatting is quite inefficient, but since our
11860 ;; thorough studies show that approx 99.37% of all
11861 ;; .newsrc files only contain a single options line, we
11862 ;; don't give a damn, frankly, my dear.
11863 (concat gnus-newsrc-options
11865 (gnus-point-at-bol)
11866 ;; Options may continue on the next line.
11867 (or (and (re-search-forward "^[^ \t]" nil 'move)
11868 (progn (beginning-of-line) (point)))
11871 ;; It was a group name.
11872 (setq subscribed (= (following-char) ?:)
11873 group (symbol-name symbol)
11876 ;; If the line ends here, this is clearly a buggy line, so
11877 ;; we put point a the beginning of line and let the cond
11878 ;; below do the error handling.
11879 (beginning-of-line)
11880 ;; We skip to the beginning of the ranges.
11881 (skip-chars-forward "!: \t"))
11882 ;; We are now at the beginning of the list of read articles.
11883 ;; We read them range by range.
11886 ((looking-at "[0-9]+")
11887 ;; We narrow and read a number instead of buffer-substring/
11888 ;; string-to-int because it's faster. narrow/widen is
11889 ;; faster than save-restriction/narrow, and save-restriction
11890 ;; produces a garbage object.
11892 (narrow-to-region (match-beginning 0) (match-end 0))
11895 ;; If the next character is a dash, then this is a range.
11896 (if (= (following-char) ?-)
11898 ;; We read the upper bound of the range.
11900 (if (not (looking-at "[0-9]+"))
11901 ;; This is a buggy line, by we pretend that
11902 ;; it's kinda OK. Perhaps the user should be
11904 (setq reads (cons num1 reads))
11908 (narrow-to-region (match-beginning 0)
11913 ;; It was just a simple number, so we add it to the
11915 (setq reads (cons num1 reads)))
11916 ;; If the next char in ?\n, then we have reached the end
11917 ;; of the line and return nil.
11918 (/= (following-char) ?\n))
11919 ((= (following-char) ?\n)
11920 ;; End of line, so we end.
11923 ;; Not numbers and not eol, so this might be a buggy
11925 (or (eobp) ; If it was eob instead of ?\n, we allow it.
11927 ;; The line was buggy.
11929 (gnus-message 3 "Mangled line: %s"
11930 (buffer-substring (gnus-point-at-bol)
11931 (gnus-point-at-eol)))
11935 ;; Skip past ", ". Spaces are illegal in these ranges, but
11936 ;; we allow them, because it's a common mistake to put a
11937 ;; space after the comma.
11938 (skip-chars-forward ", "))
11940 ;; We have already read .newsrc.eld, so we gently update the
11941 ;; data in the hash table with the information we have just
11945 (let ((info (nth 2 (gnus-gethash group gnus-newsrc-hashtb)))
11948 ;; There is an entry for this file in the alist.
11950 (setcar (nthcdr 2 info) (nreverse reads))
11951 ;; We update the level very gently. In fact, we
11952 ;; only change it if there's been a status change
11953 ;; from subscribed to unsubscribed, or vice versa.
11954 (setq level (nth 1 info))
11955 (cond ((and (<= level gnus-level-subscribed)
11957 (setq level (if reads
11958 gnus-level-default-unsubscribed
11959 (1+ gnus-level-default-unsubscribed))))
11960 ((and (> level gnus-level-subscribed) subscribed)
11961 (setq level gnus-level-default-subscribed)))
11962 (setcar (cdr info) level))
11963 ;; This is a new group.
11964 (setq info (list group
11966 gnus-level-default-subscribed
11968 (1+ gnus-level-subscribed)
11969 gnus-level-default-unsubscribed))
11970 (nreverse reads))))
11971 (setq newsrc (cons info newsrc))))
11972 (forward-line 1))))
11974 (setq newsrc (nreverse newsrc))
11976 (if (not already-read)
11978 ;; We now have two newsrc lists - `newsrc', which is what we
11979 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
11980 ;; what we've read from .newsrc.eld. We have to merge these
11981 ;; lists. We do this by "attaching" any (foreign) groups in the
11982 ;; gnus-newsrc-alist to the (native) group that precedes them.
11983 (let ((rc (cdr gnus-newsrc-alist))
11984 (prev gnus-newsrc-alist)
11987 (or (assoc (car (car rc)) newsrc)
11988 (if (setq entry (assoc (car (car prev)) newsrc))
11989 (setcdr (setq mentry (memq entry newsrc))
11990 (cons (car rc) (cdr mentry)))
11991 (setq newsrc (cons (car rc) newsrc))))
11995 (setq gnus-newsrc-alist newsrc)
11996 ;; We make the newsrc hashtb.
11997 (gnus-make-hashtable-from-newsrc-alist)
11999 ;; Finally, if we read some options lines, we parse them.
12000 (or (string= gnus-newsrc-options "")
12001 (gnus-newsrc-parse-options gnus-newsrc-options))
12004 ;; Parse options lines to find "options -n !all rec.all" and stuff.
12005 ;; The return value will be a list on the form
12006 ;; ((regexp1 . ignore)
12007 ;; (regexp2 . subscribe)...)
12008 ;; When handling new newsgroups, groups that match a `ignore' regexp
12009 ;; will be ignored, and groups that match a `subscribe' regexp will be
12010 ;; subscribed. A line like
12011 ;; options -n !all rec.all
12012 ;; will lead to a list that looks like
12013 ;; (("^rec\\..+" . subscribe)
12014 ;; ("^.+" . ignore))
12015 ;; So all "rec.*" groups will be subscribed, while all the other
12016 ;; groups will be ignored. Note that "options -n !all rec.all" is very
12017 ;; different from "options -n rec.all !all".
12018 (defun gnus-newsrc-parse-options (options)
12021 (gnus-set-work-buffer)
12022 (insert (regexp-quote options))
12023 ;; First we treat all continuation lines.
12024 (goto-char (point-min))
12025 (while (re-search-forward "\n[ \t]+" nil t)
12026 (replace-match " " t t))
12027 ;; Then we transform all "all"s into ".+"s.
12028 (goto-char (point-min))
12029 (while (re-search-forward "\\ball\\b" nil t)
12030 (replace-match ".+" t t))
12031 (goto-char (point-min))
12032 ;; We remove all other options than the "-n" ones.
12033 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
12034 (replace-match " ")
12036 (goto-char (point-min))
12038 ;; We are only interested in "options -n" lines - we
12039 ;; ignore the other option lines.
12040 (while (re-search-forward "[ \t]-n" nil t)
12042 (or (save-excursion
12043 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
12045 (gnus-point-at-eol)))
12046 ;; Search for all "words"...
12047 (while (re-search-forward "[^ \t,\n-]+" eol t)
12048 (if (= (char-after (match-beginning 0)) ?!)
12049 ;; If the word begins with a bang (!), this is a "not"
12050 ;; spec. We put this spec (minus the bang) and the
12051 ;; symbol `ignore' into the list.
12052 (setq out (cons (cons (concat
12053 "^" (buffer-substring
12054 (1+ (match-beginning 0))
12057 ;; There was no bang, so this is a "yes" spec.
12058 (setq out (cons (cons (concat
12059 "^" (buffer-substring (match-beginning 0)
12061 'subscribe) out)))))
12063 (setq gnus-newsrc-options-n out))))
12066 (defun gnus-save-newsrc-file ()
12067 "Save .newsrc file."
12068 ;; Note: We cannot save .newsrc file if all newsgroups are removed
12069 ;; from the variable gnus-newsrc-alist.
12070 (and (or gnus-newsrc-alist gnus-killed-list)
12071 gnus-current-startup-file
12072 (let ((make-backup-files t)
12073 (version-control nil)
12074 (require-final-newline t)) ;Don't ask even if requested.
12075 ;; You can stop or change version control of backup file.
12076 ;; Suggested by jason@violet.berkeley.edu.
12077 (run-hooks 'gnus-save-newsrc-hook)
12079 (if (or (not gnus-dribble-buffer)
12080 (not (buffer-name gnus-dribble-buffer))
12081 (zerop (save-excursion
12082 (set-buffer gnus-dribble-buffer)
12084 (gnus-message 4 "(No changes need to be saved)")
12085 (if gnus-save-newsrc-file
12087 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
12088 ;; Make backup file of master newsrc.
12089 (gnus-gnus-to-newsrc-format)
12090 (gnus-message 5 "Saving %s... done"
12091 gnus-current-startup-file)))
12092 ;; Quickly loadable .newsrc.
12093 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
12094 (gnus-add-current-to-buffer-list)
12095 (buffer-disable-undo (current-buffer))
12097 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
12098 (gnus-gnus-to-quick-newsrc-format)
12099 (write-region 1 (point-max)
12100 (concat gnus-current-startup-file ".eld")
12102 (kill-buffer (current-buffer))
12103 (gnus-message 5 "Saving %s.eld... done" gnus-current-startup-file)
12104 (gnus-dribble-delete-file))))))
12106 (defun gnus-gnus-to-quick-newsrc-format ()
12107 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
12108 (insert ";; (ding) Gnus startup file.\n")
12109 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
12110 (insert ";; to read .newsrc.\n")
12111 (let ((variables gnus-variable-list)
12113 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
12115 ;; insert lisp expressions.
12116 (gnus-compress-newsrc-assoc)
12118 (setq variable (car variables))
12119 (and (boundp variable)
12120 (symbol-value variable)
12121 (or gnus-save-killed-list (not (eq variable 'gnus-killed-list)))
12122 (insert "(setq " (symbol-name variable) " '"
12123 (prin1-to-string (symbol-value variable))
12125 (setq variables (cdr variables)))
12126 (gnus-uncompress-newsrc-assoc)))
12129 (defun gnus-gnus-to-newsrc-format ()
12130 ;; Generate and save the .newsrc file.
12131 (let ((newsrc (cdr gnus-newsrc-alist))
12134 (set-buffer (create-file-buffer gnus-startup-file))
12135 (buffer-disable-undo (current-buffer))
12138 (if gnus-newsrc-options (insert gnus-newsrc-options))
12139 ;; Write subscribed and unsubscribed.
12141 (setq info (car newsrc))
12142 (if (not (nth 4 info)) ;Don't write foreign groups to .newsrc.
12144 (insert (car info) (if (> (nth 1 info) gnus-level-subscribed)
12146 (if (setq ranges (nth 2 info))
12149 (if (not (listp (cdr ranges)))
12150 (if (= (car ranges) (cdr ranges))
12151 (insert (int-to-string (car ranges)))
12152 (insert (int-to-string (car ranges)) "-"
12153 (int-to-string (cdr ranges))))
12155 (setq range (car ranges)
12156 ranges (cdr ranges))
12157 (if (or (atom range) (= (car range) (cdr range)))
12158 (insert (int-to-string
12159 (or (and (atom range) range)
12161 (insert (int-to-string (car range)) "-"
12162 (int-to-string (cdr range))))
12163 (if ranges (insert ","))))))
12165 (setq newsrc (cdr newsrc)))
12166 (write-region 1 (point-max) gnus-current-startup-file nil 'nomesg)
12167 (kill-buffer (current-buffer)))))
12169 (defun gnus-read-descriptions-file ()
12170 (gnus-message 5 "Reading descriptions file...")
12172 ((not (or (gnus-server-opened gnus-select-method)
12173 (gnus-open-server gnus-select-method)))
12174 (gnus-message 1 "Couldn't open server")
12176 ((not (gnus-request-list-newsgroups gnus-select-method))
12177 (gnus-message 1 "Couldn't read newsgroups descriptions")
12181 (setq gnus-description-hashtb
12182 (gnus-make-hashtable (length gnus-active-hashtb)))
12185 (set-buffer nntp-server-buffer)
12186 (goto-char (point-min))
12187 (delete-non-matching-lines "^[-\\._+A-Za-z0-9]+[ \t]")
12188 (goto-char (point-min))
12189 (if (or (search-forward "\n.\n" nil t)
12190 (goto-char (point-max)))
12192 (beginning-of-line)
12193 (narrow-to-region (point-min) (point))))
12194 (goto-char (point-min))
12195 (while (not (eobp))
12196 (setq group (let ((obarray gnus-description-hashtb))
12197 (read (current-buffer))))
12198 (skip-chars-forward " \t")
12199 (and (symbolp group)
12200 (set group (buffer-substring (point) (gnus-point-at-eol))))
12201 (forward-line 1))))
12202 (gnus-message 5 "Reading descriptions file...done")
12205 (defun gnus-group-get-description (group)
12206 ;; Get the description of a group by sending XGTITLE to the server.
12207 (and (gnus-request-group-description group)
12209 (set-buffer nntp-server-buffer)
12210 (goto-char (point-min))
12211 (and (looking-at "[^ \t]+[ \t]+\\(.*\\)")
12212 (buffer-substring (match-beginning 1) (match-end 1))))))
12218 (defvar gnus-server-mode-hook nil
12219 "Hook run in `gnus-server-mode' buffers.")
12221 (defconst gnus-server-line-format " {%(%h:%w%)}\n"
12222 "Format of server lines.
12223 It works along the same lines as a normal formatting string,
12224 with some simple extensions.")
12226 (defvar gnus-server-mode-line-format "(ding) List of servers"
12227 "The format specification for the server mode line.")
12229 (defconst gnus-server-line-format-alist
12230 (list (list ?h 'how ?s)
12232 (list ?w 'where ?s)
12235 (defconst gnus-server-mode-line-format-alist
12236 (list (list ?S 'news-server ?s)
12237 (list ?M 'news-method ?s)
12238 (list ?u 'user-defined ?s)))
12240 (defvar gnus-server-line-format-spec nil)
12241 (defvar gnus-server-mode-line-format-spec nil)
12242 (defvar gnus-server-killed-servers nil)
12244 (defvar gnus-server-mode-map nil)
12245 (put 'gnus-server-mode 'mode-class 'special)
12247 (if gnus-server-mode-map
12249 (setq gnus-server-mode-map (make-sparse-keymap))
12250 (suppress-keymap gnus-server-mode-map)
12251 (define-key gnus-server-mode-map " " 'gnus-server-read-server)
12252 (define-key gnus-server-mode-map "\r" 'gnus-server-read-server)
12253 (define-key gnus-server-mode-map gnus-mouse-2 'gnus-server-pick-server)
12254 (define-key gnus-server-mode-map "q" 'gnus-server-exit)
12255 (define-key gnus-server-mode-map "l" 'gnus-server-list-servers)
12256 (define-key gnus-server-mode-map "k" 'gnus-server-kill-server)
12257 (define-key gnus-server-mode-map "y" 'gnus-server-yank-server)
12258 (define-key gnus-server-mode-map "c" 'gnus-server-copy-server)
12259 (define-key gnus-server-mode-map "a" 'gnus-server-add-server)
12260 (define-key gnus-server-mode-map "e" 'gnus-server-edit-server))
12262 (defun gnus-server-mode ()
12263 "Major mode for listing and editing servers.
12265 All normal editing commands are switched off.
12266 \\<gnus-server-mode-map>
12268 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
12270 The following commands are available:
12272 \\{gnus-server-mode-map}"
12274 (if gnus-visual (gnus-server-make-menu-bar))
12275 (kill-all-local-variables)
12276 (setq mode-line-modified "-- ")
12277 (make-local-variable 'mode-line-format)
12278 (setq mode-line-format (copy-sequence mode-line-format))
12279 (and (equal (nth 3 mode-line-format) " ")
12280 (setcar (nthcdr 3 mode-line-format) ""))
12281 (setq major-mode 'gnus-server-mode)
12282 (setq mode-name "Server")
12283 ; (gnus-group-set-mode-line)
12284 (setq mode-line-process nil)
12285 (use-local-map gnus-server-mode-map)
12286 (buffer-disable-undo (current-buffer))
12287 (setq truncate-lines t)
12288 (setq buffer-read-only t)
12289 (run-hooks 'gnus-server-mode-hook))
12291 (defun gnus-server-insert-server-line (sformat name method)
12292 (let* ((sformat (or sformat gnus-server-line-format-spec))
12294 (where (nth 1 method))
12296 (beginning-of-line)
12298 ;; Insert the text.
12299 (insert (eval sformat))
12300 (add-text-properties
12301 b (1+ b) (list 'gnus-server (intern name)))))
12303 (defun gnus-server-setup-buffer ()
12304 (if (get-buffer gnus-server-buffer)
12307 (set-buffer (get-buffer-create gnus-server-buffer))
12309 (and gnus-carpal (gnus-carpal-setup-buffer 'server)))))
12311 (defun gnus-server-prepare ()
12312 (setq gnus-server-mode-line-format-spec
12313 (gnus-parse-format gnus-server-mode-line-format
12314 gnus-server-mode-line-format-alist))
12315 (setq gnus-server-line-format-spec
12316 (gnus-parse-format gnus-server-line-format
12317 gnus-server-line-format-alist))
12318 (let ((alist gnus-server-alist)
12319 (buffer-read-only nil))
12322 (gnus-server-insert-server-line nil (car (car alist)) (cdr (car alist)))
12323 (setq alist (cdr alist))))
12324 (goto-char (point-min))
12325 (gnus-server-position-cursor))
12327 (defun gnus-server-server-name ()
12328 (let ((server (get-text-property (gnus-point-at-bol) 'gnus-server)))
12329 (and server (symbol-name server))))
12331 (defalias 'gnus-server-position-cursor 'gnus-goto-colon)
12333 (defconst gnus-server-edit-buffer "*Gnus edit server*")
12335 (defun gnus-server-update-server (server)
12337 (set-buffer gnus-server-buffer)
12338 (let ((buffer-read-only nil)
12339 (info (cdr (assoc server gnus-server-alist))))
12340 (gnus-dribble-enter
12341 (concat "(gnus-server-set-info \"" server "\" '"
12342 (prin1-to-string info) ")"))
12343 ;; Buffer may be narrowed.
12346 (if (gnus-server-goto-server server)
12347 (delete-region (progn (beginning-of-line) (point))
12348 (progn (forward-line 1) (point))))
12349 (let ((entry (assoc server gnus-server-alist)))
12350 (gnus-server-insert-server-line nil (car entry) (cdr entry))
12351 (gnus-server-position-cursor))))))
12353 (defun gnus-server-set-info (server info)
12354 ;; Enter a select method into the virtual server alist.
12355 (gnus-dribble-enter
12356 (concat "(gnus-server-set-info \"" server "\" '"
12357 (prin1-to-string info) ")"))
12358 (let* ((server (nth 1 info))
12359 (entry (assoc server gnus-server-alist)))
12360 (if entry (setcdr entry info)
12361 (setq gnus-server-alist
12362 (nconc gnus-server-alist (list (cons server info)))))))
12364 (defun gnus-server-to-method (server)
12365 ;; Map virtual server names to select methods.
12366 (or (and (equal server "native") gnus-select-method)
12367 (cdr (assoc server gnus-server-alist))))
12369 (defun gnus-server-extend-method (group method)
12370 ;; This function "extends" a virtual server. If the server is
12371 ;; "hello", and the select method is ("hello" (my-var "something"))
12372 ;; in the group "alt.alt", this will result in a new virtual server
12373 ;; called "helly+alt.alt".
12375 (gnus-copy-sequence
12376 (if (equal (car method) "native") gnus-select-method
12377 (cdr (assoc (car method) gnus-server-alist))))))
12378 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
12379 (nconc entry (cdr method))))
12381 (defun gnus-server-get-method (group method)
12382 ;; Input either a server name, and extended server name, or a
12383 ;; select method, and return a select method.
12384 (cond ((stringp method)
12385 (gnus-server-to-method method))
12386 ((stringp (car method))
12387 (gnus-server-extend-method group method))
12389 (gnus-server-add-address method))))
12391 (defun gnus-server-add-address (method)
12392 (let ((method-name (symbol-name (car method))))
12393 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
12394 (not (assq (intern (concat method-name "-address")) method)))
12395 (append method (list (list (intern (concat method-name "-address"))
12399 (defun gnus-server-equal (s1 s2)
12401 (and (= (length s1) (length s2))
12403 (while (and s1 (member (car s1) s2))
12404 (setq s1 (cdr s1)))
12407 ;;; Interactive server functions.
12409 (defun gnus-server-kill-server (server)
12410 "Kill the server on the current line."
12411 (interactive (list (gnus-server-server-name)))
12412 (or (gnus-server-goto-server server)
12413 (if server (error "No such server: %s" server)
12414 (error "No server on the current line")))
12415 (let ((buffer-read-only nil))
12416 (delete-region (progn (beginning-of-line) (point))
12417 (progn (forward-line 1) (point))))
12418 (setq gnus-server-killed-servers
12419 (cons (assoc server gnus-server-alist) gnus-server-killed-servers))
12420 (setq gnus-server-alist (delq (car gnus-server-killed-servers)
12421 gnus-server-alist))
12422 (gnus-server-position-cursor))
12424 (defun gnus-server-yank-server ()
12425 "Yank the previously killed server."
12427 (or gnus-server-killed-servers
12428 (error "No killed servers to be yanked"))
12429 (let ((alist gnus-server-alist)
12430 (server (gnus-server-server-name))
12431 (killed (car gnus-server-killed-servers)))
12433 (setq gnus-server-alist (nconc gnus-server-alist (list killed)))
12434 (if (string= server (car (car gnus-server-alist)))
12435 (setq gnus-server-alist (cons killed gnus-server-alist))
12436 (while (and (cdr alist)
12437 (not (string= server (car (car (cdr alist))))))
12438 (setq alist (cdr alist)))
12439 (setcdr alist (cons killed (cdr alist)))))
12440 (gnus-server-update-server (car killed))
12441 (setq gnus-server-killed-servers (cdr gnus-server-killed-servers))
12442 (gnus-server-position-cursor)))
12444 (defun gnus-server-exit ()
12445 "Return to the group buffer."
12447 (kill-buffer (current-buffer))
12448 (switch-to-buffer gnus-group-buffer))
12450 (defun gnus-server-list-servers ()
12451 "List all available servers."
12453 (let ((cur (gnus-server-server-name)))
12454 (gnus-server-prepare)
12455 (if cur (gnus-server-goto-server cur)
12456 (goto-char (point-max))
12458 (gnus-server-position-cursor)))
12460 (defun gnus-server-copy-server (from to)
12463 (or (gnus-server-server-name)
12464 (error "No server on the current line"))
12465 (read-string "Copy to: ")))
12466 (or from (error "No server on current line"))
12467 (or (and to (not (string= to ""))) (error "No name to copy to"))
12468 (and (assoc to gnus-server-alist) (error "%s already exists" to))
12469 (or (assoc from gnus-server-alist)
12470 (error "%s: no such server" from))
12471 (let ((to-entry (gnus-copy-sequence (assoc from gnus-server-alist))))
12472 (setcar to-entry to)
12473 (setcar (nthcdr 2 to-entry) to)
12474 (setq gnus-server-killed-servers
12475 (cons to-entry gnus-server-killed-servers))
12476 (gnus-server-yank-server)))
12478 (defun gnus-server-add-server (how where)
12480 (list (intern (completing-read "Server method: "
12481 gnus-valid-select-methods nil t))
12482 (read-string "Server name: ")))
12483 (setq gnus-server-killed-servers
12484 (cons (list where how where) gnus-server-killed-servers))
12485 (gnus-server-yank-server))
12487 (defun gnus-server-goto-server (server)
12488 "Jump to a server line."
12490 (list (completing-read "Goto server: " gnus-server-alist nil t)))
12491 (let ((to (text-property-any (point-min) (point-max)
12492 'gnus-server (intern server))))
12496 (gnus-server-position-cursor)))))
12498 (defun gnus-server-edit-server (server)
12499 "Edit the server on the current line."
12500 (interactive (list (gnus-server-server-name)))
12502 (error "No server on current line"))
12503 (let ((winconf (current-window-configuration)))
12504 (get-buffer-create gnus-server-edit-buffer)
12505 (gnus-configure-windows 'edit-server)
12506 (gnus-add-current-to-buffer-list)
12508 (make-local-variable 'gnus-prev-winconf)
12509 (setq gnus-prev-winconf winconf)
12510 (use-local-map (copy-keymap (current-local-map)))
12511 (let ((done-func '(lambda ()
12512 "Exit editing mode and update the information."
12514 (gnus-server-edit-server-done 'group))))
12515 (setcar (cdr (nth 4 done-func)) server)
12516 (local-set-key "\C-c\C-c" done-func))
12518 (insert ";; Type `C-c C-c' after you have edited the server.\n\n")
12519 (insert (pp-to-string (cdr (assoc server gnus-server-alist))))))
12521 (defun gnus-server-edit-server-done (server)
12523 (set-buffer (get-buffer-create gnus-server-edit-buffer))
12524 (goto-char (point-min))
12525 (let ((form (read (current-buffer)))
12526 (winconf gnus-prev-winconf))
12527 (gnus-server-set-info server form)
12528 (kill-buffer (current-buffer))
12529 (and winconf (set-window-configuration winconf))
12530 (set-buffer gnus-server-buffer)
12531 (gnus-server-update-server (gnus-server-server-name))
12532 (gnus-server-position-cursor)))
12534 (defun gnus-server-read-server (server)
12536 (interactive (list (gnus-server-server-name)))
12537 (gnus-browse-foreign-server (gnus-server-to-method server) (current-buffer)))
12539 (defun gnus-mouse-pick-server (e)
12541 (mouse-set-point e)
12542 (gnus-server-read-server (gnus-server-server-name)))
12546 ;;; gnus.el ends here