1 ;;; gnus.el --- 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.
28 (eval '(run-hooks 'gnus-load-hook))
34 (eval-when-compile (require 'cl))
36 ;; Site dependent variables. These variables should be defined in
39 (defvar gnus-default-nntp-server nil
40 "Specify a default NNTP server.
41 This variable should be defined in paths.el, and should never be set
43 If you want to change servers, you should use `gnus-select-method'.
44 See the documentation to that variable.")
46 (defconst gnus-backup-default-subscribed-newsgroups
47 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
48 "Default default new newsgroups the first time Gnus is run.
49 Should be set in paths.el, and shouldn't be touched by the user.")
51 (defvar gnus-local-domain nil
52 "Local domain name without a host name.
53 The DOMAINNAME environment variable is used instead if it is defined.
54 If the `system-name' function returns the full Internet name, there is
55 no need to set this variable.")
57 (defvar gnus-local-organization nil
58 "String with a description of what organization (if any) the user belongs to.
59 The ORGANIZATION environment variable is used instead if it is defined.
60 If this variable contains a function, this function will be called
61 with the current newsgroup name as the argument. The function should
64 In any case, if the string (either in the variable, in the environment
65 variable, or returned by the function) is a file name, the contents of
66 this file will be used as the organization.")
68 (defvar gnus-use-generic-from nil
69 "If nil, the full host name will be the system name prepended to the domain name.
70 If this is a string, the full host name will be this string.
71 If this is non-nil, non-string, the domain name will be used as the
74 (defvar gnus-use-generic-path nil
75 "If nil, use the NNTP server name in the Path header.
76 If stringp, use this; if non-nil, use no host name (user name only).")
79 ;; Customization variables
81 ;; Don't touch this variable.
82 (defvar gnus-nntp-service "nntp"
83 "*NNTP service name (\"nntp\" or 119).
84 This is an obsolete variable, which is scarcely used. If you use an
85 nntp server for your newsgroup and want to change the port number
86 used to 899, you would say something along these lines:
88 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
90 (defvar gnus-nntpserver-file "/etc/nntpserver"
91 "*A file with only the name of the nntp server in it.")
93 ;; This function is used to check both the environment variable
94 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
95 ;; an nntp server name default.
96 (defun gnus-getenv-nntpserver ()
97 (or (getenv "NNTPSERVER")
98 (and (file-readable-p gnus-nntpserver-file)
100 (set-buffer (get-buffer-create " *gnus nntp*"))
101 (buffer-disable-undo (current-buffer))
102 (insert-file-contents gnus-nntpserver-file)
103 (let ((name (buffer-string)))
105 (if (string-match "^[ \t\n]*$" name)
108 (kill-buffer (current-buffer))))))))
110 (defvar gnus-select-method
112 (list 'nntp (or (condition-case ()
113 (gnus-getenv-nntpserver)
115 (if (and gnus-default-nntp-server
116 (not (string= gnus-default-nntp-server "")))
117 gnus-default-nntp-server)
119 (if (or (null gnus-nntp-service)
120 (equal gnus-nntp-service "nntp"))
122 (list gnus-nntp-service)))
123 "*Default method for selecting a newsgroup.
124 This variable should be a list, where the first element is how the
125 news is to be fetched, the second is the address.
127 For instance, if you want to get your news via NNTP from
128 \"flab.flab.edu\", you could say:
130 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
132 If you want to use your local spool, say:
134 (setq gnus-select-method (list 'nnspool (system-name)))
136 If you use this variable, you must set `gnus-nntp-server' to nil.
138 There is a lot more to know about select methods and virtual servers -
139 see the manual for details.")
141 ;; Added by Sudish Joseph <joseph@cis.ohio-state.edu>.
142 (defvar gnus-post-method nil
143 "*Preferred method for posting USENET news.
144 If this variable is nil, Gnus will use the current method to decide
145 which method to use when posting. If it is non-nil, it will override
146 the current method. This method will not be used in mail groups and
147 the like, only in \"real\" newsgroups.
149 The value must be a valid method as discussed in the documentation of
150 `gnus-select-method'.")
152 (defvar gnus-refer-article-method nil
153 "*Preferred method for fetching an article by Message-ID.
154 If you are reading news from the local spool (with nnspool), fetching
155 articles by Message-ID is painfully slow. By setting this method to an
156 nntp method, you might get acceptable results.
158 The value of this variable must be a valid select method as discussed
159 in the documentation of `gnus-select-method'")
161 (defvar gnus-secondary-select-methods nil
162 "*A list of secondary methods that will be used for reading news.
163 This is a list where each element is a complete select method (see
164 `gnus-select-method').
166 If, for instance, you want to read your mail with the nnml backend,
167 you could set this variable:
169 (setq gnus-secondary-select-methods '((nnml \"\")))")
171 (defvar gnus-secondary-servers nil
172 "*List of NNTP servers that the user can choose between interactively.
173 To make Gnus query you for a server, you have to give `gnus' a
174 non-numeric prefix - `C-u M-x gnus', in short.")
176 (defvar gnus-nntp-server nil
177 "*The name of the host running the NNTP server.
178 This variable is semi-obsolete. Use the `gnus-select-method'
181 (defvar gnus-startup-file "~/.newsrc"
182 "*Your `.newsrc' file.
183 `.newsrc-SERVER' will be used instead if that exists.")
185 (defvar gnus-init-file "~/.gnus"
186 "*Your Gnus elisp startup file.
187 If a file with the .el or .elc suffixes exist, it will be read
190 (defvar gnus-group-faq-directory
191 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
192 ; "/ftp@ftp.uu.net:/usenet/news.answers/"
193 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
194 "/ftp@rtfm.mit.edu:/pub/usenet/news.answers/"
195 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
196 ; "/ftp@ftp.Germany.EU.net:/pub/newsarchive/news.answers/"
197 "/ftp@ftp.sunet.se:/pub/usenet/"
198 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
199 "/ftp@hwarang.postech.ac.kr:/pub/usenet/news.answers/"
200 "/ftp@ftp.hk.super.net:/mirror/faqs/")
201 "*Directory where the group FAQs are stored.
202 This will most commonly be on a remote machine, and the file will be
205 This variable can also be a list of directories. In that case, the
206 first element in the list will be used by default, and the others will
207 be used as backup sites.
209 Note that Gnus uses an aol machine as the default directory. If this
210 feels fundamentally unclean, just think of it as a way to finally get
211 something of value back from them.
213 If the default site is too slow, try one of these:
215 North America: mirrors.aol.com /pub/rtfm/usenet
216 ftp.seas.gwu.edu /pub/rtfm
217 rtfm.mit.edu /pub/usenet/news.answers
218 Europe: ftp.uni-paderborn.de /pub/FAQ
219 ftp.sunet.se /pub/usenet
220 Asia: nctuccca.edu.tw /USENET/FAQ
221 hwarang.postech.ac.kr /pub/usenet/news.answers
222 ftp.hk.super.net /mirror/faqs")
224 (defvar gnus-group-archive-directory
225 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
226 "*The address of the (ding) archives.")
228 (defvar gnus-group-recent-archive-directory
229 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
230 "*The address of the most recent (ding) articles.")
232 (defvar gnus-default-subscribed-newsgroups nil
233 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
234 It should be a list of strings.
235 If it is `t', Gnus will not do anything special the first time it is
236 started; it'll just use the normal newsgroups subscription methods.")
238 (defvar gnus-use-cross-reference t
239 "*Non-nil means that cross referenced articles will be marked as read.
240 If nil, ignore cross references. If t, mark articles as read in
241 subscribed newsgroups. If neither t nor nil, mark as read in all
244 (defvar gnus-single-article-buffer t
245 "*If non-nil, display all articles in the same buffer.
246 If nil, each group will get its own article buffer.")
248 (defvar gnus-use-dribble-file t
249 "*Non-nil means that Gnus will use a dribble file to store user updates.
250 If Emacs should crash without saving the .newsrc files, complete
251 information can be restored from the dribble file.")
253 (defvar gnus-dribble-directory nil
254 "*The directory where dribble files will be saved.
255 If this variable is nil, the directory where the .newsrc files are
256 saved will be used.")
258 (defvar gnus-asynchronous nil
259 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
261 (defvar gnus-kill-summary-on-exit t
262 "*If non-nil, kill the summary buffer when you exit from it.
263 If nil, the summary will become a \"*Dead Summary*\" buffer, and
264 it will be killed sometime later.")
266 (defvar gnus-large-newsgroup 200
267 "*The number of articles which indicates a large newsgroup.
268 If the number of articles in a newsgroup is greater than this value,
269 confirmation is required for selecting the newsgroup.")
271 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
272 (defvar gnus-no-groups-message "No news is horrible news"
273 "*Message displayed by Gnus when no groups are available.")
275 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
276 "*Non-nil means that the default name of a file to save articles in is the group name.
277 If it's nil, the directory form of the group name is used instead.
279 If this variable is a list, and the list contains the element
280 `not-score', long file names will not be used for score files; if it
281 contains the element `not-save', long file names will not be used for
282 saving; and if it contains the element `not-kill', long file names
283 will not be used for kill files.")
285 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
286 "*Name of the directory articles will be saved in (default \"~/News\").
287 Initialized from the SAVEDIR environment variable.")
289 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
290 "*Name of the directory where kill files will be stored (default \"~/News\").
291 Initialized from the SAVEDIR environment variable.")
293 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
294 "*A function to save articles in your favorite format.
295 The function must be interactively callable (in other words, it must
296 be an Emacs command).
298 Gnus provides the following functions:
300 * gnus-summary-save-in-rmail (Rmail format)
301 * gnus-summary-save-in-mail (Unix mail format)
302 * gnus-summary-save-in-folder (MH folder)
303 * gnus-summary-save-in-file (article format).
304 * gnus-summary-save-in-vm (use VM's folder format).")
306 (defvar gnus-prompt-before-saving 'always
307 "*This variable says how much prompting is to be done when saving articles.
308 If it is nil, no prompting will be done, and the articles will be
309 saved to the default files. If this variable is `always', each and
310 every article that is saved will be preceded by a prompt, even when
311 saving large batches of articles. If this variable is neither nil not
312 `always', there the user will be prompted once for a file name for
313 each invocation of the saving commands.")
315 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
316 "*A function generating a file name to save articles in Rmail format.
317 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
319 (defvar gnus-mail-save-name (function gnus-plain-save-name)
320 "*A function generating a file name to save articles in Unix mail format.
321 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
323 (defvar gnus-folder-save-name (function gnus-folder-save-name)
324 "*A function generating a file name to save articles in MH folder.
325 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
327 (defvar gnus-file-save-name (function gnus-numeric-save-name)
328 "*A function generating a file name to save articles in article format.
329 The function is called with NEWSGROUP, HEADERS, and optional
332 (defvar gnus-split-methods
333 '((gnus-article-archive-name))
334 "*Variable used to suggest where articles are to be saved.
335 For instance, if you would like to save articles related to Gnus in
336 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
337 you could set this variable to something like:
339 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
340 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
342 This variable is an alist where the where the key is the match and the
343 value is a list of possible files to save in if the match is non-nil.
345 If the match is a string, it is used as a regexp match on the
346 article. If the match is a symbol, that symbol will be funcalled
347 from the buffer of the article to be saved with the newsgroup as the
348 parameter. If it is a list, it will be evaled in the same buffer.
350 If this form or function returns a string, this string will be used as
351 a possible file name; and if it returns a non-nil list, that list will
352 be used as possible file names.")
354 (defvar gnus-move-split-methods nil
355 "*Variable used to suggest where articles are to be moved to.
356 It uses the same syntax as the `gnus-split-methods' variable.")
358 (defvar gnus-save-score nil
359 "*If non-nil, save group scoring info.")
361 (defvar gnus-use-adaptive-scoring nil
362 "*If non-nil, use some adaptive scoring scheme.")
364 (defvar gnus-use-cache nil
365 "*If nil, Gnus will ignore the article cache.
366 If `passive', it will allow entering (and reading) articles
367 explicitly entered into the cache. If anything else, use the
368 cache to the full extent of the law.")
370 (defvar gnus-keep-backlog nil
371 "*If non-nil, Gnus will keep read articles for later re-retrieval.
372 If it is a number N, then Gnus will only keep the last N articles
373 read. If it is neither nil nor a number, Gnus will keep all read
374 articles. This is not a good idea.")
376 (defvar gnus-use-nocem nil
377 "*If non-nil, Gnus will read NoCeM cancel messages.")
379 (defvar gnus-use-demon nil
380 "If non-nil, Gnus might use some demons.")
382 (defvar gnus-use-scoring t
383 "*If non-nil, enable scoring.")
385 (defvar gnus-use-picon nil
386 "*If non-nil, display picons.")
388 (defvar gnus-fetch-old-headers nil
389 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
390 If an unread article in the group refers to an older, already read (or
391 just marked as read) article, the old article will not normally be
392 displayed in the Summary buffer. If this variable is non-nil, Gnus
393 will attempt to grab the headers to the old articles, and thereby
394 build complete threads. If it has the value `some', only enough
395 headers to connect otherwise loose threads will be displayed.
396 This variable can also be a number. In that case, no more than that
397 number of old headers will be fetched.
399 The server has to support NOV for any of this to work.")
402 ;(defvar gnus-visual t
403 ; "*If non-nil, will do various highlighting.
404 ;If nil, no mouse highlights (or any other highlights) will be
405 ;performed. This might speed up Gnus some when generating large group
406 ;and summary buffers.")
408 (defvar gnus-novice-user t
409 "*Non-nil means that you are a usenet novice.
410 If non-nil, verbose messages may be displayed and confirmations may be
413 (defvar gnus-expert-user nil
414 "*Non-nil means that you will never be asked for confirmation about anything.
415 And that means *anything*.")
417 (defvar gnus-verbose 7
418 "*Integer that says how verbose Gnus should be.
419 The higher the number, the more messages Gnus will flash to say what
420 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
421 display most important messages; and at ten, Gnus will keep on
422 jabbering all the time.")
424 (defvar gnus-keep-same-level nil
425 "*Non-nil means that the next newsgroup after the current will be on the same level.
426 When you type, for instance, `n' after reading the last article in the
427 current newsgroup, you will go to the next newsgroup. If this variable
428 is nil, the next newsgroup will be the next from the group
430 If this variable is non-nil, Gnus will either put you in the
431 next newsgroup with the same level, or, if no such newsgroup is
432 available, the next newsgroup with the lowest possible level higher
433 than the current level.
434 If this variable is `best', Gnus will make the next newsgroup the one
435 with the best level.")
437 (defvar gnus-summary-make-false-root 'adopt
438 "*nil means that Gnus won't gather loose threads.
439 If the root of a thread has expired or been read in a previous
440 session, the information necessary to build a complete thread has been
441 lost. Instead of having many small sub-threads from this original thread
442 scattered all over the summary buffer, Gnus can gather them.
444 If non-nil, Gnus will try to gather all loose sub-threads from an
445 original thread into one large thread.
447 If this variable is non-nil, it should be one of `none', `adopt',
450 If this variable is `none', Gnus will not make a false root, but just
451 present the sub-threads after another.
452 If this variable is `dummy', Gnus will create a dummy root that will
453 have all the sub-threads as children.
454 If this variable is `adopt', Gnus will make one of the \"children\"
455 the parent and mark all the step-children as such.
456 If this variable is `empty', the \"children\" are printed with empty
457 subject fields. (Or rather, they will be printed with a string
458 given by the `gnus-summary-same-subject' variable.)")
460 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
461 "*A regexp to match subjects to be excluded from loose thread gathering.
462 As loose thread gathering is done on subjects only, that means that
463 there can be many false gatherings performed. By rooting out certain
464 common subjects, gathering might become saner.")
466 (defvar gnus-summary-gather-subject-limit nil
467 "*Maximum length of subject comparisons when gathering loose threads.
468 Use nil to compare full subjects. Setting this variable to a low
469 number will help gather threads that have been corrupted by
470 newsreaders chopping off subject lines, but it might also mean that
471 unrelated articles that have subject that happen to begin with the
472 same few characters will be incorrectly gathered.
474 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
475 comparing subjects.")
477 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
478 (defvar gnus-summary-same-subject ""
479 "*String indicating that the current article has the same subject as the previous.
480 This variable will only be used if the value of
481 `gnus-summary-make-false-root' is `empty'.")
483 (defvar gnus-summary-goto-unread t
484 "*If non-nil, marking commands will go to the next unread article.")
486 (defvar gnus-group-goto-unread t
487 "*If non-nil, movement commands will go to the next unread and subscribed group.")
489 (defvar gnus-check-new-newsgroups t
490 "*Non-nil means that Gnus will add new newsgroups at startup.
491 If this variable is `ask-server', Gnus will ask the server for new
492 groups since the last time it checked. This means that the killed list
493 is no longer necessary, so you could set `gnus-save-killed-list' to
496 A variant is to have this variable be a list of select methods. Gnus
497 will then use the `ask-server' method on all these select methods to
498 query for new groups from all those servers.
501 (setq gnus-check-new-newsgroups
502 '((nntp \"some.server\") (nntp \"other.server\")))
504 If this variable is nil, then you have to tell Gnus explicitly to
505 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
507 (defvar gnus-check-bogus-newsgroups nil
508 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
509 If this variable is nil, then you have to tell Gnus explicitly to
510 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
512 (defvar gnus-read-active-file t
513 "*Non-nil means that Gnus will read the entire active file at startup.
514 If this variable is nil, Gnus will only know about the groups in your
517 If this variable is `some', Gnus will try to only read the relevant
518 parts of the active file from the server. Not all servers support
519 this, and it might be quite slow with other servers, but this should
520 generally be faster than both the t and nil value.
522 If you set this variable to nil or `some', you probably still want to
523 be told about new newsgroups that arrive. To do that, set
524 `gnus-check-new-newsgroups' to `ask-server'. This may not work
525 properly with all servers.")
527 (defvar gnus-level-subscribed 5
528 "*Groups with levels less than or equal to this variable are subscribed.")
530 (defvar gnus-level-unsubscribed 7
531 "*Groups with levels less than or equal to this variable are unsubscribed.
532 Groups with levels less than `gnus-level-subscribed', which should be
533 less than this variable, are subscribed.")
535 (defvar gnus-level-zombie 8
536 "*Groups with this level are zombie groups.")
538 (defvar gnus-level-killed 9
539 "*Groups with this level are killed.")
541 (defvar gnus-level-default-subscribed 3
542 "*New subscribed groups will be subscribed at this level.")
544 (defvar gnus-level-default-unsubscribed 6
545 "*New unsubscribed groups will be unsubscribed at this level.")
547 (defvar gnus-activate-level (1+ gnus-level-subscribed)
548 "*Groups higher than this level won't be activated on startup.
549 Setting this variable to something log might save lots of time when
550 you have many groups that you aren't interested in.")
552 (defvar gnus-activate-foreign-newsgroups 4
553 "*If nil, Gnus will not check foreign newsgroups at startup.
554 If it is non-nil, it should be a number between one and nine. Foreign
555 newsgroups that have a level lower or equal to this number will be
556 activated on startup. For instance, if you want to active all
557 subscribed newsgroups, but not the rest, you'd set this variable to
558 `gnus-level-subscribed'.
560 If you subscribe to lots of newsgroups from different servers, startup
561 might take a while. By setting this variable to nil, you'll save time,
562 but you won't be told how many unread articles there are in the
565 (defvar gnus-save-newsrc-file t
566 "*Non-nil means that Gnus will save the `.newsrc' file.
567 Gnus always saves its own startup file, which is called
568 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
569 be readily understood by other newsreaders. If you don't plan on
570 using other newsreaders, set this variable to nil to save some time on
573 (defvar gnus-save-killed-list t
574 "*If non-nil, save the list of killed groups to the startup file.
575 If you set this variable to nil, you'll save both time (when starting
576 and quitting) and space (both memory and disk), but it will also mean
577 that Gnus has no record of which groups are new and which are old, so
578 the automatic new newsgroups subscription methods become meaningless.
580 You should always set `gnus-check-new-newsgroups' to `ask-server' or
581 nil if you set this variable to nil.")
583 (defvar gnus-interactive-catchup t
584 "*If non-nil, require your confirmation when catching up a group.")
586 (defvar gnus-interactive-post t
587 "*If non-nil, group name will be asked for when posting.")
589 (defvar gnus-interactive-exit t
590 "*If non-nil, require your confirmation when exiting Gnus.")
592 (defvar gnus-kill-killed t
593 "*If non-nil, Gnus will apply kill files to already killed articles.
594 If it is nil, Gnus will never apply kill files to articles that have
595 already been through the scoring process, which might very well save lots
598 (defvar gnus-extract-address-components 'gnus-extract-address-components
599 "*Function for extracting address components from a From header.
600 Two pre-defined function exist: `gnus-extract-address-components',
601 which is the default, quite fast, and too simplistic solution, and
602 `mail-extract-address-components', which works much better, but is
605 (defvar gnus-summary-default-score 0
606 "*Default article score level.
607 If this variable is nil, scoring will be disabled.")
609 (defvar gnus-summary-zcore-fuzz 0
610 "*Fuzziness factor for the zcore in the summary buffer.
611 Articles with scores closer than this to `gnus-summary-default-score'
612 will not be marked.")
614 (defvar gnus-simplify-subject-fuzzy-regexp nil
615 "*Strings to be removed when doing fuzzy matches.
616 This can either be a regular expression or list of regular expressions
617 that will be removed from subject strings if fuzzy subject
618 simplification is selected.")
620 (defvar gnus-permanently-visible-groups nil
621 "*Regexp to match groups that should always be listed in the group buffer.
622 This means that they will still be listed when there are no unread
623 articles in the groups.")
625 (defvar gnus-group-default-list-level gnus-level-subscribed
626 "*Default listing level.
627 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
629 (defvar gnus-group-use-permanent-levels nil
630 "*If non-nil, once you set a level, Gnus will use this level.")
632 (defvar gnus-group-list-inactive-groups t
633 "*If non-nil, inactive groups will be listed.")
635 (defvar gnus-show-mime nil
636 "*If non-nil, do mime processing of articles.
637 The articles will simply be fed to the function given by
638 `gnus-show-mime-method'.")
640 (defvar gnus-strict-mime t
641 "*If nil, decode MIME header even if there is not Mime-Version field.")
643 (defvar gnus-show-mime-method 'metamail-buffer
644 "*Function to process a MIME message.
645 The function is called from the article buffer.")
647 (defvar gnus-decode-encoded-word-method (lambda ())
648 "*Function to decode a MIME encoded-words.
649 The function is called from the article buffer.")
651 (defvar gnus-show-threads t
652 "*If non-nil, display threads in summary mode.")
654 (defvar gnus-thread-hide-subtree nil
655 "*If non-nil, hide all threads initially.
656 If threads are hidden, you have to run the command
657 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
658 to expose hidden threads.")
660 (defvar gnus-thread-hide-killed t
661 "*If non-nil, hide killed threads automatically.")
663 (defvar gnus-thread-ignore-subject nil
664 "*If non-nil, ignore subjects and do all threading based on the Reference header.
665 If nil, which is the default, articles that have different subjects
666 from their parents will start separate threads.")
668 (defvar gnus-thread-operation-ignore-subject t
669 "*If non-nil, subjects will be ignored when doing thread commands.
670 This affects commands like `gnus-summary-kill-thread' and
671 `gnus-summary-lower-thread'.
673 If this variable is nil, articles in the same thread with different
674 subjects will not be included in the operation in question. If this
675 variable is `fuzzy', only articles that have subjects that are fuzzily
676 equal will be included.")
678 (defvar gnus-thread-indent-level 4
679 "*Number that says how much each sub-thread should be indented.")
681 (defvar gnus-ignored-newsgroups
682 (purecopy (mapconcat 'identity
683 '("^to\\." ; not "real" groups
684 "^[0-9. \t]+ " ; all digits in name
685 "[][\"#'()]" ; bogus characters
688 "*A regexp to match uninteresting newsgroups in the active file.
689 Any lines in the active file matching this regular expression are
690 removed from the newsgroup list before anything else is done to it,
691 thus making them effectively non-existent.")
693 (defvar gnus-ignored-headers
694 "^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:"
695 "*All headers that match this regexp will be hidden.
696 This variable can also be a list of regexps of headers to be ignored.
697 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
699 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Resent-"
700 "*All headers that do not match this regexp will be hidden.
701 This variable can also be a list of regexp of headers to remain visible.
702 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
704 (defvar gnus-sorted-header-list
705 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
706 "^Cc:" "^Date:" "^Organization:")
707 "*This variable is a list of regular expressions.
708 If it is non-nil, headers that match the regular expressions will
709 be placed first in the article buffer in the sequence specified by
712 (defvar gnus-show-all-headers nil
713 "*If non-nil, don't hide any headers.")
715 (defvar gnus-save-all-headers t
716 "*If non-nil, don't remove any headers before saving.")
718 (defvar gnus-saved-headers gnus-visible-headers
719 "*Headers to keep if `gnus-save-all-headers' is nil.
720 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
721 If that variable is nil, however, all headers that match this regexp
722 will be kept while the rest will be deleted before saving.")
724 (defvar gnus-inhibit-startup-message nil
725 "*If non-nil, the startup message will not be displayed.")
727 (defvar gnus-signature-separator "^-- *$"
728 "Regexp matching signature separator.")
730 (defvar gnus-auto-extend-newsgroup t
731 "*If non-nil, extend newsgroup forward and backward when requested.")
733 (defvar gnus-auto-select-first t
734 "*If nil, don't select the first unread article when entering a group.
735 If this variable is `best', select the highest-scored unread article
736 in the group. If neither nil nor `best', select the first unread
739 If you want to prevent automatic selection of the first unread article
740 in some newsgroups, set the variable to nil in
741 `gnus-select-group-hook'.")
743 (defvar gnus-auto-select-next t
744 "*If non-nil, offer to go to the next group from the end of the previous.
745 If the value is t and the next newsgroup is empty, Gnus will exit
746 summary mode and go back to group mode. If the value is neither nil
747 nor t, Gnus will select the following unread newsgroup. In
748 particular, if the value is the symbol `quietly', the next unread
749 newsgroup will be selected without any confirmation, and if it is
750 `almost-quietly', the next group will be selected without any
751 confirmation if you are located on the last article in the group.")
753 (defvar gnus-auto-select-same nil
754 "*If non-nil, select the next article with the same subject.")
756 (defvar gnus-summary-check-current nil
757 "*If non-nil, consider the current article when moving.
758 The \"unread\" movement commands will stay on the same line if the
759 current article is unread.")
761 (defvar gnus-auto-center-summary t
762 "*If non-nil, always center the current summary buffer.")
764 (defvar gnus-break-pages t
765 "*If non-nil, do page breaking on articles.
766 The page delimiter is specified by the `gnus-page-delimiter'
769 (defvar gnus-page-delimiter "^\^L"
770 "*Regexp describing what to use as article page delimiters.
771 The default value is \"^\^L\", which is a form linefeed at the
772 beginning of a line.")
774 (defvar gnus-use-full-window t
775 "*If non-nil, use the entire Emacs screen.")
777 (defvar gnus-window-configuration nil
778 "Obsolete variable. See `gnus-buffer-configuration'.")
780 (defvar gnus-buffer-configuration
784 (if gnus-carpal (group-carpal 4))))
788 (if gnus-carpal (summary-carpal 4))))
794 (if gnus-carpal (summary-carpal 4))
800 (if gnus-carpal (summary-carpal 4))
805 (if gnus-carpal (server-carpal 2))))
809 (if gnus-carpal (browse-carpal 2))))
830 (edit-group 1.0 point)))
834 (edit-server 1.0 point)))
838 (edit-score 1.0 point)))
865 (if gnus-carpal (summary-carpal 4))
866 ("*Shell Command Output*" 1.0)))
874 "Window configuration for all possible Gnus buffers.
875 This variable is a list of lists. Each of these lists has a NAME and
876 a RULE. The NAMEs are commonsense names like `group', which names a
877 rule used when displaying the group buffer; `summary', which names a
878 rule for what happens when you enter a group and do not display an
879 article buffer; and so on. See the value of this variable for a
880 complete list of NAMEs.
882 Each RULE is a list of vectors. The first element in this vector is
883 the name of the buffer to be displayed; the second element is the
884 percentage of the screen this buffer is to occupy (a number in the
885 0.0-0.99 range); the optional third element is `point', which should
886 be present to denote which buffer point is to go to after making this
887 buffer configuration.")
889 (defvar gnus-window-to-buffer
890 '((group . gnus-group-buffer)
891 (summary . gnus-summary-buffer)
892 (article . gnus-article-buffer)
893 (server . gnus-server-buffer)
894 (browse . "*Gnus Browse Server*")
895 (edit-group . gnus-group-edit-buffer)
896 (edit-server . gnus-server-edit-buffer)
897 (group-carpal . gnus-carpal-group-buffer)
898 (summary-carpal . gnus-carpal-summary-buffer)
899 (server-carpal . gnus-carpal-server-buffer)
900 (browse-carpal . gnus-carpal-browse-buffer)
901 (edit-score . gnus-score-edit-buffer)
902 (mail . gnus-mail-buffer)
903 (post . gnus-post-news-buffer)
904 (faq . gnus-faq-buffer)
905 (picon . gnus-picon-buffer)
906 (draft . gnus-draft-buffer))
907 "Mapping from short symbols to buffer names or buffer variables.")
909 (defvar gnus-carpal nil
910 "*If non-nil, display clickable icons.")
912 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
913 "*Function called with a group name when new group is detected.
914 A few pre-made functions are supplied: `gnus-subscribe-randomly'
915 inserts new groups at the beginning of the list of groups;
916 `gnus-subscribe-alphabetically' inserts new groups in strict
917 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
918 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
919 for your decision; `gnus-subscribe-killed' kills all new groups.")
921 ;; Suggested by a bug report by Hallvard B Furuseth.
922 ;; <h.b.furuseth@usit.uio.no>.
923 (defvar gnus-subscribe-options-newsgroup-method
924 (function gnus-subscribe-alphabetically)
925 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
926 If, for instance, you want to subscribe to all newsgroups in the
927 \"no\" and \"alt\" hierarchies, you'd put the following in your
930 options -n no.all alt.all
932 Gnus will the subscribe all new newsgroups in these hierarchies with
933 the subscription method in this variable.")
935 (defvar gnus-subscribe-hierarchical-interactive nil
936 "*If non-nil, Gnus will offer to subscribe hierarchically.
937 When a new hierarchy appears, Gnus will ask the user:
939 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
941 If the user pressed `d', Gnus will descend the hierarchy, `y' will
942 subscribe to all newsgroups in the hierarchy and `s' will skip this
943 hierarchy in its entirety.")
945 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
946 "*Function used for sorting the group buffer.
947 This function will be called with group info entries as the arguments
948 for the groups to be sorted. Pre-made functions include
949 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
950 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
951 `gnus-group-sort-by-rank'.
953 This variable can also be a list of sorting functions. In that case,
954 the most significant sort function should be the last function in the
957 ;; Mark variables suggested by Thomas Michanek
958 ;; <Thomas.Michanek@telelogic.se>.
959 (defvar gnus-unread-mark ?
960 "*Mark used for unread articles.")
961 (defvar gnus-ticked-mark ?!
962 "*Mark used for ticked articles.")
963 (defvar gnus-dormant-mark ??
964 "*Mark used for dormant articles.")
965 (defvar gnus-del-mark ?r
966 "*Mark used for del'd articles.")
967 (defvar gnus-read-mark ?R
968 "*Mark used for read articles.")
969 (defvar gnus-expirable-mark ?E
970 "*Mark used for expirable articles.")
971 (defvar gnus-killed-mark ?K
972 "*Mark used for killed articles.")
973 (defvar gnus-souped-mark ?F
974 "*Mark used for killed articles.")
975 (defvar gnus-kill-file-mark ?X
976 "*Mark used for articles killed by kill files.")
977 (defvar gnus-low-score-mark ?Y
978 "*Mark used for articles with a low score.")
979 (defvar gnus-catchup-mark ?C
980 "*Mark used for articles that are caught up.")
981 (defvar gnus-replied-mark ?A
982 "*Mark used for articles that have been replied to.")
983 (defvar gnus-cached-mark ?*
984 "*Mark used for articles that are in the cache.")
985 (defvar gnus-saved-mark ?S
986 "*Mark used for articles that have been saved to.")
987 (defvar gnus-process-mark ?#
989 (defvar gnus-ancient-mark ?O
990 "*Mark used for ancient articles.")
991 (defvar gnus-canceled-mark ?G
992 "*Mark used for canceled articles.")
993 (defvar gnus-score-over-mark ?+
994 "*Score mark used for articles with high scores.")
995 (defvar gnus-score-below-mark ?-
996 "*Score mark used for articles with low scores.")
997 (defvar gnus-empty-thread-mark ?
998 "*There is no thread under the article.")
999 (defvar gnus-not-empty-thread-mark ?=
1000 "*There is a thread under the article.")
1002 (defvar gnus-view-pseudo-asynchronously nil
1003 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1005 (defvar gnus-view-pseudos nil
1006 "*If `automatic', pseudo-articles will be viewed automatically.
1007 If `not-confirm', pseudos will be viewed automatically, and the user
1008 will not be asked to confirm the command.")
1010 (defvar gnus-view-pseudos-separately t
1011 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1012 If nil, all files that use the same viewing command will be given as a
1013 list of parameters to that command.")
1015 (defvar gnus-insert-pseudo-articles t
1016 "*If non-nil, insert pseudo-articles when decoding articles.")
1018 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)\n"
1019 "*Format of group lines.
1020 It works along the same lines as a normal formatting string,
1021 with some simple extensions.
1023 %M Only marked articles (character, \"*\" or \" \")
1024 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1025 %L Level of subscribedness (integer)
1026 %N Number of unread articles (integer)
1027 %I Number of dormant articles (integer)
1028 %i Number of ticked and dormant (integer)
1029 %T Number of ticked articles (integer)
1030 %R Number of read articles (integer)
1031 %t Total number of articles (integer)
1032 %y Number of unread, unticked articles (integer)
1033 %G Group name (string)
1034 %g Qualified group name (string)
1035 %D Group description (string)
1036 %s Select method (string)
1037 %o Moderated group (char, \"m\")
1038 %p Process mark (char)
1039 %O Moderated group (string, \"(m)\" or \"\")
1040 %P Topic indentation (string)
1041 %n Select from where (string)
1042 %z A string that look like `<%s:%n>' if a foreign select method is used
1043 %u User defined specifier. The next character in the format string should
1044 be a letter. Gnus will call the function gnus-user-format-function-X,
1045 where X is the letter following %u. The function will be passed the
1046 current header as argument. The function should return a string, which
1047 will be inserted into the buffer just like information from any other
1050 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1051 the mouse point move inside the area. There can only be one such area.
1053 Note that this format specification is not always respected. For
1054 reasons of efficiency, when listing killed groups, this specification
1055 is ignored altogether. If the spec is changed considerably, your
1056 output may end up looking strange when listing both alive and killed
1059 If you use %o or %O, reading the active file will be slower and quite
1060 a bit of extra memory will be used. %D will also worsen performance.
1061 Also note that if you change the format specification to include any
1062 of these specs, you must probably re-start Gnus to see them go into
1065 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1066 "*The format specification of the lines in the summary buffer.
1068 It works along the same lines as a normal formatting string,
1069 with some simple extensions.
1071 %N Article number, left padded with spaces (string)
1073 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1074 %n Name of the poster (string)
1075 %a Extracted name of the poster (string)
1076 %A Extracted address of the poster (string)
1077 %F Contents of the From: header (string)
1078 %x Contents of the Xref: header (string)
1079 %D Date of the article (string)
1080 %d Date of the article (string) in DD-MMM format
1081 %M Message-id of the article (string)
1082 %r References of the article (string)
1083 %c Number of characters in the article (integer)
1084 %L Number of lines in the article (integer)
1085 %I Indentation based on thread level (a string of spaces)
1086 %T A string with two possible values: 80 spaces if the article
1087 is on thread level two or larger and 0 spaces on level one
1088 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1089 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1090 %[ Opening bracket (character, \"[\" or \"<\")
1091 %] Closing bracket (character, \"]\" or \">\")
1092 %> Spaces of length thread-level (string)
1093 %< Spaces of length (- 20 thread-level) (string)
1094 %i Article score (number)
1095 %z Article zcore (character)
1096 %t Number of articles under the current thread (number).
1097 %e Whether the thread is empty or not (character).
1098 %u User defined specifier. The next character in the format string should
1099 be a letter. Gnus will call the function gnus-user-format-function-X,
1100 where X is the letter following %u. The function will be passed the
1101 current header as argument. The function should return a string, which
1102 will be inserted into the summary just like information from any other
1105 Text between %( and %) will be highlighted with `gnus-mouse-face'
1106 when the mouse point is placed inside the area. There can only be one
1109 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1110 with care. For reasons of efficiency, Gnus will compute what column
1111 these characters will end up in, and \"hard-code\" that. This means that
1112 it is illegal to have these specs after a variable-length spec. Well,
1113 you might not be arrested, but your summary buffer will look strange,
1114 which is bad enough.
1116 The smart choice is to have these specs as for to the left as
1119 This restriction may disappear in later versions of Gnus.")
1121 (defvar gnus-summary-dummy-line-format
1123 "*The format specification for the dummy roots in the summary buffer.
1124 It works along the same lines as a normal formatting string,
1125 with some simple extensions.
1129 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1130 "*The format specification for the summary mode line.
1131 It works along the same lines as a normal formatting string,
1132 with some simple extensions:
1135 %p Unprefixed group name
1136 %A Current article number
1138 %U Number of unread articles in the group
1139 %e Number of unselected articles in the group
1140 %Z A string with unread/unselected article counts
1141 %g Shortish group name
1142 %S Subject of the current article
1143 %u User-defined spec
1144 %s Current score file name
1145 %d Number of dormant articles
1146 %r Number of articles that have been marked as read in this session
1147 %E Number of articles expunged by the score files")
1149 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1150 "*The format specification for the article mode line.
1151 See `gnus-summary-mode-line-format' for a closer description.")
1153 (defvar gnus-group-mode-line-format "Gnus: %%b {%M:%S}"
1154 "*The format specification for the group mode line.
1155 It works along the same lines as a normal formatting string,
1156 with some simple extensions:
1158 %S The native news server.
1159 %M The native select method.")
1161 (defvar gnus-valid-select-methods
1162 '(("nntp" post address prompt-address)
1164 ("nnvirtual" post-mail virtual prompt-address)
1165 ("nnmbox" mail respool)
1166 ("nnml" mail respool)
1167 ("nnmh" mail respool)
1168 ("nndir" post-mail prompt-address address)
1169 ("nneething" none prompt-address)
1170 ("nndoc" none prompt-address)
1171 ("nnbabyl" mail respool)
1172 ("nnkiboze" post virtual)
1173 ("nnsoup" post-mail)
1174 ("nnfolder" mail respool))
1175 "An alist of valid select methods.
1176 The first element of each list lists should be a string with the name
1177 of the select method. The other elements may be be the category of
1178 this method (ie. `post', `mail', `none' or whatever) or other
1179 properties that this method has (like being respoolable).
1180 If you implement a new select method, all you should have to change is
1181 this variable. I think.")
1183 (defvar gnus-updated-mode-lines '(group article summary)
1184 "*List of buffers that should update their mode lines.
1185 The list may contain the symbols `group', `article' and `summary'. If
1186 the corresponding symbol is present, Gnus will keep that mode line
1187 updated with information that may be pertinent.
1188 If this variable is nil, screen refresh may be quicker.")
1190 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1191 (defvar gnus-mode-non-string-length nil
1192 "*Max length of mode-line non-string contents.
1193 If this is nil, Gnus will take space as is needed, leaving the rest
1194 of the modeline intact.")
1197 ;(defvar gnus-mouse-face 'highlight
1198 ; "*Face used for mouse highlighting in Gnus.
1199 ;No mouse highlights will be done if `gnus-visual' is nil.")
1201 (defvar gnus-summary-mark-below nil
1202 "*Mark all articles with a score below this variable as read.
1203 This variable is local to each summary buffer and usually set by the
1206 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1207 "*List of functions used for sorting articles in the summary buffer.")
1209 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1210 "*List of functions used for sorting threads in the summary buffer.
1211 By default, threads are sorted by article number.
1213 Each function takes two threads and return non-nil if the first thread
1214 should be sorted before the other. If you use more than one function,
1215 the primary sort function should be the last.
1217 Ready-mady functions include `gnus-thread-sort-by-number',
1218 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1219 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1220 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1222 (defvar gnus-thread-score-function '+
1223 "*Function used for calculating the total score of a thread.
1225 The function is called with the scores of the article and each
1226 subthread and should then return the score of the thread.
1228 Some functions you can use are `+', `max', or `min'.")
1230 (defvar gnus-summary-expunge-below nil
1231 "All articles that have a score less than this variable will be expunged.")
1233 (defvar gnus-thread-expunge-below nil
1234 "All threads that have a total score less than this variable will be expunged.
1235 See `gnus-thread-score-function' for en explanation of what a
1236 \"thread score\" is.")
1238 (defvar gnus-auto-subscribed-groups
1239 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1240 "*All new groups that match this regexp will be subscribed automatically.
1241 Note that this variable only deals with new groups. It has no effect
1242 whatsoever on old groups.")
1244 (defvar gnus-options-subscribe nil
1245 "*All new groups matching this regexp will be subscribed unconditionally.
1246 Note that this variable deals only with new newsgroups. This variable
1247 does not affect old newsgroups.")
1249 (defvar gnus-options-not-subscribe nil
1250 "*All new groups matching this regexp will be ignored.
1251 Note that this variable deals only with new newsgroups. This variable
1252 does not affect old (already subscribed) newsgroups.")
1254 (defvar gnus-auto-expirable-newsgroups nil
1255 "*Groups in which to automatically mark read articles as expirable.
1256 If non-nil, this should be a regexp that should match all groups in
1257 which to perform auto-expiry. This only makes sense for mail groups.")
1259 (defvar gnus-total-expirable-newsgroups nil
1260 "*Groups in which to perform expiry of all read articles.
1261 Use with extreme caution. All groups that match this regexp will be
1262 expiring - which means that all read articles will be deleted after
1263 (say) one week. (This only goes for mail groups and the like, of
1266 (defvar gnus-hidden-properties '(invisible t intangible t)
1267 "Property list to use for hiding text.")
1269 (defvar gnus-modtime-botch nil
1270 "*Non-nil means .newsrc should be deleted prior to save. Its use is
1271 due to the bogus appearance that .newsrc was modified on disc.")
1275 (defvar gnus-group-mode-hook nil
1276 "*A hook for Gnus group mode.")
1278 (defvar gnus-summary-mode-hook nil
1279 "*A hook for Gnus summary mode.
1280 This hook is run before any variables are set in the summary buffer.")
1282 (defvar gnus-article-mode-hook nil
1283 "*A hook for Gnus article mode.")
1285 (defun gnus-summary-prepare-exit-hook nil
1286 "*A hook called when preparing to exit from the summary buffer.
1287 It calls `gnus-summary-expire-articles' by default.")
1288 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1290 (defun gnus-summary-exit-hook nil
1291 "*A hook called on exit from the summary buffer.")
1293 (defvar gnus-open-server-hook nil
1294 "*A hook called just before opening connection to the news server.")
1296 (defvar gnus-load-hook nil
1297 "*A hook run while Gnus is loaded.")
1299 (defvar gnus-startup-hook nil
1300 "*A hook called at startup.
1301 This hook is called after Gnus is connected to the NNTP server.")
1303 (defvar gnus-get-new-news-hook nil
1304 "*A hook run just before Gnus checks for new news.")
1306 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1307 "*A function that is called to generate the group buffer.
1308 The function is called with three arguments: The first is a number;
1309 all group with a level less or equal to that number should be listed,
1310 if the second is non-nil, empty groups should also be displayed. If
1311 the third is non-nil, it is a number. No groups with a level lower
1312 than this number should be displayed.
1314 The only current function implemented is `gnus-group-prepare-flat'.")
1316 (defvar gnus-group-prepare-hook nil
1317 "*A hook called after the group buffer has been generated.
1318 If you want to modify the group buffer, you can use this hook.")
1320 (defvar gnus-summary-prepare-hook nil
1321 "*A hook called after the summary buffer has been generated.
1322 If you want to modify the summary buffer, you can use this hook.")
1324 (defvar gnus-summary-generate-hook nil
1325 "*A hook run just before generating the summary buffer.
1326 This hook is commonly used to customize threading variables and the
1329 (defvar gnus-article-prepare-hook nil
1330 "*A hook called after an article has been prepared in the article buffer.
1331 If you want to run a special decoding program like nkf, use this hook.")
1333 ;(defvar gnus-article-display-hook nil
1334 ; "*A hook called after the article is displayed in the article buffer.
1335 ;The hook is designed to change the contents of the article
1336 ;buffer. Typical functions that this hook may contain are
1337 ;`gnus-article-hide-headers' (hide selected headers),
1338 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1339 ;`gnus-article-hide-signature' (hide signature) and
1340 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1341 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1342 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1343 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1345 (defvar gnus-article-x-face-command
1346 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1347 "String or function to be executed to display an X-Face header.
1348 If it is a string, the command will be executed in a sub-shell
1349 asynchronously. The compressed face will be piped to this command.")
1351 (defvar gnus-article-x-face-too-ugly nil
1352 "Regexp matching posters whose face shouldn't be shown automatically.")
1354 (defvar gnus-select-group-hook nil
1355 "*A hook called when a newsgroup is selected.
1357 If you'd like to simplify subjects like the
1358 `gnus-summary-next-same-subject' command does, you can use the
1361 (setq gnus-select-group-hook
1364 (mapcar (lambda (header)
1365 (mail-header-set-subject
1367 (gnus-simplify-subject
1368 (mail-header-subject header) 're-only)))
1369 gnus-newsgroup-headers))))")
1371 (defvar gnus-select-article-hook
1372 '(gnus-summary-show-thread)
1373 "*A hook called when an article is selected.
1374 The default hook shows conversation thread subtrees of the selected
1375 article automatically using `gnus-summary-show-thread'.")
1377 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1378 "*A hook called to apply kill files to a group.
1379 This hook is intended to apply a kill file to the selected newsgroup.
1380 The function `gnus-apply-kill-file' is called by default.
1382 Since a general kill file is too heavy to use only for a few
1383 newsgroups, I recommend you to use a lighter hook function. For
1384 example, if you'd like to apply a kill file to articles which contains
1385 a string `rmgroup' in subject in newsgroup `control', you can use the
1388 (setq gnus-apply-kill-hook
1391 (cond ((string-match \"control\" gnus-newsgroup-name)
1392 (gnus-kill \"Subject\" \"rmgroup\")
1393 (gnus-expunge \"X\"))))))")
1395 (defvar gnus-visual-mark-article-hook
1396 (list 'gnus-highlight-selected-summary)
1397 "*Hook run after selecting an article in the summary buffer.
1398 It is meant to be used for highlighting the article in some way. It
1399 is not run if `gnus-visual' is nil.")
1401 (defun gnus-parse-headers-hook nil
1402 "*A hook called before parsing the headers.")
1404 (defvar gnus-exit-group-hook nil
1405 "*A hook called when exiting (not quitting) summary mode.")
1407 (defvar gnus-suspend-gnus-hook nil
1408 "*A hook called when suspending (not exiting) Gnus.")
1410 (defvar gnus-exit-gnus-hook nil
1411 "*A hook called when exiting Gnus.")
1413 (defvar gnus-save-newsrc-hook nil
1414 "*A hook called before saving any of the newsrc files.")
1416 (defvar gnus-save-quick-newsrc-hook nil
1417 "*A hook called just before saving the quick newsrc file.
1418 Can be used to turn version control on or off.")
1420 (defvar gnus-save-standard-newsrc-hook nil
1421 "*A hook called just before saving the standard newsrc file.
1422 Can be used to turn version control on or off.")
1424 (defvar gnus-summary-update-hook
1425 (list 'gnus-summary-highlight-line)
1426 "*A hook called when a summary line is changed.
1427 The hook will not be called if `gnus-visual' is nil.
1429 The default function `gnus-summary-highlight-line' will
1430 highlight the line according to the `gnus-summary-highlight'
1433 (defvar gnus-mark-article-hook (list 'gnus-summary-mark-unread-as-read)
1434 "*A hook called when an article is selected for the first time.
1435 The hook is intended to mark an article as read (or unread)
1436 automatically when it is selected.")
1438 ;; Remove any hilit infestation.
1439 (add-hook 'gnus-startup-hook
1441 (remove-hook 'gnus-summary-prepare-hook
1442 'hilit-rehighlight-buffer-quietly)
1443 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1444 (setq gnus-mark-article-hook '(gnus-summary-mark-unread-as-read))
1445 (remove-hook 'gnus-article-prepare-hook
1446 'hilit-rehighlight-buffer-quietly)))
1450 ;; Internal variables
1452 (defconst gnus-article-mark-lists
1453 '((marked . tick) (replied . reply)
1454 (expirable . expire) (killed . killed)
1455 (bookmarks . bookmark) (dormant . dormant)
1456 (scored . score) (saved . save)))
1458 ;; Avoid highlighting in kill files.
1459 (defvar gnus-summary-inhibit-highlight nil)
1460 (defvar gnus-newsgroup-selected-overlay nil)
1462 (defvar gnus-inhibit-hiding nil)
1463 (defvar gnus-topic-indentation "")
1464 (defvar gnus-inhibit-limiting nil)
1466 (defvar gnus-article-mode-map nil)
1467 (defvar gnus-dribble-buffer nil)
1468 (defvar gnus-headers-retrieved-by nil)
1469 (defvar gnus-article-reply nil)
1470 (defvar gnus-override-method nil)
1471 (defvar gnus-article-check-size nil)
1473 (defvar gnus-nocem-hashtb nil)
1475 (defvar gnus-current-score-file nil)
1476 (defvar gnus-newsgroup-adaptive-score-file nil)
1477 (defvar gnus-scores-exclude-files nil)
1479 (defvar gnus-opened-servers nil)
1481 (defvar gnus-current-move-group nil)
1483 (defvar gnus-newsgroup-dependencies nil)
1484 (defvar gnus-newsgroup-async nil)
1485 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1487 (defvar gnus-newsgroup-adaptive nil)
1489 (defvar gnus-summary-display-table nil)
1491 (defconst gnus-group-line-format-alist
1492 `((?M gnus-tmp-marked-mark ?c)
1493 (?S gnus-tmp-subscribed ?c)
1494 (?L gnus-tmp-level ?d)
1495 (?N gnus-tmp-number ?s)
1496 (?R gnus-tmp-number-of-read ?s)
1497 (?t gnus-tmp-number-total ?s)
1498 (?y gnus-tmp-number-of-unread ?s)
1499 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1500 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1501 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1502 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1503 (?g gnus-tmp-group ?s)
1504 (?G gnus-tmp-qualified-group ?s)
1505 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1506 (?D gnus-tmp-newsgroup-description ?s)
1507 (?o gnus-tmp-moderated ?c)
1508 (?O gnus-tmp-moderated-string ?s)
1509 (?p gnus-tmp-process-marked ?c)
1510 (?s gnus-tmp-news-server ?s)
1511 (?n gnus-tmp-news-method ?s)
1512 (?P gnus-topic-indentation ?s)
1513 (?z gnus-tmp-news-method-string ?s)
1514 (?u gnus-tmp-user-defined ?s)))
1516 (defconst gnus-summary-line-format-alist
1517 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1518 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1519 (?s gnus-tmp-subject-or-nil ?s)
1520 (?n gnus-tmp-name ?s)
1521 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1523 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1525 (?F gnus-tmp-from ?s)
1526 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1527 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1528 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1529 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1530 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1531 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1532 (?L gnus-tmp-lines ?d)
1533 (?I gnus-tmp-indentation ?s)
1534 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1535 (?R gnus-tmp-replied ?c)
1536 (?\[ gnus-tmp-opening-bracket ?c)
1537 (?\] gnus-tmp-closing-bracket ?c)
1538 (?\> (make-string gnus-tmp-level ? ) ?s)
1539 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1540 (?i gnus-tmp-score ?d)
1541 (?z gnus-tmp-score-char ?c)
1542 (?U gnus-tmp-unread ?c)
1543 (?t (gnus-summary-number-of-articles-in-thread
1544 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1546 (?e (gnus-summary-number-of-articles-in-thread
1547 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1549 (?u gnus-tmp-user-defined ?s))
1550 "An alist of format specifications that can appear in summary lines,
1551 and what variables they correspond with, along with the type of the
1552 variable (string, integer, character, etc).")
1554 (defconst gnus-summary-dummy-line-format-alist
1555 (` ((?S gnus-tmp-subject ?s)
1556 (?N gnus-tmp-number ?d)
1557 (?u gnus-tmp-user-defined ?s))))
1559 (defconst gnus-summary-mode-line-format-alist
1560 (` ((?G gnus-tmp-group-name ?s)
1561 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1562 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1563 (?A gnus-tmp-article-number ?d)
1564 (?Z gnus-tmp-unread-and-unselected ?s)
1565 (?V gnus-version ?s)
1566 (?U gnus-tmp-unread ?d)
1567 (?S gnus-tmp-subject ?s)
1568 (?e gnus-tmp-unselected ?d)
1569 (?u gnus-tmp-user-defined ?s)
1570 (?d (length gnus-newsgroup-dormant) ?d)
1571 (?t (length gnus-newsgroup-marked) ?d)
1572 (?r (length gnus-newsgroup-reads) ?d)
1573 (?E gnus-newsgroup-expunged-tally ?d)
1574 (?s (gnus-current-score-file-nondirectory) ?s))))
1576 (defconst gnus-article-mode-line-format-alist
1577 gnus-summary-mode-line-format-alist)
1579 (defconst gnus-group-mode-line-format-alist
1580 (` ((?S gnus-tmp-news-server ?s)
1581 (?M gnus-tmp-news-method ?s)
1582 (?u gnus-tmp-user-defined ?s))))
1584 (defvar gnus-have-read-active-file nil)
1586 (defconst gnus-maintainer
1587 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1588 "The mail address of the Gnus maintainers.")
1590 (defconst gnus-version "September Gnus v0.26"
1591 "Version number for this version of Gnus.")
1593 (defvar gnus-info-nodes
1594 '((gnus-group-mode "(gnus)The Group Buffer")
1595 (gnus-summary-mode "(gnus)The Summary Buffer")
1596 (gnus-article-mode "(gnus)The Article Buffer"))
1597 "Assoc list of major modes and related Info nodes.")
1599 (defvar gnus-group-buffer "*Group*")
1600 (defvar gnus-summary-buffer "*Summary*")
1601 (defvar gnus-article-buffer "*Article*")
1602 (defvar gnus-server-buffer "*Server*")
1604 (defvar gnus-work-buffer " *gnus work*")
1606 (defvar gnus-original-article-buffer " *Original Article*")
1607 (defvar gnus-original-article nil)
1609 (defvar gnus-buffer-list nil
1610 "Gnus buffers that should be killed on exit.")
1612 (defvar gnus-server-alist nil
1613 "List of available servers.")
1615 (defvar gnus-slave nil
1616 "Whether this Gnus is a slave or not.")
1618 (defvar gnus-variable-list
1619 '(gnus-newsrc-options gnus-newsrc-options-n
1620 gnus-newsrc-last-checked-date
1621 gnus-newsrc-alist gnus-server-alist
1622 gnus-killed-list gnus-zombie-list
1623 gnus-topic-topology gnus-topic-alist
1625 "Gnus variables saved in the quick startup file.")
1627 (defvar gnus-newsrc-options nil
1628 "Options line in the .newsrc file.")
1630 (defvar gnus-newsrc-options-n nil
1631 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1633 (defvar gnus-newsrc-last-checked-date nil
1634 "Date Gnus last asked server for new newsgroups.")
1636 (defvar gnus-topic-topology nil
1637 "The complete topic hierarchy.")
1639 (defvar gnus-topic-alist nil
1640 "The complete topic-group alist.")
1642 (defvar gnus-newsrc-alist nil
1643 "Assoc list of read articles.
1644 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1646 (defvar gnus-newsrc-hashtb nil
1647 "Hashtable of gnus-newsrc-alist.")
1649 (defvar gnus-killed-list nil
1650 "List of killed newsgroups.")
1652 (defvar gnus-killed-hashtb nil
1653 "Hash table equivalent of gnus-killed-list.")
1655 (defvar gnus-zombie-list nil
1656 "List of almost dead newsgroups.")
1658 (defvar gnus-description-hashtb nil
1659 "Descriptions of newsgroups.")
1661 (defvar gnus-list-of-killed-groups nil
1662 "List of newsgroups that have recently been killed by the user.")
1664 (defvar gnus-active-hashtb nil
1665 "Hashtable of active articles.")
1667 (defvar gnus-moderated-list nil
1668 "List of moderated newsgroups.")
1670 (defvar gnus-group-marked nil)
1672 (defvar gnus-current-startup-file nil
1673 "Startup file for the current host.")
1675 (defvar gnus-last-search-regexp nil
1676 "Default regexp for article search command.")
1678 (defvar gnus-last-shell-command nil
1679 "Default shell command on article.")
1681 (defvar gnus-current-select-method nil
1682 "The current method for selecting a newsgroup.")
1684 (defvar gnus-group-list-mode nil)
1686 (defvar gnus-article-internal-prepare-hook nil)
1688 (defvar gnus-newsgroup-name nil)
1689 (defvar gnus-newsgroup-begin nil)
1690 (defvar gnus-newsgroup-end nil)
1691 (defvar gnus-newsgroup-last-rmail nil)
1692 (defvar gnus-newsgroup-last-mail nil)
1693 (defvar gnus-newsgroup-last-folder nil)
1694 (defvar gnus-newsgroup-last-file nil)
1695 (defvar gnus-newsgroup-auto-expire nil)
1696 (defvar gnus-newsgroup-active nil)
1698 (defvar gnus-newsgroup-data nil)
1699 (defvar gnus-newsgroup-data-reverse nil)
1700 (defvar gnus-newsgroup-limit nil)
1701 (defvar gnus-newsgroup-limits nil)
1703 (defvar gnus-newsgroup-unreads nil
1704 "List of unread articles in the current newsgroup.")
1706 (defvar gnus-newsgroup-unselected nil
1707 "List of unselected unread articles in the current newsgroup.")
1709 (defvar gnus-newsgroup-reads nil
1710 "Alist of read articles and article marks in the current newsgroup.")
1712 (defvar gnus-newsgroup-expunged-tally nil)
1714 (defvar gnus-newsgroup-marked nil
1715 "List of ticked articles in the current newsgroup (a subset of unread art).")
1717 (defvar gnus-newsgroup-killed nil
1718 "List of ranges of articles that have been through the scoring process.")
1720 (defvar gnus-newsgroup-cached nil
1721 "List of articles that come from the article cache.")
1723 (defvar gnus-newsgroup-saved nil
1724 "List of articles that have been saved.")
1726 (defvar gnus-newsgroup-kill-headers nil)
1728 (defvar gnus-newsgroup-replied nil
1729 "List of articles that have been replied to in the current newsgroup.")
1731 (defvar gnus-newsgroup-expirable nil
1732 "List of articles in the current newsgroup that can be expired.")
1734 (defvar gnus-newsgroup-processable nil
1735 "List of articles in the current newsgroup that can be processed.")
1737 (defvar gnus-newsgroup-bookmarks nil
1738 "List of articles in the current newsgroup that have bookmarks.")
1740 (defvar gnus-newsgroup-dormant nil
1741 "List of dormant articles in the current newsgroup.")
1743 (defvar gnus-newsgroup-scored nil
1744 "List of scored articles in the current newsgroup.")
1746 (defvar gnus-newsgroup-headers nil
1747 "List of article headers in the current newsgroup.")
1749 (defvar gnus-newsgroup-threads nil)
1751 (defvar gnus-newsgroup-prepared nil
1752 "Whether the current group has been prepared properly.")
1754 (defvar gnus-newsgroup-ancient nil
1755 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1757 (defvar gnus-current-article nil)
1758 (defvar gnus-article-current nil)
1759 (defvar gnus-current-headers nil)
1760 (defvar gnus-have-all-headers nil)
1761 (defvar gnus-last-article nil)
1762 (defvar gnus-newsgroup-history nil)
1763 (defvar gnus-current-kill-article nil)
1765 ;; Save window configuration.
1766 (defvar gnus-prev-winconf nil)
1768 (defvar gnus-summary-mark-positions nil)
1769 (defvar gnus-group-mark-positions nil)
1771 (defvar gnus-reffed-article-number nil)
1773 ;;; Let the byte-compiler know that we know about this variable.
1774 (defvar rmail-default-rmail-file)
1776 (defvar gnus-cache-removeable-articles nil)
1778 (defvar gnus-dead-summary nil)
1780 (defconst gnus-summary-local-variables
1781 '(gnus-newsgroup-name
1782 gnus-newsgroup-begin gnus-newsgroup-end
1783 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1784 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1785 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1786 gnus-newsgroup-unselected gnus-newsgroup-marked
1787 gnus-newsgroup-reads gnus-newsgroup-saved
1788 gnus-newsgroup-replied gnus-newsgroup-expirable
1789 gnus-newsgroup-processable gnus-newsgroup-killed
1790 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1791 gnus-newsgroup-headers gnus-newsgroup-threads
1792 gnus-newsgroup-prepared
1793 gnus-current-article gnus-current-headers gnus-have-all-headers
1794 gnus-last-article gnus-article-internal-prepare-hook
1795 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1796 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1797 gnus-newsgroup-async
1798 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1799 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1800 gnus-newsgroup-history gnus-newsgroup-ancient
1801 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1802 gnus-newsgroup-adaptive-score-file
1803 (gnus-newsgroup-expunged-tally . 0)
1804 gnus-cache-removeable-articles gnus-newsgroup-cached
1805 gnus-newsgroup-data gnus-newsgroup-data-reverse
1806 gnus-newsgroup-limit gnus-newsgroup-limits)
1807 "Variables that are buffer-local to the summary buffers.")
1809 (defconst gnus-bug-message
1810 "Sending a bug report to the Gnus Towers.
1811 ========================================
1813 The buffer below is a mail buffer. When you press `C-c C-c', it will
1814 be sent to the Gnus Bug Exterminators.
1816 At the bottom of the buffer you'll see lots of variable settings.
1817 Please do not delete those. They will tell the Bug People what your
1818 environment is, so that it will be easier to locate the bugs.
1820 If you have found a bug that makes Emacs go \"beep\", set
1821 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1822 and include the backtrace in your bug report.
1824 Please describe the bug in annoying, painstaking detail.
1826 Thank you for your help in stamping out bugs.
1829 ;;; End of variables.
1831 ;; Define some autoload functions Gnus might use.
1834 ;; This little mapcar goes through the list below and marks the
1835 ;; symbols in question as autoloaded functions.
1838 (let ((interactive (nth 1 (memq ':interactive package))))
1842 (when (consp function)
1843 (setq keymap (car (memq 'keymap function)))
1844 (setq function (car function)))
1845 (autoload function (car package) nil interactive keymap)))
1846 (if (eq (nth 1 package) ':interactive)
1849 '(("metamail" metamail-buffer)
1850 ("info" Info-goto-node)
1851 ("hexl" hexl-hex-string-to-integer)
1852 ("pp" pp pp-to-string pp-eval-expression)
1853 ("mail-extr" mail-extract-address-components)
1854 ("nnmail" nnmail-split-fancy nnmail-article-group)
1855 ("nnvirtual" nnvirtual-catchup-group)
1856 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
1857 timezone-make-sortable-date timezone-make-time-string)
1858 ("sendmail" mail-position-on-field mail-setup)
1859 ("rmailout" rmail-output)
1860 ("rnewspost" news-mail-other-window news-reply-yank-original
1861 news-caesar-buffer-body)
1862 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
1864 ("gnus-soup" :interactive t
1865 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
1866 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
1867 ("nnsoup" nnsoup-pack-replies)
1868 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
1869 gnus-Folder-save-name gnus-folder-save-name)
1870 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
1871 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
1872 gnus-server-make-menu-bar gnus-article-make-menu-bar
1873 gnus-browse-make-menu-bar gnus-highlight-selected-summary
1874 gnus-summary-highlight-line gnus-carpal-setup-buffer
1875 gnus-article-add-button gnus-insert-next-page-button
1876 gnus-insert-prev-page-button)
1877 ("gnus-vis" :interactive t
1878 gnus-article-push-button gnus-article-press-button
1879 gnus-article-highlight gnus-article-highlight-some
1880 gnus-article-highlight-headers gnus-article-highlight-signature
1881 gnus-article-add-buttons gnus-article-add-buttons-to-head
1882 gnus-article-next-button gnus-article-prev-button)
1883 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
1884 gnus-demon-add-disconnection gnus-demon-add-handler
1885 gnus-demon-remove-handler)
1886 ("gnus-demon" :interactive t
1887 gnus-demon-init gnus-demon-cancel)
1888 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close)
1889 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
1890 ("gnus-cite" :interactive t
1891 gnus-article-highlight-citation gnus-article-hide-citation-maybe
1892 gnus-article-hide-citation)
1893 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
1894 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
1895 gnus-execute gnus-expunge)
1896 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
1897 gnus-cache-possibly-remove-articles gnus-cache-request-article
1898 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
1899 gnus-cache-enter-remove-article gnus-cached-article-p
1900 gnus-cache-open gnus-cache-close)
1901 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
1902 gnus-cache-remove-article)
1903 ("gnus-score" :interactive t
1904 gnus-summary-increase-score gnus-summary-lower-score
1905 gnus-score-flush-cache gnus-score-close
1906 gnus-score-raise-same-subject-and-select
1907 gnus-score-raise-same-subject gnus-score-default
1908 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
1909 gnus-score-lower-same-subject gnus-score-lower-thread
1910 gnus-possibly-score-headers)
1912 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
1913 gnus-current-score-file-nondirectory gnus-score-adaptive
1914 gnus-score-find-trace gnus-score-file-name)
1915 ("gnus-edit" :interactive t gnus-score-customize)
1916 ("gnus-topic" :interactive t gnus-topic-mode)
1917 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
1918 ("gnus-uu" :interactive t
1919 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
1920 gnus-uu-mark-series gnus-uu-mark-region
1921 gnus-uu-mark-by-regexp gnus-uu-mark-all
1922 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
1923 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
1924 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
1925 gnus-uu-decode-binhex gnus-uu-decode-uu-view
1926 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
1927 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
1928 gnus-uu-decode-binhex-view)
1929 ("gnus-msg" (gnus-summary-send-map keymap)
1930 gnus-mail-yank-original gnus-mail-send-and-exit
1931 gnus-sendmail-setup-mail gnus-article-mail
1932 gnus-inews-message-id gnus-new-mail gnus-mail-reply)
1933 ("gnus-msg" :interactive t
1934 gnus-group-post-news gnus-group-mail gnus-summary-post-news
1935 gnus-summary-followup gnus-summary-followup-with-original
1936 gnus-summary-followup-and-reply
1937 gnus-summary-followup-and-reply-with-original
1938 gnus-summary-cancel-article gnus-summary-supersede-article
1939 gnus-post-news gnus-inews-news gnus-cancel-news
1940 gnus-summary-reply gnus-summary-reply-with-original
1941 gnus-summary-mail-forward gnus-summary-mail-other-window
1943 ("gnus-picon" gnus-article-display-picons)
1944 ("gnus-vm" gnus-vm-mail-setup)
1945 ("gnus-vm" :interactive t gnus-summary-save-in-vm
1946 gnus-summary-save-article-vm gnus-yank-article))))
1950 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1951 ;; If you want the cursor to go somewhere else, set these two
1952 ;; functions in some startup hook to whatever you want.
1953 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
1954 (defalias 'gnus-group-position-point 'gnus-goto-colon)
1956 ;;; Various macros and substs.
1958 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
1959 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
1960 `(let ((GnusStartBufferWindow (selected-window)))
1963 (pop-to-buffer ,buffer)
1965 (select-window GnusStartBufferWindow))))
1967 (defmacro gnus-gethash (string hashtable)
1968 "Get hash value of STRING in HASHTABLE."
1969 `(symbol-value (intern-soft ,string ,hashtable)))
1971 (defmacro gnus-sethash (string value hashtable)
1972 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1973 `(set (intern ,string ,hashtable) ,value))
1975 (defmacro gnus-intern-safe (string hashtable)
1976 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
1977 `(let ((symbol (intern ,string ,hashtable)))
1982 (defmacro gnus-group-unread (group)
1983 "Get the currently computed number of unread articles in GROUP."
1984 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
1986 (defmacro gnus-active (group)
1987 "Get active info on GROUP."
1988 `(gnus-gethash ,group gnus-active-hashtb))
1990 (defmacro gnus-set-active (group active)
1991 "Set GROUP's active info."
1992 `(gnus-sethash ,group ,active gnus-active-hashtb))
1994 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
1995 ;; function `substring' might cut on a middle of multi-octet
1997 (defun gnus-truncate-string (str width)
1998 (substring str 0 width))
2000 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2001 ;; to limit the length of a string. This function is necessary since
2002 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2003 (defsubst gnus-limit-string (str width)
2004 (if (> (length str) width)
2005 (substring str 0 width)
2008 (defsubst gnus-simplify-subject-re (subject)
2009 "Remove \"Re:\" from subject lines."
2010 (if (string-match "^[Rr][Ee]: *" subject)
2011 (substring subject (match-end 0))
2014 (defsubst gnus-goto-char (point)
2015 (and point (goto-char point)))
2017 (defmacro gnus-buffer-exists-p (buffer)
2019 (funcall (if (stringp ,buffer) 'get-buffer 'buffer-name)
2022 (defmacro gnus-kill-buffer (buffer)
2023 `(let ((buf ,buffer))
2024 (if (gnus-buffer-exists-p buf)
2025 (kill-buffer buf))))
2027 (defsubst gnus-point-at-bol ()
2028 "Return point at the beginning of the line."
2035 (defsubst gnus-point-at-eol ()
2036 "Return point at the end of the line."
2043 ;; Delete the current line (and the next N lines.);
2044 (defmacro gnus-delete-line (&optional n)
2045 `(delete-region (progn (beginning-of-line) (point))
2046 (progn (forward-line ,(or n 1)) (point))))
2048 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2049 (defvar gnus-init-inhibit nil)
2050 (defun gnus-read-init-file (&optional inhibit-next)
2051 (if gnus-init-inhibit
2052 (setq gnus-init-inhibit nil)
2053 (setq gnus-init-inhibit inhibit-next)
2055 (or (and (file-exists-p gnus-init-file)
2056 ;; Don't try to load a directory.
2057 (not (file-directory-p gnus-init-file)))
2058 (file-exists-p (concat gnus-init-file ".el"))
2059 (file-exists-p (concat gnus-init-file ".elc")))
2060 (load gnus-init-file nil t))))
2062 ;; Info access macros.
2064 (defmacro gnus-info-group (info)
2066 (defmacro gnus-info-rank (info)
2068 (defmacro gnus-info-read (info)
2070 (defmacro gnus-info-marks (info)
2072 (defmacro gnus-info-method (info)
2074 (defmacro gnus-info-params (info)
2077 (defmacro gnus-info-level (info)
2078 `(let ((rank (gnus-info-rank ,info)))
2082 (defmacro gnus-info-score (info)
2083 `(let ((rank (gnus-info-rank ,info)))
2084 (or (and (consp rank) (cdr rank)) 0)))
2086 (defmacro gnus-info-set-group (info group)
2087 `(setcar ,info ,group))
2088 (defmacro gnus-info-set-rank (info rank)
2089 `(setcar (nthcdr 1 ,info) ,rank))
2090 (defmacro gnus-info-set-read (info read)
2091 `(setcar (nthcdr 2 ,info) ,read))
2092 (defmacro gnus-info-set-marks (info marks)
2093 `(setcar (nthcdr 3 ,info) ,marks))
2094 (defmacro gnus-info-set-method (info method)
2095 `(setcar (nthcdr 4 ,info) ,method))
2096 (defmacro gnus-info-set-params (info params)
2097 `(setcar (nthcdr 5 ,info) ,params))
2099 (defmacro gnus-info-set-level (info level)
2100 `(let ((rank (cdr ,info)))
2101 (if (consp (car rank))
2102 (setcar (car rank) ,level)
2103 (setcar rank ,level))))
2104 (defmacro gnus-info-set-score (info score)
2105 `(let ((rank (cdr ,info)))
2106 (if (consp (car rank))
2107 (setcdr (car rank) ,score)
2108 (setcar rank (cons (car rank) ,score)))))
2110 (defmacro gnus-get-info (group)
2111 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2113 (defun gnus-byte-code (func)
2114 "Return a form that can be `eval'ed based on FUNC."
2115 (let ((fval (symbol-function func)))
2116 (if (byte-code-function-p fval)
2117 (let ((flist (append fval nil)))
2118 (setcar flist 'byte-code)
2120 (cons 'progn (cdr (cdr fval))))))
2122 ;;; Load the user startup file.
2123 ;; (eval '(gnus-read-init-file 'inhibit))
2125 ;;; Load the compatability functions.
2132 ;; Format specs. The chunks below are the machine-generated forms
2133 ;; that are to be evaled as the result of the default format strings.
2134 ;; We write them in here to get them byte-compiled. That way the
2135 ;; default actions will be quite fast, while still retaining the full
2136 ;; flexibility of the user-defined format specs.
2138 ;; First we have lots of dummy defvars to let the compiler know these
2139 ;; are really dynamic variables.
2141 (defvar gnus-tmp-unread)
2142 (defvar gnus-tmp-replied)
2143 (defvar gnus-tmp-score-char)
2144 (defvar gnus-tmp-indentation)
2145 (defvar gnus-tmp-opening-bracket)
2146 (defvar gnus-tmp-lines)
2147 (defvar gnus-tmp-name)
2148 (defvar gnus-tmp-closing-bracket)
2149 (defvar gnus-tmp-subject-or-nil)
2150 (defvar gnus-tmp-subject)
2151 (defvar gnus-tmp-marked)
2152 (defvar gnus-tmp-marked-mark)
2153 (defvar gnus-tmp-subscribed)
2154 (defvar gnus-tmp-process-marked)
2155 (defvar gnus-tmp-number-of-unread)
2156 (defvar gnus-tmp-group-name)
2157 (defvar gnus-tmp-group)
2158 (defvar gnus-tmp-article-number)
2159 (defvar gnus-tmp-unread-and-unselected)
2160 (defvar gnus-tmp-news-method)
2161 (defvar gnus-tmp-news-server)
2162 (defvar gnus-tmp-article-number)
2163 (defvar gnus-mouse-face)
2164 (defvar gnus-mouse-face-prop)
2166 (defun gnus-summary-line-format-spec ()
2167 (insert gnus-tmp-unread gnus-tmp-replied
2168 gnus-tmp-score-char gnus-tmp-indentation)
2173 gnus-tmp-opening-bracket
2174 (format "%4d: %-20s"
2176 (if (> (length gnus-tmp-name) 20)
2177 (substring gnus-tmp-name 0 20)
2179 gnus-tmp-closing-bracket)
2181 gnus-mouse-face-prop gnus-mouse-face)
2182 (insert " " gnus-tmp-subject-or-nil "\n"))
2184 (defvar gnus-summary-line-format-spec
2185 (gnus-byte-code 'gnus-summary-line-format-spec))
2187 (defun gnus-summary-dummy-line-format-spec ()
2194 gnus-mouse-face-prop gnus-mouse-face)
2195 (insert " " gnus-tmp-subject "\n"))
2197 (defvar gnus-summary-dummy-line-format-spec
2198 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2200 (defun gnus-group-line-format-spec ()
2201 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2202 gnus-tmp-process-marked
2203 gnus-topic-indentation
2204 (format "%5s: " gnus-tmp-number-of-unread))
2208 (insert gnus-tmp-group "\n")
2210 gnus-mouse-face-prop gnus-mouse-face))
2211 (defvar gnus-group-line-format-spec
2212 (gnus-byte-code 'gnus-group-line-format-spec))
2214 (defvar gnus-format-specs
2215 `((version . ,emacs-version)
2216 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2217 (summary-dummy ,gnus-summary-dummy-line-format
2218 ,gnus-summary-dummy-line-format-spec)
2219 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2221 (defvar gnus-article-mode-line-format-spec nil)
2222 (defvar gnus-summary-mode-line-format-spec nil)
2223 (defvar gnus-group-mode-line-format-spec nil)
2225 ;;; Phew. All that gruft is over, fortunately.
2229 ;;; Gnus Utility Functions
2232 (defun gnus-extract-address-components (from)
2234 ;; First find the address - the thing with the @ in it. This may
2235 ;; not be accurate in mail addresses, but does the trick most of
2236 ;; the time in news messages.
2237 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2238 (setq address (substring from (match-beginning 0) (match-end 0))))
2239 ;; Then we check whether the "name <address>" format is used.
2241 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2242 ;; Linear white space is not required.
2243 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2244 (and (setq name (substring from 0 (match-beginning 0)))
2245 ;; Strip any quotes from the name.
2246 (string-match "\".*\"" name)
2247 (setq name (substring name 1 (1- (match-end 0))))))
2248 ;; If not, then "address (name)" is used.
2250 (and (string-match "(.+)" from)
2251 (setq name (substring from (1+ (match-beginning 0))
2252 (1- (match-end 0)))))
2253 (and (string-match "()" from)
2254 (setq name address))
2255 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2256 ;; XOVER might not support folded From headers.
2257 (and (string-match "(.*" from)
2258 (setq name (substring from (1+ (match-beginning 0))
2260 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2261 (list (or name from) (or address from))))
2263 (defun gnus-fetch-field (field)
2264 "Return the value of the header FIELD of current article."
2267 (let ((case-fold-search t))
2268 (gnus-narrow-to-headers)
2269 (mail-fetch-field field)))))
2271 (defun gnus-goto-colon ()
2273 (search-forward ":" (gnus-point-at-eol) t))
2275 (defun gnus-narrow-to-headers ()
2276 "Narrow to the head of an article."
2279 (goto-char (point-min))
2280 (if (search-forward "\n\n" nil t)
2283 (goto-char (point-min)))
2286 (defun gnus-update-format (var)
2287 "Update the format specification near point."
2292 ;; Find the end of the current word.
2293 (re-search-forward "[ \t\n]" nil t)
2295 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2296 (match-string 1)))))
2297 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2298 (match-string 1 var))))
2299 (entry (assq type gnus-format-specs))
2302 (setq gnus-format-specs (delq entry gnus-format-specs)))
2304 (intern (format "%s-spec" var))
2305 (gnus-parse-format (setq value (symbol-value (intern var)))
2306 (symbol-value (intern (format "%s-alist" var)))
2307 (not (string-match "mode" var))))
2308 (setq spec (symbol-value (intern (format "%s-spec" var))))
2309 (push (list type value spec) gnus-format-specs)
2311 (pop-to-buffer "*Gnus Format*")
2313 (lisp-interaction-mode)
2314 (insert (pp-to-string spec))))
2317 (defun gnus-update-format-specifications (&optional force)
2318 "Update all (necessary) format specifications."
2319 ;; Make the indentation array.
2320 (gnus-make-thread-indent-array)
2323 (and (assq 'version gnus-format-specs)
2324 (not (equal emacs-version
2325 (cdr (assq 'version gnus-format-specs))))))
2326 (setq gnus-format-specs nil))
2328 (let ((types '(summary summary-dummy group
2329 summary-mode group-mode article-mode))
2330 old-format new-format entry type val)
2332 (setq type (pop types))
2333 (setq new-format (symbol-value
2334 (intern (format "gnus-%s-line-format" type))))
2335 (setq entry (cdr (assq type gnus-format-specs)))
2337 (equal (car entry) new-format))
2338 (set (intern (format "gnus-%s-line-format-spec" type))
2341 (if (not (stringp new-format))
2342 ;; This is a function call or something.
2344 ;; This is a "real" format.
2348 (intern (format "gnus-%s-line-format-alist"
2349 (if (eq type 'article-mode)
2350 'summary-mode type))))
2351 (not (string-match "mode$" (symbol-name type))))))
2352 (set (intern (format "gnus-%s-line-format-spec" type)) val)
2354 (setcar (cdr entry) val)
2355 (push (list type new-format val) gnus-format-specs)))))
2357 (gnus-update-group-mark-positions)
2358 (gnus-update-summary-mark-positions)
2360 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
2361 (not gnus-description-hashtb)
2362 gnus-read-active-file)
2363 (gnus-read-all-descriptions-files)))
2365 (defun gnus-update-summary-mark-positions ()
2367 (let ((gnus-replied-mark 129)
2368 (gnus-score-below-mark 130)
2369 (gnus-score-over-mark 130)
2373 (gnus-set-work-buffer)
2374 (gnus-summary-insert-line
2375 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2376 (goto-char (point-min))
2377 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2379 (goto-char (point-min))
2380 (setq pos (cons (cons 'replied (and (search-forward "\201" nil t)
2381 (- (point) 2))) pos))
2382 (goto-char (point-min))
2383 (setq pos (cons (cons 'score (and (search-forward "\202" nil t)
2384 (- (point) 2))) pos))
2385 (setq gnus-summary-mark-positions pos))))
2387 (defun gnus-update-group-mark-positions ()
2389 (let ((gnus-process-mark 128)
2390 (gnus-group-marked '("dummy.group")))
2391 (gnus-set-active "dummy.group" '(0 . 0))
2392 (gnus-set-work-buffer)
2393 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2394 (goto-char (point-min))
2395 (setq gnus-group-mark-positions
2396 (list (cons 'process (and (search-forward "\200" nil t)
2397 (- (point) 2))))))))
2399 (defvar gnus-mouse-face-0 'highlight)
2400 (defvar gnus-mouse-face-1 'highlight)
2401 (defvar gnus-mouse-face-2 'highlight)
2402 (defvar gnus-mouse-face-3 'highlight)
2403 (defvar gnus-mouse-face-4 'highlight)
2405 (defun gnus-mouse-face-function (form type)
2407 (point) (progn ,@form (point))
2408 gnus-mouse-face-prop
2411 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2413 (defvar gnus-face-0 'bold)
2414 (defvar gnus-face-1 'italic)
2415 (defvar gnus-face-2 'bold-italic)
2416 (defvar gnus-face-3 'bold)
2417 (defvar gnus-face-4 'bold)
2419 (defun gnus-face-face-function (form type)
2421 (point) (progn ,@form (point))
2422 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2424 (defun gnus-max-width-function (el max-width)
2425 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2427 `(if (> (length ,el) ,max-width)
2428 (substring ,el 0 ,max-width)
2430 `(let ((val (eval ,el)))
2432 (setq val (int-to-string val)))
2433 (if (> (length val) ,max-width)
2434 (substring val 0 ,max-width)
2437 (defun gnus-parse-format (format spec-alist &optional insert)
2438 ;; This function parses the FORMAT string with the help of the
2439 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2440 ;; string. If the FORMAT string contains the specifiers %( and %)
2441 ;; the text between them will have the mouse-face text property.
2443 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2445 (gnus-parse-complex-format format spec-alist)
2446 ;; This is a simple format.
2447 (gnus-parse-simple-format format spec-alist insert)))
2449 (defun gnus-parse-complex-format (format spec-alist)
2451 (gnus-set-work-buffer)
2453 (goto-char (point-min))
2454 (while (re-search-forward "\"" nil t)
2455 (replace-match "\\\"" nil t))
2456 (goto-char (point-min))
2458 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2459 (let ((number (if (match-beginning 1)
2460 (match-string 1) "0"))
2461 (delim (aref (match-string 2) 0)))
2462 (if (or (= delim ?\() (= delim ?\{))
2463 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2465 (replace-match "\")\""))))
2466 (goto-char (point-max))
2468 (goto-char (point-min))
2469 (let ((form (read (current-buffer))))
2470 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2472 (defun gnus-complex-form-to-spec (form spec-alist)
2477 (gnus-parse-simple-format sform spec-alist t)
2478 (funcall (intern (format "gnus-%s-face-function"
2480 (gnus-complex-form-to-spec
2481 (cdr (cdr sform)) spec-alist)
2485 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2486 ;; This function parses the FORMAT string with the help of the
2487 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2490 spec flist fstring newspec elem beg result dontinsert)
2492 (gnus-set-work-buffer)
2494 (goto-char (point-min))
2495 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2497 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2499 beg (1+ (match-beginning 0)))
2500 ;; First check if there are any specs that look anything like
2501 ;; "%12,12A", ie. with a "max width specification". These have
2502 ;; to be treated specially.
2503 (if (setq beg (match-beginning 1))
2507 (1+ (match-beginning 1)) (match-end 1))))
2509 (setq beg (match-beginning 2)))
2510 ;; Find the specification from `spec-alist'.
2511 (unless (setq elem (cdr (assq spec spec-alist)))
2512 (setq elem '("*" ?s)))
2513 ;; Treat user defined format specifiers specially.
2514 (when (eq (car elem) 'gnus-tmp-user-defined)
2517 (list (intern (concat "gnus-user-format-function-"
2519 'gnus-tmp-header) ?s))
2520 (delete-region (match-beginning 3) (match-end 3)))
2521 (if (not (zerop max-width))
2522 (let ((el (car elem)))
2523 (cond ((= (car (cdr elem)) ?c)
2524 (setq el (list 'char-to-string el)))
2525 ((= (car (cdr elem)) ?d)
2526 (numberp el) (setq el (list 'int-to-string el))))
2527 (setq flist (cons (gnus-max-width-function el max-width)
2531 (setq flist (cons (car elem) flist))
2532 (setq newspec (car (cdr elem))))))
2533 ;; Remove the old specification (and possibly a ",12" string).
2534 (delete-region beg (match-end 2))
2535 ;; Insert the new specification.
2538 (setq fstring (buffer-substring 1 (point-max))))
2539 ;; Do some postprocessing to increase efficiency.
2544 ((string= fstring "")
2546 ;; Not a format string.
2547 ((not (string-match "%" fstring))
2549 ;; A format string with just a single string spec.
2550 ((string= fstring "%s")
2552 ;; A single character.
2553 ((string= fstring "%c")
2556 ((string= fstring "%d")
2559 (list `(princ ,(car flist)))
2560 (list `(int-to-string ,(car flist)))))
2561 ;; Just lots of chars and strings.
2562 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2564 ;; A single string spec at the beginning of the spec.
2565 ((string-match "\\`%[sc][^%]+\\'" fstring)
2566 (list (car flist) (substring fstring 2)))
2567 ;; A single string spec in the middle of the spec.
2568 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2569 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2570 ;; A single string spec in the end of the spec.
2571 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2572 (list (match-string 1 fstring) (car flist)))
2573 ;; A more complex spec.
2575 (list (cons 'format (cons fstring (nreverse flist)))))))
2581 (cons 'insert result)))
2582 (cond ((stringp result)
2585 (cons 'concat result))
2588 (defun gnus-eval-format (format &optional alist props)
2589 "Eval the format variable FORMAT, using ALIST.
2590 If PROPS, insert the result."
2591 (let ((form (gnus-parse-format format alist props)))
2593 (add-text-properties (point) (progn (eval form) (point)) props)
2596 (defun gnus-remove-text-with-property (prop)
2597 "Delete all text in the current buffer with text property PROP."
2599 (goto-char (point-min))
2601 (while (get-text-property (point) prop)
2603 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2605 (defun gnus-set-work-buffer ()
2606 (if (get-buffer gnus-work-buffer)
2608 (set-buffer gnus-work-buffer)
2610 (set-buffer (get-buffer-create gnus-work-buffer))
2611 (kill-all-local-variables)
2612 (buffer-disable-undo (current-buffer))
2613 (gnus-add-current-to-buffer-list)))
2615 ;; Article file names when saving.
2617 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2618 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2619 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2620 Otherwise, it is like ~/News/news/group/num."
2623 (concat (if (gnus-use-long-file-name 'not-save)
2624 (gnus-capitalize-newsgroup newsgroup)
2625 (gnus-newsgroup-directory-form newsgroup))
2626 "/" (int-to-string (mail-header-number headers)))
2627 (or gnus-article-save-directory "~/News"))))
2629 (string-equal (file-name-directory default)
2630 (file-name-directory last-file))
2631 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2633 (or last-file default))))
2635 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2636 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2637 If variable `gnus-use-long-file-name' is non-nil, it is
2638 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2641 (concat (if (gnus-use-long-file-name 'not-save)
2643 (gnus-newsgroup-directory-form newsgroup))
2644 "/" (int-to-string (mail-header-number headers)))
2645 (or gnus-article-save-directory "~/News"))))
2647 (string-equal (file-name-directory default)
2648 (file-name-directory last-file))
2649 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2651 (or last-file default))))
2653 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2654 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2655 If variable `gnus-use-long-file-name' is non-nil, it is
2656 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2659 (if (gnus-use-long-file-name 'not-save)
2660 (gnus-capitalize-newsgroup newsgroup)
2661 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2662 (or gnus-article-save-directory "~/News"))))
2664 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2665 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2666 If variable `gnus-use-long-file-name' is non-nil, it is
2667 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2670 (if (gnus-use-long-file-name 'not-save)
2672 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2673 (or gnus-article-save-directory "~/News"))))
2675 ;; For subscribing new newsgroup
2677 (defun gnus-subscribe-hierarchical-interactive (groups)
2678 (let ((groups (sort groups 'string<))
2679 prefixes prefix start ans group starts)
2681 (setq prefixes (list "^"))
2682 (while (and groups prefixes)
2683 (while (not (string-match (car prefixes) (car groups)))
2684 (setq prefixes (cdr prefixes)))
2685 (setq prefix (car prefixes))
2686 (setq start (1- (length prefix)))
2687 (if (and (string-match "[^\\.]\\." (car groups) start)
2690 (concat "^" (substring (car groups) 0 (match-end 0))))
2691 (string-match prefix (car (cdr groups))))
2693 (setq prefixes (cons prefix prefixes))
2694 (message "Descend hierarchy %s? ([y]nsq): "
2695 (substring prefix 1 (1- (length prefix))))
2696 (setq ans (read-char))
2699 (string-match prefix
2700 (setq group (car groups))))
2701 (setq gnus-killed-list
2702 (cons group gnus-killed-list))
2703 (gnus-sethash group group gnus-killed-hashtb)
2704 (setq groups (cdr groups)))
2705 (setq starts (cdr starts)))
2708 (string-match prefix
2709 (setq group (car groups))))
2710 (gnus-sethash group group gnus-killed-hashtb)
2711 (gnus-subscribe-alphabetically (car groups))
2712 (setq groups (cdr groups)))
2713 (setq starts (cdr starts)))
2716 (setq group (car groups))
2717 (setq gnus-killed-list (cons group gnus-killed-list))
2718 (gnus-sethash group group gnus-killed-hashtb)
2719 (setq groups (cdr groups))))
2721 (message "Subscribe %s? ([n]yq)" (car groups))
2722 (setq ans (read-char))
2723 (setq group (car groups))
2725 (gnus-subscribe-alphabetically (car groups))
2726 (gnus-sethash group group gnus-killed-hashtb))
2729 (setq group (car groups))
2730 (setq gnus-killed-list (cons group gnus-killed-list))
2731 (gnus-sethash group group gnus-killed-hashtb)
2732 (setq groups (cdr groups))))
2734 (setq gnus-killed-list (cons group gnus-killed-list))
2735 (gnus-sethash group group gnus-killed-hashtb)))
2736 (setq groups (cdr groups)))))))
2738 (defun gnus-subscribe-randomly (newsgroup)
2739 "Subscribe new NEWSGROUP by making it the first newsgroup."
2740 (gnus-subscribe-newsgroup newsgroup))
2742 (defun gnus-subscribe-alphabetically (newgroup)
2743 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2744 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2745 (let ((groups (cdr gnus-newsrc-alist))
2747 (while (and (not before) groups)
2748 (if (string< newgroup (car (car groups)))
2749 (setq before (car (car groups)))
2750 (setq groups (cdr groups))))
2751 (gnus-subscribe-newsgroup newgroup before)))
2753 (defun gnus-subscribe-hierarchically (newgroup)
2754 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2755 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2757 (set-buffer (find-file-noselect gnus-current-startup-file))
2758 (let ((groupkey newgroup)
2760 (while (and (not before) groupkey)
2761 (goto-char (point-min))
2763 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2764 (while (and (re-search-forward groupkey-re nil t)
2766 (setq before (match-string 1))
2767 (string< before newgroup)))))
2768 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2770 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2771 (substring groupkey (match-beginning 1) (match-end 1)))))
2772 (gnus-subscribe-newsgroup newgroup before))))
2774 (defun gnus-subscribe-interactively (group)
2775 "Subscribe the new GROUP interactively.
2776 It is inserted in hierarchical newsgroup order if subscribed. If not,
2778 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
2779 (gnus-subscribe-hierarchically group)
2780 (push group gnus-killed-list)))
2782 (defun gnus-subscribe-zombies (group)
2783 "Make the new GROUP into a zombie group."
2784 (push group gnus-zombie-list))
2786 (defun gnus-subscribe-killed (group)
2787 "Make the new GROUP a killed group."
2788 (push group gnus-killed-list))
2790 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2791 "Subscribe new NEWSGROUP.
2792 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2793 the first newsgroup."
2794 ;; We subscribe the group by changing its level to `subscribed'.
2795 (gnus-group-change-level
2796 newsgroup gnus-level-default-subscribed
2797 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2798 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2802 (defun gnus-newsgroup-directory-form (newsgroup)
2803 "Make hierarchical directory name from NEWSGROUP name."
2804 (let ((newsgroup (gnus-newsgroup-saveable-name newsgroup))
2805 (len (length newsgroup))
2807 ;; If this is a foreign group, we don't want to translate the
2809 (if (setq idx (string-match ":" newsgroup))
2810 (aset newsgroup idx ?/)
2812 ;; Replace all occurrences of `.' with `/'.
2814 (if (= (aref newsgroup idx) ?.)
2815 (aset newsgroup idx ?/))
2816 (setq idx (1+ idx)))
2819 (defun gnus-newsgroup-saveable-name (group)
2820 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2822 (gnus-replace-chars-in-string group ?/ ?.))
2824 (defun gnus-make-directory (dir)
2825 "Make DIRECTORY recursively."
2826 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2827 ;; of the many mysteries of the universe.
2828 (let* ((dir (expand-file-name dir default-directory))
2830 (if (string-match "/$" dir)
2831 (setq dir (substring dir 0 (match-beginning 0))))
2832 ;; First go down the path until we find a directory that exists.
2833 (while (not (file-exists-p dir))
2834 (setq dirs (cons dir dirs))
2835 (string-match "/[^/]+$" dir)
2836 (setq dir (substring dir 0 (match-beginning 0))))
2837 ;; Then create all the subdirs.
2838 (while (and dirs (not err))
2840 (make-directory (car dirs))
2841 (error (setq err t)))
2842 (setq dirs (cdr dirs)))
2843 ;; We return whether we were successful or not.
2846 (defun gnus-capitalize-newsgroup (newsgroup)
2847 "Capitalize NEWSGROUP name."
2848 (and (not (zerop (length newsgroup)))
2849 (concat (char-to-string (upcase (aref newsgroup 0)))
2850 (substring newsgroup 1))))
2854 (defun gnus-simplify-subject (subject &optional re-only)
2855 "Remove `Re:' and words in parentheses.
2856 If optional argument RE-ONLY is non-nil, strip `Re:' only."
2857 (let ((case-fold-search t)) ;Ignore case.
2858 ;; Remove `Re:' and `Re^N:'.
2859 (if (string-match "^re:[ \t]*" subject)
2860 (setq subject (substring subject (match-end 0))))
2861 ;; Remove words in parentheses from end.
2863 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
2864 (setq subject (substring subject 0 (match-beginning 0)))))
2865 ;; Return subject string.
2868 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
2870 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
2871 (defun gnus-simplify-buffer-fuzzy ()
2872 (goto-char (point-min))
2874 (looking-at "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*")
2875 (looking-at "^[[].*:[ \t].*[]]$"))
2876 (goto-char (point-min))
2877 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
2879 (replace-match "" t t))
2880 (goto-char (point-min))
2881 (while (re-search-forward "^[[].*:[ \t].*[]]$" nil t)
2882 (goto-char (match-end 0))
2885 (progn (goto-char (match-beginning 0)))
2886 (re-search-forward ":"))))
2887 (goto-char (point-min))
2888 (while (re-search-forward "[ \t\n]*([^()]*)[ \t]*$" nil t)
2889 (replace-match "" t t))
2890 (goto-char (point-min))
2891 (while (re-search-forward "[ \t]+" nil t)
2892 (replace-match " " t t))
2893 (goto-char (point-min))
2894 (while (re-search-forward "[ \t]+$" nil t)
2895 (replace-match "" t t))
2896 (goto-char (point-min))
2897 (while (re-search-forward "^[ \t]+" nil t)
2898 (replace-match "" t t))
2899 (goto-char (point-min))
2900 (if gnus-simplify-subject-fuzzy-regexp
2901 (if (listp gnus-simplify-subject-fuzzy-regexp)
2902 (let ((list gnus-simplify-subject-fuzzy-regexp))
2904 (goto-char (point-min))
2905 (while (re-search-forward (car list) nil t)
2906 (replace-match "" t t))
2907 (setq list (cdr list))))
2908 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
2909 (replace-match "" t t)))))
2911 (defun gnus-simplify-subject-fuzzy (subject)
2912 "Siplify a subject string fuzzily."
2913 (let ((case-fold-search t))
2915 (gnus-set-work-buffer)
2917 (inline (gnus-simplify-buffer-fuzzy))
2920 ;; Add the current buffer to the list of buffers to be killed on exit.
2921 (defun gnus-add-current-to-buffer-list ()
2922 (or (memq (current-buffer) gnus-buffer-list)
2923 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
2925 (defun gnus-string> (s1 s2)
2926 (not (or (string< s1 s2)
2929 ;; Functions accessing headers.
2930 ;; Functions are more convenient than macros in some cases.
2932 (defun gnus-header-number (header)
2933 (mail-header-number header))
2935 (defun gnus-header-subject (header)
2936 (mail-header-subject header))
2938 (defun gnus-header-from (header)
2939 (mail-header-from header))
2941 (defun gnus-header-xref (header)
2942 (mail-header-xref header))
2944 (defun gnus-header-lines (header)
2945 (mail-header-lines header))
2947 (defun gnus-header-date (header)
2948 (mail-header-date header))
2950 (defun gnus-header-id (header)
2951 (mail-header-id header))
2953 (defun gnus-header-message-id (header)
2954 (mail-header-id header))
2956 (defun gnus-header-chars (header)
2957 (mail-header-chars header))
2959 (defun gnus-header-references (header)
2960 (mail-header-references header))
2962 ;;; General various misc type functions.
2964 (defun gnus-clear-system ()
2965 "Clear all variables and buffers."
2966 ;; Clear Gnus variables.
2967 (let ((variables gnus-variable-list))
2969 (set (car variables) nil)
2970 (setq variables (cdr variables))))
2971 ;; Clear other internal variables.
2972 (setq gnus-list-of-killed-groups nil
2973 gnus-have-read-active-file nil
2974 gnus-newsrc-alist nil
2975 gnus-newsrc-hashtb nil
2976 gnus-killed-list nil
2977 gnus-zombie-list nil
2978 gnus-killed-hashtb nil
2979 gnus-active-hashtb nil
2980 gnus-moderated-list nil
2981 gnus-description-hashtb nil
2982 gnus-newsgroup-headers nil
2983 gnus-newsgroup-name nil
2984 gnus-server-alist nil
2985 gnus-opened-servers nil
2986 gnus-current-select-method nil)
2987 ;; Reset any score variables.
2988 (and gnus-use-scoring (gnus-score-close))
2989 ;; Kill the startup file.
2990 (and gnus-current-startup-file
2991 (get-file-buffer gnus-current-startup-file)
2992 (kill-buffer (get-file-buffer gnus-current-startup-file)))
2993 ;; Save any cache buffers.
2994 (and gnus-use-cache (gnus-cache-save-buffers))
2995 ;; Clear the dribble buffer.
2996 (gnus-dribble-clear)
2997 ;; Close down NoCeM.
2998 (and gnus-use-nocem (gnus-nocem-close))
2999 ;; Shut down the demons.
3000 (and gnus-use-demon (gnus-demon-cancel))
3001 ;; Kill global KILL file buffer.
3002 (if (get-file-buffer (gnus-newsgroup-kill-file nil))
3003 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3004 (gnus-kill-buffer nntp-server-buffer)
3006 (and gnus-keep-backlog (gnus-backlog-shutdown))
3007 ;; Kill Gnus buffers.
3008 (while gnus-buffer-list
3009 (gnus-kill-buffer (car gnus-buffer-list))
3010 (setq gnus-buffer-list (cdr gnus-buffer-list))))
3012 (defun gnus-windows-old-to-new (setting)
3013 ;; First we take care of the really, really old Gnus 3 actions.
3014 (if (symbolp setting)
3016 (cond ((memq setting '(SelectArticle))
3018 ((memq setting '(SelectSubject ExpandSubject))
3020 ((memq setting '(SelectNewsgroup ExitNewsgroup))
3023 (if (or (listp setting)
3024 (not (and gnus-window-configuration
3025 (memq setting '(group summary article)))))
3027 (let* ((setting (if (eq setting 'group)
3028 (if (assq 'newsgroup gnus-window-configuration)
3030 'newsgroups) setting))
3031 (elem (car (cdr (assq setting gnus-window-configuration))))
3032 (total (apply '+ elem))
3033 (types '(group summary article))
3034 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3039 (or (not (numberp (nth i elem)))
3040 (zerop (nth i elem))
3042 (setq perc (/ (* 1.0 (nth 0 elem)) total))
3043 (setq out (cons (if (eq pbuf (nth i types))
3044 (vector (nth i types) perc 'point)
3045 (vector (nth i types) perc))
3048 (list (nreverse out)))))
3050 (defun gnus-add-configuration (conf)
3051 (setq gnus-buffer-configuration
3052 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3053 gnus-buffer-configuration))))
3055 (defun gnus-configure-frame (split &optional window)
3056 "Split WINDOW according to SPLIT."
3058 (setq window (get-buffer-window (current-buffer))))
3059 (select-window window)
3060 ;; This might be an old-stylee buffer config.
3061 (when (vectorp split)
3062 (setq split (append split nil)))
3063 (when (or (consp (car split))
3064 (vectorp (car split)))
3066 (push 'vertical split))
3067 ;; The SPLIT might be something that is to be evaled to
3068 ;; return a new SPLIT.
3069 (while (and (not (assq (car split) gnus-window-to-buffer))
3070 (gnus-functionp (car split)))
3071 (setq split (eval split)))
3072 (let* ((type (car split))
3073 (subs (cdr (cdr split)))
3074 (len (if (eq type 'horizontal) (window-width) (window-height) ))
3076 s result new-win rest comp-subs size sub)
3078 ;; Nothing to do here.
3080 ;; This is a buffer to be selected.
3081 ((not (or (eq type 'horizontal) (eq type 'vertical)))
3082 (let ((buffer (cond ((stringp type) type)
3083 (t (cdr (assq type gnus-window-to-buffer)))))
3086 (error "Illegal buffer type: %s" type))
3087 (unless (setq buf (get-buffer (if (symbolp buffer)
3088 (symbol-value buffer) buffer)))
3089 (setq buf (get-buffer-create (if (symbolp buffer)
3090 (symbol-value buffer) buffer))))
3091 (switch-to-buffer buf)
3092 ;; We return the window if it has the `point' spec.
3093 (and (memq 'point split) window)))
3094 ;; This is a normal split.
3096 (when (> (length subs) 0)
3097 ;; First we have to compute the sizes of all new windows.
3099 (setq sub (append (pop subs) nil))
3100 (while (and (not (assq (car sub) gnus-window-to-buffer))
3101 (gnus-functionp (car sub)))
3102 (setq sub (eval sub)))
3104 (push sub comp-subs)
3105 (setq size (cadar comp-subs))
3106 (cond ((equal size 1.0)
3107 (setq rest (car comp-subs))
3110 (setq s (floor (* size len))))
3114 (error "Illegal size: %s" size)))
3115 ;; Try to make sure that we are inside the safe limits.
3117 ((and (eq type 'horizontal)
3120 ((and (eq type 'vertical)
3123 (setcar (cdar comp-subs) s)
3125 ;; Take care of the "1.0" spec.
3127 (setcar (cdr rest) (- len total))
3128 (error "No 1.0 specs in %s" split))
3129 ;; The we do the actual splitting in a nice recursive
3131 (setq comp-subs (nreverse comp-subs))
3133 (if (null (cdr comp-subs))
3134 (setq new-win window)
3136 (split-window window (cadar comp-subs)
3137 (eq type 'horizontal))))
3138 (setq result (or (gnus-configure-frame
3139 (car comp-subs) window) result))
3140 (select-window new-win)
3141 (setq window new-win)
3142 (setq comp-subs (cdr comp-subs))))
3143 ;; Return the proper window, if any.
3145 (select-window result))))))
3147 (defun gnus-configure-windows (setting &optional force)
3148 (setq setting (gnus-windows-old-to-new setting))
3149 (let ((split (if (symbolp setting)
3150 (car (cdr (assq setting gnus-buffer-configuration)))
3152 (in-buf (current-buffer))
3153 rule val w height hor ohor heights sub jump-buffer
3154 rel total to-buf all-visible)
3157 (error "No such setting: %s" setting))
3159 (if (and (not force) (setq all-visible (gnus-all-windows-visible-p split)))
3160 ;; All the windows mentioned are already visible, so we just
3161 ;; put point in the assigned buffer, and do not touch the
3163 (select-window all-visible)
3165 ;; Either remove all windows or just remove all Gnus windows.
3166 (if gnus-use-full-window
3167 (delete-other-windows)
3168 (gnus-remove-some-windows)
3169 (switch-to-buffer nntp-server-buffer))
3171 (switch-to-buffer nntp-server-buffer)
3172 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3174 (defun gnus-all-windows-visible-p (split)
3175 (when (vectorp split)
3176 (setq split (append split nil)))
3177 (when (or (consp (car split))
3178 (vectorp (car split)))
3180 (push 'vertical split))
3181 ;; The SPLIT might be something that is to be evaled to
3182 ;; return a new SPLIT.
3183 (while (and (not (assq (car split) gnus-window-to-buffer))
3184 (gnus-functionp (car split)))
3185 (setq split (eval split)))
3186 (let* ((type (elt split 0)))
3190 ((not (or (eq type 'horizontal) (eq type 'vertical)))
3191 (let ((buffer (cond ((stringp type) type)
3192 (t (cdr (assq type gnus-window-to-buffer)))))
3195 (error "Illegal buffer type: %s" type))
3196 (when (setq buf (get-buffer (if (symbolp buffer) (symbol-value buffer)
3198 (setq win (get-buffer-window buf)))
3200 (if (memq 'point split)
3204 (let ((n (mapcar 'gnus-all-windows-visible-p
3208 (cond ((windowp (car n))
3215 (defun gnus-window-top-edge (&optional window)
3216 (nth 1 (window-edges window)))
3218 (defun gnus-remove-some-windows ()
3219 (let ((buffers gnus-window-to-buffer)
3220 buf bufs lowest-buf lowest)
3222 ;; Remove windows on all known Gnus buffers.
3224 (setq buf (cdr (car buffers)))
3226 (setq buf (and (boundp buf) (symbol-value buf))))
3228 (get-buffer-window buf)
3230 (setq bufs (cons buf bufs))
3232 (if (or (not lowest)
3233 (< (gnus-window-top-edge) lowest))
3235 (setq lowest (gnus-window-top-edge))
3236 (setq lowest-buf buf)))))
3237 (setq buffers (cdr buffers)))
3238 ;; Remove windows on *all* summary buffers.
3242 (let ((buf (window-buffer win)))
3243 (if (string-match "^\\*Summary" (buffer-name buf))
3245 (setq bufs (cons buf bufs))
3247 (if (or (not lowest)
3248 (< (gnus-window-top-edge) lowest))
3250 (setq lowest-buf buf)
3251 (setq lowest (gnus-window-top-edge))))))))))
3254 (pop-to-buffer lowest-buf)
3255 (switch-to-buffer nntp-server-buffer)))
3257 (and (not (eq (car bufs) lowest-buf))
3258 (delete-windows-on (car bufs)))
3259 (setq bufs (cdr bufs))))))
3261 (defun gnus-version ()
3262 "Version numbers of this version of Gnus."
3264 (let ((methods gnus-valid-select-methods)
3267 ;; Go through all the legal select methods and add their version
3268 ;; numbers to the total version string. Only the backends that are
3269 ;; currently in use will have their message numbers taken into
3272 (setq meth (intern (concat (car (car methods)) "-version")))
3274 (stringp (symbol-value meth))
3275 (setq mess (concat mess "; " (symbol-value meth))))
3276 (setq methods (cdr methods)))
3277 (gnus-message 2 mess)))
3279 (defun gnus-info-find-node ()
3280 "Find Info documentation of Gnus."
3282 ;; Enlarge info window if needed.
3283 (let ((mode major-mode))
3284 (gnus-configure-windows 'info)
3285 (Info-goto-node (car (cdr (assq mode gnus-info-nodes))))))
3287 (defun gnus-replace-chars-in-string (string &rest pairs)
3288 "Replace characters in STRING from FROM to TO."
3289 (let ((string (substring string 0)) ;Copy string.
3290 (len (length string))
3293 (or (zerop (% (length pairs) 2))
3294 (error "Odd number of translation pairs"))
3295 (setplist 'sym pairs)
3296 ;; Replace all occurrences of FROM with TO.
3298 (if (setq to (get 'sym (aref string idx)))
3299 (aset string idx to))
3300 (setq idx (1+ idx)))
3303 (defun gnus-days-between (date1 date2)
3304 ;; Return the number of days between date1 and date2.
3305 (- (gnus-day-number date1) (gnus-day-number date2)))
3307 (defun gnus-day-number (date)
3308 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3309 (timezone-parse-date date))))
3310 (timezone-absolute-from-gregorian
3311 (nth 1 dat) (nth 2 dat) (car dat))))
3313 ;; Returns a floating point number that says how many seconds have
3314 ;; lapsed between Jan 1 12:00:00 1970 and DATE.
3315 (defun gnus-seconds-since-epoch (date)
3316 (let* ((tdate (mapcar (lambda (ti) (and ti (string-to-int ti)))
3317 (timezone-parse-date date)))
3318 (ttime (mapcar (lambda (ti) (and ti (string-to-int ti)))
3319 (timezone-parse-time
3320 (aref (timezone-parse-date date) 3))))
3321 (edate (mapcar (lambda (ti) (and ti (string-to-int ti)))
3322 (timezone-parse-date "Jan 1 12:00:00 1970")))
3323 (tday (- (timezone-absolute-from-gregorian
3324 (nth 1 tdate) (nth 2 tdate) (nth 0 tdate))
3325 (timezone-absolute-from-gregorian
3326 (nth 1 edate) (nth 2 edate) (nth 0 edate)))))
3328 (* (nth 1 ttime) 60)
3329 (* 1.0 (nth 0 ttime) 60 60)
3330 (* 1.0 tday 60 60 24))))
3332 (defun gnus-file-newer-than (file date)
3333 (let ((fdate (nth 5 (file-attributes file))))
3334 (or (> (car fdate) (car date))
3335 (and (= (car fdate) (car date))
3336 (> (nth 1 fdate) (nth 1 date))))))
3338 (defun gnus-group-read-only-p (&optional group)
3339 "Check whether GROUP supports editing or not.
3340 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3341 that that variable is buffer-local to the summary buffers."
3342 (let ((group (or group gnus-newsgroup-name)))
3343 (not (gnus-check-backend-function 'request-replace-article group))))
3345 (defun gnus-group-total-expirable-p (group)
3346 "Check whether GROUP is total-expirable or not."
3347 (let ((params (gnus-info-params (gnus-get-info group))))
3348 (or (memq 'total-expire params)
3349 (cdr (assq 'total-expire params)) ; (total-expire . t)
3350 (and gnus-total-expirable-newsgroups ; Check var.
3351 (string-match gnus-total-expirable-newsgroups group)))))
3353 (defun gnus-group-auto-expirable-p (group)
3354 "Check whether GROUP is total-expirable or not."
3355 (let ((params (gnus-info-params (gnus-get-info group))))
3356 (or (memq 'auto-expire params)
3357 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3358 (and gnus-auto-expirable-newsgroups ; Check var.
3359 (string-match gnus-auto-expirable-newsgroups group)))))
3361 (defsubst gnus-simplify-subject-fully (subject)
3362 "Simplify a subject string according to the user's wishes."
3364 ((null gnus-summary-gather-subject-limit)
3365 (gnus-simplify-subject-re subject))
3366 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3367 (gnus-simplify-subject-fuzzy subject))
3368 ((numberp gnus-summary-gather-subject-limit)
3369 (gnus-limit-string subject gnus-summary-gather-subject-limit))
3373 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3374 "Check whether two subjects are equal. If optional argument
3375 simple-first is t, first argument is already simplified."
3377 ((null simple-first)
3378 (equal (gnus-simplify-subject-fully s1)
3379 (gnus-simplify-subject-fully s2)))
3382 (gnus-simplify-subject-fully s2)))))
3384 ;; Returns a list of writable groups.
3385 (defun gnus-writable-groups ()
3386 (let ((alist gnus-newsrc-alist)
3389 (or (gnus-group-read-only-p (car (car alist)))
3390 (setq groups (cons (car (car alist)) groups)))
3391 (setq alist (cdr alist)))
3394 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3396 (defun gnus-y-or-n-p (prompt)
3401 (defun gnus-yes-or-no-p (prompt)
3403 (yes-or-no-p prompt)
3406 ;; Check whether to use long file names.
3407 (defun gnus-use-long-file-name (symbol)
3408 ;; The variable has to be set...
3409 (and gnus-use-long-file-name
3410 ;; If it isn't a list, then we return t.
3411 (or (not (listp gnus-use-long-file-name))
3412 ;; If it is a list, and the list contains `symbol', we
3414 (not (memq symbol gnus-use-long-file-name)))))
3416 ;; I suspect there's a better way, but I haven't taken the time to do
3417 ;; it yet. -erik selberg@cs.washington.edu
3418 (defun gnus-dd-mmm (messy-date)
3419 "Return a string like DD-MMM from a big messy string"
3420 (let ((datevec (timezone-parse-date messy-date)))
3422 (or (aref datevec 2) "??")
3425 (nth (1- (string-to-number (aref datevec 1)))
3426 timezone-months-assoc))
3429 ;; Make a hash table (default and minimum size is 255).
3430 ;; Optional argument HASHSIZE specifies the table size.
3431 (defun gnus-make-hashtable (&optional hashsize)
3432 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3434 ;; Make a number that is suitable for hashing; bigger than MIN and one
3436 (defun gnus-create-hash-size (min)
3442 ;; Show message if message has a lower level than `gnus-verbose'.
3443 ;; Guide-line for numbers:
3444 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3445 ;; for things that take a long time, 7 - not very important messages
3446 ;; on stuff, 9 - messages inside loops.
3447 (defun gnus-message (level &rest args)
3448 (if (<= level gnus-verbose)
3449 (apply 'message args)
3450 ;; We have to do this format thingie here even if the result isn't
3451 ;; shown - the return value has to be the same as the return value
3453 (apply 'format args)))
3455 (defun gnus-functionp (form)
3456 "Return non-nil if FORM is funcallable."
3457 (or (and (symbolp form) (fboundp form))
3458 (and (listp form) (eq (car form) 'lambda))))
3460 ;; Generate a unique new group name.
3461 (defun gnus-generate-new-group-name (leaf)
3464 (while (gnus-gethash name gnus-newsrc-hashtb)
3465 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3468 ;; Find out whether the gnus-visual TYPE is wanted.
3469 (defun gnus-visual-p (&optional type class)
3470 (and gnus-visual ; Has to be non-nil, at least.
3471 (if (not type) ; We don't care about type.
3473 (if (listp gnus-visual) ; It's a list, so we check it.
3474 (or (memq type gnus-visual)
3475 (memq class gnus-visual))
3478 (defun gnus-parent-id (references)
3479 "Return the last Message-ID in REFERENCES."
3481 (string-match "\\(<[^<>]+>\\) *$" references)
3482 (substring references (match-beginning 1) (match-end 1))))
3484 (defun gnus-ephemeral-group-p (group)
3485 "Say whether GROUP is ephemeral or not."
3486 (assoc 'quit-config (gnus-find-method-for-group group)))
3488 (defun gnus-group-quit-config (group)
3489 "Return the quit-config of GROUP."
3490 (nth 1 (assoc 'quit-config (gnus-find-method-for-group group))))
3492 (defun gnus-simplify-mode-line ()
3493 "Make mode lines a bit simpler."
3494 (setq mode-line-modified "-- ")
3495 (when (listp mode-line-format)
3496 (make-local-variable 'mode-line-format)
3497 (setq mode-line-format (copy-sequence mode-line-format))
3498 (and (equal (nth 3 mode-line-format) " ")
3499 (setcar (nthcdr 3 mode-line-format) " "))))
3501 ;;; List and range functions
3503 (defun gnus-last-element (list)
3504 "Return last element of LIST."
3506 (setq list (cdr list)))
3509 (defun gnus-copy-sequence (list)
3510 "Do a complete, total copy of a list."
3511 (if (and (consp list) (not (consp (cdr list))))
3512 (cons (car list) (cdr list))
3513 (mapcar (lambda (elem) (if (consp elem)
3514 (if (consp (cdr elem))
3515 (gnus-copy-sequence elem)
3516 (cons (car elem) (cdr elem)))
3520 (defun gnus-set-difference (list1 list2)
3521 "Return a list of elements of LIST1 that do not appear in LIST2."
3522 (let ((list1 (copy-sequence list1)))
3524 (setq list1 (delq (car list2) list1))
3525 (setq list2 (cdr list2)))
3528 (defun gnus-sorted-complement (list1 list2)
3529 "Return a list of elements of LIST1 that do not appear in LIST2.
3530 Both lists have to be sorted over <."
3532 (if (or (null list1) (null list2))
3534 (while (and list1 list2)
3535 (cond ((= (car list1) (car list2))
3536 (setq list1 (cdr list1)
3538 ((< (car list1) (car list2))
3539 (setq out (cons (car list1) out))
3540 (setq list1 (cdr list1)))
3542 (setq out (cons (car list2) out))
3543 (setq list2 (cdr list2)))))
3544 (nconc (nreverse out) (or list1 list2)))))
3546 (defun gnus-intersection (list1 list2)
3549 (if (memq (car list2) list1)
3550 (setq result (cons (car list2) result)))
3551 (setq list2 (cdr list2)))
3554 (defun gnus-sorted-intersection (list1 list2)
3555 ;; LIST1 and LIST2 have to be sorted over <.
3557 (while (and list1 list2)
3558 (cond ((= (car list1) (car list2))
3559 (setq out (cons (car list1) out)
3562 ((< (car list1) (car list2))
3563 (setq list1 (cdr list1)))
3565 (setq list2 (cdr list2)))))
3568 (defun gnus-set-sorted-intersection (list1 list2)
3569 ;; LIST1 and LIST2 have to be sorted over <.
3570 ;; This function modifies LIST1.
3571 (let* ((top (cons nil list1))
3573 (while (and list1 list2)
3574 (cond ((= (car list1) (car list2))
3578 ((< (car list1) (car list2))
3579 (setcdr prev (cdr list1))
3580 (setq list1 (cdr list1)))
3582 (setq list2 (cdr list2)))))
3586 (defun gnus-compress-sequence (numbers &optional always-list)
3587 "Convert list of numbers to a list of ranges or a single range.
3588 If ALWAYS-LIST is non-nil, this function will always release a list of
3590 (let* ((first (car numbers))
3591 (last (car numbers))
3595 (if (not (listp (cdr numbers)))
3598 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3599 ((= (1+ last) (car numbers)) ;Still in sequence
3600 (setq last (car numbers)))
3601 (t ;End of one sequence
3603 (cons (if (= first last) first
3604 (cons first last)) result))
3605 (setq first (car numbers))
3606 (setq last (car numbers))))
3607 (setq numbers (cdr numbers)))
3608 (if (and (not always-list) (null result))
3609 (if (= first last) (list first) (cons first last))
3610 (nreverse (cons (if (= first last) first (cons first last))
3613 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3614 (defun gnus-uncompress-range (ranges)
3615 "Expand a list of ranges into a list of numbers.
3616 RANGES is either a single range on the form `(num . num)' or a list of
3618 (let (first last result)
3622 ((not (listp (cdr ranges)))
3623 (setq first (car ranges))
3624 (setq last (cdr ranges))
3625 (while (<= first last)
3626 (setq result (cons first result))
3627 (setq first (1+ first)))
3631 (if (atom (car ranges))
3632 (if (numberp (car ranges))
3633 (setq result (cons (car ranges) result)))
3634 (setq first (car (car ranges)))
3635 (setq last (cdr (car ranges)))
3636 (while (<= first last)
3637 (setq result (cons first result))
3638 (setq first (1+ first))))
3639 (setq ranges (cdr ranges)))
3640 (nreverse result)))))
3642 (defun gnus-add-to-range (ranges list)
3643 "Return a list of ranges that has all articles from both RANGES and LIST.
3644 Note: LIST has to be sorted over `<'."
3646 (gnus-compress-sequence list t)
3647 (setq list (copy-sequence list))
3648 (or (listp (cdr ranges))
3649 (setq ranges (list ranges)))
3651 ilist lowest highest temp)
3652 (while (and ranges list)
3654 (setq lowest (or (and (atom (car ranges)) (car ranges))
3655 (car (car ranges))))
3656 (while (and list (cdr list) (< (car (cdr list)) lowest))
3657 (setq list (cdr list)))
3658 (if (< (car ilist) lowest)
3661 (setq list (cdr list))
3663 (setq out (nconc (gnus-compress-sequence ilist t) out))))
3664 (setq highest (or (and (atom (car ranges)) (car ranges))
3665 (cdr (car ranges))))
3666 (while (and list (<= (car list) highest))
3667 (setq list (cdr list)))
3668 (setq ranges (cdr ranges)))
3670 (setq out (nconc (gnus-compress-sequence list t) out)))
3671 (setq out (sort out (lambda (r1 r2)
3672 (< (or (and (atom r1) r1) (car r1))
3673 (or (and (atom r2) r2) (car r2))))))
3676 (if (atom (car ranges))
3678 (if (atom (car (cdr ranges)))
3679 (if (= (1+ (car ranges)) (car (cdr ranges)))
3681 (setcar ranges (cons (car ranges)
3682 (car (cdr ranges))))
3683 (setcdr ranges (cdr (cdr ranges)))))
3684 (if (= (1+ (car ranges)) (car (car (cdr ranges))))
3686 (setcar (car (cdr ranges)) (car ranges))
3687 (setcar ranges (car (cdr ranges)))
3688 (setcdr ranges (cdr (cdr ranges)))))))
3690 (if (atom (car (cdr ranges)))
3691 (if (= (1+ (cdr (car ranges))) (car (cdr ranges)))
3693 (setcdr (car ranges) (car (cdr ranges)))
3694 (setcdr ranges (cdr (cdr ranges)))))
3695 (if (= (1+ (cdr (car ranges))) (car (car (cdr ranges))))
3697 (setcdr (car ranges) (cdr (car (cdr ranges))))
3698 (setcdr ranges (cdr (cdr ranges))))))))
3699 (setq ranges (cdr ranges)))
3702 (defun gnus-remove-from-range (ranges list)
3703 "Return a list of ranges that has all articles from LIST removed from RANGES.
3704 Note: LIST has to be sorted over `<'."
3705 ;; !!! This function shouldn't look like this, but I've got a headache.
3706 (gnus-compress-sequence
3707 (gnus-sorted-complement
3708 (gnus-uncompress-range ranges) list)))
3710 (defun gnus-member-of-range (number ranges)
3711 (if (not (listp (cdr ranges)))
3712 (and (>= number (car ranges))
3713 (<= number (cdr ranges)))
3716 (if (numberp (car ranges))
3717 (>= number (car ranges))
3718 (>= number (car (car ranges))))
3720 (if (if (numberp (car ranges))
3721 (= number (car ranges))
3722 (and (>= number (car (car ranges)))
3723 (<= number (cdr (car ranges)))))
3724 (setq not-stop nil))
3725 (setq ranges (cdr ranges)))
3728 (defun gnus-range-length (range)
3729 "Return the length RANGE would have if uncompressed."
3730 (length (gnus-uncompress-range range)))
3732 (defun gnus-sublist-p (list sublist)
3733 "Test whether all elements in SUBLIST are members of LIST."
3736 (unless (memq (pop sublist) list)
3746 (defvar gnus-group-mode-map nil)
3747 (defvar gnus-group-group-map nil)
3748 (defvar gnus-group-mark-map nil)
3749 (defvar gnus-group-list-map nil)
3750 (defvar gnus-group-sort-map nil)
3751 (defvar gnus-group-soup-map nil)
3752 (defvar gnus-group-sub-map nil)
3753 (defvar gnus-group-help-map nil)
3754 (defvar gnus-group-score-map nil)
3755 (put 'gnus-group-mode 'mode-class 'special)
3757 (if gnus-group-mode-map
3759 (setq gnus-group-mode-map (make-keymap))
3760 (suppress-keymap gnus-group-mode-map)
3761 (define-key gnus-group-mode-map " " 'gnus-group-read-group)
3762 (define-key gnus-group-mode-map "=" 'gnus-group-select-group)
3763 (define-key gnus-group-mode-map "\M- " 'gnus-group-unhidden-select-group)
3764 (define-key gnus-group-mode-map "\r" 'gnus-group-select-group)
3765 (define-key gnus-group-mode-map "\M-\r" 'gnus-group-quick-select-group)
3766 (define-key gnus-group-mode-map "j" 'gnus-group-jump-to-group)
3767 (define-key gnus-group-mode-map "n" 'gnus-group-next-unread-group)
3768 (define-key gnus-group-mode-map "p" 'gnus-group-prev-unread-group)
3769 (define-key gnus-group-mode-map "\177" 'gnus-group-prev-unread-group)
3770 (define-key gnus-group-mode-map "N" 'gnus-group-next-group)
3771 (define-key gnus-group-mode-map "P" 'gnus-group-prev-group)
3772 (define-key gnus-group-mode-map
3773 "\M-n" 'gnus-group-next-unread-group-same-level)
3774 (define-key gnus-group-mode-map
3775 "\M-p" 'gnus-group-prev-unread-group-same-level)
3776 (define-key gnus-group-mode-map "," 'gnus-group-best-unread-group)
3777 (define-key gnus-group-mode-map "." 'gnus-group-first-unread-group)
3778 (define-key gnus-group-mode-map "u" 'gnus-group-unsubscribe-current-group)
3779 (define-key gnus-group-mode-map "U" 'gnus-group-unsubscribe-group)
3780 (define-key gnus-group-mode-map "c" 'gnus-group-catchup-current)
3781 (define-key gnus-group-mode-map "C" 'gnus-group-catchup-current-all)
3782 (define-key gnus-group-mode-map "l" 'gnus-group-list-groups)
3783 (define-key gnus-group-mode-map "L" 'gnus-group-list-all-groups)
3784 (define-key gnus-group-mode-map "m" 'gnus-group-mail)
3785 (define-key gnus-group-mode-map "g" 'gnus-group-get-new-news)
3786 (define-key gnus-group-mode-map "\M-g" 'gnus-group-get-new-news-this-group)
3787 (define-key gnus-group-mode-map "R" 'gnus-group-restart)
3788 (define-key gnus-group-mode-map "r" 'gnus-group-read-init-file)
3789 (define-key gnus-group-mode-map "B" 'gnus-group-browse-foreign-server)
3790 (define-key gnus-group-mode-map "b" 'gnus-group-check-bogus-groups)
3791 (define-key gnus-group-mode-map "F" 'gnus-find-new-newsgroups)
3792 (define-key gnus-group-mode-map "\C-c\C-d" 'gnus-group-describe-group)
3793 (define-key gnus-group-mode-map "\M-d" 'gnus-group-describe-all-groups)
3794 (define-key gnus-group-mode-map "\C-c\C-a" 'gnus-group-apropos)
3795 (define-key gnus-group-mode-map "\C-c\M-\C-a" 'gnus-group-description-apropos)
3796 (define-key gnus-group-mode-map "a" 'gnus-group-post-news)
3797 (define-key gnus-group-mode-map "\ek" 'gnus-group-edit-local-kill)
3798 (define-key gnus-group-mode-map "\eK" 'gnus-group-edit-global-kill)
3799 (define-key gnus-group-mode-map "\C-k" 'gnus-group-kill-group)
3800 (define-key gnus-group-mode-map "\C-y" 'gnus-group-yank-group)
3801 (define-key gnus-group-mode-map "\C-w" 'gnus-group-kill-region)
3802 (define-key gnus-group-mode-map "\C-x\C-t" 'gnus-group-transpose-groups)
3803 (define-key gnus-group-mode-map "\C-c\C-l" 'gnus-group-list-killed)
3804 (define-key gnus-group-mode-map "\C-c\C-x" 'gnus-group-expire-articles)
3805 (define-key gnus-group-mode-map "\C-c\M-\C-x" 'gnus-group-expire-all-groups)
3806 (define-key gnus-group-mode-map "V" 'gnus-version)
3807 (define-key gnus-group-mode-map "s" 'gnus-group-save-newsrc)
3808 (define-key gnus-group-mode-map "z" 'gnus-group-suspend)
3809 (define-key gnus-group-mode-map "Z" 'gnus-group-clear-dribble)
3810 (define-key gnus-group-mode-map "q" 'gnus-group-exit)
3811 (define-key gnus-group-mode-map "Q" 'gnus-group-quit)
3812 (define-key gnus-group-mode-map "?" 'gnus-group-describe-briefly)
3813 (define-key gnus-group-mode-map "\C-c\C-i" 'gnus-info-find-node)
3814 (define-key gnus-group-mode-map "\M-e" 'gnus-group-edit-group-method)
3815 (define-key gnus-group-mode-map "^" 'gnus-group-enter-server-mode)
3816 (define-key gnus-group-mode-map gnus-mouse-2 'gnus-mouse-pick-group)
3817 (define-key gnus-group-mode-map "<" 'beginning-of-buffer)
3818 (define-key gnus-group-mode-map ">" 'end-of-buffer)
3819 (define-key gnus-group-mode-map "\C-c\C-b" 'gnus-bug)
3820 (define-key gnus-group-mode-map "\C-c\C-s" 'gnus-group-sort-groups)
3821 (define-key gnus-group-mode-map "t" 'gnus-topic-mode)
3822 (define-key gnus-group-mode-map "\C-c\M-g" 'gnus-activate-all-groups)
3824 (define-key gnus-group-mode-map "#" 'gnus-group-mark-group)
3825 (define-key gnus-group-mode-map "\M-#" 'gnus-group-unmark-group)
3826 (define-prefix-command 'gnus-group-mark-map)
3827 (define-key gnus-group-mode-map "M" 'gnus-group-mark-map)
3828 (define-key gnus-group-mark-map "m" 'gnus-group-mark-group)
3829 (define-key gnus-group-mark-map "u" 'gnus-group-unmark-group)
3830 (define-key gnus-group-mark-map "w" 'gnus-group-mark-region)
3831 (define-key gnus-group-mark-map "r" 'gnus-group-mark-regexp)
3833 (define-prefix-command 'gnus-group-group-map)
3834 (define-key gnus-group-mode-map "G" 'gnus-group-group-map)
3835 (define-key gnus-group-group-map "d" 'gnus-group-make-directory-group)
3836 (define-key gnus-group-group-map "h" 'gnus-group-make-help-group)
3837 (define-key gnus-group-group-map "a" 'gnus-group-make-archive-group)
3838 (define-key gnus-group-group-map "k" 'gnus-group-make-kiboze-group)
3839 (define-key gnus-group-group-map "m" 'gnus-group-make-group)
3840 (define-key gnus-group-group-map "E" 'gnus-group-edit-group)
3841 (define-key gnus-group-group-map "e" 'gnus-group-edit-group-method)
3842 (define-key gnus-group-group-map "p" 'gnus-group-edit-group-parameters)
3843 (define-key gnus-group-group-map "v" 'gnus-group-add-to-virtual)
3844 (define-key gnus-group-group-map "V" 'gnus-group-make-empty-virtual)
3845 (define-key gnus-group-group-map "D" 'gnus-group-enter-directory)
3846 (define-key gnus-group-group-map "f" 'gnus-group-make-doc-group)
3847 (define-key gnus-group-group-map "r" 'gnus-group-rename-group)
3848 (define-key gnus-group-group-map "\177" 'gnus-group-delete-group)
3850 (define-prefix-command 'gnus-group-soup-map)
3851 (define-key gnus-group-group-map "s" 'gnus-group-soup-map)
3852 (define-key gnus-group-soup-map "b" 'gnus-group-brew-soup)
3853 (define-key gnus-group-soup-map "w" 'gnus-soup-save-areas)
3854 (define-key gnus-group-soup-map "s" 'gnus-soup-send-replies)
3855 (define-key gnus-group-soup-map "p" 'gnus-soup-pack-packet)
3856 (define-key gnus-group-soup-map "r" 'nnsoup-pack-replies)
3858 (define-prefix-command 'gnus-group-sort-map)
3859 (define-key gnus-group-group-map "S" 'gnus-group-sort-map)
3860 (define-key gnus-group-sort-map "s" 'gnus-group-sort-groups)
3861 (define-key gnus-group-sort-map "a" 'gnus-group-sort-groups-by-alphabet)
3862 (define-key gnus-group-sort-map "u" 'gnus-group-sort-groups-by-unread)
3863 (define-key gnus-group-sort-map "l" 'gnus-group-sort-groups-by-level)
3864 (define-key gnus-group-sort-map "v" 'gnus-group-sort-groups-by-score)
3865 (define-key gnus-group-sort-map "r" 'gnus-group-sort-groups-by-rank)
3866 (define-key gnus-group-sort-map "m" 'gnus-group-sort-groups-by-method)
3868 (define-prefix-command 'gnus-group-list-map)
3869 (define-key gnus-group-mode-map "A" 'gnus-group-list-map)
3870 (define-key gnus-group-list-map "k" 'gnus-group-list-killed)
3871 (define-key gnus-group-list-map "z" 'gnus-group-list-zombies)
3872 (define-key gnus-group-list-map "s" 'gnus-group-list-groups)
3873 (define-key gnus-group-list-map "u" 'gnus-group-list-all-groups)
3874 (define-key gnus-group-list-map "A" 'gnus-group-list-active)
3875 (define-key gnus-group-list-map "a" 'gnus-group-apropos)
3876 (define-key gnus-group-list-map "d" 'gnus-group-description-apropos)
3877 (define-key gnus-group-list-map "m" 'gnus-group-list-matching)
3878 (define-key gnus-group-list-map "M" 'gnus-group-list-all-matching)
3879 (define-key gnus-group-list-map "l" 'gnus-group-list-level)
3881 (define-prefix-command 'gnus-group-score-map)
3882 (define-key gnus-group-mode-map "W" 'gnus-group-score-map)
3883 (define-key gnus-group-score-map "f" 'gnus-score-flush-cache)
3885 (define-prefix-command 'gnus-group-help-map)
3886 (define-key gnus-group-mode-map "H" 'gnus-group-help-map)
3887 (define-key gnus-group-help-map "f" 'gnus-group-fetch-faq)
3889 (define-prefix-command 'gnus-group-sub-map)
3890 (define-key gnus-group-mode-map "S" 'gnus-group-sub-map)
3891 (define-key gnus-group-sub-map "l" 'gnus-group-set-current-level)
3892 (define-key gnus-group-sub-map "t" 'gnus-group-unsubscribe-current-group)
3893 (define-key gnus-group-sub-map "s" 'gnus-group-unsubscribe-group)
3894 (define-key gnus-group-sub-map "k" 'gnus-group-kill-group)
3895 (define-key gnus-group-sub-map "y" 'gnus-group-yank-group)
3896 (define-key gnus-group-sub-map "w" 'gnus-group-kill-region)
3897 (define-key gnus-group-sub-map "\C-k" 'gnus-group-kill-level)
3898 (define-key gnus-group-sub-map "z" 'gnus-group-kill-all-zombies))
3900 (defun gnus-group-mode ()
3901 "Major mode for reading news.
3903 All normal editing commands are switched off.
3904 \\<gnus-group-mode-map>
3905 The group buffer lists (some of) the groups available. For instance,
3906 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
3907 lists all zombie groups.
3909 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
3910 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
3912 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
3914 The following commands are available:
3916 \\{gnus-group-mode-map}"
3918 (when (and menu-bar-mode
3919 (gnus-visual-p 'group-menu 'menu))
3920 (gnus-group-make-menu-bar))
3921 (kill-all-local-variables)
3922 (gnus-simplify-mode-line)
3923 (setq major-mode 'gnus-group-mode)
3924 (setq mode-name "Group")
3925 (gnus-group-set-mode-line)
3926 (setq mode-line-process nil)
3927 (use-local-map gnus-group-mode-map)
3928 (buffer-disable-undo (current-buffer))
3929 (setq truncate-lines t)
3930 (setq buffer-read-only t)
3931 (run-hooks 'gnus-group-mode-hook))
3933 (defun gnus-mouse-pick-group (e)
3934 "Enter the group under the mouse pointer."
3937 (gnus-group-read-group nil))
3939 ;; Look at LEVEL and find out what the level is really supposed to be.
3940 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
3941 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
3942 (defun gnus-group-default-level (&optional level number-or-nil)
3944 (gnus-group-use-permanent-levels
3945 (setq gnus-group-default-list-level
3946 (or level gnus-group-default-list-level))
3947 (or gnus-group-default-list-level gnus-level-subscribed))
3951 (or level gnus-group-default-list-level gnus-level-subscribed))))
3954 (defun gnus-slave-no-server (&optional arg)
3955 "Read network news as a slave, without connecting to local server"
3957 (gnus-no-server arg t))
3960 (defun gnus-no-server (&optional arg slave)
3962 If ARG is a positive number, Gnus will use that as the
3963 startup level. If ARG is nil, Gnus will be started at level 2.
3964 If ARG is non-nil and not a positive number, Gnus will
3965 prompt the user for the name of an NNTP server to use.
3966 As opposed to `gnus', this command will not connect to the local server."
3968 (make-local-variable 'gnus-group-use-permanent-levels)
3969 (setq gnus-group-use-permanent-levels t)
3970 (gnus (or arg (1- gnus-level-default-subscribed)) t slave))
3973 (defun gnus-slave (&optional arg)
3974 "Read news as a slave."
3976 (gnus arg nil 'slave))
3979 (defun gnus (&optional arg dont-connect slave)
3981 If ARG is non-nil and a positive number, Gnus will use that as the
3982 startup level. If ARG is non-nil and not a positive number, Gnus will
3983 prompt the user for the name of an NNTP server to use."
3985 (if (get-buffer gnus-group-buffer)
3987 (switch-to-buffer gnus-group-buffer)
3988 (gnus-group-get-new-news))
3991 (nnheader-init-server-buffer)
3992 (gnus-read-init-file)
3993 (setq gnus-slave slave)
3995 (gnus-group-setup-buffer)
3996 (let ((buffer-read-only nil))
3998 (if (not gnus-inhibit-startup-message)
4000 (gnus-group-startup-message)
4003 (let ((level (and arg (numberp arg) (> arg 0) arg))
4009 (gnus-start-news-server (and arg (not level))))))
4010 (if (and (not dont-connect)
4013 (run-hooks 'gnus-startup-hook)
4014 ;; NNTP server is successfully open.
4016 ;; Find the current startup file name.
4017 (setq gnus-current-startup-file
4018 (gnus-make-newsrc-file gnus-startup-file))
4020 ;; Read the dribble file.
4021 (and (or gnus-slave gnus-use-dribble-file) (gnus-dribble-read-file))
4023 (gnus-summary-make-display-table)
4024 ;; Do the actual startup.
4025 (gnus-setup-news nil level)
4026 ;; Generate the group buffer.
4027 (gnus-group-list-groups level)
4028 (gnus-configure-windows 'group)
4029 (gnus-group-set-mode-line))))))
4031 (defun gnus-unload ()
4032 "Unload all Gnus features."
4034 (or (boundp 'load-history)
4035 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4036 (let ((history load-history)
4039 (and (string-match "^gnus" (car (car history)))
4040 (setq feature (cdr (assq 'provide (car history))))
4041 (unload-feature feature 'force))
4042 (setq history (cdr history)))))
4044 (defun gnus-compile ()
4045 "Byte-compile the user-defined format specs."
4047 (let ((entries gnus-format-specs)
4048 entry gnus-tmp-func)
4050 (gnus-message 7 "Compiling format specs...")
4053 (setq entry (pop entries))
4054 (if (eq (car entry) 'version)
4055 (setq gnus-format-specs (delq entry gnus-format-specs))
4056 (when (and (listp (caddr entry))
4057 (not (eq 'byte-code (caaddr entry))))
4058 (fset 'gnus-tmp-func
4059 `(lambda () ,(caddr entry)))
4060 (byte-compile 'gnus-tmp-func)
4061 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4063 (push (cons 'version emacs-version) gnus-format-specs)
4065 (gnus-message 7 "Compiling user specs...done"))))
4067 (defun gnus-indent-rigidly (start end arg)
4068 "Indent rigidly using only spaces and no tabs."
4071 (narrow-to-region start end)
4072 (indent-rigidly start end arg)
4073 (goto-char (point-min))
4074 (while (search-forward "\t" nil t)
4075 (replace-match " " t t)))))
4077 (defun gnus-group-startup-message (&optional x y)
4078 "Insert startup message in current buffer."
4079 ;; Insert the message.
4084 _ ___ __ ___ __ _ ___
4103 ;; And then hack it.
4104 (gnus-indent-rigidly (point-min) (point-max)
4105 (/ (max (- (window-width) (or x 46)) 0) 2))
4106 (goto-char (point-min))
4108 (let* ((pheight (count-lines (point-min) (point-max)))
4109 (wheight (window-height))
4110 (rest (- wheight pheight)))
4111 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4113 (goto-char (point-min))
4114 (and (search-forward "Praxis" nil t)
4115 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4116 (goto-char (point-min))
4117 (let* ((mode-string (gnus-group-set-mode-line)))
4118 (setq mode-line-buffer-identification
4119 (list (concat gnus-version (substring (car mode-string) 4))))
4120 (set-buffer-modified-p t)))
4122 (defun gnus-group-startup-message-old (&optional x y)
4123 "Insert startup message in current buffer."
4124 ;; Insert the message.
4140 ;; And then hack it.
4141 ;; 18 is the longest line.
4142 (indent-rigidly (point-min) (point-max)
4143 (/ (max (- (window-width) (or x 28)) 0) 2))
4144 (goto-char (point-min))
4145 ;; +4 is fuzzy factor.
4146 (insert-char ?\n (/ (max (- (window-height) (or y 12)) 0) 2))
4149 (goto-char (point-min))
4150 (search-forward "Praxis")
4151 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold)
4152 (goto-char (point-min)))
4154 (defun gnus-group-setup-buffer ()
4155 (or (get-buffer gnus-group-buffer)
4157 (switch-to-buffer gnus-group-buffer)
4158 (gnus-add-current-to-buffer-list)
4160 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4162 (defun gnus-group-list-groups (&optional level unread lowest)
4163 "List newsgroups with level LEVEL or lower that have unread articles.
4164 Default is all subscribed groups.
4165 If argument UNREAD is non-nil, groups with no unread articles are also
4167 (interactive (list (if current-prefix-arg
4168 (prefix-numeric-value current-prefix-arg)
4170 (gnus-group-default-level nil t)
4171 gnus-group-default-list-level
4172 gnus-level-subscribed))))
4174 (setq level (car gnus-group-list-mode)
4175 unread (cdr gnus-group-list-mode)))
4176 (setq level (gnus-group-default-level level))
4177 (gnus-group-setup-buffer) ;May call from out of group buffer
4178 (gnus-update-format-specifications)
4179 (let ((case-fold-search nil)
4180 (group (gnus-group-group-name)))
4181 (funcall gnus-group-prepare-function level unread lowest)
4182 (if (zerop (buffer-size))
4183 (gnus-message 5 gnus-no-groups-message)
4184 (goto-char (point-min))
4186 ;; Go to the first group with unread articles.
4187 (gnus-group-search-forward nil nil nil t)
4188 ;; Find the right group to put point on. If the current group
4189 ;; has disapeared in the new listing, try to find the next
4190 ;; one. If no next one can be found, just leave point at the
4191 ;; first newsgroup in the buffer.
4192 (if (not (gnus-goto-char
4194 (point-min) (point-max)
4195 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4196 (let ((newsrc (nthcdr 3 (gnus-gethash group gnus-newsrc-hashtb))))
4198 (not (gnus-goto-char
4200 (point-min) (point-max) 'gnus-group
4202 (car (car newsrc)) gnus-active-hashtb)))))
4203 (setq newsrc (cdr newsrc)))
4204 (or newsrc (progn (goto-char (point-max))
4205 (forward-line -1))))))
4206 ;; Adjust cursor point.
4207 (gnus-group-position-point))))
4209 (defun gnus-group-list-level (level &optional all)
4210 "List groups on LEVEL.
4211 If ALL (the prefix), also list groups that have no unread articles."
4212 (interactive "nList groups on level: \nP")
4213 (gnus-group-list-groups level all level))
4215 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4216 "List all newsgroups with unread articles of level LEVEL or lower.
4217 If ALL is non-nil, list groups that have no unread articles.
4218 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4219 If REGEXP, only list groups matching REGEXP."
4220 (set-buffer gnus-group-buffer)
4221 (setq gnus-topic-indentation "")
4222 (let ((buffer-read-only nil)
4223 (newsrc (cdr gnus-newsrc-alist))
4224 (lowest (or lowest 1))
4225 info clevel unread group params)
4227 (if (< lowest gnus-level-zombie)
4228 ;; List living groups.
4230 (setq info (car newsrc)
4231 group (gnus-info-group info)
4232 params (gnus-info-params info)
4234 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4235 (and unread ; This group might be bogus
4237 (string-match regexp group))
4238 (<= (setq clevel (gnus-info-level info)) level)
4240 (or all ; We list all groups?
4241 (and gnus-group-list-inactive-groups
4242 (eq unread t)) ; We list unactivated groups
4243 (> unread 0) ; We list groups with unread articles
4244 (cdr (assq 'tick (gnus-info-marks info)))
4245 ; And groups with tickeds
4246 ;; Check for permanent visibility.
4247 (and gnus-permanently-visible-groups
4248 (string-match gnus-permanently-visible-groups
4250 (memq 'visible params)
4251 (cdr (assq 'visible params)))
4252 (gnus-group-insert-group-line
4253 group (gnus-info-level info)
4254 (gnus-info-marks info) unread (gnus-info-method info)))))
4256 ;; List dead groups.
4257 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4258 (gnus-group-prepare-flat-list-dead
4259 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4260 gnus-level-zombie ?Z
4262 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4263 (gnus-group-prepare-flat-list-dead
4264 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4265 gnus-level-killed ?K regexp))
4267 (gnus-group-set-mode-line)
4268 (setq gnus-group-list-mode (cons level all))
4269 (run-hooks 'gnus-group-prepare-hook)))
4271 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4272 ;; List zombies and killed lists somehwat faster, which was
4273 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4274 ;; this by ignoring the group format specification altogether.
4277 ;; This loop is used when listing groups that match some
4280 (setq group (pop groups))
4281 (when (string-match regexp group)
4282 (add-text-properties
4283 (point) (prog1 (1+ (point))
4284 (insert " " mark " *: " group "\n"))
4285 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4287 'gnus-level level))))
4288 ;; This loop is used when listing all groups.
4290 (add-text-properties
4291 (point) (prog1 (1+ (point))
4292 (insert " " mark " *: "
4293 (setq group (pop groups)) "\n"))
4294 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4296 'gnus-level level))))))
4298 (defmacro gnus-group-real-name (group)
4299 "Find the real name of a foreign newsgroup."
4300 `(let ((gname ,group))
4301 (if (string-match ":[^:]+$" gname)
4302 (substring gname (1+ (match-beginning 0)))
4305 (defsubst gnus-server-add-address (method)
4306 (let ((method-name (symbol-name (car method))))
4307 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4308 (not (assq (intern (concat method-name "-address")) method)))
4309 (append method (list (list (intern (concat method-name "-address"))
4313 (defsubst gnus-server-get-method (group method)
4314 ;; Input either a server name, and extended server name, or a
4315 ;; select method, and return a select method.
4316 (cond ((stringp method)
4317 (gnus-server-to-method method))
4318 ((and (stringp (car method)) group)
4319 (gnus-server-extend-method group method))
4321 (gnus-server-add-address method))))
4323 (defun gnus-server-to-method (server)
4324 "Map virtual server names to select methods."
4325 (or (and (equal server "native") gnus-select-method)
4326 (cdr (assoc server gnus-server-alist))))
4328 (defun gnus-group-prefixed-name (group method)
4329 "Return the whole name from GROUP and METHOD."
4330 (and (stringp method) (setq method (gnus-server-to-method method)))
4331 (concat (format "%s" (car method))
4333 (assoc (format "%s" (car method)) (gnus-methods-using 'address))
4334 (not (string= (nth 1 method) "")))
4335 (concat "+" (nth 1 method)))
4338 (defun gnus-group-real-prefix (group)
4339 "Return the prefix of the current group name."
4340 (if (string-match "^[^:]+:" group)
4341 (substring group 0 (match-end 0))
4344 (defun gnus-group-method-name (group)
4345 "Return the method used for selecting GROUP."
4346 (let ((prefix (gnus-group-real-prefix group)))
4347 (if (equal prefix "")
4349 (if (string-match "^[^\\+]+\\+" prefix)
4350 (list (intern (substring prefix 0 (1- (match-end 0))))
4351 (substring prefix (match-end 0) (1- (length prefix))))
4352 (list (intern (substring prefix 0 (1- (length prefix)))) "")))))
4354 (defsubst gnus-secondary-method-p (method)
4355 "Return whether METHOD is a secondary select method."
4356 (let ((methods gnus-secondary-select-methods)
4357 (gmethod (gnus-server-get-method nil method)))
4359 (not (equal (gnus-server-get-method nil (car methods))
4361 (setq methods (cdr methods)))
4364 (defun gnus-group-foreign-p (group)
4365 "Say whether a group is foreign or not."
4366 (and (not (gnus-group-native-p group))
4367 (not (gnus-group-secondary-p group))))
4369 (defun gnus-group-native-p (group)
4370 "Say whether the group is native or not."
4371 (not (string-match ":" group)))
4373 (defun gnus-group-secondary-p (group)
4374 "Say whether the group is secondary or not."
4375 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4377 (defun gnus-group-get-parameter (group &optional symbol)
4378 "Returns the group parameters for GROUP.
4379 If SYMBOL, return the value of that symbol in the group parameters."
4380 (let ((params (gnus-info-params (gnus-get-info group))))
4382 (gnus-group-parameter-value params symbol)
4385 (defun gnus-group-parameter-value (params symbol)
4386 "Return the value of SYMBOL in group PARAMS."
4387 (or (car (memq symbol params)) ; It's either a simple symbol
4388 (cdr (assq symbol params)))) ; or a cons.
4390 (defun gnus-group-add-parameter (group param)
4391 "Add parameter PARAM to GROUP."
4392 (let ((info (gnus-get-info group)))
4394 () ; This is a dead group. We just ignore it.
4395 ;; Cons the new param to the old one and update.
4396 (gnus-group-set-info (cons param (gnus-info-params info))
4399 (defun gnus-group-add-score (group &optional score)
4400 "Add SCORE to the GROUP score.
4401 If SCORE is nil, add 1 to the score of GROUP."
4402 (let ((info (gnus-get-info group)))
4403 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1)))))
4405 (defun gnus-summary-bubble-group ()
4406 "Increase the score of the current group.
4407 This is a handy function to add to `gnus-summary-exit-hook' to
4408 increase the score of each group you read."
4409 (gnus-group-add-score gnus-newsgroup-name))
4411 (defun gnus-group-set-info (info &optional method-only-group part)
4412 (let* ((entry (gnus-gethash
4413 (or method-only-group (gnus-info-group info))
4414 gnus-newsrc-hashtb))
4416 (info (if method-only-group (nth 2 entry) info)))
4417 (when method-only-group
4419 (error "Trying to change non-existent group %s" method-only-group))
4420 ;; We have recevied parts of the actual group info - either the
4421 ;; select method or the group parameters. We first check
4422 ;; whether we have to extend the info, and if so, do that.
4423 (let ((len (length info))
4424 (total (if (eq part 'method) 5 6)))
4426 (setcdr (nthcdr (1- len) info)
4427 (make-list (- total len) nil)))
4428 ;; Then we enter the new info.
4429 (setcar (nthcdr (1- total) info) part-info)))
4431 ;; This is a new group, so we just create it.
4433 (set-buffer gnus-group-buffer)
4434 (if (gnus-info-method info)
4435 ;; It's a foreign group...
4436 (gnus-group-make-group
4437 (gnus-group-real-name (gnus-info-group info))
4438 (prin1-to-string (car (gnus-info-method info)))
4439 (nth 1 (gnus-info-method info)))
4440 ;; It's a native group.
4441 (gnus-group-make-group (gnus-info-group info)))
4442 (gnus-message 6 "Note: New group created")
4444 (gnus-gethash (gnus-group-prefixed-name
4445 (gnus-group-real-name (gnus-info-group info))
4446 (or (gnus-info-method info) gnus-select-method))
4447 gnus-newsrc-hashtb))))
4448 ;; Whether it was a new group or not, we now have the entry, so we
4449 ;; can do the update.
4452 (setcar (nthcdr 2 entry) info)
4453 (when (and (not (eq (car entry) t))
4454 (gnus-active (gnus-info-group info)))
4455 (let ((marked (gnus-info-marks info)))
4456 (setcar entry (length (gnus-list-of-unread-articles
4458 (error "No such group: %s" (gnus-info-group info)))))
4460 (defun gnus-group-set-method-info (group select-method)
4461 (gnus-group-set-info select-method group 'method))
4463 (defun gnus-group-set-params-info (group params)
4464 (gnus-group-set-info params group 'params))
4466 (defun gnus-group-update-group-line ()
4467 "Update the current line in the group buffer."
4468 (let* ((buffer-read-only nil)
4469 (group (gnus-group-group-name))
4470 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
4472 (not (gnus-ephemeral-group-p group))
4474 (concat "(gnus-group-set-info '"
4475 (prin1-to-string (nth 2 entry)) ")")))
4477 (gnus-group-insert-group-line-info group)
4479 (gnus-group-position-point)))
4481 (defun gnus-group-insert-group-line-info (group)
4482 "Insert GROUP on the current line."
4483 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4487 ;; (Un)subscribed group.
4488 (setq info (nth 2 entry))
4489 (gnus-group-insert-group-line
4490 group (gnus-info-level info) (gnus-info-marks info)
4491 (or (car entry) t) (gnus-info-method info)))
4492 ;; This group is dead.
4493 (gnus-group-insert-group-line
4495 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4497 (if (setq active (gnus-active group))
4498 (- (1+ (cdr active)) (car active)) 0)
4501 ;; Dummy function redefined when running under XEmacs.
4502 (defalias 'gnus-group-remove-excess-properties 'ignore)
4504 (defun gnus-group-insert-group-line
4505 (gnus-tmp-group gnus-tmp-level gnus-tmp-marked number
4507 "Insert a group line in the group buffer."
4508 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4509 (gnus-tmp-number-total
4511 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4513 (gnus-tmp-number-of-unread
4514 (if (numberp number) (int-to-string (max 0 number))
4516 (gnus-tmp-number-of-read
4517 (if (numberp number)
4518 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4520 (gnus-tmp-subscribed
4521 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4522 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4523 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4525 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4526 (gnus-tmp-newsgroup-description
4527 (if gnus-description-hashtb
4528 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4531 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4532 (gnus-tmp-moderated-string
4533 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4535 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4536 (gnus-tmp-news-server (or (car (cdr gnus-tmp-method)) ""))
4537 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4538 (gnus-tmp-news-method-string
4540 (format "(%s:%s)" (car gnus-tmp-method)
4541 (car (cdr gnus-tmp-method))) ""))
4542 (gnus-tmp-marked-mark
4543 (if (and (numberp number)
4545 (cdr (assq 'tick gnus-tmp-marked)))
4548 (cond ((eq number t) "*" )
4549 ((numberp number) (int-to-string number))
4551 (gnus-tmp-process-marked
4552 (if (member gnus-tmp-group gnus-group-marked)
4553 gnus-process-mark ? ))
4554 (buffer-read-only nil)
4555 header) ; passed as parameter to user-funcs.
4557 (add-text-properties
4561 (eval gnus-group-line-format-spec))
4562 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
4563 gnus-unread ,(if (numberp number)
4564 (string-to-int gnus-tmp-number-of-unread)
4566 gnus-marked ,gnus-tmp-marked-mark
4567 gnus-level ,gnus-tmp-level))
4568 ;; Allow XEmacs to remove front-sticky text properties.
4569 (gnus-group-remove-excess-properties)))
4571 (defun gnus-group-update-group (group &optional visible-only)
4572 "Update all lines where GROUP appear.
4573 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
4576 (set-buffer gnus-group-buffer)
4577 ;; The buffer may be narrowed.
4580 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
4582 found buffer-read-only visible)
4583 ;; Enter the current status into the dribble buffer.
4584 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
4585 (if (and entry (not (gnus-ephemeral-group-p group)))
4587 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
4589 ;; Find all group instances. If topics are in use, each group
4590 ;; may be listed in more than once.
4591 (while (setq loc (text-property-any
4592 loc (point-max) 'gnus-group ident))
4596 (gnus-group-insert-group-line-info group)
4597 (setq loc (1+ loc)))
4598 (if (or found visible-only)
4600 ;; No such line in the buffer, find out where it's supposed to
4601 ;; go, and insert it there (or at the end of the buffer).
4602 ;; Fix by Per Abrahamsen <amanda@iesd.auc.dk>.
4603 (let ((entry (cdr (cdr (gnus-gethash group gnus-newsrc-hashtb)))))
4604 (while (and entry (car entry)
4608 (point-min) (point-max)
4609 'gnus-group (gnus-intern-safe
4611 gnus-active-hashtb)))))
4612 (setq entry (cdr entry)))
4613 (or entry (goto-char (point-max))))
4614 ;; Finally insert the line.
4615 (gnus-group-insert-group-line-info group))
4616 (gnus-group-set-mode-line)))))
4618 (defun gnus-group-set-mode-line ()
4619 (when (memq 'group gnus-updated-mode-lines)
4620 (let* ((gformat (or gnus-group-mode-line-format-spec
4621 (setq gnus-group-mode-line-format-spec
4623 gnus-group-mode-line-format
4624 gnus-group-mode-line-format-alist))))
4625 (gnus-tmp-news-server (car (cdr gnus-select-method)))
4626 (gnus-tmp-news-method (car gnus-select-method))
4628 header ;Dummy binding for user-defined formats
4629 ;; Get the resulting string.
4630 (mode-string (eval gformat)))
4631 ;; If the line is too long, we chop it off.
4632 (when (> (length mode-string) max-len)
4633 (setq mode-string (substring mode-string 0 (- max-len 4))))
4635 (setq mode-line-buffer-identification (list mode-string))
4636 (set-buffer-modified-p t)))))
4638 (defun gnus-group-group-name ()
4639 "Get the name of the newsgroup on the current line."
4640 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
4641 (and group (symbol-name group))))
4643 (defun gnus-group-group-level ()
4644 "Get the level of the newsgroup on the current line."
4645 (get-text-property (gnus-point-at-bol) 'gnus-level))
4647 (defun gnus-group-group-unread ()
4648 "Get the number of unread articles of the newsgroup on the current line."
4649 (get-text-property (gnus-point-at-bol) 'gnus-unread))
4651 (defun gnus-group-search-forward (&optional backward all level first-too)
4652 "Find the next newsgroup with unread articles.
4653 If BACKWARD is non-nil, find the previous newsgroup instead.
4654 If ALL is non-nil, just find any newsgroup.
4655 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
4657 If FIRST-TOO, the current line is also eligible as a target."
4658 (let ((way (if backward -1 1))
4659 (low gnus-level-killed)
4662 (if (and backward (progn (beginning-of-line)) (bobp))
4664 (or first-too (forward-line way))
4672 (get-text-property (point) 'gnus-unread)))
4673 (and (numberp unread) (> unread 0)))
4674 (setq lev (get-text-property (point)
4676 (<= lev gnus-level-subscribed)))
4678 (and (setq lev (get-text-property (point)
4687 (zerop (forward-line way)))))
4689 (progn (gnus-group-position-point) t)
4690 (goto-char (or pos beg))
4693 ;;; Gnus group mode commands
4697 (defun gnus-group-mark-group (n &optional unmark no-advance)
4698 "Mark the current group."
4700 (let ((buffer-read-only nil)
4704 (setq group (gnus-group-group-name))
4708 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
4713 (setq gnus-group-marked (delete group gnus-group-marked)))
4715 (setq gnus-group-marked
4716 (cons group (delete group gnus-group-marked))))
4718 (or no-advance (zerop (gnus-group-next-group 1))))
4720 (gnus-summary-position-point)
4723 (defun gnus-group-unmark-group (n)
4724 "Remove the mark from the current group."
4726 (gnus-group-mark-group n 'unmark))
4728 (defun gnus-group-mark-region (unmark beg end)
4729 "Mark all groups between point and mark.
4730 If UNMARK, remove the mark instead."
4731 (interactive "P\nr")
4732 (let ((num (count-lines beg end)))
4735 (- num (gnus-group-mark-group num unmark)))))
4737 (defun gnus-group-mark-regexp (regexp)
4738 "Mark all groups that match some regexp."
4739 (interactive "sMark (regexp): ")
4740 (let ((alist (cdr gnus-newsrc-alist))
4743 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
4744 (gnus-group-set-mark group)))))
4746 (defun gnus-group-remove-mark (group)
4747 (if (gnus-group-goto-group group)
4749 (gnus-group-mark-group 1 'unmark t))
4750 (setq gnus-group-marked
4751 (delete group gnus-group-marked))))
4753 (defun gnus-group-set-mark (group)
4754 "Set the process mark on GROUP."
4755 (if (gnus-group-goto-group group)
4757 (gnus-group-mark-group 1 nil t))
4758 (setq gnus-group-marked
4759 (cons group (delete group gnus-group-marked)))))
4761 ;; Return a list of groups to work on. Take into consideration N (the
4762 ;; prefix) and the list of marked groups.
4763 (defun gnus-group-process-prefix (n)
4766 (setq n (prefix-numeric-value n))
4767 ;; There is a prefix, so we return a list of the N next
4769 (let ((way (if (< n 0) -1 1))
4774 (setq group (gnus-group-group-name)))
4775 (setq groups (cons group groups))
4777 (gnus-group-next-group way)))
4779 ((and (boundp 'transient-mark-mode)
4782 ;; Work on the region between point and mark.
4783 (let ((max (max (point) (mark)))
4786 (goto-char (min (point) (mark)))
4789 (push (gnus-group-group-name) groups)
4790 (zerop (gnus-group-next-group 1))
4792 (nreverse groups))))
4794 ;; No prefix, but a list of marked articles.
4795 (reverse gnus-group-marked))
4797 ;; Neither marked articles or a prefix, so we return the
4799 (let ((group (gnus-group-group-name)))
4800 (and group (list group))))))
4802 ;; Selecting groups.
4804 (defun gnus-group-read-group (&optional all no-article group)
4805 "Read news in this newsgroup.
4806 If the prefix argument ALL is non-nil, already read articles become
4807 readable. IF ALL is a number, fetch this number of articles. If the
4808 optional argument NO-ARTICLE is non-nil, no article will be
4809 auto-selected upon group entry. If GROUP is non-nil, fetch that
4812 (let ((group (or group (gnus-group-group-name)))
4813 number active marked entry)
4814 (or group (error "No group on current line"))
4815 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
4816 group gnus-newsrc-hashtb)))))
4817 ;; This group might be a dead group. In that case we have to get
4818 ;; the number of unread articles from `gnus-active-hashtb'.
4820 (cond ((numberp all) all)
4822 ((setq active (gnus-active group))
4823 (- (1+ (cdr active)) (car active)))))
4824 (gnus-summary-read-group
4825 group (or all (and (numberp number)
4826 (zerop (+ number (length (cdr (assq 'tick marked)))
4827 (length (cdr (assq 'dormant marked)))))))
4830 (defun gnus-group-select-group (&optional all)
4831 "Select this newsgroup.
4832 No article is selected automatically.
4833 If ALL is non-nil, already read articles become readable.
4834 If ALL is a number, fetch this number of articles."
4836 (gnus-group-read-group all t))
4838 (defun gnus-group-quick-select-group (&optional all)
4839 "Select the current group \"quickly\".
4840 This means that no highlighting or scoring will be performed."
4843 gnus-score-find-score-files-function
4844 gnus-apply-kill-hook
4845 gnus-summary-expunge-below)
4846 (gnus-group-read-group all t)))
4848 (defun gnus-group-visible-select-group (&optional all)
4849 "Select the current group without hiding any articles."
4851 (let ((gnus-inhibit-limiting t))
4852 (gnus-group-read-group all t)))
4855 (defun gnus-fetch-group (group)
4856 "Start Gnus if necessary and enter GROUP.
4857 Returns whether the fetching was successful or not."
4858 (interactive "sGroup name: ")
4859 (or (get-buffer gnus-group-buffer)
4861 (gnus-group-select-group))
4863 ;; Enter a group that is not in the group buffer. Non-nil is returned
4864 ;; if selection was successful.
4865 (defun gnus-group-read-ephemeral-group
4866 (group method &optional activate quit-config)
4867 (let ((group (if (gnus-group-foreign-p group) group
4868 (gnus-group-prefixed-name group method)))
4869 (cur (current-buffer)))
4872 (list t nil (list group gnus-level-default-subscribed nil nil
4876 (if quit-config quit-config
4877 (cons (current-buffer) 'summary)))))))
4879 (set-buffer gnus-group-buffer)
4880 (or (gnus-check-server method)
4881 (error "Unable to contact server: %s" (gnus-status-message method)))
4882 (if activate (or (gnus-request-group group)
4883 (error "Couldn't request group")))
4885 (gnus-group-read-group t t group)
4888 (not (equal (current-buffer) cur))))
4890 (defun gnus-group-jump-to-group (group)
4891 "Jump to newsgroup GROUP."
4893 (list (completing-read
4894 "Group: " gnus-active-hashtb nil
4895 (memq gnus-select-method gnus-have-read-active-file))))
4897 (if (equal group "")
4898 (error "Empty group name"))
4900 (let ((b (text-property-any
4901 (point-min) (point-max)
4902 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4904 ;; Either go to the line in the group buffer...
4906 ;; ... or insert the line.
4909 (gnus-activate-group group)
4910 (error "%s error: %s" group (gnus-status-message group)))
4912 (gnus-group-update-group group)
4913 (goto-char (text-property-any
4914 (point-min) (point-max)
4915 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
4916 ;; Adjust cursor point.
4917 (gnus-group-position-point))
4919 (defun gnus-group-goto-group (group)
4920 "Goto to newsgroup GROUP."
4922 (let ((b (text-property-any (point-min) (point-max)
4923 'gnus-group (gnus-intern-safe
4924 group gnus-active-hashtb))))
4925 (and b (goto-char b)))))
4927 (defun gnus-group-next-group (n)
4928 "Go to next N'th newsgroup.
4929 If N is negative, search backward instead.
4930 Returns the difference between N and the number of skips actually
4933 (gnus-group-next-unread-group n t))
4935 (defun gnus-group-next-unread-group (n &optional all level)
4936 "Go to next N'th unread newsgroup.
4937 If N is negative, search backward instead.
4938 If ALL is non-nil, choose any newsgroup, unread or not.
4939 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
4940 such group can be found, the next group with a level higher than
4942 Returns the difference between N and the number of skips actually
4945 (let ((backward (< n 0))
4948 (gnus-group-search-forward
4949 backward (or (not gnus-group-goto-unread) all) level))
4951 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
4952 (if level " on this level or higher" "")))
4955 (defun gnus-group-prev-group (n)
4956 "Go to previous N'th newsgroup.
4957 Returns the difference between N and the number of skips actually
4960 (gnus-group-next-unread-group (- n) t))
4962 (defun gnus-group-prev-unread-group (n)
4963 "Go to previous N'th unread newsgroup.
4964 Returns the difference between N and the number of skips actually
4967 (gnus-group-next-unread-group (- n)))
4969 (defun gnus-group-next-unread-group-same-level (n)
4970 "Go to next N'th unread newsgroup on the same level.
4971 If N is negative, search backward instead.
4972 Returns the difference between N and the number of skips actually
4975 (gnus-group-next-unread-group n t (gnus-group-group-level))
4976 (gnus-group-position-point))
4978 (defun gnus-group-prev-unread-group-same-level (n)
4979 "Go to next N'th unread newsgroup on the same level.
4980 Returns the difference between N and the number of skips actually
4983 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
4984 (gnus-group-position-point))
4986 (defun gnus-group-best-unread-group (&optional exclude-group)
4987 "Go to the group with the highest level.
4988 If EXCLUDE-GROUP, do not go to that group."
4990 (goto-char (point-min))
4993 (while (setq unread (get-text-property (point) 'gnus-unread))
4994 (if (and (numberp unread) (> unread 0))
4996 (if (and (< (get-text-property (point) 'gnus-level) best)
4997 (or (not exclude-group)
4998 (not (equal exclude-group (gnus-group-group-name)))))
5000 (setq best (get-text-property (point) 'gnus-level))
5001 (setq best-point (point))))))
5003 (if best-point (goto-char best-point))
5004 (gnus-summary-position-point)
5005 (and best-point (gnus-group-group-name))))
5007 (defun gnus-group-first-unread-group ()
5008 "Go to the first group with unread articles."
5011 (let ((opoint (point))
5013 (goto-char (point-min))
5014 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5015 (and (numberp unread) ; Not a topic.
5016 (not (zerop unread))) ; Has unread articles.
5017 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5020 nil)) ; Not success.
5021 (gnus-group-position-point)))
5023 (defun gnus-group-enter-server-mode ()
5024 "Jump to the server buffer."
5026 (gnus-enter-server-buffer))
5028 (defun gnus-group-make-group (name &optional method address)
5029 "Add a new newsgroup.
5030 The user will be prompted for a NAME, for a select METHOD, and an
5034 (read-string "Group name: ")
5037 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5039 (if (assoc method gnus-valid-select-methods)
5041 (if (memq 'prompt-address
5042 (assoc method gnus-valid-select-methods))
5043 (read-string "Address: ")
5045 (list method nil)))))
5048 (set-buffer gnus-group-buffer)
5049 (let* ((meth (and method (if address (list (intern method) address)
5051 (nname (if method (gnus-group-prefixed-name name meth) name))
5053 (and (gnus-gethash nname gnus-newsrc-hashtb)
5054 (error "Group %s already exists" nname))
5055 (gnus-group-change-level
5056 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5057 gnus-level-default-subscribed gnus-level-killed
5058 (and (gnus-group-group-name)
5059 (gnus-gethash (gnus-group-group-name)
5060 gnus-newsrc-hashtb))
5062 (gnus-set-active nname (cons 1 0))
5063 (or (gnus-ephemeral-group-p name)
5065 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5066 (gnus-group-insert-group-line-info nname)
5068 (if (assoc method gnus-valid-select-methods)
5069 (require (intern method)))
5070 (and (gnus-check-backend-function 'request-create-group nname)
5071 (gnus-request-create-group nname))
5074 (defun gnus-group-delete-group (group &optional force)
5075 "Delete the current group.
5076 If FORCE (the prefix) is non-nil, all the articles in the group will
5077 be deleted. This is \"deleted\" as in \"removed forever from the face
5078 of the Earth\". There is no undo."
5080 (list (gnus-group-group-name)
5081 current-prefix-arg))
5082 (or group (error "No group to rename"))
5083 (or (gnus-check-backend-function 'request-delete-group group)
5084 (error "This backend does not support group deletion"))
5086 (if (not (gnus-yes-or-no-p
5088 "Do you really want to delete %s%s? "
5089 group (if force " and all its contents" ""))))
5091 (gnus-message 6 "Deleting group %s..." group)
5092 (if (not (gnus-request-delete-group group force))
5094 (gnus-message 3 "Couldn't delete group %s" group)
5096 (gnus-message 6 "Deleting group %s...done" group)
5097 (gnus-group-goto-group group)
5098 (gnus-group-kill-group 1 t)
5100 (gnus-group-position-point)))
5102 (defun gnus-group-rename-group (group new-name)
5105 (gnus-group-group-name)
5107 (or (gnus-check-backend-function
5108 'request-rename-group (gnus-group-group-name))
5109 (error "This backend does not support renaming groups"))
5110 (read-string "New group name: "))))
5112 (or (gnus-check-backend-function 'request-rename-group group)
5113 (error "This backend does not support renaming groups"))
5115 (or group (error "No group to rename"))
5116 (and (string-match "^[ \t]*$" new-name)
5117 (error "Not a valid group name"))
5119 ;; We find the proper prefixed name.
5121 (gnus-group-prefixed-name
5122 (gnus-group-real-name new-name)
5123 (gnus-info-method (gnus-get-info group))))
5125 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5127 (if (not (gnus-request-rename-group group new-name))
5129 (gnus-message 3 "Couldn't rename group %s to %s" group new-name)
5131 ;; We rename the group internally by killing it...
5132 (gnus-group-goto-group group)
5133 (gnus-group-kill-group)
5134 ;; ... changing its name ...
5135 (setcar (cdr (car gnus-list-of-killed-groups))
5137 ;; ... and then yanking it. Magic!
5138 (gnus-group-yank-group)
5139 (gnus-set-active new-name (gnus-active group))
5140 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5142 (gnus-group-position-point)))
5145 (defun gnus-group-edit-group (group &optional part)
5146 "Edit the group on the current line."
5147 (interactive (list (gnus-group-group-name)))
5148 (let ((done-func '(lambda ()
5149 "Exit editing mode and update the information."
5151 (gnus-group-edit-group-done 'part 'group)))
5152 (part (or part 'info))
5153 (winconf (current-window-configuration))
5155 (or group (error "No group on current line"))
5156 (or (setq info (gnus-get-info group))
5157 (error "Killed group; can't be edited"))
5158 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5159 (gnus-configure-windows 'edit-group)
5160 (gnus-add-current-to-buffer-list)
5162 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5163 (use-local-map (copy-keymap emacs-lisp-mode-map))
5164 (local-set-key "\C-c\C-c" done-func)
5165 (make-local-variable 'gnus-prev-winconf)
5166 (setq gnus-prev-winconf winconf)
5167 ;; We modify the func to let it know what part it is editing.
5168 (setcar (cdr (nth 4 done-func)) (list 'quote part))
5169 (setcar (cdr (cdr (nth 4 done-func))) group)
5174 ";; Type `C-c C-c' after editing the select method.\n\n")
5176 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5178 ";; Type `C-c C-c' after editing the group info.\n\n")))
5181 (cond ((eq part 'method)
5182 (or (gnus-info-method info) "native"))
5184 (gnus-info-params info))
5188 (defun gnus-group-edit-group-method (group)
5189 "Edit the select method of GROUP."
5190 (interactive (list (gnus-group-group-name)))
5191 (gnus-group-edit-group group 'method))
5193 (defun gnus-group-edit-group-parameters (group)
5194 "Edit the group parameters of GROUP."
5195 (interactive (list (gnus-group-group-name)))
5196 (gnus-group-edit-group group 'params))
5198 (defun gnus-group-edit-group-done (part group)
5199 "Get info from buffer, update variables and jump to the group buffer."
5200 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5201 (goto-char (point-min))
5202 (let* ((form (read (current-buffer)))
5203 (winconf gnus-prev-winconf)
5204 (new-group (when (eq part 'info)
5205 (if (or (not (nth 4 form))
5207 gnus-select-method (nth 4 form)))
5208 (gnus-group-real-name (car form))
5209 (gnus-group-prefixed-name
5210 (gnus-group-real-name (car form)) (nth 4 form))))))
5214 (when new-group (setcar form new-group))
5215 (gnus-group-set-info form))
5216 (gnus-group-set-info form group part))
5217 (kill-buffer (current-buffer))
5218 (and winconf (set-window-configuration winconf))
5219 (set-buffer gnus-group-buffer)
5220 (when (and new-group
5221 (not (equal new-group group)))
5222 (when (gnus-group-goto-group group)
5223 (gnus-group-kill-group 1))
5224 (gnus-activate-group new-group))
5225 (gnus-group-update-group (or new-group group))
5226 (gnus-group-position-point)))
5228 (defun gnus-group-make-help-group ()
5229 "Create the Gnus documentation group."
5231 (let ((path load-path)
5232 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5234 (and (gnus-gethash name gnus-newsrc-hashtb)
5235 (error "Documentation group already exists"))
5237 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5239 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5241 (setq file (concat (file-name-directory
5242 (directory-file-name dir))
5243 "etc/gnus-tut.txt"))))
5246 (message "Couldn't find doc group")
5247 (gnus-group-make-group
5248 (gnus-group-real-name name)
5250 (list 'nndoc-address file)
5251 (list 'nndoc-article-type 'mbox)))))
5252 (gnus-group-position-point))
5254 (defun gnus-group-make-doc-group (file type)
5255 "Create a group that uses a single file as the source."
5257 (list (read-file-name "File name: ")
5258 (and current-prefix-arg 'ask)))
5259 (when (eq type 'ask)
5264 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5266 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5267 ((= char ?b) 'babyl)
5268 ((= char ?d) 'digest)
5269 ((= char ?f) 'forward)
5271 (t (setq err (format "%c unknown. " char))
5274 (let* ((file (expand-file-name file))
5275 (name (gnus-generate-new-group-name
5276 (gnus-group-prefixed-name
5277 (file-name-nondirectory file) '(nndoc "")))))
5278 (gnus-group-make-group
5279 (gnus-group-real-name name)
5281 (list 'nndoc-address file)
5282 (list 'nndoc-article-type (or type 'guess))))
5284 (gnus-group-position-point)))
5286 (defun gnus-group-make-archive-group (&optional all)
5287 "Create the (ding) Gnus archive group of the most recent articles.
5288 Given a prefix, create a full group."
5290 (let ((group (gnus-group-prefixed-name
5291 (if all "ding.archives" "ding.recent") '(nndir ""))))
5292 (and (gnus-gethash group gnus-newsrc-hashtb)
5293 (error "Archive group already exists"))
5294 (gnus-group-make-group
5295 (gnus-group-real-name group)
5296 (list 'nndir (if all "hpc" "edu")
5297 (list 'nndir-directory
5298 (if all gnus-group-archive-directory
5299 gnus-group-recent-archive-directory)))))
5301 (gnus-group-position-point))
5303 (defun gnus-group-make-directory-group (dir)
5304 "Create an nndir group.
5305 The user will be prompted for a directory. The contents of this
5306 directory will be used as a newsgroup. The directory should contain
5307 mail messages or news articles in files that have numeric names."
5309 (list (read-file-name "Create group from directory: ")))
5310 (or (file-exists-p dir) (error "No such directory"))
5311 (or (file-directory-p dir) (error "Not a directory"))
5315 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5317 (gnus-group-prefixed-name
5318 (concat (file-name-as-directory (directory-file-name dir))
5321 (setq ext (format "<%d>" (setq i (1+ i)))))
5322 (gnus-group-make-group
5323 (gnus-group-real-name group)
5324 (list 'nndir group (list 'nndir-directory dir))))
5326 (gnus-group-position-point))
5328 (defun gnus-group-make-kiboze-group (group address scores)
5329 "Create an nnkiboze group.
5330 The user will be prompted for a name, a regexp to match groups, and
5331 score file entries for articles to include in the group."
5334 (read-string "nnkiboze group name: ")
5335 (read-string "Source groups (regexp): ")
5336 (let ((headers (mapcar (lambda (group) (list group))
5337 '("subject" "from" "number" "date" "message-id"
5338 "references" "chars" "lines" "xref"
5339 "followup" "all" "body" "head")))
5340 scores header regexp regexps)
5341 (while (not (equal "" (setq header (completing-read
5342 "Match on header: " headers nil t))))
5344 (while (not (equal "" (setq regexp (read-string
5345 (format "Match on %s (string): "
5347 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5348 (setq scores (cons (cons header regexps) scores)))
5350 (gnus-group-make-group group "nnkiboze" address)
5352 (gnus-set-work-buffer)
5353 (let (emacs-lisp-mode-hook)
5354 (pp scores (current-buffer)))
5355 (write-region (point-min) (point-max)
5356 (gnus-score-file-name (concat "nnkiboze:" group))))
5358 (gnus-group-position-point))
5360 (defun gnus-group-add-to-virtual (n vgroup)
5361 "Add the current group to a virtual group."
5363 (list current-prefix-arg
5364 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5366 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5367 (error "%s is not an nnvirtual group" vgroup))
5368 (let* ((groups (gnus-group-process-prefix n))
5369 (method (gnus-info-method (gnus-get-info vgroup))))
5370 (setcar (cdr method)
5372 (nth 1 method) "\\|"
5375 (gnus-group-remove-mark s)
5376 (concat "\\(^" (regexp-quote s) "$\\)"))
5378 (gnus-group-position-point))
5380 (defun gnus-group-make-empty-virtual (group)
5381 "Create a new, fresh, empty virtual group."
5382 (interactive "sCreate new, empty virtual group: ")
5383 (let* ((method (list 'nnvirtual "^$"))
5384 (pgroup (gnus-group-prefixed-name group method)))
5385 ;; Check whether it exists already.
5386 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5387 (error "Group %s already exists." pgroup))
5388 ;; Subscribe the new group after the group on the current line.
5389 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5390 (gnus-group-update-group pgroup)
5392 (gnus-group-position-point)))
5394 (defun gnus-group-enter-directory (dir)
5395 "Enter an ephemeral nneething group."
5396 (interactive "DDirectory to read: ")
5397 (let* ((method (list 'nneething dir))
5398 (leaf (gnus-group-prefixed-name
5399 (file-name-nondirectory (directory-file-name dir))
5401 (name (gnus-generate-new-group-name leaf)))
5402 (let ((nneething-read-only t))
5403 (or (gnus-group-read-ephemeral-group
5405 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5407 (error "Couldn't enter %s" dir)))))
5409 ;; Group sorting commands
5410 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5412 (defun gnus-group-sort-groups (func &optional reverse)
5413 "Sort the group buffer according to FUNC.
5414 If REVERSE, reverse the sorting order."
5415 (interactive (list gnus-group-sort-function
5416 current-prefix-arg))
5417 (unless (listp func)
5418 (setq func (list func)))
5419 ;; We peel off the dummy group from the alist.
5420 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5421 (pop gnus-newsrc-alist))
5424 (setq gnus-newsrc-alist
5425 (sort gnus-newsrc-alist (pop func))))
5427 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5428 ;; Regenerate the hash table.
5429 (gnus-make-hashtable-from-newsrc-alist)
5430 (gnus-group-list-groups))
5432 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5433 "Sort the group buffer alphabetically by group name.
5434 If REVERSE, sort in reverse order."
5436 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5438 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5439 "Sort the group buffer by number of unread articles.
5440 If REVERSE, sort in reverse order."
5442 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5444 (defun gnus-group-sort-groups-by-level (&optional reverse)
5445 "Sort the group buffer by group level.
5446 If REVERSE, sort in reverse order."
5448 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5450 (defun gnus-group-sort-groups-by-score (&optional reverse)
5451 "Sort the group buffer by group score.
5452 If REVERSE, sort in reverse order."
5454 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5456 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5457 "Sort the group buffer by group rank.
5458 If REVERSE, sort in reverse order."
5460 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5462 (defun gnus-group-sort-groups-by-method (&optional reverse)
5463 "Sort the group buffer alphabetically by backend name.
5464 If REVERSE, sort in reverse order."
5466 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
5468 (defun gnus-group-sort-by-alphabet (info1 info2)
5469 "Sort alphabetically."
5470 (string< (gnus-info-group info1) (gnus-info-group info2)))
5472 (defun gnus-group-sort-by-unread (info1 info2)
5473 "Sort by number of unread articles."
5474 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
5475 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
5476 (< (or (and (numberp n1) n1) 0)
5477 (or (and (numberp n2) n2) 0))))
5479 (defun gnus-group-sort-by-level (info1 info2)
5481 (< (gnus-info-level info1) (gnus-info-level info2)))
5483 (defun gnus-group-sort-by-method (info1 info2)
5484 "Sort alphabetically by backend name."
5485 (string< (symbol-name (car (gnus-find-method-for-group
5486 (gnus-info-group info1) info1)))
5487 (symbol-name (car (gnus-find-method-for-group
5488 (gnus-info-group info2) info2)))))
5490 (defun gnus-group-sort-by-score (info1 info2)
5491 "Sort by group score."
5492 (< (gnus-info-score info1) (gnus-info-score info2)))
5494 (defun gnus-group-sort-by-rank (info1 info2)
5495 "Sort by level and score."
5496 (let ((level1 (gnus-info-level info1))
5497 (level2 (gnus-info-level info2)))
5498 (or (< level1 level2)
5499 (and (= level1 level2)
5500 (< (gnus-info-score info1) (gnus-info-score info2))))))
5502 ;; Group catching up.
5504 (defun gnus-group-catchup-current (&optional n all)
5505 "Mark all articles not marked as unread in current newsgroup as read.
5506 If prefix argument N is numeric, the ARG next newsgroups will be
5507 caught up. If ALL is non-nil, marked articles will also be marked as
5508 read. Cross references (Xref: header) of articles are ignored.
5509 The difference between N and actual number of newsgroups that were
5510 caught up is returned."
5512 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
5516 "Do you really want to mark all articles as read? "
5517 "Mark all unread articles as read? "))))
5519 (let ((groups (gnus-group-process-prefix n))
5522 ;; Virtual groups have to be given special treatment.
5523 (let ((method (gnus-find-method-for-group (car groups))))
5524 (if (eq 'nnvirtual (car method))
5525 (nnvirtual-catchup-group
5526 (gnus-group-real-name (car groups)) (nth 1 method) all)))
5527 (gnus-group-remove-mark (car groups))
5529 (gnus-group-goto-group (car groups))
5530 (gnus-group-catchup (car groups) all))
5531 (gnus-group-update-group-line)
5532 (setq ret (1+ ret)))
5533 (setq groups (cdr groups)))
5534 (gnus-group-next-unread-group 1)
5537 (defun gnus-group-catchup-current-all (&optional n)
5538 "Mark all articles in current newsgroup as read.
5539 Cross references (Xref: header) of articles are ignored."
5541 (gnus-group-catchup-current n 'all))
5543 (defun gnus-group-catchup (group &optional all)
5544 "Mark all articles in GROUP as read.
5545 If ALL is non-nil, all articles are marked as read.
5546 The return value is the number of articles that were marked as read,
5547 or nil if no action could be taken."
5548 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5550 ;; Do the updating only if the newsgroup isn't killed.
5551 (if (not (numberp (car entry)))
5552 (gnus-message 1 "Can't catch up; non-active group")
5553 ;; Do auto-expirable marks if that's required.
5554 (when (gnus-group-auto-expirable-p group)
5555 (gnus-add-marked-articles
5556 group 'expire (gnus-list-of-unread-articles group))
5558 (let ((marks (nth 3 (nth 2 entry))))
5559 (gnus-add-marked-articles
5560 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
5561 (gnus-add-marked-articles
5562 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
5564 (gnus-update-read-articles group nil)
5565 ;; Also nix out the lists of marks and dormants.
5567 (gnus-add-marked-articles group 'tick nil nil 'force)
5568 (gnus-add-marked-articles group 'dormant nil nil 'force))
5571 (defun gnus-group-expire-articles (&optional n)
5572 "Expire all expirable articles in the current newsgroup."
5574 (let ((groups (gnus-group-process-prefix n))
5577 (error "No groups to expire"))
5579 (setq group (pop groups))
5580 (gnus-group-remove-mark group)
5581 (when (gnus-check-backend-function 'request-expire-articles group)
5582 (gnus-message 6 "Expiring articles in %s..." group)
5583 (let* ((info (gnus-get-info group))
5584 (expirable (if (gnus-group-total-expirable-p group)
5585 (cons nil (gnus-list-of-read-articles group))
5586 (assq 'expire (gnus-info-marks info))))
5587 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
5590 (gnus-compress-sequence
5592 (let ((nnmail-expiry-wait-function nil)
5593 (nnmail-expiry-wait expiry-wait))
5594 (gnus-request-expire-articles
5595 (gnus-uncompress-sequence (cdr expirable)) group))
5596 (gnus-request-expire-articles
5597 (gnus-uncompress-sequence (cdr expirable))
5599 (gnus-message 6 "Expiring articles in %s...done" group)))
5600 (gnus-group-position-point))))
5603 (defun gnus-group-expire-all-groups ()
5604 "Expire all expirable articles in all newsgroups."
5607 (gnus-message 5 "Expiring...")
5608 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
5609 (cdr gnus-newsrc-alist))))
5610 (gnus-group-expire-articles nil)))
5611 (gnus-group-position-point)
5612 (gnus-message 5 "Expiring...done"))
5614 (defun gnus-group-set-current-level (n level)
5615 "Set the level of the next N groups to LEVEL."
5620 (let ((s (read-string
5621 (format "Level (default %s): " (gnus-group-group-level)))))
5622 (if (string-match "^\\s-*$" s)
5623 (int-to-string (gnus-group-group-level))
5625 (or (and (>= level 1) (<= level gnus-level-killed))
5626 (error "Illegal level: %d" level))
5627 (let ((groups (gnus-group-process-prefix n))
5630 (setq group (car groups)
5631 groups (cdr groups))
5632 (gnus-group-remove-mark group)
5633 (gnus-message 6 "Changed level of %s from %d to %d"
5634 group (gnus-group-group-level) level)
5635 (gnus-group-change-level group level
5636 (gnus-group-group-level))
5637 (gnus-group-update-group-line)))
5638 (gnus-group-position-point))
5640 (defun gnus-group-unsubscribe-current-group (&optional n)
5641 "Toggle subscription of the current group.
5642 If given numerical prefix, toggle the N next groups."
5644 (let ((groups (gnus-group-process-prefix n))
5647 (setq group (car groups)
5648 groups (cdr groups))
5649 (gnus-group-remove-mark group)
5650 (gnus-group-unsubscribe-group
5651 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
5652 gnus-level-default-unsubscribed
5653 gnus-level-default-subscribed) t)
5654 (gnus-group-update-group-line))
5655 (gnus-group-next-group 1)))
5657 (defun gnus-group-unsubscribe-group (group &optional level silent)
5658 "Toggle subscription to GROUP.
5659 Killed newsgroups are subscribed. If SILENT, don't try to update the
5662 (list (completing-read
5663 "Group: " gnus-active-hashtb nil
5664 (memq gnus-select-method gnus-have-read-active-file))))
5665 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
5667 ((string-match "^[ \t]$" group)
5668 (error "Empty group name"))
5670 ;; Toggle subscription flag.
5671 (gnus-group-change-level
5672 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
5673 gnus-level-subscribed)
5674 (1+ gnus-level-subscribed)
5675 gnus-level-default-subscribed)))
5677 (gnus-group-update-group group)))
5678 ((and (stringp group)
5679 (or (not (memq gnus-select-method gnus-have-read-active-file))
5680 (gnus-active group)))
5681 ;; Add new newsgroup.
5682 (gnus-group-change-level
5684 (if level level gnus-level-default-subscribed)
5685 (or (and (member group gnus-zombie-list)
5688 (and (gnus-group-group-name)
5689 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
5691 (gnus-group-update-group group)))
5692 (t (error "No such newsgroup: %s" group)))
5693 (gnus-group-position-point)))
5695 (defun gnus-group-transpose-groups (n)
5696 "Move the current newsgroup up N places.
5697 If given a negative prefix, move down instead. The difference between
5698 N and the number of steps taken is returned."
5700 (or (gnus-group-group-name)
5701 (error "No group on current line"))
5702 (gnus-group-kill-group 1)
5704 (forward-line (- n))
5705 (gnus-group-yank-group)
5706 (gnus-group-position-point)))
5708 (defun gnus-group-kill-all-zombies ()
5709 "Kill all zombie newsgroups."
5711 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
5712 (setq gnus-zombie-list nil)
5713 (gnus-group-list-groups))
5715 (defun gnus-group-kill-region (begin end)
5716 "Kill newsgroups in current region (excluding current point).
5717 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
5732 (beginning-of-line) ;Important when LINES < 1
5733 (gnus-group-kill-group lines)))
5735 (defun gnus-group-kill-group (&optional n discard)
5736 "Kill the next N groups.
5737 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
5738 However, only groups that were alive can be yanked; already killed
5739 groups or zombie groups can't be yanked.
5740 The return value is the name of the group that was killed, or a list
5743 (let ((buffer-read-only nil)
5744 (groups (gnus-group-process-prefix n))
5745 group entry level out)
5746 (if (< (length groups) 10)
5747 ;; This is faster when there are few groups.
5749 (push (setq group (pop groups)) out)
5750 (gnus-group-remove-mark group)
5751 (setq level (gnus-group-group-level))
5753 (if (and (not discard)
5754 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
5755 (setq gnus-list-of-killed-groups
5756 (cons (cons (car entry) (nth 2 entry))
5757 gnus-list-of-killed-groups)))
5758 (gnus-group-change-level
5759 (if entry entry group) gnus-level-killed (if entry nil level)))
5760 ;; If there are lots and lots of groups to be killed, we use
5761 ;; this thing instead.
5763 (setq groups (nreverse groups))
5765 (gnus-group-remove-mark (car groups))
5767 (setq entry (gnus-gethash (pop groups) gnus-newsrc-hashtb))
5768 (push (cons (car entry) (nth 2 entry))
5769 gnus-list-of-killed-groups)
5770 (setcdr (cdr entry) (cdr (cdr (cdr entry)))))
5771 (gnus-make-hashtable-from-newsrc-alist)))
5773 (gnus-group-position-point)
5774 (if (< (length out) 2) (car out) (nreverse out))))
5776 (defun gnus-group-yank-group (&optional arg)
5777 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
5778 inserting it before the current newsgroup. The numeric ARG specifies
5779 how many newsgroups are to be yanked. The name of the newsgroup yanked
5780 is returned, or (if several groups are yanked) a list of yanked groups
5783 (setq arg (or arg 1))
5784 (let (info group prev out)
5785 (while (>= (decf arg) 0)
5786 (if (not (setq info (pop gnus-list-of-killed-groups)))
5787 (error "No more newsgroups to yank"))
5788 (push (setq group (nth 1 info)) out)
5789 ;; Find which newsgroup to insert this one before - search
5790 ;; backward until something suitable is found. If there are no
5791 ;; other newsgroups in this buffer, just make this newsgroup the
5793 (setq prev (gnus-group-group-name))
5794 (gnus-group-change-level
5795 info (nth 2 info) gnus-level-killed
5796 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
5798 (gnus-group-insert-group-line-info group))
5800 (gnus-group-position-point)
5801 (if (< (length out) 2) (car out) (nreverse out))))
5803 (defun gnus-group-kill-level (level)
5804 "Kill all groups that is on a certain LEVEL."
5805 (interactive "nKill all groups on level: ")
5807 ((= level gnus-level-zombie)
5808 (setq gnus-killed-list
5809 (nconc gnus-zombie-list gnus-killed-list))
5810 (setq gnus-zombie-list nil))
5811 ((and (< level gnus-level-zombie)
5813 (or gnus-expert-user
5816 "Do you really want to kill all groups on level %d? "
5818 (let* ((prev gnus-newsrc-alist)
5821 (if (= (gnus-info-level level) level)
5822 (setcdr prev (cdr alist))
5824 (setq alist (cdr alist)))
5825 (gnus-make-hashtable-from-newsrc-alist)
5826 (gnus-group-list-groups)))
5828 (error "Can't kill; illegal level: %d" level))))
5830 (defun gnus-group-list-all-groups (&optional arg)
5831 "List all newsgroups with level ARG or lower.
5832 Default is gnus-level-unsubscribed, which lists all subscribed and most
5833 unsubscribed groups."
5835 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
5837 ;; Redefine this to list ALL killed groups if prefix arg used.
5838 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
5839 (defun gnus-group-list-killed (&optional arg)
5840 "List all killed newsgroups in the group buffer.
5841 If ARG is non-nil, list ALL killed groups known to Gnus. This may
5842 entail asking the server for the groups."
5844 ;; Find all possible killed newsgroups if arg.
5846 ;; First make sure active file has been read.
5847 (unless gnus-have-read-active-file
5848 (let ((gnus-read-active-file t))
5849 (gnus-read-active-file)))
5850 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
5851 ;; Go through all newsgroups that are known to Gnus - enlarge kill list
5855 (group (symbol-name sym)))
5856 (if (or (null group)
5857 (gnus-gethash group gnus-killed-hashtb)
5858 (gnus-gethash group gnus-newsrc-hashtb))
5860 (let ((do-sub (gnus-matches-options-n group)))
5861 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
5863 (setq groups (1+ groups))
5864 (setq gnus-killed-list
5865 (cons group gnus-killed-list))
5866 (gnus-sethash group group gnus-killed-hashtb))))))
5867 gnus-active-hashtb))
5868 (if (not gnus-killed-list)
5869 (gnus-message 6 "No killed groups")
5870 (let (gnus-group-list-mode)
5871 (funcall gnus-group-prepare-function
5872 gnus-level-killed t gnus-level-killed))
5873 (goto-char (point-min)))
5874 (gnus-group-position-point))
5876 (defun gnus-group-list-zombies ()
5877 "List all zombie newsgroups in the group buffer."
5879 (if (not gnus-zombie-list)
5880 (gnus-message 6 "No zombie groups")
5881 (let (gnus-group-list-mode)
5882 (funcall gnus-group-prepare-function
5883 gnus-level-zombie t gnus-level-zombie))
5884 (goto-char (point-min)))
5885 (gnus-group-position-point))
5887 (defun gnus-group-list-active ()
5888 "List all groups that are available from the server(s)."
5890 ;; First we make sure that we have really read the active file.
5891 (unless gnus-have-read-active-file
5892 (let ((gnus-read-active-file t))
5893 (gnus-read-active-file)))
5894 ;; Find all groups and sort them.
5900 (and (symbol-value sym)
5901 (setq list (cons (symbol-name sym) list))))
5905 (buffer-read-only nil))
5908 (gnus-group-insert-group-line-info (car groups))
5909 (setq groups (cdr groups)))
5910 (goto-char (point-min))))
5912 (defun gnus-activate-all-groups (level)
5913 "Activate absolutely all groups."
5914 (interactive (list 7))
5915 (let ((gnus-activate-level level)
5916 (gnus-activate-foreign-newsgroups level))
5917 (gnus-group-get-new-news)))
5919 (defun gnus-group-get-new-news (&optional arg)
5920 "Get newly arrived articles.
5921 If ARG is a number, it specifies which levels you are interested in
5922 re-scanning. If ARG is non-nil and not a number, this will force
5923 \"hard\" re-reading of the active files from all servers."
5925 (run-hooks 'gnus-get-new-news-hook)
5926 ;; We might read in new NoCeM messages here.
5927 (and gnus-use-nocem (gnus-nocem-scan-groups))
5928 ;; If ARG is not a number, then we read the active file.
5932 (let ((gnus-read-active-file t))
5933 (gnus-read-active-file))
5936 (setq arg (gnus-group-default-level arg t))
5937 (if (and gnus-read-active-file (not arg))
5939 (gnus-read-active-file)
5940 (gnus-get-unread-articles arg))
5941 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
5942 (gnus-get-unread-articles arg)))
5943 (gnus-group-list-groups))
5945 (defun gnus-group-get-new-news-this-group (&optional n)
5946 "Check for newly arrived news in the current group (and the N-1 next groups).
5947 The difference between N and the number of newsgroup checked is returned.
5948 If N is negative, this group and the N-1 previous groups will be checked."
5950 (let* ((groups (gnus-group-process-prefix n))
5951 (ret (if (numberp n) (- n (length groups)) 0))
5954 (setq group (car groups)
5955 groups (cdr groups))
5956 (gnus-group-remove-mark group)
5957 (or (gnus-get-new-news-in-group group)
5960 (gnus-message 3 "%s error: %s" group (gnus-status-message group))
5962 (gnus-group-next-unread-group 1 t)
5963 (gnus-summary-position-point)
5966 (defun gnus-get-new-news-in-group (group)
5967 (when (and group (gnus-activate-group group 'scan))
5968 (gnus-get-unread-articles-in-group
5969 (gnus-get-info group) (gnus-active group))
5970 (when (gnus-group-goto-group group)
5971 (gnus-group-update-group-line))
5974 (defun gnus-group-fetch-faq (group &optional faq-dir)
5975 "Fetch the FAQ for the current group."
5978 (gnus-group-real-name (gnus-group-group-name))
5979 (cond (current-prefix-arg
5981 "Faq dir: " (and (listp gnus-group-faq-directory)
5982 gnus-group-faq-directory))))))
5984 (setq faq-dir (if (listp gnus-group-faq-directory)
5985 (car gnus-group-faq-directory)
5986 gnus-group-faq-directory)))
5987 (or group (error "No group name given"))
5988 (let ((file (concat (file-name-as-directory faq-dir)
5989 (gnus-group-real-name group))))
5990 (if (not (file-exists-p file))
5991 (error "No such file: %s" file)
5994 (defun gnus-group-describe-group (force &optional group)
5995 "Display a description of the current newsgroup."
5996 (interactive (list current-prefix-arg (gnus-group-group-name)))
5997 (and force (setq gnus-description-hashtb nil))
5998 (let ((method (gnus-find-method-for-group group))
6000 (or group (error "No group name given"))
6001 (and (or (and gnus-description-hashtb
6002 ;; We check whether this group's method has been
6003 ;; queried for a description file.
6005 (gnus-group-prefixed-name "" method)
6006 gnus-description-hashtb))
6007 (setq desc (gnus-group-get-description group))
6008 (gnus-read-descriptions-file method))
6010 (or desc (gnus-gethash group gnus-description-hashtb)
6011 "No description available")))))
6013 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6014 (defun gnus-group-describe-all-groups (&optional force)
6015 "Pop up a buffer with descriptions of all newsgroups."
6017 (and force (setq gnus-description-hashtb nil))
6018 (if (not (or gnus-description-hashtb
6019 (gnus-read-all-descriptions-files)))
6020 (error "Couldn't request descriptions file"))
6021 (let ((buffer-read-only nil)
6027 (insert (format " *: %-20s %s\n" (symbol-name group)
6028 (symbol-value group)))
6029 (add-text-properties
6030 b (1+ b) (list 'gnus-group group
6031 'gnus-unread t 'gnus-marked nil
6032 'gnus-level (1+ gnus-level-subscribed))))
6033 gnus-description-hashtb)
6034 (goto-char (point-min))
6035 (gnus-group-position-point)))
6037 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6038 (defun gnus-group-apropos (regexp &optional search-description)
6039 "List all newsgroups that have names that match a regexp."
6040 (interactive "sGnus apropos (regexp): ")
6042 (obuf (current-buffer))
6044 ;; Go through all newsgroups that are known to Gnus.
6047 (and (symbol-name group)
6048 (string-match regexp (symbol-name group))
6049 (setq groups (cons (symbol-name group) groups))))
6051 ;; Go through all descriptions that are known to Gnus.
6052 (if search-description
6055 (and (string-match regexp (symbol-value group))
6056 (gnus-active (symbol-name group))
6057 (setq groups (cons (symbol-name group) groups))))
6058 gnus-description-hashtb))
6060 (gnus-message 3 "No groups matched \"%s\"." regexp)
6061 ;; Print out all the groups.
6063 (pop-to-buffer "*Gnus Help*")
6064 (buffer-disable-undo (current-buffer))
6066 (setq groups (sort groups 'string<))
6068 ;; Groups may be entered twice into the list of groups.
6069 (if (not (string= (car groups) prev))
6071 (insert (setq prev (car groups)) "\n")
6072 (if (and gnus-description-hashtb
6073 (setq des (gnus-gethash (car groups)
6074 gnus-description-hashtb)))
6075 (insert " " des "\n"))))
6076 (setq groups (cdr groups)))
6077 (goto-char (point-min))))
6078 (pop-to-buffer obuf)))
6080 (defun gnus-group-description-apropos (regexp)
6081 "List all newsgroups that have names or descriptions that match a regexp."
6082 (interactive "sGnus description apropos (regexp): ")
6083 (if (not (or gnus-description-hashtb
6084 (gnus-read-all-descriptions-files)))
6085 (error "Couldn't request descriptions file"))
6086 (gnus-group-apropos regexp t))
6088 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6089 (defun gnus-group-list-matching (level regexp &optional all lowest)
6090 "List all groups with unread articles that match REGEXP.
6091 If the prefix LEVEL is non-nil, it should be a number that says which
6092 level to cut off listing groups.
6093 If ALL, also list groups with no unread articles.
6094 If LOWEST, don't list groups with level lower than LOWEST."
6095 (interactive "P\nsList newsgroups matching: ")
6096 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6097 all (or lowest 1) regexp)
6098 (goto-char (point-min))
6099 (gnus-group-position-point))
6101 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6102 "List all groups that match REGEXP.
6103 If the prefix LEVEL is non-nil, it should be a number that says which
6104 level to cut off listing groups.
6105 If LOWEST, don't list groups with level lower than LOWEST."
6106 (interactive "P\nsList newsgroups matching: ")
6107 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6109 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6110 (defun gnus-group-save-newsrc (&optional force)
6111 "Save the Gnus startup files.
6112 If FORCE, force saving whether it is necessary or not."
6114 (gnus-save-newsrc-file force))
6116 (defun gnus-group-restart (&optional arg)
6117 "Force Gnus to read the .newsrc file."
6119 (gnus-save-newsrc-file)
6120 (gnus-setup-news 'force)
6121 (gnus-group-list-groups arg))
6123 (defun gnus-group-read-init-file ()
6124 "Read the Gnus elisp init file."
6126 (gnus-read-init-file))
6128 (defun gnus-group-check-bogus-groups (&optional silent)
6129 "Check bogus newsgroups.
6130 If given a prefix, don't ask for confirmation before removing a bogus
6133 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6134 (gnus-group-list-groups))
6136 (defun gnus-group-edit-global-kill (&optional article group)
6137 "Edit the global kill file.
6138 If GROUP, edit that local kill file instead."
6140 (setq gnus-current-kill-article article)
6141 (gnus-kill-file-edit-file group)
6144 (substitute-command-keys
6145 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6146 (if group "local" "global")))))
6148 (defun gnus-group-edit-local-kill (article group)
6149 "Edit a local kill file."
6150 (interactive (list nil (gnus-group-group-name)))
6151 (gnus-group-edit-global-kill article group))
6153 (defun gnus-group-force-update ()
6154 "Update `.newsrc' file."
6156 (gnus-save-newsrc-file))
6158 (defun gnus-group-suspend ()
6159 "Suspend the current Gnus session.
6160 In fact, cleanup buffers except for group mode buffer.
6161 The hook gnus-suspend-gnus-hook is called before actually suspending."
6163 (run-hooks 'gnus-suspend-gnus-hook)
6164 ;; Kill Gnus buffers except for group mode buffer.
6165 (let ((group-buf (get-buffer gnus-group-buffer)))
6166 ;; Do this on a separate list in case the user does a ^G before we finish
6167 (let ((gnus-buffer-list
6168 (delq group-buf (delq gnus-dribble-buffer
6169 (append gnus-buffer-list nil)))))
6170 (while gnus-buffer-list
6171 (gnus-kill-buffer (car gnus-buffer-list))
6172 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6175 (setq gnus-buffer-list (list group-buf))
6176 (bury-buffer group-buf)
6177 (delete-windows-on group-buf t)))))
6179 (defun gnus-group-clear-dribble ()
6180 "Clear all information from the dribble buffer."
6182 (gnus-dribble-clear)
6183 (gnus-message 7 "Cleared dribble buffer"))
6185 (defun gnus-group-exit ()
6186 "Quit reading news after updating .newsrc.eld and .newsrc.
6187 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6189 (if (or noninteractive ;For gnus-batch-kill
6190 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
6191 (not gnus-interactive-exit) ;Without confirmation
6193 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6195 (run-hooks 'gnus-exit-gnus-hook)
6196 ;; Offer to save data from non-quitted summary buffers.
6197 (gnus-offer-save-summaries)
6198 ;; Save the newsrc file(s).
6199 (gnus-save-newsrc-file)
6201 (gnus-close-backends)
6202 ;; Shut down the cache.
6203 (when gnus-use-cache
6205 ;; Reset everything.
6206 (gnus-clear-system))))
6208 (defun gnus-close-backends ()
6209 ;; Send a close request to all backends that support such a request.
6210 (let ((methods gnus-valid-select-methods)
6213 (if (fboundp (setq func (intern (concat (car (car methods))
6214 "-request-close"))))
6216 (setq methods (cdr methods)))))
6218 (defun gnus-group-quit ()
6219 "Quit reading news without updating .newsrc.eld or .newsrc.
6220 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6222 (when (or noninteractive ;For gnus-batch-kill
6223 (zerop (buffer-size))
6224 (not (gnus-server-opened gnus-select-method))
6226 (not gnus-current-startup-file)
6228 (format "Quit reading news without saving %s? "
6229 (file-name-nondirectory gnus-current-startup-file))))
6230 (run-hooks 'gnus-exit-gnus-hook)
6231 (if gnus-use-full-window
6232 (delete-other-windows)
6233 (gnus-remove-some-windows))
6235 (gnus-close-backends)
6236 ;; Shut down the cache.
6237 (when gnus-use-cache
6239 (gnus-clear-system)))
6241 (defun gnus-offer-save-summaries ()
6242 "Offer to save all active summary buffers."
6244 (let ((buflist (buffer-list))
6246 ;; Go through all buffers and find all summaries.
6248 (and (setq bufname (buffer-name (car buflist)))
6249 (string-match "Summary" bufname)
6251 (set-buffer bufname)
6252 ;; We check that this is, indeed, a summary buffer.
6253 (and (eq major-mode 'gnus-summary-mode)
6254 ;; Also make sure this isn't bogus.
6255 gnus-newsgroup-prepared))
6256 (push bufname buffers))
6257 (setq buflist (cdr buflist)))
6258 ;; Go through all these summary buffers and offer to save them.
6261 "Update summary buffer %s? "
6262 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6265 (defun gnus-group-describe-briefly ()
6266 "Give a one line description of the group mode commands."
6268 (gnus-message 7 (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")))
6270 (defun gnus-group-browse-foreign-server (method)
6271 "Browse a foreign news server.
6272 If called interactively, this function will ask for a select method
6273 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6274 If not, METHOD should be a list where the first element is the method
6275 and the second element is the address."
6277 (list (let ((how (completing-read
6279 (append gnus-valid-select-methods gnus-server-alist)
6281 ;; We either got a backend name or a virtual server name.
6282 ;; If the first, we also need an address.
6283 (if (assoc how gnus-valid-select-methods)
6285 ;; Suggested by mapjph@bath.ac.uk.
6288 (mapcar (lambda (server) (list server))
6289 gnus-secondary-servers)))
6290 ;; We got a server name, so we find the method.
6291 (gnus-server-to-method how)))))
6292 (gnus-browse-foreign-server method))
6296 ;;; Browse Server Mode
6299 (defvar gnus-browse-mode-hook nil)
6300 (defvar gnus-browse-mode-map nil)
6301 (put 'gnus-browse-mode 'mode-class 'special)
6303 (if gnus-browse-mode-map
6305 (setq gnus-browse-mode-map (make-keymap))
6306 (suppress-keymap gnus-browse-mode-map)
6307 (define-key gnus-browse-mode-map " " 'gnus-browse-read-group)
6308 (define-key gnus-browse-mode-map "=" 'gnus-browse-select-group)
6309 (define-key gnus-browse-mode-map "n" 'gnus-browse-next-group)
6310 (define-key gnus-browse-mode-map "p" 'gnus-browse-prev-group)
6311 (define-key gnus-browse-mode-map "\177" 'gnus-browse-prev-group)
6312 (define-key gnus-browse-mode-map "N" 'gnus-browse-next-group)
6313 (define-key gnus-browse-mode-map "P" 'gnus-browse-prev-group)
6314 (define-key gnus-browse-mode-map "\M-n" 'gnus-browse-next-group)
6315 (define-key gnus-browse-mode-map "\M-p" 'gnus-browse-prev-group)
6316 (define-key gnus-browse-mode-map "\r" 'gnus-browse-select-group)
6317 (define-key gnus-browse-mode-map "u" 'gnus-browse-unsubscribe-current-group)
6318 (define-key gnus-browse-mode-map "l" 'gnus-browse-exit)
6319 (define-key gnus-browse-mode-map "L" 'gnus-browse-exit)
6320 (define-key gnus-browse-mode-map "q" 'gnus-browse-exit)
6321 (define-key gnus-browse-mode-map "Q" 'gnus-browse-exit)
6322 (define-key gnus-browse-mode-map "\C-c\C-c" 'gnus-browse-exit)
6323 (define-key gnus-browse-mode-map "?" 'gnus-browse-describe-briefly)
6324 (define-key gnus-browse-mode-map "\C-c\C-i" 'gnus-info-find-node)
6327 (defvar gnus-browse-current-method nil)
6328 (defvar gnus-browse-return-buffer nil)
6330 (defvar gnus-browse-buffer "*Gnus Browse Server*")
6332 (defun gnus-browse-foreign-server (method &optional return-buffer)
6333 "Browse the server METHOD."
6334 (setq gnus-browse-current-method method)
6335 (setq gnus-browse-return-buffer return-buffer)
6336 (let ((gnus-select-method method)
6338 (gnus-message 5 "Connecting to %s..." (nth 1 method))
6340 ((not (gnus-check-server method))
6342 1 "Unable to contact server: %s" (gnus-status-message method))
6344 ((not (gnus-request-list method))
6346 1 "Couldn't request list: %s" (gnus-status-message method))
6349 (get-buffer-create gnus-browse-buffer)
6350 (gnus-add-current-to-buffer-list)
6351 (and gnus-carpal (gnus-carpal-setup-buffer 'browse))
6352 (gnus-configure-windows 'browse)
6353 (buffer-disable-undo (current-buffer))
6354 (let ((buffer-read-only nil))
6357 (setq mode-line-buffer-identification
6360 "Gnus: %%b {%s:%s}" (car method) (car (cdr method)))))
6362 (set-buffer nntp-server-buffer)
6363 (let ((cur (current-buffer)))
6364 (goto-char (point-min))
6365 (or (string= gnus-ignored-newsgroups "")
6366 (delete-matching-lines gnus-ignored-newsgroups))
6367 (while (re-search-forward
6368 "\\(^[^ \t]+\\)[ \t]+[0-9]+[ \t]+[0-9]+" nil t)
6369 (goto-char (match-end 1))
6370 (setq groups (cons (cons (match-string 1)
6371 (max 0 (- (1+ (read cur)) (read cur))))
6373 (setq groups (sort groups
6375 (string< (car l1) (car l2)))))
6376 (let ((buffer-read-only nil))
6378 (setq group (car groups))
6380 (format "K%7d: %s\n" (cdr group) (car group)))
6381 (setq groups (cdr groups))))
6382 (switch-to-buffer (current-buffer))
6383 (goto-char (point-min))
6384 (gnus-group-position-point)
6387 (defun gnus-browse-mode ()
6388 "Major mode for browsing a foreign server.
6390 All normal editing commands are switched off.
6392 \\<gnus-browse-mode-map>
6393 The only things you can do in this buffer is
6395 1) `\\[gnus-browse-unsubscribe-current-group]' to subscribe to a group.
6396 The group will be inserted into the group buffer upon exit from this
6399 2) `\\[gnus-browse-read-group]' to read a group ephemerally.
6401 3) `\\[gnus-browse-exit]' to return to the group buffer."
6403 (kill-all-local-variables)
6404 (when (and menu-bar-mode
6405 (gnus-visual-p 'browse-menu 'menu))
6406 (gnus-browse-make-menu-bar))
6407 (gnus-simplify-mode-line)
6408 (setq major-mode 'gnus-browse-mode)
6409 (setq mode-name "Browse Server")
6410 (setq mode-line-process nil)
6411 (use-local-map gnus-browse-mode-map)
6412 (buffer-disable-undo (current-buffer))
6413 (setq truncate-lines t)
6414 (setq buffer-read-only t)
6415 (run-hooks 'gnus-browse-mode-hook))
6417 (defun gnus-browse-read-group (&optional no-article)
6418 "Enter the group at the current line."
6420 (let ((group (gnus-browse-group-name)))
6421 (or (gnus-group-read-ephemeral-group
6422 group gnus-browse-current-method nil
6423 (cons (current-buffer) 'browse))
6424 (error "Couldn't enter %s" group))))
6426 (defun gnus-browse-select-group ()
6427 "Select the current group."
6429 (gnus-browse-read-group 'no))
6431 (defun gnus-browse-next-group (n)
6432 "Go to the next group."
6436 (gnus-group-position-point)))
6438 (defun gnus-browse-prev-group (n)
6439 "Go to the next group."
6441 (gnus-browse-next-group (- n)))
6443 (defun gnus-browse-unsubscribe-current-group (arg)
6444 "(Un)subscribe to the next ARG groups."
6447 (error "No group at current line."))
6448 (let ((ward (if (< arg 0) -1 1))
6450 (while (and (> arg 0)
6452 (gnus-browse-unsubscribe-group)
6453 (zerop (gnus-browse-next-group ward)))
6454 (setq arg (1- arg)))
6455 (gnus-group-position-point)
6456 (if (/= 0 arg) (gnus-message 7 "No more newsgroups"))
6459 (defun gnus-browse-group-name ()
6462 (when (re-search-forward ": \\(.*\\)$" (gnus-point-at-eol) t)
6463 (gnus-group-prefixed-name (match-string 1) gnus-browse-current-method))))
6465 (defun gnus-browse-unsubscribe-group ()
6466 "Toggle subscription of the current group in the browse buffer."
6468 (buffer-read-only nil)
6472 ;; If this group it killed, then we want to subscribe it.
6473 (if (= (following-char) ?K) (setq sub t))
6474 (setq group (gnus-browse-group-name))
6478 (gnus-group-change-level
6479 (list t group gnus-level-default-subscribed
6480 nil nil gnus-browse-current-method)
6481 gnus-level-default-subscribed gnus-level-killed
6482 (and (car (nth 1 gnus-newsrc-alist))
6483 (gnus-gethash (car (nth 1 gnus-newsrc-alist))
6484 gnus-newsrc-hashtb))
6487 (gnus-group-change-level
6488 group gnus-level-killed gnus-level-default-subscribed)
6492 (defun gnus-browse-exit ()
6493 "Quit browsing and return to the group buffer."
6495 (if (eq major-mode 'gnus-browse-mode)
6496 (kill-buffer (current-buffer)))
6497 (if gnus-browse-return-buffer
6498 (gnus-configure-windows 'server 'force)
6499 (gnus-configure-windows 'group 'force)
6500 (gnus-group-list-groups nil)))
6502 (defun gnus-browse-describe-briefly ()
6503 "Give a one line description of the group mode commands."
6506 (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")))
6510 ;;; Gnus summary mode
6513 (defvar gnus-summary-mode-map nil)
6514 (defvar gnus-summary-mark-map nil)
6515 (defvar gnus-summary-mscore-map nil)
6516 (defvar gnus-summary-article-map nil)
6517 (defvar gnus-summary-thread-map nil)
6518 (defvar gnus-summary-goto-map nil)
6519 (defvar gnus-summary-exit-map nil)
6520 (defvar gnus-summary-interest-map nil)
6521 (defvar gnus-summary-sort-map nil)
6522 (defvar gnus-summary-backend-map nil)
6523 (defvar gnus-summary-save-map nil)
6524 (defvar gnus-summary-wash-map nil)
6525 (defvar gnus-summary-wash-hide-map nil)
6526 (defvar gnus-summary-wash-highlight-map nil)
6527 (defvar gnus-summary-wash-time-map nil)
6528 (defvar gnus-summary-help-map nil)
6529 (defvar gnus-summary-limit-map nil)
6531 (put 'gnus-summary-mode 'mode-class 'special)
6533 (if gnus-summary-mode-map
6535 (setq gnus-summary-mode-map (make-keymap))
6536 (suppress-keymap gnus-summary-mode-map)
6538 ;; Non-orthogonal keys
6540 (define-key gnus-summary-mode-map " " 'gnus-summary-next-page)
6541 (define-key gnus-summary-mode-map "\177" 'gnus-summary-prev-page)
6542 (define-key gnus-summary-mode-map "\r" 'gnus-summary-scroll-up)
6543 (define-key gnus-summary-mode-map "n" 'gnus-summary-next-unread-article)
6544 (define-key gnus-summary-mode-map "p" 'gnus-summary-prev-unread-article)
6545 (define-key gnus-summary-mode-map "N" 'gnus-summary-next-article)
6546 (define-key gnus-summary-mode-map "P" 'gnus-summary-prev-article)
6547 (define-key gnus-summary-mode-map "\M-\C-n" 'gnus-summary-next-same-subject)
6548 (define-key gnus-summary-mode-map "\M-\C-p" 'gnus-summary-prev-same-subject)
6549 (define-key gnus-summary-mode-map "\M-n" 'gnus-summary-next-unread-subject)
6550 (define-key gnus-summary-mode-map "\M-p" 'gnus-summary-prev-unread-subject)
6551 (define-key gnus-summary-mode-map "." 'gnus-summary-first-unread-article)
6552 (define-key gnus-summary-mode-map "," 'gnus-summary-best-unread-article)
6553 (define-key gnus-summary-mode-map
6554 "\M-s" 'gnus-summary-search-article-forward)
6555 (define-key gnus-summary-mode-map
6556 "\M-r" 'gnus-summary-search-article-backward)
6557 (define-key gnus-summary-mode-map "<" 'gnus-summary-beginning-of-article)
6558 (define-key gnus-summary-mode-map ">" 'gnus-summary-end-of-article)
6559 (define-key gnus-summary-mode-map "j" 'gnus-summary-goto-article)
6560 (define-key gnus-summary-mode-map "^" 'gnus-summary-refer-parent-article)
6561 (define-key gnus-summary-mode-map "\M-^" 'gnus-summary-refer-article)
6562 (define-key gnus-summary-mode-map "u" 'gnus-summary-tick-article-forward)
6563 (define-key gnus-summary-mode-map "!" 'gnus-summary-tick-article-forward)
6564 (define-key gnus-summary-mode-map "U" 'gnus-summary-tick-article-backward)
6565 (define-key gnus-summary-mode-map "d" 'gnus-summary-mark-as-read-forward)
6566 (define-key gnus-summary-mode-map "D" 'gnus-summary-mark-as-read-backward)
6567 (define-key gnus-summary-mode-map "E" 'gnus-summary-mark-as-expirable)
6568 (define-key gnus-summary-mode-map "\M-u" 'gnus-summary-clear-mark-forward)
6569 (define-key gnus-summary-mode-map "\M-U" 'gnus-summary-clear-mark-backward)
6570 (define-key gnus-summary-mode-map
6571 "k" 'gnus-summary-kill-same-subject-and-select)
6572 (define-key gnus-summary-mode-map "\C-k" 'gnus-summary-kill-same-subject)
6573 (define-key gnus-summary-mode-map "\M-\C-k" 'gnus-summary-kill-thread)
6574 (define-key gnus-summary-mode-map "\M-\C-l" 'gnus-summary-lower-thread)
6575 (define-key gnus-summary-mode-map "e" 'gnus-summary-edit-article)
6576 (define-key gnus-summary-mode-map "#" 'gnus-summary-mark-as-processable)
6577 (define-key gnus-summary-mode-map "\M-#" 'gnus-summary-unmark-as-processable)
6578 (define-key gnus-summary-mode-map "\M-\C-t" 'gnus-summary-toggle-threads)
6579 (define-key gnus-summary-mode-map "\M-\C-s" 'gnus-summary-show-thread)
6580 (define-key gnus-summary-mode-map "\M-\C-h" 'gnus-summary-hide-thread)
6581 (define-key gnus-summary-mode-map "\M-\C-f" 'gnus-summary-next-thread)
6582 (define-key gnus-summary-mode-map "\M-\C-b" 'gnus-summary-prev-thread)
6583 (define-key gnus-summary-mode-map "\M-\C-u" 'gnus-summary-up-thread)
6584 (define-key gnus-summary-mode-map "\M-\C-d" 'gnus-summary-down-thread)
6585 (define-key gnus-summary-mode-map "&" 'gnus-summary-execute-command)
6586 (define-key gnus-summary-mode-map "c" 'gnus-summary-catchup-and-exit)
6587 (define-key gnus-summary-mode-map "\C-w" 'gnus-summary-mark-region-as-read)
6588 (define-key gnus-summary-mode-map "\C-t" 'gnus-summary-toggle-truncation)
6589 (define-key gnus-summary-mode-map "?" 'gnus-summary-mark-as-dormant)
6590 (define-key gnus-summary-mode-map
6591 "\C-c\M-\C-s" 'gnus-summary-limit-include-expunged)
6592 (define-key gnus-summary-mode-map
6593 "\C-c\C-s\C-n" 'gnus-summary-sort-by-number)
6594 (define-key gnus-summary-mode-map
6595 "\C-c\C-s\C-a" 'gnus-summary-sort-by-author)
6596 (define-key gnus-summary-mode-map
6597 "\C-c\C-s\C-s" 'gnus-summary-sort-by-subject)
6598 (define-key gnus-summary-mode-map "\C-c\C-s\C-d" 'gnus-summary-sort-by-date)
6599 (define-key gnus-summary-mode-map "\C-c\C-s\C-i" 'gnus-summary-sort-by-score)
6600 (define-key gnus-summary-mode-map "=" 'gnus-summary-expand-window)
6601 (define-key gnus-summary-mode-map
6602 "\C-x\C-s" 'gnus-summary-reselect-current-group)
6603 (define-key gnus-summary-mode-map "\M-g" 'gnus-summary-rescan-group)
6604 (define-key gnus-summary-mode-map "w" 'gnus-summary-stop-page-breaking)
6605 (define-key gnus-summary-mode-map "\C-c\C-r" 'gnus-summary-caesar-message)
6606 (define-key gnus-summary-mode-map "\M-t" 'gnus-summary-toggle-mime)
6607 (define-key gnus-summary-mode-map "f" 'gnus-summary-followup)
6608 (define-key gnus-summary-mode-map "F" 'gnus-summary-followup-with-original)
6609 (define-key gnus-summary-mode-map "C" 'gnus-summary-cancel-article)
6610 (define-key gnus-summary-mode-map "r" 'gnus-summary-reply)
6611 (define-key gnus-summary-mode-map "R" 'gnus-summary-reply-with-original)
6612 (define-key gnus-summary-mode-map "\C-c\C-f" 'gnus-summary-mail-forward)
6613 (define-key gnus-summary-mode-map "o" 'gnus-summary-save-article)
6614 (define-key gnus-summary-mode-map "\C-o" 'gnus-summary-save-article-mail)
6615 (define-key gnus-summary-mode-map "|" 'gnus-summary-pipe-output)
6616 (define-key gnus-summary-mode-map "\M-k" 'gnus-summary-edit-local-kill)
6617 (define-key gnus-summary-mode-map "\M-K" 'gnus-summary-edit-global-kill)
6618 (define-key gnus-summary-mode-map "V" 'gnus-version)
6619 (define-key gnus-summary-mode-map "\C-c\C-d" 'gnus-summary-describe-group)
6620 (define-key gnus-summary-mode-map "q" 'gnus-summary-exit)
6621 (define-key gnus-summary-mode-map "Q" 'gnus-summary-exit-no-update)
6622 (define-key gnus-summary-mode-map "\C-c\C-i" 'gnus-info-find-node)
6623 (define-key gnus-summary-mode-map gnus-mouse-2 'gnus-mouse-pick-article)
6624 (define-key gnus-summary-mode-map "m" 'gnus-summary-mail-other-window)
6625 (define-key gnus-summary-mode-map "a" 'gnus-summary-post-news)
6626 (define-key gnus-summary-mode-map "x" 'gnus-summary-limit-to-unread)
6627 (define-key gnus-summary-mode-map "s" 'gnus-summary-isearch-article)
6628 (define-key gnus-summary-mode-map "t" 'gnus-summary-toggle-header)
6629 (define-key gnus-summary-mode-map "g" 'gnus-summary-show-article)
6630 ; (define-key gnus-summary-mode-map "?" 'gnus-summary-describe-briefly)
6631 (define-key gnus-summary-mode-map "l" 'gnus-summary-goto-last-article)
6632 (define-key gnus-summary-mode-map "\C-c\C-v\C-v" 'gnus-uu-decode-uu-view)
6633 (define-key gnus-summary-mode-map "\C-d" 'gnus-summary-enter-digest-group)
6634 (define-key gnus-summary-mode-map "v" 'gnus-summary-verbose-headers)
6635 (define-key gnus-summary-mode-map "\C-c\C-b" 'gnus-bug)
6637 (define-key gnus-summary-mode-map "*" 'gnus-cache-enter-article)
6638 (define-key gnus-summary-mode-map "\M-*" 'gnus-cache-remove-article)
6640 ;; Sort of orthogonal keymap
6641 (define-prefix-command 'gnus-summary-mark-map)
6642 (define-key gnus-summary-mode-map "M" 'gnus-summary-mark-map)
6643 (define-key gnus-summary-mark-map "t" 'gnus-summary-tick-article-forward)
6644 (define-key gnus-summary-mark-map "!" 'gnus-summary-tick-article-forward)
6645 (define-key gnus-summary-mark-map "d" 'gnus-summary-mark-as-read-forward)
6646 (define-key gnus-summary-mark-map "r" 'gnus-summary-mark-as-read-forward)
6647 (define-key gnus-summary-mark-map "c" 'gnus-summary-clear-mark-forward)
6648 (define-key gnus-summary-mark-map " " 'gnus-summary-clear-mark-forward)
6649 (define-key gnus-summary-mark-map "e" 'gnus-summary-mark-as-expirable)
6650 (define-key gnus-summary-mark-map "x" 'gnus-summary-mark-as-expirable)
6651 (define-key gnus-summary-mark-map "?" 'gnus-summary-mark-as-dormant)
6652 (define-key gnus-summary-mark-map "b" 'gnus-summary-set-bookmark)
6653 (define-key gnus-summary-mark-map "B" 'gnus-summary-remove-bookmark)
6654 (define-key gnus-summary-mark-map "#" 'gnus-summary-mark-as-processable)
6655 (define-key gnus-summary-mark-map "\M-#" 'gnus-summary-unmark-as-processable)
6656 (define-key gnus-summary-mark-map "S" 'gnus-summary-limit-include-expunged)
6657 (define-key gnus-summary-mark-map "C" 'gnus-summary-catchup)
6658 (define-key gnus-summary-mark-map "H" 'gnus-summary-catchup-to-here)
6659 (define-key gnus-summary-mark-map "\C-c" 'gnus-summary-catchup-all)
6660 (define-key gnus-summary-mark-map
6661 "k" 'gnus-summary-kill-same-subject-and-select)
6662 (define-key gnus-summary-mark-map "K" 'gnus-summary-kill-same-subject)
6664 (define-prefix-command 'gnus-summary-mscore-map)
6665 (define-key gnus-summary-mark-map "V" 'gnus-summary-mscore-map)
6666 (define-key gnus-summary-mscore-map "c" 'gnus-summary-clear-above)
6667 (define-key gnus-summary-mscore-map "u" 'gnus-summary-tick-above)
6668 (define-key gnus-summary-mscore-map "m" 'gnus-summary-mark-above)
6669 (define-key gnus-summary-mscore-map "k" 'gnus-summary-kill-below)
6671 (define-key gnus-summary-mark-map "P" 'gnus-uu-mark-map)
6673 (define-key gnus-summary-mode-map "S" 'gnus-summary-send-map)
6675 (define-prefix-command 'gnus-summary-limit-map)
6676 (define-key gnus-summary-mode-map "/" 'gnus-summary-limit-map)
6677 (define-key gnus-summary-limit-map "/" 'gnus-summary-limit-to-subject)
6678 (define-key gnus-summary-limit-map "n" 'gnus-summary-limit-to-articles)
6679 (define-key gnus-summary-limit-map "w" 'gnus-summary-pop-limit)
6680 (define-key gnus-summary-limit-map "s" 'gnus-summary-limit-to-subject)
6681 (define-key gnus-summary-limit-map "u" 'gnus-summary-limit-to-unread)
6682 (define-key gnus-summary-limit-map "m" 'gnus-summary-limit-to-marks)
6683 (define-key gnus-summary-limit-map "v" 'gnus-summary-limit-to-score)
6684 (define-key gnus-summary-limit-map "D" 'gnus-summary-limit-include-dormant)
6685 (define-key gnus-summary-limit-map "d" 'gnus-summary-limit-exclude-dormant)
6686 ; (define-key gnus-summary-limit-map "t" 'gnus-summary-limit-exclude-thread)
6687 (define-key gnus-summary-mark-map "E" 'gnus-summary-limit-include-expunged)
6688 (define-key gnus-summary-limit-map "c"
6689 'gnus-summary-limit-exclude-childless-dormant)
6691 (define-prefix-command 'gnus-summary-goto-map)
6692 (define-key gnus-summary-mode-map "G" 'gnus-summary-goto-map)
6693 (define-key gnus-summary-goto-map "n" 'gnus-summary-next-unread-article)
6694 (define-key gnus-summary-goto-map "p" 'gnus-summary-prev-unread-article)
6695 (define-key gnus-summary-goto-map "N" 'gnus-summary-next-article)
6696 (define-key gnus-summary-goto-map "P" 'gnus-summary-prev-article)
6697 (define-key gnus-summary-goto-map "\C-n" 'gnus-summary-next-same-subject)
6698 (define-key gnus-summary-goto-map "\C-p" 'gnus-summary-prev-same-subject)
6699 (define-key gnus-summary-goto-map "\M-n" 'gnus-summary-next-unread-subject)
6700 (define-key gnus-summary-goto-map "\M-p" 'gnus-summary-prev-unread-subject)
6701 (define-key gnus-summary-goto-map "f" 'gnus-summary-first-unread-article)
6702 (define-key gnus-summary-goto-map "b" 'gnus-summary-best-unread-article)
6703 (define-key gnus-summary-goto-map "g" 'gnus-summary-goto-subject)
6704 (define-key gnus-summary-goto-map "l" 'gnus-summary-goto-last-article)
6705 (define-key gnus-summary-goto-map "p" 'gnus-summary-pop-article)
6708 (define-prefix-command 'gnus-summary-thread-map)
6709 (define-key gnus-summary-mode-map "T" 'gnus-summary-thread-map)
6710 (define-key gnus-summary-thread-map "k" 'gnus-summary-kill-thread)
6711 (define-key gnus-summary-thread-map "l" 'gnus-summary-lower-thread)
6712 (define-key gnus-summary-thread-map "i" 'gnus-summary-raise-thread)
6713 (define-key gnus-summary-thread-map "T" 'gnus-summary-toggle-threads)
6714 (define-key gnus-summary-thread-map "T" 'gnus-summary-rethread-current)
6715 (define-key gnus-summary-thread-map "s" 'gnus-summary-show-thread)
6716 (define-key gnus-summary-thread-map "S" 'gnus-summary-show-all-threads)
6717 (define-key gnus-summary-thread-map "h" 'gnus-summary-hide-thread)
6718 (define-key gnus-summary-thread-map "H" 'gnus-summary-hide-all-threads)
6719 (define-key gnus-summary-thread-map "n" 'gnus-summary-next-thread)
6720 (define-key gnus-summary-thread-map "p" 'gnus-summary-prev-thread)
6721 (define-key gnus-summary-thread-map "u" 'gnus-summary-up-thread)
6722 (define-key gnus-summary-thread-map "d" 'gnus-summary-down-thread)
6723 (define-key gnus-summary-thread-map "#" 'gnus-uu-mark-thread)
6724 (define-key gnus-summary-thread-map "\M-#" 'gnus-uu-unmark-thread)
6727 (define-prefix-command 'gnus-summary-exit-map)
6728 (define-key gnus-summary-mode-map "Z" 'gnus-summary-exit-map)
6729 (define-key gnus-summary-exit-map "c" 'gnus-summary-catchup-and-exit)
6730 (define-key gnus-summary-exit-map "C" 'gnus-summary-catchup-all-and-exit)
6731 (define-key gnus-summary-exit-map "E" 'gnus-summary-exit-no-update)
6732 (define-key gnus-summary-exit-map "Q" 'gnus-summary-exit)
6733 (define-key gnus-summary-exit-map "Z" 'gnus-summary-exit)
6734 (define-key gnus-summary-exit-map
6735 "n" 'gnus-summary-catchup-and-goto-next-group)
6736 (define-key gnus-summary-exit-map "R" 'gnus-summary-reselect-current-group)
6737 (define-key gnus-summary-exit-map "G" 'gnus-summary-rescan-group)
6738 (define-key gnus-summary-exit-map "N" 'gnus-summary-next-group)
6739 (define-key gnus-summary-exit-map "P" 'gnus-summary-prev-group)
6742 (define-prefix-command 'gnus-summary-article-map)
6743 (define-key gnus-summary-mode-map "A" 'gnus-summary-article-map)
6744 (define-key gnus-summary-article-map " " 'gnus-summary-next-page)
6745 (define-key gnus-summary-article-map "n" 'gnus-summary-next-page)
6746 (define-key gnus-summary-article-map "\177" 'gnus-summary-prev-page)
6747 (define-key gnus-summary-article-map "p" 'gnus-summary-prev-page)
6748 (define-key gnus-summary-article-map "\r" 'gnus-summary-scroll-up)
6749 (define-key gnus-summary-article-map "<" 'gnus-summary-beginning-of-article)
6750 (define-key gnus-summary-article-map ">" 'gnus-summary-end-of-article)
6751 (define-key gnus-summary-article-map "b" 'gnus-summary-beginning-of-article)
6752 (define-key gnus-summary-article-map "e" 'gnus-summary-end-of-article)
6753 (define-key gnus-summary-article-map "^" 'gnus-summary-refer-parent-article)
6754 (define-key gnus-summary-article-map "r" 'gnus-summary-refer-parent-article)
6755 (define-key gnus-summary-article-map "R" 'gnus-summary-refer-references)
6756 (define-key gnus-summary-article-map "g" 'gnus-summary-show-article)
6757 (define-key gnus-summary-article-map "s" 'gnus-summary-isearch-article)
6761 (define-prefix-command 'gnus-summary-wash-map)
6762 (define-key gnus-summary-mode-map "W" 'gnus-summary-wash-map)
6764 (define-prefix-command 'gnus-summary-wash-hide-map)
6765 (define-key gnus-summary-wash-map "W" 'gnus-summary-wash-hide-map)
6766 (define-key gnus-summary-wash-hide-map "a" 'gnus-article-hide)
6767 (define-key gnus-summary-wash-hide-map "h" 'gnus-article-hide-headers)
6768 (define-key gnus-summary-wash-hide-map "s" 'gnus-article-hide-signature)
6769 (define-key gnus-summary-wash-hide-map "c" 'gnus-article-hide-citation)
6770 (define-key gnus-summary-wash-hide-map "p" 'gnus-article-hide-pgp)
6771 (define-key gnus-summary-wash-hide-map
6772 "\C-c" 'gnus-article-hide-citation-maybe)
6774 (define-prefix-command 'gnus-summary-wash-highlight-map)
6775 (define-key gnus-summary-wash-map "H" 'gnus-summary-wash-highlight-map)
6776 (define-key gnus-summary-wash-highlight-map "a" 'gnus-article-highlight)
6777 (define-key gnus-summary-wash-highlight-map
6778 "h" 'gnus-article-highlight-headers)
6779 (define-key gnus-summary-wash-highlight-map
6780 "c" 'gnus-article-highlight-citation)
6781 (define-key gnus-summary-wash-highlight-map
6782 "s" 'gnus-article-highlight-signature)
6784 (define-prefix-command 'gnus-summary-wash-time-map)
6785 (define-key gnus-summary-wash-map "T" 'gnus-summary-wash-time-map)
6786 (define-key gnus-summary-wash-time-map "z" 'gnus-article-date-ut)
6787 (define-key gnus-summary-wash-time-map "u" 'gnus-article-date-ut)
6788 (define-key gnus-summary-wash-time-map "l" 'gnus-article-date-local)
6789 (define-key gnus-summary-wash-time-map "e" 'gnus-article-date-lapsed)
6790 (define-key gnus-summary-wash-time-map "o" 'gnus-article-date-original)
6792 (define-key gnus-summary-wash-map "b" 'gnus-article-add-buttons)
6793 (define-key gnus-summary-wash-map "B" 'gnus-article-add-buttons-to-head)
6794 (define-key gnus-summary-wash-map "o" 'gnus-article-treat-overstrike)
6795 (define-key gnus-summary-wash-map "w" 'gnus-article-word-wrap)
6796 (define-key gnus-summary-wash-map "c" 'gnus-article-remove-cr)
6797 (define-key gnus-summary-wash-map "q" 'gnus-article-de-quoted-unreadable)
6798 (define-key gnus-summary-wash-map "f" 'gnus-article-display-x-face)
6799 (define-key gnus-summary-wash-map "l" 'gnus-summary-stop-page-breaking)
6800 (define-key gnus-summary-wash-map "r" 'gnus-summary-caesar-message)
6801 (define-key gnus-summary-wash-map "t" 'gnus-summary-toggle-header)
6802 (define-key gnus-summary-wash-map "m" 'gnus-summary-toggle-mime)
6805 (define-prefix-command 'gnus-summary-help-map)
6806 (define-key gnus-summary-mode-map "H" 'gnus-summary-help-map)
6807 (define-key gnus-summary-help-map "v" 'gnus-version)
6808 (define-key gnus-summary-help-map "f" 'gnus-summary-fetch-faq)
6809 (define-key gnus-summary-help-map "d" 'gnus-summary-describe-group)
6810 (define-key gnus-summary-help-map "h" 'gnus-summary-describe-briefly)
6811 (define-key gnus-summary-help-map "i" 'gnus-info-find-node)
6814 (define-prefix-command 'gnus-summary-backend-map)
6815 (define-key gnus-summary-mode-map "B" 'gnus-summary-backend-map)
6816 (define-key gnus-summary-backend-map "e" 'gnus-summary-expire-articles)
6817 (define-key gnus-summary-backend-map "\M-\C-e"
6818 'gnus-summary-expire-articles-now)
6819 (define-key gnus-summary-backend-map "\177" 'gnus-summary-delete-article)
6820 (define-key gnus-summary-backend-map "m" 'gnus-summary-move-article)
6821 (define-key gnus-summary-backend-map "r" 'gnus-summary-respool-article)
6822 (define-key gnus-summary-backend-map "w" 'gnus-summary-edit-article)
6823 (define-key gnus-summary-backend-map "c" 'gnus-summary-copy-article)
6824 (define-key gnus-summary-backend-map "q" 'gnus-summary-respool-query)
6825 (define-key gnus-summary-backend-map "i" 'gnus-summary-import-article)
6828 (define-prefix-command 'gnus-summary-save-map)
6829 (define-key gnus-summary-mode-map "O" 'gnus-summary-save-map)
6830 (define-key gnus-summary-save-map "o" 'gnus-summary-save-article)
6831 (define-key gnus-summary-save-map "m" 'gnus-summary-save-article-mail)
6832 (define-key gnus-summary-save-map "r" 'gnus-summary-save-article-rmail)
6833 (define-key gnus-summary-save-map "f" 'gnus-summary-save-article-file)
6834 (define-key gnus-summary-save-map "b" 'gnus-summary-save-article-body-file)
6835 (define-key gnus-summary-save-map "h" 'gnus-summary-save-article-folder)
6836 (define-key gnus-summary-save-map "v" 'gnus-summary-save-article-vm)
6837 (define-key gnus-summary-save-map "p" 'gnus-summary-pipe-output)
6838 (define-key gnus-summary-save-map "s" 'gnus-soup-add-article)
6840 (define-key gnus-summary-mode-map "X" 'gnus-uu-extract-map)
6842 (define-key gnus-summary-mode-map "\M-&" 'gnus-summary-universal-argument)
6843 (define-key gnus-summary-article-map "D" 'gnus-summary-enter-digest-group)
6845 (define-key gnus-summary-mode-map "V" 'gnus-summary-score-map)
6847 (define-key gnus-summary-mode-map "I" 'gnus-summary-increase-score)
6848 (define-key gnus-summary-mode-map "L" 'gnus-summary-lower-score)
6854 (defun gnus-summary-mode (&optional group)
6855 "Major mode for reading articles.
6857 All normal editing commands are switched off.
6858 \\<gnus-summary-mode-map>
6859 Each line in this buffer represents one article. To read an
6860 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
6861 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
6864 You can also post articles and send mail from this buffer. To
6865 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
6866 of an article, type `\\[gnus-summary-reply]'.
6868 There are approx. one gazillion commands you can execute in this
6869 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
6871 The following commands are available:
6873 \\{gnus-summary-mode-map}"
6875 (when (and menu-bar-mode
6876 (gnus-visual-p 'summary-menu 'menu))
6877 (gnus-summary-make-menu-bar))
6878 (kill-all-local-variables)
6879 (let ((locals gnus-summary-local-variables))
6881 (if (consp (car locals))
6883 (make-local-variable (car (car locals)))
6884 (set (car (car locals)) (eval (cdr (car locals)))))
6885 (make-local-variable (car locals))
6886 (set (car locals) nil))
6887 (setq locals (cdr locals))))
6888 (gnus-make-thread-indent-array)
6889 (gnus-simplify-mode-line)
6890 (setq major-mode 'gnus-summary-mode)
6891 (setq mode-name "Summary")
6892 (make-local-variable 'minor-mode-alist)
6893 (use-local-map gnus-summary-mode-map)
6894 (buffer-disable-undo (current-buffer))
6895 (setq buffer-read-only t) ;Disable modification
6896 (setq truncate-lines t)
6897 (setq selective-display t)
6898 (setq selective-display-ellipses t) ;Display `...'
6899 (setq buffer-display-table gnus-summary-display-table)
6900 (setq gnus-newsgroup-name group)
6901 (run-hooks 'gnus-summary-mode-hook))
6903 (defun gnus-summary-make-display-table ()
6904 ;; Change the display table. Odd characters have a tendency to mess
6905 ;; up nicely formatted displays - we make all possible glyphs
6906 ;; display only a single character.
6908 ;; We start from the standard display table, if any.
6909 (setq gnus-summary-display-table
6910 (or (copy-sequence standard-display-table)
6911 (make-display-table)))
6912 ;; Nix out all the control chars...
6914 (while (>= (setq i (1- i)) 0)
6915 (aset gnus-summary-display-table i [??])))
6916 ;; ... but not newline and cr, of course. (cr is necessary for the
6917 ;; selective display).
6918 (aset gnus-summary-display-table ?\n nil)
6919 (aset gnus-summary-display-table ?\r nil)
6920 ;; We nix out any glyphs over 126 that are not set already.
6922 (while (>= (setq i (1- i)) 127)
6923 ;; Only modify if the entry is nil.
6924 (or (aref gnus-summary-display-table i)
6925 (aset gnus-summary-display-table i [??])))))
6927 (defun gnus-summary-clear-local-variables ()
6928 (let ((locals gnus-summary-local-variables))
6930 (if (consp (car locals))
6931 (and (vectorp (car (car locals)))
6932 (set (car (car locals)) nil))
6933 (and (vectorp (car locals))
6934 (set (car locals) nil)))
6935 (setq locals (cdr locals)))))
6937 ;; Summary data functions.
6939 (defmacro gnus-data-number (data)
6942 (defmacro gnus-data-mark (data)
6945 (defmacro gnus-data-set-mark (data mark)
6946 `(setcar (nthcdr 1 ,data) ,mark))
6948 (defmacro gnus-data-pos (data)
6951 (defmacro gnus-data-set-pos (data pos)
6952 `(setcar (nthcdr 2 ,data) ,pos))
6954 (defmacro gnus-data-header (data)
6957 (defmacro gnus-data-level (data)
6960 (defmacro gnus-data-unread-p (data)
6961 `(= (nth 1 ,data) gnus-unread-mark))
6963 (defmacro gnus-data-pseudo-p (data)
6964 `(consp (nth 3 ,data)))
6966 (defmacro gnus-data-find (number)
6967 `(assq ,number gnus-newsgroup-data))
6969 (defmacro gnus-data-find-list (number &optional data)
6970 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
6971 (memq (assq ,number bdata)
6974 (defmacro gnus-data-make (number mark pos header level)
6975 `(list ,number ,mark ,pos ,header ,level))
6977 (defun gnus-data-enter (after-article number mark pos header level offset)
6978 (let ((data (gnus-data-find-list after-article)))
6979 (or data (error "No such article: %d" after-article))
6980 (setcdr data (cons (gnus-data-make number mark pos header level)
6982 (setq gnus-newsgroup-data-reverse nil)
6983 (gnus-data-update-list (cdr (cdr data)) offset)))
6985 (defun gnus-data-enter-list (after-article list &optional offset)
6987 (let ((data (and after-article (gnus-data-find-list after-article)))
6989 (or data (not after-article) (error "No such article: %d" after-article))
6990 ;; Find the last element in the list to be spliced into the main
6993 (setq list (cdr list)))
6996 (setcdr list gnus-newsgroup-data)
6997 (setq gnus-newsgroup-data ilist)
6998 (and offset (gnus-data-update-list (cdr list) offset)))
6999 (setcdr list (cdr data))
7001 (and offset (gnus-data-update-list (cdr data) offset)))
7002 (setq gnus-newsgroup-data-reverse nil))))
7004 (defun gnus-data-remove (article &optional offset)
7005 (let ((data gnus-newsgroup-data))
7006 (if (= (gnus-data-number (car data)) article)
7007 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7008 gnus-newsgroup-data-reverse nil)
7010 (and (= (gnus-data-number (car (cdr data))) article)
7012 (setcdr data (cdr (cdr data)))
7013 (and offset (gnus-data-update-list (cdr data) offset))
7015 gnus-newsgroup-data-reverse nil)))
7016 (setq data (cdr data))))))
7018 (defmacro gnus-data-list (backward)
7020 (or gnus-newsgroup-data-reverse
7021 (setq gnus-newsgroup-data-reverse
7022 (reverse gnus-newsgroup-data)))
7023 gnus-newsgroup-data))
7025 (defun gnus-data-update-list (data offset)
7026 "Add OFFSET to the POS of all data entries in DATA."
7028 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7029 (setq data (cdr data))))
7031 (defun gnus-data-compute-positions ()
7032 "Compute the positions of all articles."
7033 (let ((data gnus-newsgroup-data)
7036 (when (setq pos (text-property-any
7037 (point-min) (point-max)
7038 'gnus-number (gnus-data-number (car data))))
7039 (gnus-data-set-pos (car data) (+ pos 3)))
7040 (setq data (cdr data)))))
7042 (defun gnus-summary-article-pseudo-p (article)
7043 "Say whether this article is a pseudo article or not."
7044 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7046 (defun gnus-article-parent-p (number)
7047 "Say whether this article is a parent or not."
7048 (let* ((data (gnus-data-find-list number)))
7049 (and (cdr data) ; There has to be an article after...
7050 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7051 (gnus-data-level (nth 1 data))))))
7053 (defmacro gnus-summary-skip-intangible ()
7054 "If the current article is intangible, then jump to a different article."
7055 '(let ((to (get-text-property (point) 'gnus-intangible)))
7057 (gnus-summary-goto-subject to))))
7059 (defmacro gnus-summary-article-intangible-p ()
7060 "Say whether this article is intangible or not."
7061 '(get-text-property (point) 'gnus-intangible))
7063 ;; Some summary mode macros.
7065 (defmacro gnus-summary-article-number ()
7066 "The article number of the article on the current line.
7067 If there isn's an article number here, then we return the current
7070 (gnus-summary-skip-intangible)
7071 (or (get-text-property (point) 'gnus-number)
7072 (gnus-summary-last-subject))))
7074 (defmacro gnus-summary-article-header (&optional number)
7075 `(gnus-data-header (gnus-data-find
7076 ,(or number '(gnus-summary-article-number)))))
7078 (defmacro gnus-summary-thread-level (&optional number)
7079 `(gnus-data-level (gnus-data-find
7080 ,(or number '(gnus-summary-article-number)))))
7082 (defmacro gnus-summary-article-mark (&optional number)
7083 `(gnus-data-mark (gnus-data-find
7084 ,(or number '(gnus-summary-article-number)))))
7086 (defmacro gnus-summary-article-pos (&optional number)
7087 `(gnus-data-pos (gnus-data-find
7088 ,(or number '(gnus-summary-article-number)))))
7090 (defmacro gnus-summary-article-subject (&optional number)
7091 "Return current subject string or nil if nothing."
7094 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7095 '(gnus-data-header (assq (gnus-summary-article-number)
7096 gnus-newsgroup-data)))))
7099 (mail-header-subject headers))))
7101 (defmacro gnus-summary-article-score (&optional number)
7102 "Return current article score."
7103 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7104 gnus-newsgroup-scored))
7105 gnus-summary-default-score 0))
7107 (defun gnus-summary-article-children (&optional number)
7108 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7109 (level (gnus-data-level (car data)))
7111 (while (and (setq data (cdr data))
7112 (> (setq l (gnus-data-level (car data))) level))
7113 (and (= (1+ level) l)
7114 (setq children (cons (gnus-data-number (car data))
7116 (nreverse children)))
7118 (defun gnus-summary-article-parent (&optional number)
7119 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7120 (gnus-data-list t)))
7121 (level (gnus-data-level (car data)))
7124 () ; This is a root.
7125 ;; We search until we find an article with a level less than
7126 ;; this one. That function has to be the parent.
7127 (while (and (setq data (cdr data))
7128 (not (< (gnus-data-level (car data)) level))))
7129 (and data (gnus-data-number (car data))))))
7132 ;; Various summary mode internalish functions.
7134 (defun gnus-mouse-pick-article (e)
7137 (gnus-summary-next-page nil t))
7139 (defun gnus-summary-setup-buffer (group)
7140 "Initialize summary buffer."
7141 (let ((buffer (concat "*Summary " group "*")))
7142 (if (get-buffer buffer)
7145 (setq gnus-summary-buffer (current-buffer))
7146 (not gnus-newsgroup-prepared))
7147 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7148 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7149 (gnus-add-current-to-buffer-list)
7150 (gnus-summary-mode group)
7152 (gnus-carpal-setup-buffer 'summary))
7153 (unless gnus-single-article-buffer
7154 (make-local-variable 'gnus-article-buffer))
7155 (setq gnus-newsgroup-name group)
7158 (defun gnus-set-global-variables ()
7159 ;; Set the global equivalents of the summary buffer-local variables
7160 ;; to the latest values they had. These reflect the summary buffer
7161 ;; that was in action when the last article was fetched.
7162 (when (eq major-mode 'gnus-summary-mode)
7163 (setq gnus-summary-buffer (current-buffer))
7164 (let ((name gnus-newsgroup-name)
7165 (marked gnus-newsgroup-marked)
7166 (unread gnus-newsgroup-unreads)
7167 (headers gnus-current-headers)
7168 (data gnus-newsgroup-data)
7169 (article-buffer gnus-article-buffer)
7170 (score-file gnus-current-score-file))
7172 (set-buffer gnus-group-buffer)
7173 (setq gnus-newsgroup-name name)
7174 (setq gnus-newsgroup-marked marked)
7175 (setq gnus-newsgroup-unreads unread)
7176 (setq gnus-current-headers headers)
7177 (setq gnus-newsgroup-data data)
7178 (setq gnus-article-buffer article-buffer)
7179 (setq gnus-current-score-file score-file)))))
7181 (defun gnus-summary-last-article-p (&optional article)
7182 "Return whether ARTICLE is the last article in the buffer."
7183 (if (not (setq article (or article (gnus-summary-article-number))))
7184 t ; All non-existant numbers are the last article. :-)
7185 (cdr (gnus-data-find-list article))))
7187 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7188 "Insert a dummy root in the summary buffer."
7190 (add-text-properties
7191 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7192 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7194 (defvar gnus-thread-indent-array nil)
7195 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
7196 (defun gnus-make-thread-indent-array ()
7198 (if (and gnus-thread-indent-array
7199 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7201 (setq gnus-thread-indent-array (make-vector 201 "")
7202 gnus-thread-indent-array-level gnus-thread-indent-level)
7204 (aset gnus-thread-indent-array n
7205 (make-string (* n gnus-thread-indent-level) ? ))
7208 (defun gnus-summary-insert-line
7209 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7210 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7211 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7212 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7213 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7214 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7215 (gnus-tmp-score-char
7216 (if (or (null gnus-summary-default-score)
7217 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7218 gnus-summary-zcore-fuzz)) ?
7219 (if (< gnus-tmp-score gnus-summary-default-score)
7220 gnus-score-below-mark gnus-score-over-mark)))
7221 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7222 ((memq gnus-tmp-current gnus-newsgroup-cached)
7224 (gnus-tmp-replied gnus-replied-mark)
7225 ((memq gnus-tmp-current gnus-newsgroup-saved)
7227 (t gnus-unread-mark)))
7228 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7231 ((string-match "(.+)" gnus-tmp-from)
7232 (substring gnus-tmp-from
7233 (1+ (match-beginning 0)) (1- (match-end 0))))
7234 ((string-match "<[^>]+> *$" gnus-tmp-from)
7235 (let ((beg (match-beginning 0)))
7236 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7237 (substring gnus-tmp-from (1+ (match-beginning 0))
7238 (1- (match-end 0))))
7239 (substring gnus-tmp-from 0 beg))))
7241 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7242 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7243 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7244 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7245 (buffer-read-only nil))
7246 (when (string= gnus-tmp-name "")
7247 (setq gnus-tmp-name gnus-tmp-from))
7248 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7251 (progn (eval gnus-summary-line-format-spec) (point))
7252 'gnus-number gnus-tmp-number)
7253 (when (gnus-visual-p 'summary-highlight 'highlight)
7255 (run-hooks 'gnus-summary-update-hook)
7258 (defun gnus-summary-update-line (&optional dont-update)
7259 ;; Update summary line after change.
7260 (when (and gnus-summary-default-score
7261 (not gnus-summary-inhibit-highlight))
7262 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7263 (article (gnus-summary-article-number))
7264 (score (gnus-summary-article-score article)))
7266 (if (and gnus-summary-mark-below
7267 (< (gnus-summary-article-score)
7268 gnus-summary-mark-below))
7269 ;; This article has a low score, so we mark it as read.
7270 (when (memq article gnus-newsgroup-unreads)
7271 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7272 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7273 ;; This article was previously marked as read on account
7274 ;; of a low score, but now it has risen, so we mark it as
7276 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7277 (gnus-summary-update-mark
7278 (if (or (null gnus-summary-default-score)
7279 (<= (abs (- score gnus-summary-default-score))
7280 gnus-summary-zcore-fuzz)) ?
7281 (if (< score gnus-summary-default-score)
7282 gnus-score-below-mark gnus-score-over-mark)) 'score))
7283 ;; Do visual highlighting.
7284 (when (gnus-visual-p 'summary-highlight 'highlight)
7285 (run-hooks 'gnus-summary-update-hook)))))
7287 (defvar gnus-tmp-new-adopts)
7289 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7290 ;; Sum up all elements (and sub-elements) in a list.
7292 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7293 (cond ((and (consp thread) (cdr thread))
7296 'gnus-summary-number-of-articles-in-thread
7300 ((and level (zerop level) gnus-tmp-new-adopts)
7302 'gnus-summary-number-of-articles-in-thread
7303 gnus-tmp-new-adopts)))
7304 ((memq (mail-header-number (car thread))
7305 gnus-newsgroup-limit)
7309 (if (> number 1) gnus-not-empty-thread-mark
7310 gnus-empty-thread-mark)
7313 (defun gnus-summary-set-local-parameters (group)
7314 "Go through the local params of GROUP and set all variable specs in that list."
7315 (let ((params (gnus-info-params (gnus-get-info group)))
7318 (setq elem (car params)
7319 params (cdr params))
7320 (and (consp elem) ; Has to be a cons.
7321 (consp (cdr elem)) ; The cdr has to be a list.
7322 (symbolp (car elem)) ; Has to be a symbol in there.
7323 (progn ; So we set it.
7324 (make-local-variable (car elem))
7325 (set (car elem) (eval (nth 1 elem))))))))
7327 (defun gnus-summary-read-group
7328 (group &optional show-all no-article kill-buffer no-display)
7329 "Start reading news in newsgroup GROUP.
7330 If SHOW-ALL is non-nil, already read articles are also listed.
7331 If NO-ARTICLE is non-nil, no article is selected initially.
7332 If NO-DISPLAY, don't generate a summary buffer."
7333 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7334 (let* ((new-group (gnus-summary-setup-buffer group))
7335 (quit-config (gnus-group-quit-config group))
7336 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7338 ;; This summary buffer exists already, so we just select it.
7340 (gnus-set-global-variables)
7341 (gnus-kill-or-deaden-summary kill-buffer)
7342 (gnus-configure-windows 'summary 'force)
7343 (gnus-set-mode-line 'summary)
7344 (gnus-summary-position-point)
7347 ;; We couldn't select this group.
7349 (when (and (eq major-mode 'gnus-summary-mode)
7350 (not (equal (current-buffer) kill-buffer)))
7351 (kill-buffer (current-buffer))
7352 (if (not quit-config)
7354 (set-buffer gnus-group-buffer)
7355 (gnus-group-jump-to-group group)
7356 (gnus-group-next-unread-group 1))
7357 (if (not (buffer-name (car quit-config)))
7358 (gnus-configure-windows 'group 'force)
7359 (set-buffer (car quit-config))
7360 (and (eq major-mode 'gnus-summary-mode)
7361 (gnus-set-global-variables))
7362 (gnus-configure-windows (cdr quit-config)))))
7363 (gnus-message 3 "Can't select group")
7365 ;; The user did a `C-g' while prompting for number of articles,
7366 ;; so we exit this group.
7367 ((eq did-select 'quit)
7368 (and (eq major-mode 'gnus-summary-mode)
7369 (not (equal (current-buffer) kill-buffer))
7370 (kill-buffer (current-buffer)))
7371 (gnus-kill-or-deaden-summary kill-buffer)
7372 (if (not quit-config)
7374 (set-buffer gnus-group-buffer)
7375 (gnus-group-jump-to-group group)
7376 (gnus-group-next-unread-group 1)
7377 (gnus-configure-windows 'group 'force))
7378 (if (not (buffer-name (car quit-config)))
7379 (gnus-configure-windows 'group 'force)
7380 (set-buffer (car quit-config))
7381 (and (eq major-mode 'gnus-summary-mode)
7382 (gnus-set-global-variables))
7383 (gnus-configure-windows (cdr quit-config))))
7384 ;; Finallt signal the quit.
7386 ;; The group was successfully selected.
7388 (gnus-set-global-variables)
7389 ;; Save the active value in effect when the group was entered.
7390 (setq gnus-newsgroup-active
7392 (gnus-active gnus-newsgroup-name)))
7393 ;; You can change the summary buffer in some way with this hook.
7394 (run-hooks 'gnus-select-group-hook)
7395 ;; Set any local variables in the group parameters.
7396 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7397 ;; Do score processing.
7398 (when gnus-use-scoring
7399 (gnus-possibly-score-headers))
7400 (gnus-update-format-specifications)
7401 ;; Find the initial limit.
7402 (gnus-summary-initial-limit)
7403 ;; Generate the summary buffer.
7405 (gnus-summary-prepare))
7406 ;; If the summary buffer is empty, but there are some low-scored
7407 ;; articles or some excluded dormants, we include these in the
7409 (when (zerop (buffer-size))
7410 (cond (gnus-newsgroup-dormant
7411 (gnus-summary-limit-include-dormant))
7412 ((and gnus-newsgroup-scored show-all)
7413 (gnus-summary-limit-include-expunged))))
7414 ;; Function `gnus-apply-kill-file' must be called in this hook.
7415 (run-hooks 'gnus-apply-kill-hook)
7416 (if (zerop (buffer-size))
7418 ;; This newsgroup is empty.
7419 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7420 (gnus-message 6 "No unread news")
7421 (gnus-kill-or-deaden-summary kill-buffer)
7422 ;; Return nil from this function.
7424 ;; Hide conversation thread subtrees. We cannot do this in
7425 ;; gnus-summary-prepare-hook since kill processing may not
7426 ;; work with hidden articles.
7427 (and gnus-show-threads
7428 gnus-thread-hide-subtree
7429 (gnus-summary-hide-all-threads))
7430 ;; Show first unread article if requested.
7431 (if (and (not no-article)
7432 gnus-newsgroup-unreads
7433 gnus-auto-select-first)
7435 (if (eq gnus-auto-select-first 'best)
7436 (gnus-summary-best-unread-article)
7437 (gnus-summary-first-unread-article)))
7438 ;; Don't select any articles, just move point to the first
7439 ;; article in the group.
7440 (goto-char (point-min))
7441 (gnus-summary-position-point)
7442 (gnus-set-mode-line 'summary)
7443 (gnus-configure-windows 'summary 'force))
7444 ;; If we are in async mode, we send some info to the backend.
7445 (when gnus-newsgroup-async
7446 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7447 (gnus-kill-or-deaden-summary kill-buffer)
7448 (when (get-buffer-window gnus-group-buffer)
7449 ;; Gotta use windows, because recenter does wierd stuff if
7450 ;; the current buffer ain't the displayed window.
7451 (let ((owin (selected-window)))
7452 (select-window (get-buffer-window gnus-group-buffer))
7453 (when (gnus-group-goto-group group)
7455 (select-window owin))))
7456 ;; Mark this buffer as "prepared".
7457 (setq gnus-newsgroup-prepared t)
7460 (defun gnus-summary-prepare ()
7461 "Generate the summary buffer."
7462 (let ((buffer-read-only nil))
7464 (setq gnus-newsgroup-data nil
7465 gnus-newsgroup-data-reverse nil)
7466 (run-hooks 'gnus-summary-generate-hook)
7467 ;; Generate the buffer, either with threads or without.
7468 (gnus-summary-prepare-threads
7469 (if gnus-show-threads
7470 (gnus-gather-threads (gnus-sort-threads (gnus-make-threads)))
7471 gnus-newsgroup-headers))
7472 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7473 ;; Call hooks for modifying summary buffer.
7474 (goto-char (point-min))
7475 (run-hooks 'gnus-summary-prepare-hook)))
7477 (defun gnus-gather-threads (threads)
7478 "Gather threads that have lost their roots."
7479 (if (not gnus-summary-make-false-root)
7481 (let ((hashtb (gnus-make-hashtable 1023))
7484 subject hthread whole-subject)
7487 (setq subject (mail-header-subject (car (car threads)))))
7488 (if (and gnus-summary-gather-exclude-subject
7489 (string-match gnus-summary-gather-exclude-subject
7491 () ; We don't want to do anything with this.
7492 (if gnus-summary-gather-subject-limit
7493 (or (and (numberp gnus-summary-gather-subject-limit)
7494 (> (length subject) gnus-summary-gather-subject-limit)
7496 (substring subject 0
7497 gnus-summary-gather-subject-limit)))
7498 (and (eq 'fuzzy gnus-summary-gather-subject-limit)
7499 (setq subject (gnus-simplify-subject-fuzzy subject))))
7500 (setq subject (gnus-simplify-subject-re subject)))
7502 (gnus-gethash subject hashtb))
7504 (or (stringp (car (car hthread)))
7505 (setcar hthread (list whole-subject (car hthread))))
7506 (setcdr (car hthread) (nconc (cdr (car hthread))
7507 (list (car threads))))
7508 (setcdr prev (cdr threads))
7509 (setq threads prev))
7510 (gnus-sethash subject threads hashtb)))
7512 (setq threads (cdr threads)))
7515 (defun gnus-make-threads ()
7516 "Go through the dependency hashtb and find the roots. Return all threads."
7517 ;; Then we find all the roots and return all the threads.
7521 (or (car (symbol-value refs))
7522 (setq threads (append (cdr (symbol-value refs)) threads))))
7523 gnus-newsgroup-dependencies)
7526 (defun gnus-build-old-threads ()
7527 ;; Look at all the articles that refer back to old articles, and
7528 ;; fetch the headers for the articles that aren't there. This will
7529 ;; build complete threads - if the roots haven't been expired by the
7534 (when (not (car (symbol-value refs)))
7535 (setq heads (cdr (symbol-value refs)))
7537 (if (memq (mail-header-number (car (car heads)))
7538 gnus-newsgroup-dormant)
7539 (setq heads (cdr heads))
7540 (setq id (symbol-name refs))
7541 (while (and (setq id (gnus-build-get-header id))
7542 (not (car (gnus-gethash
7543 id gnus-newsgroup-dependencies)))))
7544 (setq heads nil)))))
7545 gnus-newsgroup-dependencies)))
7547 (defun gnus-build-get-header (id)
7548 ;; Look through the buffer of NOV lines and find the header to
7549 ;; ID. Enter this line into the dependencies hash table, and return
7550 ;; the id of the parent article (if any).
7551 (let ((deps gnus-newsgroup-dependencies)
7555 (set-buffer nntp-server-buffer)
7556 (goto-char (point-min))
7557 (while (and (not found) (search-forward id nil t))
7559 (setq found (looking-at
7560 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
7561 (regexp-quote id))))
7562 (or found (beginning-of-line 2)))
7567 (setq header (gnus-nov-parse-line
7568 (read (current-buffer)) deps))
7569 (gnus-parent-id (mail-header-references header))))))
7571 (let ((number (mail-header-number header)))
7572 (push number gnus-newsgroup-limit)
7573 (push header gnus-newsgroup-headers)
7574 (push number gnus-newsgroup-ancient))))))
7576 (defun gnus-rebuild-thread (id)
7577 "Rebuild the thread containing ID."
7578 (let ((dep gnus-newsgroup-dependencies)
7579 (buffer-read-only nil)
7580 current headers refs thread art data)
7581 (if (not gnus-show-threads)
7582 (setq thread (list (car (gnus-gethash (downcase id) dep))))
7583 ;; Get the thread this article is part of.
7584 (setq thread (gnus-remove-thread id)))
7585 (setq current (save-excursion
7586 (and (zerop (forward-line -1))
7587 (gnus-summary-article-number))))
7588 ;; If this is a gathered thread, we have to go some re-gathering.
7589 (when (stringp (car thread))
7590 (let ((subject (car thread))
7592 (setq thread (cdr thread))
7594 (unless (memq (setq thr (gnus-id-to-thread
7596 (mail-header-id (car (car thread))))))
7599 (setq thread (cdr thread)))
7600 ;; We now have all (unique) roots.
7601 (if (= (length roots) 1)
7602 ;; All the loose roots are now one solid root.
7603 (setq thread (car roots))
7604 (setq thread (cons subject (gnus-sort-threads roots))))))
7607 ;; We then insert this thread into the summary buffer.
7608 (let (gnus-newsgroup-data gnus-newsgroup-threads)
7609 (gnus-summary-prepare-threads (list thread))
7610 (setq data (nreverse gnus-newsgroup-data))
7611 (setq threads gnus-newsgroup-threads))
7612 ;; We splice the new data into the data structure.
7613 (gnus-data-enter-list current data)
7614 (gnus-data-compute-positions)
7615 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
7617 (defun gnus-id-to-thread (id)
7618 "Return the (sub-)thread where ID appears."
7619 (gnus-gethash (downcase id) gnus-newsgroup-dependencies))
7621 (defun gnus-root-id (id)
7622 "Return the id of the root of the thread where ID appears."
7624 (while (and id (setq prev (car (gnus-gethash
7626 gnus-newsgroup-dependencies))))
7628 id (gnus-parent-id (mail-header-references prev))))
7631 (defun gnus-remove-thread (id)
7632 "Remove the thread that has ID in it."
7633 (let ((dep gnus-newsgroup-dependencies)
7634 headers thread prev last-id)
7635 ;; First go up in this thread until we find the root.
7636 (setq last-id (gnus-root-id id))
7637 (setq headers (list (car (gnus-id-to-thread last-id))
7638 (car (car (cdr (gnus-id-to-thread last-id))))))
7639 ;; We have now found the real root of this thread. It might have
7640 ;; been gathered into some loose thread, so we have to search
7641 ;; through the threads to find the thread we wanted.
7642 (let ((threads gnus-newsgroup-threads)
7645 (setq sub (car threads))
7646 (if (stringp (car sub))
7647 ;; This is a gathered threads, so we look at the roots
7648 ;; below it to find whether this article in in this
7651 (setq sub (cdr sub))
7653 (when (member (car (car sub)) headers)
7654 (setq thread (car threads)
7657 (setq sub (cdr sub))))
7658 ;; It's an ordinary thread, so we check it.
7659 (when (eq (car sub) (car headers))
7662 (setq threads (cdr threads)))
7663 ;; If this article is in no thread, then it's a root.
7665 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads))
7666 (setq thread (gnus-gethash (downcase last-id) dep)))
7669 thread ; We return this thread.
7670 (if (stringp (car thread))
7672 ;; If we use dummy roots, then we have to remove the
7673 ;; dummy root as well.
7674 (when (eq gnus-summary-make-false-root 'dummy)
7677 (setq thread (cdr thread))
7679 (gnus-remove-thread-1 (car thread))
7680 (setq thread (cdr thread))))
7681 (gnus-remove-thread-1 thread)))))))
7683 (defun gnus-remove-thread-1 (thread)
7684 "Remove the thread THREAD recursively."
7685 (let ((number (mail-header-number (car thread)))
7687 (when (setq pos (text-property-any
7688 (point-min) (point-max) 'gnus-number number))
7691 (gnus-data-remove number))
7692 (setq thread (cdr thread))
7694 (gnus-remove-thread-1 (car thread))
7695 (setq thread (cdr thread)))))
7697 (defun gnus-sort-threads (threads)
7698 "Sort THREADS as specified in `gnus-thread-sort-functions'."
7699 (let ((funs gnus-thread-sort-functions))
7702 (gnus-message 7 "Sorting with %S..." (car funs))
7703 (setq threads (sort threads (pop funs))))
7704 (gnus-message 7 "Sorting...done")))
7707 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
7708 (defmacro gnus-thread-header (thread)
7709 ;; Return header of first article in THREAD.
7710 ;; Note that THREAD must never, ever be anything else than a variable -
7711 ;; using some other form will lead to serious barfage.
7712 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
7713 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
7714 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
7717 (defsubst gnus-article-sort-by-number (h1 h2)
7718 "Sort articles by article number."
7719 (< (mail-header-number h1)
7720 (mail-header-number h2)))
7722 (defun gnus-thread-sort-by-number (h1 h2)
7723 "Sort threads by root article number."
7724 (gnus-article-sort-by-number
7725 (gnus-thread-header h1) (gnus-thread-header h2)))
7727 (defsubst gnus-article-sort-by-author (h1 h2)
7728 "Sort articles by root author."
7730 (let ((extract (funcall
7731 gnus-extract-address-components
7732 (mail-header-from h1))))
7733 (or (car extract) (cdr extract)))
7734 (let ((extract (funcall
7735 gnus-extract-address-components
7736 (mail-header-from h2))))
7737 (or (car extract) (cdr extract)))))
7739 (defun gnus-thread-sort-by-author (h1 h2)
7740 "Sort threads by root author."
7741 (gnus-article-sort-by-author
7742 (gnus-thread-header h1) (gnus-thread-header h2)))
7744 (defsubst gnus-article-sort-by-subject (h1 h2)
7745 "Sort articles by root subject."
7747 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
7748 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
7750 (defun gnus-thread-sort-by-subject (h1 h2)
7751 "Sort threads by root subject."
7752 (gnus-article-sort-by-subject
7753 (gnus-thread-header h1) (gnus-thread-header h2)))
7755 (defsubst gnus-article-sort-by-date (h1 h2)
7756 "Sort articles by root article date."
7758 (gnus-sortable-date (mail-header-date h1))
7759 (gnus-sortable-date (mail-header-date h2))))
7761 (defun gnus-thread-sort-by-date (h1 h2)
7762 "Sort threads by root article date."
7763 (gnus-article-sort-by-date
7764 (gnus-thread-header h1) (gnus-thread-header h2)))
7766 (defsubst gnus-article-sort-by-score (h1 h2)
7767 "Sort articles by root article score.
7768 Unscored articles will be counted as having a score of zero."
7769 (> (or (cdr (assq (mail-header-number h1)
7770 gnus-newsgroup-scored))
7771 gnus-summary-default-score 0)
7772 (or (cdr (assq (mail-header-number h2)
7773 gnus-newsgroup-scored))
7774 gnus-summary-default-score 0)))
7776 (defun gnus-thread-sort-by-score (h1 h2)
7777 "Sort threads by root article score."
7778 (gnus-article-sort-by-score
7779 (gnus-thread-header h1) (gnus-thread-header h2)))
7781 (defun gnus-thread-sort-by-total-score (h1 h2)
7782 "Sort threads by the sum of all scores in the thread.
7783 Unscored articles will be counted as having a score of zero."
7784 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
7786 (defun gnus-thread-total-score (thread)
7787 ;; This function find the total score of THREAD.
7789 (if (stringp (car thread))
7790 (apply gnus-thread-score-function 0
7791 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
7792 (gnus-thread-total-score-1 thread))
7793 (gnus-thread-total-score-1 (list thread))))
7795 (defun gnus-thread-total-score-1 (root)
7796 ;; This function find the total score of the thread below ROOT.
7797 (setq root (car root))
7798 (apply gnus-thread-score-function
7799 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
7800 gnus-summary-default-score 0)
7801 (mapcar 'gnus-thread-total-score
7802 (cdr (gnus-gethash (downcase (mail-header-id root))
7803 gnus-newsgroup-dependencies)))))
7805 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
7806 (defvar gnus-tmp-prev-subject nil)
7807 (defvar gnus-tmp-false-parent nil)
7808 (defvar gnus-tmp-root-expunged nil)
7809 (defvar gnus-tmp-dummy-line nil)
7811 (defun gnus-summary-prepare-threads (threads)
7812 "Prepare summary buffer from THREADS and indentation LEVEL.
7813 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
7814 or a straight list of headers."
7815 (gnus-message 7 "Generating summary...")
7817 (setq gnus-newsgroup-threads threads)
7820 (let ((gnus-tmp-level 0)
7821 (default-score (or gnus-summary-default-score 0))
7822 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
7823 thread number subject stack state gnus-tmp-gathered beg-match
7824 new-roots gnus-tmp-new-adopts thread-end
7825 gnus-tmp-header gnus-tmp-unread
7826 gnus-tmp-replied gnus-tmp-subject-or-nil
7827 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
7828 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
7829 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
7831 (setq gnus-tmp-prev-subject nil)
7833 (if (vectorp (car threads))
7834 ;; If this is a straight (sic) list of headers, then a
7835 ;; threaded summary display isn't required, so we just create
7836 ;; an unthreaded one.
7837 (gnus-summary-prepare-unthreaded threads)
7839 ;; Do the threaded display.
7841 (while (or threads stack gnus-tmp-new-adopts new-roots)
7843 (if (and (= gnus-tmp-level 0)
7844 (not (setq gnus-tmp-dummy-line nil))
7846 (= (car (car stack)) 0))
7847 (not gnus-tmp-false-parent)
7848 (or gnus-tmp-new-adopts new-roots))
7849 (if gnus-tmp-new-adopts
7850 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
7851 thread (list (car gnus-tmp-new-adopts))
7852 gnus-tmp-header (car (car thread))
7853 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
7855 (setq thread (list (car new-roots))
7856 gnus-tmp-header (car (car thread))
7857 new-roots (cdr new-roots))))
7860 ;; If there are some threads, we do them before the
7861 ;; threads on the stack.
7862 (setq thread threads
7863 gnus-tmp-header (car (car thread)))
7864 ;; There were no current threads, so we pop something off
7866 (setq state (car stack)
7867 gnus-tmp-level (car state)
7870 gnus-tmp-header (car (car thread)))))
7872 (setq gnus-tmp-false-parent nil)
7873 (setq gnus-tmp-root-expunged nil)
7874 (setq thread-end nil)
7876 (if (stringp gnus-tmp-header)
7877 ;; The header is a dummy root.
7879 ((eq gnus-summary-make-false-root 'adopt)
7880 ;; We let the first article adopt the rest.
7881 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
7882 (cdr (cdr (car thread)))))
7883 (setq gnus-tmp-gathered
7885 (lambda (h) (mail-header-number (car h)))
7886 (cdr (cdr (car thread))))
7888 (setq thread (cons (list (car (car thread))
7889 (car (cdr (car thread))))
7891 (setq gnus-tmp-level -1
7892 gnus-tmp-false-parent t))
7893 ((eq gnus-summary-make-false-root 'empty)
7894 ;; We print adopted articles with empty subject fields.
7895 (setq gnus-tmp-gathered
7897 (lambda (h) (mail-header-number (car h)))
7898 (cdr (cdr (car thread))))
7900 (setq gnus-tmp-level -1))
7901 ((eq gnus-summary-make-false-root 'dummy)
7902 ;; We remember that we probably want to output a dummy
7904 (setq gnus-tmp-dummy-line gnus-tmp-header)
7905 (setq gnus-tmp-prev-subject gnus-tmp-header))
7907 ;; We do not make a root for the gathered
7908 ;; sub-threads at all.
7909 (setq gnus-tmp-level -1)))
7911 (setq number (mail-header-number gnus-tmp-header)
7912 subject (mail-header-subject gnus-tmp-header))
7915 ;; If the thread has changed subject, we might want to make
7916 ;; this subthread into a root.
7917 ((and (null gnus-thread-ignore-subject)
7918 (not (zerop gnus-tmp-level))
7919 gnus-tmp-prev-subject
7921 (gnus-subject-equal gnus-tmp-prev-subject subject))))
7922 (setq new-roots (nconc new-roots (list (car thread)))
7924 gnus-tmp-header nil))
7925 ;; If the article lies outside the current limit,
7926 ;; then we do not display it.
7927 ((not (memq number gnus-newsgroup-limit))
7928 (setq gnus-tmp-gathered
7930 (lambda (h) (mail-header-number (car h)))
7933 (setq gnus-tmp-new-adopts (if (cdr (car thread))
7934 (append gnus-tmp-new-adopts
7936 gnus-tmp-new-adopts)
7938 gnus-tmp-header nil)
7939 (when (zerop gnus-tmp-level)
7940 (setq gnus-tmp-root-expunged t)))
7941 ;; Perhaps this article is to be marked as read?
7942 ((and gnus-summary-mark-below
7943 (< (or (cdr (assq number gnus-newsgroup-scored))
7945 gnus-summary-mark-below))
7946 (setq gnus-newsgroup-unreads
7947 (delq number gnus-newsgroup-unreads))
7948 (if gnus-newsgroup-auto-expire
7949 (push number gnus-newsgroup-expirable)
7950 (push (cons number gnus-low-score-mark)
7951 gnus-newsgroup-reads))))
7953 (when gnus-tmp-header
7954 ;; We may have an old dummy line to output before this
7956 (when gnus-tmp-dummy-line
7957 (gnus-summary-insert-dummy-line
7958 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
7959 (setq gnus-tmp-dummy-line nil))
7961 ;; Compute the mark.
7965 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
7966 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
7967 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
7968 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
7969 (t (or (cdr (assq number gnus-newsgroup-reads))
7970 gnus-ancient-mark))))
7972 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
7973 gnus-tmp-header gnus-tmp-level)
7974 gnus-newsgroup-data)
7976 ;; Actually insert the line.
7978 gnus-tmp-subject-or-nil
7980 ((and gnus-thread-ignore-subject
7981 gnus-tmp-prev-subject
7982 (not (inline (gnus-subject-equal
7983 gnus-tmp-prev-subject subject))))
7985 ((zerop gnus-tmp-level)
7986 (if (and (eq gnus-summary-make-false-root 'empty)
7987 (memq number gnus-tmp-gathered)
7988 gnus-tmp-prev-subject
7989 (inline (gnus-subject-equal
7990 gnus-tmp-prev-subject subject)))
7991 gnus-summary-same-subject
7993 (t gnus-summary-same-subject)))
7994 (if (and (eq gnus-summary-make-false-root 'adopt)
7995 (= gnus-tmp-level 1)
7996 (memq number gnus-tmp-gathered))
7997 (setq gnus-tmp-opening-bracket ?\<
7998 gnus-tmp-closing-bracket ?\>)
7999 (setq gnus-tmp-opening-bracket ?\[
8000 gnus-tmp-closing-bracket ?\]))
8002 gnus-tmp-indentation
8003 (aref gnus-thread-indent-array gnus-tmp-level)
8004 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8005 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8006 gnus-summary-default-score 0)
8008 (if (or (null gnus-summary-default-score)
8009 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8010 gnus-summary-zcore-fuzz)) ?
8011 (if (< gnus-tmp-score gnus-summary-default-score)
8012 gnus-score-below-mark gnus-score-over-mark))
8014 (cond ((memq number gnus-newsgroup-processable)
8016 ((memq number gnus-newsgroup-cached)
8018 ((memq number gnus-newsgroup-replied)
8020 (t gnus-unread-mark))
8021 gnus-tmp-from (mail-header-from gnus-tmp-header)
8024 ((string-match "(.+)" gnus-tmp-from)
8025 (substring gnus-tmp-from
8026 (1+ (match-beginning 0)) (1- (match-end 0))))
8027 ((string-match "<[^>]+> *$" gnus-tmp-from)
8028 (setq beg-match (match-beginning 0))
8029 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8030 (substring gnus-tmp-from (1+ (match-beginning 0))
8031 (1- (match-end 0))))
8032 (substring gnus-tmp-from 0 beg-match)))
8034 (when (string= gnus-tmp-name "")
8035 (setq gnus-tmp-name gnus-tmp-from))
8036 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8039 (progn (eval gnus-summary-line-format-spec) (point))
8040 'gnus-number number)
8043 (run-hooks 'gnus-summary-update-hook)
8046 (setq gnus-tmp-prev-subject subject)))
8048 (when (nth 1 thread)
8049 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8050 (incf gnus-tmp-level)
8051 (setq threads (if thread-end nil (cdr (car thread))))
8053 (setq gnus-tmp-level 0)))))
8054 (gnus-message 7 "Generating summary...done"))
8056 (defun gnus-summary-prepare-unthreaded (headers)
8057 "Generate an unthreaded summary buffer based on HEADERS."
8058 (let (header number mark)
8061 (setq header (car headers)
8062 headers (cdr headers)
8063 number (mail-header-number header))
8065 ;; We may have to root out some bad articles...
8066 (when (memq number gnus-newsgroup-limit)
8067 (when (and gnus-summary-mark-below
8068 (< (or (cdr (assq number gnus-newsgroup-scored))
8069 gnus-summary-default-score 0)
8070 gnus-summary-mark-below))
8071 (setq gnus-newsgroup-unreads
8072 (delq number gnus-newsgroup-unreads))
8073 (if gnus-newsgroup-auto-expire
8074 (push number gnus-newsgroup-expirable)
8075 (push (cons number gnus-low-score-mark)
8076 gnus-newsgroup-reads)))
8080 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8081 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8082 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8083 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8084 (t (or (cdr (assq number gnus-newsgroup-reads))
8085 gnus-ancient-mark))))
8086 (setq gnus-newsgroup-data
8087 (cons (gnus-data-make number mark (1+ (point)) header 0)
8088 gnus-newsgroup-data))
8089 (gnus-summary-insert-line
8090 header 0 nil mark (memq number gnus-newsgroup-replied)
8091 (memq number gnus-newsgroup-expirable)
8092 (mail-header-subject header) nil
8093 (cdr (assq number gnus-newsgroup-scored))
8094 (memq number gnus-newsgroup-processable))))))
8096 (defun gnus-select-newsgroup (group &optional read-all)
8097 "Select newsgroup GROUP.
8098 If READ-ALL is non-nil, all articles in the group are selected."
8099 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8100 (info (nth 2 entry))
8101 articles fetched-articles)
8103 (or (gnus-check-server
8104 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8105 (error "Couldn't open server"))
8107 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8108 (gnus-activate-group group) ; Or we can activate it...
8109 (progn ; Or we bug out.
8110 (kill-buffer (current-buffer))
8111 (error "Couldn't request group %s: %s"
8112 group (gnus-status-message group))))
8114 (setq gnus-newsgroup-name group)
8115 (setq gnus-newsgroup-unselected nil)
8116 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8118 (and gnus-asynchronous
8119 (gnus-check-backend-function
8120 'request-asynchronous gnus-newsgroup-name)
8121 (setq gnus-newsgroup-async
8122 (gnus-request-asynchronous gnus-newsgroup-name)))
8124 ;; Adjust and set lists of article marks.
8126 (gnus-adjust-marked-articles info))
8128 (setq gnus-newsgroup-unreads
8129 (gnus-set-difference
8130 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8131 gnus-newsgroup-dormant))
8133 (setq gnus-newsgroup-processable nil)
8135 (setq articles (gnus-articles-to-read group read-all))
8139 (gnus-message 3 "Couldn't select newsgroup")
8141 ((eq articles 0) nil)
8143 ;; Init the dependencies hash table.
8144 (setq gnus-newsgroup-dependencies
8145 (gnus-make-hashtable (length articles)))
8146 ;; Retrieve the headers and read them in.
8147 (gnus-message 5 "Fetching headers...")
8148 (setq gnus-newsgroup-headers
8150 (setq gnus-headers-retrieved-by
8151 (gnus-retrieve-headers
8152 articles gnus-newsgroup-name
8153 ;; We might want to fetch old headers, but
8154 ;; not if there is only 1 article.
8155 (and gnus-fetch-old-headers
8157 (not (eq gnus-fetch-old-headers 'some))
8158 (not (numberp gnus-fetch-old-headers)))
8159 (> (length articles) 1))))))
8160 (gnus-get-newsgroup-headers-xover articles)
8161 (gnus-get-newsgroup-headers)))
8162 (gnus-message 5 "Fetching headers...done")
8163 ;; Set the initial limit.
8164 (setq gnus-newsgroup-limit (copy-sequence articles))
8165 ;; Remove canceled articles from the list of unread articles.
8166 (setq gnus-newsgroup-unreads
8167 (gnus-set-sorted-intersection
8168 gnus-newsgroup-unreads
8169 (setq fetched-articles
8170 (mapcar (lambda (headers) (mail-header-number headers))
8171 gnus-newsgroup-headers))))
8172 ;; Removed marked articles that do not exist.
8173 (gnus-update-missing-marks
8174 (gnus-sorted-complement fetched-articles articles))
8175 ;; We might want to build some more threads first.
8176 (and gnus-fetch-old-headers
8177 (eq gnus-headers-retrieved-by 'nov)
8178 (gnus-build-old-threads))
8179 ;; Check whether auto-expire is to be done in this group.
8180 (setq gnus-newsgroup-auto-expire
8181 (gnus-group-auto-expirable-p group))
8182 ;; First and last article in this newsgroup.
8183 (and gnus-newsgroup-headers
8184 (setq gnus-newsgroup-begin
8185 (mail-header-number (car gnus-newsgroup-headers)))
8186 (setq gnus-newsgroup-end
8188 (gnus-last-element gnus-newsgroup-headers))))
8189 (setq gnus-reffed-article-number -1)
8190 ;; GROUP is successfully selected.
8191 (or gnus-newsgroup-headers t)))))
8193 (defun gnus-articles-to-read (group read-all)
8194 ;; Find out what articles the user wants to read.
8196 ;; Select all articles if `read-all' is non-nil, or if there
8197 ;; are no unread articles.
8199 (and (zerop (length gnus-newsgroup-marked))
8200 (zerop (length gnus-newsgroup-unreads))))
8201 (gnus-uncompress-range (gnus-active group))
8202 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8203 (copy-sequence gnus-newsgroup-unreads))
8205 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8206 (scored (length scored-list))
8207 (number (length articles))
8208 (marked (+ (length gnus-newsgroup-marked)
8209 (length gnus-newsgroup-dormant)))
8217 ((and (or (<= scored marked) (= scored number))
8218 (numberp gnus-large-newsgroup)
8219 (> number gnus-large-newsgroup))
8223 "How many articles from %s (default %d): "
8224 gnus-newsgroup-name number))))
8225 (if (string-match "^[ \t]*$" input) number input)))
8226 ((and (> scored marked) (< scored number))
8229 (format "%s %s (%d scored, %d total): "
8230 "How many articles from"
8231 group scored number))))
8232 (if (string-match "^[ \t]*$" input)
8236 (setq select (if (stringp select) (string-to-number select) select))
8237 (if (or (null select) (zerop select))
8239 (if (and (not (zerop scored)) (<= (abs select) scored))
8241 (setq articles (sort scored-list '<))
8242 (setq number (length articles)))
8243 (setq articles (copy-sequence articles)))
8245 (if (< (abs select) number)
8247 ;; Select the N oldest articles.
8248 (setcdr (nthcdr (1- (abs select)) articles) nil)
8249 ;; Select the N most recent articles.
8250 (setq articles (nthcdr (- number select) articles))))
8251 (setq gnus-newsgroup-unselected
8252 (gnus-sorted-intersection
8253 gnus-newsgroup-unreads
8254 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8257 (defun gnus-killed-articles (killed articles)
8260 (if (inline (gnus-member-of-range (car articles) killed))
8261 (setq out (cons (car articles) out)))
8262 (setq articles (cdr articles)))
8265 (defun gnus-adjust-marked-articles (info)
8266 "Set all article lists and remove all marks that are no longer legal."
8267 (let* ((marked-lists (gnus-info-marks info))
8268 (active (gnus-active (gnus-info-group info)))
8271 (types gnus-article-mark-lists)
8272 (uncompressed '(score bookmark))
8273 marks var articles article mark)
8276 (setq marks (pop marked-lists))
8277 (set (setq var (intern (format "gnus-newsgroup-%s"
8278 (car (rassq (setq mark (car marks))
8280 (if (memq (car marks) uncompressed) (cdr marks)
8281 (gnus-uncompress-range (cdr marks))))
8283 (setq articles (symbol-value var))
8285 ;; All articles have to be subsets of the active articles.
8287 ;; Adjust "simple" lists.
8288 ((memq mark '(tick dormant expirable reply killed save))
8290 (when (or (< (setq article (pop articles)) min) (> article max))
8291 (set var (delq article (symbol-value var))))))
8293 ((memq mark '(score bookmark))
8295 (when (or (< (car (setq article (pop articles))) min)
8296 (> (car article) max))
8297 (set var (delq article (symbol-value var))))))))))
8299 (defun gnus-update-missing-marks (missing)
8300 "Go through the list of MISSING articles and remove them mark lists."
8302 (let ((types gnus-article-mark-lists)
8304 ;; Go through all types.
8306 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8307 (when (symbol-value var)
8308 ;; This list has articles. So we delete all missing articles
8312 (set var (delq (pop m) (symbol-value var)))))))))
8314 (defun gnus-update-marks ()
8315 "Enter the various lists of marked articles into the newsgroup info list."
8316 (let ((types gnus-article-mark-lists)
8317 (info (gnus-get-info gnus-newsgroup-name))
8318 (uncompressed '(score bookmark killed))
8319 var type list newmarked symbol)
8320 ;; Add all marks lists that are non-nil to the list of marks lists.
8322 (setq type (pop types))
8323 (when (setq list (symbol-value
8325 (intern (format "gnus-newsgroup-%s"
8327 (push (cons (cdr type)
8328 (if (memq (cdr type) uncompressed) list
8329 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8332 ;; Enter these new marks into the info of the group.
8334 (setcar (nthcdr 3 info) newmarked)
8335 ;; Add the marks lists to the end of the info.
8337 (setcdr (nthcdr 2 info) (list newmarked))))
8339 ;; Cut off the end of the info if there's nothing else there.
8343 (when (nthcdr (decf i) info)
8344 (setcdr (nthcdr i info) nil))))))
8346 (defun gnus-add-marked-articles (group type articles &optional info force)
8347 ;; Add ARTICLES of TYPE to the info of GROUP.
8348 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8349 ;; add, but replace marked articles of TYPE with ARTICLES.
8350 (let ((info (or info (gnus-get-info group)))
8351 (uncompressed '(score bookmark killed))
8354 (and (not (setq marked (nthcdr 3 info)))
8355 (setcdr (nthcdr 2 info)
8356 (list (list (cons type (gnus-compress-sequence
8358 (and (not (setq m (assq type (car marked))))
8360 (cons (cons type (gnus-compress-sequence articles t) )
8363 (setcdr m (gnus-compress-sequence articles t))
8364 (setcdr m (gnus-compress-sequence
8365 (sort (nconc (gnus-uncompress-range m)
8366 (copy-sequence articles)) '<) t))))))
8368 (defun gnus-set-mode-line (where)
8369 "This function sets the mode line of the article or summary buffers.
8370 If WHERE is `summary', the summary mode line format will be used."
8371 ;; Is this mode line one we keep updated?
8372 (when (memq where gnus-updated-mode-lines)
8375 ;; We evaluate this in the summary buffer since these
8376 ;; variables are buffer-local to that buffer.
8377 (set-buffer gnus-summary-buffer)
8378 ;; We bind all these variables that are used in the `eval' form
8380 (let* ((mformat (if (eq where 'article)
8381 gnus-article-mode-line-format-spec
8382 gnus-summary-mode-line-format-spec))
8383 (gnus-tmp-group-name gnus-newsgroup-name)
8384 (gnus-tmp-article-number (or gnus-current-article 0))
8385 (gnus-tmp-unread gnus-newsgroup-unreads)
8386 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
8387 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
8388 (gnus-tmp-unread-and-unselected
8389 (cond ((and (zerop gnus-tmp-unread-and-unticked)
8390 (zerop gnus-tmp-unselected)) "")
8391 ((zerop gnus-tmp-unselected)
8392 (format "{%d more}" gnus-tmp-unread-and-unticked))
8393 (t (format "{%d(+%d) more}"
8394 gnus-tmp-unread-and-unticked
8395 gnus-tmp-unselected))))
8397 (if (and gnus-current-headers
8398 (vectorp gnus-current-headers))
8399 (mail-header-subject gnus-current-headers) ""))
8401 header);; passed as argument to any user-format-funcs
8402 (setq mode-string (eval mformat))
8403 (setq max-len (max 4 (if gnus-mode-non-string-length
8405 gnus-mode-non-string-length)
8406 (length mode-string))))
8407 ;; We might have to chop a bit of the string off...
8408 (when (> (length mode-string) max-len)
8410 (concat (gnus-truncate-string mode-string (- max-len 3))
8412 ;; Pad the mode string a bit.
8413 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
8414 ;; Update the mode line.
8415 (setq mode-line-buffer-identification (list mode-string))
8416 (set-buffer-modified-p t))))
8418 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
8419 "Go through the HEADERS list and add all Xrefs to a hash table.
8420 The resulting hash table is returned, or nil if no Xrefs were found."
8421 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
8422 (virtual (memq 'virtual
8423 (assoc (symbol-name (car (gnus-find-method-for-group
8425 gnus-valid-select-methods)))
8426 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
8427 (xref-hashtb (make-vector 63 0))
8428 start group entry number xrefs header)
8430 (setq header (pop headers))
8431 (when (and (setq xrefs (mail-header-xref header))
8432 (not (memq (setq number (mail-header-number header))
8435 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
8436 (setq start (match-end 0))
8437 (setq group (concat prefix (substring xrefs (match-beginning 1)
8440 (string-to-int (substring xrefs (match-beginning 2)
8442 (if (setq entry (gnus-gethash group xref-hashtb))
8443 (setcdr entry (cons number (cdr entry)))
8444 (gnus-sethash group (cons number nil) xref-hashtb)))))
8445 (and start xref-hashtb)))
8447 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
8448 "Look through all the headers and mark the Xrefs as read."
8449 (let ((virtual (memq 'virtual
8450 (assoc (symbol-name (car (gnus-find-method-for-group
8452 gnus-valid-select-methods)))
8453 name entry info xref-hashtb idlist method
8456 (set-buffer gnus-group-buffer)
8457 (when (setq xref-hashtb
8458 (gnus-create-xref-hashtb from-newsgroup headers unreads))
8461 (unless (string= from-newsgroup (setq name (symbol-name group)))
8462 (setq idlist (symbol-value group))
8463 ;; Dead groups are not updated.
8465 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
8467 (if (stringp (setq nth4 (gnus-info-method info)))
8468 (setq nth4 (gnus-server-to-method nth4))))
8469 ;; Only do the xrefs if the group has the same
8470 ;; select method as the group we have just read.
8471 (or (gnus-methods-equal-p
8472 nth4 (gnus-find-method-for-group from-newsgroup))
8474 (equal nth4 (setq method (gnus-find-method-for-group
8476 (and (equal (car nth4) (car method))
8477 (equal (nth 1 nth4) (nth 1 method))))
8478 gnus-use-cross-reference
8479 (or (not (eq gnus-use-cross-reference t))
8481 ;; Only do cross-references on subscribed
8482 ;; groups, if that is what is wanted.
8483 (<= (gnus-info-level info) gnus-level-subscribed))
8484 (gnus-group-make-articles-read name idlist))))
8487 (defun gnus-group-make-articles-read (group articles)
8489 (entry (gnus-gethash group gnus-newsrc-hashtb))
8490 (info (nth 2 entry))
8491 (active (gnus-active group))
8493 ;; First peel off all illegal article numbers.
8495 (let ((ids articles)
8499 (if (and first (> id (cdr active)))
8501 ;; We'll end up in this situation in one particular
8502 ;; obscure situation. If you re-scan a group and get
8503 ;; a new article that is cross-posted to a different
8504 ;; group that has not been re-scanned, you might get
8505 ;; crossposted article that has a higher number than
8506 ;; Gnus believes possible. So we re-activate this
8507 ;; group as well. This might mean doing the
8508 ;; crossposting thingie will *increase* the number
8509 ;; of articles in some groups. Tsk, tsk.
8510 (setq active (or (gnus-activate-group group) active))))
8511 (if (or (> id (cdr active))
8512 (< id (car active)))
8513 (setq articles (delq id articles)))
8514 (setq ids (cdr ids)))))
8515 ;; If the read list is nil, we init it.
8517 (null (gnus-info-read info))
8519 (gnus-info-set-read info (cons 1 (1- (car active)))))
8520 ;; Then we add the read articles to the range.
8525 (gnus-info-read info) (setq articles (sort articles '<)))))
8526 ;; Then we have to re-compute how many unread
8527 ;; articles there are in this group.
8532 (setq num (- (1+ (cdr active)) (car active))))
8533 ((not (listp (cdr range)))
8534 (setq num (- (cdr active) (- (1+ (cdr range))
8538 (if (numberp (car range))
8540 (setq num (+ num (- (1+ (cdr (car range)))
8541 (car (car range))))))
8542 (setq range (cdr range)))
8543 (setq num (- (cdr active) num))))
8544 ;; Update the number of unread articles.
8546 ;; Update the group buffer.
8547 (gnus-group-update-group group t)))))
8549 (defun gnus-methods-equal-p (m1 m2)
8550 (let ((m1 (or m1 gnus-select-method))
8551 (m2 (or m2 gnus-select-method)))
8553 (and (eq (car m1) (car m2))
8554 (or (not (memq 'address (assoc (symbol-name (car m1))
8555 gnus-valid-select-methods)))
8556 (equal (nth 1 m1) (nth 1 m2)))))))
8558 (defsubst gnus-header-value ()
8559 (buffer-substring (match-end 0) (gnus-point-at-eol)))
8561 (defvar gnus-newsgroup-none-id 0)
8563 (defun gnus-get-newsgroup-headers (&optional dependencies)
8564 (let ((cur nntp-server-buffer)
8567 (save-excursion (set-buffer gnus-summary-buffer)
8568 gnus-newsgroup-dependencies)))
8569 headers id id-dep ref-dep end ref)
8571 (set-buffer nntp-server-buffer)
8572 (let ((case-fold-search t)
8573 in-reply-to header number p lines)
8574 (goto-char (point-min))
8575 ;; Search to the beginning of the next header. Error messages
8576 ;; do not begin with 2 or 3.
8577 (while (re-search-forward "^[23][0-9]+ " nil t)
8580 ;; This implementation of this function, with nine
8581 ;; search-forwards instead of the one re-search-forward and
8582 ;; a case (which basically was the old function) is actually
8583 ;; about twice as fast, even though it looks messier. You
8584 ;; can't have everything, I guess. Speed and elegance
8585 ;; doesn't always go hand in hand.
8594 (narrow-to-region (point)
8595 (or (and (search-forward "\n.\n" nil t)
8601 (if (search-forward "\nsubject: " nil t)
8602 (gnus-header-value) "(none)"))
8606 (if (search-forward "\nfrom: " nil t)
8607 (gnus-header-value) "(nobody)"))
8611 (if (search-forward "\ndate: " nil t)
8612 (gnus-header-value) ""))
8616 (if (search-forward "\nmessage-id: " nil t)
8617 (setq id (gnus-header-value))
8618 ;; If there was no message-id, we just fake one to make
8619 ;; subsequent routines simpler.
8620 (setq id (concat "none+"
8622 (setq gnus-newsgroup-none-id
8623 (1+ gnus-newsgroup-none-id)))))))
8627 (if (search-forward "\nreferences: " nil t)
8630 (setq end (match-end 0))
8637 (search-backward ">" end t)
8640 (search-backward "<" end t)
8642 ;; Get the references from the in-reply-to header if there
8643 ;; were no references and the in-reply-to header looks
8645 (if (and (search-forward "\nin-reply-to: " nil t)
8646 (setq in-reply-to (gnus-header-value))
8647 (string-match "<[^>]+>" in-reply-to))
8649 (setq ref (substring in-reply-to (match-beginning 0)
8651 (setq ref (downcase ref))))
8658 (if (search-forward "\nlines: " nil t)
8659 (if (numberp (setq lines (read cur)))
8665 (and (search-forward "\nxref: " nil t)
8666 (gnus-header-value)))))
8667 (if (and gnus-nocem-hashtb
8668 (gnus-gethash id gnus-nocem-hashtb))
8671 ;; We do the threading while we read the headers. The
8672 ;; message-id and the last reference are both entered into
8673 ;; the same hash table. Some tippy-toeing around has to be
8674 ;; done in case an article has arrived before the article
8675 ;; which it refers to.
8676 (if (boundp (setq id-dep (intern (downcase id) dependencies)))
8677 (if (car (symbol-value id-dep))
8678 ;; An article with this Message-ID has already
8679 ;; been seen, so we ignore this one, except we add
8680 ;; any additional Xrefs (in case the two articles
8681 ;; came from different servers).
8683 (mail-header-set-xref
8684 (car (symbol-value id-dep))
8685 (concat (or (mail-header-xref
8686 (car (symbol-value id-dep))) "")
8687 (or (mail-header-xref header) "")))
8689 (setcar (symbol-value id-dep) header))
8690 (set id-dep (list header))))
8693 (if (boundp (setq ref-dep (intern ref dependencies)))
8694 (setcdr (symbol-value ref-dep)
8695 (nconc (cdr (symbol-value ref-dep))
8696 (list (symbol-value id-dep))))
8697 (set ref-dep (list nil (symbol-value id-dep))))
8698 (setq headers (cons header headers))))
8699 (goto-char (point-max))
8701 (nreverse headers)))))
8703 ;; The following macros and functions were written by Felix Lee
8704 ;; <flee@cse.psu.edu>.
8706 (defmacro gnus-nov-read-integer ()
8708 (if (= (following-char) ?\t)
8710 (let ((num (condition-case nil (read buffer) (error nil))))
8711 (if (numberp num) num 0)))
8712 (or (eobp) (forward-char 1))))
8714 (defmacro gnus-nov-skip-field ()
8715 '(search-forward "\t" eol 'move))
8717 (defmacro gnus-nov-field ()
8718 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
8720 ;; Goes through the xover lines and returns a list of vectors
8721 (defun gnus-get-newsgroup-headers-xover (sequence)
8722 "Parse the news overview data in the server buffer, and return a
8723 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
8724 ;; Get the Xref when the users reads the articles since most/some
8725 ;; NNTP servers do not include Xrefs when using XOVER.
8726 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
8727 (let ((cur nntp-server-buffer)
8728 (dependencies gnus-newsgroup-dependencies)
8729 number headers header)
8731 (set-buffer nntp-server-buffer)
8732 ;; Allow the user to mangle the headers before parsing them.
8733 (run-hooks 'gnus-parse-headers-hook)
8734 ;; Allow the user to mangle the headers before parsing them.
8735 (run-hooks 'gnus-parse-headers-hook)
8736 (goto-char (point-min))
8737 (while (and sequence (not (eobp)))
8738 (setq number (read cur))
8739 (while (and sequence (< (car sequence) number))
8740 (setq sequence (cdr sequence)))
8742 (eq number (car sequence))
8744 (setq sequence (cdr sequence))
8746 (inline (gnus-nov-parse-line number dependencies)))
8747 (setq headers (cons header headers)))))
8749 (setq headers (nreverse headers)))
8752 ;; This function has to be called with point after the article number
8753 ;; on the beginning of the line.
8754 (defun gnus-nov-parse-line (number dependencies)
8756 (eol (gnus-point-at-eol))
8757 (buffer (current-buffer))
8758 header ref id id-dep ref-dep)
8760 ;; overview: [num subject from date id refs chars lines misc]
8761 (narrow-to-region (point) eol)
8762 (or (eobp) (forward-char))
8768 (gnus-nov-field) ; subject
8769 (gnus-nov-field) ; from
8770 (gnus-nov-field) ; date
8771 (setq id (or (gnus-nov-field)
8774 (setq none (1+ none)))))) ; id
8777 (let ((beg (point)))
8778 (search-forward "\t" eol)
8779 (if (search-backward ">" beg t)
8785 (search-backward "<" beg t)
8788 (gnus-nov-field)) ; refs
8789 (gnus-nov-read-integer) ; chars
8790 (gnus-nov-read-integer) ; lines
8791 (if (= (following-char) ?\n)
8793 (gnus-nov-field)) ; misc
8797 (gnus-message 4 "Strange nov line")
8803 ;; We build the thread tree.
8805 (if (and gnus-nocem-hashtb
8806 (gnus-gethash id gnus-nocem-hashtb))
8809 (if (boundp (setq id-dep (intern (downcase id) dependencies)))
8810 (if (car (symbol-value id-dep))
8811 ;; An article with this Message-ID has already been seen,
8812 ;; so we ignore this one, except we add any additional
8813 ;; Xrefs (in case the two articles came from different
8816 (mail-header-set-xref
8817 (car (symbol-value id-dep))
8818 (concat (or (mail-header-xref
8819 (car (symbol-value id-dep))) "")
8820 (or (mail-header-xref header) "")))
8822 (setcar (symbol-value id-dep) header))
8823 (set id-dep (list header)))))
8826 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
8827 (setcdr (symbol-value ref-dep)
8828 (nconc (cdr (symbol-value ref-dep))
8829 (list (symbol-value id-dep))))
8830 (set ref-dep (list nil (symbol-value id-dep))))))
8833 (defun gnus-article-get-xrefs ()
8834 "Fill in the Xref value in `gnus-current-headers', if necessary.
8835 This is meant to be called in `gnus-article-internal-prepare-hook'."
8836 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
8837 gnus-current-headers)))
8838 (or (not gnus-use-cross-reference)
8840 (and (mail-header-xref headers)
8841 (not (string= (mail-header-xref headers) "")))
8842 (let ((case-fold-search t)
8845 (gnus-narrow-to-headers)
8846 (goto-char (point-min))
8847 (if (or (and (eq (downcase (following-char)) ?x)
8848 (looking-at "Xref:"))
8849 (search-forward "\nXref:" nil t))
8851 (goto-char (1+ (match-end 0)))
8852 (setq xref (buffer-substring (point)
8853 (progn (end-of-line) (point))))
8854 (mail-header-set-xref headers xref))))))))
8856 (defun gnus-summary-insert-subject (id)
8857 "Find article ID and insert the summary line for that article."
8858 (let ((header (gnus-read-header id))
8861 ;; Rebuild the thread that this article is part of and go to the
8862 ;; article we have fetched.
8863 (gnus-rebuild-thread (mail-header-id header))
8864 (gnus-summary-goto-subject (setq number (mail-header-number header)))
8866 ;; We have to update the boundaries, possibly.
8867 (and (> number gnus-newsgroup-end)
8868 (setq gnus-newsgroup-end number))
8869 (and (< number gnus-newsgroup-begin)
8870 (setq gnus-newsgroup-begin number))
8871 (setq gnus-newsgroup-unselected
8872 (delq number gnus-newsgroup-unselected)))
8873 ;; Report back a success.
8876 (defun gnus-summary-work-articles (n)
8877 "Return a list of articles to be worked upon. The prefix argument,
8878 the list of process marked articles, and the current article will be
8879 taken into consideration."
8881 ((and n (numberp n))
8882 ;; A numerical prefix has been given.
8883 (let ((backward (< n 0))
8889 (push (setq article (gnus-summary-article-number))
8892 (gnus-summary-find-prev nil article)
8893 (gnus-summary-find-next nil article)))
8895 (nreverse articles)))
8896 ((and (boundp 'transient-mark-mode)
8899 ;; Work on the region between point and mark.
8900 (let ((max (max (point) (mark)))
8903 (goto-char (min (point) (mark)))
8906 (push (setq article (gnus-summary-article-number)) articles)
8907 (gnus-summary-find-next nil article)
8909 (nreverse articles))))
8910 (gnus-newsgroup-processable
8911 ;; There are process-marked articles present.
8912 (reverse gnus-newsgroup-processable))
8914 ;; Just return the current article.
8915 (list (gnus-summary-article-number)))))
8917 (defun gnus-summary-search-group (&optional backward use-level)
8918 "Search for next unread newsgroup.
8919 If optional argument BACKWARD is non-nil, search backward instead."
8921 (set-buffer gnus-group-buffer)
8922 (if (gnus-group-search-forward
8923 backward nil (if use-level (gnus-group-group-level) nil))
8924 (gnus-group-group-name))))
8926 (defun gnus-summary-best-group (&optional exclude-group)
8927 "Find the name of the best unread group.
8928 If EXCLUDE-GROUP, do not go to this group."
8930 (set-buffer gnus-group-buffer)
8932 (gnus-group-best-unread-group exclude-group))))
8934 (defun gnus-summary-find-next (&optional unread article backward)
8935 (if backward (gnus-summary-find-prev)
8936 (let* ((article (or article (gnus-summary-article-number)))
8937 (arts (gnus-data-find-list article))
8939 (when (or (not gnus-summary-check-current)
8941 (not (gnus-data-unread-p (car arts))))
8942 (setq arts (cdr arts)))
8947 (when (gnus-data-unread-p (car arts))
8948 (setq result (car arts)
8950 (setq arts (cdr arts)))
8953 (goto-char (gnus-data-pos result))
8954 (gnus-data-number result)))))
8956 (defun gnus-summary-find-prev (&optional unread article)
8957 (let* ((article (or article (gnus-summary-article-number)))
8958 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
8960 (when (or (not gnus-summary-check-current)
8962 (not (gnus-data-unread-p (car arts))))
8963 (setq arts (cdr arts)))
8968 (and (gnus-data-unread-p (car arts))
8969 (setq result (car arts)
8971 (setq arts (cdr arts)))
8975 (goto-char (gnus-data-pos result))
8976 (gnus-data-number result)))))
8978 (defun gnus-summary-find-subject (subject &optional unread backward article)
8979 (let* ((simp-subject (gnus-simplify-subject-fully subject))
8980 (article (or article (gnus-summary-article-number)))
8981 (articles (gnus-data-list backward))
8982 (arts (gnus-data-find-list article articles))
8984 (when (or (not gnus-summary-check-current)
8986 (not (gnus-data-unread-p (car arts))))
8987 (setq arts (cdr arts)))
8989 (and (or (not unread)
8990 (gnus-data-unread-p (car arts)))
8991 (vectorp (gnus-data-header (car arts)))
8993 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
8994 (setq result (car arts)
8996 (setq arts (cdr arts)))
8998 (goto-char (gnus-data-pos result))
8999 (gnus-data-number result))))
9001 (defun gnus-summary-search-forward (&optional unread subject backward)
9003 (gnus-summary-find-subject subject unread backward))
9005 (gnus-summary-find-prev unread))
9007 (gnus-summary-find-next unread))))
9009 (defun gnus-summary-recenter ()
9010 "Center point in the summary window.
9011 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9012 displayed, no centering will be performed."
9013 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9014 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9015 (let* ((top (cond ((< (window-height) 4) 0)
9016 ((< (window-height) 7) 1)
9018 (height (1- (window-height)))
9019 (bottom (save-excursion (goto-char (point-max))
9020 (forward-line (- height))
9022 (window (get-buffer-window (current-buffer))))
9024 ;; The user has to want it,
9025 gnus-auto-center-summary
9026 ;; the article buffer must be displayed,
9027 (get-buffer-window gnus-article-buffer)
9028 ;; Set the window start to either `bottom', which is the biggest
9029 ;; possible valid number, or the second line from the top,
9030 ;; whichever is the least.
9032 window (min bottom (save-excursion (forward-line (- top)) (point)))))))
9034 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9035 (defun gnus-short-group-name (group &optional levels)
9036 "Collapse GROUP name LEVELS."
9037 (let* ((name "") (foreign "") (depth -1) (skip 1)
9040 (while (string-match "\\." group skip)
9041 (setq skip (match-end 0)
9044 (if (string-match ":" group)
9045 (setq foreign (substring group 0 (match-end 0))
9046 group (substring group (match-end 0))))
9048 (if (and (string-match "\\." group) (> levels 0))
9049 (setq name (concat name (substring group 0 1))
9050 group (substring group (match-end 0))
9052 name (concat name "."))
9053 (setq name (concat foreign name group)
9057 (defun gnus-summary-jump-to-group (newsgroup)
9058 "Move point to NEWSGROUP in group mode buffer."
9059 ;; Keep update point of group mode buffer if visible.
9060 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9061 (save-window-excursion
9062 ;; Take care of tree window mode.
9063 (if (get-buffer-window gnus-group-buffer)
9064 (pop-to-buffer gnus-group-buffer))
9065 (gnus-group-jump-to-group newsgroup))
9067 ;; Take care of tree window mode.
9068 (if (get-buffer-window gnus-group-buffer)
9069 (pop-to-buffer gnus-group-buffer)
9070 (set-buffer gnus-group-buffer))
9071 (gnus-group-jump-to-group newsgroup))))
9073 ;; This function returns a list of article numbers based on the
9074 ;; difference between the ranges of read articles in this group and
9075 ;; the range of active articles.
9076 (defun gnus-list-of-unread-articles (group)
9077 (let* ((read (gnus-info-read (gnus-get-info group)))
9078 (active (gnus-active group))
9081 ;; If none are read, then all are unread.
9083 (setq first (car active))
9084 ;; If the range of read articles is a single range, then the
9085 ;; first unread article is the article after the last read
9086 ;; article. Sounds logical, doesn't it?
9087 (if (not (listp (cdr read)))
9088 (setq first (1+ (cdr read)))
9089 ;; `read' is a list of ranges.
9090 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9091 (car (car read)))) 1)
9095 (while (< first nlast)
9096 (setq unread (cons first unread))
9097 (setq first (1+ first))))
9098 (setq first (1+ (if (atom (car read)) (car read) (cdr (car read)))))
9099 (setq nlast (if (atom (car (cdr read)))
9101 (car (car (cdr read)))))
9102 (setq read (cdr read)))))
9103 ;; And add the last unread articles.
9104 (while (<= first last)
9105 (setq unread (cons first unread))
9106 (setq first (1+ first)))
9107 ;; Return the list of unread articles.
9110 (defun gnus-list-of-read-articles (group)
9111 "Return a list of unread, unticked and non-dormant articles."
9112 (let* ((info (gnus-get-info group))
9113 (marked (gnus-info-marks info))
9114 (active (gnus-active group)))
9116 (gnus-set-difference
9117 (gnus-sorted-complement
9118 (gnus-uncompress-range active)
9119 (gnus-list-of-unread-articles group))
9121 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9122 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9124 ;; Various summary commands
9126 (defun gnus-summary-universal-argument ()
9127 "Perform any operation on all articles marked with the process mark."
9129 (gnus-set-global-variables)
9130 (let ((articles (reverse gnus-newsgroup-processable))
9132 (or articles (error "No articles marked"))
9133 (or (setq func (key-binding (read-key-sequence "C-c C-u")))
9134 (error "Undefined key"))
9136 (gnus-summary-goto-subject (car articles))
9137 (command-execute func)
9138 (gnus-summary-remove-process-mark (car articles))
9139 (setq articles (cdr articles)))))
9141 (defun gnus-summary-toggle-truncation (&optional arg)
9142 "Toggle truncation of summary lines.
9143 With arg, turn line truncation on iff arg is positive."
9145 (setq truncate-lines
9146 (if (null arg) (not truncate-lines)
9147 (> (prefix-numeric-value arg) 0)))
9150 (defun gnus-summary-reselect-current-group (&optional all)
9151 "Once exit and then reselect the current newsgroup.
9152 The prefix argument ALL means to select all articles."
9154 (gnus-set-global-variables)
9155 (let ((current-subject (gnus-summary-article-number))
9156 (group gnus-newsgroup-name))
9157 (setq gnus-newsgroup-begin nil)
9159 ;; We have to adjust the point of group mode buffer because the
9160 ;; current point was moved to the next unread newsgroup by
9162 (gnus-summary-jump-to-group group)
9163 (gnus-group-read-group all t)
9164 (gnus-summary-goto-subject current-subject)))
9166 (defun gnus-summary-rescan-group (&optional all)
9167 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9169 (gnus-set-global-variables)
9170 ;; Fix by Ilja Weis <kult@uni-paderborn.de>.
9171 (let ((group gnus-newsgroup-name))
9173 (gnus-summary-jump-to-group group)
9175 (set-buffer gnus-group-buffer)
9176 (gnus-group-get-new-news-this-group 1))
9177 (gnus-summary-jump-to-group group)
9178 (gnus-group-read-group all)))
9180 (defun gnus-summary-update-info ()
9181 (let* ((group gnus-newsgroup-name))
9182 (when gnus-newsgroup-kill-headers
9183 (setq gnus-newsgroup-killed
9184 (gnus-compress-sequence
9186 (gnus-set-sorted-intersection
9187 (gnus-uncompress-range gnus-newsgroup-killed)
9188 (setq gnus-newsgroup-unselected
9189 (sort gnus-newsgroup-unselected '<)))
9190 (setq gnus-newsgroup-unreads
9191 (sort gnus-newsgroup-unreads '<))) t)))
9192 (unless (listp (cdr gnus-newsgroup-killed))
9193 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9194 (let ((headers gnus-newsgroup-headers))
9195 (gnus-close-group group)
9196 (run-hooks 'gnus-exit-group-hook)
9197 (unless gnus-save-score
9198 (setq gnus-newsgroup-scored nil))
9199 ;; Set the new ranges of read articles.
9200 (gnus-update-read-articles
9201 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9202 ;; Set the current article marks.
9204 ;; Do the cross-ref thing.
9205 (when gnus-use-cross-reference
9206 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9207 ;; Do adaptive scoring, and possibly save score files.
9208 (when gnus-newsgroup-adaptive
9209 (gnus-score-adaptive))
9210 (when gnus-use-scoring
9212 ;; Do not switch windows but change the buffer to work.
9213 (set-buffer gnus-group-buffer)
9214 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9215 (gnus-group-update-group group)))))
9217 (defun gnus-summary-exit (&optional temporary)
9218 "Exit reading current newsgroup, and then return to group selection mode.
9219 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9221 (gnus-set-global-variables)
9222 (gnus-kill-save-kill-buffer)
9223 (let* ((group gnus-newsgroup-name)
9224 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9226 (buf (current-buffer)))
9227 (run-hooks 'gnus-summary-prepare-exit-hook)
9228 ;; Make all changes in this group permanent.
9229 (gnus-summary-update-info)
9231 (when gnus-use-cache
9232 (gnus-cache-possibly-remove-articles)
9233 (gnus-cache-save-buffers))
9234 ;; Make sure where I was, and go to next newsgroup.
9235 (set-buffer gnus-group-buffer)
9238 (gnus-group-jump-to-group group)
9239 (gnus-group-next-unread-group 1)))
9242 ;; If we have several article buffers, we kill them at exit.
9243 (unless gnus-single-article-buffer
9244 (gnus-kill-buffer gnus-article-buffer))
9245 (if (not gnus-kill-summary-on-exit)
9246 (gnus-deaden-summary)
9247 ;; We set all buffer-local variables to nil. It is unclear why
9248 ;; this is needed, but if we don't, buffer-local variables are
9249 ;; not garbage-collected, it seems. This would the lead to en
9250 ;; ever-growing Emacs.
9252 (gnus-summary-clear-local-variables)
9253 ;; We clear the global counterparts of the buffer-local
9254 ;; variables as well, just to be on the safe side.
9255 (gnus-configure-windows 'group 'force)
9256 (gnus-summary-clear-local-variables)
9257 ;; Return to group mode buffer.
9258 (if (eq mode 'gnus-summary-mode)
9259 (gnus-kill-buffer buf)))
9260 (setq gnus-current-select-method gnus-select-method)
9261 (pop-to-buffer gnus-group-buffer)
9262 ;; Clear the current group name.
9263 (if (not quit-config)
9265 (gnus-group-jump-to-group group)
9266 (gnus-group-next-unread-group 1))
9267 (if (not (buffer-name (car quit-config)))
9268 (gnus-configure-windows 'group 'force)
9269 (set-buffer (car quit-config))
9270 (and (eq major-mode 'gnus-summary-mode)
9271 (gnus-set-global-variables))
9272 (gnus-configure-windows (cdr quit-config))))
9273 (run-hooks 'gnus-summary-exit-hook)
9275 (setq gnus-newsgroup-name nil)))))
9277 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9278 (defun gnus-summary-exit-no-update (&optional no-questions)
9279 "Quit reading current newsgroup without updating read article info."
9281 (gnus-set-global-variables)
9282 (let* ((group gnus-newsgroup-name)
9283 (quit-config (gnus-group-quit-config group)))
9284 (when (or no-questions
9286 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9287 ;; If we have several article buffers, we kill them at exit.
9288 (unless gnus-single-article-buffer
9289 (gnus-kill-buffer gnus-article-buffer))
9290 (if (not gnus-kill-summary-on-exit)
9291 (gnus-deaden-summary)
9292 (gnus-close-group group)
9293 (gnus-summary-clear-local-variables)
9294 (set-buffer gnus-group-buffer)
9295 (gnus-summary-clear-local-variables)
9296 (when (get-buffer gnus-summary-buffer)
9297 (kill-buffer gnus-summary-buffer)))
9298 ;; Return to the group buffer.
9299 (gnus-configure-windows 'group 'force)
9300 ;; Clear the current group name.
9301 (setq gnus-newsgroup-name nil)
9302 (when (equal (gnus-group-group-name) group)
9303 (gnus-group-next-unread-group 1))
9305 (if (not (buffer-name (car quit-config)))
9306 (gnus-configure-windows 'group 'force)
9307 (set-buffer (car quit-config))
9308 (when (eq major-mode 'gnus-summary-mode)
9309 (gnus-set-global-variables))
9310 (gnus-configure-windows (cdr quit-config)))))))
9314 (defvar gnus-dead-summary-mode-map nil)
9316 (if gnus-dead-summary-mode-map
9318 (setq gnus-dead-summary-map (make-keymap))
9319 (suppress-keymap gnus-dead-summary-map)
9320 (substitute-key-definition
9321 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-map)
9322 (let ((keys '("\C-d" "\r" "\177")))
9324 (define-key gnus-dead-summary-map
9325 (pop keys) 'gnus-summary-wake-up-the-dead))))
9327 (defvar gnus-dead-summary-mode nil
9328 "Minor mode for Gnus summary buffers.")
9330 (defun gnus-dead-summary-mode (&optional arg)
9331 "Minor mode for Gnus summary buffers."
9333 (when (eq major-mode 'gnus-summary-mode)
9334 (make-local-variable 'gnus-dead-summary-mode)
9335 (setq gnus-dead-summary-mode
9336 (if (null arg) (not gnus-dead-summary-mode)
9337 (> (prefix-numeric-value arg) 0)))
9338 (when gnus-dead-summary-mode
9339 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
9340 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
9341 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
9342 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
9343 minor-mode-map-alist)))))
9345 (defun gnus-deaden-summary ()
9346 "Make the current summary buffer into a dead summary buffer."
9347 ;; Kill any previous dead summary buffer.
9348 (when (and gnus-dead-summary
9349 (buffer-name gnus-dead-summary))
9351 (set-buffer gnus-dead-summary)
9352 (when gnus-dead-summary-mode
9353 (kill-buffer (current-buffer)))))
9354 ;; Make this the current dead summary.
9355 (setq gnus-dead-summary (current-buffer))
9356 (gnus-dead-summary-mode 1)
9357 (let ((name (buffer-name)))
9358 (when (string-match "Summary" name)
9360 (concat (substring name 0 (match-beginning 0)) "Dead "
9361 (substring name (match-beginning 0))) t))))
9363 (defun gnus-kill-or-deaden-summary (buffer)
9364 "Kill or deaden the summary BUFFER."
9365 (cond (gnus-kill-summary-on-exit
9366 (gnus-kill-buffer buffer))
9367 ((and (get-buffer buffer)
9368 (buffer-name (get-buffer buffer)))
9371 (gnus-deaden-summary)))))
9373 (defun gnus-summary-wake-up-the-dead (&rest args)
9374 "Wake up the dead summary buffer."
9376 (gnus-dead-summary-mode -1)
9377 (let ((name (buffer-name)))
9378 (when (string-match "Dead " name)
9380 (concat (substring name 0 (match-beginning 0))
9381 (substring name (match-end 0))) t)))
9382 (gnus-message 3 "This dead summary is now alive again"))
9384 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
9385 (defun gnus-summary-fetch-faq (&optional faq-dir)
9386 "Fetch the FAQ for the current group.
9387 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
9391 (if current-prefix-arg
9393 "Faq dir: " (and (listp gnus-group-faq-directory)
9394 gnus-group-faq-directory)))))
9395 (let (gnus-faq-buffer)
9396 (and (setq gnus-faq-buffer
9397 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
9398 (gnus-configure-windows 'summary-faq))))
9400 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
9401 (defun gnus-summary-describe-group (&optional force)
9402 "Describe the current newsgroup."
9404 (gnus-group-describe-group force gnus-newsgroup-name))
9406 (defun gnus-summary-describe-briefly ()
9407 "Describe summary mode commands briefly."
9410 (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")))
9412 ;; Walking around group mode buffer from summary mode.
9414 (defun gnus-summary-next-group (&optional no-article target-group backward)
9415 "Exit current newsgroup and then select next unread newsgroup.
9416 If prefix argument NO-ARTICLE is non-nil, no article is selected
9417 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
9418 previous group instead."
9420 (gnus-set-global-variables)
9421 (let ((current-group gnus-newsgroup-name)
9422 (current-buffer (current-buffer))
9424 ;; First we semi-exit this group to update Xrefs and all variables.
9425 ;; We can't do a real exit, because the window conf must remain
9426 ;; the same in case the user is prompted for info, and we don't
9427 ;; want the window conf to change before that...
9428 (gnus-summary-exit t)
9429 (while (not entered)
9430 ;; Then we find what group we are supposed to enter.
9431 (set-buffer gnus-group-buffer)
9432 (gnus-group-jump-to-group current-group)
9435 (if (eq gnus-keep-same-level 'best)
9436 (gnus-summary-best-group gnus-newsgroup-name)
9437 (gnus-summary-search-group backward gnus-keep-same-level))))
9438 (if (not target-group)
9439 ;; There are no further groups, so we return to the group
9442 (gnus-message 5 "Returning to the group buffer")
9444 (set-buffer current-buffer)
9445 (gnus-summary-exit))
9446 ;; We try to enter the target group.
9447 (gnus-group-jump-to-group target-group)
9448 (let ((unreads (gnus-group-group-unread)))
9449 (if (and (or (eq t unreads)
9450 (and unreads (not (zerop unreads))))
9451 (gnus-summary-read-group
9452 target-group nil no-article current-buffer))
9454 (setq current-group target-group
9455 target-group nil)))))))
9457 (defun gnus-summary-prev-group (&optional no-article)
9458 "Exit current newsgroup and then select previous unread newsgroup.
9459 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
9461 (gnus-summary-next-group no-article nil t))
9463 ;; Walking around summary lines.
9465 (defun gnus-summary-first-subject (&optional unread)
9466 "Go to the first unread subject.
9467 If UNREAD is non-nil, go to the first unread article.
9468 Returns the article selected or nil if there are no unread articles."
9473 ((null gnus-newsgroup-data)
9474 (gnus-message 3 "No articles in the group")
9476 ;; Pick the first article.
9478 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
9479 (gnus-data-number (car gnus-newsgroup-data)))
9480 ;; No unread articles.
9481 ((null gnus-newsgroup-unreads)
9482 (gnus-message 3 "No more unread articles")
9484 ;; Find the first unread article.
9486 (let ((data gnus-newsgroup-data))
9488 (not (gnus-data-unread-p (car data))))
9489 (setq data (cdr data)))
9492 (goto-char (gnus-data-pos (car data)))
9493 (gnus-data-number (car data)))))))
9494 (gnus-summary-position-point)))
9496 (defun gnus-summary-next-subject (n &optional unread dont-display)
9497 "Go to next N'th summary line.
9498 If N is negative, go to the previous N'th subject line.
9499 If UNREAD is non-nil, only unread articles are selected.
9500 The difference between N and the actual number of steps taken is
9503 (let ((backward (< n 0))
9507 (gnus-summary-find-prev unread)
9508 (gnus-summary-find-next unread)))
9510 (if (/= 0 n) (gnus-message 7 "No more%s articles"
9511 (if unread " unread" "")))
9514 (gnus-summary-recenter)
9515 (gnus-summary-position-point)))
9518 (defun gnus-summary-next-unread-subject (n)
9519 "Go to next N'th unread summary line."
9521 (gnus-summary-next-subject n t))
9523 (defun gnus-summary-prev-subject (n &optional unread)
9524 "Go to previous N'th summary line.
9525 If optional argument UNREAD is non-nil, only unread article is selected."
9527 (gnus-summary-next-subject (- n) unread))
9529 (defun gnus-summary-prev-unread-subject (n)
9530 "Go to previous N'th unread summary line."
9532 (gnus-summary-next-subject (- n) t))
9534 (defun gnus-summary-goto-subject (article &optional force silent)
9535 "Go the subject line of ARTICLE.
9536 If FORCE, also allow jumping to articles not currently shown."
9538 (data (gnus-data-find article)))
9539 ;; We read in the article if we have to.
9542 (gnus-summary-insert-subject article)
9543 (setq data (gnus-data-find article)))
9548 (gnus-message 3 "Can't find article %d" article))
9550 (goto-char (gnus-data-pos data))
9553 ;; Walking around summary lines with displaying articles.
9555 (defun gnus-summary-expand-window (&optional arg)
9556 "Make the summary buffer take up the entire Emacs frame.
9557 Given a prefix, will force an `article' buffer configuration."
9559 (gnus-set-global-variables)
9561 (gnus-configure-windows 'article 'force)
9562 (gnus-configure-windows 'summary 'force)))
9564 (defun gnus-summary-display-article (article &optional all-header)
9565 "Display ARTICLE in article buffer."
9566 (gnus-set-global-variables)
9570 (gnus-article-prepare article all-header)
9571 (gnus-summary-show-thread)
9572 (run-hooks 'gnus-select-article-hook)
9573 (gnus-summary-recenter)
9574 (gnus-summary-goto-subject article)
9575 ;; Successfully display article.
9576 (gnus-summary-update-line)
9577 (gnus-article-set-window-start
9578 (cdr (assq article gnus-newsgroup-bookmarks)))
9581 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
9582 "Select the current article.
9583 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
9584 non-nil, the article will be re-fetched even if it already present in
9585 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
9587 (let ((article (or article (gnus-summary-article-number)))
9588 (all-headers (not (not all-headers))) ;Must be T or NIL.
9591 (gnus-summary-article-pseudo-p article)
9592 (error "This is a pseudo-article."))
9595 (set-buffer gnus-summary-buffer)
9596 (if (or (and gnus-single-article-buffer
9597 (or (null gnus-current-article)
9598 (null gnus-article-current)
9599 (null (get-buffer gnus-article-buffer))
9600 (not (eq article (cdr gnus-article-current)))
9601 (not (equal (car gnus-article-current)
9602 gnus-newsgroup-name))))
9603 (and (not gnus-single-article-buffer)
9604 (null gnus-current-article))
9606 ;; The requested article is different from the current article.
9608 (gnus-summary-display-article article all-headers)
9610 (if (or all-headers gnus-show-all-headers)
9611 (gnus-article-show-all-headers))
9614 (gnus-article-set-window-start
9615 (cdr (assq article gnus-newsgroup-bookmarks)))))))
9617 (defun gnus-summary-set-current-mark (&optional current-mark)
9618 "Obsolete function."
9621 (defun gnus-summary-next-article (&optional unread subject backward)
9622 "Select the next article.
9623 If UNREAD, only unread articles are selected.
9624 If SUBJECT, only articles with SUBJECT are selected.
9625 If BACKWARD, the previous article is selected instead of the next."
9627 (gnus-set-global-variables)
9630 ;; Is there such an article?
9631 ((and (gnus-summary-search-forward unread subject backward)
9632 (or (gnus-summary-display-article (gnus-summary-article-number))
9633 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
9634 (gnus-summary-position-point))
9635 ;; If not, we try the first unread, if that is wanted.
9637 gnus-auto-select-same
9638 (or (gnus-summary-first-unread-article)
9639 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
9640 (gnus-summary-position-point)
9641 (gnus-message 6 "Wrapped"))
9642 ;; Try to get next/previous article not displayed in this group.
9643 ((and gnus-auto-extend-newsgroup
9644 (not unread) (not subject))
9645 (gnus-summary-goto-article
9646 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
9648 ;; Go to next/previous group.
9650 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9651 (gnus-summary-jump-to-group gnus-newsgroup-name))
9652 (let ((cmd last-command-char)
9654 (if (eq gnus-keep-same-level 'best)
9655 (gnus-summary-best-group gnus-newsgroup-name)
9656 (gnus-summary-search-group backward gnus-keep-same-level))))
9657 ;; For some reason, the group window gets selected. We change
9659 (select-window (get-buffer-window (current-buffer)))
9660 ;; Select next unread newsgroup automagically.
9662 ((not gnus-auto-select-next)
9663 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
9664 ((or (eq gnus-auto-select-next 'quietly)
9665 (and (eq gnus-auto-select-next 'almost-quietly)
9666 (gnus-summary-last-article-p)))
9668 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
9670 (gnus-message 7 "No more%s articles (%s)..."
9671 (if unread " unread" "")
9672 (if group (concat "selecting " group)
9674 (gnus-summary-next-group nil group backward)))
9676 (gnus-summary-walk-group-buffer
9677 gnus-newsgroup-name cmd unread backward))))))))
9679 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
9680 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
9681 (?\C-p (gnus-group-prev-unread-group 1))))
9682 keve key group ended)
9684 (set-buffer gnus-group-buffer)
9685 (gnus-summary-jump-to-group from-group)
9686 (setq group (gnus-summary-search-group backward)))
9689 7 "No more%s articles%s" (if unread " unread" "")
9691 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
9692 (format " (Type %s for %s [%s])"
9693 (single-key-description cmd) group
9694 (car (gnus-gethash group gnus-newsrc-hashtb)))
9695 (format " (Type %s to exit %s)"
9696 (single-key-description cmd)
9697 gnus-newsgroup-name)))
9698 ;; Confirm auto selection.
9699 (setq key (car (setq keve (gnus-read-event-char))))
9702 ((assq key keystrokes)
9703 (let ((obuf (current-buffer)))
9704 (switch-to-buffer gnus-group-buffer)
9706 (gnus-group-jump-to-group group))
9707 (eval (car (cdr (assq key keystrokes))))
9708 (setq group (gnus-group-group-name))
9709 (switch-to-buffer obuf))
9713 (gnus-ephemeral-group-p gnus-newsgroup-name))
9715 (gnus-summary-next-group nil group backward)))
9717 (push (cdr keve) unread-command-events))))))
9719 (defun gnus-read-event-char ()
9720 "Get the next event."
9721 (let ((event (read-event)))
9722 (cons (and (numberp event) event) event)))
9724 (defun gnus-summary-next-unread-article ()
9725 "Select unread article after current one."
9727 (gnus-summary-next-article t (and gnus-auto-select-same
9728 (gnus-summary-article-subject))))
9730 (defun gnus-summary-prev-article (&optional unread subject)
9731 "Select the article after the current one.
9732 If UNREAD is non-nil, only unread articles are selected."
9734 (gnus-summary-next-article unread subject t))
9736 (defun gnus-summary-prev-unread-article ()
9737 "Select unred article before current one."
9739 (gnus-summary-prev-article t (and gnus-auto-select-same
9740 (gnus-summary-article-subject))))
9742 (defun gnus-summary-next-page (&optional lines circular)
9743 "Show next page of selected article.
9744 If end of article, select next article.
9745 Argument LINES specifies lines to be scrolled up.
9746 If CIRCULAR is non-nil, go to the start of the article instead of
9747 instead of selecting the next article when reaching the end of the
9750 (setq gnus-summary-buffer (current-buffer))
9751 (gnus-set-global-variables)
9752 (let ((article (gnus-summary-article-number))
9754 (gnus-configure-windows 'article)
9755 (if (or (null gnus-current-article)
9756 (null gnus-article-current)
9757 (/= article (cdr gnus-article-current))
9758 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
9759 ;; Selected subject is different from current article's.
9760 (gnus-summary-display-article article)
9761 (gnus-eval-in-buffer-window
9763 (setq endp (gnus-article-next-page lines)))
9766 (gnus-summary-beginning-of-article))
9768 (gnus-message 3 "End of message"))
9770 (gnus-summary-next-unread-article)))))
9771 (gnus-summary-recenter)
9772 (gnus-summary-position-point)))
9774 (defun gnus-summary-prev-page (&optional lines)
9775 "Show previous page of selected article.
9776 Argument LINES specifies lines to be scrolled down."
9778 (gnus-set-global-variables)
9779 (let ((article (gnus-summary-article-number)))
9780 (gnus-configure-windows 'article)
9781 (if (or (null gnus-current-article)
9782 (null gnus-article-current)
9783 (/= article (cdr gnus-article-current))
9784 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
9785 ;; Selected subject is different from current article's.
9786 (gnus-summary-display-article article)
9787 (gnus-summary-recenter)
9788 (gnus-eval-in-buffer-window gnus-article-buffer
9789 (gnus-article-prev-page lines))))
9790 (gnus-summary-position-point))
9792 (defun gnus-summary-scroll-up (lines)
9793 "Scroll up (or down) one line current article.
9794 Argument LINES specifies lines to be scrolled up (or down if negative)."
9796 (gnus-set-global-variables)
9797 (gnus-configure-windows 'article)
9798 (or (gnus-summary-select-article nil nil 'pseudo)
9799 (gnus-eval-in-buffer-window
9802 (if (gnus-article-next-page lines)
9803 (gnus-message 3 "End of message")))
9805 (gnus-article-prev-page (- lines))))))
9806 (gnus-summary-recenter)
9807 (gnus-summary-position-point))
9809 (defun gnus-summary-next-same-subject ()
9810 "Select next article which has the same subject as current one."
9812 (gnus-set-global-variables)
9813 (gnus-summary-next-article nil (gnus-summary-article-subject)))
9815 (defun gnus-summary-prev-same-subject ()
9816 "Select previous article which has the same subject as current one."
9818 (gnus-set-global-variables)
9819 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
9821 (defun gnus-summary-next-unread-same-subject ()
9822 "Select next unread article which has the same subject as current one."
9824 (gnus-set-global-variables)
9825 (gnus-summary-next-article t (gnus-summary-article-subject)))
9827 (defun gnus-summary-prev-unread-same-subject ()
9828 "Select previous unread article which has the same subject as current one."
9830 (gnus-set-global-variables)
9831 (gnus-summary-prev-article t (gnus-summary-article-subject)))
9833 (defun gnus-summary-first-unread-article ()
9834 "Select the first unread article.
9835 Return nil if there are no unread articles."
9837 (gnus-set-global-variables)
9839 (if (gnus-summary-first-subject t)
9841 (gnus-summary-show-thread)
9842 (gnus-summary-first-subject t)
9843 (gnus-summary-display-article (gnus-summary-article-number))))
9844 (gnus-summary-position-point)))
9846 (defun gnus-summary-best-unread-article ()
9847 "Select the unread article with the highest score."
9849 (gnus-set-global-variables)
9850 (let ((best -1000000)
9851 (data gnus-newsgroup-data)
9854 (and (gnus-data-unread-p (car data))
9856 (gnus-summary-article-score (gnus-data-number (car data))))
9859 article (gnus-data-number (car data))))
9860 (setq data (cdr data)))
9862 (gnus-summary-goto-article article)
9863 (error "No unread articles"))
9864 (gnus-summary-position-point)))
9866 (defun gnus-summary-last-subject ()
9867 "Go to the last displayed subject line in the group."
9868 (let ((article (gnus-data-number (car (gnus-data-list t)))))
9870 (gnus-summary-goto-subject article))))
9872 (defun gnus-summary-goto-article (article &optional all-headers force)
9873 "Fetch ARTICLE and display it if it exists.
9874 If ALL-HEADERS is non-nil, no header lines are hidden."
9880 (mapcar (lambda (number) (list (int-to-string number)))
9881 gnus-newsgroup-limit)))
9885 (if (gnus-summary-goto-subject article force)
9886 (gnus-summary-display-article article all-headers)
9887 (gnus-message 4 "Couldn't go to article %s" article) nil)
9888 (gnus-summary-position-point)))
9890 (defun gnus-summary-goto-last-article ()
9891 "Go to the previously read article."
9894 (and gnus-last-article
9895 (gnus-summary-goto-article gnus-last-article))
9896 (gnus-summary-position-point)))
9898 (defun gnus-summary-pop-article (number)
9899 "Pop one article off the history and go to the previous.
9900 NUMBER articles will be popped off."
9903 (setq gnus-newsgroup-history
9904 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
9906 (gnus-summary-goto-article (car to))
9907 (error "Article history empty")))
9908 (gnus-summary-position-point))
9910 ;; Summary commands and functions for limiting the summary buffer.
9912 (defun gnus-summary-limit-to-articles (n)
9913 "Limit the summary buffer to the next N articles.
9914 If not given a prefix, use the process marked articles instead."
9916 (gnus-set-global-variables)
9918 (let ((articles (gnus-summary-work-articles n)))
9919 (setq gnus-newsgroup-processable nil)
9920 (gnus-summary-limit articles))
9921 (gnus-summary-position-point)))
9923 (defun gnus-summary-pop-limit (&optional total)
9924 "Restore the previous limit.
9925 If given a prefix, remove all limits."
9927 (gnus-set-global-variables)
9929 (if total (setq gnus-newsgroup-limits
9930 (list (mapcar (lambda (h) (mail-header-number h))
9931 gnus-newsgroup-headers))))
9932 (gnus-summary-limit nil 'pop)
9933 (gnus-summary-position-point)))
9935 (defun gnus-summary-limit-to-subject (subject)
9936 "Limit the summary buffer to articles that have subjects that match a regexp."
9937 (interactive "sRegexp: ")
9938 (when (not (equal "" subject))
9940 (let ((articles (gnus-summary-find-matching "subject" subject 'all)))
9941 (or articles (error "Found no matches for \"%s\"" subject))
9942 (gnus-summary-limit articles))
9943 (gnus-summary-position-point))))
9945 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
9947 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
9949 (defun gnus-summary-limit-to-unread (&optional all)
9950 "Limit the summary buffer to articles that are not marked as read.
9951 If ALL is non-nil, limit strictly to unread articles."
9954 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
9955 (gnus-summary-limit-to-marks
9956 ;; Concat all the marks that say that an article is read and have
9958 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
9959 gnus-killed-mark gnus-kill-file-mark
9960 gnus-low-score-mark gnus-expirable-mark
9961 gnus-canceled-mark gnus-catchup-mark)
9964 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
9965 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
9967 (defun gnus-summary-limit-to-marks (marks &optional reverse)
9968 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
9969 If REVERSE, limit the summary buffer to articles that are not marked
9970 with MARKS. MARKS can either be a string of marks or a list of marks.
9971 Returns how many articles were removed."
9972 (interactive "sMarks: ")
9973 (gnus-set-global-variables)
9975 (let ((data gnus-newsgroup-data)
9976 (marks (if (listp marks) marks
9977 (append marks nil))) ; Transform to list.
9980 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
9981 (memq (gnus-data-mark (car data)) marks))
9982 (setq articles (cons (gnus-data-number (car data)) articles)))
9983 (setq data (cdr data)))
9984 (gnus-summary-limit articles))
9985 (gnus-summary-position-point)))
9987 (defun gnus-summary-limit-to-score (&optional score)
9988 "Limit to articles with score at or above SCORE."
9990 (gnus-set-global-variables)
9991 (setq score (if score
9992 (prefix-numeric-value score)
9993 (or gnus-summary-default-score 0)))
9994 (let ((data gnus-newsgroup-data)
9997 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
9999 (push (gnus-data-number (car data)) articles))
10000 (setq data (cdr data)))
10002 (gnus-summary-limit articles)
10003 (gnus-summary-position-point))))
10005 (defun gnus-summary-limit-include-dormant ()
10006 "Display all the hidden articles that are marked as dormant."
10008 (gnus-set-global-variables)
10009 (or gnus-newsgroup-dormant
10010 (error "There are no dormant articles in this group"))
10012 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10013 (gnus-summary-position-point)))
10015 (defun gnus-summary-limit-exclude-dormant ()
10016 "Hide all dormant articles."
10018 (gnus-set-global-variables)
10020 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10021 (gnus-summary-position-point)))
10023 (defun gnus-summary-limit-exclude-childless-dormant ()
10024 "Hide all dormant articles that have no children."
10026 (gnus-set-global-variables)
10027 (let ((data gnus-newsgroup-data)
10029 ;; Find all articles that are either not dormant or have
10032 (and (or (not (= (gnus-data-mark (car data)) gnus-dormant-mark))
10033 (gnus-article-parent-p (gnus-data-number (car data))))
10034 (setq articles (cons (gnus-data-number (car data))
10036 (setq data (cdr data)))
10037 ;; Do the limiting.
10039 (gnus-summary-limit articles)
10040 (gnus-summary-position-point))))
10042 (defun gnus-summary-limit (articles &optional pop)
10044 ;; We pop the previous limit off the stack and use that.
10045 (setq articles (car gnus-newsgroup-limits)
10046 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10047 ;; We use the new limit, so we push the old limit on the stack.
10048 (setq gnus-newsgroup-limits
10049 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10051 (setq gnus-newsgroup-limit articles)
10052 (let ((total (length gnus-newsgroup-data))
10053 (data (gnus-data-find-list (gnus-summary-article-number)))
10055 ;; This will do all the work of generating the new summary buffer
10056 ;; according to the new limit.
10057 (gnus-summary-prepare)
10058 ;; Try to return to the article you were at, or on in the
10061 ;; We try to find some article after the current one.
10063 (and (gnus-summary-goto-subject
10064 (gnus-data-number (car data)) nil t)
10067 (setq data (cdr data))))
10069 ;; If there is no data, that means that we were after the last
10070 ;; article. The same goes when we can't find any articles
10071 ;; after the current one.
10073 (goto-char (point-max))
10074 (gnus-summary-find-prev)))
10075 ;; We return how many articles were removed from the summary
10076 ;; buffer as a result of the new limit.
10077 (- total (length gnus-newsgroup-data))))
10079 (defun gnus-summary-initial-limit ()
10080 "Figure out what the initial limit is supposed to be on group entry.
10081 This entails weeding out unwanted dormants, low-scored articles,
10082 fetch-old-headers verbiage, and so on."
10083 ;; Most groups have nothing to remove.
10084 (if (or gnus-inhibit-limiting
10085 (and (null gnus-newsgroup-dormant)
10086 (not (eq gnus-fetch-old-headers 'some))
10087 (null gnus-summary-expunge-below)
10088 (null gnus-thread-expunge-below)))
10090 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10091 (setq gnus-newsgroup-limit nil)
10094 (unless (car (symbol-value node))
10095 ;; These threads have no parents -- they are roots.
10096 (let ((nodes (cdr (symbol-value node))))
10098 (if (and gnus-thread-expunge-below
10099 (< (gnus-thread-total-score (car nodes))
10100 gnus-thread-expunge-below))
10101 (gnus-expunge-thread (pop nodes))
10102 (gnus-summary-limit-children (pop nodes)))))))
10103 gnus-newsgroup-dependencies)
10104 (when (not gnus-newsgroup-limit)
10105 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10106 gnus-newsgroup-limit))
10108 (defun gnus-summary-limit-children (thread)
10109 "Return 1 if this subthread is visible and 0 if it is not."
10110 ;; First we get the number of visible children to this thread. This
10111 ;; is done by recursing down the thread using this function, so this
10112 ;; will really go down to a leaf article first, before slowly
10113 ;; working its way up towards the root.
10116 (apply '+ (mapcar 'gnus-summary-limit-children
10119 (number (mail-header-number (car thread)))
10122 ;; If this article is dormant and has absolutely no visible
10123 ;; children, then this article isn't visible.
10124 (and (memq number gnus-newsgroup-dormant)
10126 ;; If this is a "fetch-old-headered" and there is only one
10127 ;; visible child (or less), then we don't want this article.
10128 (and (eq gnus-fetch-old-headers 'some)
10129 (memq number gnus-newsgroup-ancient)
10131 ;; If we use expunging, and this article is really
10132 ;; low-scored, then we don't want this article.
10133 (when (and gnus-summary-expunge-below
10135 (or (cdr (assq number gnus-newsgroup-scored))
10136 gnus-summary-default-score))
10137 gnus-summary-expunge-below))
10138 ;; We increase the expunge-tally here, but that has
10139 ;; nothing to do with the limits, really.
10140 (incf gnus-newsgroup-expunged-tally)
10141 ;; We also mark as read here, if that's wanted.
10142 (when (and gnus-summary-mark-below
10143 (< score gnus-summary-mark-below))
10144 (setq gnus-newsgroup-unreads
10145 (delq number gnus-newsgroup-unreads))
10146 (if gnus-newsgroup-auto-expire
10147 (push number gnus-newsgroup-expirable)
10148 (push (cons number gnus-low-score-mark)
10149 gnus-newsgroup-reads)))
10151 ;; Nope, invisible article.
10153 ;; Ok, this article is to be visible, so we add it to the limit
10155 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
10158 (defun gnus-expunge-thread (thread)
10159 "Mark all articles in THREAD as read."
10160 (let* ((number (mail-header-number (car thread))))
10161 (incf gnus-newsgroup-expunged-tally)
10162 ;; We also mark as read here, if that's wanted.
10163 (setq gnus-newsgroup-unreads
10164 (delq number gnus-newsgroup-unreads))
10165 (if gnus-newsgroup-auto-expire
10166 (push number gnus-newsgroup-expirable)
10167 (push (cons number gnus-low-score-mark)
10168 gnus-newsgroup-reads)))
10169 ;; Go recursively through all subthreads.
10170 (mapcar 'gnus-expunge-thread (cdr thread)))
10172 ;; Summary article oriented commands
10174 (defun gnus-summary-refer-parent-article (n)
10175 "Refer parent article N times.
10176 The difference between N and the number of articles fetched is returned."
10178 (gnus-set-global-variables)
10182 (let* ((header (gnus-summary-article-header))
10184 ;; If we try to find the parent of the currently
10185 ;; displayed article, then we take a look at the actual
10186 ;; References header, since this is slightly more
10187 ;; reliable than the References field we got from the
10189 (if (and (eq (mail-header-number header)
10190 (cdr gnus-article-current))
10191 (equal gnus-newsgroup-name
10192 (car gnus-article-current)))
10194 (set-buffer gnus-original-article-buffer)
10195 (gnus-narrow-to-headers)
10197 (mail-fetch-field "references")
10199 ;; It's not the current article, so we take a bet on
10200 ;; the value we got from the server.
10201 (mail-header-references header))))
10203 (or (gnus-summary-refer-article (gnus-parent-id ref))
10204 (gnus-message 1 "Couldn't find parent"))
10205 (gnus-message 1 "No references in article %d"
10206 (gnus-summary-article-number))
10209 (gnus-summary-position-point)
10212 (defun gnus-summary-refer-references ()
10213 "Fetch all articles mentioned in the References header.
10214 Return how many articles were fetched."
10216 (gnus-set-global-variables)
10217 (let ((ref (mail-header-references (gnus-summary-article-header)))
10218 (current (gnus-summary-article-number))
10220 ;; For each Message-ID in the References header...
10221 (while (string-match "<[^>]*>" ref)
10223 ;; ... fetch that article.
10224 (gnus-summary-refer-article
10225 (prog1 (match-string 0 ref)
10226 (setq ref (substring ref (match-end 0))))))
10227 (gnus-summary-goto-subject current)
10228 (gnus-summary-position-point)
10231 (defun gnus-summary-refer-article (message-id)
10232 "Fetch an article specified by MESSAGE-ID."
10233 (interactive "sMessage-ID: ")
10234 (when (and (stringp message-id)
10235 (not (zerop (length message-id))))
10236 ;; Construct the correct Message-ID if necessary.
10237 ;; Suggested by tale@pawl.rpi.edu.
10238 (unless (string-match "^<" message-id)
10239 (setq message-id (concat "<" message-id)))
10240 (unless (string-match ">$" message-id)
10241 (setq message-id (concat message-id ">")))
10242 (let ((header (car (gnus-gethash (downcase message-id)
10243 gnus-newsgroup-dependencies))))
10245 ;; The article is present in the buffer, to we just go to it.
10246 (gnus-summary-goto-article (mail-header-number header) nil t)
10247 ;; We fetch the article
10248 (let ((gnus-override-method gnus-refer-article-method)
10250 ;; Start the special refer-article method, if necessary.
10251 (when gnus-refer-article-method
10252 (gnus-check-server gnus-refer-article-method))
10253 ;; Fetch the header, and display the article.
10254 (when (setq number (gnus-summary-insert-subject message-id))
10255 (gnus-summary-select-article nil nil nil number)))))))
10257 (defun gnus-summary-enter-digest-group (&optional force)
10258 "Enter a digest group based on the current article."
10260 (gnus-set-global-variables)
10261 (gnus-summary-select-article)
10262 (let ((name (format "%s-%d"
10263 (gnus-group-prefixed-name
10264 gnus-newsgroup-name (list 'nndoc ""))
10265 gnus-current-article))
10266 (ogroup gnus-newsgroup-name)
10267 (buf (current-buffer)))
10269 (set-buffer gnus-original-article-buffer)
10270 (goto-char (point-min))
10271 (search-forward "\n\n" nil t)
10272 (narrow-to-region (point) (point-max)))
10274 (if (gnus-group-read-ephemeral-group
10275 name `(nndoc ,name (nndoc-address
10276 ,(get-buffer gnus-original-article-buffer))
10277 (nndoc-article-type ,(if force 'digest 'guess))) t)
10278 ;; Make all postings to this group go to the parent group.
10279 (setcdr (nthcdr 4 (gnus-get-info name))
10280 (list (list (cons 'to-group ogroup))))
10281 ;; Couldn't select this doc group.
10282 (switch-to-buffer buf)
10283 (gnus-set-global-variables)
10284 (gnus-configure-windows 'summary)
10285 (gnus-message 3 "Article couldn't be entered?"))
10287 (set-buffer gnus-original-article-buffer)
10290 (defun gnus-summary-isearch-article (&optional regexp-p)
10291 "Do incremental search forward on the current article.
10292 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
10294 (gnus-set-global-variables)
10295 (gnus-summary-select-article)
10296 (gnus-eval-in-buffer-window
10297 gnus-article-buffer
10298 (goto-char (point-min))
10299 (isearch-forward regexp-p)))
10301 (defun gnus-summary-search-article-forward (regexp &optional backward)
10302 "Search for an article containing REGEXP forward.
10303 If BACKWARD, search backward instead."
10306 (format "Search article %s (regexp%s): "
10307 (if current-prefix-arg "backward" "forward")
10308 (if gnus-last-search-regexp
10309 (concat ", default " gnus-last-search-regexp)
10311 current-prefix-arg))
10312 (gnus-set-global-variables)
10313 (if (string-equal regexp "")
10314 (setq regexp (or gnus-last-search-regexp ""))
10315 (setq gnus-last-search-regexp regexp))
10316 (if (gnus-summary-search-article regexp backward)
10317 (gnus-article-set-window-start
10318 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
10319 (error "Search failed: \"%s\"" regexp)))
10321 (defun gnus-summary-search-article-backward (regexp)
10322 "Search for an article containing REGEXP backward."
10325 (format "Search article backward (regexp%s): "
10326 (if gnus-last-search-regexp
10327 (concat ", default " gnus-last-search-regexp)
10329 (gnus-summary-search-article-forward regexp 'backward))
10331 (defun gnus-summary-search-article (regexp &optional backward)
10332 "Search for an article containing REGEXP.
10333 Optional argument BACKWARD means do search for backward.
10334 gnus-select-article-hook is not called during the search."
10335 (let ((gnus-select-article-hook nil) ;Disable hook.
10336 (gnus-mark-article-hook nil) ;Inhibit marking as read.
10339 (function re-search-backward) (function re-search-forward)))
10342 ;; Hidden thread subtrees must be searched for ,too.
10343 (gnus-summary-show-all-threads)
10344 ;; First of all, search current article.
10345 ;; We don't want to read article again from NNTP server nor reset
10347 (gnus-summary-select-article)
10348 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10349 (setq last gnus-current-article)
10350 (gnus-eval-in-buffer-window
10351 gnus-article-buffer
10354 ;; Begin search from current point.
10355 (setq found (funcall re-search regexp nil t))))
10356 ;; Then search next articles.
10357 (while (and (not found)
10358 (gnus-summary-display-article
10359 (if backward (gnus-summary-find-prev)
10360 (gnus-summary-find-next))))
10361 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10362 (gnus-eval-in-buffer-window
10363 gnus-article-buffer
10366 (goto-char (if backward (point-max) (point-min)))
10367 (setq found (funcall re-search regexp nil t)))))
10369 ;; Adjust article pointer.
10370 (or (eq last gnus-current-article)
10371 (setq gnus-last-article last))
10372 ;; Return T if found such article.
10375 (defun gnus-summary-find-matching (header regexp &optional backward unread
10377 "Return a list of all articles that match REGEXP on HEADER.
10378 The search stars on the current article and goes forwards unless
10379 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
10380 If UNREAD is non-nil, only unread articles will
10381 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
10382 in the comparisons."
10383 (let ((data (if (eq backward 'all) gnus-newsgroup-data
10384 (gnus-data-find-list
10385 (gnus-summary-article-number) (gnus-data-list backward))))
10386 (func (intern (concat "gnus-header-" header)))
10387 (case-fold-search (not not-case-fold))
10389 (or (fboundp func) (error "%s is not a valid header" header))
10391 (setq d (car data))
10392 (and (or (not unread) ; We want all articles...
10393 (gnus-data-unread-p d)) ; Or just unreads.
10394 (vectorp (gnus-data-header d)) ; It's not a pseudo.
10395 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
10396 (setq articles (cons (gnus-data-number d) articles))) ; Success!
10397 (setq data (cdr data)))
10398 (nreverse articles)))
10400 (defun gnus-summary-execute-command (header regexp command &optional backward)
10401 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
10402 If HEADER is an empty string (or nil), the match is done on the entire
10403 article. If BACKWARD (the prefix) is non-nil, search backward instead."
10405 (list (let ((completion-ignore-case t))
10408 (mapcar (lambda (string) (list string))
10409 '("Number" "Subject" "From" "Lines" "Date"
10410 "Message-ID" "Xref" "References"))
10411 nil 'require-match))
10412 (read-string "Regexp: ")
10413 (read-key-sequence "Command: ")
10414 current-prefix-arg))
10415 (gnus-set-global-variables)
10416 ;; Hidden thread subtrees must be searched as well.
10417 (gnus-summary-show-all-threads)
10418 ;; We don't want to change current point nor window configuration.
10420 (save-window-excursion
10421 (gnus-message 6 "Executing %s..." (key-description command))
10422 ;; We'd like to execute COMMAND interactively so as to give arguments.
10423 (gnus-execute header regexp
10424 `(lambda () (call-interactively ',(key-binding command)))
10426 (gnus-message 6 "Executing %s...done" (key-description command)))))
10428 (defun gnus-summary-beginning-of-article ()
10429 "Scroll the article back to the beginning."
10431 (gnus-set-global-variables)
10432 (gnus-summary-select-article)
10433 (gnus-configure-windows 'article)
10434 (gnus-eval-in-buffer-window
10435 gnus-article-buffer
10437 (goto-char (point-min))
10438 (and gnus-break-pages (gnus-narrow-to-page))))
10440 (defun gnus-summary-end-of-article ()
10441 "Scroll to the end of the article."
10443 (gnus-set-global-variables)
10444 (gnus-summary-select-article)
10445 (gnus-configure-windows 'article)
10446 (gnus-eval-in-buffer-window
10447 gnus-article-buffer
10449 (goto-char (point-max))
10451 (and gnus-break-pages (gnus-narrow-to-page))))
10453 (defun gnus-summary-show-article (&optional arg)
10454 "Force re-fetching of the current article.
10455 If ARG (the prefix) is non-nil, show the raw article without any
10456 article massaging functions being run."
10458 (gnus-set-global-variables)
10460 ;; Select the article the normal way.
10461 (gnus-summary-select-article nil 'force)
10462 ;; Bind the article treatment functions to nil.
10463 (let ((gnus-have-all-headers t)
10464 gnus-article-display-hook
10465 gnus-article-prepare-hook
10467 (gnus-summary-select-article nil 'force)))
10468 (gnus-configure-windows 'article)
10469 (gnus-summary-position-point))
10471 (defun gnus-summary-verbose-headers (&optional arg)
10472 "Toggle permanent full header display.
10473 If ARG is a positive number, turn header display on.
10474 If ARG is a negative number, turn header display off."
10476 (gnus-set-global-variables)
10477 (gnus-summary-toggle-header arg)
10478 (setq gnus-show-all-headers
10479 (cond ((or (not (numberp arg))
10481 (not gnus-show-all-headers))
10485 (defun gnus-summary-toggle-header (&optional arg)
10486 "Show the headers if they are hidden, or hide them if they are shown.
10487 If ARG is a positive number, show the entire header.
10488 If ARG is a negative number, hide the unwanted header lines."
10490 (gnus-set-global-variables)
10492 (set-buffer gnus-article-buffer)
10493 (let* ((buffer-read-only nil)
10494 (inhibit-point-motion-hooks t)
10495 (hidden (text-property-any
10496 (goto-char (point-min)) (search-forward "\n\n")
10499 (goto-char (point-min))
10500 (when (search-forward "\n\n" nil t)
10501 (delete-region (point-min) (1- (point))))
10502 (goto-char (point-min))
10504 (set-buffer gnus-original-article-buffer)
10505 (goto-char (point-min))
10506 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
10507 (insert-buffer-substring gnus-original-article-buffer 1 e)
10508 (let ((gnus-inhibit-hiding t))
10509 (run-hooks 'gnus-article-display-hook))
10510 (if (or (not hidden) (and (numberp arg) (< arg 0)))
10511 (gnus-article-hide-headers)))))
10513 (defun gnus-summary-show-all-headers ()
10514 "Make all header lines visible."
10516 (gnus-set-global-variables)
10517 (gnus-article-show-all-headers))
10519 (defun gnus-summary-toggle-mime (&optional arg)
10520 "Toggle MIME processing.
10521 If ARG is a positive number, turn MIME processing on."
10523 (gnus-set-global-variables)
10524 (setq gnus-show-mime
10525 (if (null arg) (not gnus-show-mime)
10526 (> (prefix-numeric-value arg) 0)))
10527 (gnus-summary-select-article t 'force))
10529 (defun gnus-summary-caesar-message (&optional arg)
10530 "Caesar rotate the current article by 13.
10531 The numerical prefix specifies how manu places to rotate each letter
10534 (gnus-set-global-variables)
10535 (gnus-summary-select-article)
10536 (let ((mail-header-separator ""))
10537 (gnus-eval-in-buffer-window
10538 gnus-article-buffer
10541 (let ((start (window-start)))
10542 (news-caesar-buffer-body arg)
10543 (set-window-start (get-buffer-window (current-buffer)) start))))))
10545 (defun gnus-summary-stop-page-breaking ()
10546 "Stop page breaking in the current article."
10548 (gnus-set-global-variables)
10549 (gnus-summary-select-article)
10550 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
10552 ;; Suggested by Brian Edmonds <bedmonds@prodigy.bc.ca>.
10554 (defun gnus-summary-move-article (&optional n to-newsgroup select-method)
10555 "Move the current article to a different newsgroup.
10556 If N is a positive number, move the N next articles.
10557 If N is a negative number, move the N previous articles.
10558 If N is nil and any articles have been marked with the process mark,
10559 move those articles instead.
10560 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
10561 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
10562 re-spool using this method.
10563 For this function to work, both the current newsgroup and the
10564 newsgroup that you want to move to have to support the `request-move'
10565 and `request-accept' functions. (Ie. mail newsgroups at present.)"
10567 (gnus-set-global-variables)
10568 (unless (gnus-check-backend-function
10569 'request-move-article gnus-newsgroup-name)
10570 (error "The current newsgroup does not support article moving"))
10571 (let ((articles (gnus-summary-work-articles n))
10572 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
10573 art-group to-method sel-met)
10574 (when (and (not to-newsgroup)
10575 (not select-method))
10577 (gnus-read-move-group-name
10578 "move" gnus-current-move-group articles prefix))
10579 (setq gnus-current-move-group to-newsgroup))
10580 (setq to-method (if select-method (list select-method "")
10581 (gnus-find-method-for-group to-newsgroup)))
10582 (or (gnus-check-backend-function 'request-accept-article (car to-method))
10583 (error "%s does not support article copying" (car to-method)))
10584 (or (gnus-check-server to-method)
10585 (error "Can't open server %s" (car to-method)))
10586 (gnus-message 6 "Moving to %s: %s..."
10587 (or select-method to-newsgroup) articles)
10589 (if (setq art-group
10590 (gnus-request-move-article
10591 (car articles) ; Article to move
10592 gnus-newsgroup-name ; From newsgrouo
10593 (nth 1 (gnus-find-method-for-group
10594 gnus-newsgroup-name)) ; Server
10595 (list 'gnus-request-accept-article
10597 (list 'quote select-method)
10599 (not (cdr articles))) ; Accept form
10600 (not (cdr articles)))) ; Only save nov last time
10601 (let* ((buffer-read-only nil)
10604 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
10606 (gnus-group-prefixed-name
10608 (if select-method (list select-method "")
10609 (gnus-find-method-for-group to-newsgroup)))
10610 gnus-newsrc-hashtb)))
10611 (info (nth 2 entry))
10612 (article (car articles)))
10613 ;; Update the group that has been moved to.
10615 () ; This group does not exist yet.
10616 (unless (memq article gnus-newsgroup-unreads)
10617 (gnus-info-set-read
10618 info (gnus-add-to-range (gnus-info-read info)
10619 (list (cdr art-group)))))
10621 ;; Copy any marks over to the new group.
10622 (let ((marks '((tick . gnus-newsgroup-marked)
10623 (dormant . gnus-newsgroup-dormant)
10624 (expire . gnus-newsgroup-expirable)
10625 (bookmark . gnus-newsgroup-bookmarks)
10626 (save . gnus-newsgroup-saved)
10627 (reply . gnus-newsgroup-replied)))
10628 (to-article (cdr art-group)))
10630 ;; See whether the article is to be put in the cache.
10631 (when gnus-use-cache
10632 (gnus-cache-possibly-enter-article
10633 (gnus-info-group info) to-article
10634 (let ((header (copy-sequence
10635 (gnus-summary-article-header article))))
10636 (mail-header-set-number header to-article)
10638 (memq article gnus-newsgroup-marked)
10639 (memq article gnus-newsgroup-dormant)
10640 (memq article gnus-newsgroup-unreads)))
10643 (if (memq article (symbol-value (cdr (car marks))))
10644 (gnus-add-marked-articles
10645 (gnus-info-group info) (car (car marks))
10646 (list to-article) info))
10647 (setq marks (cdr marks)))))
10648 (gnus-summary-goto-subject article)
10649 (gnus-summary-mark-article article gnus-canceled-mark))
10650 (gnus-message 1 "Couldn't move article %s" (car articles)))
10651 (gnus-summary-remove-process-mark (car articles))
10652 (setq articles (cdr articles)))
10653 (gnus-set-mode-line 'summary)))
10655 (defun gnus-summary-respool-article (&optional n respool-method)
10656 "Respool the current article.
10657 The article will be squeezed through the mail spooling process again,
10658 which means that it will be put in some mail newsgroup or other
10659 depending on `nnmail-split-methods'.
10660 If N is a positive number, respool the N next articles.
10661 If N is a negative number, respool the N previous articles.
10662 If N is nil and any articles have been marked with the process mark,
10663 respool those articles instead.
10665 Respooling can be done both from mail groups and \"real\" newsgroups.
10666 In the former case, the articles in question will be moved from the
10667 current group into whatever groups they are destined to. In the
10668 latter case, they will be copied into the relevant groups."
10670 (gnus-set-global-variables)
10671 (let ((respool-methods (gnus-methods-using 'respool))
10673 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
10675 (setq respool-method
10677 "What method do you want to use when respooling? "
10678 respool-methods nil t methname)))
10679 (or (string= respool-method "")
10680 (if (assoc (symbol-name
10681 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10683 (gnus-summary-move-article n nil (intern respool-method))
10684 (gnus-summary-copy-article n nil (intern respool-method))))))
10686 ;; Suggested by gregj@unidata.com (Gregory J. Grubbs).
10687 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10688 "Move the current article to a different newsgroup.
10689 If N is a positive number, move the N next articles.
10690 If N is a negative number, move the N previous articles.
10691 If N is nil and any articles have been marked with the process mark,
10692 move those articles instead.
10693 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
10694 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
10695 re-spool using this method.
10696 For this function to work, the newsgroup that you want to move to have
10697 to support the `request-move' and `request-accept'
10698 functions. (Ie. mail newsgroups at present.)"
10700 (gnus-set-global-variables)
10701 (let ((articles (gnus-summary-work-articles n))
10702 (copy-buf (get-buffer-create "*copy work*"))
10703 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
10704 art-group to-method)
10705 (buffer-disable-undo copy-buf)
10706 (when (and (not to-newsgroup)
10707 (not select-method))
10709 (gnus-read-move-group-name
10710 "copy" gnus-current-move-group articles prefix))
10711 (setq gnus-current-move-group to-newsgroup))
10712 (setq to-method (if select-method (list select-method "")
10713 (gnus-find-method-for-group to-newsgroup)))
10714 (or (gnus-check-backend-function 'request-accept-article (car to-method))
10715 (error "%s does not support article copying" (car to-method)))
10716 (or (gnus-check-server to-method)
10717 (error "Can't open server %s" (car to-method)))
10719 (gnus-message 6 "Copying to %s: %s..."
10720 (or select-method to-newsgroup) articles)
10721 (if (setq art-group
10723 (set-buffer copy-buf)
10724 (gnus-request-article-this-buffer
10725 (car articles) gnus-newsgroup-name)
10726 (gnus-request-accept-article
10727 (if select-method select-method to-newsgroup)
10728 (not (cdr articles)))))
10731 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
10733 (gnus-group-prefixed-name
10735 (if select-method (list select-method "")
10736 (gnus-find-method-for-group to-newsgroup)))
10737 gnus-newsrc-hashtb)))
10738 (info (nth 2 entry))
10739 (article (car articles)))
10740 ;; We copy the info over to the new group.
10742 () ; This group does not exist (yet).
10743 (if (not (memq article gnus-newsgroup-unreads))
10744 (gnus-info-set-read
10745 info (gnus-add-to-range (gnus-info-read info)
10746 (list (cdr art-group)))))
10748 ;; Copy any marks over to the new group.
10749 (let ((marks '((tick . gnus-newsgroup-marked)
10750 (dormant . gnus-newsgroup-dormant)
10751 (expire . gnus-newsgroup-expirable)
10752 (bookmark . gnus-newsgroup-bookmarks)
10753 (save . gnus-newsgroup-saved)
10754 (reply . gnus-newsgroup-replied)))
10755 (to-article (cdr art-group)))
10757 ;; See whether the article is to be put in the cache.
10758 (when gnus-use-cache
10759 (gnus-cache-possibly-enter-article
10760 (gnus-info-group info) to-article
10761 (let ((header (copy-sequence
10762 (gnus-summary-article-header article))))
10763 (mail-header-set-number header to-article)
10765 (memq article gnus-newsgroup-marked)
10766 (memq article gnus-newsgroup-dormant)
10767 (memq article gnus-newsgroup-unreads)))
10770 (if (memq article (symbol-value (cdr (car marks))))
10771 (gnus-add-marked-articles
10772 (gnus-info-group info) (car (car marks))
10773 (list to-article) info))
10774 (setq marks (cdr marks))))))
10775 (gnus-message 1 "Couldn't copy article %s" (car articles)))
10776 (gnus-summary-remove-process-mark (car articles))
10777 (setq articles (cdr articles)))
10778 (kill-buffer copy-buf)))
10780 (defun gnus-summary-import-article (file)
10781 "Import a random file into a mail newsgroup."
10782 (interactive "fImport file: ")
10783 (gnus-set-global-variables)
10784 (let ((group gnus-newsgroup-name)
10786 (or (gnus-check-backend-function 'request-accept-article group)
10787 (error "%s does not support article importing" group))
10788 (or (file-readable-p file)
10789 (not (file-regular-p file))
10790 (error "Can't read %s" file))
10792 (set-buffer (get-buffer-create " *import file*"))
10793 (buffer-disable-undo (current-buffer))
10795 (insert-file-contents file)
10796 (goto-char (point-min))
10797 (if (nnheader-article-p)
10799 (setq atts (file-attributes file)
10800 lines (count-lines (point-min) (point-max)))
10801 (insert "From: " (read-string "From: ") "\n"
10802 "Subject: " (read-string "Subject: ") "\n"
10803 "Date: " (current-time-string (nth 5 atts)) "\n"
10804 "Message-ID: " (gnus-inews-message-id) "\n"
10805 "Lines: " (int-to-string lines) "\n"
10806 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10807 (gnus-request-accept-article group t)
10808 (kill-buffer (current-buffer)))))
10810 (defun gnus-summary-expire-articles ()
10811 "Expire all articles that are marked as expirable in the current group."
10813 (gnus-set-global-variables)
10814 (when (gnus-check-backend-function
10815 'request-expire-articles gnus-newsgroup-name)
10816 ;; This backend supports expiry.
10817 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10818 (expirable (if total
10819 (gnus-list-of-read-articles gnus-newsgroup-name)
10820 (setq gnus-newsgroup-expirable
10821 (sort gnus-newsgroup-expirable '<))))
10822 (expiry-wait (gnus-group-get-parameter
10823 gnus-newsgroup-name 'expiry-wait))
10826 ;; There are expirable articles in this group, so we run them
10827 ;; through the expiry process.
10828 (gnus-message 6 "Expiring articles...")
10829 ;; The list of articles that weren't expired is returned.
10831 (let ((nnmail-expiry-wait-function nil)
10832 (nnmail-expiry-wait expiry-wait))
10833 (setq es (gnus-request-expire-articles
10834 expirable gnus-newsgroup-name)))
10835 (setq es (gnus-request-expire-articles
10836 expirable gnus-newsgroup-name)))
10837 (or total (setq gnus-newsgroup-expirable es))
10838 ;; We go through the old list of expirable, and mark all
10839 ;; really expired articles as non-existant.
10840 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10841 (let ((gnus-use-cache nil))
10843 (unless (memq (car expirable) es)
10844 (when (gnus-data-find (car expirable))
10845 (gnus-summary-mark-article
10846 (car expirable) gnus-canceled-mark)))
10847 (setq expirable (cdr expirable)))))
10848 (gnus-message 6 "Expiring articles...done")))))
10850 (defun gnus-summary-expire-articles-now ()
10851 "Expunge all expirable articles in the current group.
10852 This means that *all* articles that are marked as expirable will be
10853 deleted forever, right now."
10855 (gnus-set-global-variables)
10856 (or gnus-expert-user
10858 "Are you really, really, really sure you want to expunge? ")
10860 (let ((nnmail-expiry-wait 'immediate)
10861 (nnmail-expiry-wait-function nil))
10862 (gnus-summary-expire-articles)))
10864 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10865 (defun gnus-summary-delete-article (&optional n)
10866 "Delete the N next (mail) articles.
10867 This command actually deletes articles. This is not a marking
10868 command. The article will disappear forever from your life, never to
10870 If N is negative, delete backwards.
10871 If N is nil and articles have been marked with the process mark,
10872 delete these instead."
10874 (gnus-set-global-variables)
10875 (or (gnus-check-backend-function 'request-expire-articles
10876 gnus-newsgroup-name)
10877 (error "The current newsgroup does not support article deletion."))
10878 ;; Compute the list of articles to delete.
10879 (let ((articles (gnus-summary-work-articles n))
10881 (if (and gnus-novice-user
10882 (not (gnus-y-or-n-p
10883 (format "Do you really want to delete %s forever? "
10884 (if (> (length articles) 1) "these articles"
10885 "this article")))))
10887 ;; Delete the articles.
10888 (setq not-deleted (gnus-request-expire-articles
10889 articles gnus-newsgroup-name 'force))
10891 (gnus-summary-remove-process-mark (car articles))
10892 ;; The backend might not have been able to delete the article
10894 (or (memq (car articles) not-deleted)
10895 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
10896 (setq articles (cdr articles))))
10897 (gnus-summary-position-point)
10898 (gnus-set-mode-line 'summary)
10901 (defun gnus-summary-edit-article (&optional force)
10902 "Enter into a buffer and edit the current article.
10903 This will have permanent effect only in mail groups.
10904 If FORCE is non-nil, allow editing of articles even in read-only
10907 (gnus-set-global-variables)
10908 (when (and (not force)
10909 (gnus-group-read-only-p))
10910 (error "The current newsgroup does not support article editing."))
10911 (gnus-summary-select-article t nil t)
10912 (gnus-configure-windows 'article)
10913 (select-window (get-buffer-window gnus-article-buffer))
10914 (gnus-message 6 "C-c C-c to end edits")
10915 (setq buffer-read-only nil)
10917 (use-local-map (copy-keymap (current-local-map)))
10918 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
10919 (buffer-enable-undo)
10921 (goto-char (point-min))
10922 (search-forward "\n\n" nil t))
10924 (defun gnus-summary-edit-article-done ()
10925 "Make edits to the current article permanent."
10927 (if (gnus-group-read-only-p)
10929 (gnus-summary-edit-article-postpone)
10931 1 "The current newsgroup does not support article editing.")
10933 (let ((buf (buffer-substring-no-properties (point-min) (point-max))))
10936 (if (not (gnus-request-replace-article
10937 (cdr gnus-article-current) (car gnus-article-current)
10939 (error "Couldn't replace article.")
10940 (gnus-article-mode)
10941 (use-local-map gnus-article-mode-map)
10942 (setq buffer-read-only t)
10943 (buffer-disable-undo (current-buffer))
10944 (gnus-configure-windows 'summary))
10945 (and (gnus-visual-p 'summary-highlight 'highlight)
10946 (run-hooks 'gnus-visual-mark-article-hook)))))
10948 (defun gnus-summary-edit-article-postpone ()
10949 "Postpone changes to the current article."
10951 (gnus-article-mode)
10952 (use-local-map gnus-article-mode-map)
10953 (setq buffer-read-only t)
10954 (buffer-disable-undo (current-buffer))
10955 (gnus-configure-windows 'summary)
10956 (and (gnus-visual-p 'summary-highlight 'highlight)
10957 (run-hooks 'gnus-visual-mark-article-hook)))
10959 (defun gnus-summary-respool-query ()
10960 "Query where the respool algorithm would put this article."
10962 (gnus-set-global-variables)
10963 (gnus-summary-select-article)
10965 (set-buffer gnus-article-buffer)
10967 (goto-char (point-min))
10968 (search-forward "\n\n")
10969 (narrow-to-region (point-min) (point))
10970 (pp-eval-expression
10971 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
10973 ;; Summary score commands.
10975 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
10977 (defun gnus-summary-raise-score (n)
10978 "Raise the score of the current article by N."
10980 (gnus-set-global-variables)
10981 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
10983 (defun gnus-summary-set-score (n)
10984 "Set the score of the current article to N."
10986 (gnus-set-global-variables)
10988 (gnus-summary-show-thread)
10989 (let ((buffer-read-only nil))
10991 (gnus-summary-update-mark
10992 (if (= n (or gnus-summary-default-score 0)) ?
10993 (if (< n (or gnus-summary-default-score 0))
10994 gnus-score-below-mark gnus-score-over-mark)) 'score))
10995 (let* ((article (gnus-summary-article-number))
10996 (score (assq article gnus-newsgroup-scored)))
10997 (if score (setcdr score n)
10998 (setq gnus-newsgroup-scored
10999 (cons (cons article n) gnus-newsgroup-scored))))
11000 (gnus-summary-update-line)))
11002 (defun gnus-summary-current-score ()
11003 "Return the score of the current article."
11005 (gnus-set-global-variables)
11006 (message "%s" (gnus-summary-article-score)))
11008 ;; Summary marking commands.
11010 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11011 "Mark articles which has the same subject as read, and then select the next.
11012 If UNMARK is positive, remove any kind of mark.
11013 If UNMARK is negative, tick articles."
11015 (gnus-set-global-variables)
11017 (setq unmark (prefix-numeric-value unmark)))
11019 (gnus-summary-mark-same-subject
11020 (gnus-summary-article-subject) unmark)))
11021 ;; Select next unread article. If auto-select-same mode, should
11022 ;; select the first unread article.
11023 (gnus-summary-next-article t (and gnus-auto-select-same
11024 (gnus-summary-article-subject)))
11025 (gnus-message 7 "%d article%s marked as %s"
11026 count (if (= count 1) " is" "s are")
11027 (if unmark "unread" "read"))))
11029 (defun gnus-summary-kill-same-subject (&optional unmark)
11030 "Mark articles which has the same subject as read.
11031 If UNMARK is positive, remove any kind of mark.
11032 If UNMARK is negative, tick articles."
11034 (gnus-set-global-variables)
11036 (setq unmark (prefix-numeric-value unmark)))
11038 (gnus-summary-mark-same-subject
11039 (gnus-summary-article-subject) unmark)))
11040 ;; If marked as read, go to next unread subject.
11042 ;; Go to next unread subject.
11043 (gnus-summary-next-subject 1 t))
11044 (gnus-message 7 "%d articles are marked as %s"
11045 count (if unmark "unread" "read"))))
11047 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11048 "Mark articles with same SUBJECT as read, and return marked number.
11049 If optional argument UNMARK is positive, remove any kinds of marks.
11050 If optional argument UNMARK is negative, mark articles as unread instead."
11054 ((null unmark) ; Mark as read.
11057 (gnus-summary-mark-article-as-read gnus-killed-mark)
11058 (gnus-summary-show-thread) t)
11059 (gnus-summary-find-subject subject))
11060 (setq count (1+ count))))
11061 ((> unmark 0) ; Tick.
11064 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11065 (gnus-summary-show-thread) t)
11066 (gnus-summary-find-subject subject))
11067 (setq count (1+ count))))
11068 (t ; Mark as unread.
11071 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11072 (gnus-summary-show-thread) t)
11073 (gnus-summary-find-subject subject))
11074 (setq count (1+ count)))))
11075 (gnus-set-mode-line 'summary)
11076 ;; Return the number of marked articles.
11079 (defun gnus-summary-mark-as-processable (n &optional unmark)
11080 "Set the process mark on the next N articles.
11081 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11082 the process mark instead. The difference between N and the actual
11083 number of articles marked is returned."
11085 (gnus-set-global-variables)
11086 (let ((backward (< n 0))
11091 (gnus-summary-remove-process-mark
11092 (gnus-summary-article-number))
11093 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11094 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11096 (if (/= 0 n) (gnus-message 7 "No more articles"))
11097 (gnus-summary-recenter)
11098 (gnus-summary-position-point)
11101 (defun gnus-summary-unmark-as-processable (n)
11102 "Remove the process mark from the next N articles.
11103 If N is negative, mark backward instead. The difference between N and
11104 the actual number of articles marked is returned."
11106 (gnus-set-global-variables)
11107 (gnus-summary-mark-as-processable n t))
11109 (defun gnus-summary-unmark-all-processable ()
11110 "Remove the process mark from all articles."
11112 (gnus-set-global-variables)
11114 (while gnus-newsgroup-processable
11115 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11116 (gnus-summary-position-point))
11118 (defun gnus-summary-mark-as-expirable (n)
11119 "Mark N articles forward as expirable.
11120 If N is negative, mark backward instead. The difference between N and
11121 the actual number of articles marked is returned."
11123 (gnus-set-global-variables)
11124 (gnus-summary-mark-forward n gnus-expirable-mark))
11126 (defun gnus-summary-mark-article-as-replied (article)
11127 "Mark ARTICLE replied and update the summary line."
11128 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11129 (let ((buffer-read-only nil))
11130 (when (gnus-summary-goto-subject article)
11131 (gnus-summary-update-secondary-mark article))))
11133 (defun gnus-summary-set-bookmark (article)
11134 "Set a bookmark in current article."
11135 (interactive (list (gnus-summary-article-number)))
11136 (gnus-set-global-variables)
11137 (if (or (not (get-buffer gnus-article-buffer))
11138 (not gnus-current-article)
11139 (not gnus-article-current)
11140 (not (equal gnus-newsgroup-name (car gnus-article-current))))
11141 (error "No current article selected"))
11142 ;; Remove old bookmark, if one exists.
11143 (let ((old (assq article gnus-newsgroup-bookmarks)))
11144 (if old (setq gnus-newsgroup-bookmarks
11145 (delq old gnus-newsgroup-bookmarks))))
11146 ;; Set the new bookmark, which is on the form
11147 ;; (article-number . line-number-in-body).
11148 (setq gnus-newsgroup-bookmarks
11152 (set-buffer gnus-article-buffer)
11156 (goto-char (point-min))
11157 (search-forward "\n\n" nil t)
11160 gnus-newsgroup-bookmarks))
11161 (gnus-message 6 "A bookmark has been added to the current article."))
11163 (defun gnus-summary-remove-bookmark (article)
11164 "Remove the bookmark from the current article."
11165 (interactive (list (gnus-summary-article-number)))
11166 (gnus-set-global-variables)
11167 ;; Remove old bookmark, if one exists.
11168 (let ((old (assq article gnus-newsgroup-bookmarks)))
11171 (setq gnus-newsgroup-bookmarks
11172 (delq old gnus-newsgroup-bookmarks))
11173 (gnus-message 6 "Removed bookmark."))
11174 (gnus-message 6 "No bookmark in current article."))))
11176 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11177 (defun gnus-summary-mark-as-dormant (n)
11178 "Mark N articles forward as dormant.
11179 If N is negative, mark backward instead. The difference between N and
11180 the actual number of articles marked is returned."
11182 (gnus-set-global-variables)
11183 (gnus-summary-mark-forward n gnus-dormant-mark))
11185 (defun gnus-summary-set-process-mark (article)
11186 "Set the process mark on ARTICLE and update the summary line."
11187 (setq gnus-newsgroup-processable
11189 (delq article gnus-newsgroup-processable)))
11190 (when (gnus-summary-goto-subject article)
11191 (gnus-summary-show-thread)
11192 (gnus-summary-update-secondary-mark article)))
11194 (defun gnus-summary-remove-process-mark (article)
11195 "Remove the process mark from ARTICLE and update the summary line."
11196 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
11197 (when (gnus-summary-goto-subject article)
11198 (gnus-summary-show-thread)
11199 (gnus-summary-update-secondary-mark article)))
11201 (defun gnus-summary-set-saved-mark (article)
11202 "Set the process mark on ARTICLE and update the summary line."
11203 (push article gnus-newsgroup-saved)
11204 (when (gnus-summary-goto-subject article)
11205 (gnus-summary-update-secondary-mark article)))
11207 (defun gnus-summary-mark-forward (n &optional mark no-expire)
11208 "Mark N articles as read forwards.
11209 If N is negative, mark backwards instead.
11210 Mark with MARK. If MARK is ? , ?! or ??, articles will be
11212 The difference between N and the actual number of articles marked is
11215 (gnus-set-global-variables)
11216 (let ((backward (< n 0))
11217 (gnus-summary-goto-unread
11218 (and gnus-summary-goto-unread
11219 (not (memq mark (list gnus-unread-mark
11220 gnus-ticked-mark gnus-dormant-mark)))))
11222 (mark (or mark gnus-del-mark)))
11223 (while (and (> n 0)
11224 (gnus-summary-mark-article nil mark no-expire)
11225 (zerop (gnus-summary-next-subject
11226 (if backward -1 1) gnus-summary-goto-unread t)))
11228 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11229 (gnus-summary-recenter)
11230 (gnus-summary-position-point)
11231 (gnus-set-mode-line 'summary)
11234 (defun gnus-summary-mark-article-as-read (mark)
11235 "Mark the current article quickly as read with MARK."
11236 (let ((article (gnus-summary-article-number)))
11237 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11238 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11239 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11240 (setq gnus-newsgroup-reads
11241 (cons (cons article mark) gnus-newsgroup-reads))
11242 ;; Possibly remove from cache, if that is used.
11243 (and gnus-use-cache (gnus-cache-enter-remove-article article))
11244 (and gnus-newsgroup-auto-expire
11245 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11246 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11247 (= mark gnus-read-mark) (= mark gnus-souped-mark))
11249 (setq mark gnus-expirable-mark)
11250 (setq gnus-newsgroup-expirable
11251 (cons article gnus-newsgroup-expirable))))
11253 (gnus-summary-update-mark mark 'unread)
11256 (defun gnus-summary-mark-article-as-unread (mark)
11257 "Mark the current article quickly as unread with MARK."
11258 (let ((article (gnus-summary-article-number)))
11259 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11260 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11261 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11262 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11263 (cond ((= mark gnus-ticked-mark)
11264 (push article gnus-newsgroup-marked))
11265 ((= mark gnus-dormant-mark)
11266 (push article gnus-newsgroup-dormant))
11268 (push article gnus-newsgroup-unreads)))
11269 (setq gnus-newsgroup-reads
11270 (delq (assq article gnus-newsgroup-reads)
11271 gnus-newsgroup-reads))
11273 ;; See whether the article is to be put in the cache.
11274 (and gnus-use-cache
11275 (vectorp (gnus-summary-article-header article))
11277 (gnus-cache-possibly-enter-article
11278 gnus-newsgroup-name article
11279 (gnus-summary-article-header article)
11280 (= mark gnus-ticked-mark)
11281 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11284 (gnus-summary-update-mark mark 'unread)
11287 (defun gnus-summary-mark-article (&optional article mark no-expire)
11288 "Mark ARTICLE with MARK. MARK can be any character.
11289 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11290 `??' (dormant) and `?E' (expirable).
11291 If MARK is nil, then the default character `?D' is used.
11292 If ARTICLE is nil, then the article on the current line will be
11294 ;; The mark might be a string.
11295 (and (stringp mark)
11296 (setq mark (aref mark 0)))
11297 ;; If no mark is given, then we check auto-expiring.
11298 (and (not no-expire)
11299 gnus-newsgroup-auto-expire
11301 (and (numberp mark)
11302 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11303 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11304 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
11305 (setq mark gnus-expirable-mark))
11306 (let* ((mark (or mark gnus-del-mark))
11307 (article (or article (gnus-summary-article-number))))
11308 (or article (error "No article on current line"))
11309 (if (or (= mark gnus-unread-mark)
11310 (= mark gnus-ticked-mark)
11311 (= mark gnus-dormant-mark))
11312 (gnus-mark-article-as-unread article mark)
11313 (gnus-mark-article-as-read article mark))
11315 ;; See whether the article is to be put in the cache.
11316 (and gnus-use-cache
11317 (not (= mark gnus-canceled-mark))
11318 (vectorp (gnus-summary-article-header article))
11320 (gnus-cache-possibly-enter-article
11321 gnus-newsgroup-name article
11322 (gnus-summary-article-header article)
11323 (= mark gnus-ticked-mark)
11324 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11326 (if (gnus-summary-goto-subject article nil t)
11327 (let ((buffer-read-only nil))
11328 (gnus-summary-show-thread)
11330 (gnus-summary-update-mark mark 'unread)
11333 (defun gnus-summary-update-secondary-mark (article)
11334 "Update the secondary (read, process, cache) mark."
11335 (gnus-summary-update-mark
11336 (cond ((memq article gnus-newsgroup-processable)
11338 ((memq article gnus-newsgroup-cached)
11340 ((memq article gnus-newsgroup-replied)
11342 ((memq article gnus-newsgroup-saved)
11344 (t gnus-unread-mark))
11346 (when (gnus-visual-p 'summary-highlight 'highlight)
11347 (run-hooks 'gnus-summary-update-hook))
11350 (defun gnus-summary-update-mark (mark type)
11351 (beginning-of-line)
11352 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11353 (buffer-read-only nil))
11355 ;; Go to the right position on the line.
11356 (forward-char forward)
11357 ;; Replace the old mark with the new mark.
11358 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
11359 ;; Optionally update the marks by some user rule.
11360 (when (eq type 'unread)
11361 (gnus-data-set-mark
11362 (gnus-data-find (gnus-summary-article-number)) mark)
11363 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
11365 (defun gnus-mark-article-as-read (article &optional mark)
11366 "Enter ARTICLE in the pertinent lists and remove it from others."
11367 ;; Make the article expirable.
11368 (let ((mark (or mark gnus-del-mark)))
11369 (if (= mark gnus-expirable-mark)
11370 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
11371 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
11372 ;; Remove from unread and marked lists.
11373 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11374 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11375 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11376 (push (cons article mark) gnus-newsgroup-reads)
11377 ;; Possibly remove from cache, if that is used.
11378 (when gnus-use-cache
11379 (gnus-cache-enter-remove-article article))))
11381 (defun gnus-mark-article-as-unread (article &optional mark)
11382 "Enter ARTICLE in the pertinent lists and remove it from others."
11383 (let ((mark (or mark gnus-ticked-mark)))
11384 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11385 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11386 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11387 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11388 (cond ((= mark gnus-ticked-mark)
11389 (push article gnus-newsgroup-marked))
11390 ((= mark gnus-dormant-mark)
11391 (push article gnus-newsgroup-dormant))
11393 (push article gnus-newsgroup-unreads)))
11394 (setq gnus-newsgroup-reads
11395 (delq (assq article gnus-newsgroup-reads)
11396 gnus-newsgroup-reads))))
11398 (defalias 'gnus-summary-mark-as-unread-forward
11399 'gnus-summary-tick-article-forward)
11400 (make-obsolete 'gnus-summary-mark-as-unread-forward
11401 'gnus-summary-tick-article-forward)
11402 (defun gnus-summary-tick-article-forward (n)
11403 "Tick N articles forwards.
11404 If N is negative, tick backwards instead.
11405 The difference between N and the number of articles ticked is returned."
11407 (gnus-summary-mark-forward n gnus-ticked-mark))
11409 (defalias 'gnus-summary-mark-as-unread-backward
11410 'gnus-summary-tick-article-backward)
11411 (make-obsolete 'gnus-summary-mark-as-unread-backward
11412 'gnus-summary-tick-article-backward)
11413 (defun gnus-summary-tick-article-backward (n)
11414 "Tick N articles backwards.
11415 The difference between N and the number of articles ticked is returned."
11417 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11419 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
11420 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
11421 (defun gnus-summary-tick-article (&optional article clear-mark)
11422 "Mark current article as unread.
11423 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11424 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11425 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11426 gnus-ticked-mark)))
11428 (defun gnus-summary-mark-as-read-forward (n)
11429 "Mark N articles as read forwards.
11430 If N is negative, mark backwards instead.
11431 The difference between N and the actual number of articles marked is
11434 (gnus-summary-mark-forward n gnus-del-mark t))
11436 (defun gnus-summary-mark-as-read-backward (n)
11437 "Mark the N articles as read backwards.
11438 The difference between N and the actual number of articles marked is
11441 (gnus-summary-mark-forward (- n) gnus-del-mark t))
11443 (defun gnus-summary-mark-as-read (&optional article mark)
11444 "Mark current article as read.
11445 ARTICLE specifies the article to be marked as read.
11446 MARK specifies a string to be inserted at the beginning of the line."
11447 (gnus-summary-mark-article article mark))
11449 (defun gnus-summary-clear-mark-forward (n)
11450 "Clear marks from N articles forward.
11451 If N is negative, clear backward instead.
11452 The difference between N and the number of marks cleared is returned."
11454 (gnus-summary-mark-forward n gnus-unread-mark))
11456 (defun gnus-summary-clear-mark-backward (n)
11457 "Clear marks from N articles backward.
11458 The difference between N and the number of marks cleared is returned."
11460 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11462 (defun gnus-summary-mark-unread-as-read ()
11463 "Intended to be used by `gnus-summary-mark-article-hook'."
11464 (when (memq gnus-current-article gnus-newsgroup-unreads)
11465 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11467 (defun gnus-summary-mark-region-as-read (point mark all)
11468 "Mark all unread articles between point and mark as read.
11469 If given a prefix, mark all articles between point and mark as read,
11470 even ticked and dormant ones."
11471 (interactive "r\nP")
11475 (beginning-of-line)
11480 (memq (setq article (gnus-summary-article-number))
11481 gnus-newsgroup-unreads))
11482 (gnus-summary-mark-article article gnus-del-mark))
11484 (gnus-summary-find-next))))))
11486 (defun gnus-summary-mark-below (score mark)
11487 "Mark articles with score less than SCORE with MARK."
11488 (interactive "P\ncMark: ")
11489 (gnus-set-global-variables)
11490 (setq score (if score
11491 (prefix-numeric-value score)
11492 (or gnus-summary-default-score 0)))
11494 (set-buffer gnus-summary-buffer)
11495 (goto-char (point-min))
11496 (while (not (eobp))
11497 (and (< (gnus-summary-article-score) score)
11498 (gnus-summary-mark-article nil mark))
11499 (gnus-summary-find-next))))
11501 (defun gnus-summary-kill-below (&optional score)
11502 "Mark articles with score below SCORE as read."
11504 (gnus-set-global-variables)
11505 (gnus-summary-mark-below score gnus-killed-mark))
11507 (defun gnus-summary-clear-above (&optional score)
11508 "Clear all marks from articles with score above SCORE."
11510 (gnus-set-global-variables)
11511 (gnus-summary-mark-above score gnus-unread-mark))
11513 (defun gnus-summary-tick-above (&optional score)
11514 "Tick all articles with score above SCORE."
11516 (gnus-set-global-variables)
11517 (gnus-summary-mark-above score gnus-ticked-mark))
11519 (defun gnus-summary-mark-above (score mark)
11520 "Mark articles with score over SCORE with MARK."
11521 (interactive "P\ncMark: ")
11522 (gnus-set-global-variables)
11523 (setq score (if score
11524 (prefix-numeric-value score)
11525 (or gnus-summary-default-score 0)))
11527 (set-buffer gnus-summary-buffer)
11528 (goto-char (point-min))
11530 (if (> (gnus-summary-article-score) score)
11531 (gnus-summary-mark-article nil mark))
11533 (gnus-summary-find-next)))))
11535 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11536 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11537 (defun gnus-summary-limit-include-expunged ()
11538 "Display all the hidden articles that were expunged for low scores."
11540 (gnus-set-global-variables)
11541 (let ((buffer-read-only nil))
11542 (let ((scored gnus-newsgroup-scored)
11545 (or (gnus-summary-goto-subject (car (car scored)))
11546 (and (setq h (gnus-summary-article-header (car (car scored))))
11547 (< (cdr (car scored)) gnus-summary-expunge-below)
11548 (setq headers (cons h headers))))
11549 (setq scored (cdr scored)))
11550 (or headers (error "No expunged articles hidden."))
11551 (goto-char (point-min))
11552 (gnus-summary-prepare-unthreaded (nreverse headers)))
11553 (goto-char (point-min))
11554 (gnus-summary-position-point)))
11556 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
11557 "Mark all articles not marked as unread in this newsgroup as read.
11558 If prefix argument ALL is non-nil, all articles are marked as read.
11559 If QUIETLY is non-nil, no questions will be asked.
11560 If TO-HERE is non-nil, it should be a point in the buffer. All
11561 articles before this point will be marked as read.
11562 The number of articles marked as read is returned."
11564 (gnus-set-global-variables)
11567 (not gnus-interactive-catchup) ;Without confirmation?
11571 "Mark absolutely all articles as read? "
11572 "Mark all unread articles as read? ")))
11574 (not gnus-newsgroup-adaptive)
11575 (not gnus-newsgroup-auto-expire))
11578 (setq gnus-newsgroup-marked nil
11579 gnus-newsgroup-dormant nil))
11580 (setq gnus-newsgroup-unreads nil))
11581 ;; We actually mark all articles as canceled, which we
11582 ;; have to do when using auto-expiry or adaptive scoring.
11583 (gnus-summary-show-all-threads)
11584 (if (gnus-summary-first-subject (not all))
11586 (if to-here (< (point) to-here) t)
11587 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11588 (gnus-summary-find-next (not all)))))
11590 (setq gnus-newsgroup-unreads nil))
11591 (gnus-set-mode-line 'summary)))
11592 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
11593 (if (and (not to-here) (eq 'nnvirtual (car method)))
11594 (nnvirtual-catchup-group
11595 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
11596 (gnus-summary-position-point)))
11598 (defun gnus-summary-catchup-to-here (&optional all)
11599 "Mark all unticked articles before the current one as read.
11600 If ALL is non-nil, also mark ticked and dormant articles as read."
11602 (gnus-set-global-variables)
11604 (let ((beg (point)))
11605 ;; We check that there are unread articles.
11606 (when (or all (gnus-summary-find-prev))
11607 (gnus-summary-catchup all t beg))))
11608 (gnus-summary-position-point))
11610 (defun gnus-summary-catchup-all (&optional quietly)
11611 "Mark all articles in this newsgroup as read."
11613 (gnus-set-global-variables)
11614 (gnus-summary-catchup t quietly))
11616 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11617 "Mark all articles not marked as unread in this newsgroup as read, then exit.
11618 If prefix argument ALL is non-nil, all articles are marked as read."
11620 (gnus-set-global-variables)
11621 (gnus-summary-catchup all quietly nil 'fast)
11622 ;; Select next newsgroup or exit.
11623 (if (eq gnus-auto-select-next 'quietly)
11624 (gnus-summary-next-group nil)
11625 (gnus-summary-exit)))
11627 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11628 "Mark all articles in this newsgroup as read, and then exit."
11630 (gnus-set-global-variables)
11631 (gnus-summary-catchup-and-exit t quietly))
11633 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
11634 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11635 "Mark all articles in this group as read and select the next group.
11636 If given a prefix, mark all articles, unread as well as ticked, as
11639 (gnus-set-global-variables)
11641 (gnus-summary-catchup all))
11642 (gnus-summary-next-article t))
11644 ;; Thread-based commands.
11646 (defun gnus-summary-articles-in-thread (&optional article)
11647 "Return a list of all articles in the current thread.
11648 If ARTICLE is non-nil, return all articles in the thread that starts
11649 with that article."
11650 (let* ((article (or article (gnus-summary-article-number)))
11651 (data (gnus-data-find-list article))
11652 (top-level (gnus-data-level (car data)))
11654 (cond ((null gnus-thread-operation-ignore-subject)
11655 (gnus-simplify-subject-re
11656 (mail-header-subject (gnus-data-header (car data)))))
11657 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11658 (gnus-simplify-subject-fuzzy
11659 (mail-header-subject (gnus-data-header (car data)))))
11663 () ; This article doesn't exist.
11665 (and (or (not top-subject)
11666 (string= top-subject
11667 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11668 (gnus-simplify-subject-fuzzy
11669 (mail-header-subject
11670 (gnus-data-header (car data))))
11671 (gnus-simplify-subject-re
11672 (mail-header-subject
11673 (gnus-data-header (car data)))))))
11674 (setq articles (cons (gnus-data-number (car data)) articles)))
11675 (if (and (setq data (cdr data))
11676 (> (gnus-data-level (car data)) top-level))
11679 ;; Return the list of articles.
11680 (nreverse articles))))
11682 (defun gnus-summary-rethread-current ()
11683 "Rethread the thread the current article is part of."
11685 (gnus-set-global-variables)
11686 (let* ((gnus-show-threads t)
11687 (article (gnus-summary-article-number))
11688 (id (mail-header-id (gnus-summary-article-header)))
11689 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11691 (error "No article on the current line"))
11692 (gnus-rebuild-thread id)
11693 (gnus-summary-goto-subject article)))
11695 (defun gnus-summary-toggle-threads (&optional arg)
11696 "Toggle showing conversation threads.
11697 If ARG is positive number, turn showing conversation threads on."
11699 (gnus-set-global-variables)
11700 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11701 (setq gnus-show-threads
11702 (if (null arg) (not gnus-show-threads)
11703 (> (prefix-numeric-value arg) 0)))
11704 (gnus-summary-prepare)
11705 (gnus-summary-goto-subject current)
11706 (gnus-summary-position-point)))
11708 (defun gnus-summary-show-all-threads ()
11709 "Show all threads."
11711 (gnus-set-global-variables)
11713 (let ((buffer-read-only nil))
11714 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
11715 (gnus-summary-position-point))
11717 (defun gnus-summary-show-thread ()
11718 "Show thread subtrees.
11719 Returns nil if no thread was there to be shown."
11721 (gnus-set-global-variables)
11722 (let ((buffer-read-only nil)
11724 ;; first goto end then to beg, to have point at beg after let
11725 (end (progn (end-of-line) (point)))
11726 (beg (progn (beginning-of-line) (point))))
11728 ;; Any hidden lines here?
11729 (search-forward "\r" end t)
11730 (subst-char-in-region beg end ?\^M ?\n t)
11732 (gnus-summary-position-point))))
11734 (defun gnus-summary-hide-all-threads ()
11735 "Hide all thread subtrees."
11737 (gnus-set-global-variables)
11739 (goto-char (point-min))
11740 (gnus-summary-hide-thread)
11741 (while (zerop (gnus-summary-next-thread 1 t))
11742 (gnus-summary-hide-thread)))
11743 (gnus-summary-position-point))
11745 (defun gnus-summary-hide-thread ()
11746 "Hide thread subtrees.
11747 Returns nil if no threads were there to be hidden."
11749 (gnus-set-global-variables)
11750 (let ((buffer-read-only nil)
11752 (article (gnus-summary-article-number))
11754 ;; Go forward until either the buffer ends or the subthread
11756 (when (and (not (eobp))
11757 (or (and (zerop (gnus-summary-next-thread 1 t))
11758 (gnus-summary-find-prev))
11759 (goto-char (gnus-data-pos (car (gnus-data-list 'rev))))))
11762 (if (and (> (point) start)
11763 (search-backward "\n" start t))
11765 (subst-char-in-region start end ?\n ?\^M)
11766 (gnus-summary-goto-subject article))
11769 (gnus-summary-position-point)))))
11771 (defun gnus-summary-go-to-next-thread (&optional previous)
11772 "Go to the same level (or less) next thread.
11773 If PREVIOUS is non-nil, go to previous thread instead.
11774 Return the article number moved to, or nil if moving was impossible."
11775 (let* ((level (gnus-summary-thread-level))
11776 (article (gnus-summary-article-number))
11777 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
11780 (if (<= (gnus-data-level (car data)) level)
11781 (setq oart (gnus-data-number (car data))
11783 (setq data (cdr data))))
11785 (gnus-summary-goto-subject oart))))
11787 (defun gnus-summary-next-thread (n &optional silent)
11788 "Go to the same level next N'th thread.
11789 If N is negative, search backward instead.
11790 Returns the difference between N and the number of skips actually
11793 If SILENT, don't output messages."
11795 (gnus-set-global-variables)
11796 (let ((backward (< n 0))
11798 (while (and (> n 0)
11799 (gnus-summary-go-to-next-thread backward))
11801 (gnus-summary-position-point)
11802 (when (and (not silent) (/= 0 n))
11803 (gnus-message 7 "No more threads"))
11806 (defun gnus-summary-prev-thread (n)
11807 "Go to the same level previous N'th thread.
11808 Returns the difference between N and the number of skips actually
11811 (gnus-set-global-variables)
11812 (gnus-summary-next-thread (- n)))
11814 (defun gnus-summary-go-down-thread ()
11815 "Go down one level in the current thread."
11816 (let ((children (gnus-summary-article-children)))
11818 (gnus-summary-goto-subject (car children)))))
11820 (defun gnus-summary-go-up-thread ()
11821 "Go up one level in the current thread."
11822 (let ((parent (gnus-summary-article-parent)))
11824 (gnus-summary-goto-subject parent))))
11826 (defun gnus-summary-down-thread (n)
11827 "Go down thread N steps.
11828 If N is negative, go up instead.
11829 Returns the difference between N and how many steps down that were
11832 (gnus-set-global-variables)
11835 (while (and (> n 0)
11836 (if up (gnus-summary-go-up-thread)
11837 (gnus-summary-go-down-thread)))
11839 (gnus-summary-position-point)
11840 (if (/= 0 n) (gnus-message 7 "Can't go further"))
11843 (defun gnus-summary-up-thread (n)
11844 "Go up thread N steps.
11845 If N is negative, go up instead.
11846 Returns the difference between N and how many steps down that were
11849 (gnus-set-global-variables)
11850 (gnus-summary-down-thread (- n)))
11852 (defun gnus-summary-kill-thread (&optional unmark)
11853 "Mark articles under current thread as read.
11854 If the prefix argument is positive, remove any kinds of marks.
11855 If the prefix argument is negative, tick articles instead."
11857 (gnus-set-global-variables)
11859 (setq unmark (prefix-numeric-value unmark)))
11860 (let ((articles (gnus-summary-articles-in-thread)))
11862 ;; Expand the thread.
11863 (gnus-summary-show-thread)
11864 ;; Mark all the articles.
11866 (gnus-summary-goto-subject (car articles))
11867 (cond ((null unmark)
11868 (gnus-summary-mark-article-as-read gnus-killed-mark))
11870 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11872 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11873 (setq articles (cdr articles))))
11874 ;; Hide killed subtrees.
11876 gnus-thread-hide-killed
11877 (gnus-summary-hide-thread))
11878 ;; If marked as read, go to next unread subject.
11880 ;; Go to next unread subject.
11881 (gnus-summary-next-subject 1 t)))
11882 (gnus-set-mode-line 'summary))
11884 ;; Summary sorting commands
11886 (defun gnus-summary-sort-by-number (&optional reverse)
11887 "Sort summary buffer by article number.
11888 Argument REVERSE means reverse order."
11890 (gnus-summary-sort 'number reverse))
11892 (defun gnus-summary-sort-by-author (&optional reverse)
11893 "Sort summary buffer by author name alphabetically.
11894 If case-fold-search is non-nil, case of letters is ignored.
11895 Argument REVERSE means reverse order."
11897 (gnus-summary-sort 'author reverse))
11899 (defun gnus-summary-sort-by-subject (&optional reverse)
11900 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
11901 If case-fold-search is non-nil, case of letters is ignored.
11902 Argument REVERSE means reverse order."
11904 (gnus-summary-sort 'subject reverse))
11906 (defun gnus-summary-sort-by-date (&optional reverse)
11907 "Sort summary buffer by date.
11908 Argument REVERSE means reverse order."
11910 (gnus-summary-sort 'date reverse))
11912 (defun gnus-summary-sort-by-score (&optional reverse)
11913 "Sort summary buffer by score.
11914 Argument REVERSE means reverse order."
11916 (gnus-summary-sort 'score reverse))
11918 (defun gnus-summary-sort (predicate reverse)
11919 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11920 (gnus-set-global-variables)
11921 (let* ((gnus-thread-sort-functions
11922 (list (intern (format "gnus-thread-sort-by-%s" predicate))))
11923 (gnus-article-sort-functions
11924 (list (intern (format "gnus-article-sort-by-%s" predicate))))
11926 (gnus-summary-prepare-hook nil))
11927 ;; We do the sorting by regenerating the threads.
11928 (gnus-summary-prepare)
11929 ;; Hide subthreads if needed.
11930 (when (and gnus-show-threads gnus-thread-hide-subtree)
11931 (gnus-summary-hide-all-threads)))
11932 ;; If in async mode, we send some info to the backend.
11933 (when gnus-newsgroup-async
11934 (gnus-request-asynchronous
11935 gnus-newsgroup-name gnus-newsgroup-data)))
11937 (defun gnus-sortable-date (date)
11938 "Make sortable string by string-lessp from DATE.
11939 Timezone package is used."
11940 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
11941 (year (aref date 0))
11942 (month (aref date 1))
11943 (day (aref date 2)))
11944 (timezone-make-sortable-date
11946 (timezone-make-time-string
11947 (aref date 3) (aref date 4) (aref date 5)))))
11950 ;; Summary saving commands.
11952 (defun gnus-summary-save-article (&optional n not-saved)
11953 "Save the current article using the default saver function.
11954 If N is a positive number, save the N next articles.
11955 If N is a negative number, save the N previous articles.
11956 If N is nil and any articles have been marked with the process mark,
11957 save those articles instead.
11958 The variable `gnus-default-article-saver' specifies the saver function."
11960 (gnus-set-global-variables)
11961 (let ((articles (gnus-summary-work-articles n))
11962 file header article)
11964 (setq header (gnus-summary-article-header
11965 (setq article (pop articles))))
11966 (if (not (vectorp header))
11967 ;; This is a pseudo-article.
11968 (if (assq 'name header)
11969 (gnus-copy-file (cdr (assq 'name header)))
11970 (gnus-message 1 "Article %d is unsaveable" article))
11971 ;; This is a real article.
11972 (save-window-excursion
11973 (gnus-summary-select-article t nil nil article))
11974 (unless gnus-save-all-headers
11975 ;; Remove headers accoring to `gnus-saved-headers'.
11976 (let ((gnus-visible-headers
11977 (or gnus-saved-headers gnus-visible-headers)))
11978 (gnus-article-hide-headers nil t)))
11979 ;; Remove any X-Gnus lines.
11981 (set-buffer gnus-article-buffer)
11983 (let ((buffer-read-only nil))
11984 (gnus-narrow-to-headers)
11985 (while (re-search-forward "^X-Gnus" nil t)
11986 (gnus-delete-line)))))
11987 (save-window-excursion
11988 (if (not gnus-default-article-saver)
11989 (error "No default saver is defined.")
11990 (setq file (funcall
11991 gnus-default-article-saver
11993 ((not gnus-prompt-before-saving)
11995 ((eq gnus-prompt-before-saving 'always)
11998 (gnus-summary-remove-process-mark article)
12000 (gnus-summary-set-saved-mark article))))
12001 (gnus-summary-position-point)
12004 (defun gnus-summary-pipe-output (&optional arg)
12005 "Pipe the current article to a subprocess.
12006 If N is a positive number, pipe the N next articles.
12007 If N is a negative number, pipe the N previous articles.
12008 If N is nil and any articles have been marked with the process mark,
12009 pipe those articles instead."
12011 (gnus-set-global-variables)
12012 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12013 (gnus-summary-save-article arg t))
12014 (gnus-configure-windows 'pipe))
12016 (defun gnus-summary-save-article-mail (&optional arg)
12017 "Append the current article to an mail file.
12018 If N is a positive number, save the N next articles.
12019 If N is a negative number, save the N previous articles.
12020 If N is nil and any articles have been marked with the process mark,
12021 save those articles instead."
12023 (gnus-set-global-variables)
12024 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12025 (gnus-summary-save-article arg)))
12027 (defun gnus-summary-save-article-rmail (&optional arg)
12028 "Append the current article to an rmail file.
12029 If N is a positive number, save the N next articles.
12030 If N is a negative number, save the N previous articles.
12031 If N is nil and any articles have been marked with the process mark,
12032 save those articles instead."
12034 (gnus-set-global-variables)
12035 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12036 (gnus-summary-save-article arg)))
12038 (defun gnus-summary-save-article-file (&optional arg)
12039 "Append the current article to a file.
12040 If N is a positive number, save the N next articles.
12041 If N is a negative number, save the N previous articles.
12042 If N is nil and any articles have been marked with the process mark,
12043 save those articles instead."
12045 (gnus-set-global-variables)
12046 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12047 (gnus-summary-save-article arg)))
12049 (defun gnus-summary-save-article-body-file (&optional arg)
12050 "Append the current article body to a file.
12051 If N is a positive number, save the N next articles.
12052 If N is a negative number, save the N previous articles.
12053 If N is nil and any articles have been marked with the process mark,
12054 save those articles instead."
12056 (gnus-set-global-variables)
12057 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12058 (gnus-summary-save-article arg)))
12060 (defun gnus-get-split-value (methods)
12061 "Return a value based on the split METHODS."
12062 (let (split-name method result match)
12065 (set-buffer gnus-original-article-buffer)
12067 (gnus-narrow-to-headers)
12069 (goto-char (point-min))
12070 (setq method (pop methods))
12071 (setq match (pop method))
12074 ;; Regular expression.
12076 (re-search-forward match nil t)
12078 ((gnus-functionp match)
12081 (setq result (funcall match gnus-newsgroup-name))))
12085 (setq result (eval match)))))
12086 (setq split-name (append (cdr methods) split-name))
12087 (cond ((stringp result)
12088 (push result split-name))
12090 (setq split-name (append result split-name)))))))))
12093 (defun gnus-read-move-group-name (prompt default articles prefix)
12094 "Read a group name."
12095 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12097 (format "Where do you want to %s %s? "
12099 (if (> (length articles) 1)
12100 (format "these %d articles" (length articles))
12108 (format "(default %s) " default)
12110 gnus-active-hashtb nil nil prefix))
12111 ((= 1 (length split-name))
12112 (completing-read prom gnus-active-hashtb
12113 nil nil (cons (car split-name) 0)))
12116 prom (mapcar (lambda (el) (list el)) (nreverse split-name)))))))
12119 (if (or (string= to-newsgroup "")
12120 (string= to-newsgroup prefix))
12121 (setq to-newsgroup (or default "")))
12122 (or (gnus-active to-newsgroup)
12123 (gnus-activate-group to-newsgroup)
12124 (error "No such group: %s" to-newsgroup)))
12127 (defun gnus-read-save-file-name (prompt default-name)
12128 (let ((split-name (gnus-get-split-value gnus-split-methods)))
12129 ;; Let the split methods have their say.
12131 ;; No split name was found.
12134 (concat prompt " (default " (file-name-nondirectory default-name) ") ")
12135 (file-name-directory default-name)
12137 ;; A single split name was found
12138 ((= 1 (length split-name))
12140 (concat prompt " (default " (car split-name) ") ")
12141 gnus-article-save-directory
12142 (concat gnus-article-save-directory (car split-name))))
12143 ;; A list of splits was found.
12145 (setq split-name (mapcar (lambda (el) (list el)) (nreverse split-name)))
12146 (let ((result (completing-read (concat prompt " ") split-name nil nil)))
12147 (concat gnus-article-save-directory
12148 (if (string= result "")
12149 (car (car split-name))
12152 (defun gnus-article-archive-name (group)
12153 "Return the first instance of an \"Archive-name\" in the current buffer."
12154 (let ((case-fold-search t))
12155 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
12156 (match-string 1))))
12158 (defun gnus-summary-save-in-rmail (&optional filename)
12159 "Append this article to Rmail file.
12160 Optional argument FILENAME specifies file name.
12161 Directory to save to is default to `gnus-article-save-directory' which
12162 is initialized from the SAVEDIR environment variable."
12164 (gnus-set-global-variables)
12165 (let ((default-name
12166 (funcall gnus-rmail-save-name gnus-newsgroup-name
12167 gnus-current-headers gnus-newsgroup-last-rmail)))
12169 (cond ((eq filename 'default)
12171 (filename filename)
12172 (t (gnus-read-save-file-name
12173 "Save in rmail file:" default-name))))
12174 (gnus-make-directory (file-name-directory filename))
12175 (gnus-eval-in-buffer-window
12176 gnus-original-article-buffer
12180 (gnus-output-to-rmail filename))))
12181 ;; Remember the directory name to save articles
12182 (setq gnus-newsgroup-last-rmail filename)))
12184 (defun gnus-summary-save-in-mail (&optional filename)
12185 "Append this article to Unix mail file.
12186 Optional argument FILENAME specifies file name.
12187 Directory to save to is default to `gnus-article-save-directory' which
12188 is initialized from the SAVEDIR environment variable."
12190 (gnus-set-global-variables)
12191 (let ((default-name
12192 (funcall gnus-mail-save-name gnus-newsgroup-name
12193 gnus-current-headers gnus-newsgroup-last-mail)))
12195 (cond ((eq filename 'default)
12197 (filename filename)
12198 (t (gnus-read-save-file-name
12199 "Save in Unix mail file:" default-name))))
12201 (expand-file-name filename
12203 (file-name-directory default-name))))
12204 (gnus-make-directory (file-name-directory filename))
12205 (gnus-eval-in-buffer-window
12206 gnus-original-article-buffer
12210 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
12211 (gnus-output-to-rmail filename)
12212 (let ((mail-use-rfc822 t))
12213 (rmail-output filename 1 t t))))))
12214 ;; Remember the directory name to save articles.
12215 (setq gnus-newsgroup-last-mail filename)))
12217 (defun gnus-summary-save-in-file (&optional filename)
12218 "Append this article to file.
12219 Optional argument FILENAME specifies file name.
12220 Directory to save to is default to `gnus-article-save-directory' which
12221 is initialized from the SAVEDIR environment variable."
12223 (gnus-set-global-variables)
12224 (let ((default-name
12225 (funcall gnus-file-save-name gnus-newsgroup-name
12226 gnus-current-headers gnus-newsgroup-last-file)))
12228 (cond ((eq filename 'default)
12230 (filename filename)
12231 (t (gnus-read-save-file-name
12232 "Save in file:" default-name))))
12233 (gnus-make-directory (file-name-directory filename))
12234 (gnus-eval-in-buffer-window
12235 gnus-article-buffer
12239 (gnus-output-to-file filename))))
12240 ;; Remember the directory name to save articles.
12241 (setq gnus-newsgroup-last-file filename)))
12243 (defun gnus-summary-save-body-in-file (&optional filename)
12244 "Append this article body to a file.
12245 Optional argument FILENAME specifies file name.
12246 The directory to save in defaults to `gnus-article-save-directory' which
12247 is initialized from the SAVEDIR environment variable."
12249 (gnus-set-global-variables)
12250 (let ((default-name
12251 (funcall gnus-file-save-name gnus-newsgroup-name
12252 gnus-current-headers gnus-newsgroup-last-file)))
12254 (cond ((eq filename 'default)
12256 (filename filename)
12257 (t (gnus-read-save-file-name
12258 "Save body in file:" default-name))))
12259 (gnus-make-directory (file-name-directory filename))
12260 (gnus-eval-in-buffer-window
12261 gnus-article-buffer
12265 (goto-char (point-min))
12266 (and (search-forward "\n\n" nil t)
12267 (narrow-to-region (point) (point-max)))
12268 (gnus-output-to-file filename))))
12269 ;; Remember the directory name to save articles.
12270 (setq gnus-newsgroup-last-file filename)))
12272 (defun gnus-summary-save-in-pipe (&optional command)
12273 "Pipe this article to subprocess."
12275 (gnus-set-global-variables)
12277 (cond ((eq command 'default)
12278 gnus-last-shell-command)
12280 (t (read-string "Shell command on article: "
12281 gnus-last-shell-command))))
12282 (if (string-equal command "")
12283 (setq command gnus-last-shell-command))
12284 (gnus-eval-in-buffer-window
12285 gnus-article-buffer
12288 (shell-command-on-region (point-min) (point-max) command nil)))
12289 (setq gnus-last-shell-command command))
12291 ;; Summary extract commands
12293 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12294 (let ((buffer-read-only nil)
12295 (article (gnus-summary-article-number))
12297 (or (gnus-summary-goto-subject article)
12298 (error (format "No such article: %d" article)))
12299 (gnus-summary-position-point)
12300 ;; If all commands are to be bunched up on one line, we collect
12302 (if gnus-view-pseudos-separately
12304 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12307 (setq action (cdr (assq 'action (car ps))))
12308 (setq files (list (cdr (assq 'name (car ps)))))
12309 (while (and ps (cdr ps)
12310 (string= (or action "1")
12311 (or (cdr (assq 'action (car (cdr ps)))) "2")))
12312 (setq files (cons (cdr (assq 'name (car (cdr ps)))) files))
12313 (setcdr ps (cdr (cdr ps))))
12316 (if (not (string-match "%s" action))
12317 (setq files (cons " " files)))
12318 (setq files (cons " " files))
12319 (and (assq 'execute (car ps))
12320 (setcdr (assq 'execute (car ps))
12321 (funcall (if (string-match "%s" action)
12324 (mapconcat (lambda (f) f) files " ")))))
12325 (setq ps (cdr ps)))))
12326 (if (and gnus-view-pseudos (not not-view))
12328 (and (assq 'execute (car pslist))
12329 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12330 (eq gnus-view-pseudos 'not-confirm)))
12331 (setq pslist (cdr pslist)))
12334 (setq after-article (or (cdr (assq 'article (car pslist)))
12335 (gnus-summary-article-number)))
12336 (gnus-summary-goto-subject after-article)
12339 (insert " " (file-name-nondirectory
12340 (cdr (assq 'name (car pslist))))
12341 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12343 (forward-line -1) ; back to `b'
12344 (put-text-property b e 'gnus-number gnus-reffed-article-number)
12345 (gnus-data-enter after-article
12346 gnus-reffed-article-number
12352 (setq gnus-newsgroup-unreads
12353 (cons gnus-reffed-article-number gnus-newsgroup-unreads))
12354 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12355 (setq pslist (cdr pslist)))))))
12357 (defun gnus-pseudos< (p1 p2)
12358 (let ((c1 (cdr (assq 'action p1)))
12359 (c2 (cdr (assq 'action p2))))
12360 (and c1 c2 (string< c1 c2))))
12362 (defun gnus-request-pseudo-article (props)
12363 (cond ((assq 'execute props)
12364 (gnus-execute-command (cdr (assq 'execute props)))))
12365 (let ((gnus-current-article (gnus-summary-article-number)))
12366 (run-hooks 'gnus-mark-article-hook)))
12368 (defun gnus-execute-command (command &optional automatic)
12370 (gnus-article-setup-buffer)
12371 (set-buffer gnus-article-buffer)
12372 (let ((command (if automatic command (read-string "Command: " command)))
12373 (buffer-read-only nil))
12375 (insert "$ " command "\n\n")
12376 (if gnus-view-pseudo-asynchronously
12377 (start-process "gnus-execute" nil "sh" "-c" command)
12378 (call-process "sh" nil t nil "-c" command)))))
12380 (defun gnus-copy-file (file &optional to)
12383 (list (read-file-name "Copy file: " default-directory)
12384 (read-file-name "Copy file to: " default-directory)))
12385 (gnus-set-global-variables)
12386 (or to (setq to (read-file-name "Copy file to: " default-directory)))
12387 (and (file-directory-p to)
12388 (setq to (concat (file-name-as-directory to)
12389 (file-name-nondirectory file))))
12390 (copy-file file to))
12392 ;; Summary kill commands.
12394 (defun gnus-summary-edit-global-kill (article)
12395 "Edit the \"global\" kill file."
12396 (interactive (list (gnus-summary-article-number)))
12397 (gnus-set-global-variables)
12398 (gnus-group-edit-global-kill article))
12400 (defun gnus-summary-edit-local-kill ()
12401 "Edit a local kill file applied to the current newsgroup."
12403 (gnus-set-global-variables)
12404 (setq gnus-current-headers (gnus-summary-article-header))
12405 (gnus-set-global-variables)
12406 (gnus-group-edit-local-kill
12407 (gnus-summary-article-number) gnus-newsgroup-name))
12411 ;;; Gnus article mode
12414 (put 'gnus-article-mode 'mode-class 'special)
12416 (if gnus-article-mode-map
12418 (setq gnus-article-mode-map (make-keymap))
12419 (suppress-keymap gnus-article-mode-map)
12420 (define-key gnus-article-mode-map " " 'gnus-article-next-page)
12421 (define-key gnus-article-mode-map "\177" 'gnus-article-prev-page)
12422 (define-key gnus-article-mode-map "\C-c^" 'gnus-article-refer-article)
12423 (define-key gnus-article-mode-map "h" 'gnus-article-show-summary)
12424 (define-key gnus-article-mode-map "s" 'gnus-article-show-summary)
12425 (define-key gnus-article-mode-map "\C-c\C-m" 'gnus-article-mail)
12426 (define-key gnus-article-mode-map "?" 'gnus-article-describe-briefly)
12427 (define-key gnus-article-mode-map gnus-mouse-2 'gnus-article-push-button)
12428 (define-key gnus-article-mode-map "\r" 'gnus-article-press-button)
12429 (define-key gnus-article-mode-map "\t" 'gnus-article-next-button)
12430 (define-key gnus-article-mode-map "\M-\t" 'gnus-article-prev-button)
12431 (define-key gnus-article-mode-map "\C-c\C-b" 'gnus-bug)
12433 ;; Duplicate almost all summary keystrokes in the article mode map.
12436 "p" "N" "P" "\M-\C-n" "\M-\C-p"
12437 "\M-n" "\M-p" "." "," "\M-s" "\M-r" "<" ">" "j"
12438 "u" "!" "U" "d" "D" "E" "\M-u" "\M-U" "k" "\C-k" "\M-\C-k"
12439 "\M-\C-l" "e" "#" "\M-#" "\M-\C-t" "\M-\C-s" "\M-\C-h"
12440 "\M-\C-f" "\M-\C-b" "\M-\C-u" "\M-\C-d" "&" "\C-w"
12441 "\C-t" "?" "\C-c\M-\C-s" "\C-c\C-s\C-n" "\C-c\C-s\C-a"
12442 "\C-c\C-s\C-s" "\C-c\C-s\C-d" "\C-c\C-s\C-i" "\C-x\C-s"
12443 "\M-g" "w" "\C-c\C-r" "\M-t" "C"
12444 "o" "\C-o" "|" "\M-k" "\M-K" "V" "\C-c\C-d"
12445 "\C-c\C-i" "x" "X" "t" "g" "?" "l"
12446 "\C-c\C-v\C-v" "\C-d" "v"
12447 ;; "Mt" "M!" "Md" "Mr"
12448 ;; "Mc" "M " "Me" "Mx" "M?" "Mb" "MB" "M#" "M\M-#" "M\M-r"
12449 ;; "M\M-\C-r" "MD" "M\M-D" "MS" "MC" "MH" "M\C-c" "Mk" "MK"
12450 ;; "Ms" "Mc" "Mu" "Mm" "Mk" "Gn" "Gp" "GN" "GP" "G\C-n" "G\C-p"
12451 ;; "G\M-n" "G\M-p" "Gf" "Gb" "Gg" "Gl" "Gp" "Tk" "Tl" "Ti" "TT"
12452 ;; "Ts" "TS" "Th" "TH" "Tn" "Tp" "Tu" "Td" "T#" "A " "An" "A\177" "Ap"
12453 ;; "A\r" "A<" "A>" "Ab" "Ae" "A^" "Ar" "Aw" "Ac" "Ag" "At" "Am"
12454 ;; "As" "Wh" "Ws" "Wc" "Wo" "Ww" "Wd" "Wq" "Wf" "Wt" "W\C-t"
12455 ;; "WT" "WA" "Wa" "WH" "WC" "WS" "Wb" "Hv" "Hf" "Hd" "Hh" "Hi"
12456 ;; "Be" "B\177" "Bm" "Br" "Bw" "Bc" "Bq" "Bi" "Oo" "Om" "Or"
12457 ;; "Of" "Oh" "Ov" "Op" "Vu" "V\C-s" "V\C-r" "Vr" "V&" "VT" "Ve"
12458 ;; "VD" "Vk" "VK" "Vsn" "Vsa" "Vss" "Vsd" "Vsi"
12461 (define-key gnus-article-mode-map (car commands)
12462 'gnus-article-summary-command)
12463 (setq commands (cdr commands))))
12465 (let ((commands (list "q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
12466 ;; "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
12467 "=" "n" "^" "\M-^")))
12469 (define-key gnus-article-mode-map (car commands)
12470 'gnus-article-summary-command-nosave)
12471 (setq commands (cdr commands)))))
12474 (defun gnus-article-mode ()
12475 "Major mode for displaying an article.
12477 All normal editing commands are switched off.
12479 The following commands are available:
12481 \\<gnus-article-mode-map>
12482 \\[gnus-article-next-page]\t Scroll the article one page forwards
12483 \\[gnus-article-prev-page]\t Scroll the article one page backwards
12484 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
12485 \\[gnus-article-show-summary]\t Display the summary buffer
12486 \\[gnus-article-mail]\t Send a reply to the address near point
12487 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
12488 \\[gnus-info-find-node]\t Go to the Gnus info node"
12490 (when (and menu-bar-mode
12491 (gnus-visual-p 'article-menu 'menu))
12492 (gnus-article-make-menu-bar))
12493 (kill-all-local-variables)
12494 (gnus-simplify-mode-line)
12495 (setq mode-name "Article")
12496 (setq major-mode 'gnus-article-mode)
12497 (make-local-variable 'minor-mode-alist)
12498 (or (assq 'gnus-show-mime minor-mode-alist)
12499 (setq minor-mode-alist
12500 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
12501 (use-local-map gnus-article-mode-map)
12502 (make-local-variable 'page-delimiter)
12503 (setq page-delimiter gnus-page-delimiter)
12504 (buffer-disable-undo (current-buffer))
12505 (setq buffer-read-only t) ;Disable modification
12506 (run-hooks 'gnus-article-mode-hook))
12508 (defun gnus-article-setup-buffer ()
12509 "Initialize the article buffer."
12510 ;; Returns the article buffer.
12511 (let ((name (if gnus-single-article-buffer "*Article*"
12512 (concat "*Article " gnus-newsgroup-name "*"))))
12513 (setq gnus-article-buffer name)
12514 ;; This might be a variable local to the summary buffer.
12515 (unless gnus-single-article-buffer
12517 (set-buffer gnus-summary-buffer)
12518 (setq gnus-article-buffer name))
12519 (make-local-variable 'gnus-summary-buffer))
12520 (if (get-buffer name)
12523 (buffer-disable-undo (current-buffer))
12524 (setq buffer-read-only t)
12525 (gnus-add-current-to-buffer-list)
12526 (or (eq major-mode 'gnus-article-mode)
12527 (gnus-article-mode))
12530 (set-buffer (get-buffer-create name))
12531 (gnus-add-current-to-buffer-list)
12532 (gnus-article-mode)
12533 (current-buffer)))))
12535 ;; Set article window start at LINE, where LINE is the number of lines
12536 ;; from the head of the article.
12537 (defun gnus-article-set-window-start (&optional line)
12539 (get-buffer-window gnus-article-buffer)
12541 (set-buffer gnus-article-buffer)
12542 (goto-char (point-min))
12545 (gnus-message 6 "Moved to bookmark")
12546 (search-forward "\n\n" nil t)
12547 (forward-line line)
12550 (defun gnus-kill-all-overlays ()
12551 "Delete all overlays in the current buffer."
12552 (when (fboundp 'overlay-lists)
12553 (let* ((overlayss (overlay-lists))
12554 (buffer-read-only nil)
12555 (overlays (nconc (car overlayss) (cdr overlayss))))
12557 (delete-overlay (pop overlays))))))
12559 (defun gnus-request-article-this-buffer (article group)
12560 "Get an article and insert it into this buffer."
12563 (if (get-buffer gnus-original-article-buffer)
12564 (set-buffer (get-buffer gnus-original-article-buffer))
12565 (set-buffer (get-buffer-create gnus-original-article-buffer))
12566 (buffer-disable-undo (current-buffer))
12567 (setq major-mode 'gnus-original-article-mode)
12568 (setq buffer-read-only t)
12569 (gnus-add-current-to-buffer-list))
12571 (setq group (or group gnus-newsgroup-name))
12573 ;; Open server if it has closed.
12574 (gnus-check-server (gnus-find-method-for-group group))
12576 ;; Using `gnus-request-article' directly will insert the article into
12577 ;; `nntp-server-buffer' - so we'll save some time by not having to
12578 ;; copy it from the server buffer into the article buffer.
12580 ;; We only request an article by message-id when we do not have the
12581 ;; headers for it, so we'll have to get those.
12582 (and (stringp article)
12583 (let ((gnus-override-method gnus-refer-article-method))
12584 (gnus-read-header article)))
12586 ;; If the article number is negative, that means that this article
12587 ;; doesn't belong in this newsgroup (possibly), so we find its
12588 ;; message-id and request it by id instead of number.
12589 (if (not (numberp article))
12592 (set-buffer gnus-summary-buffer)
12593 (let ((header (gnus-summary-article-header article)))
12595 (if (vectorp header)
12596 ;; It's a real article.
12597 (setq article (mail-header-id header))
12598 ;; It is an extracted pseudo-article.
12599 (setq article 'pseudo)
12600 (gnus-request-pseudo-article header)))
12602 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12603 (if (not (eq (car method) 'nneething))
12605 (let ((dir (concat (file-name-as-directory (nth 1 method))
12606 (mail-header-subject header))))
12607 (if (file-directory-p dir)
12609 (setq article 'nneething)
12610 (gnus-group-enter-directory dir)))))))))
12613 ;; We first check `gnus-original-article-buffer'.
12614 ((and (equal (car gnus-original-article) group)
12615 (eq (cdr gnus-original-article) article))
12616 ;; We don't have to do anything, since it's already where we
12619 ;; Check the backlog.
12620 ((and gnus-keep-backlog
12621 (gnus-backlog-request-article group article (current-buffer)))
12623 ;; Check the cache.
12624 ((and gnus-use-cache
12626 (gnus-cache-request-article article group))
12628 ;; Get the article and put into the article buffer.
12629 ((or (stringp article) (numberp article))
12630 (let ((gnus-override-method
12631 (and (stringp article) gnus-refer-article-method))
12632 (buffer-read-only nil))
12634 (gnus-kill-all-overlays)
12635 (if (gnus-request-article article group (current-buffer))
12637 (and gnus-keep-backlog
12638 (gnus-backlog-enter-article
12639 group article (current-buffer)))
12641 ;; It was a pseudo.
12643 (setq gnus-original-article (cons group article))
12644 (let (buffer-read-only)
12646 (gnus-kill-all-overlays)
12647 (insert-buffer-substring gnus-original-article-buffer))))
12649 (defun gnus-read-header (id)
12650 "Read the headers of article ID and enter them into the Gnus system."
12651 (let ((group gnus-newsgroup-name)
12652 (headers gnus-newsgroup-headers)
12654 ;; First we check to see whether the header in question is already
12657 ;; This is a Message-ID.
12659 (if (string= id (mail-header-id (car headers)))
12660 (setq header (car headers)
12662 (setq headers (cdr headers))))
12663 ;; This is an article number.
12665 (if (= id (mail-header-number (car headers)))
12666 (setq header (car headers)
12668 (setq headers (cdr headers)))))
12670 ;; We have found the header.
12672 ;; We have to really fetch the header to this article.
12674 (if (gnus-check-backend-function 'request-head group)
12675 (gnus-request-head id group)
12676 (gnus-request-article id group)))
12678 (set-buffer nntp-server-buffer)
12679 (and (search-forward "\n\n" nil t)
12680 (delete-region (1- (point)) (point-max)))
12681 (goto-char (point-max))
12683 (goto-char (point-min))
12692 gnus-reffed-article-number)))
12693 " Article retrieved.\n"))
12694 (if (not (setq header (car (gnus-get-newsgroup-headers))))
12695 () ; Malformed head.
12696 (if (and (stringp id)
12697 (not (string= (gnus-group-real-name group)
12699 ;; If we fetched by Message-ID and the article came
12700 ;; from a different group, we fudge some bogus article
12701 ;; numbers for this article.
12702 (mail-header-set-number header gnus-reffed-article-number))
12703 (decf gnus-reffed-article-number)
12704 (push header gnus-newsgroup-headers)
12705 (setq gnus-current-headers header)
12706 (push (mail-header-number header) gnus-newsgroup-limit)
12709 (defun gnus-article-prepare (article &optional all-headers header)
12710 "Prepare ARTICLE in article mode buffer.
12711 ARTICLE should either be an article number or a Message-ID.
12712 If ARTICLE is an id, HEADER should be the article headers.
12713 If ALL-HEADERS is non-nil, no headers are hidden."
12715 ;; Make sure we start in a summary buffer.
12716 (unless (eq major-mode 'gnus-summary-mode)
12717 (set-buffer gnus-summary-buffer))
12718 (setq gnus-summary-buffer (current-buffer))
12719 ;; Make sure the connection to the server is alive.
12720 (unless (gnus-server-opened
12721 (gnus-find-method-for-group gnus-newsgroup-name))
12722 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
12723 (gnus-request-group gnus-newsgroup-name t))
12724 (let* ((article (if header (mail-header-number header) article))
12725 (summary-buffer (current-buffer))
12726 (internal-hook gnus-article-internal-prepare-hook)
12727 (group gnus-newsgroup-name)
12730 (gnus-article-setup-buffer)
12731 (set-buffer gnus-article-buffer)
12732 ;; Deactivate active regions.
12733 (when (and (boundp 'transient-mark-mode)
12734 transient-mark-mode)
12735 (setq mark-active nil))
12736 (if (not (setq result (let ((buffer-read-only nil))
12737 (gnus-request-article-this-buffer
12739 ;; There is no such article.
12741 (if (not (numberp article))
12743 (setq gnus-article-current
12744 (cons gnus-newsgroup-name article))
12745 (set-buffer gnus-summary-buffer)
12746 (setq gnus-current-article article)
12747 (gnus-summary-mark-article article gnus-canceled-mark))
12749 1 "No such article (may have expired or been canceled)")
12752 (if (or (eq result 'pseudo) (eq result 'nneething))
12755 (set-buffer summary-buffer)
12756 (setq gnus-last-article gnus-current-article
12757 gnus-newsgroup-history (cons gnus-current-article
12758 gnus-newsgroup-history)
12759 gnus-current-article 0
12760 gnus-current-headers nil
12761 gnus-article-current nil)
12762 (if (eq result 'nneething)
12763 (gnus-configure-windows 'summary)
12764 (gnus-configure-windows 'article))
12765 (gnus-set-global-variables))
12766 (gnus-set-mode-line 'article))
12767 ;; The result from the `request' was an actual article -
12768 ;; or at least some text that is now displayed in the
12770 (if (and (numberp article)
12771 (not (eq article gnus-current-article)))
12772 ;; Seems like a new article has been selected.
12773 ;; `gnus-current-article' must be an article number.
12775 (set-buffer summary-buffer)
12776 (setq gnus-last-article gnus-current-article
12777 gnus-newsgroup-history (cons gnus-current-article
12778 gnus-newsgroup-history)
12779 gnus-current-article article
12780 gnus-current-headers
12781 (gnus-summary-article-header gnus-current-article)
12782 gnus-article-current
12783 (cons gnus-newsgroup-name gnus-current-article))
12784 (unless (vectorp gnus-current-headers)
12785 (setq gnus-current-headers nil))
12786 (gnus-summary-show-thread)
12787 (run-hooks 'gnus-mark-article-hook)
12788 (gnus-set-mode-line 'summary)
12789 (and (gnus-visual-p 'article-highlight 'highlight)
12790 (run-hooks 'gnus-visual-mark-article-hook))
12791 ;; Set the global newsgroup variables here.
12792 ;; Suggested by Jim Sisolak
12793 ;; <sisolak@trans4.neep.wisc.edu>.
12794 (gnus-set-global-variables)
12795 (setq gnus-have-all-headers
12796 (or all-headers gnus-show-all-headers))
12797 (and gnus-use-cache
12798 (vectorp (gnus-summary-article-header article))
12799 (gnus-cache-possibly-enter-article
12801 (gnus-summary-article-header article)
12802 (memq article gnus-newsgroup-marked)
12803 (memq article gnus-newsgroup-dormant)
12804 (memq article gnus-newsgroup-unreads)))))
12805 ;; Hooks for getting information from the article.
12806 ;; This hook must be called before being narrowed.
12807 (let (buffer-read-only)
12808 (run-hooks 'internal-hook)
12809 (run-hooks 'gnus-article-prepare-hook)
12810 ;; Decode MIME message.
12812 (if (or (not gnus-strict-mime)
12813 (gnus-fetch-field "Mime-Version"))
12814 (funcall gnus-show-mime-method)
12815 (funcall gnus-decode-encoded-word-method)))
12816 ;; Perform the article display hooks.
12817 (run-hooks 'gnus-article-display-hook))
12819 (goto-char (point-min))
12820 (and gnus-break-pages (gnus-narrow-to-page))
12821 (gnus-set-mode-line 'article)
12822 (gnus-configure-windows 'article)
12823 (goto-char (point-min))
12826 (defun gnus-article-show-all-headers ()
12827 "Show all article headers in article mode buffer."
12829 (gnus-article-setup-buffer)
12830 (set-buffer gnus-article-buffer)
12831 (let ((buffer-read-only nil))
12832 (remove-text-properties (point-min) (point-max)
12833 gnus-hidden-properties))))
12835 (defun gnus-article-hide-headers-if-wanted ()
12836 "Hide unwanted headers if `gnus-have-all-headers' is nil.
12837 Provided for backwards compatability."
12838 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
12839 gnus-inhibit-hiding
12840 (gnus-article-hide-headers)))
12842 (defun gnus-article-hide-headers (&optional show delete)
12843 "Hide unwanted headers and possibly sort them as well."
12845 ;; This function might be inhibited.
12847 (gnus-article-show-hidden-text 'headers)
12848 (unless gnus-inhibit-hiding
12850 (set-buffer gnus-article-buffer)
12852 (let ((buffer-read-only nil)
12853 (ignored (when (not (stringp gnus-visible-headers))
12854 (cond ((stringp gnus-ignored-headers)
12855 gnus-ignored-headers)
12856 ((listp gnus-ignored-headers)
12857 (mapconcat 'identity gnus-ignored-headers
12859 (visible (cond ((stringp gnus-visible-headers)
12860 gnus-visible-headers)
12861 ((listp gnus-visible-headers)
12862 (mapconcat 'identity gnus-visible-headers
12864 want-list beg want-l)
12865 ;; First we narrow to just the headers.
12867 (goto-char (point-min))
12868 ;; Hide any "From " lines at the beginning of (mail) articles.
12869 (while (looking-at "From ")
12872 (add-text-properties
12873 (point-min) (point)
12874 (nconc (list 'gnus-type 'headers) gnus-hidden-properties)))
12875 ;; Then treat the rest of the header lines.
12878 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
12879 ;; Then we use the two regular expressions
12880 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
12881 ;; select which header lines is to remain visible in the
12883 (goto-char (point-min))
12884 (while (re-search-forward "^[^ \t]*:" nil t)
12885 (beginning-of-line)
12886 ;; We add the headers we want to keep to a list and delete
12887 ;; them from the buffer.
12888 (if (or (and visible (looking-at visible))
12889 (and ignored (not (looking-at ignored))))
12891 (push (buffer-substring
12895 ;; Be sure to get multi-line headers...
12896 (re-search-forward "^[^ \t]*:" nil t)
12897 (beginning-of-line)
12900 (delete-region beg (point)))
12902 ;; Sort the headers that we want to display.
12903 (setq want-list (sort want-list 'gnus-article-header-less))
12904 (goto-char (point-min))
12906 (insert (pop want-list)))
12907 ;; We make the unwanted headers invisible.
12909 (delete-region (point-min) (point-max))
12910 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
12911 (add-text-properties
12912 (point) (point-max)
12913 (nconc (list 'gnus-type 'headers)
12914 gnus-hidden-properties)))))))))
12916 (defsubst gnus-article-header-rank (header)
12917 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
12918 (let ((list gnus-sorted-header-list)
12921 (when (string-match (car list) header)
12923 (setq list (cdr list))
12927 (defun gnus-article-header-less (h1 h2)
12928 "Say whether string H1 is \"less\" than string H2."
12929 (< (gnus-article-header-rank h1)
12930 (gnus-article-header-rank h2)))
12932 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
12933 (defun gnus-article-treat-overstrike ()
12934 "Translate overstrikes into bold text."
12937 (set-buffer gnus-article-buffer)
12938 (let ((buffer-read-only nil))
12939 (while (search-forward "\b" nil t)
12940 (let ((next (following-char))
12941 (previous (char-after (- (point) 2))))
12942 (cond ((eq next previous)
12943 (put-text-property (- (point) 2) (point) 'invisible t)
12944 (put-text-property (point) (1+ (point)) 'face 'bold))
12946 (put-text-property (1- (point)) (1+ (point)) 'invisible t)
12948 (- (point) 2) (1- (point)) 'face 'underline))
12950 (put-text-property (- (point) 2) (point) 'invisible t)
12952 (point) (1+ (point)) 'face 'underline))))))))
12954 (defun gnus-article-word-wrap ()
12955 "Format too long lines."
12958 (set-buffer gnus-article-buffer)
12959 (let ((buffer-read-only nil)
12962 (goto-char (point-min))
12963 (search-forward "\n\n" nil t)
12965 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
12966 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
12967 (adaptive-fill-mode t))
12968 (while (not (eobp))
12969 (and (>= (current-column) (min fill-column (window-width)))
12970 (/= (preceding-char) ?:)
12971 (fill-paragraph nil))
12972 (end-of-line 2))))))
12974 (defun gnus-article-remove-cr ()
12975 "Remove carriage returns from an article."
12978 (set-buffer gnus-article-buffer)
12979 (let ((buffer-read-only nil))
12980 (goto-char (point-min))
12981 (while (search-forward "\r" nil t)
12982 (replace-match "" t t)))))
12984 (defun gnus-article-display-x-face (&optional force)
12985 "Look for an X-Face header and display it if present."
12986 (interactive (list 'force))
12988 (set-buffer gnus-article-buffer)
12989 ;; Delete the old process, if any.
12990 (when (process-status "gnus-x-face")
12991 (delete-process "gnus-x-face"))
12992 (let ((inhibit-point-motion-hooks t)
12993 (case-fold-search nil)
12996 (gnus-narrow-to-headers)
12997 (setq from (mail-fetch-field "from"))
12998 (goto-char (point-min))
12999 (when (and gnus-article-x-face-command
13001 ;; Check whether this face is censored.
13002 (not gnus-article-x-face-too-ugly)
13003 (and gnus-article-x-face-too-ugly from
13004 (not (string-match gnus-article-x-face-too-ugly
13006 ;; Has to be present.
13007 (re-search-forward "^X-Face: " nil t))
13008 ;; We now have the area of the buffer where the X-Face is stored.
13009 (let ((beg (point))
13010 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
13011 ;; We display the face.
13012 (if (symbolp gnus-article-x-face-command)
13013 ;; The command is a lisp function, so we call it.
13014 (if (gnus-functionp gnus-article-x-face-command)
13015 (funcall gnus-article-x-face-command beg end)
13016 (error "%s is not a function" gnus-article-x-face-command))
13017 ;; The command is a string, so we interpret the command
13018 ;; as a, well, command, and fork it off.
13019 (let ((process-connection-type nil))
13020 (process-kill-without-query
13022 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
13023 (process-send-region "gnus-x-face" beg end)
13024 (process-send-eof "gnus-x-face")))))))))
13026 (defun gnus-headers-decode-quoted-printable ()
13027 "Hack to remove QP encoding from headers."
13028 (let ((case-fold-search t)
13029 (inhibit-point-motion-hooks t)
13031 (goto-char (point-min))
13032 (while (re-search-forward "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
13033 (setq string (match-string 1))
13034 (narrow-to-region (match-beginning 0) (match-end 0))
13035 (delete-region (point-min) (point-max))
13037 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
13038 (subst-char-in-region (point-min) (point-max) ?_ ? )
13040 (goto-char (point-min)))))
13042 (defun gnus-article-de-quoted-unreadable (&optional force)
13043 "Do a naive translation of a quoted-printable-encoded article.
13044 This is in no way, shape or form meant as a replacement for real MIME
13045 processing, but is simply a stop-gap measure until MIME support is
13047 If FORCE, decode the article whether it is marked as quoted-printable
13049 (interactive (list 'force))
13051 (set-buffer gnus-article-buffer)
13052 (let ((case-fold-search t)
13053 (buffer-read-only nil)
13054 (type (gnus-fetch-field "content-transfer-encoding")))
13056 (and type (string-match "quoted-printable" type)))
13057 (goto-char (point-min))
13058 (search-forward "\n\n" nil 'move)
13059 (gnus-mime-decode-quoted-printable (point) (point-max))
13060 (gnus-headers-decode-quoted-printable)))))
13062 (defun gnus-mime-decode-quoted-printable (from to)
13063 "Decode Quoted-Printable in the region between FROM and TO."
13065 (while (search-forward "=" to t)
13066 (cond ((eq (following-char) ?\n)
13069 ((looking-at "[0-9A-F][0-9A-F]")
13071 (insert (hexl-hex-string-to-integer
13072 (buffer-substring (point) (+ 2 (point)))))
13076 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
13078 (defun gnus-article-hide-pgp (&optional show)
13079 "Hide any PGP headers and signatures in the current article.
13080 If given a prefix, show the hidden PGP gruft instead."
13083 (gnus-article-show-hidden-text 'pgp)
13085 (set-buffer gnus-article-buffer)
13086 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
13087 buffer-read-only beg end)
13089 (goto-char (point-min))
13090 ;; Hide the "header".
13091 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
13092 (add-text-properties (match-beginning 0) (match-end 0) props))
13094 ;; Hide the actual signature.
13095 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
13096 (setq end (match-beginning 0))
13097 (add-text-properties
13098 (match-beginning 0)
13099 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
13101 ;; Perhaps we shouldn't hide to the end of the buffer
13102 ;; if there is no end to the signature?
13105 ;; Hide "- " PGP quotation markers.
13106 (when (and beg end)
13107 (narrow-to-region beg end)
13108 (goto-char (point-min))
13109 (while (re-search-forward "^- " nil t)
13110 (add-text-properties (match-beginning 0) (match-end 0) props))
13113 (defun gnus-article-hide-signature (&optional show)
13114 "Hide the signature in the current article.
13115 If given a prefix, show the signature instead."
13118 (gnus-article-show-hidden-text 'signature)
13120 (set-buffer gnus-article-buffer)
13121 (let ((buffer-read-only nil))
13122 (goto-char (point-max))
13123 (and (re-search-backward gnus-signature-separator nil t)
13124 gnus-signature-face
13125 (add-text-properties
13126 (match-end 0) (point-max)
13127 (nconc (list 'gnus-type 'signature)
13128 gnus-hidden-properties)))))))
13130 (defun gnus-article-hide (&optional show force)
13131 "Hide all the gruft in the current article.
13132 This means that PGP stuff, signatures, cited text and (some)
13133 headers will be hidden.
13134 If given a prefix, show the hidden text instead."
13135 (interactive (list current-prefix-arg 'force))
13136 (gnus-article-hide-headers show)
13137 (gnus-article-hide-pgp show)
13138 (gnus-article-hide-citation-maybe show force)
13139 (gnus-article-hide-signature show))
13141 (defun gnus-article-show-hidden-text (type)
13143 (set-buffer gnus-article-buffer)
13144 (let ((buffer-read-only nil)
13146 (while (gnus-goto-char (text-property-any
13147 beg (point-max) 'gnus-type type))
13148 (remove-text-properties (point) (setq beg (1+ (point)))
13149 gnus-hidden-properties)))))
13151 (defvar gnus-article-time-units
13152 `((year . ,(* 365.25 24 60 60))
13153 (week . ,(* 7 24 60 60))
13154 (day . ,(* 24 60 60))
13155 (hour . ,(* 60 60))
13158 "Mapping from time units to seconds.")
13160 (defun gnus-article-date-ut (&optional type highlight)
13161 "Convert DATE date to universal time in the current article.
13162 If TYPE is `local', convert to local time; if it is `lapsed', output
13163 how much time has lapsed since DATE."
13164 (interactive (list 'ut t))
13165 (let* ((header (or gnus-current-headers
13166 (gnus-summary-article-header) ""))
13167 (date (and (vectorp header) (mail-header-date header)))
13168 (date-regexp "^Date: \\|^X-Sent: ")
13169 (inhibit-point-motion-hooks t))
13170 (when (and date (not (string= date "")))
13172 (set-buffer gnus-article-buffer)
13174 (gnus-narrow-to-headers)
13175 (let ((buffer-read-only nil))
13176 ;; Delete any old Date headers.
13177 (if (zerop (nnheader-remove-header date-regexp t))
13178 (beginning-of-line)
13179 (goto-char (point-max)))
13182 ;; Convert to the local timezone. We have to slap a
13183 ;; `condition-case' round the calls to the timezone
13184 ;; functions since they aren't particularly resistant to
13187 (concat "Date: " (condition-case ()
13188 (timezone-make-date-arpa-standard date)
13191 ;; Convert to Universal Time.
13195 (timezone-make-date-arpa-standard date nil "UT")
13198 ;; Get the original date from the article.
13199 ((eq type 'original)
13200 (concat "Date: " date "\n"))
13201 ;; Do an X-Sent lapsed format.
13203 ;; If the date is seriously mangled, the timezone
13204 ;; functions are liable to bug out, so we condition-case
13205 ;; the entire thing.
13206 (let* ((real-sec (condition-case ()
13207 (- (gnus-seconds-since-epoch
13208 (timezone-make-date-arpa-standard
13209 (current-time-string)
13210 (current-time-zone) "UT"))
13211 (gnus-seconds-since-epoch
13212 (timezone-make-date-arpa-standard
13215 (sec (abs real-sec))
13221 ;; This is a bit convoluted, but basically we go
13222 ;; through the time units for years, weeks, etc,
13223 ;; and divide things to see whether that results
13224 ;; in positive answers.
13227 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
13228 ;; The (remaining) seconds are too few to
13229 ;; be divided into this time unit.
13231 ;; It's big enough, so we output it.
13232 (setq sec (- sec (* num (cdr unit))))
13234 (concat (if prev ", " "") (int-to-string
13236 " " (symbol-name (car unit))
13237 (if (> num 1) "s" ""))
13239 gnus-article-time-units "")
13240 ;; If dates are odd, then it might appear like the
13241 ;; article was sent in the future.
13244 " in the future\n")))))
13246 (error "Unknown conversion type: %s" type)))))
13247 ;; Do highlighting.
13248 (when (and highlight (gnus-visual-p 'article-highlight 'highlight))
13249 (gnus-article-highlight-headers)))))))
13251 (defun gnus-article-date-local (&optional highlight)
13252 "Convert the current article date to the local timezone."
13253 (interactive (list t))
13254 (gnus-article-date-ut 'local highlight))
13256 (defun gnus-article-date-original (&optional highlight)
13257 "Convert the current article date to what it was originally.
13258 This is only useful if you have used some other date conversion
13259 function and want to see what the date was before converting."
13260 (interactive (list t))
13261 (gnus-article-date-ut 'original highlight))
13263 (defun gnus-article-date-lapsed (&optional highlight)
13264 "Convert the current article date to time lapsed since it was sent."
13265 (interactive (list t))
13266 (gnus-article-date-ut 'lapsed highlight))
13268 (defun gnus-article-maybe-highlight ()
13269 "Do some article highlighting if `gnus-visual' is non-nil."
13270 (if (gnus-visual-p 'article-highlight 'highlight)
13271 (gnus-article-highlight-some)))
13275 (defun gnus-output-to-rmail (file-name)
13276 "Append the current article to an Rmail file named FILE-NAME."
13278 ;; Most of these codes are borrowed from rmailout.el.
13279 (setq file-name (expand-file-name file-name))
13280 (setq rmail-default-rmail-file file-name)
13281 (let ((artbuf (current-buffer))
13282 (tmpbuf (get-buffer-create " *Gnus-output*")))
13284 (or (get-file-buffer file-name)
13285 (file-exists-p file-name)
13286 (if (gnus-yes-or-no-p
13287 (concat "\"" file-name "\" does not exist, create it? "))
13288 (let ((file-buffer (create-file-buffer file-name)))
13290 (set-buffer file-buffer)
13291 (rmail-insert-rmail-file-header)
13292 (let ((require-final-newline nil))
13293 (write-region (point-min) (point-max) file-name t 1)))
13294 (kill-buffer file-buffer))
13295 (error "Output file does not exist")))
13296 (set-buffer tmpbuf)
13297 (buffer-disable-undo (current-buffer))
13299 (insert-buffer-substring artbuf)
13300 (gnus-convert-article-to-rmail)
13301 ;; Decide whether to append to a file or to an Emacs buffer.
13302 (let ((outbuf (get-file-buffer file-name)))
13304 (append-to-file (point-min) (point-max) file-name)
13305 ;; File has been visited, in buffer OUTBUF.
13306 (set-buffer outbuf)
13307 (let ((buffer-read-only nil)
13308 (msg (and (boundp 'rmail-current-message)
13309 (symbol-value 'rmail-current-message))))
13310 ;; If MSG is non-nil, buffer is in RMAIL mode.
13313 (narrow-to-region (point-max) (point-max))))
13314 (insert-buffer-substring tmpbuf)
13317 (goto-char (point-min))
13319 (search-backward "\^_")
13320 (narrow-to-region (point) (point-max))
13321 (goto-char (1+ (point-min)))
13322 (rmail-count-new-messages t)
13323 (rmail-show-message msg)))))))
13324 (kill-buffer tmpbuf)))
13326 (defun gnus-output-to-file (file-name)
13327 "Append the current article to a file named FILE-NAME."
13328 (setq file-name (expand-file-name file-name))
13329 (let ((artbuf (current-buffer))
13330 (tmpbuf (get-buffer-create " *Gnus-output*")))
13332 (set-buffer tmpbuf)
13333 (buffer-disable-undo (current-buffer))
13335 (insert-buffer-substring artbuf)
13336 ;; Append newline at end of the buffer as separator, and then
13337 ;; save it to file.
13338 (goto-char (point-max))
13340 (append-to-file (point-min) (point-max) file-name))
13341 (kill-buffer tmpbuf)))
13343 (defun gnus-convert-article-to-rmail ()
13344 "Convert article in current buffer to Rmail message format."
13345 (let ((buffer-read-only nil))
13346 ;; Convert article directly into Babyl format.
13347 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
13348 (goto-char (point-min))
13349 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
13350 (while (search-forward "\n\^_" nil t) ;single char
13351 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
13352 (goto-char (point-max))
13355 (defun gnus-narrow-to-page (&optional arg)
13356 "Narrow the article buffer to a page.
13357 If given a numerical ARG, move forward ARG pages."
13359 (setq arg (if arg (prefix-numeric-value arg) 0))
13361 (set-buffer gnus-article-buffer)
13362 (goto-char (point-min))
13364 (when (gnus-visual-p 'page-marker)
13365 (let ((buffer-read-only nil))
13366 (gnus-remove-text-with-property 'gnus-prev)
13367 (gnus-remove-text-with-property 'gnus-next)))
13370 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
13372 (re-search-forward page-delimiter nil 'move arg)))
13373 (goto-char (match-end 0)))
13376 (if (re-search-forward page-delimiter nil 'move)
13377 (match-beginning 0)
13379 (when (and (gnus-visual-p 'page-marker)
13380 (not (= (point-min) 1)))
13382 (goto-char (point-min))
13383 (gnus-insert-prev-page-button)))
13384 (when (and (gnus-visual-p 'page-marker)
13385 (not (= (1- (point-max)) (buffer-size))))
13387 (goto-char (point-max))
13388 (gnus-insert-next-page-button)))))
13391 ;; Article mode commands
13393 (defun gnus-article-next-page (&optional lines)
13394 "Show next page of current article.
13395 If end of article, return non-nil. Otherwise return nil.
13396 Argument LINES specifies lines to be scrolled up."
13398 (move-to-window-line -1)
13399 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
13400 (if (save-excursion
13402 (and (pos-visible-in-window-p) ;Not continuation line.
13404 ;; Nothing in this page.
13405 (if (or (not gnus-break-pages)
13408 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
13410 (gnus-narrow-to-page 1) ;Go to next page.
13412 ;; More in this page.
13416 ;; Long lines may cause an end-of-buffer error.
13417 (goto-char (point-max))))
13420 (defun gnus-article-prev-page (&optional lines)
13421 "Show previous page of current article.
13422 Argument LINES specifies lines to be scrolled down."
13424 (move-to-window-line 0)
13425 (if (and gnus-break-pages
13427 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
13429 (gnus-narrow-to-page -1) ;Go to previous page.
13430 (goto-char (point-max))
13433 (scroll-down lines)
13436 (defun gnus-article-refer-article ()
13437 "Read article specified by message-id around point."
13439 (search-forward ">" nil t) ;Move point to end of "<....>".
13440 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
13441 (let ((message-id (match-string 1)))
13442 (set-buffer gnus-summary-buffer)
13443 (gnus-summary-refer-article message-id))
13444 (error "No references around point")))
13446 (defun gnus-article-show-summary ()
13447 "Reconfigure windows to show summary buffer."
13449 (gnus-configure-windows 'article)
13450 (gnus-summary-goto-subject gnus-current-article))
13452 (defun gnus-article-describe-briefly ()
13453 "Describe article mode commands briefly."
13456 (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")))
13458 (defun gnus-article-summary-command ()
13459 "Execute the last keystroke in the summary buffer."
13461 (let ((obuf (current-buffer))
13462 (owin (current-window-configuration))
13464 (switch-to-buffer gnus-summary-buffer 'norecord)
13465 (setq func (lookup-key (current-local-map) (this-command-keys)))
13466 (call-interactively func)
13468 (set-window-configuration owin)
13469 (set-window-point (get-buffer-window (current-buffer)) (point))))
13471 (defun gnus-article-summary-command-nosave ()
13472 "Execute the last keystroke in the summary buffer."
13475 (pop-to-buffer gnus-summary-buffer 'norecord)
13476 (setq func (lookup-key (current-local-map) (this-command-keys)))
13477 (call-interactively func)))
13480 ;; Basic ideas by emv@math.lsa.umich.edu (Edward Vielmetti)
13483 (defalias 'gnus-batch-kill 'gnus-batch-score)
13485 (defun gnus-batch-score ()
13486 "Run batched scoring.
13487 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
13488 Newsgroups is a list of strings in Bnews format. If you want to score
13489 the comp hierarchy, you'd say \"comp.all\". If you would not like to
13490 score the alt hierarchy, you'd say \"!alt.all\"."
13493 (gnus-newsrc-parse-options
13494 (apply (function concat)
13495 (mapcar (lambda (g) (concat g " "))
13496 command-line-args-left))))
13497 (gnus-expert-user t)
13498 (nnmail-spool-file nil)
13499 (gnus-use-dribble-file nil)
13500 (yes (car yes-and-no))
13501 (no (cdr yes-and-no))
13503 ;; Disable verbose message.
13504 gnus-novice-user gnus-large-newsgroup)
13505 ;; Eat all arguments.
13506 (setq command-line-args-left nil)
13509 ;; Apply kills to specified newsgroups in command line arguments.
13510 (setq newsrc (cdr gnus-newsrc-alist))
13512 (setq group (car (car newsrc)))
13513 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
13514 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
13516 (or (eq (car entry) t)
13517 (not (zerop (car entry)))))
13518 (if yes (string-match yes group) t)
13519 (or (null no) (not (string-match no group))))
13521 (gnus-summary-read-group group nil t nil t)
13522 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
13523 (gnus-summary-exit))))
13524 (setq newsrc (cdr newsrc)))
13526 (switch-to-buffer gnus-group-buffer)
13527 (gnus-group-save-newsrc)))
13529 (defun gnus-apply-kill-file ()
13530 "Apply a kill file to the current newsgroup.
13531 Returns the number of articles marked as read."
13532 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
13533 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
13534 (gnus-apply-kill-file-internal)
13537 (defun gnus-kill-save-kill-buffer ()
13539 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
13540 (if (get-file-buffer file)
13542 (set-buffer (get-file-buffer file))
13543 (and (buffer-modified-p) (save-buffer))
13544 (kill-buffer (current-buffer)))))))
13546 (defvar gnus-kill-file-name "KILL"
13547 "Suffix of the kill files.")
13549 (defun gnus-newsgroup-kill-file (newsgroup)
13550 "Return the name of a kill file name for NEWSGROUP.
13551 If NEWSGROUP is nil, return the global kill file name instead."
13552 (cond ((or (null newsgroup)
13553 (string-equal newsgroup ""))
13554 ;; The global KILL file is placed at top of the directory.
13555 (expand-file-name gnus-kill-file-name
13556 (or gnus-kill-files-directory "~/News")))
13557 ((gnus-use-long-file-name 'not-kill)
13558 ;; Append ".KILL" to newsgroup name.
13559 (expand-file-name (concat (gnus-newsgroup-saveable-name newsgroup)
13560 "." gnus-kill-file-name)
13561 (or gnus-kill-files-directory "~/News")))
13563 ;; Place "KILL" under the hierarchical directory.
13564 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
13565 "/" gnus-kill-file-name)
13566 (or gnus-kill-files-directory "~/News")))))
13573 (defvar gnus-dribble-ignore nil)
13574 (defvar gnus-dribble-eval-file nil)
13576 (defun gnus-dribble-file-name ()
13578 (if gnus-dribble-directory
13579 (concat (file-name-as-directory gnus-dribble-directory)
13580 (file-name-nondirectory gnus-current-startup-file))
13581 gnus-current-startup-file)
13584 (defun gnus-dribble-enter (string)
13585 (if (and (not gnus-dribble-ignore)
13586 (or gnus-dribble-buffer
13588 (buffer-name gnus-dribble-buffer))
13589 (let ((obuf (current-buffer)))
13590 (set-buffer gnus-dribble-buffer)
13591 (insert string "\n")
13592 (set-window-point (get-buffer-window (current-buffer)) (point-max))
13593 (set-buffer obuf))))
13595 (defun gnus-dribble-read-file ()
13596 (let ((dribble-file (gnus-dribble-file-name)))
13598 (set-buffer (setq gnus-dribble-buffer
13600 (file-name-nondirectory dribble-file))))
13601 (gnus-add-current-to-buffer-list)
13603 (setq buffer-file-name dribble-file)
13605 (buffer-disable-undo (current-buffer))
13606 (bury-buffer (current-buffer))
13607 (set-buffer-modified-p nil)
13608 (let ((auto (make-auto-save-file-name))
13609 (gnus-dribble-ignore t))
13610 (if (or (file-exists-p auto) (file-exists-p dribble-file))
13612 (if (file-newer-than-file-p auto dribble-file)
13613 (setq dribble-file auto))
13614 (insert-file-contents dribble-file)
13615 (if (not (zerop (buffer-size)))
13616 (set-buffer-modified-p t))
13618 "Auto-save file exists. Do you want to read it? ")
13619 (setq gnus-dribble-eval-file t))))))))
13621 (defun gnus-dribble-eval-file ()
13622 (if (not gnus-dribble-eval-file)
13624 (setq gnus-dribble-eval-file nil)
13626 (let ((gnus-dribble-ignore t))
13627 (set-buffer gnus-dribble-buffer)
13628 (eval-buffer (current-buffer))))))
13630 (defun gnus-dribble-delete-file ()
13631 (if (file-exists-p (gnus-dribble-file-name))
13632 (delete-file (gnus-dribble-file-name)))
13633 (if gnus-dribble-buffer
13635 (set-buffer gnus-dribble-buffer)
13636 (let ((auto (make-auto-save-file-name)))
13637 (if (file-exists-p auto)
13638 (delete-file auto))
13640 (set-buffer-modified-p nil)))))
13642 (defun gnus-dribble-save ()
13643 (if (and gnus-dribble-buffer
13644 (buffer-name gnus-dribble-buffer))
13646 (set-buffer gnus-dribble-buffer)
13649 (defun gnus-dribble-clear ()
13651 (if (gnus-buffer-exists-p gnus-dribble-buffer)
13653 (set-buffer gnus-dribble-buffer)
13655 (set-buffer-modified-p nil)
13656 (setq buffer-saved-size (buffer-size))))))
13659 ;;; Server Communication
13662 (defun gnus-start-news-server (&optional confirm)
13663 "Open a method for getting news.
13664 If CONFIRM is non-nil, the user will be asked for an NNTP server."
13666 (if gnus-current-select-method
13667 ;; Stream is already opened.
13669 ;; Open NNTP server.
13670 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
13673 ;; Read server name with completion.
13674 (setq gnus-nntp-server
13675 (completing-read "NNTP server: "
13676 (mapcar (lambda (server) (list server))
13677 (cons (list gnus-nntp-server)
13678 gnus-secondary-servers))
13679 nil nil gnus-nntp-server))))
13681 (if (and gnus-nntp-server
13682 (stringp gnus-nntp-server)
13683 (not (string= gnus-nntp-server "")))
13684 (setq gnus-select-method
13685 (cond ((or (string= gnus-nntp-server "")
13686 (string= gnus-nntp-server "::"))
13687 (list 'nnspool (system-name)))
13688 ((string-match "^:" gnus-nntp-server)
13689 (list 'nnmh gnus-nntp-server
13690 (list 'nnmh-directory
13691 (file-name-as-directory
13693 (concat "~/" (substring
13694 gnus-nntp-server 1)))))
13695 (list 'nnmh-get-new-mail nil)))
13697 (list 'nntp gnus-nntp-server)))))
13699 (setq how (car gnus-select-method))
13700 (cond ((eq how 'nnspool)
13702 (gnus-message 5 "Looking up local news spool..."))
13705 (gnus-message 5 "Looking up mh spool..."))
13708 (setq gnus-current-select-method gnus-select-method)
13709 (run-hooks 'gnus-open-server-hook)
13711 ;; gnus-open-server-hook might have opened it
13712 (gnus-server-opened gnus-select-method)
13713 (gnus-open-server gnus-select-method)
13716 "%s open error: '%s'. Continue? "
13717 (nth 1 gnus-select-method)
13718 (gnus-status-message gnus-select-method)))
13720 (gnus-message 1 "Couldn't open server on %s"
13721 (nth 1 gnus-select-method))
13725 (defun gnus-check-server (&optional method)
13726 "Check whether the connection to METHOD is down.
13727 If METHOD is nil, use `gnus-select-method'.
13728 If it is down, start it up (again)."
13729 (let ((method (or method gnus-select-method)))
13730 ;; Transform virtual server names into select methods.
13731 (when (stringp method)
13732 (setq method (gnus-server-to-method method)))
13733 (if (gnus-server-opened method)
13734 ;; The stream is already opened.
13736 ;; Open the server.
13737 (gnus-message 5 "Opening %s server on %s..." (car method) (nth 1 method))
13738 (run-hooks 'gnus-open-server-hook)
13740 (gnus-open-server method)
13743 (defun gnus-get-function (method function)
13744 "Return a function symbol based on METHOD and FUNCTION."
13745 ;; Translate server names into methods.
13747 (error "Attempted use of a nil select method"))
13748 (when (stringp method)
13749 (setq method (gnus-server-to-method method)))
13750 (let ((func (intern (format "%s-%s" (car method) function))))
13751 ;; If the functions isn't bound, we require the backend in
13753 (unless (fboundp func)
13754 (require (car method))
13755 (unless (fboundp func)
13756 ;; This backend doesn't implement this function.
13757 (error "No such function: %s" func)))
13760 ;;; Interface functions to the backends.
13762 (defun gnus-open-server (method)
13763 "Open a connection to METHOD."
13764 (let ((elem (assoc method gnus-opened-servers)))
13765 ;; If this method was previously denied, we just return nil.
13766 (if (eq (nth 1 elem) 'denied)
13768 (gnus-message 1 "Denied server")
13770 ;; Open the server.
13772 (funcall (gnus-get-function method 'open-server)
13773 (nth 1 method) (nthcdr 2 method))))
13774 ;; If this hasn't been opened before, we add it to the list.
13776 (setq elem (list method nil)
13777 gnus-opened-servers (cons elem gnus-opened-servers)))
13778 ;; Set the status of this server.
13779 (setcar (cdr elem) (if result 'ok 'denied))
13780 ;; Return the result from the "open" call.
13783 (defun gnus-close-server (method)
13784 "Close the connection to METHOD."
13785 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
13787 (defun gnus-request-list (method)
13788 "Request the active file from METHOD."
13789 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
13791 (defun gnus-request-list-newsgroups (method)
13792 "Request the newsgroups file from METHOD."
13793 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
13795 (defun gnus-request-newgroups (date method)
13796 "Request all new groups since DATE from METHOD."
13797 (funcall (gnus-get-function method 'request-newgroups)
13798 date (nth 1 method)))
13800 (defun gnus-server-opened (method)
13801 "Check whether a connection to METHOD has been opened."
13802 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
13804 (defun gnus-status-message (method)
13805 "Return the status message from METHOD.
13806 If METHOD is a string, it is interpreted as a group name. The method
13807 this group uses will be queried."
13808 (let ((method (if (stringp method) (gnus-find-method-for-group method)
13810 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
13812 (defun gnus-request-group (group &optional dont-check)
13813 "Request GROUP. If DONT-CHECK, no information is required."
13814 (let ((method (gnus-find-method-for-group group)))
13815 (funcall (gnus-get-function method 'request-group)
13816 (gnus-group-real-name group) (nth 1 method) dont-check)))
13818 (defun gnus-request-asynchronous (group &optional articles)
13819 "Request that GROUP behave asynchronously.
13820 ARTICLES is the `data' of the group."
13821 (let ((method (gnus-find-method-for-group group)))
13822 (funcall (gnus-get-function method 'request-asynchronous)
13823 (gnus-group-real-name group) (nth 1 method) articles)))
13825 (defun gnus-list-active-group (group)
13826 "Request active information on GROUP."
13827 (let ((method (gnus-find-method-for-group group))
13828 (func 'list-active-group))
13829 (when (gnus-check-backend-function func group)
13830 (funcall (gnus-get-function method func)
13831 (gnus-group-real-name group) (nth 1 method)))))
13833 (defun gnus-request-group-description (group)
13834 "Request a description of GROUP."
13835 (let ((method (gnus-find-method-for-group group))
13836 (func 'request-group-description))
13837 (when (gnus-check-backend-function func group)
13838 (funcall (gnus-get-function method func)
13839 (gnus-group-real-name group) (nth 1 method)))))
13841 (defun gnus-close-group (group)
13842 "Request the GROUP be closed."
13843 (let ((method (gnus-find-method-for-group group)))
13844 (funcall (gnus-get-function method 'close-group)
13845 (gnus-group-real-name group) (nth 1 method))))
13847 (defun gnus-retrieve-headers (articles group &optional fetch-old)
13848 "Request headers for ARTICLES in GROUP.
13849 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
13850 (let ((method (gnus-find-method-for-group group)))
13851 (if (and gnus-use-cache (numberp (car articles)))
13852 (gnus-cache-retrieve-headers articles group fetch-old)
13853 (funcall (gnus-get-function method 'retrieve-headers)
13854 articles (gnus-group-real-name group) (nth 1 method)
13857 (defun gnus-retrieve-groups (groups method)
13858 "Request active information on GROUPS from METHOD."
13859 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
13861 (defun gnus-request-type (group &optional article)
13862 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
13863 (let ((method (gnus-find-method-for-group group)))
13864 (if (not (gnus-check-backend-function 'request-type (car method)))
13866 (funcall (gnus-get-function method 'request-type)
13867 (gnus-group-real-name group) article))))
13869 (defun gnus-request-article (article group &optional buffer)
13870 "Request the ARTICLE in GROUP.
13871 ARTICLE can either be an article number or an article Message-ID.
13872 If BUFFER, insert the article in that group."
13873 (let ((method (gnus-find-method-for-group group)))
13874 (funcall (gnus-get-function method 'request-article)
13875 article (gnus-group-real-name group) (nth 1 method) buffer)))
13877 (defun gnus-request-head (article group)
13878 "Request the head of ARTICLE in GROUP."
13879 (let ((method (gnus-find-method-for-group group)))
13880 (funcall (gnus-get-function method 'request-head)
13881 article (gnus-group-real-name group) (nth 1 method))))
13883 (defun gnus-request-body (article group)
13884 "Request the body of ARTICLE in GROUP."
13885 (let ((method (gnus-find-method-for-group group)))
13886 (funcall (gnus-get-function method 'request-body)
13887 article (gnus-group-real-name group) (nth 1 method))))
13889 (defun gnus-request-post (method)
13890 "Post the current buffer using METHOD."
13891 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
13893 (defun gnus-request-scan (group method)
13894 "Request a SCAN being performed in GROUP from METHOD.
13895 If GROUP is nil, all groups on METHOD are scanned."
13896 (let ((method (if group (gnus-find-method-for-group group) method)))
13897 (funcall (gnus-get-function method 'request-scan)
13898 (and group (gnus-group-real-name group)) (nth 1 method))))
13900 (defun gnus-request-update-info (info method)
13901 "Request that METHOD update INFO."
13902 (when (gnus-check-backend-function 'request-update-info method)
13903 (funcall (gnus-get-function method 'request-update-info)
13904 (gnus-group-real-name (gnus-info-group info))
13905 info (nth 1 method))))
13907 (defun gnus-request-expire-articles (articles group &optional force)
13908 (let ((method (gnus-find-method-for-group group)))
13909 (funcall (gnus-get-function method 'request-expire-articles)
13910 articles (gnus-group-real-name group) (nth 1 method)
13913 (defun gnus-request-move-article
13914 (article group server accept-function &optional last)
13915 (let ((method (gnus-find-method-for-group group)))
13916 (funcall (gnus-get-function method 'request-move-article)
13917 article (gnus-group-real-name group)
13918 (nth 1 method) accept-function last)))
13920 (defun gnus-request-accept-article (group &optional last)
13921 (let ((func (if (symbolp group) group
13922 (car (gnus-find-method-for-group group)))))
13923 (funcall (intern (format "%s-request-accept-article" func))
13924 (if (stringp group) (gnus-group-real-name group) group)
13927 (defun gnus-request-replace-article (article group buffer)
13928 (let ((func (car (gnus-find-method-for-group group))))
13929 (funcall (intern (format "%s-request-replace-article" func))
13930 article (gnus-group-real-name group) buffer)))
13932 (defun gnus-request-associate-buffer (group)
13933 (let ((method (gnus-find-method-for-group group)))
13934 (funcall (gnus-get-function method 'request-associate-buffer)
13935 (gnus-group-real-name group))))
13937 (defun gnus-request-restore-buffer (article group)
13938 "Request a new buffer restored to the state of ARTICLE."
13939 (let ((method (gnus-find-method-for-group group)))
13940 (funcall (gnus-get-function method 'request-restore-buffer)
13941 article (gnus-group-real-name group) (nth 1 method))))
13943 (defun gnus-request-create-group (group)
13944 (let ((method (gnus-find-method-for-group group)))
13945 (funcall (gnus-get-function method 'request-create-group)
13946 (gnus-group-real-name group) (nth 1 method))))
13948 (defun gnus-request-delete-group (group &optional force)
13949 (let ((method (gnus-find-method-for-group group)))
13950 (funcall (gnus-get-function method 'request-delete-group)
13951 (gnus-group-real-name group) force (nth 1 method))))
13953 (defun gnus-request-rename-group (group new-name)
13954 (let ((method (gnus-find-method-for-group group)))
13955 (funcall (gnus-get-function method 'request-rename-group)
13956 (gnus-group-real-name group)
13957 (gnus-group-real-name new-name) (nth 1 method))))
13959 (defun gnus-post-method (group force-group-method)
13960 "Return the posting method based on GROUP and FORCE."
13961 (let ((group-method (if (stringp group)
13962 (gnus-find-method-for-group group)
13965 ;; If the group-method is nil (which shouldn't happen) we use
13966 ;; the default method.
13967 ((null group-method)
13968 gnus-select-method)
13969 ;; We want this group's method.
13970 (force-group-method group-method)
13971 ;; Override normal method.
13972 ((and gnus-post-method
13973 (or (gnus-method-option-p group-method 'post)
13974 (gnus-method-option-p group-method 'post-mail)))
13976 ;; Perhaps this is a mail group?
13977 ((and (not (gnus-member-of-valid 'post group))
13978 (not (gnus-method-option-p group-method 'post-mail)))
13980 ;; Use the normal select method.
13981 (t gnus-select-method))))
13983 (defun gnus-member-of-valid (symbol group)
13984 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
13985 (memq symbol (assoc
13986 (symbol-name (car (gnus-find-method-for-group group)))
13987 gnus-valid-select-methods)))
13989 (defun gnus-method-option-p (method option)
13990 "Return non-nil if select METHOD has OPTION as a parameter."
13991 (memq option (assoc (format "%s" (car method))
13992 gnus-valid-select-methods)))
13994 (defmacro gnus-server-equal (ss1 ss2)
13995 "Say whether two servers are equal."
13999 (and (= (length s1) (length s2))
14001 (while (and s1 (member (car s1) s2))
14002 (setq s1 (cdr s1)))
14005 (defun gnus-server-extend-method (group method)
14006 ;; This function "extends" a virtual server. If the server is
14007 ;; "hello", and the select method is ("hello" (my-var "something"))
14008 ;; in the group "alt.alt", this will result in a new virtual server
14009 ;; called "helly+alt.alt".
14011 (gnus-copy-sequence
14012 (if (equal (car method) "native") gnus-select-method
14013 (cdr (assoc (car method) gnus-server-alist))))))
14014 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
14015 (nconc entry (cdr method))))
14017 (defun gnus-find-method-for-group (group &optional info)
14018 "Find the select method that GROUP uses."
14019 (or gnus-override-method
14021 gnus-select-method)
14022 (let ((info (or info (gnus-get-info group)))
14025 (not (setq method (gnus-info-method info))))
14026 (setq method gnus-select-method)
14028 (cond ((stringp method)
14029 (gnus-server-to-method method))
14030 ((stringp (car method))
14031 (gnus-server-extend-method group method))
14034 (gnus-server-add-address method))))
14036 (defun gnus-check-backend-function (func group)
14037 "Check whether GROUP supports function FUNC."
14038 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
14040 (fboundp (intern (format "%s-%s" method func)))))
14042 (defun gnus-methods-using (feature)
14043 "Find all methods that have FEATURE."
14044 (let ((valids gnus-valid-select-methods)
14047 (if (memq feature (car valids))
14048 (setq outs (cons (car valids) outs)))
14049 (setq valids (cdr valids)))
14053 ;;; Active & Newsrc File Handling
14056 ;; Newsrc related functions.
14057 ;; Gnus internal format of gnus-newsrc-alist:
14058 ;; (("alt.general" 3 (1 . 1))
14059 ;; ("alt.misc" 3 ((1 . 10) (12 . 15)))
14060 ;; ("alt.test" 7 (1 . 99) (45 57 93)) ...)
14061 ;; The first item is the group name; the second is the subscription
14062 ;; level; the third is either a range of a list of ranges of read
14063 ;; articles, the optional fourth element is a list of marked articles,
14064 ;; the optional fifth element is the select method.
14066 ;; Gnus internal format of gnus-newsrc-hashtb:
14067 ;; (95 ("alt.general" 3 (1 . 1)) ("alt.misc" 3 ((1 . 10) (12 . 15))) ...)
14068 ;; This is the entry for "alt.misc". The first element is the number
14069 ;; of unread articles in "alt.misc". The cdr of this entry is the
14070 ;; element *before* "alt.misc" in gnus-newsrc-alist, which makes is
14071 ;; trivial to remove or add new elements into gnus-newsrc-alist
14072 ;; without scanning the entire list. So, to get the actual information
14073 ;; of "alt.misc", you'd say something like
14074 ;; (nth 2 (gnus-gethash "alt.misc" gnus-newsrc-hashtb))
14076 ;; Gnus internal format of gnus-active-hashtb:
14080 ;; The only element in each entry in this hash table is a range of
14081 ;; (possibly) available articles. (Articles in this range may have
14082 ;; been expired or canceled.)
14084 ;; Gnus internal format of gnus-killed-list and gnus-zombie-list:
14085 ;; ("alt.misc" "alt.test" "alt.general" ...)
14087 (defun gnus-setup-news (&optional rawfile level)
14088 "Setup news information.
14089 If RAWFILE is non-nil, the .newsrc file will also be read.
14090 If LEVEL is non-nil, the news will be set up at level LEVEL."
14091 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
14092 ;; Clear some variables to re-initialize news information.
14093 (if init (setq gnus-newsrc-alist nil
14094 gnus-active-hashtb nil))
14096 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
14097 (if init (gnus-read-newsrc-file rawfile))
14099 ;; If we don't read the complete active file, we fill in the
14101 (if (or (null gnus-read-active-file)
14102 (eq gnus-read-active-file 'some))
14103 (gnus-update-active-hashtb-from-killed))
14105 ;; Read the active file and create `gnus-active-hashtb'.
14106 ;; If `gnus-read-active-file' is nil, then we just create an empty
14107 ;; hash table. The partial filling out of the hash table will be
14108 ;; done in `gnus-get-unread-articles'.
14109 (and gnus-read-active-file
14111 (gnus-read-active-file))
14113 (or gnus-active-hashtb
14114 (setq gnus-active-hashtb (make-vector 4095 0)))
14116 ;; Initialize the cache.
14117 (when gnus-use-cache
14120 ;; Possibly eval the dribble file.
14121 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
14123 (gnus-update-format-specifications)
14125 ;; Find new newsgroups and treat them.
14126 (if (and init gnus-check-new-newsgroups gnus-read-active-file (not level)
14127 (gnus-check-server gnus-select-method))
14128 (gnus-find-new-newsgroups))
14130 ;; Find the number of unread articles in each non-dead group.
14131 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
14132 (gnus-get-unread-articles level))
14134 (if (and init gnus-check-bogus-newsgroups
14135 gnus-read-active-file (not level)
14136 (gnus-server-opened gnus-select-method))
14137 (gnus-check-bogus-newsgroups))))
14139 (defun gnus-find-new-newsgroups ()
14140 "Search for new newsgroups and add them.
14141 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
14142 The `-n' option line from .newsrc is respected."
14144 (or (gnus-check-first-time-used)
14145 (if (or (consp gnus-check-new-newsgroups)
14146 (eq gnus-check-new-newsgroups 'ask-server))
14147 (gnus-ask-server-for-new-groups)
14149 group new-newsgroups)
14150 (gnus-message 5 "Looking for new newsgroups...")
14151 (or gnus-have-read-active-file (gnus-read-active-file))
14152 (setq gnus-newsrc-last-checked-date (current-time-string))
14153 (if (not gnus-killed-hashtb) (gnus-make-hashtable-from-killed))
14154 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
14155 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
14158 (if (or (null (setq group (symbol-name sym)))
14160 (null (symbol-value sym))
14161 (gnus-gethash group gnus-killed-hashtb)
14162 (gnus-gethash group gnus-newsrc-hashtb))
14164 (let ((do-sub (gnus-matches-options-n group)))
14166 ((eq do-sub 'subscribe)
14167 (setq groups (1+ groups))
14168 (gnus-sethash group group gnus-killed-hashtb)
14169 (funcall gnus-subscribe-options-newsgroup-method group))
14170 ((eq do-sub 'ignore)
14173 (setq groups (1+ groups))
14174 (gnus-sethash group group gnus-killed-hashtb)
14175 (if gnus-subscribe-hierarchical-interactive
14176 (setq new-newsgroups (cons group new-newsgroups))
14177 (funcall gnus-subscribe-newsgroup-method group)))))))
14178 gnus-active-hashtb)
14180 (gnus-subscribe-hierarchical-interactive new-newsgroups))
14181 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
14183 (gnus-message 6 "%d new newsgroup%s arrived."
14184 groups (if (> groups 1) "s have" " has"))
14185 (gnus-message 6 "No new newsgroups."))))))
14187 (defun gnus-matches-options-n (group)
14188 ;; Returns `subscribe' if the group is to be uncoditionally
14189 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
14190 ;; no match for the group.
14192 ;; First we check the two user variables.
14194 ((and gnus-options-subscribe
14195 (string-match gnus-options-subscribe group))
14197 ((and gnus-auto-subscribed-groups
14198 (string-match gnus-auto-subscribed-groups group))
14200 ((and gnus-options-not-subscribe
14201 (string-match gnus-options-not-subscribe group))
14203 ;; Then we go through the list that was retrieved from the .newsrc
14204 ;; file. This list has elements on the form
14205 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
14206 ;; is in the reverse order of the options line) is returned.
14208 (let ((regs gnus-newsrc-options-n))
14210 (not (string-match (car (car regs)) group)))
14211 (setq regs (cdr regs)))
14212 (and regs (cdr (car regs)))))))
14214 (defun gnus-ask-server-for-new-groups ()
14215 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
14216 (methods (cons gnus-select-method
14218 (and (consp gnus-check-new-newsgroups)
14219 gnus-check-new-newsgroups)
14220 gnus-secondary-select-methods)))
14222 (new-date (current-time-string))
14223 (hashtb (gnus-make-hashtable 100))
14224 group new-newsgroups got-new method)
14225 ;; Go through both primary and secondary select methods and
14226 ;; request new newsgroups.
14228 (setq method (gnus-server-get-method nil (car methods)))
14229 (and (gnus-check-server method)
14230 (gnus-request-newgroups date method)
14233 (set-buffer nntp-server-buffer)
14234 ;; Enter all the new groups in a hashtable.
14235 (gnus-active-to-gnus-format method hashtb 'ignore)))
14236 (setq methods (cdr methods)))
14237 (and got-new (setq gnus-newsrc-last-checked-date new-date))
14238 ;; Now all new groups from all select methods are in `hashtb'.
14240 (lambda (group-sym)
14241 (setq group (symbol-name group-sym))
14242 (if (or (null group)
14243 (null (symbol-value group-sym))
14244 (gnus-gethash group gnus-newsrc-hashtb)
14245 (member group gnus-zombie-list)
14246 (member group gnus-killed-list))
14247 ;; The group is already known.
14249 (and (symbol-value group-sym)
14250 (gnus-set-active group (symbol-value group-sym)))
14251 (let ((do-sub (gnus-matches-options-n group)))
14252 (cond ((eq do-sub 'subscribe)
14253 (setq groups (1+ groups))
14254 (gnus-sethash group group gnus-killed-hashtb)
14256 gnus-subscribe-options-newsgroup-method group))
14257 ((eq do-sub 'ignore)
14260 (setq groups (1+ groups))
14261 (gnus-sethash group group gnus-killed-hashtb)
14262 (if gnus-subscribe-hierarchical-interactive
14263 (setq new-newsgroups (cons group new-newsgroups))
14264 (funcall gnus-subscribe-newsgroup-method group)))))))
14267 (gnus-subscribe-hierarchical-interactive new-newsgroups))
14268 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
14270 (gnus-message 6 "%d new newsgroup%s arrived."
14271 groups (if (> groups 1) "s have" " has")))
14274 (defun gnus-check-first-time-used ()
14275 (if (or (> (length gnus-newsrc-alist) 1)
14276 (file-exists-p gnus-startup-file)
14277 (file-exists-p (concat gnus-startup-file ".el"))
14278 (file-exists-p (concat gnus-startup-file ".eld")))
14280 (gnus-message 6 "First time user; subscribing you to default groups")
14281 (or gnus-have-read-active-file (gnus-read-active-file))
14282 (setq gnus-newsrc-last-checked-date (current-time-string))
14283 (let ((groups gnus-default-subscribed-newsgroups)
14287 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
14290 (if (null (setq group (symbol-name sym)))
14292 (let ((do-sub (gnus-matches-options-n group)))
14294 ((eq do-sub 'subscribe)
14295 (gnus-sethash group group gnus-killed-hashtb)
14296 (funcall gnus-subscribe-options-newsgroup-method group))
14297 ((eq do-sub 'ignore)
14300 (setq gnus-killed-list (cons group gnus-killed-list)))))))
14301 gnus-active-hashtb)
14303 (if (gnus-active (car groups))
14304 (gnus-group-change-level
14305 (car groups) gnus-level-default-subscribed gnus-level-killed))
14306 (setq groups (cdr groups)))
14307 (gnus-group-make-help-group)
14308 (and gnus-novice-user
14309 (gnus-message 7 "`A k' to list killed groups"))))))
14311 (defun gnus-subscribe-group (group previous &optional method)
14312 (gnus-group-change-level
14314 (list t group gnus-level-default-subscribed nil nil method)
14316 gnus-level-default-subscribed gnus-level-killed previous t))
14318 ;; `gnus-group-change-level' is the fundamental function for changing
14319 ;; subscription levels of newsgroups. This might mean just changing
14320 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
14321 ;; again, which subscribes/unsubscribes a group, which is equally
14322 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
14323 ;; from 8-9 to 1-7 means that you remove the group from the list of
14324 ;; killed (or zombie) groups and add them to the (kinda) subscribed
14325 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
14326 ;; which is trivial.
14327 ;; ENTRY can either be a string (newsgroup name) or a list (if
14328 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
14329 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
14331 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
14332 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
14334 (defun gnus-group-change-level (entry level &optional oldlevel
14335 previous fromkilled)
14336 (let (group info active num)
14337 ;; Glean what info we can from the arguments
14339 (if fromkilled (setq group (nth 1 entry))
14340 (setq group (car (nth 2 entry))))
14341 (setq group entry))
14342 (if (and (stringp entry)
14344 (< oldlevel gnus-level-zombie))
14345 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
14346 (if (and (not oldlevel)
14348 (setq oldlevel (car (cdr (nth 2 entry)))))
14349 (if (stringp previous)
14350 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
14352 (if (and (>= oldlevel gnus-level-zombie)
14353 (gnus-gethash group gnus-newsrc-hashtb))
14354 ;; We are trying to subscribe a group that is already
14358 (or (gnus-ephemeral-group-p group)
14359 (gnus-dribble-enter
14360 (format "(gnus-group-change-level %S %S %S %S %S)"
14361 group level oldlevel (car (nth 2 previous)) fromkilled)))
14363 ;; Then we remove the newgroup from any old structures, if needed.
14364 ;; If the group was killed, we remove it from the killed or zombie
14365 ;; list. If not, and it is in fact going to be killed, we remove
14366 ;; it from the newsrc hash table and assoc.
14367 (cond ((>= oldlevel gnus-level-zombie)
14368 (if (= oldlevel gnus-level-zombie)
14369 (setq gnus-zombie-list (delete group gnus-zombie-list))
14370 (setq gnus-killed-list (delete group gnus-killed-list))))
14372 (if (and (>= level gnus-level-zombie)
14375 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
14377 (setcdr (gnus-gethash (car (nth 3 entry))
14378 gnus-newsrc-hashtb)
14380 (setcdr (cdr entry) (cdr (cdr (cdr entry))))))))
14382 ;; Finally we enter (if needed) the list where it is supposed to
14383 ;; go, and change the subscription level. If it is to be killed,
14384 ;; we enter it into the killed or zombie list.
14385 (cond ((>= level gnus-level-zombie)
14386 ;; Remove from the hash table.
14387 (gnus-sethash group nil gnus-newsrc-hashtb)
14388 ;; We do not enter foreign groups into the list of dead
14390 (unless (gnus-group-foreign-p group)
14391 (if (= level gnus-level-zombie)
14392 (setq gnus-zombie-list (cons group gnus-zombie-list))
14393 (setq gnus-killed-list (cons group gnus-killed-list)))))
14395 ;; If the list is to be entered into the newsrc assoc, and
14396 ;; it was killed, we have to create an entry in the newsrc
14397 ;; hashtb format and fix the pointers in the newsrc assoc.
14398 (if (>= oldlevel gnus-level-zombie)
14402 (setq info (cdr entry))
14403 (setq num (car entry)))
14404 (setq active (gnus-active group))
14406 (if active (- (1+ (cdr active)) (car active)) t))
14407 ;; Check whether the group is foreign. If so, the
14408 ;; foreign select method has to be entered into the
14410 (let ((method (gnus-group-method-name group)))
14411 (if (eq method gnus-select-method)
14412 (setq info (list group level nil))
14413 (setq info (list group level nil nil method)))))
14416 (let ((p gnus-newsrc-alist))
14417 (while (cdr (cdr p))
14420 (setq entry (cons info (cdr (cdr previous))))
14423 (setcdr (cdr previous) entry)
14424 (gnus-sethash group (cons num (cdr previous))
14425 gnus-newsrc-hashtb))
14426 (setcdr previous entry)
14427 (gnus-sethash group (cons num previous)
14428 gnus-newsrc-hashtb))
14430 (setcdr (gnus-gethash (car (car (cdr entry)))
14431 gnus-newsrc-hashtb)
14433 ;; It was alive, and it is going to stay alive, so we
14434 ;; just change the level and don't change any pointers or
14435 ;; hash table entries.
14436 (setcar (cdr (car (cdr (cdr entry)))) level)))))))
14438 (defun gnus-kill-newsgroup (newsgroup)
14439 "Obsolete function. Kills a newsgroup."
14440 (gnus-group-change-level
14441 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
14443 (defun gnus-check-bogus-newsgroups (&optional confirm)
14444 "Remove bogus newsgroups.
14445 If CONFIRM is non-nil, the user has to confirm the deletion of every
14447 (let ((newsrc (cdr gnus-newsrc-alist))
14448 bogus group entry info)
14449 (gnus-message 5 "Checking bogus newsgroups...")
14450 (unless gnus-have-read-active-file
14451 (gnus-read-active-file))
14452 (when (member gnus-select-method gnus-have-read-active-file)
14453 ;; Find all bogus newsgroup that are subscribed.
14455 (setq info (pop newsrc)
14456 group (gnus-info-group info))
14457 (unless (or (gnus-active group) ; Active
14458 (gnus-info-method info) ; Foreign
14460 (not (gnus-y-or-n-p
14461 (format "Remove bogus newsgroup: %s " group)))))
14462 ;; Found a bogus newsgroup.
14463 (push group bogus)))
14464 ;; Remove all bogus subscribed groups by first killing them, and
14465 ;; then removing them from the list of killed groups.
14467 (when (setq entry (gnus-gethash (setq group (pop bogus))
14468 gnus-newsrc-hashtb))
14469 (gnus-group-change-level entry gnus-level-killed)
14470 (setq gnus-killed-list (delete group gnus-killed-list))))
14471 ;; Then we remove all bogus groups from the list of killed and
14472 ;; zombie groups. They are are removed without confirmation.
14473 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
14476 (setq killed (symbol-value (car dead-lists)))
14478 (unless (gnus-active (setq group (pop killed)))
14479 ;; The group is bogus.
14480 ;; !!!Slow as hell.
14481 (set (car dead-lists)
14482 (delete group (symbol-value (car dead-lists))))))
14483 (setq dead-lists (cdr dead-lists))))
14484 (gnus-message 5 "Checking bogus newsgroups...done"))))
14486 (defun gnus-check-duplicate-killed-groups ()
14487 "Remove duplicates from the list of killed groups."
14489 (let ((killed gnus-killed-list))
14491 (gnus-message 9 "%d" (length killed))
14492 (setcdr killed (delete (car killed) (cdr killed)))
14493 (setq killed (cdr killed)))))
14495 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
14496 ;; and compute how many unread articles there are in each group.
14497 (defun gnus-get-unread-articles (&optional level)
14498 (let* ((newsrc (cdr gnus-newsrc-alist))
14499 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
14502 (cond ((and gnus-activate-foreign-newsgroups
14503 (not (numberp gnus-activate-foreign-newsgroups)))
14504 (1+ gnus-level-subscribed))
14505 ((numberp gnus-activate-foreign-newsgroups)
14506 gnus-activate-foreign-newsgroups)
14510 (fboundp (intern (format "%s-request-update-info"
14511 (car gnus-select-method)))))
14512 info group active virtuals method fmethod)
14513 (gnus-message 5 "Checking new news...")
14516 (setq info (car newsrc)
14517 group (gnus-info-group info)
14518 active (gnus-active group))
14520 ;; Check newsgroups. If the user doesn't want to check them, or
14521 ;; they can't be checked (for instance, if the news server can't
14522 ;; be reached) we just set the number of unread articles in this
14523 ;; newsgroup to t. This means that Gnus thinks that there are
14524 ;; unread articles, but it has no idea how many.
14525 (if (and (setq method (gnus-info-method info))
14526 (not (gnus-server-equal
14529 (setq fmethod (gnus-server-get-method nil method))
14530 ;; We do this here because it would be awkward
14531 ;; to do it anywhere else. Hell, it's pretty
14532 ;; awkward here as well, but at least it's
14533 ;; reasonably efficient.
14534 (and (<= (gnus-info-level info) foreign-level)
14535 (gnus-request-update-info info method)))))
14536 (not (gnus-secondary-method-p method)))
14537 ;; These groups are foreign. Check the level.
14538 (if (<= (gnus-info-level info) foreign-level)
14539 (setq active (gnus-activate-group (gnus-info-group info) 'scan)))
14541 ;; These groups are native or secondary.
14542 (if (<= (gnus-info-level info) level)
14544 (if (and update (not method))
14546 ;; Allow updating of native groups as well, even
14547 ;; though that's pretty unlikely.
14548 (gnus-request-update-info info gnus-select-method)
14549 (setq active (gnus-activate-group
14550 (gnus-info-group info) 'scan)))
14551 (or gnus-read-active-file
14552 (setq active (gnus-activate-group
14553 (gnus-info-group info) 'scan)))))))
14556 (gnus-get-unread-articles-in-group info active)
14557 ;; The group couldn't be reached, so we nix out the number of
14558 ;; unread articles and stuff.
14559 (gnus-set-active group nil)
14560 (setcar (gnus-gethash group gnus-newsrc-hashtb) t))
14562 (setq newsrc (cdr newsrc)))
14564 (gnus-message 5 "Checking new news...done")))
14566 ;; Create a hash table out of the newsrc alist. The `car's of the
14567 ;; alist elements are used as keys.
14568 (defun gnus-make-hashtable-from-newsrc-alist ()
14569 (let ((alist gnus-newsrc-alist)
14570 (ohashtb gnus-newsrc-hashtb)
14572 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
14574 (setq prev (setq gnus-newsrc-alist
14575 (if (equal (car (car gnus-newsrc-alist))
14578 (cons (list "dummy.group" 0 nil) alist)))))
14582 (cons (and ohashtb (car (gnus-gethash (car (car alist)) ohashtb)))
14584 gnus-newsrc-hashtb)
14586 alist (cdr alist)))))
14588 (defun gnus-make-hashtable-from-killed ()
14589 "Create a hash table from the killed and zombie lists."
14590 (let ((lists '(gnus-killed-list gnus-zombie-list))
14592 (setq gnus-killed-hashtb
14593 (gnus-make-hashtable
14594 (+ (length gnus-killed-list) (length gnus-zombie-list))))
14596 (setq list (symbol-value (car lists)))
14597 (setq lists (cdr lists))
14599 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
14600 (setq list (cdr list))))))
14602 (defun gnus-get-unread-articles-in-group (info active)
14603 (let* ((range (gnus-info-read info))
14605 (marked (gnus-info-marks info)))
14606 ;; If a cache is present, we may have to alter the active info.
14607 (and gnus-use-cache
14608 (gnus-cache-possibly-alter-active (gnus-info-group info) active))
14609 ;; Modify the list of read articles according to what articles
14610 ;; are available; then tally the unread articles and add the
14611 ;; number to the group hash table entry.
14613 ((zerop (cdr active))
14616 (setq num (- (1+ (cdr active)) (car active))))
14617 ((not (listp (cdr range)))
14618 ;; Fix a single (num . num) range according to the
14619 ;; active hash table.
14620 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
14621 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
14622 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
14623 ;; Compute number of unread articles.
14624 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
14626 ;; The read list is a list of ranges. Fix them according to
14627 ;; the active hash table.
14628 ;; First peel off any elements that are below the lower
14630 (while (and (cdr range)
14632 (or (and (atom (car (cdr range))) (car (cdr range)))
14633 (car (car (cdr range))))))
14634 (if (numberp (car range))
14637 (or (and (numberp (car (cdr range)))
14639 (cdr (car (cdr range))))))
14640 (setcdr (car range)
14641 (or (and (numberp (nth 1 range)) (nth 1 range))
14642 (cdr (car (cdr range))))))
14643 (setcdr range (cdr (cdr range))))
14644 ;; Adjust the first element to be the same as the lower limit.
14645 (if (and (not (atom (car range)))
14646 (< (cdr (car range)) (car active)))
14647 (setcdr (car range) (1- (car active))))
14648 ;; Then we want to peel off any elements that are higher
14649 ;; than the upper active limit.
14650 (let ((srange range))
14651 ;; Go past all legal elements.
14652 (while (and (cdr srange)
14653 (<= (or (and (atom (car (cdr srange)))
14654 (car (cdr srange)))
14655 (car (car (cdr srange)))) (cdr active)))
14656 (setq srange (cdr srange)))
14658 ;; Nuke all remaining illegal elements.
14659 (setcdr srange nil))
14661 ;; Adjust the final element.
14662 (if (and (not (atom (car srange)))
14663 (> (cdr (car srange)) (cdr active)))
14664 (setcdr (car srange) (cdr active))))
14665 ;; Compute the number of unread articles.
14667 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
14668 (cdr (car range))))
14669 (or (and (atom (car range)) (car range))
14670 (car (car range))))))
14671 (setq range (cdr range)))
14672 (setq num (max 0 (- (cdr active) num)))))
14673 ;; Set the number of unread articles.
14674 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num)
14677 (defun gnus-activate-group (group &optional scan)
14678 ;; Check whether a group has been activated or not.
14679 ;; If SCAN, request a scan of that group as well.
14680 (let ((method (gnus-find-method-for-group group))
14682 (and (gnus-check-server method)
14683 ;; We escape all bugs and quit here to make it possible to
14684 ;; continue if a group is so out-there that it reports bugs
14688 (gnus-check-backend-function 'request-scan (car method))
14689 (gnus-request-scan group method))
14692 (gnus-request-group group)
14696 (set-buffer nntp-server-buffer)
14697 (goto-char (point-min))
14698 ;; Parse the result we got from `gnus-request-group'.
14699 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
14701 (goto-char (match-beginning 1))
14703 group (setq active (cons (read (current-buffer))
14704 (read (current-buffer)))))
14705 ;; Return the new active info.
14708 (defun gnus-update-read-articles (group unread)
14709 "Update the list of read and ticked articles in GROUP using the
14710 UNREAD and TICKED lists.
14711 Note: UNSELECTED has to be sorted over `<'.
14712 Returns whether the updating was successful."
14713 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
14714 (entry (gnus-gethash group gnus-newsrc-hashtb))
14715 (info (nth 2 entry))
14716 (marked (gnus-info-marks info))
14718 (unread (sort (copy-sequence unread) '<))
14720 (if (or (not info) (not active))
14721 ;; There is no info on this group if it was, in fact,
14722 ;; killed. Gnus stores no information on killed groups, so
14723 ;; there's nothing to be done.
14724 ;; One could store the information somewhere temporarily,
14725 ;; perhaps... Hmmm...
14727 ;; Remove any negative articles numbers.
14728 (while (and unread (< (car unread) 0))
14729 (setq unread (cdr unread)))
14730 ;; Remove any expired article numbers
14731 (while (and unread (< (car unread) (car active)))
14732 (setq unread (cdr unread)))
14733 ;; Compute the ranges of read articles by looking at the list of
14734 ;; unread articles.
14736 (if (/= (car unread) prev)
14737 (setq read (cons (if (= prev (1- (car unread))) prev
14738 (cons prev (1- (car unread)))) read)))
14739 (setq prev (1+ (car unread)))
14740 (setq unread (cdr unread)))
14741 (when (<= prev (cdr active))
14742 (setq read (cons (cons prev (cdr active)) read)))
14743 ;; Enter this list into the group info.
14744 (gnus-info-set-read
14745 info (if (> (length read) 1) (nreverse read) read))
14746 ;; Set the number of unread articles in gnus-newsrc-hashtb.
14747 (gnus-get-unread-articles-in-group info (gnus-active group))
14750 (defun gnus-make-articles-unread (group articles)
14751 "Mark ARTICLES in GROUP as unread."
14752 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
14753 (gnus-gethash (gnus-group-real-name group)
14754 gnus-newsrc-hashtb))))
14755 (ranges (gnus-info-read info))
14758 (when (gnus-member-of-range
14759 (setq article (pop articles)) ranges)
14760 (setq news (cons article news))))
14762 (gnus-info-set-read
14763 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
14764 (gnus-group-update-group group t))))
14766 ;; Enter all dead groups into the hashtb.
14767 (defun gnus-update-active-hashtb-from-killed ()
14768 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
14769 (lists (list gnus-killed-list gnus-zombie-list))
14772 (setq killed (car lists))
14774 (gnus-sethash (car killed) nil hashtb)
14775 (setq killed (cdr killed)))
14776 (setq lists (cdr lists)))))
14778 ;; Get the active file(s) from the backend(s).
14779 (defun gnus-read-active-file ()
14780 (gnus-group-set-mode-line)
14781 (let ((methods (if (gnus-check-server gnus-select-method)
14782 ;; The native server is available.
14783 (cons gnus-select-method gnus-secondary-select-methods)
14784 ;; The native server is down, so we just do the
14786 gnus-secondary-select-methods))
14788 (setq gnus-have-read-active-file nil)
14790 (set-buffer nntp-server-buffer)
14792 (let* ((method (gnus-server-get-method nil (car methods)))
14793 (where (nth 1 method))
14794 (mesg (format "Reading active file%s via %s..."
14795 (if (and where (not (zerop (length where))))
14796 (concat " from " where) "")
14798 (gnus-message 5 mesg)
14799 (if (not (gnus-check-server method))
14801 ;; Request that the backend scan its incoming messages.
14802 (and (gnus-check-backend-function 'request-scan (car method))
14803 (gnus-request-scan nil method))
14805 ((and (eq gnus-read-active-file 'some)
14806 (gnus-check-backend-function 'retrieve-groups (car method)))
14807 (let ((newsrc (cdr gnus-newsrc-alist))
14808 (gmethod (gnus-server-get-method nil method))
14811 (and (gnus-server-equal
14812 (gnus-find-method-for-group
14813 (car (car newsrc)) (car newsrc))
14815 (setq groups (cons (gnus-group-real-name
14816 (car (car newsrc))) groups)))
14817 (setq newsrc (cdr newsrc)))
14818 (gnus-check-server method)
14819 (setq list-type (gnus-retrieve-groups groups method))
14823 1 "Cannot read partial active file from %s server."
14827 ((eq list-type 'active)
14828 (gnus-active-to-gnus-format method gnus-active-hashtb))
14830 (gnus-groups-to-gnus-format method gnus-active-hashtb)))))
14832 (if (not (gnus-request-list method))
14834 (gnus-message 1 "Cannot read active file from %s server."
14837 (gnus-active-to-gnus-format method)
14838 ;; We mark this active file as read.
14839 (setq gnus-have-read-active-file
14840 (cons method gnus-have-read-active-file))
14841 (gnus-message 5 "%sdone" mesg))))))
14842 (setq methods (cdr methods))))))
14844 ;; Read an active file and place the results in `gnus-active-hashtb'.
14845 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
14847 (setq method gnus-select-method))
14848 (let ((cur (current-buffer))
14850 (if (and gnus-active-hashtb
14851 (not (equal method gnus-select-method)))
14853 (setq gnus-active-hashtb
14854 (if (equal method gnus-select-method)
14855 (gnus-make-hashtable
14856 (count-lines (point-min) (point-max)))
14857 (gnus-make-hashtable 4096))))))
14858 (flag-hashtb (gnus-make-hashtable 60)))
14859 ;; Delete unnecessary lines.
14860 (goto-char (point-min))
14861 (while (search-forward "\nto." nil t)
14862 (delete-region (1+ (match-beginning 0))
14863 (progn (forward-line 1) (point))))
14864 (or (string= gnus-ignored-newsgroups "")
14866 (goto-char (point-min))
14867 (delete-matching-lines gnus-ignored-newsgroups)))
14868 ;; Make the group names readable as a lisp expression even if they
14869 ;; contain special characters.
14870 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
14871 (goto-char (point-max))
14872 (while (re-search-backward "[][';?()#]" nil t)
14874 ;; If these are groups from a foreign select method, we insert the
14875 ;; group prefix in front of the group names.
14876 (and method (not (gnus-server-equal
14877 (gnus-server-get-method nil method)
14878 (gnus-server-get-method nil gnus-select-method)))
14879 (let ((prefix (gnus-group-prefixed-name "" method)))
14880 (goto-char (point-min))
14881 (while (and (not (eobp))
14882 (progn (insert prefix)
14883 (zerop (forward-line 1)))))))
14884 ;; Store the active file in a hash table.
14885 (goto-char (point-min))
14886 (if (string-match "%[oO]" gnus-group-line-format)
14887 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
14888 ;; If we want information on moderated groups, we use this
14890 (let* ((mod-hashtb (make-vector 7 0))
14891 (m (intern "m" mod-hashtb))
14893 (while (not (eobp))
14894 (condition-case nil
14896 (narrow-to-region (point) (gnus-point-at-eol))
14897 (setq group (let ((obarray hashtb)) (read cur)))
14898 (if (and (numberp (setq max (read cur)))
14899 (numberp (setq min (read cur)))
14901 (skip-chars-forward " \t")
14903 (or (= (following-char) ?=)
14904 (= (following-char) ?x)
14905 (= (following-char) ?j)))))
14906 (set group (cons min max))
14908 ;; Enter moderated groups into a list.
14909 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
14910 (setq gnus-moderated-list
14911 (cons (symbol-name group) gnus-moderated-list))))
14918 ;; And if we do not care about moderation, we use this loop,
14919 ;; which is faster.
14920 (let (group max min)
14921 (while (not (eobp))
14924 (narrow-to-region (point) (gnus-point-at-eol))
14925 ;; group gets set to a symbol interned in the hash table
14926 ;; (what a hack!!) - jwz
14927 (setq group (let ((obarray hashtb)) (read cur)))
14928 (if (and (numberp (setq max (read cur)))
14929 (numberp (setq min (read cur)))
14931 (skip-chars-forward " \t")
14933 (or (= (following-char) ?=)
14934 (= (following-char) ?x)
14935 (= (following-char) ?j)))))
14936 (set group (cons min max))
14944 (gnus-message 3 "Warning - illegal active: %s"
14946 (gnus-point-at-bol) (gnus-point-at-eol)))))))
14948 (forward-line 1))))))
14950 (defun gnus-groups-to-gnus-format (method &optional hashtb)
14951 ;; Parse a "groups" active file.
14952 (let ((cur (current-buffer))
14954 (if (and method gnus-active-hashtb)
14956 (setq gnus-active-hashtb
14957 (gnus-make-hashtable
14958 (count-lines (point-min) (point-max)))))))
14959 (prefix (and method
14960 (not (gnus-server-equal
14961 (gnus-server-get-method nil method)
14962 (gnus-server-get-method nil gnus-select-method)))
14963 (gnus-group-prefixed-name "" method))))
14965 (goto-char (point-min))
14966 ;; We split this into to separate loops, one with the prefix
14967 ;; and one without to speed the reading up somewhat.
14969 (let (min max opoint group)
14970 (while (not (eobp))
14973 (read cur) (read cur)
14974 (setq min (read cur)
14977 (skip-chars-forward " \t")
14980 (set (let ((obarray hashtb)) (read cur))
14982 (error (and group (symbolp group) (set group nil))))
14984 (let (min max group)
14985 (while (not (eobp))
14987 (if (= (following-char) ?2)
14989 (read cur) (read cur)
14990 (setq min (read cur)
14992 (set (setq group (let ((obarray hashtb)) (read cur)))
14994 (error (and group (symbolp group) (set group nil))))
14995 (forward-line 1))))))
14997 (defun gnus-read-newsrc-file (&optional force)
14998 "Read startup file.
14999 If FORCE is non-nil, the .newsrc file is read."
15000 ;; Reset variables that might be defined in the .newsrc.eld file.
15001 (let ((variables gnus-variable-list))
15003 (set (car variables) nil)
15004 (setq variables (cdr variables))))
15005 (let* ((newsrc-file gnus-current-startup-file)
15006 (quick-file (concat newsrc-file ".el")))
15008 ;; We always load the .newsrc.eld file. If always contains
15009 ;; much information that can not be gotten from the .newsrc
15010 ;; file (ticked articles, killed groups, foreign methods, etc.)
15011 (gnus-read-newsrc-el-file quick-file)
15014 (and (file-newer-than-file-p newsrc-file quick-file)
15015 (file-newer-than-file-p newsrc-file
15016 (concat quick-file "d")))
15017 (not gnus-newsrc-alist))
15018 ;; We read the .newsrc file. Note that if there if a
15019 ;; .newsrc.eld file exists, it has already been read, and
15020 ;; the `gnus-newsrc-hashtb' has been created. While reading
15021 ;; the .newsrc file, Gnus will only use the information it
15022 ;; can find there for changing the data already read -
15023 ;; ie. reading the .newsrc file will not trash the data
15024 ;; already read (except for read articles).
15026 (gnus-message 5 "Reading %s..." newsrc-file)
15027 (set-buffer (find-file-noselect newsrc-file))
15028 (buffer-disable-undo (current-buffer))
15029 (gnus-newsrc-to-gnus-format)
15030 (kill-buffer (current-buffer))
15031 (gnus-message 5 "Reading %s...done" newsrc-file)))
15033 ;; Read any slave files.
15035 (gnus-master-read-slave-newsrc)))))
15037 (defun gnus-read-newsrc-el-file (file)
15038 (let ((ding-file (concat file "d")))
15039 ;; We always, always read the .eld file.
15040 (gnus-message 5 "Reading %s..." ding-file)
15041 (let (gnus-newsrc-assoc)
15042 (condition-case nil
15043 (load ding-file t t t)
15045 (gnus-message 1 "Error in %s" ding-file)
15047 (when gnus-newsrc-assoc
15048 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
15049 (gnus-make-hashtable-from-newsrc-alist)
15050 (when (file-newer-than-file-p file ding-file)
15051 ;; Old format quick file
15052 (gnus-message 5 "Reading %s..." file)
15053 ;; The .el file is newer than the .eld file, so we read that one
15055 (gnus-read-old-newsrc-el-file file))))
15057 ;; Parse the old-style quick startup file
15058 (defun gnus-read-old-newsrc-el-file (file)
15059 (let (newsrc killed marked group m)
15061 (let ((gnus-killed-assoc nil)
15062 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
15064 (condition-case nil
15067 (setq newsrc gnus-newsrc-assoc
15068 killed gnus-killed-assoc
15069 marked gnus-marked-assoc)))
15070 (setq gnus-newsrc-alist nil)
15072 (setq group (car newsrc))
15073 (let ((info (gnus-get-info (car group))))
15076 (gnus-info-set-read info (cdr (cdr group)))
15077 (gnus-info-set-level
15078 info (if (nth 1 group) gnus-level-default-subscribed
15079 gnus-level-default-unsubscribed))
15080 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
15081 (setq gnus-newsrc-alist
15085 (if (nth 1 group) gnus-level-default-subscribed
15086 gnus-level-default-unsubscribed)
15087 (cdr (cdr group))))
15088 gnus-newsrc-alist)))
15089 (if (setq m (assoc (car group) marked))
15090 (gnus-info-set-marks
15091 info (cons (list (cons 'tick (gnus-compress-sequence
15092 (sort (cdr m) '<) t)))
15094 (setq newsrc (cdr newsrc)))
15095 (setq newsrc killed)
15097 (setcar newsrc (car (car newsrc)))
15098 (setq newsrc (cdr newsrc)))
15099 (setq gnus-killed-list killed))
15100 ;; The .el file version of this variable does not begin with
15101 ;; "options", while the .eld version does, so we just add it if it
15104 gnus-newsrc-options
15106 (and (not (string-match "^ *options" gnus-newsrc-options))
15107 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
15108 (and (not (string-match "\n$" gnus-newsrc-options))
15109 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
15110 ;; Finally, if we read some options lines, we parse them.
15111 (or (string= gnus-newsrc-options "")
15112 (gnus-newsrc-parse-options gnus-newsrc-options))))
15114 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
15115 (gnus-make-hashtable-from-newsrc-alist)))
15117 (defun gnus-make-newsrc-file (file)
15118 "Make server dependent file name by catenating FILE and server host name."
15119 (let* ((file (expand-file-name file nil))
15120 (real-file (concat file "-" (nth 1 gnus-select-method))))
15121 (if (or (file-exists-p real-file)
15122 (file-exists-p (concat real-file ".el"))
15123 (file-exists-p (concat real-file ".eld")))
15126 (defun gnus-newsrc-to-gnus-format ()
15127 (setq gnus-newsrc-options "")
15128 (setq gnus-newsrc-options-n nil)
15130 (or gnus-active-hashtb
15131 (setq gnus-active-hashtb (make-vector 4095 0)))
15132 (let ((buf (current-buffer))
15133 (already-read (> (length gnus-newsrc-alist) 1))
15134 group subscribed options-symbol newsrc Options-symbol
15136 (goto-char (point-min))
15137 ;; We intern the symbol `options' in the active hashtb so that we
15138 ;; can `eq' against it later.
15139 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
15140 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
15142 (while (not (eobp))
15143 ;; We first read the first word on the line by narrowing and
15144 ;; then reading into `gnus-active-hashtb'. Most groups will
15145 ;; already exist in that hashtb, so this will save some string
15149 (progn (skip-chars-forward "^ \t!:\n") (point)))
15150 (goto-char (point-min))
15152 (and (/= (point-min) (point-max))
15153 (let ((obarray gnus-active-hashtb)) (read buf))))
15155 ;; Now, the symbol we have read is either `options' or a group
15156 ;; name. If it is an options line, we just add it to a string.
15158 ((or (eq symbol options-symbol)
15159 (eq symbol Options-symbol))
15160 (setq gnus-newsrc-options
15161 ;; This concatting is quite inefficient, but since our
15162 ;; thorough studies show that approx 99.37% of all
15163 ;; .newsrc files only contain a single options line, we
15164 ;; don't give a damn, frankly, my dear.
15165 (concat gnus-newsrc-options
15167 (gnus-point-at-bol)
15168 ;; Options may continue on the next line.
15169 (or (and (re-search-forward "^[^ \t]" nil 'move)
15170 (progn (beginning-of-line) (point)))
15174 (or (boundp symbol) (set symbol nil))
15175 ;; It was a group name.
15176 (setq subscribed (= (following-char) ?:)
15177 group (symbol-name symbol)
15180 ;; If the line ends here, this is clearly a buggy line, so
15181 ;; we put point a the beginning of line and let the cond
15182 ;; below do the error handling.
15183 (beginning-of-line)
15184 ;; We skip to the beginning of the ranges.
15185 (skip-chars-forward "!: \t"))
15186 ;; We are now at the beginning of the list of read articles.
15187 ;; We read them range by range.
15190 ((looking-at "[0-9]+")
15191 ;; We narrow and read a number instead of buffer-substring/
15192 ;; string-to-int because it's faster. narrow/widen is
15193 ;; faster than save-restriction/narrow, and save-restriction
15194 ;; produces a garbage object.
15196 (narrow-to-region (match-beginning 0) (match-end 0))
15199 ;; If the next character is a dash, then this is a range.
15200 (if (= (following-char) ?-)
15202 ;; We read the upper bound of the range.
15204 (if (not (looking-at "[0-9]+"))
15205 ;; This is a buggy line, by we pretend that
15206 ;; it's kinda OK. Perhaps the user should be
15208 (setq reads (cons num1 reads))
15213 (narrow-to-region (match-beginning 0)
15218 ;; It was just a simple number, so we add it to the
15220 (setq reads (cons num1 reads)))
15221 ;; If the next char in ?\n, then we have reached the end
15222 ;; of the line and return nil.
15223 (/= (following-char) ?\n))
15224 ((= (following-char) ?\n)
15225 ;; End of line, so we end.
15228 ;; Not numbers and not eol, so this might be a buggy
15231 ;; If it was eob instead of ?\n, we allow it.
15233 ;; The line was buggy.
15235 (gnus-message 3 "Mangled line: %s"
15236 (buffer-substring (gnus-point-at-bol)
15237 (gnus-point-at-eol)))
15241 ;; Skip past ", ". Spaces are illegal in these ranges, but
15242 ;; we allow them, because it's a common mistake to put a
15243 ;; space after the comma.
15244 (skip-chars-forward ", "))
15246 ;; We have already read .newsrc.eld, so we gently update the
15247 ;; data in the hash table with the information we have just
15250 (let ((info (gnus-get-info group))
15253 ;; There is an entry for this file in the alist.
15255 (gnus-info-set-read info (nreverse reads))
15256 ;; We update the level very gently. In fact, we
15257 ;; only change it if there's been a status change
15258 ;; from subscribed to unsubscribed, or vice versa.
15259 (setq level (gnus-info-level info))
15260 (cond ((and (<= level gnus-level-subscribed)
15262 (setq level (if reads
15263 gnus-level-default-unsubscribed
15264 (1+ gnus-level-default-unsubscribed))))
15265 ((and (> level gnus-level-subscribed) subscribed)
15266 (setq level gnus-level-default-subscribed)))
15267 (gnus-info-set-level info level))
15268 ;; This is a new group.
15269 (setq info (list group
15271 gnus-level-default-subscribed
15273 (1+ gnus-level-subscribed)
15274 gnus-level-default-unsubscribed))
15275 (nreverse reads))))
15276 (setq newsrc (cons info newsrc))))))
15279 (setq newsrc (nreverse newsrc))
15281 (if (not already-read)
15283 ;; We now have two newsrc lists - `newsrc', which is what we
15284 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
15285 ;; what we've read from .newsrc.eld. We have to merge these
15286 ;; lists. We do this by "attaching" any (foreign) groups in the
15287 ;; gnus-newsrc-alist to the (native) group that precedes them.
15288 (let ((rc (cdr gnus-newsrc-alist))
15289 (prev gnus-newsrc-alist)
15292 (or (null (nth 4 (car rc))) ; It's a native group.
15293 (assoc (car (car rc)) newsrc) ; It's already in the alist.
15294 (if (setq entry (assoc (car (car prev)) newsrc))
15295 (setcdr (setq mentry (memq entry newsrc))
15296 (cons (car rc) (cdr mentry)))
15297 (setq newsrc (cons (car rc) newsrc))))
15301 (setq gnus-newsrc-alist newsrc)
15302 ;; We make the newsrc hashtb.
15303 (gnus-make-hashtable-from-newsrc-alist)
15305 ;; Finally, if we read some options lines, we parse them.
15306 (or (string= gnus-newsrc-options "")
15307 (gnus-newsrc-parse-options gnus-newsrc-options))))
15309 ;; Parse options lines to find "options -n !all rec.all" and stuff.
15310 ;; The return value will be a list on the form
15311 ;; ((regexp1 . ignore)
15312 ;; (regexp2 . subscribe)...)
15313 ;; When handling new newsgroups, groups that match a `ignore' regexp
15314 ;; will be ignored, and groups that match a `subscribe' regexp will be
15315 ;; subscribed. A line like
15316 ;; options -n !all rec.all
15317 ;; will lead to a list that looks like
15318 ;; (("^rec\\..+" . subscribe)
15319 ;; ("^.+" . ignore))
15320 ;; So all "rec.*" groups will be subscribed, while all the other
15321 ;; groups will be ignored. Note that "options -n !all rec.all" is very
15322 ;; different from "options -n rec.all !all".
15323 (defun gnus-newsrc-parse-options (options)
15326 (gnus-set-work-buffer)
15327 (insert (regexp-quote options))
15328 ;; First we treat all continuation lines.
15329 (goto-char (point-min))
15330 (while (re-search-forward "\n[ \t]+" nil t)
15331 (replace-match " " t t))
15332 ;; Then we transform all "all"s into ".+"s.
15333 (goto-char (point-min))
15334 (while (re-search-forward "\\ball\\b" nil t)
15335 (replace-match ".+" t t))
15336 (goto-char (point-min))
15337 ;; We remove all other options than the "-n" ones.
15338 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
15339 (replace-match " ")
15341 (goto-char (point-min))
15343 ;; We are only interested in "options -n" lines - we
15344 ;; ignore the other option lines.
15345 (while (re-search-forward "[ \t]-n" nil t)
15347 (or (save-excursion
15348 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
15350 (gnus-point-at-eol)))
15351 ;; Search for all "words"...
15352 (while (re-search-forward "[^ \t,\n]+" eol t)
15353 (if (= (char-after (match-beginning 0)) ?!)
15354 ;; If the word begins with a bang (!), this is a "not"
15355 ;; spec. We put this spec (minus the bang) and the
15356 ;; symbol `ignore' into the list.
15357 (setq out (cons (cons (concat
15358 "^" (buffer-substring
15359 (1+ (match-beginning 0))
15362 ;; There was no bang, so this is a "yes" spec.
15363 (setq out (cons (cons (concat "^" (match-string 0))
15364 'subscribe) out)))))
15366 (setq gnus-newsrc-options-n out))))
15368 (defun gnus-save-newsrc-file (&optional force)
15369 "Save .newsrc file."
15370 ;; Note: We cannot save .newsrc file if all newsgroups are removed
15371 ;; from the variable gnus-newsrc-alist.
15372 (when (and (or gnus-newsrc-alist gnus-killed-list)
15373 gnus-current-startup-file)
15375 (if (and (or gnus-use-dribble-file gnus-slave)
15377 (or (not gnus-dribble-buffer)
15378 (not (buffer-name gnus-dribble-buffer))
15379 (zerop (save-excursion
15380 (set-buffer gnus-dribble-buffer)
15382 (gnus-message 4 "(No changes need to be saved)")
15383 (run-hooks 'gnus-save-newsrc-hook)
15385 (gnus-slave-save-newsrc)
15387 (when gnus-save-newsrc-file
15388 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
15389 (gnus-gnus-to-newsrc-format)
15390 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
15391 ;; Save .newsrc.eld.
15392 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
15393 (make-local-variable 'version-control)
15394 (setq version-control 'never)
15395 (setq buffer-file-name
15396 (concat gnus-current-startup-file ".eld"))
15397 (gnus-add-current-to-buffer-list)
15398 (buffer-disable-undo (current-buffer))
15400 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
15401 (gnus-gnus-to-quick-newsrc-format)
15402 (run-hooks 'gnus-save-quick-newsrc-hook)
15404 (kill-buffer (current-buffer))
15406 5 "Saving %s.eld...done" gnus-current-startup-file))
15407 (gnus-dribble-delete-file)))))
15409 (defun gnus-gnus-to-quick-newsrc-format ()
15410 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
15411 (insert ";; Gnus startup file.\n")
15412 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
15413 (insert ";; to read .newsrc.\n")
15414 (insert "(setq gnus-newsrc-file-version "
15415 (prin1-to-string gnus-version) ")\n")
15417 (if gnus-save-killed-list gnus-variable-list
15418 ;; Remove the `gnus-killed-list' from the list of variables
15419 ;; to be saved, if required.
15420 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
15421 ;; Peel off the "dummy" group.
15422 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
15424 ;; Insert the variables into the file.
15426 (when (and (boundp (setq variable (pop variables)))
15427 (symbol-value variable))
15428 (insert "(setq " (symbol-name variable) " '"
15429 (prin1-to-string (symbol-value variable)) ")\n")))))
15431 (defun gnus-gnus-to-newsrc-format ()
15432 ;; Generate and save the .newsrc file.
15433 (let ((newsrc (cdr gnus-newsrc-alist))
15436 (set-buffer (create-file-buffer gnus-current-startup-file))
15437 (setq buffer-file-name gnus-current-startup-file)
15438 (buffer-disable-undo (current-buffer))
15441 (if gnus-newsrc-options (insert gnus-newsrc-options))
15442 ;; Write subscribed and unsubscribed.
15444 (setq info (car newsrc))
15445 (if (not (gnus-info-method info))
15446 ;; Don't write foreign groups to .newsrc.
15448 (insert (gnus-info-group info)
15449 (if (> (gnus-info-level info) gnus-level-subscribed)
15451 (if (setq ranges (gnus-info-read info))
15454 (if (not (listp (cdr ranges)))
15455 (if (= (car ranges) (cdr ranges))
15456 (insert (int-to-string (car ranges)))
15457 (insert (int-to-string (car ranges)) "-"
15458 (int-to-string (cdr ranges))))
15460 (setq range (car ranges)
15461 ranges (cdr ranges))
15462 (if (or (atom range) (= (car range) (cdr range)))
15463 (insert (int-to-string
15464 (or (and (atom range) range)
15466 (insert (int-to-string (car range)) "-"
15467 (int-to-string (cdr range))))
15468 (if ranges (insert ","))))))
15470 (setq newsrc (cdr newsrc)))
15471 (make-local-variable 'version-control)
15472 (setq version-control 'never)
15473 ;; It has been reported that sometime the modtime on the .newsrc
15474 ;; file seems to be off. We really do want to overwrite it, so
15475 ;; we clear the modtime here before saving. It's a bit odd,
15477 ;; sometimes the modtime clear isn't sufficient. most brute force:
15478 ;; delete the silly thing entirely first. but this fails to provide
15479 ;; such niceties as .newsrc~ creation.
15480 (if gnus-modtime-botch
15481 (delete-file gnus-startup-file)
15482 (clear-visited-file-modtime))
15483 (run-hooks 'gnus-save-standard-newsrc-hook)
15485 (kill-buffer (current-buffer)))))
15488 ;;; Slave functions.
15490 (defun gnus-slave-save-newsrc ()
15492 (set-buffer gnus-dribble-buffer)
15494 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
15495 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
15497 (defun gnus-master-read-slave-newsrc ()
15500 (file-name-directory gnus-current-startup-file)
15504 (file-name-nondirectory gnus-current-startup-file)
15508 (if (not slave-files)
15509 () ; There are no slave files to read.
15510 (gnus-message 7 "Reading slave newsrcs...")
15512 (set-buffer (get-buffer-create " *gnus slave*"))
15513 (buffer-disable-undo (current-buffer))
15515 (sort (mapcar (lambda (file)
15516 (list (nth 5 (file-attributes file)) file))
15519 (or (< (car (car f1)) (car (car f2)))
15520 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
15523 (setq file (nth 1 (car slave-files)))
15524 (insert-file-contents file)
15525 (if (condition-case ()
15527 (eval-buffer (current-buffer))
15530 (gnus-message 3 "Possible error in %s" file)
15534 (or gnus-slave ; Slaves shouldn't delete these files.
15538 (setq slave-files (cdr slave-files))))
15539 (gnus-message 7 "Reading slave newsrcs...done"))))
15542 ;;; Group description.
15544 (defun gnus-read-all-descriptions-files ()
15545 (let ((methods (cons gnus-select-method gnus-secondary-select-methods)))
15547 (gnus-read-descriptions-file (car methods))
15548 (setq methods (cdr methods)))
15551 (defun gnus-read-descriptions-file (&optional method)
15552 (let ((method (or method gnus-select-method)))
15553 ;; We create the hashtable whether we manage to read the desc file
15554 ;; to avoid trying to re-read after a failed read.
15555 (or gnus-description-hashtb
15556 (setq gnus-description-hashtb
15557 (gnus-make-hashtable (length gnus-active-hashtb))))
15558 ;; Mark this method's desc file as read.
15559 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
15560 gnus-description-hashtb)
15562 (gnus-message 5 "Reading descriptions file via %s..." (car method))
15564 ((not (gnus-check-server method))
15565 (gnus-message 1 "Couldn't open server")
15567 ((not (gnus-request-list-newsgroups method))
15568 (gnus-message 1 "Couldn't read newsgroups descriptions")
15574 (set-buffer nntp-server-buffer)
15575 (goto-char (point-min))
15576 (if (or (search-forward "\n.\n" nil t)
15577 (goto-char (point-max)))
15579 (beginning-of-line)
15580 (narrow-to-region (point-min) (point))))
15581 (goto-char (point-min))
15582 (while (not (eobp))
15583 ;; If we get an error, we set group to 0, which is not a
15587 (let ((obarray gnus-description-hashtb))
15588 ;; Group is set to a symbol interned in this
15590 (read nntp-server-buffer))
15592 (skip-chars-forward " \t")
15593 ;; ... which leads to this line being effectively ignored.
15594 (and (symbolp group)
15595 (set group (buffer-substring
15596 (point) (progn (end-of-line) (point)))))
15597 (forward-line 1))))
15598 (gnus-message 5 "Reading descriptions file...done")
15601 (defun gnus-group-get-description (group)
15602 "Get the description of a group by sending XGTITLE to the server."
15603 (when (gnus-request-group-description group)
15605 (set-buffer nntp-server-buffer)
15606 (goto-char (point-min))
15607 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
15608 (match-string 1)))))
15611 ;;; Buffering of read articles.
15614 (defvar gnus-backlog-buffer " *Gnus Backlog*")
15615 (defvar gnus-backlog-articles nil)
15616 (defvar gnus-backlog-hashtb nil)
15618 (defun gnus-backlog-buffer ()
15619 "Return the backlog buffer."
15620 (or (get-buffer gnus-backlog-buffer)
15622 (set-buffer (get-buffer-create gnus-backlog-buffer))
15623 (buffer-disable-undo (current-buffer))
15624 (setq buffer-read-only t)
15625 (gnus-add-current-to-buffer-list)
15626 (get-buffer gnus-backlog-buffer))))
15628 (defun gnus-backlog-setup ()
15629 "Initialize backlog variables."
15630 (unless gnus-backlog-hashtb
15631 (setq gnus-backlog-hashtb (make-vector 1023 0))))
15633 (defun gnus-backlog-shutdown ()
15634 "Clear all backlog variables and buffers."
15635 (when (get-buffer gnus-backlog-buffer)
15636 (kill-buffer gnus-backlog-buffer))
15637 (setq gnus-backlog-hashtb nil
15638 gnus-backlog-articles nil))
15640 (defun gnus-backlog-enter-article (group number buffer)
15641 (gnus-backlog-setup)
15642 (let ((ident (intern (concat group ":" (int-to-string number))
15643 gnus-backlog-hashtb))
15645 (if (memq ident gnus-backlog-articles)
15646 () ; It's already kept.
15647 ;; Remove the oldest article, if necessary.
15648 (and (numberp gnus-keep-backlog)
15649 (>= (length gnus-backlog-articles) gnus-keep-backlog)
15650 (gnus-backlog-remove-oldest-article))
15651 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
15652 ;; Insert the new article.
15654 (set-buffer (gnus-backlog-buffer))
15655 (let (buffer-read-only)
15656 (goto-char (point-max))
15657 (or (bolp) (insert "\n"))
15659 (insert-buffer-substring buffer)
15660 ;; Tag the beginning of the article with the ident.
15661 (put-text-property b (1+ b) 'gnus-backlog ident))))))
15663 (defun gnus-backlog-remove-oldest-article ()
15665 (set-buffer (gnus-backlog-buffer))
15666 (goto-char (point-min))
15667 (if (zerop (buffer-size))
15668 () ; The buffer is empty.
15669 (let ((ident (get-text-property (point) 'gnus-backlog))
15671 ;; Remove the ident from the list of articles.
15673 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
15674 ;; Delete the article itself.
15676 (point) (next-single-property-change
15677 (1+ (point)) 'gnus-backlog nil (point-max)))))))
15679 (defun gnus-backlog-request-article (group number buffer)
15680 (gnus-backlog-setup)
15681 (let ((ident (intern (concat group ":" (int-to-string number))
15682 gnus-backlog-hashtb))
15684 (when (memq ident gnus-backlog-articles)
15685 ;; It was in the backlog.
15687 (set-buffer (gnus-backlog-buffer))
15688 (if (not (setq beg (text-property-any
15689 (point-min) (point-max) 'gnus-backlog
15691 ;; It wasn't in the backlog after all.
15693 (setq gnus-backlog-articles (delq ident gnus-backlog-articles))
15695 ;; Find the end (i. e., the beginning of the next article).
15697 (next-single-property-change
15698 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
15699 (let ((buffer-read-only nil))
15701 (insert-buffer-substring gnus-backlog-buffer beg end)
15704 ;; Allow redefinition of Gnus functions.
15706 (gnus-ems-redefine)
15710 ;;; gnus.el ends here