1 ;;; gnus.el --- a newsreader for GNU Emacs
2 ;; Copyright (C) 1987,88,89,90,93,94,95,96 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 the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval '(run-hooks 'gnus-load-hook))
35 (eval-when-compile (require 'cl))
37 ;; Site dependent variables. These variables should be defined in
40 (defvar gnus-default-nntp-server nil
41 "Specify a default NNTP server.
42 This variable should be defined in paths.el, and should never be set
44 If you want to change servers, you should use `gnus-select-method'.
45 See the documentation to that variable.")
47 (defvar gnus-backup-default-subscribed-newsgroups
48 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
49 "Default default new newsgroups the first time Gnus is run.
50 Should be set in paths.el, and shouldn't be touched by the user.")
52 (defvar gnus-local-domain nil
53 "Local domain name without a host name.
54 The DOMAINNAME environment variable is used instead if it is defined.
55 If the `system-name' function returns the full Internet name, there is
56 no need to set this variable.")
58 (defvar gnus-local-organization nil
59 "String with a description of what organization (if any) the user belongs to.
60 The ORGANIZATION environment variable is used instead if it is defined.
61 If this variable contains a function, this function will be called
62 with the current newsgroup name as the argument. The function should
65 In any case, if the string (either in the variable, in the environment
66 variable, or returned by the function) is a file name, the contents of
67 this file will be used as the organization.")
69 ;; Customization variables
71 ;; Don't touch this variable.
72 (defvar gnus-nntp-service "nntp"
73 "*NNTP service name (\"nntp\" or 119).
74 This is an obsolete variable, which is scarcely used. If you use an
75 nntp server for your newsgroup and want to change the port number
76 used to 899, you would say something along these lines:
78 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
80 (defvar gnus-nntpserver-file "/etc/nntpserver"
81 "*A file with only the name of the nntp server in it.")
83 ;; This function is used to check both the environment variable
84 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
85 ;; an nntp server name default.
86 (defun gnus-getenv-nntpserver ()
87 (or (getenv "NNTPSERVER")
88 (and (file-readable-p gnus-nntpserver-file)
90 (set-buffer (get-buffer-create " *gnus nntp*"))
91 (buffer-disable-undo (current-buffer))
92 (insert-file-contents gnus-nntpserver-file)
93 (let ((name (buffer-string)))
95 (if (string-match "^[ \t\n]*$" name)
98 (kill-buffer (current-buffer))))))))
100 (defvar gnus-select-method
102 (list 'nntp (or (condition-case ()
103 (gnus-getenv-nntpserver)
105 (if (and gnus-default-nntp-server
106 (not (string= gnus-default-nntp-server "")))
107 gnus-default-nntp-server)
109 (if (or (null gnus-nntp-service)
110 (equal gnus-nntp-service "nntp"))
112 (list gnus-nntp-service)))
113 "*Default method for selecting a newsgroup.
114 This variable should be a list, where the first element is how the
115 news is to be fetched, the second is the address.
117 For instance, if you want to get your news via NNTP from
118 \"flab.flab.edu\", you could say:
120 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
122 If you want to use your local spool, say:
124 (setq gnus-select-method (list 'nnspool (system-name)))
126 If you use this variable, you must set `gnus-nntp-server' to nil.
128 There is a lot more to know about select methods and virtual servers -
129 see the manual for details.")
131 (defvar gnus-message-archive-method
132 '(nnfolder "archive" (nnfolder-directory "~/Mail/archive/")
133 (nnfolder-active-file "~/Mail/archive/active")
134 (nnfolder-get-new-mail nil)
135 (nnfolder-inhibit-expiry t))
136 "*Method used for archiving messages you've sent.
137 This should be a mail method.")
139 (defvar gnus-refer-article-method nil
140 "*Preferred method for fetching an article by Message-ID.
141 If you are reading news from the local spool (with nnspool), fetching
142 articles by Message-ID is painfully slow. By setting this method to an
143 nntp method, you might get acceptable results.
145 The value of this variable must be a valid select method as discussed
146 in the documentation of `gnus-select-method'.")
148 (defvar gnus-secondary-select-methods nil
149 "*A list of secondary methods that will be used for reading news.
150 This is a list where each element is a complete select method (see
151 `gnus-select-method').
153 If, for instance, you want to read your mail with the nnml backend,
154 you could set this variable:
156 (setq gnus-secondary-select-methods '((nnml \"\")))")
158 (defvar gnus-secondary-servers nil
159 "*List of NNTP servers that the user can choose between interactively.
160 To make Gnus query you for a server, you have to give `gnus' a
161 non-numeric prefix - `C-u M-x gnus', in short.")
163 (defvar gnus-nntp-server nil
164 "*The name of the host running the NNTP server.
165 This variable is semi-obsolete. Use the `gnus-select-method'
168 (defvar gnus-startup-file "~/.newsrc"
169 "*Your `.newsrc' file.
170 `.newsrc-SERVER' will be used instead if that exists.")
172 (defvar gnus-init-file "~/.gnus"
173 "*Your Gnus elisp startup file.
174 If a file with the .el or .elc suffixes exist, it will be read
177 (defvar gnus-group-faq-directory
178 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
179 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
180 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
181 "/ftp@rtfm.mit.edu:/pub/usenet/news.answers/"
182 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
183 "/ftp@ftp.sunet.se:/pub/usenet/"
184 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
185 "/ftp@hwarang.postech.ac.kr:/pub/usenet/news.answers/"
186 "/ftp@ftp.hk.super.net:/mirror/faqs/")
187 "*Directory where the group FAQs are stored.
188 This will most commonly be on a remote machine, and the file will be
191 This variable can also be a list of directories. In that case, the
192 first element in the list will be used by default, and the others will
193 be used as backup sites.
195 Note that Gnus uses an aol machine as the default directory. If this
196 feels fundamentally unclean, just think of it as a way to finally get
197 something of value back from them.
199 If the default site is too slow, try one of these:
201 North America: mirrors.aol.com /pub/rtfm/usenet
202 ftp.seas.gwu.edu /pub/rtfm
203 rtfm.mit.edu /pub/usenet/news.answers
204 Europe: ftp.uni-paderborn.de /pub/FAQ
205 src.doc.ic.ac.uk /usenet/news-FAQS
206 ftp.sunet.se /pub/usenet
207 Asia: nctuccca.edu.tw /USENET/FAQ
208 hwarang.postech.ac.kr /pub/usenet/news.answers
209 ftp.hk.super.net /mirror/faqs")
211 (defvar gnus-group-archive-directory
212 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
213 "*The address of the (ding) archives.")
215 (defvar gnus-group-recent-archive-directory
216 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
217 "*The address of the most recent (ding) articles.")
219 (defvar gnus-default-subscribed-newsgroups nil
220 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
221 It should be a list of strings.
222 If it is `t', Gnus will not do anything special the first time it is
223 started; it'll just use the normal newsgroups subscription methods.")
225 (defvar gnus-use-cross-reference t
226 "*Non-nil means that cross referenced articles will be marked as read.
227 If nil, ignore cross references. If t, mark articles as read in
228 subscribed newsgroups. If neither t nor nil, mark as read in all
231 (defvar gnus-single-article-buffer t
232 "*If non-nil, display all articles in the same buffer.
233 If nil, each group will get its own article buffer.")
235 (defvar gnus-use-dribble-file t
236 "*Non-nil means that Gnus will use a dribble file to store user updates.
237 If Emacs should crash without saving the .newsrc files, complete
238 information can be restored from the dribble file.")
240 (defvar gnus-dribble-directory nil
241 "*The directory where dribble files will be saved.
242 If this variable is nil, the directory where the .newsrc files are
243 saved will be used.")
245 (defvar gnus-asynchronous nil
246 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
248 (defvar gnus-kill-summary-on-exit t
249 "*If non-nil, kill the summary buffer when you exit from it.
250 If nil, the summary will become a \"*Dead Summary*\" buffer, and
251 it will be killed sometime later.")
253 (defvar gnus-large-newsgroup 200
254 "*The number of articles which indicates a large newsgroup.
255 If the number of articles in a newsgroup is greater than this value,
256 confirmation is required for selecting the newsgroup.")
258 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
259 (defvar gnus-no-groups-message "No news is horrible news"
260 "*Message displayed by Gnus when no groups are available.")
262 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
263 "*Non-nil means that the default name of a file to save articles in is the group name.
264 If it's nil, the directory form of the group name is used instead.
266 If this variable is a list, and the list contains the element
267 `not-score', long file names will not be used for score files; if it
268 contains the element `not-save', long file names will not be used for
269 saving; and if it contains the element `not-kill', long file names
270 will not be used for kill files.")
272 (defvar gnus-article-save-directory (or (getenv "SAVEDIR") "~/News/")
273 "*Name of the directory articles will be saved in (default \"~/News\").
274 Initialized from the SAVEDIR environment variable.")
276 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
277 "*Name of the directory where kill files will be stored (default \"~/News\").
278 Initialized from the SAVEDIR environment variable.")
280 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
281 "*A function to save articles in your favorite format.
282 The function must be interactively callable (in other words, it must
283 be an Emacs command).
285 Gnus provides the following functions:
287 * gnus-summary-save-in-rmail (Rmail format)
288 * gnus-summary-save-in-mail (Unix mail format)
289 * gnus-summary-save-in-folder (MH folder)
290 * gnus-summary-save-in-file (article format).
291 * gnus-summary-save-in-vm (use VM's folder format).")
293 (defvar gnus-prompt-before-saving 'always
294 "*This variable says how much prompting is to be done when saving articles.
295 If it is nil, no prompting will be done, and the articles will be
296 saved to the default files. If this variable is `always', each and
297 every article that is saved will be preceded by a prompt, even when
298 saving large batches of articles. If this variable is neither nil not
299 `always', there the user will be prompted once for a file name for
300 each invocation of the saving commands.")
302 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
303 "*A function generating a file name to save articles in Rmail format.
304 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
306 (defvar gnus-mail-save-name (function gnus-plain-save-name)
307 "*A function generating a file name to save articles in Unix mail format.
308 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
310 (defvar gnus-folder-save-name (function gnus-folder-save-name)
311 "*A function generating a file name to save articles in MH folder.
312 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
314 (defvar gnus-file-save-name (function gnus-numeric-save-name)
315 "*A function generating a file name to save articles in article format.
316 The function is called with NEWSGROUP, HEADERS, and optional
319 (defvar gnus-split-methods
320 '((gnus-article-archive-name))
321 "*Variable used to suggest where articles are to be saved.
322 For instance, if you would like to save articles related to Gnus in
323 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
324 you could set this variable to something like:
326 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
327 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
329 This variable is an alist where the where the key is the match and the
330 value is a list of possible files to save in if the match is non-nil.
332 If the match is a string, it is used as a regexp match on the
333 article. If the match is a symbol, that symbol will be funcalled
334 from the buffer of the article to be saved with the newsgroup as the
335 parameter. If it is a list, it will be evaled in the same buffer.
337 If this form or function returns a string, this string will be used as
338 a possible file name; and if it returns a non-nil list, that list will
339 be used as possible file names.")
341 (defvar gnus-move-split-methods nil
342 "*Variable used to suggest where articles are to be moved to.
343 It uses the same syntax as the `gnus-split-methods' variable.")
345 (defvar gnus-save-score nil
346 "*If non-nil, save group scoring info.")
348 (defvar gnus-use-adaptive-scoring nil
349 "*If non-nil, use some adaptive scoring scheme.")
351 (defvar gnus-use-cache nil
352 "*If nil, Gnus will ignore the article cache.
353 If `passive', it will allow entering (and reading) articles
354 explicitly entered into the cache. If anything else, use the
355 cache to the full extent of the law.")
357 (defvar gnus-use-trees nil
358 "*If non-nil, display a thread tree buffer.")
360 (defvar gnus-use-grouplens nil
361 "*If non-nil, use GroupLens ratings.")
363 (defvar gnus-keep-backlog nil
364 "*If non-nil, Gnus will keep read articles for later re-retrieval.
365 If it is a number N, then Gnus will only keep the last N articles
366 read. If it is neither nil nor a number, Gnus will keep all read
367 articles. This is not a good idea.")
369 (defvar gnus-use-nocem nil
370 "*If non-nil, Gnus will read NoCeM cancel messages.")
372 (defvar gnus-use-demon nil
373 "If non-nil, Gnus might use some demons.")
375 (defvar gnus-use-scoring t
376 "*If non-nil, enable scoring.")
378 (defvar gnus-use-picons nil
379 "*If non-nil, display picons.")
381 (defvar gnus-fetch-old-headers nil
382 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
383 If an unread article in the group refers to an older, already read (or
384 just marked as read) article, the old article will not normally be
385 displayed in the Summary buffer. If this variable is non-nil, Gnus
386 will attempt to grab the headers to the old articles, and thereby
387 build complete threads. If it has the value `some', only enough
388 headers to connect otherwise loose threads will be displayed.
389 This variable can also be a number. In that case, no more than that
390 number of old headers will be fetched.
392 The server has to support NOV for any of this to work.")
395 ;(defvar gnus-visual t
396 ; "*If non-nil, will do various highlighting.
397 ;If nil, no mouse highlights (or any other highlights) will be
398 ;performed. This might speed up Gnus some when generating large group
399 ;and summary buffers.")
401 (defvar gnus-novice-user t
402 "*Non-nil means that you are a usenet novice.
403 If non-nil, verbose messages may be displayed and confirmations may be
406 (defvar gnus-expert-user nil
407 "*Non-nil means that you will never be asked for confirmation about anything.
408 And that means *anything*.")
410 (defvar gnus-verbose 7
411 "*Integer that says how verbose Gnus should be.
412 The higher the number, the more messages Gnus will flash to say what
413 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
414 display most important messages; and at ten, Gnus will keep on
415 jabbering all the time.")
417 (defvar gnus-keep-same-level nil
418 "*Non-nil means that the next newsgroup after the current will be on the same level.
419 When you type, for instance, `n' after reading the last article in the
420 current newsgroup, you will go to the next newsgroup. If this variable
421 is nil, the next newsgroup will be the next from the group
423 If this variable is non-nil, Gnus will either put you in the
424 next newsgroup with the same level, or, if no such newsgroup is
425 available, the next newsgroup with the lowest possible level higher
426 than the current level.
427 If this variable is `best', Gnus will make the next newsgroup the one
428 with the best level.")
430 (defvar gnus-summary-make-false-root 'adopt
431 "*nil means that Gnus won't gather loose threads.
432 If the root of a thread has expired or been read in a previous
433 session, the information necessary to build a complete thread has been
434 lost. Instead of having many small sub-threads from this original thread
435 scattered all over the summary buffer, Gnus can gather them.
437 If non-nil, Gnus will try to gather all loose sub-threads from an
438 original thread into one large thread.
440 If this variable is non-nil, it should be one of `none', `adopt',
443 If this variable is `none', Gnus will not make a false root, but just
444 present the sub-threads after another.
445 If this variable is `dummy', Gnus will create a dummy root that will
446 have all the sub-threads as children.
447 If this variable is `adopt', Gnus will make one of the \"children\"
448 the parent and mark all the step-children as such.
449 If this variable is `empty', the \"children\" are printed with empty
450 subject fields. (Or rather, they will be printed with a string
451 given by the `gnus-summary-same-subject' variable.)")
453 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
454 "*A regexp to match subjects to be excluded from loose thread gathering.
455 As loose thread gathering is done on subjects only, that means that
456 there can be many false gatherings performed. By rooting out certain
457 common subjects, gathering might become saner.")
459 (defvar gnus-summary-gather-subject-limit nil
460 "*Maximum length of subject comparisons when gathering loose threads.
461 Use nil to compare full subjects. Setting this variable to a low
462 number will help gather threads that have been corrupted by
463 newsreaders chopping off subject lines, but it might also mean that
464 unrelated articles that have subject that happen to begin with the
465 same few characters will be incorrectly gathered.
467 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
468 comparing subjects.")
470 (defvar gnus-simplify-ignored-prefixes nil
471 "*Regexp, matches for which are removed from subject lines when simplifying.")
473 (defvar gnus-build-sparse-threads nil
474 "*If non-nil, fill in the gaps in threads.
475 If `some', only fill in the gaps that are needed to tie loose threads
476 together. If `more', fill in all leaf nodes that Gnus can find. If
477 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
479 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
480 "Function used for gathering loose threads.
481 There are two pre-defined functions: `gnus-gather-threads-by-subject',
482 which only takes Subjects into consideration; and
483 `gnus-gather-threads-by-references', which compared the References
484 headers of the articles to find matches.")
486 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
487 (defvar gnus-summary-same-subject ""
488 "*String indicating that the current article has the same subject as the previous.
489 This variable will only be used if the value of
490 `gnus-summary-make-false-root' is `empty'.")
492 (defvar gnus-summary-goto-unread t
493 "*If non-nil, marking commands will go to the next unread article.
494 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
495 whether it is read or not.")
497 (defvar gnus-group-goto-unread t
498 "*If non-nil, movement commands will go to the next unread and subscribed group.")
500 (defvar gnus-goto-next-group-when-activating t
501 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
503 (defvar gnus-check-new-newsgroups t
504 "*Non-nil means that Gnus will add new newsgroups at startup.
505 If this variable is `ask-server', Gnus will ask the server for new
506 groups since the last time it checked. This means that the killed list
507 is no longer necessary, so you could set `gnus-save-killed-list' to
510 A variant is to have this variable be a list of select methods. Gnus
511 will then use the `ask-server' method on all these select methods to
512 query for new groups from all those servers.
515 (setq gnus-check-new-newsgroups
516 '((nntp \"some.server\") (nntp \"other.server\")))
518 If this variable is nil, then you have to tell Gnus explicitly to
519 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
521 (defvar gnus-check-bogus-newsgroups nil
522 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
523 If this variable is nil, then you have to tell Gnus explicitly to
524 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
526 (defvar gnus-read-active-file t
527 "*Non-nil means that Gnus will read the entire active file at startup.
528 If this variable is nil, Gnus will only know about the groups in your
531 If this variable is `some', Gnus will try to only read the relevant
532 parts of the active file from the server. Not all servers support
533 this, and it might be quite slow with other servers, but this should
534 generally be faster than both the t and nil value.
536 If you set this variable to nil or `some', you probably still want to
537 be told about new newsgroups that arrive. To do that, set
538 `gnus-check-new-newsgroups' to `ask-server'. This may not work
539 properly with all servers.")
541 (defvar gnus-level-subscribed 5
542 "*Groups with levels less than or equal to this variable are subscribed.")
544 (defvar gnus-level-unsubscribed 7
545 "*Groups with levels less than or equal to this variable are unsubscribed.
546 Groups with levels less than `gnus-level-subscribed', which should be
547 less than this variable, are subscribed.")
549 (defvar gnus-level-zombie 8
550 "*Groups with this level are zombie groups.")
552 (defvar gnus-level-killed 9
553 "*Groups with this level are killed.")
555 (defvar gnus-level-default-subscribed 3
556 "*New subscribed groups will be subscribed at this level.")
558 (defvar gnus-level-default-unsubscribed 6
559 "*New unsubscribed groups will be unsubscribed at this level.")
561 (defvar gnus-activate-level (1+ gnus-level-subscribed)
562 "*Groups higher than this level won't be activated on startup.
563 Setting this variable to something log might save lots of time when
564 you have many groups that you aren't interested in.")
566 (defvar gnus-activate-foreign-newsgroups 4
567 "*If nil, Gnus will not check foreign newsgroups at startup.
568 If it is non-nil, it should be a number between one and nine. Foreign
569 newsgroups that have a level lower or equal to this number will be
570 activated on startup. For instance, if you want to active all
571 subscribed newsgroups, but not the rest, you'd set this variable to
572 `gnus-level-subscribed'.
574 If you subscribe to lots of newsgroups from different servers, startup
575 might take a while. By setting this variable to nil, you'll save time,
576 but you won't be told how many unread articles there are in the
579 (defvar gnus-save-newsrc-file t
580 "*Non-nil means that Gnus will save the `.newsrc' file.
581 Gnus always saves its own startup file, which is called
582 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
583 be readily understood by other newsreaders. If you don't plan on
584 using other newsreaders, set this variable to nil to save some time on
587 (defvar gnus-save-killed-list t
588 "*If non-nil, save the list of killed groups to the startup file.
589 If you set this variable to nil, you'll save both time (when starting
590 and quitting) and space (both memory and disk), but it will also mean
591 that Gnus has no record of which groups are new and which are old, so
592 the automatic new newsgroups subscription methods become meaningless.
594 You should always set `gnus-check-new-newsgroups' to `ask-server' or
595 nil if you set this variable to nil.")
597 (defvar gnus-interactive-catchup t
598 "*If non-nil, require your confirmation when catching up a group.")
600 (defvar gnus-interactive-post t
601 "*If non-nil, group name will be asked for when posting.")
603 (defvar gnus-interactive-exit t
604 "*If non-nil, require your confirmation when exiting Gnus.")
606 (defvar gnus-kill-killed t
607 "*If non-nil, Gnus will apply kill files to already killed articles.
608 If it is nil, Gnus will never apply kill files to articles that have
609 already been through the scoring process, which might very well save lots
612 (defvar gnus-extract-address-components 'gnus-extract-address-components
613 "*Function for extracting address components from a From header.
614 Two pre-defined function exist: `gnus-extract-address-components',
615 which is the default, quite fast, and too simplistic solution, and
616 `mail-extract-address-components', which works much better, but is
619 (defvar gnus-summary-default-score 0
620 "*Default article score level.
621 If this variable is nil, scoring will be disabled.")
623 (defvar gnus-summary-zcore-fuzz 0
624 "*Fuzziness factor for the zcore in the summary buffer.
625 Articles with scores closer than this to `gnus-summary-default-score'
626 will not be marked.")
628 (defvar gnus-simplify-subject-fuzzy-regexp nil
629 "*Strings to be removed when doing fuzzy matches.
630 This can either be a regular expression or list of regular expressions
631 that will be removed from subject strings if fuzzy subject
632 simplification is selected.")
634 (defvar gnus-permanently-visible-groups nil
635 "*Regexp to match groups that should always be listed in the group buffer.
636 This means that they will still be listed when there are no unread
637 articles in the groups.")
639 (defvar gnus-list-groups-with-ticked-articles t
640 "*If non-nil, list groups that have only ticked articles.
641 If nil, only list groups that have unread articles.")
643 (defvar gnus-group-default-list-level gnus-level-subscribed
644 "*Default listing level.
645 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
647 (defvar gnus-group-use-permanent-levels nil
648 "*If non-nil, once you set a level, Gnus will use this level.")
650 (defvar gnus-group-list-inactive-groups t
651 "*If non-nil, inactive groups will be listed.")
653 (defvar gnus-show-mime nil
654 "*If non-nil, do mime processing of articles.
655 The articles will simply be fed to the function given by
656 `gnus-show-mime-method'.")
658 (defvar gnus-strict-mime t
659 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
661 (defvar gnus-show-mime-method 'metamail-buffer
662 "*Function to process a MIME message.
663 The function is called from the article buffer.")
665 (defvar gnus-decode-encoded-word-method (lambda ())
666 "*Function to decode a MIME encoded-words.
667 The function is called from the article buffer.")
669 (defvar gnus-show-threads t
670 "*If non-nil, display threads in summary mode.")
672 (defvar gnus-thread-hide-subtree nil
673 "*If non-nil, hide all threads initially.
674 If threads are hidden, you have to run the command
675 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
676 to expose hidden threads.")
678 (defvar gnus-thread-hide-killed t
679 "*If non-nil, hide killed threads automatically.")
681 (defvar gnus-thread-ignore-subject nil
682 "*If non-nil, ignore subjects and do all threading based on the Reference header.
683 If nil, which is the default, articles that have different subjects
684 from their parents will start separate threads.")
686 (defvar gnus-thread-operation-ignore-subject t
687 "*If non-nil, subjects will be ignored when doing thread commands.
688 This affects commands like `gnus-summary-kill-thread' and
689 `gnus-summary-lower-thread'.
691 If this variable is nil, articles in the same thread with different
692 subjects will not be included in the operation in question. If this
693 variable is `fuzzy', only articles that have subjects that are fuzzily
694 equal will be included.")
696 (defvar gnus-thread-indent-level 4
697 "*Number that says how much each sub-thread should be indented.")
699 (defvar gnus-ignored-newsgroups
700 (purecopy (mapconcat 'identity
701 '("^to\\." ; not "real" groups
702 "^[0-9. \t]+ " ; all digits in name
703 "[][\"#'()]" ; bogus characters
706 "*A regexp to match uninteresting newsgroups in the active file.
707 Any lines in the active file matching this regular expression are
708 removed from the newsgroup list before anything else is done to it,
709 thus making them effectively non-existent.")
711 (defvar gnus-ignored-headers
712 "^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:"
713 "*All headers that match this regexp will be hidden.
714 This variable can also be a list of regexps of headers to be ignored.
715 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
717 (defvar gnus-visible-headers "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-"
718 "*All headers that do not match this regexp will be hidden.
719 This variable can also be a list of regexp of headers to remain visible.
720 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
722 (defvar gnus-sorted-header-list
723 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
724 "^Cc:" "^Date:" "^Organization:")
725 "*This variable is a list of regular expressions.
726 If it is non-nil, headers that match the regular expressions will
727 be placed first in the article buffer in the sequence specified by
730 (defvar gnus-boring-article-headers
731 '(empty followup-to reply-to)
732 "*Headers that are only to be displayed if they have interesting data.
733 Possible values in this list are `empty', `newsgroups', `followup-to',
734 `reply-to', and `date'.")
736 (defvar gnus-show-all-headers nil
737 "*If non-nil, don't hide any headers.")
739 (defvar gnus-save-all-headers t
740 "*If non-nil, don't remove any headers before saving.")
742 (defvar gnus-saved-headers gnus-visible-headers
743 "*Headers to keep if `gnus-save-all-headers' is nil.
744 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
745 If that variable is nil, however, all headers that match this regexp
746 will be kept while the rest will be deleted before saving.")
748 (defvar gnus-inhibit-startup-message nil
749 "*If non-nil, the startup message will not be displayed.")
751 (defvar gnus-signature-separator "^-- *$"
752 "Regexp matching signature separator.")
754 (defvar gnus-signature-limit nil
755 "Provide a limit to what is considered a signature.
756 If it is a number, no signature may not be longer (in characters) than
757 that number. If it is a function, the function will be called without
758 any parameters, and if it returns nil, there is no signature in the
759 buffer. If it is a string, it will be used as a regexp. If it
760 matches, the text in question is not a signature.")
762 (defvar gnus-auto-extend-newsgroup t
763 "*If non-nil, extend newsgroup forward and backward when requested.")
765 (defvar gnus-auto-select-first t
766 "*If nil, don't select the first unread article when entering a group.
767 If this variable is `best', select the highest-scored unread article
768 in the group. If neither nil nor `best', select the first unread
771 If you want to prevent automatic selection of the first unread article
772 in some newsgroups, set the variable to nil in
773 `gnus-select-group-hook'.")
775 (defvar gnus-auto-select-next t
776 "*If non-nil, offer to go to the next group from the end of the previous.
777 If the value is t and the next newsgroup is empty, Gnus will exit
778 summary mode and go back to group mode. If the value is neither nil
779 nor t, Gnus will select the following unread newsgroup. In
780 particular, if the value is the symbol `quietly', the next unread
781 newsgroup will be selected without any confirmation, and if it is
782 `almost-quietly', the next group will be selected without any
783 confirmation if you are located on the last article in the group.
784 Finally, if this variable is `slightly-quietly', the `Z n' command
785 will go to the next group without confirmation.")
787 (defvar gnus-auto-select-same nil
788 "*If non-nil, select the next article with the same subject.")
790 (defvar gnus-summary-check-current nil
791 "*If non-nil, consider the current article when moving.
792 The \"unread\" movement commands will stay on the same line if the
793 current article is unread.")
795 (defvar gnus-auto-center-summary t
796 "*If non-nil, always center the current summary buffer.
797 In particular, if `vertical' do only vertical recentering. If non-nil
798 and non-`vertical', do both horizontal and vertical recentering.")
800 (defvar gnus-break-pages t
801 "*If non-nil, do page breaking on articles.
802 The page delimiter is specified by the `gnus-page-delimiter'
805 (defvar gnus-page-delimiter "^\^L"
806 "*Regexp describing what to use as article page delimiters.
807 The default value is \"^\^L\", which is a form linefeed at the
808 beginning of a line.")
810 (defvar gnus-use-full-window t
811 "*If non-nil, use the entire Emacs screen.")
813 (defvar gnus-window-configuration nil
814 "Obsolete variable. See `gnus-buffer-configuration'.")
816 (defvar gnus-window-min-width 2
817 "*Minimum width of Gnus buffers.")
819 (defvar gnus-window-min-height 1
820 "*Minimum height of Gnus buffers.")
822 (defvar gnus-buffer-configuration
826 (if gnus-carpal '(group-carpal 4))))
830 (if gnus-carpal '(summary-carpal 4))))
837 (if gnus-carpal '(summary-carpal 4))
839 (vertical ((height . 5) (width . 15)
841 (left . -1) (top . 1))
851 (if gnus-carpal '(summary-carpal 4))
852 (if gnus-use-trees '(tree 0.25))
857 (if gnus-carpal '(server-carpal 2))))
861 (if gnus-carpal '(browse-carpal 2))))
864 (message 1.0 point)))
867 (article 1.0 point)))
878 (edit-group 1.0 point)))
882 (edit-server 1.0 point)))
886 (edit-score 1.0 point)))
893 (message 1.0 point)))
896 (message 1.0 point)))
899 (message 1.0 point)))
903 (message 1.0 point)))
910 (if gnus-carpal '(summary-carpal 4))
911 ("*Shell Command Output*" 1.0)))
915 (message 1.0 point))))
916 "Window configuration for all possible Gnus buffers.
917 This variable is a list of lists. Each of these lists has a NAME and
918 a RULE. The NAMEs are commonsense names like `group', which names a
919 rule used when displaying the group buffer; `summary', which names a
920 rule for what happens when you enter a group and do not display an
921 article buffer; and so on. See the value of this variable for a
922 complete list of NAMEs.
924 Each RULE is a list of vectors. The first element in this vector is
925 the name of the buffer to be displayed; the second element is the
926 percentage of the screen this buffer is to occupy (a number in the
927 0.0-0.99 range); the optional third element is `point', which should
928 be present to denote which buffer point is to go to after making this
929 buffer configuration.")
931 (defvar gnus-window-to-buffer
932 '((group . gnus-group-buffer)
933 (summary . gnus-summary-buffer)
934 (article . gnus-article-buffer)
935 (server . gnus-server-buffer)
936 (browse . "*Gnus Browse Server*")
937 (edit-group . gnus-group-edit-buffer)
938 (edit-server . gnus-server-edit-buffer)
939 (group-carpal . gnus-carpal-group-buffer)
940 (summary-carpal . gnus-carpal-summary-buffer)
941 (server-carpal . gnus-carpal-server-buffer)
942 (browse-carpal . gnus-carpal-browse-buffer)
943 (edit-score . gnus-score-edit-buffer)
944 (message . gnus-message-buffer)
945 (faq . gnus-faq-buffer)
946 (picons . "*Picons*")
947 (tree . gnus-tree-buffer)
948 (info . gnus-info-buffer)
949 (article-copy . gnus-article-copy)
950 (draft . gnus-draft-buffer))
951 "Mapping from short symbols to buffer names or buffer variables.")
953 (defvar gnus-carpal nil
954 "*If non-nil, display clickable icons.")
956 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
957 "*Function called with a group name when new group is detected.
958 A few pre-made functions are supplied: `gnus-subscribe-randomly'
959 inserts new groups at the beginning of the list of groups;
960 `gnus-subscribe-alphabetically' inserts new groups in strict
961 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
962 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
963 for your decision; `gnus-subscribe-killed' kills all new groups.")
965 ;; Suggested by a bug report by Hallvard B Furuseth.
966 ;; <h.b.furuseth@usit.uio.no>.
967 (defvar gnus-subscribe-options-newsgroup-method
968 (function gnus-subscribe-alphabetically)
969 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
970 If, for instance, you want to subscribe to all newsgroups in the
971 \"no\" and \"alt\" hierarchies, you'd put the following in your
974 options -n no.all alt.all
976 Gnus will the subscribe all new newsgroups in these hierarchies with
977 the subscription method in this variable.")
979 (defvar gnus-subscribe-hierarchical-interactive nil
980 "*If non-nil, Gnus will offer to subscribe hierarchically.
981 When a new hierarchy appears, Gnus will ask the user:
983 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
985 If the user pressed `d', Gnus will descend the hierarchy, `y' will
986 subscribe to all newsgroups in the hierarchy and `s' will skip this
987 hierarchy in its entirety.")
989 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
990 "*Function used for sorting the group buffer.
991 This function will be called with group info entries as the arguments
992 for the groups to be sorted. Pre-made functions include
993 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
994 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
995 `gnus-group-sort-by-rank'.
997 This variable can also be a list of sorting functions. In that case,
998 the most significant sort function should be the last function in the
1001 ;; Mark variables suggested by Thomas Michanek
1002 ;; <Thomas.Michanek@telelogic.se>.
1003 (defvar gnus-unread-mark ?
1004 "*Mark used for unread articles.")
1005 (defvar gnus-ticked-mark ?!
1006 "*Mark used for ticked articles.")
1007 (defvar gnus-dormant-mark ??
1008 "*Mark used for dormant articles.")
1009 (defvar gnus-del-mark ?r
1010 "*Mark used for del'd articles.")
1011 (defvar gnus-read-mark ?R
1012 "*Mark used for read articles.")
1013 (defvar gnus-expirable-mark ?E
1014 "*Mark used for expirable articles.")
1015 (defvar gnus-killed-mark ?K
1016 "*Mark used for killed articles.")
1017 (defvar gnus-souped-mark ?F
1018 "*Mark used for killed articles.")
1019 (defvar gnus-kill-file-mark ?X
1020 "*Mark used for articles killed by kill files.")
1021 (defvar gnus-low-score-mark ?Y
1022 "*Mark used for articles with a low score.")
1023 (defvar gnus-catchup-mark ?C
1024 "*Mark used for articles that are caught up.")
1025 (defvar gnus-replied-mark ?A
1026 "*Mark used for articles that have been replied to.")
1027 (defvar gnus-cached-mark ?*
1028 "*Mark used for articles that are in the cache.")
1029 (defvar gnus-saved-mark ?S
1030 "*Mark used for articles that have been saved to.")
1031 (defvar gnus-process-mark ?#
1033 (defvar gnus-ancient-mark ?O
1034 "*Mark used for ancient articles.")
1035 (defvar gnus-sparse-mark ?Q
1036 "*Mark used for sparsely reffed articles.")
1037 (defvar gnus-canceled-mark ?G
1038 "*Mark used for canceled articles.")
1039 (defvar gnus-score-over-mark ?+
1040 "*Score mark used for articles with high scores.")
1041 (defvar gnus-score-below-mark ?-
1042 "*Score mark used for articles with low scores.")
1043 (defvar gnus-empty-thread-mark ?
1044 "*There is no thread under the article.")
1045 (defvar gnus-not-empty-thread-mark ?=
1046 "*There is a thread under the article.")
1048 (defvar gnus-view-pseudo-asynchronously nil
1049 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1051 (defvar gnus-view-pseudos nil
1052 "*If `automatic', pseudo-articles will be viewed automatically.
1053 If `not-confirm', pseudos will be viewed automatically, and the user
1054 will not be asked to confirm the command.")
1056 (defvar gnus-view-pseudos-separately t
1057 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1058 If nil, all files that use the same viewing command will be given as a
1059 list of parameters to that command.")
1061 (defvar gnus-insert-pseudo-articles t
1062 "*If non-nil, insert pseudo-articles when decoding articles.")
1064 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1065 "*Format of group lines.
1066 It works along the same lines as a normal formatting string,
1067 with some simple extensions.
1069 %M Only marked articles (character, \"*\" or \" \")
1070 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1071 %L Level of subscribedness (integer)
1072 %N Number of unread articles (integer)
1073 %I Number of dormant articles (integer)
1074 %i Number of ticked and dormant (integer)
1075 %T Number of ticked articles (integer)
1076 %R Number of read articles (integer)
1077 %t Total number of articles (integer)
1078 %y Number of unread, unticked articles (integer)
1079 %G Group name (string)
1080 %g Qualified group name (string)
1081 %D Group description (string)
1082 %s Select method (string)
1083 %o Moderated group (char, \"m\")
1084 %p Process mark (char)
1085 %O Moderated group (string, \"(m)\" or \"\")
1086 %P Topic indentation (string)
1087 %l Whether there are GroupLens predictions for this group (string)
1088 %n Select from where (string)
1089 %z A string that look like `<%s:%n>' if a foreign select method is used
1090 %u User defined specifier. The next character in the format string should
1091 be a letter. Gnus will call the function gnus-user-format-function-X,
1092 where X is the letter following %u. The function will be passed the
1093 current header as argument. The function should return a string, which
1094 will be inserted into the buffer just like information from any other
1097 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1098 the mouse point move inside the area. There can only be one such area.
1100 Note that this format specification is not always respected. For
1101 reasons of efficiency, when listing killed groups, this specification
1102 is ignored altogether. If the spec is changed considerably, your
1103 output may end up looking strange when listing both alive and killed
1106 If you use %o or %O, reading the active file will be slower and quite
1107 a bit of extra memory will be used. %D will also worsen performance.
1108 Also note that if you change the format specification to include any
1109 of these specs, you must probably re-start Gnus to see them go into
1112 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1113 "*The format specification of the lines in the summary buffer.
1115 It works along the same lines as a normal formatting string,
1116 with some simple extensions.
1118 %N Article number, left padded with spaces (string)
1120 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1121 %n Name of the poster (string)
1122 %a Extracted name of the poster (string)
1123 %A Extracted address of the poster (string)
1124 %F Contents of the From: header (string)
1125 %x Contents of the Xref: header (string)
1126 %D Date of the article (string)
1127 %d Date of the article (string) in DD-MMM format
1128 %M Message-id of the article (string)
1129 %r References of the article (string)
1130 %c Number of characters in the article (integer)
1131 %L Number of lines in the article (integer)
1132 %I Indentation based on thread level (a string of spaces)
1133 %T A string with two possible values: 80 spaces if the article
1134 is on thread level two or larger and 0 spaces on level one
1135 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1136 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1137 %[ Opening bracket (character, \"[\" or \"<\")
1138 %] Closing bracket (character, \"]\" or \">\")
1139 %> Spaces of length thread-level (string)
1140 %< Spaces of length (- 20 thread-level) (string)
1141 %i Article score (number)
1142 %z Article zcore (character)
1143 %t Number of articles under the current thread (number).
1144 %e Whether the thread is empty or not (character).
1145 %l GroupLens score (number)
1146 %u User defined specifier. The next character in the format string should
1147 be a letter. Gnus will call the function gnus-user-format-function-X,
1148 where X is the letter following %u. The function will be passed the
1149 current header as argument. The function should return a string, which
1150 will be inserted into the summary just like information from any other
1153 Text between %( and %) will be highlighted with `gnus-mouse-face'
1154 when the mouse point is placed inside the area. There can only be one
1157 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1158 with care. For reasons of efficiency, Gnus will compute what column
1159 these characters will end up in, and \"hard-code\" that. This means that
1160 it is illegal to have these specs after a variable-length spec. Well,
1161 you might not be arrested, but your summary buffer will look strange,
1162 which is bad enough.
1164 The smart choice is to have these specs as for to the left as
1167 This restriction may disappear in later versions of Gnus.")
1169 (defvar gnus-summary-dummy-line-format
1171 "*The format specification for the dummy roots in the summary buffer.
1172 It works along the same lines as a normal formatting string,
1173 with some simple extensions.
1177 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1178 "*The format specification for the summary mode line.
1179 It works along the same lines as a normal formatting string,
1180 with some simple extensions:
1183 %p Unprefixed group name
1184 %A Current article number
1186 %U Number of unread articles in the group
1187 %e Number of unselected articles in the group
1188 %Z A string with unread/unselected article counts
1189 %g Shortish group name
1190 %S Subject of the current article
1191 %u User-defined spec
1192 %s Current score file name
1193 %d Number of dormant articles
1194 %r Number of articles that have been marked as read in this session
1195 %E Number of articles expunged by the score files")
1197 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1198 "*The format specification for the article mode line.
1199 See `gnus-summary-mode-line-format' for a closer description.")
1201 (defvar gnus-group-mode-line-format "Gnus: %%b {%M:%S}"
1202 "*The format specification for the group mode line.
1203 It works along the same lines as a normal formatting string,
1204 with some simple extensions:
1206 %S The native news server.
1207 %M The native select method.")
1209 (defvar gnus-valid-select-methods
1210 '(("nntp" post address prompt-address)
1211 ("nnspool" post address)
1212 ("nnvirtual" post-mail virtual prompt-address)
1213 ("nnmbox" mail respool address)
1214 ("nnml" mail respool address)
1215 ("nnmh" mail respool address)
1216 ("nndir" post-mail prompt-address address)
1217 ("nneething" none address prompt-address)
1218 ("nndoc" none address prompt-address)
1219 ("nnbabyl" mail address respool)
1220 ("nnkiboze" post address virtual)
1221 ("nnsoup" post-mail address)
1222 ("nndraft" post-mail)
1223 ("nnfolder" mail respool address))
1224 "An alist of valid select methods.
1225 The first element of each list lists should be a string with the name
1226 of the select method. The other elements may be be the category of
1227 this method (ie. `post', `mail', `none' or whatever) or other
1228 properties that this method has (like being respoolable).
1229 If you implement a new select method, all you should have to change is
1230 this variable. I think.")
1232 (defvar gnus-updated-mode-lines '(group article summary tree)
1233 "*List of buffers that should update their mode lines.
1234 The list may contain the symbols `group', `article' and `summary'. If
1235 the corresponding symbol is present, Gnus will keep that mode line
1236 updated with information that may be pertinent.
1237 If this variable is nil, screen refresh may be quicker.")
1239 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1240 (defvar gnus-mode-non-string-length nil
1241 "*Max length of mode-line non-string contents.
1242 If this is nil, Gnus will take space as is needed, leaving the rest
1243 of the modeline intact.")
1246 ;(defvar gnus-mouse-face 'highlight
1247 ; "*Face used for mouse highlighting in Gnus.
1248 ;No mouse highlights will be done if `gnus-visual' is nil.")
1250 (defvar gnus-summary-mark-below nil
1251 "*Mark all articles with a score below this variable as read.
1252 This variable is local to each summary buffer and usually set by the
1255 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1256 "*List of functions used for sorting articles in the summary buffer.
1257 This variable is only used when not using a threaded display.")
1259 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1260 "*List of functions used for sorting threads in the summary buffer.
1261 By default, threads are sorted by article number.
1263 Each function takes two threads and return non-nil if the first thread
1264 should be sorted before the other. If you use more than one function,
1265 the primary sort function should be the last. You should probably
1266 always include `gnus-thread-sort-by-number' in the list of sorting
1267 functions -- preferably first.
1269 Ready-mady functions include `gnus-thread-sort-by-number',
1270 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1271 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1272 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1274 (defvar gnus-thread-score-function '+
1275 "*Function used for calculating the total score of a thread.
1277 The function is called with the scores of the article and each
1278 subthread and should then return the score of the thread.
1280 Some functions you can use are `+', `max', or `min'.")
1282 (defvar gnus-summary-expunge-below nil
1283 "All articles that have a score less than this variable will be expunged.")
1285 (defvar gnus-thread-expunge-below nil
1286 "All threads that have a total score less than this variable will be expunged.
1287 See `gnus-thread-score-function' for en explanation of what a
1288 \"thread score\" is.")
1290 (defvar gnus-auto-subscribed-groups
1291 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1292 "*All new groups that match this regexp will be subscribed automatically.
1293 Note that this variable only deals with new groups. It has no effect
1294 whatsoever on old groups.")
1296 (defvar gnus-options-subscribe nil
1297 "*All new groups matching this regexp will be subscribed unconditionally.
1298 Note that this variable deals only with new newsgroups. This variable
1299 does not affect old newsgroups.")
1301 (defvar gnus-options-not-subscribe nil
1302 "*All new groups matching this regexp will be ignored.
1303 Note that this variable deals only with new newsgroups. This variable
1304 does not affect old (already subscribed) newsgroups.")
1306 (defvar gnus-auto-expirable-newsgroups nil
1307 "*Groups in which to automatically mark read articles as expirable.
1308 If non-nil, this should be a regexp that should match all groups in
1309 which to perform auto-expiry. This only makes sense for mail groups.")
1311 (defvar gnus-total-expirable-newsgroups nil
1312 "*Groups in which to perform expiry of all read articles.
1313 Use with extreme caution. All groups that match this regexp will be
1314 expiring - which means that all read articles will be deleted after
1315 (say) one week. (This only goes for mail groups and the like, of
1318 (defvar gnus-group-uncollapsed-levels 1
1319 "Number of group name elements to leave alone when making a short group name.")
1321 (defvar gnus-hidden-properties '(invisible t intangible t)
1322 "Property list to use for hiding text.")
1324 (defvar gnus-modtime-botch nil
1325 "*Non-nil means .newsrc should be deleted prior to save.
1326 Its use is due to the bogus appearance that .newsrc was modified on
1331 (defvar gnus-group-mode-hook nil
1332 "*A hook for Gnus group mode.")
1334 (defvar gnus-summary-mode-hook nil
1335 "*A hook for Gnus summary mode.
1336 This hook is run before any variables are set in the summary buffer.")
1338 (defvar gnus-article-mode-hook nil
1339 "*A hook for Gnus article mode.")
1341 (defvar gnus-summary-prepare-exit-hook nil
1342 "*A hook called when preparing to exit from the summary buffer.
1343 It calls `gnus-summary-expire-articles' by default.")
1344 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1346 (defvar gnus-summary-exit-hook nil
1347 "*A hook called on exit from the summary buffer.")
1349 (defvar gnus-group-catchup-group-hook nil
1350 "*A hook run when catching up a group from the group buffer.")
1352 (defvar gnus-open-server-hook nil
1353 "*A hook called just before opening connection to the news server.")
1355 (defvar gnus-load-hook nil
1356 "*A hook run while Gnus is loaded.")
1358 (defvar gnus-startup-hook nil
1359 "*A hook called at startup.
1360 This hook is called after Gnus is connected to the NNTP server.")
1362 (defvar gnus-get-new-news-hook nil
1363 "*A hook run just before Gnus checks for new news.")
1365 (defvar gnus-after-getting-new-news-hook nil
1366 "*A hook run after Gnus checks for new news.")
1368 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1369 "*A function that is called to generate the group buffer.
1370 The function is called with three arguments: The first is a number;
1371 all group with a level less or equal to that number should be listed,
1372 if the second is non-nil, empty groups should also be displayed. If
1373 the third is non-nil, it is a number. No groups with a level lower
1374 than this number should be displayed.
1376 The only current function implemented is `gnus-group-prepare-flat'.")
1378 (defvar gnus-group-prepare-hook nil
1379 "*A hook called after the group buffer has been generated.
1380 If you want to modify the group buffer, you can use this hook.")
1382 (defvar gnus-summary-prepare-hook nil
1383 "*A hook called after the summary buffer has been generated.
1384 If you want to modify the summary buffer, you can use this hook.")
1386 (defvar gnus-summary-generate-hook nil
1387 "*A hook run just before generating the summary buffer.
1388 This hook is commonly used to customize threading variables and the
1391 (defvar gnus-article-prepare-hook nil
1392 "*A hook called after an article has been prepared in the article buffer.
1393 If you want to run a special decoding program like nkf, use this hook.")
1395 ;(defvar gnus-article-display-hook nil
1396 ; "*A hook called after the article is displayed in the article buffer.
1397 ;The hook is designed to change the contents of the article
1398 ;buffer. Typical functions that this hook may contain are
1399 ;`gnus-article-hide-headers' (hide selected headers),
1400 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1401 ;`gnus-article-hide-signature' (hide signature) and
1402 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1403 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1404 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1405 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1407 (defvar gnus-article-x-face-command
1408 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1409 "String or function to be executed to display an X-Face header.
1410 If it is a string, the command will be executed in a sub-shell
1411 asynchronously. The compressed face will be piped to this command.")
1413 (defvar gnus-article-x-face-too-ugly nil
1414 "Regexp matching posters whose face shouldn't be shown automatically.")
1416 (defvar gnus-select-group-hook nil
1417 "*A hook called when a newsgroup is selected.
1419 If you'd like to simplify subjects like the
1420 `gnus-summary-next-same-subject' command does, you can use the
1423 (setq gnus-select-group-hook
1426 (mapcar (lambda (header)
1427 (mail-header-set-subject
1429 (gnus-simplify-subject
1430 (mail-header-subject header) 're-only)))
1431 gnus-newsgroup-headers))))")
1433 (defvar gnus-select-article-hook nil
1434 "*A hook called when an article is selected.")
1436 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1437 "*A hook called to apply kill files to a group.
1438 This hook is intended to apply a kill file to the selected newsgroup.
1439 The function `gnus-apply-kill-file' is called by default.
1441 Since a general kill file is too heavy to use only for a few
1442 newsgroups, I recommend you to use a lighter hook function. For
1443 example, if you'd like to apply a kill file to articles which contains
1444 a string `rmgroup' in subject in newsgroup `control', you can use the
1447 (setq gnus-apply-kill-hook
1450 (cond ((string-match \"control\" gnus-newsgroup-name)
1451 (gnus-kill \"Subject\" \"rmgroup\")
1452 (gnus-expunge \"X\"))))))")
1454 (defvar gnus-visual-mark-article-hook
1455 (list 'gnus-highlight-selected-summary)
1456 "*Hook run after selecting an article in the summary buffer.
1457 It is meant to be used for highlighting the article in some way. It
1458 is not run if `gnus-visual' is nil.")
1460 (defvar gnus-parse-headers-hook nil
1461 "*A hook called before parsing the headers.")
1463 (defvar gnus-exit-group-hook nil
1464 "*A hook called when exiting (not quitting) summary mode.")
1466 (defvar gnus-suspend-gnus-hook nil
1467 "*A hook called when suspending (not exiting) Gnus.")
1469 (defvar gnus-exit-gnus-hook nil
1470 "*A hook called when exiting Gnus.")
1472 (defvar gnus-after-exiting-gnus-hook nil
1473 "*A hook called after exiting Gnus.")
1475 (defvar gnus-save-newsrc-hook nil
1476 "*A hook called before saving any of the newsrc files.")
1478 (defvar gnus-save-quick-newsrc-hook nil
1479 "*A hook called just before saving the quick newsrc file.
1480 Can be used to turn version control on or off.")
1482 (defvar gnus-save-standard-newsrc-hook nil
1483 "*A hook called just before saving the standard newsrc file.
1484 Can be used to turn version control on or off.")
1486 (defvar gnus-summary-update-hook
1487 (list 'gnus-summary-highlight-line)
1488 "*A hook called when a summary line is changed.
1489 The hook will not be called if `gnus-visual' is nil.
1491 The default function `gnus-summary-highlight-line' will
1492 highlight the line according to the `gnus-summary-highlight'
1495 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1496 "*A hook called when a group line is changed.
1497 The hook will not be called if `gnus-visual' is nil.
1499 The default function `gnus-group-highlight-line' will
1500 highlight the line according to the `gnus-group-highlight'
1503 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1504 "*A hook called when an article is selected for the first time.
1505 The hook is intended to mark an article as read (or unread)
1506 automatically when it is selected.")
1508 (defvar gnus-group-change-level-function nil
1509 "Function run when a group level is changed.
1510 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1512 ;; Remove any hilit infestation.
1513 (add-hook 'gnus-startup-hook
1515 (remove-hook 'gnus-summary-prepare-hook
1516 'hilit-rehighlight-buffer-quietly)
1517 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1518 (setq gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read))
1519 (remove-hook 'gnus-article-prepare-hook
1520 'hilit-rehighlight-buffer-quietly)))
1523 ;; Internal variables
1525 (defvar gnus-server-alist nil
1526 "List of available servers.")
1528 (defvar gnus-group-indentation-function nil)
1530 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1532 (defvar gnus-goto-missing-group-function nil)
1534 (defvar gnus-override-subscribe-method nil)
1536 (defvar gnus-group-goto-next-group-function nil
1537 "Function to override finding the next group after listing groups.")
1539 (defconst gnus-article-mark-lists
1540 '((marked . tick) (replied . reply)
1541 (expirable . expire) (killed . killed)
1542 (bookmarks . bookmark) (dormant . dormant)
1543 (scored . score) (saved . save)
1547 ;; Avoid highlighting in kill files.
1548 (defvar gnus-summary-inhibit-highlight nil)
1549 (defvar gnus-newsgroup-selected-overlay nil)
1551 (defvar gnus-inhibit-hiding nil)
1552 (defvar gnus-group-indentation "")
1553 (defvar gnus-inhibit-limiting nil)
1554 (defvar gnus-created-frames nil)
1556 (defvar gnus-article-mode-map nil)
1557 (defvar gnus-dribble-buffer nil)
1558 (defvar gnus-headers-retrieved-by nil)
1559 (defvar gnus-article-reply nil)
1560 (defvar gnus-override-method nil)
1561 (defvar gnus-article-check-size nil)
1563 (defvar gnus-current-score-file nil)
1564 (defvar gnus-newsgroup-adaptive-score-file nil)
1565 (defvar gnus-scores-exclude-files nil)
1567 (defvar gnus-opened-servers nil)
1569 (defvar gnus-current-move-group nil)
1571 (defvar gnus-newsgroup-dependencies nil)
1572 (defvar gnus-newsgroup-async nil)
1573 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1575 (defvar gnus-newsgroup-adaptive nil)
1577 (defvar gnus-summary-display-table nil)
1578 (defvar gnus-summary-display-article-function nil)
1580 (defvar gnus-summary-highlight-line-function nil
1581 "Function called after highlighting a summary line.")
1583 (defvar gnus-group-line-format-alist
1584 `((?M gnus-tmp-marked-mark ?c)
1585 (?S gnus-tmp-subscribed ?c)
1586 (?L gnus-tmp-level ?d)
1587 (?N (cond ((eq number t) "*" )
1591 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1592 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1594 (?R gnus-tmp-number-of-read ?s)
1595 (?t gnus-tmp-number-total ?d)
1596 (?y gnus-tmp-number-of-unread ?s)
1597 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1598 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1599 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1600 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1601 (?g gnus-tmp-group ?s)
1602 (?G gnus-tmp-qualified-group ?s)
1603 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1604 (?D gnus-tmp-newsgroup-description ?s)
1605 (?o gnus-tmp-moderated ?c)
1606 (?O gnus-tmp-moderated-string ?s)
1607 (?p gnus-tmp-process-marked ?c)
1608 (?s gnus-tmp-news-server ?s)
1609 (?n gnus-tmp-news-method ?s)
1610 (?P gnus-group-indentation ?s)
1611 (?l gnus-tmp-grouplens ?s)
1612 (?z gnus-tmp-news-method-string ?s)
1613 (?u gnus-tmp-user-defined ?s)))
1615 (defvar gnus-summary-line-format-alist
1616 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1617 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1618 (?s gnus-tmp-subject-or-nil ?s)
1619 (?n gnus-tmp-name ?s)
1620 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1622 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1624 (?F gnus-tmp-from ?s)
1625 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1626 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1627 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1628 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1629 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1630 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1631 (?L gnus-tmp-lines ?d)
1632 (?I gnus-tmp-indentation ?s)
1633 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1634 (?R gnus-tmp-replied ?c)
1635 (?\[ gnus-tmp-opening-bracket ?c)
1636 (?\] gnus-tmp-closing-bracket ?c)
1637 (?\> (make-string gnus-tmp-level ? ) ?s)
1638 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1639 (?i gnus-tmp-score ?d)
1640 (?z gnus-tmp-score-char ?c)
1641 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1642 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1643 (?U gnus-tmp-unread ?c)
1644 (?t (gnus-summary-number-of-articles-in-thread
1645 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1647 (?e (gnus-summary-number-of-articles-in-thread
1648 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1650 (?u gnus-tmp-user-defined ?s))
1651 "An alist of format specifications that can appear in summary lines,
1652 and what variables they correspond with, along with the type of the
1653 variable (string, integer, character, etc).")
1655 (defvar gnus-summary-dummy-line-format-alist
1656 `((?S gnus-tmp-subject ?s)
1657 (?N gnus-tmp-number ?d)
1658 (?u gnus-tmp-user-defined ?s)))
1660 (defvar gnus-summary-mode-line-format-alist
1661 `((?G gnus-tmp-group-name ?s)
1662 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1663 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1664 (?A gnus-tmp-article-number ?d)
1665 (?Z gnus-tmp-unread-and-unselected ?s)
1666 (?V gnus-version ?s)
1667 (?U gnus-tmp-unread ?d)
1668 (?S gnus-tmp-subject ?s)
1669 (?e gnus-tmp-unselected ?d)
1670 (?u gnus-tmp-user-defined ?s)
1671 (?d (length gnus-newsgroup-dormant) ?d)
1672 (?t (length gnus-newsgroup-marked) ?d)
1673 (?r (length gnus-newsgroup-reads) ?d)
1674 (?E gnus-newsgroup-expunged-tally ?d)
1675 (?s (gnus-current-score-file-nondirectory) ?s)))
1677 (defvar gnus-article-mode-line-format-alist
1678 gnus-summary-mode-line-format-alist)
1680 (defvar gnus-group-mode-line-format-alist
1681 `((?S gnus-tmp-news-server ?s)
1682 (?M gnus-tmp-news-method ?s)
1683 (?u gnus-tmp-user-defined ?s)))
1685 (defvar gnus-have-read-active-file nil)
1687 (defconst gnus-maintainer
1688 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1689 "The mail address of the Gnus maintainers.")
1691 (defconst gnus-version "September Gnus v0.60"
1692 "Version number for this version of Gnus.")
1694 (defvar gnus-info-nodes
1695 '((gnus-group-mode "(gnus)The Group Buffer")
1696 (gnus-summary-mode "(gnus)The Summary Buffer")
1697 (gnus-article-mode "(gnus)The Article Buffer"))
1698 "Assoc list of major modes and related Info nodes.")
1700 (defvar gnus-group-buffer "*Group*")
1701 (defvar gnus-summary-buffer "*Summary*")
1702 (defvar gnus-article-buffer "*Article*")
1703 (defvar gnus-server-buffer "*Server*")
1705 (defvar gnus-work-buffer " *gnus work*")
1707 (defvar gnus-original-article-buffer " *Original Article*")
1708 (defvar gnus-original-article nil)
1710 (defvar gnus-buffer-list nil
1711 "Gnus buffers that should be killed on exit.")
1713 (defvar gnus-slave nil
1714 "Whether this Gnus is a slave or not.")
1716 (defvar gnus-variable-list
1717 '(gnus-newsrc-options gnus-newsrc-options-n
1718 gnus-newsrc-last-checked-date
1719 gnus-newsrc-alist gnus-server-alist
1720 gnus-killed-list gnus-zombie-list
1721 gnus-topic-topology gnus-topic-alist
1723 "Gnus variables saved in the quick startup file.")
1725 (defvar gnus-newsrc-options nil
1726 "Options line in the .newsrc file.")
1728 (defvar gnus-newsrc-options-n nil
1729 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1731 (defvar gnus-newsrc-last-checked-date nil
1732 "Date Gnus last asked server for new newsgroups.")
1734 (defvar gnus-topic-topology nil
1735 "The complete topic hierarchy.")
1737 (defvar gnus-topic-alist nil
1738 "The complete topic-group alist.")
1740 (defvar gnus-newsrc-alist nil
1741 "Assoc list of read articles.
1742 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1744 (defvar gnus-newsrc-hashtb nil
1745 "Hashtable of gnus-newsrc-alist.")
1747 (defvar gnus-killed-list nil
1748 "List of killed newsgroups.")
1750 (defvar gnus-killed-hashtb nil
1751 "Hash table equivalent of gnus-killed-list.")
1753 (defvar gnus-zombie-list nil
1754 "List of almost dead newsgroups.")
1756 (defvar gnus-description-hashtb nil
1757 "Descriptions of newsgroups.")
1759 (defvar gnus-list-of-killed-groups nil
1760 "List of newsgroups that have recently been killed by the user.")
1762 (defvar gnus-active-hashtb nil
1763 "Hashtable of active articles.")
1765 (defvar gnus-moderated-list nil
1766 "List of moderated newsgroups.")
1768 (defvar gnus-group-marked nil)
1770 (defvar gnus-current-startup-file nil
1771 "Startup file for the current host.")
1773 (defvar gnus-last-search-regexp nil
1774 "Default regexp for article search command.")
1776 (defvar gnus-last-shell-command nil
1777 "Default shell command on article.")
1779 (defvar gnus-current-select-method nil
1780 "The current method for selecting a newsgroup.")
1782 (defvar gnus-group-list-mode nil)
1784 (defvar gnus-article-internal-prepare-hook nil)
1786 (defvar gnus-newsgroup-name nil)
1787 (defvar gnus-newsgroup-begin nil)
1788 (defvar gnus-newsgroup-end nil)
1789 (defvar gnus-newsgroup-last-rmail nil)
1790 (defvar gnus-newsgroup-last-mail nil)
1791 (defvar gnus-newsgroup-last-folder nil)
1792 (defvar gnus-newsgroup-last-file nil)
1793 (defvar gnus-newsgroup-auto-expire nil)
1794 (defvar gnus-newsgroup-active nil)
1796 (defvar gnus-newsgroup-data nil)
1797 (defvar gnus-newsgroup-data-reverse nil)
1798 (defvar gnus-newsgroup-limit nil)
1799 (defvar gnus-newsgroup-limits nil)
1801 (defvar gnus-newsgroup-unreads nil
1802 "List of unread articles in the current newsgroup.")
1804 (defvar gnus-newsgroup-unselected nil
1805 "List of unselected unread articles in the current newsgroup.")
1807 (defvar gnus-newsgroup-reads nil
1808 "Alist of read articles and article marks in the current newsgroup.")
1810 (defvar gnus-newsgroup-expunged-tally nil)
1812 (defvar gnus-newsgroup-marked nil
1813 "List of ticked articles in the current newsgroup (a subset of unread art).")
1815 (defvar gnus-newsgroup-killed nil
1816 "List of ranges of articles that have been through the scoring process.")
1818 (defvar gnus-newsgroup-cached nil
1819 "List of articles that come from the article cache.")
1821 (defvar gnus-newsgroup-saved nil
1822 "List of articles that have been saved.")
1824 (defvar gnus-newsgroup-kill-headers nil)
1826 (defvar gnus-newsgroup-replied nil
1827 "List of articles that have been replied to in the current newsgroup.")
1829 (defvar gnus-newsgroup-expirable nil
1830 "List of articles in the current newsgroup that can be expired.")
1832 (defvar gnus-newsgroup-processable nil
1833 "List of articles in the current newsgroup that can be processed.")
1835 (defvar gnus-newsgroup-bookmarks nil
1836 "List of articles in the current newsgroup that have bookmarks.")
1838 (defvar gnus-newsgroup-dormant nil
1839 "List of dormant articles in the current newsgroup.")
1841 (defvar gnus-newsgroup-scored nil
1842 "List of scored articles in the current newsgroup.")
1844 (defvar gnus-newsgroup-headers nil
1845 "List of article headers in the current newsgroup.")
1847 (defvar gnus-newsgroup-threads nil)
1849 (defvar gnus-newsgroup-prepared nil
1850 "Whether the current group has been prepared properly.")
1852 (defvar gnus-newsgroup-ancient nil
1853 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1855 (defvar gnus-newsgroup-sparse nil)
1857 (defvar gnus-current-article nil)
1858 (defvar gnus-article-current nil)
1859 (defvar gnus-current-headers nil)
1860 (defvar gnus-have-all-headers nil)
1861 (defvar gnus-last-article nil)
1862 (defvar gnus-newsgroup-history nil)
1863 (defvar gnus-current-kill-article nil)
1865 ;; Save window configuration.
1866 (defvar gnus-prev-winconf nil)
1868 (defvar gnus-summary-mark-positions nil)
1869 (defvar gnus-group-mark-positions nil)
1871 (defvar gnus-reffed-article-number nil)
1873 ;;; Let the byte-compiler know that we know about this variable.
1874 (defvar rmail-default-rmail-file)
1876 (defvar gnus-cache-removable-articles nil)
1878 (defvar gnus-dead-summary nil)
1880 (defconst gnus-summary-local-variables
1881 '(gnus-newsgroup-name
1882 gnus-newsgroup-begin gnus-newsgroup-end
1883 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1884 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1885 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1886 gnus-newsgroup-unselected gnus-newsgroup-marked
1887 gnus-newsgroup-reads gnus-newsgroup-saved
1888 gnus-newsgroup-replied gnus-newsgroup-expirable
1889 gnus-newsgroup-processable gnus-newsgroup-killed
1890 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1891 gnus-newsgroup-headers gnus-newsgroup-threads
1892 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1893 gnus-current-article gnus-current-headers gnus-have-all-headers
1894 gnus-last-article gnus-article-internal-prepare-hook
1895 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1896 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1897 gnus-newsgroup-async
1898 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1899 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1900 gnus-newsgroup-history gnus-newsgroup-ancient
1901 gnus-newsgroup-sparse
1902 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1903 gnus-newsgroup-adaptive-score-file
1904 (gnus-newsgroup-expunged-tally . 0)
1905 gnus-cache-removable-articles gnus-newsgroup-cached
1906 gnus-newsgroup-data gnus-newsgroup-data-reverse
1907 gnus-newsgroup-limit gnus-newsgroup-limits)
1908 "Variables that are buffer-local to the summary buffers.")
1910 (defconst gnus-bug-message
1911 "Sending a bug report to the Gnus Towers.
1912 ========================================
1914 The buffer below is a mail buffer. When you press `C-c C-c', it will
1915 be sent to the Gnus Bug Exterminators.
1917 At the bottom of the buffer you'll see lots of variable settings.
1918 Please do not delete those. They will tell the Bug People what your
1919 environment is, so that it will be easier to locate the bugs.
1921 If you have found a bug that makes Emacs go \"beep\", set
1922 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1923 and include the backtrace in your bug report.
1925 Please describe the bug in annoying, painstaking detail.
1927 Thank you for your help in stamping out bugs.
1930 ;;; End of variables.
1932 ;; Define some autoload functions Gnus might use.
1935 ;; This little mapcar goes through the list below and marks the
1936 ;; symbols in question as autoloaded functions.
1939 (let ((interactive (nth 1 (memq ':interactive package))))
1943 (when (consp function)
1944 (setq keymap (car (memq 'keymap function)))
1945 (setq function (car function)))
1946 (autoload function (car package) nil interactive keymap)))
1947 (if (eq (nth 1 package) ':interactive)
1950 '(("metamail" metamail-buffer)
1951 ("info" Info-goto-node)
1952 ("hexl" hexl-hex-string-to-integer)
1953 ("pp" pp pp-to-string pp-eval-expression)
1954 ("mail-extr" mail-extract-address-components)
1955 ("nnmail" nnmail-split-fancy nnmail-article-group)
1956 ("nnvirtual" nnvirtual-catchup-group)
1957 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
1958 timezone-make-sortable-date timezone-make-time-string)
1959 ("sendmail" mail-position-on-field mail-setup)
1960 ("rmailout" rmail-output)
1961 ("rnewspost" news-mail-other-window news-reply-yank-original
1962 news-caesar-buffer-body)
1963 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
1965 ("gnus-soup" :interactive t
1966 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
1967 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
1968 ("nnsoup" nnsoup-pack-replies)
1969 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
1970 gnus-Folder-save-name gnus-folder-save-name)
1971 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
1972 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
1973 gnus-server-make-menu-bar gnus-article-make-menu-bar
1974 gnus-browse-make-menu-bar gnus-highlight-selected-summary
1975 gnus-summary-highlight-line gnus-carpal-setup-buffer
1976 gnus-group-highlight-line
1977 gnus-article-add-button gnus-insert-next-page-button
1978 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
1979 ("gnus-vis" :interactive t
1980 gnus-article-push-button gnus-article-press-button
1981 gnus-article-highlight gnus-article-highlight-some
1982 gnus-article-highlight-headers gnus-article-highlight-signature
1983 gnus-article-add-buttons gnus-article-add-buttons-to-head
1984 gnus-article-next-button gnus-article-prev-button)
1985 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
1986 gnus-demon-add-disconnection gnus-demon-add-handler
1987 gnus-demon-remove-handler)
1988 ("gnus-demon" :interactive t
1989 gnus-demon-init gnus-demon-cancel)
1990 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
1991 gnus-tree-open gnus-tree-close)
1992 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
1993 gnus-nocem-unwanted-article-p)
1994 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
1995 ("gnus-srvr" gnus-browse-foreign-server)
1996 ("gnus-cite" :interactive t
1997 gnus-article-highlight-citation gnus-article-hide-citation-maybe
1998 gnus-article-hide-citation gnus-article-fill-cited-article)
1999 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2000 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2001 gnus-execute gnus-expunge)
2002 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2003 gnus-cache-possibly-remove-articles gnus-cache-request-article
2004 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2005 gnus-cache-enter-remove-article gnus-cached-article-p
2006 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2007 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2008 gnus-cache-remove-article)
2009 ("gnus-score" :interactive t
2010 gnus-summary-increase-score gnus-summary-lower-score
2011 gnus-score-flush-cache gnus-score-close
2012 gnus-score-raise-same-subject-and-select
2013 gnus-score-raise-same-subject gnus-score-default
2014 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2015 gnus-score-lower-same-subject gnus-score-lower-thread
2016 gnus-possibly-score-headers)
2018 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2019 gnus-current-score-file-nondirectory gnus-score-adaptive
2020 gnus-score-find-trace gnus-score-file-name)
2021 ("gnus-edit" :interactive t gnus-score-customize)
2022 ("gnus-topic" :interactive t gnus-topic-mode)
2023 ("gnus-topic" gnus-topic-remove-group)
2024 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2025 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2026 ("gnus-uu" :interactive t
2027 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2028 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2029 gnus-uu-mark-by-regexp gnus-uu-mark-all
2030 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2031 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2032 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2033 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2034 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2035 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2036 gnus-uu-decode-binhex-view)
2037 ("gnus-msg" (gnus-summary-send-map keymap)
2038 gnus-mail-yank-original gnus-mail-send-and-exit
2039 gnus-sendmail-setup-mail gnus-article-mail
2040 gnus-inews-message-id gnus-new-mail gnus-mail-reply)
2041 ("gnus-msg" :interactive t
2042 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2043 gnus-summary-followup gnus-summary-followup-with-original
2044 gnus-summary-followup-and-reply
2045 gnus-summary-followup-and-reply-with-original
2046 gnus-summary-cancel-article gnus-summary-supersede-article
2047 gnus-post-news gnus-inews-news gnus-cancel-news
2048 gnus-summary-reply gnus-summary-reply-with-original
2049 gnus-summary-mail-forward gnus-summary-mail-other-window
2051 ("gnus-picon" :interactive t gnus-article-display-picons
2052 gnus-group-display-picons gnus-picons-article-display-x-face)
2053 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2054 gnus-grouplens-mode)
2055 ("gnus-vm" gnus-vm-mail-setup)
2056 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2057 gnus-summary-save-article-vm gnus-yank-article))))
2061 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2062 ;; If you want the cursor to go somewhere else, set these two
2063 ;; functions in some startup hook to whatever you want.
2064 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2065 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2067 ;;; Various macros and substs.
2069 (defun gnus-header-from (header)
2070 (mail-header-from header))
2072 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2073 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2074 (let ((tempvar (make-symbol "GnusStartBufferWindow")))
2075 `(let ((,tempvar (selected-window)))
2078 (pop-to-buffer ,buffer)
2080 (select-window ,tempvar)))))
2082 (defmacro gnus-gethash (string hashtable)
2083 "Get hash value of STRING in HASHTABLE."
2084 `(symbol-value (intern-soft ,string ,hashtable)))
2086 (defmacro gnus-sethash (string value hashtable)
2087 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2088 `(set (intern ,string ,hashtable) ,value))
2090 (defmacro gnus-intern-safe (string hashtable)
2091 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2092 `(let ((symbol (intern ,string ,hashtable)))
2097 (defmacro gnus-group-unread (group)
2098 "Get the currently computed number of unread articles in GROUP."
2099 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2101 (defmacro gnus-group-entry (group)
2102 "Get the newsrc entry for GROUP."
2103 `(gnus-gethash ,group gnus-newsrc-hashtb))
2105 (defmacro gnus-active (group)
2106 "Get active info on GROUP."
2107 `(gnus-gethash ,group gnus-active-hashtb))
2109 (defmacro gnus-set-active (group active)
2110 "Set GROUP's active info."
2111 `(gnus-sethash ,group ,active gnus-active-hashtb))
2113 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2114 ;; function `substring' might cut on a middle of multi-octet
2116 (defun gnus-truncate-string (str width)
2117 (substring str 0 width))
2119 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2120 ;; to limit the length of a string. This function is necessary since
2121 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2122 (defsubst gnus-limit-string (str width)
2123 (if (> (length str) width)
2124 (substring str 0 width)
2127 (defsubst gnus-simplify-subject-re (subject)
2128 "Remove \"Re:\" from subject lines."
2129 (if (string-match "^[Rr][Ee]: *" subject)
2130 (substring subject (match-end 0))
2133 (defsubst gnus-functionp (form)
2134 "Return non-nil if FORM is funcallable."
2135 (or (and (symbolp form) (fboundp form))
2136 (and (listp form) (eq (car form) 'lambda))))
2138 (defsubst gnus-goto-char (point)
2139 (and point (goto-char point)))
2141 (defmacro gnus-buffer-exists-p (buffer)
2142 `(let ((buffer ,buffer))
2144 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2147 (defmacro gnus-kill-buffer (buffer)
2148 `(let ((buf ,buffer))
2149 (if (gnus-buffer-exists-p buf)
2150 (kill-buffer buf))))
2152 (defsubst gnus-point-at-bol ()
2153 "Return point at the beginning of the line."
2160 (defsubst gnus-point-at-eol ()
2161 "Return point at the end of the line."
2168 (defun gnus-alive-p ()
2169 "Say whether Gnus is running or not."
2170 (and gnus-group-buffer
2171 (get-buffer gnus-group-buffer)))
2173 ;; Delete the current line (and the next N lines.);
2174 (defmacro gnus-delete-line (&optional n)
2175 `(delete-region (progn (beginning-of-line) (point))
2176 (progn (forward-line ,(or n 1)) (point))))
2178 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2179 (defvar gnus-init-inhibit nil)
2180 (defun gnus-read-init-file (&optional inhibit-next)
2181 (if gnus-init-inhibit
2182 (setq gnus-init-inhibit nil)
2183 (setq gnus-init-inhibit inhibit-next)
2185 (or (and (file-exists-p gnus-init-file)
2186 ;; Don't try to load a directory.
2187 (not (file-directory-p gnus-init-file)))
2188 (file-exists-p (concat gnus-init-file ".el"))
2189 (file-exists-p (concat gnus-init-file ".elc")))
2191 (load gnus-init-file nil t)
2193 (error "Error in %s: %s" gnus-init-file var))))))
2195 ;; Info access macros.
2197 (defmacro gnus-info-group (info)
2199 (defmacro gnus-info-rank (info)
2201 (defmacro gnus-info-read (info)
2203 (defmacro gnus-info-marks (info)
2205 (defmacro gnus-info-method (info)
2207 (defmacro gnus-info-params (info)
2210 (defmacro gnus-info-level (info)
2211 `(let ((rank (gnus-info-rank ,info)))
2215 (defmacro gnus-info-score (info)
2216 `(let ((rank (gnus-info-rank ,info)))
2217 (or (and (consp rank) (cdr rank)) 0)))
2219 (defmacro gnus-info-set-group (info group)
2220 `(setcar ,info ,group))
2221 (defmacro gnus-info-set-rank (info rank)
2222 `(setcar (nthcdr 1 ,info) ,rank))
2223 (defmacro gnus-info-set-read (info read)
2224 `(setcar (nthcdr 2 ,info) ,read))
2225 (defmacro gnus-info-set-marks (info marks)
2226 `(setcar (nthcdr 3 ,info) ,marks))
2227 (defmacro gnus-info-set-method (info method)
2228 `(setcar (nthcdr 4 ,info) ,method))
2229 (defmacro gnus-info-set-params (info params)
2230 `(setcar (nthcdr 5 ,info) ,params))
2232 (defmacro gnus-info-set-level (info level)
2233 `(let ((rank (cdr ,info)))
2234 (if (consp (car rank))
2235 (setcar (car rank) ,level)
2236 (setcar rank ,level))))
2237 (defmacro gnus-info-set-score (info score)
2238 `(let ((rank (cdr ,info)))
2239 (if (consp (car rank))
2240 (setcdr (car rank) ,score)
2241 (setcar rank (cons (car rank) ,score)))))
2243 (defmacro gnus-get-info (group)
2244 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2246 (defun gnus-byte-code (func)
2247 "Return a form that can be `eval'ed based on FUNC."
2248 (let ((fval (symbol-function func)))
2249 (if (byte-code-function-p fval)
2250 (let ((flist (append fval nil)))
2251 (setcar flist 'byte-code)
2253 (cons 'progn (cddr fval)))))
2255 ;;; Load the compatability functions.
2265 (defvar gnus-shutdown-alist nil)
2267 (defun gnus-add-shutdown (function &rest symbols)
2268 "Run FUNCTION whenever one of SYMBOLS is shut down."
2269 (push (cons function symbols) gnus-shutdown-alist))
2271 (defun gnus-shutdown (symbol)
2272 "Shut down everything that waits for SYMBOL."
2273 (let ((alist gnus-shutdown-alist)
2275 (while (setq entry (pop alist))
2276 (when (memq symbol (cdr entry))
2277 (funcall (car entry))))))
2281 ;; Format specs. The chunks below are the machine-generated forms
2282 ;; that are to be evaled as the result of the default format strings.
2283 ;; We write them in here to get them byte-compiled. That way the
2284 ;; default actions will be quite fast, while still retaining the full
2285 ;; flexibility of the user-defined format specs.
2287 ;; First we have lots of dummy defvars to let the compiler know these
2288 ;; are really dynamic variables.
2290 (defvar gnus-tmp-unread)
2291 (defvar gnus-tmp-replied)
2292 (defvar gnus-tmp-score-char)
2293 (defvar gnus-tmp-indentation)
2294 (defvar gnus-tmp-opening-bracket)
2295 (defvar gnus-tmp-lines)
2296 (defvar gnus-tmp-name)
2297 (defvar gnus-tmp-closing-bracket)
2298 (defvar gnus-tmp-subject-or-nil)
2299 (defvar gnus-tmp-subject)
2300 (defvar gnus-tmp-marked)
2301 (defvar gnus-tmp-marked-mark)
2302 (defvar gnus-tmp-subscribed)
2303 (defvar gnus-tmp-process-marked)
2304 (defvar gnus-tmp-number-of-unread)
2305 (defvar gnus-tmp-group-name)
2306 (defvar gnus-tmp-group)
2307 (defvar gnus-tmp-article-number)
2308 (defvar gnus-tmp-unread-and-unselected)
2309 (defvar gnus-tmp-news-method)
2310 (defvar gnus-tmp-news-server)
2311 (defvar gnus-tmp-article-number)
2312 (defvar gnus-mouse-face)
2313 (defvar gnus-mouse-face-prop)
2315 (defun gnus-summary-line-format-spec ()
2316 (insert gnus-tmp-unread gnus-tmp-replied
2317 gnus-tmp-score-char gnus-tmp-indentation)
2322 gnus-tmp-opening-bracket
2323 (format "%4d: %-20s"
2325 (if (> (length gnus-tmp-name) 20)
2326 (substring gnus-tmp-name 0 20)
2328 gnus-tmp-closing-bracket)
2330 gnus-mouse-face-prop gnus-mouse-face)
2331 (insert " " gnus-tmp-subject-or-nil "\n"))
2333 (defvar gnus-summary-line-format-spec
2334 (gnus-byte-code 'gnus-summary-line-format-spec))
2336 (defun gnus-summary-dummy-line-format-spec ()
2343 gnus-mouse-face-prop gnus-mouse-face)
2344 (insert " " gnus-tmp-subject "\n"))
2346 (defvar gnus-summary-dummy-line-format-spec
2347 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2349 (defun gnus-group-line-format-spec ()
2350 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2351 gnus-tmp-process-marked
2352 gnus-group-indentation
2353 (format "%5s: " gnus-tmp-number-of-unread))
2357 (insert gnus-tmp-group "\n")
2359 gnus-mouse-face-prop gnus-mouse-face))
2360 (defvar gnus-group-line-format-spec
2361 (gnus-byte-code 'gnus-group-line-format-spec))
2363 (defvar gnus-format-specs
2364 `((version . ,emacs-version)
2365 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2366 (summary-dummy ,gnus-summary-dummy-line-format
2367 ,gnus-summary-dummy-line-format-spec)
2368 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2370 (defvar gnus-article-mode-line-format-spec nil)
2371 (defvar gnus-summary-mode-line-format-spec nil)
2372 (defvar gnus-group-mode-line-format-spec nil)
2374 ;;; Phew. All that gruft is over, fortunately.
2378 ;;; Gnus Utility Functions
2381 (defun gnus-extract-address-components (from)
2383 ;; First find the address - the thing with the @ in it. This may
2384 ;; not be accurate in mail addresses, but does the trick most of
2385 ;; the time in news messages.
2386 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2387 (setq address (substring from (match-beginning 0) (match-end 0))))
2388 ;; Then we check whether the "name <address>" format is used.
2390 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2391 ;; Linear white space is not required.
2392 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2393 (and (setq name (substring from 0 (match-beginning 0)))
2394 ;; Strip any quotes from the name.
2395 (string-match "\".*\"" name)
2396 (setq name (substring name 1 (1- (match-end 0))))))
2397 ;; If not, then "address (name)" is used.
2399 (and (string-match "(.+)" from)
2400 (setq name (substring from (1+ (match-beginning 0))
2401 (1- (match-end 0)))))
2402 (and (string-match "()" from)
2403 (setq name address))
2404 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2405 ;; XOVER might not support folded From headers.
2406 (and (string-match "(.*" from)
2407 (setq name (substring from (1+ (match-beginning 0))
2409 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2410 (list (or name from) (or address from))))
2412 (defun gnus-fetch-field (field)
2413 "Return the value of the header FIELD of current article."
2416 (let ((case-fold-search t))
2417 (nnheader-narrow-to-headers)
2418 (mail-fetch-field field)))))
2420 (defun gnus-goto-colon ()
2422 (search-forward ":" (gnus-point-at-eol) t))
2425 (defun gnus-update-format (var)
2426 "Update the format specification near point."
2431 ;; Find the end of the current word.
2432 (re-search-forward "[ \t\n]" nil t)
2434 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2435 (match-string 1)))))
2436 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2437 (match-string 1 var))))
2438 (entry (assq type gnus-format-specs))
2441 (setq gnus-format-specs (delq entry gnus-format-specs)))
2443 (intern (format "%s-spec" var))
2444 (gnus-parse-format (setq value (symbol-value (intern var)))
2445 (symbol-value (intern (format "%s-alist" var)))
2446 (not (string-match "mode" var))))
2447 (setq spec (symbol-value (intern (format "%s-spec" var))))
2448 (push (list type value spec) gnus-format-specs)
2450 (pop-to-buffer "*Gnus Format*")
2452 (lisp-interaction-mode)
2453 (insert (pp-to-string spec))))
2455 (defun gnus-update-format-specifications (&optional force)
2456 "Update all (necessary) format specifications."
2457 ;; Make the indentation array.
2458 (gnus-make-thread-indent-array)
2460 ;; See whether all the stored info needs to be flushed.
2462 (not (equal emacs-version
2463 (cdr (assq 'version gnus-format-specs)))))
2464 (setq gnus-format-specs nil))
2466 ;; Go through all the formats and see whether they need updating.
2467 (let ((types '(summary summary-dummy group
2468 summary-mode group-mode article-mode))
2469 new-format entry type val)
2470 (while (setq type (pop types))
2471 ;; Jump to the proper buffer to find out the value of
2472 ;; the variable, if possible. (It may be buffer-local.)
2474 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2476 (when (and (boundp buffer)
2477 (setq val (symbol-value buffer))
2479 (buffer-name (get-buffer val)))
2480 (set-buffer (get-buffer val)))
2481 (setq new-format (symbol-value
2482 (intern (format "gnus-%s-line-format" type))))))
2483 (setq entry (cdr (assq type gnus-format-specs)))
2485 (equal (car entry) new-format))
2486 ;; Use the old format.
2487 (set (intern (format "gnus-%s-line-format-spec" type))
2489 ;; This is a new format.
2491 (if (not (stringp new-format))
2492 ;; This is a function call or something.
2494 ;; This is a "real" format.
2498 (intern (format "gnus-%s-line-format-alist"
2499 (if (eq type 'article-mode)
2500 'summary-mode type))))
2501 (not (string-match "mode$" (symbol-name type))))))
2502 ;; Enter the new format spec into the list.
2505 (setcar (cdr entry) val)
2506 (setcar entry new-format))
2507 (push (list type new-format val) gnus-format-specs))
2508 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2510 (unless (assq 'version gnus-format-specs)
2511 (push (cons 'version emacs-version) gnus-format-specs))
2513 (gnus-update-group-mark-positions)
2514 (gnus-update-summary-mark-positions))
2516 (defun gnus-update-summary-mark-positions ()
2517 "Compute where the summary marks are to go."
2519 (let ((gnus-replied-mark 129)
2520 (gnus-score-below-mark 130)
2521 (gnus-score-over-mark 130)
2525 (gnus-set-work-buffer)
2526 (gnus-summary-insert-line
2527 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2528 (goto-char (point-min))
2529 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2531 (goto-char (point-min))
2532 (push (cons 'replied (and (search-forward "\201" nil t) (- (point) 2)))
2534 (goto-char (point-min))
2535 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2537 (setq gnus-summary-mark-positions pos))))
2539 (defun gnus-update-group-mark-positions ()
2541 (let ((gnus-process-mark 128)
2542 (gnus-group-marked '("dummy.group")))
2543 (gnus-set-active "dummy.group" '(0 . 0))
2544 (gnus-set-work-buffer)
2545 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2546 (goto-char (point-min))
2547 (setq gnus-group-mark-positions
2548 (list (cons 'process (and (search-forward "\200" nil t)
2549 (- (point) 2))))))))
2551 (defvar gnus-mouse-face-0 'highlight)
2552 (defvar gnus-mouse-face-1 'highlight)
2553 (defvar gnus-mouse-face-2 'highlight)
2554 (defvar gnus-mouse-face-3 'highlight)
2555 (defvar gnus-mouse-face-4 'highlight)
2557 (defun gnus-mouse-face-function (form type)
2559 (point) (progn ,@form (point))
2560 gnus-mouse-face-prop
2563 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2565 (defvar gnus-face-0 'bold)
2566 (defvar gnus-face-1 'italic)
2567 (defvar gnus-face-2 'bold-italic)
2568 (defvar gnus-face-3 'bold)
2569 (defvar gnus-face-4 'bold)
2571 (defun gnus-face-face-function (form type)
2573 (point) (progn ,@form (point))
2574 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2576 (defun gnus-max-width-function (el max-width)
2577 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2579 `(if (> (length ,el) ,max-width)
2580 (substring ,el 0 ,max-width)
2582 `(let ((val (eval ,el)))
2584 (setq val (int-to-string val)))
2585 (if (> (length val) ,max-width)
2586 (substring val 0 ,max-width)
2589 (defun gnus-parse-format (format spec-alist &optional insert)
2590 ;; This function parses the FORMAT string with the help of the
2591 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2592 ;; string. If the FORMAT string contains the specifiers %( and %)
2593 ;; the text between them will have the mouse-face text property.
2595 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2597 (gnus-parse-complex-format format spec-alist)
2598 ;; This is a simple format.
2599 (gnus-parse-simple-format format spec-alist insert)))
2601 (defun gnus-parse-complex-format (format spec-alist)
2603 (gnus-set-work-buffer)
2605 (goto-char (point-min))
2606 (while (re-search-forward "\"" nil t)
2607 (replace-match "\\\"" nil t))
2608 (goto-char (point-min))
2610 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2611 (let ((number (if (match-beginning 1)
2612 (match-string 1) "0"))
2613 (delim (aref (match-string 2) 0)))
2614 (if (or (= delim ?\() (= delim ?\{))
2615 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2617 (replace-match "\")\""))))
2618 (goto-char (point-max))
2620 (goto-char (point-min))
2621 (let ((form (read (current-buffer))))
2622 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2624 (defun gnus-complex-form-to-spec (form spec-alist)
2629 (gnus-parse-simple-format sform spec-alist t)
2630 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2631 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2635 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2636 ;; This function parses the FORMAT string with the help of the
2637 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2640 spec flist fstring newspec elem beg result dontinsert)
2642 (gnus-set-work-buffer)
2644 (goto-char (point-min))
2645 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2647 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2649 beg (1+ (match-beginning 0)))
2650 ;; First check if there are any specs that look anything like
2651 ;; "%12,12A", ie. with a "max width specification". These have
2652 ;; to be treated specially.
2653 (if (setq beg (match-beginning 1))
2657 (1+ (match-beginning 1)) (match-end 1))))
2659 (setq beg (match-beginning 2)))
2660 ;; Find the specification from `spec-alist'.
2661 (unless (setq elem (cdr (assq spec spec-alist)))
2662 (setq elem '("*" ?s)))
2663 ;; Treat user defined format specifiers specially.
2664 (when (eq (car elem) 'gnus-tmp-user-defined)
2667 (list (intern (concat "gnus-user-format-function-"
2669 'gnus-tmp-header) ?s))
2670 (delete-region (match-beginning 3) (match-end 3)))
2671 (if (not (zerop max-width))
2672 (let ((el (car elem)))
2673 (cond ((= (cadr elem) ?c)
2674 (setq el (list 'char-to-string el)))
2676 (setq el (list 'int-to-string el))))
2677 (setq flist (cons (gnus-max-width-function el max-width)
2681 (setq flist (cons (car elem) flist))
2682 (setq newspec (cadr elem)))))
2683 ;; Remove the old specification (and possibly a ",12" string).
2684 (delete-region beg (match-end 2))
2685 ;; Insert the new specification.
2688 (setq fstring (buffer-substring 1 (point-max))))
2689 ;; Do some postprocessing to increase efficiency.
2694 ((string= fstring "")
2696 ;; Not a format string.
2697 ((not (string-match "%" fstring))
2699 ;; A format string with just a single string spec.
2700 ((string= fstring "%s")
2702 ;; A single character.
2703 ((string= fstring "%c")
2706 ((string= fstring "%d")
2709 (list `(princ ,(car flist)))
2710 (list `(int-to-string ,(car flist)))))
2711 ;; Just lots of chars and strings.
2712 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2714 ;; A single string spec at the beginning of the spec.
2715 ((string-match "\\`%[sc][^%]+\\'" fstring)
2716 (list (car flist) (substring fstring 2)))
2717 ;; A single string spec in the middle of the spec.
2718 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2719 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2720 ;; A single string spec in the end of the spec.
2721 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2722 (list (match-string 1 fstring) (car flist)))
2723 ;; A more complex spec.
2725 (list (cons 'format (cons fstring (nreverse flist)))))))
2731 (cons 'insert result)))
2732 (cond ((stringp result)
2735 (cons 'concat result))
2738 (defun gnus-eval-format (format &optional alist props)
2739 "Eval the format variable FORMAT, using ALIST.
2740 If PROPS, insert the result."
2741 (let ((form (gnus-parse-format format alist props)))
2743 (add-text-properties (point) (progn (eval form) (point)) props)
2746 (defun gnus-remove-text-with-property (prop)
2747 "Delete all text in the current buffer with text property PROP."
2749 (goto-char (point-min))
2751 (while (get-text-property (point) prop)
2753 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2755 (defun gnus-set-work-buffer ()
2756 (if (get-buffer gnus-work-buffer)
2758 (set-buffer gnus-work-buffer)
2760 (set-buffer (get-buffer-create gnus-work-buffer))
2761 (kill-all-local-variables)
2762 (buffer-disable-undo (current-buffer))
2763 (gnus-add-current-to-buffer-list)))
2765 ;; Article file names when saving.
2767 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2768 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2769 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2770 Otherwise, it is like ~/News/news/group/num."
2773 (concat (if (gnus-use-long-file-name 'not-save)
2774 (gnus-capitalize-newsgroup newsgroup)
2775 (gnus-newsgroup-directory-form newsgroup))
2776 "/" (int-to-string (mail-header-number headers)))
2777 (or gnus-article-save-directory "~/News"))))
2779 (string-equal (file-name-directory default)
2780 (file-name-directory last-file))
2781 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2783 (or last-file default))))
2785 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2786 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2787 If variable `gnus-use-long-file-name' is non-nil, it is
2788 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2791 (concat (if (gnus-use-long-file-name 'not-save)
2793 (gnus-newsgroup-directory-form newsgroup))
2794 "/" (int-to-string (mail-header-number headers)))
2795 (or gnus-article-save-directory "~/News"))))
2797 (string-equal (file-name-directory default)
2798 (file-name-directory last-file))
2799 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2801 (or last-file default))))
2803 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2804 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2805 If variable `gnus-use-long-file-name' is non-nil, it is
2806 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2809 (if (gnus-use-long-file-name 'not-save)
2810 (gnus-capitalize-newsgroup newsgroup)
2811 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2812 (or gnus-article-save-directory "~/News"))))
2814 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2815 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2816 If variable `gnus-use-long-file-name' is non-nil, it is
2817 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2820 (if (gnus-use-long-file-name 'not-save)
2822 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2823 (or gnus-article-save-directory "~/News"))))
2825 ;; For subscribing new newsgroup
2827 (defun gnus-subscribe-hierarchical-interactive (groups)
2828 (let ((groups (sort groups 'string<))
2829 prefixes prefix start ans group starts)
2831 (setq prefixes (list "^"))
2832 (while (and groups prefixes)
2833 (while (not (string-match (car prefixes) (car groups)))
2834 (setq prefixes (cdr prefixes)))
2835 (setq prefix (car prefixes))
2836 (setq start (1- (length prefix)))
2837 (if (and (string-match "[^\\.]\\." (car groups) start)
2840 (concat "^" (substring (car groups) 0 (match-end 0))))
2841 (string-match prefix (cadr groups)))
2843 (setq prefixes (cons prefix prefixes))
2844 (message "Descend hierarchy %s? ([y]nsq): "
2845 (substring prefix 1 (1- (length prefix))))
2846 (setq ans (read-char))
2849 (string-match prefix
2850 (setq group (car groups))))
2851 (setq gnus-killed-list
2852 (cons group gnus-killed-list))
2853 (gnus-sethash group group gnus-killed-hashtb)
2854 (setq groups (cdr groups)))
2855 (setq starts (cdr starts)))
2858 (string-match prefix
2859 (setq group (car groups))))
2860 (gnus-sethash group group gnus-killed-hashtb)
2861 (gnus-subscribe-alphabetically (car groups))
2862 (setq groups (cdr groups)))
2863 (setq starts (cdr starts)))
2866 (setq group (car groups))
2867 (setq gnus-killed-list (cons group gnus-killed-list))
2868 (gnus-sethash group group gnus-killed-hashtb)
2869 (setq groups (cdr groups))))
2871 (message "Subscribe %s? ([n]yq)" (car groups))
2872 (setq ans (read-char))
2873 (setq group (car groups))
2875 (gnus-subscribe-alphabetically (car groups))
2876 (gnus-sethash group group gnus-killed-hashtb))
2879 (setq group (car groups))
2880 (setq gnus-killed-list (cons group gnus-killed-list))
2881 (gnus-sethash group group gnus-killed-hashtb)
2882 (setq groups (cdr groups))))
2884 (setq gnus-killed-list (cons group gnus-killed-list))
2885 (gnus-sethash group group gnus-killed-hashtb)))
2886 (setq groups (cdr groups)))))))
2888 (defun gnus-subscribe-randomly (newsgroup)
2889 "Subscribe new NEWSGROUP by making it the first newsgroup."
2890 (gnus-subscribe-newsgroup newsgroup))
2892 (defun gnus-subscribe-alphabetically (newgroup)
2893 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2894 (let ((groups (cdr gnus-newsrc-alist))
2896 (while (and (not before) groups)
2897 (if (string< newgroup (caar groups))
2898 (setq before (caar groups))
2899 (setq groups (cdr groups))))
2900 (gnus-subscribe-newsgroup newgroup before)))
2902 (defun gnus-subscribe-hierarchically (newgroup)
2903 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2904 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2906 (set-buffer (find-file-noselect gnus-current-startup-file))
2907 (let ((groupkey newgroup)
2909 (while (and (not before) groupkey)
2910 (goto-char (point-min))
2912 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2913 (while (and (re-search-forward groupkey-re nil t)
2915 (setq before (match-string 1))
2916 (string< before newgroup)))))
2917 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2919 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2920 (substring groupkey (match-beginning 1) (match-end 1)))))
2921 (gnus-subscribe-newsgroup newgroup before))))
2923 (defun gnus-subscribe-interactively (group)
2924 "Subscribe the new GROUP interactively.
2925 It is inserted in hierarchical newsgroup order if subscribed. If not,
2927 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
2928 (gnus-subscribe-hierarchically group)
2929 (push group gnus-killed-list)))
2931 (defun gnus-subscribe-zombies (group)
2932 "Make the new GROUP into a zombie group."
2933 (push group gnus-zombie-list))
2935 (defun gnus-subscribe-killed (group)
2936 "Make the new GROUP a killed group."
2937 (push group gnus-killed-list))
2939 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2940 "Subscribe new NEWSGROUP.
2941 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2942 the first newsgroup."
2943 ;; We subscribe the group by changing its level to `subscribed'.
2944 (gnus-group-change-level
2945 newsgroup gnus-level-default-subscribed
2946 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2947 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2951 (defun gnus-newsgroup-directory-form (newsgroup)
2952 "Make hierarchical directory name from NEWSGROUP name."
2953 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
2954 (len (length newsgroup))
2956 ;; If this is a foreign group, we don't want to translate the
2958 (if (setq idx (string-match ":" newsgroup))
2959 (aset newsgroup idx ?/)
2961 ;; Replace all occurrences of `.' with `/'.
2963 (if (= (aref newsgroup idx) ?.)
2964 (aset newsgroup idx ?/))
2965 (setq idx (1+ idx)))
2968 (defun gnus-newsgroup-savable-name (group)
2969 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2971 (nnheader-replace-chars-in-string group ?/ ?.))
2973 (defun gnus-make-directory (dir)
2974 "Make DIRECTORY recursively."
2975 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2976 ;; of the many mysteries of the universe.
2977 (let* ((dir (expand-file-name dir default-directory))
2979 (if (string-match "/$" dir)
2980 (setq dir (substring dir 0 (match-beginning 0))))
2981 ;; First go down the path until we find a directory that exists.
2982 (while (not (file-exists-p dir))
2983 (setq dirs (cons dir dirs))
2984 (string-match "/[^/]+$" dir)
2985 (setq dir (substring dir 0 (match-beginning 0))))
2986 ;; Then create all the subdirs.
2987 (while (and dirs (not err))
2989 (make-directory (car dirs))
2990 (error (setq err t)))
2991 (setq dirs (cdr dirs)))
2992 ;; We return whether we were successful or not.
2995 (defun gnus-capitalize-newsgroup (newsgroup)
2996 "Capitalize NEWSGROUP name."
2997 (and (not (zerop (length newsgroup)))
2998 (concat (char-to-string (upcase (aref newsgroup 0)))
2999 (substring newsgroup 1))))
3001 ;; Various... things.
3003 (defun gnus-simplify-subject (subject &optional re-only)
3004 "Remove `Re:' and words in parentheses.
3005 If RE-ONLY is non-nil, strip leading `Re:'s only."
3006 (let ((case-fold-search t)) ;Ignore case.
3007 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3008 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3009 (setq subject (substring subject (match-end 0))))
3010 ;; Remove uninteresting prefixes.
3011 (if (and (not re-only)
3012 gnus-simplify-ignored-prefixes
3013 (string-match gnus-simplify-ignored-prefixes subject))
3014 (setq subject (substring subject (match-end 0))))
3015 ;; Remove words in parentheses from end.
3017 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3018 (setq subject (substring subject 0 (match-beginning 0)))))
3019 ;; Return subject string.
3022 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3024 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3025 (defun gnus-simplify-buffer-fuzzy ()
3026 (goto-char (point-min))
3027 (while (search-forward "\t" nil t)
3028 (replace-match " " t t))
3029 (goto-char (point-min))
3030 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3031 (goto-char (match-beginning 0))
3033 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3034 (looking-at "^[[].*: .*[]]$"))
3035 (goto-char (point-min))
3036 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3038 (replace-match "" t t))
3039 (goto-char (point-min))
3040 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3041 (goto-char (match-end 0))
3044 (progn (goto-char (match-beginning 0)))
3045 (re-search-forward ":"))))
3046 (goto-char (point-min))
3047 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3048 (replace-match "" t t))
3049 (goto-char (point-min))
3050 (while (re-search-forward " +" nil t)
3051 (replace-match " " t t))
3052 (goto-char (point-min))
3053 (while (re-search-forward " $" nil t)
3054 (replace-match "" t t))
3055 (goto-char (point-min))
3056 (while (re-search-forward "^ +" nil t)
3057 (replace-match "" t t))
3058 (goto-char (point-min))
3059 (when gnus-simplify-subject-fuzzy-regexp
3060 (if (listp gnus-simplify-subject-fuzzy-regexp)
3061 (let ((list gnus-simplify-subject-fuzzy-regexp))
3063 (goto-char (point-min))
3064 (while (re-search-forward (car list) nil t)
3065 (replace-match "" t t))
3066 (setq list (cdr list))))
3067 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3068 (replace-match "" t t)))))
3070 (defun gnus-simplify-subject-fuzzy (subject)
3071 "Siplify a subject string fuzzily."
3073 (gnus-set-work-buffer)
3074 (let ((case-fold-search t))
3076 (inline (gnus-simplify-buffer-fuzzy))
3079 ;; Add the current buffer to the list of buffers to be killed on exit.
3080 (defun gnus-add-current-to-buffer-list ()
3081 (or (memq (current-buffer) gnus-buffer-list)
3082 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3084 (defun gnus-string> (s1 s2)
3085 (not (or (string< s1 s2)
3088 ;;; General various misc type functions.
3090 (defun gnus-clear-system ()
3091 "Clear all variables and buffers."
3092 ;; Clear Gnus variables.
3093 (let ((variables gnus-variable-list))
3095 (set (car variables) nil)
3096 (setq variables (cdr variables))))
3097 ;; Clear other internal variables.
3098 (setq gnus-list-of-killed-groups nil
3099 gnus-have-read-active-file nil
3100 gnus-newsrc-alist nil
3101 gnus-newsrc-hashtb nil
3102 gnus-killed-list nil
3103 gnus-zombie-list nil
3104 gnus-killed-hashtb nil
3105 gnus-active-hashtb nil
3106 gnus-moderated-list nil
3107 gnus-description-hashtb nil
3108 gnus-current-headers nil
3109 gnus-thread-indent-array nil
3110 gnus-newsgroup-headers nil
3111 gnus-newsgroup-name nil
3112 gnus-server-alist nil
3113 gnus-group-list-mode nil
3114 gnus-opened-servers nil
3115 gnus-current-select-method nil)
3116 (gnus-shutdown 'gnus)
3117 ;; Kill the startup file.
3118 (and gnus-current-startup-file
3119 (get-file-buffer gnus-current-startup-file)
3120 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3121 ;; Clear the dribble buffer.
3122 (gnus-dribble-clear)
3123 ;; Kill global KILL file buffer.
3124 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3125 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3126 (gnus-kill-buffer nntp-server-buffer)
3127 ;; Kill Gnus buffers.
3128 (while gnus-buffer-list
3129 (gnus-kill-buffer (pop gnus-buffer-list)))
3130 ;; Remove Gnus frames.
3131 (while gnus-created-frames
3132 (when (frame-live-p (car gnus-created-frames))
3133 ;; We slap a condition-case around this `delete-frame' to ensure
3134 ;; agains errors if we try do delete the single frame that's left.
3136 (delete-frame (car gnus-created-frames))
3138 (pop gnus-created-frames)))
3140 (defun gnus-windows-old-to-new (setting)
3141 ;; First we take care of the really, really old Gnus 3 actions.
3142 (when (symbolp setting)
3144 ;; Take care of ooold GNUS 3.x values.
3145 (cond ((eq setting 'SelectArticle) 'article)
3146 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3147 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3149 (if (or (listp setting)
3150 (not (and gnus-window-configuration
3151 (memq setting '(group summary article)))))
3153 (let* ((setting (if (eq setting 'group)
3154 (if (assq 'newsgroup gnus-window-configuration)
3156 'newsgroups) setting))
3157 (elem (cadr (assq setting gnus-window-configuration)))
3158 (total (apply '+ elem))
3159 (types '(group summary article))
3160 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3165 (or (not (numberp (nth i elem)))
3166 (zerop (nth i elem))
3168 (setq perc (/ (float (nth 0 elem)) total))
3169 (setq out (cons (if (eq pbuf (nth i types))
3170 (vector (nth i types) perc 'point)
3171 (vector (nth i types) perc))
3174 (list (nreverse out)))))
3177 (defun gnus-add-configuration (conf)
3178 "Add the window configuration CONF to `gnus-buffer-configuration'."
3179 (setq gnus-buffer-configuration
3180 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3181 gnus-buffer-configuration))))
3183 (defvar gnus-frame-list nil)
3185 (defun gnus-configure-frame (split &optional window)
3186 "Split WINDOW according to SPLIT."
3188 (setq window (get-buffer-window (current-buffer))))
3189 (select-window window)
3190 ;; This might be an old-stylee buffer config.
3191 (when (vectorp split)
3192 (setq split (append split nil)))
3193 (when (or (consp (car split))
3194 (vectorp (car split)))
3196 (push 'vertical split))
3197 ;; The SPLIT might be something that is to be evaled to
3198 ;; return a new SPLIT.
3199 (while (and (not (assq (car split) gnus-window-to-buffer))
3200 (gnus-functionp (car split)))
3201 (setq split (eval split)))
3202 (let* ((type (car split))
3204 (len (if (eq type 'horizontal) (window-width) (window-height)))
3206 (window-min-width (or gnus-window-min-width window-min-width))
3207 (window-min-height (or gnus-window-min-height window-min-height))
3208 s result new-win rest comp-subs size sub)
3210 ;; Nothing to do here.
3212 ;; Don't switch buffers.
3214 (and (memq 'point split) window))
3215 ;; This is a buffer to be selected.
3216 ((not (memq type '(frame horizontal vertical)))
3217 (let ((buffer (cond ((stringp type) type)
3218 (t (cdr (assq type gnus-window-to-buffer)))))
3221 (error "Illegal buffer type: %s" type))
3222 (unless (setq buf (get-buffer (if (symbolp buffer)
3223 (symbol-value buffer) buffer)))
3224 (setq buf (get-buffer-create (if (symbolp buffer)
3225 (symbol-value buffer) buffer))))
3226 (switch-to-buffer buf)
3227 ;; We return the window if it has the `point' spec.
3228 (and (memq 'point split) window)))
3229 ;; This is a frame split.
3231 (unless gnus-frame-list
3232 (setq gnus-frame-list (list (window-frame
3233 (get-buffer-window (current-buffer))))))
3235 params frame fresult)
3236 (while (< i (length subs))
3237 ;; Frame parameter is gotten from the sub-split.
3238 (setq params (cadr (elt subs i)))
3239 ;; It should be a list.
3240 (unless (listp params)
3242 ;; Create a new frame?
3243 (unless (setq frame (elt gnus-frame-list i))
3244 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3245 (push frame gnus-created-frames))
3246 ;; Is the old frame still alive?
3247 (unless (frame-live-p frame)
3248 (setcar (nthcdr i gnus-frame-list)
3249 (setq frame (make-frame params))))
3250 ;; Select the frame in question and do more splits there.
3251 (select-frame frame)
3252 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3254 ;; Select the frame that has the selected buffer.
3256 (select-frame (window-frame fresult)))))
3257 ;; This is a normal split.
3259 (when (> (length subs) 0)
3260 ;; First we have to compute the sizes of all new windows.
3262 (setq sub (append (pop subs) nil))
3263 (while (and (not (assq (car sub) gnus-window-to-buffer))
3264 (gnus-functionp (car sub)))
3265 (setq sub (eval sub)))
3267 (push sub comp-subs)
3268 (setq size (cadar comp-subs))
3269 (cond ((equal size 1.0)
3270 (setq rest (car comp-subs))
3273 (setq s (floor (* size len))))
3277 (error "Illegal size: %s" size)))
3278 ;; Try to make sure that we are inside the safe limits.
3280 ((eq type 'horizontal)
3281 (setq s (max s window-min-width)))
3282 ((eq type 'vertical)
3283 (setq s (max s window-min-height))))
3284 (setcar (cdar comp-subs) s)
3286 ;; Take care of the "1.0" spec.
3288 (setcar (cdr rest) (- len total))
3289 (error "No 1.0 specs in %s" split))
3290 ;; The we do the actual splitting in a nice recursive
3292 (setq comp-subs (nreverse comp-subs))
3294 (if (null (cdr comp-subs))
3295 (setq new-win window)
3297 (split-window window (cadar comp-subs)
3298 (eq type 'horizontal))))
3299 (setq result (or (gnus-configure-frame
3300 (car comp-subs) window) result))
3301 (select-window new-win)
3302 (setq window new-win)
3303 (setq comp-subs (cdr comp-subs))))
3304 ;; Return the proper window, if any.
3306 (select-window result))))))
3308 (defvar gnus-frame-split-p nil)
3310 (defun gnus-configure-windows (setting &optional force)
3311 (setq setting (gnus-windows-old-to-new setting))
3312 (let ((split (if (symbolp setting)
3313 (cadr (assq setting gnus-buffer-configuration))
3317 (setq gnus-frame-split-p nil)
3320 (error "No such setting: %s" setting))
3322 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3324 ;; All the windows mentioned are already visible, so we just
3325 ;; put point in the assigned buffer, and do not touch the
3327 (select-window all-visible)
3329 ;; Either remove all windows or just remove all Gnus windows.
3330 (let ((frame (selected-frame)))
3332 (if gnus-use-full-window
3333 ;; We want to remove all other windows.
3334 (if (not gnus-frame-split-p)
3335 ;; This is not a `frame' split, so we ignore the
3337 (delete-other-windows)
3338 ;; This is a `frame' split, so we delete all windows
3342 (unless (eq (cdr (assq 'minibuffer
3343 (frame-parameters frame)))
3345 (select-frame frame)
3346 (delete-other-windows)))
3348 ;; Just remove some windows.
3349 (gnus-remove-some-windows)
3350 (switch-to-buffer nntp-server-buffer))
3351 (select-frame frame)))
3353 (switch-to-buffer nntp-server-buffer)
3354 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3356 (defun gnus-all-windows-visible-p (split)
3357 "Say whether all buffers in SPLIT are currently visible.
3358 In particular, the value returned will be the window that
3360 (let ((stack (list split))
3362 type buffer win buf)
3363 (while (and (setq split (pop stack))
3365 ;; Be backwards compatible.
3366 (when (vectorp split)
3367 (setq split (append split nil)))
3368 (when (or (consp (car split))
3369 (vectorp (car split)))
3371 (push 'vertical split))
3372 ;; The SPLIT might be something that is to be evaled to
3373 ;; return a new SPLIT.
3374 (while (and (not (assq (car split) gnus-window-to-buffer))
3375 (gnus-functionp (car split)))
3376 (setq split (eval split)))
3378 (setq type (elt split 0))
3383 ((not (memq type '(horizontal vertical frame)))
3384 (setq buffer (cond ((stringp type) type)
3385 (t (cdr (assq type gnus-window-to-buffer)))))
3387 (error "Illegal buffer type: %s" type))
3388 (when (setq buf (get-buffer (if (symbolp buffer)
3389 (symbol-value buffer)
3391 (setq win (get-buffer-window buf t)))
3393 (when (memq 'point split)
3394 (setq all-visible win))
3395 (setq all-visible nil)))
3397 (when (eq type 'frame)
3398 (setq gnus-frame-split-p t))
3399 (setq stack (append (cddr split) stack)))))
3400 (unless (eq all-visible t)
3403 (defun gnus-window-top-edge (&optional window)
3404 (nth 1 (window-edges window)))
3406 (defun gnus-remove-some-windows ()
3407 (let ((buffers gnus-window-to-buffer)
3408 buf bufs lowest-buf lowest)
3410 ;; Remove windows on all known Gnus buffers.
3412 (setq buf (cdar buffers))
3414 (setq buf (and (boundp buf) (symbol-value buf))))
3416 (get-buffer-window buf)
3418 (setq bufs (cons buf bufs))
3420 (if (or (not lowest)
3421 (< (gnus-window-top-edge) lowest))
3423 (setq lowest (gnus-window-top-edge))
3424 (setq lowest-buf buf)))))
3425 (setq buffers (cdr buffers)))
3426 ;; Remove windows on *all* summary buffers.
3429 (let ((buf (window-buffer win)))
3430 (if (string-match "^\\*Summary" (buffer-name buf))
3432 (setq bufs (cons buf bufs))
3434 (if (or (not lowest)
3435 (< (gnus-window-top-edge) lowest))
3437 (setq lowest-buf buf)
3438 (setq lowest (gnus-window-top-edge)))))))))
3441 (pop-to-buffer lowest-buf)
3442 (switch-to-buffer nntp-server-buffer)))
3444 (and (not (eq (car bufs) lowest-buf))
3445 (delete-windows-on (car bufs)))
3446 (setq bufs (cdr bufs))))))
3448 (defun gnus-version ()
3449 "Version numbers of this version of Gnus."
3451 (let ((methods gnus-valid-select-methods)
3454 ;; Go through all the legal select methods and add their version
3455 ;; numbers to the total version string. Only the backends that are
3456 ;; currently in use will have their message numbers taken into
3459 (setq meth (intern (concat (caar methods) "-version")))
3461 (stringp (symbol-value meth))
3462 (setq mess (concat mess "; " (symbol-value meth))))
3463 (setq methods (cdr methods)))
3464 (gnus-message 2 mess)))
3466 (defun gnus-info-find-node ()
3467 "Find Info documentation of Gnus."
3469 ;; Enlarge info window if needed.
3470 (let ((mode major-mode)
3472 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3473 (setq gnus-info-buffer (current-buffer))
3474 (gnus-configure-windows 'info)))
3476 (defun gnus-days-between (date1 date2)
3477 ;; Return the number of days between date1 and date2.
3478 (- (gnus-day-number date1) (gnus-day-number date2)))
3480 (defun gnus-day-number (date)
3481 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3482 (timezone-parse-date date))))
3483 (timezone-absolute-from-gregorian
3484 (nth 1 dat) (nth 2 dat) (car dat))))
3486 (defun gnus-encode-date (date)
3487 "Convert DATE to internal time."
3488 (let* ((parse (timezone-parse-date date))
3489 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3490 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3491 (encode-time (caddr time) (cadr time) (car time)
3492 (caddr date) (cadr date) (car date) (nth 4 date))))
3494 (defun gnus-time-minus (t1 t2)
3495 "Subtract two internal times."
3496 (let ((borrow (< (cadr t1) (cadr t2))))
3497 (list (- (car t1) (car t2) (if borrow 1 0))
3498 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3500 (defun gnus-file-newer-than (file date)
3501 (let ((fdate (nth 5 (file-attributes file))))
3502 (or (> (car fdate) (car date))
3503 (and (= (car fdate) (car date))
3504 (> (nth 1 fdate) (nth 1 date))))))
3506 (defmacro gnus-local-set-keys (&rest plist)
3507 "Set the keys in PLIST in the current keymap."
3508 `(gnus-define-keys-1 (current-local-map) ',plist))
3510 (defmacro gnus-define-keys (keymap &rest plist)
3511 "Define all keys in PLIST in KEYMAP."
3512 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3514 (put 'gnus-define-keys 'lisp-indent-function 1)
3515 (put 'gnus-define-keys 'lisp-indent-hook 1)
3516 (put 'gnus-define-keymap 'lisp-indent-function 1)
3517 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3519 (defmacro gnus-define-keymap (keymap &rest plist)
3520 "Define all keys in PLIST in KEYMAP."
3521 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3523 (defun gnus-define-keys-1 (keymap plist)
3525 (error "Can't set keys in a null keymap"))
3526 (cond ((symbolp keymap)
3527 (setq keymap (symbol-value keymap)))
3530 (set (car keymap) nil)
3531 (define-prefix-command (car keymap))
3532 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3533 (setq keymap (symbol-value (car keymap)))))
3536 (when (symbolp (setq key (pop plist)))
3537 (setq key (symbol-value key)))
3538 (define-key keymap key (pop plist)))))
3540 (defun gnus-group-read-only-p (&optional group)
3541 "Check whether GROUP supports editing or not.
3542 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3543 that that variable is buffer-local to the summary buffers."
3544 (let ((group (or group gnus-newsgroup-name)))
3545 (not (gnus-check-backend-function 'request-replace-article group))))
3547 (defun gnus-group-total-expirable-p (group)
3548 "Check whether GROUP is total-expirable or not."
3549 (let ((params (gnus-info-params (gnus-get-info group))))
3550 (or (memq 'total-expire params)
3551 (cdr (assq 'total-expire params)) ; (total-expire . t)
3552 (and gnus-total-expirable-newsgroups ; Check var.
3553 (string-match gnus-total-expirable-newsgroups group)))))
3555 (defun gnus-group-auto-expirable-p (group)
3556 "Check whether GROUP is total-expirable or not."
3557 (let ((params (gnus-info-params (gnus-get-info group))))
3558 (or (memq 'auto-expire params)
3559 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3560 (and gnus-auto-expirable-newsgroups ; Check var.
3561 (string-match gnus-auto-expirable-newsgroups group)))))
3563 (defun gnus-virtual-group-p (group)
3564 "Say whether GROUP is virtual or not."
3565 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3566 gnus-valid-select-methods)))
3568 (defsubst gnus-simplify-subject-fully (subject)
3569 "Simplify a subject string according to the user's wishes."
3571 ((null gnus-summary-gather-subject-limit)
3572 (gnus-simplify-subject-re subject))
3573 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3574 (gnus-simplify-subject-fuzzy subject))
3575 ((numberp gnus-summary-gather-subject-limit)
3576 (gnus-limit-string (gnus-simplify-subject-re subject)
3577 gnus-summary-gather-subject-limit))
3581 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3582 "Check whether two subjects are equal. If optional argument
3583 simple-first is t, first argument is already simplified."
3585 ((null simple-first)
3586 (equal (gnus-simplify-subject-fully s1)
3587 (gnus-simplify-subject-fully s2)))
3590 (gnus-simplify-subject-fully s2)))))
3592 ;; Returns a list of writable groups.
3593 (defun gnus-writable-groups ()
3594 (let ((alist gnus-newsrc-alist)
3596 (while (setq group (car (pop alist)))
3597 (unless (gnus-group-read-only-p group)
3598 (push group groups)))
3601 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3603 (defun gnus-y-or-n-p (prompt)
3608 (defun gnus-yes-or-no-p (prompt)
3610 (yes-or-no-p prompt)
3613 ;; Check whether to use long file names.
3614 (defun gnus-use-long-file-name (symbol)
3615 ;; The variable has to be set...
3616 (and gnus-use-long-file-name
3617 ;; If it isn't a list, then we return t.
3618 (or (not (listp gnus-use-long-file-name))
3619 ;; If it is a list, and the list contains `symbol', we
3621 (not (memq symbol gnus-use-long-file-name)))))
3623 ;; I suspect there's a better way, but I haven't taken the time to do
3624 ;; it yet. -erik selberg@cs.washington.edu
3625 (defun gnus-dd-mmm (messy-date)
3626 "Return a string like DD-MMM from a big messy string"
3627 (let ((datevec (timezone-parse-date messy-date)))
3630 ;; Make sure leading zeroes are stripped.
3631 (number-to-string (string-to-number (aref datevec 2)))
3635 (nth (1- (string-to-number (aref datevec 1)))
3636 timezone-months-assoc))
3639 ;; Make a hash table (default and minimum size is 255).
3640 ;; Optional argument HASHSIZE specifies the table size.
3641 (defun gnus-make-hashtable (&optional hashsize)
3642 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3644 ;; Make a number that is suitable for hashing; bigger than MIN and one
3646 (defun gnus-create-hash-size (min)
3652 ;; Show message if message has a lower level than `gnus-verbose'.
3653 ;; Guideline for numbers:
3654 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3655 ;; for things that take a long time, 7 - not very important messages
3656 ;; on stuff, 9 - messages inside loops.
3657 (defun gnus-message (level &rest args)
3658 (if (<= level gnus-verbose)
3659 (apply 'message args)
3660 ;; We have to do this format thingy here even if the result isn't
3661 ;; shown - the return value has to be the same as the return value
3663 (apply 'format args)))
3665 ;; Generate a unique new group name.
3666 (defun gnus-generate-new-group-name (leaf)
3669 (while (gnus-gethash name gnus-newsrc-hashtb)
3670 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3673 (defsubst gnus-hide-text (b e props)
3674 "Set text PROPS on the B to E region, extending `intangble' 1 past B."
3675 (add-text-properties b e props)
3676 (when (memq 'intangible props)
3677 (put-text-property (max (1- b) (point-min))
3678 b 'intangible (cddr (memq 'intangible props)))))
3680 (defsubst gnus-unhide-text (b e)
3681 "Remove hidden text properties from region between B and E."
3682 (remove-text-properties b e gnus-hidden-properties)
3683 (when (memq 'intangible gnus-hidden-properties)
3684 (put-text-property (max (1- b) (point-min))
3685 b 'intangible nil)))
3687 (defun gnus-hide-text-type (b e type)
3688 "Hide text of TYPE between B and E."
3689 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3691 ;; Find out whether the gnus-visual TYPE is wanted.
3692 (defun gnus-visual-p (&optional type class)
3693 (and gnus-visual ; Has to be non-nil, at least.
3694 (if (not type) ; We don't care about type.
3696 (if (listp gnus-visual) ; It's a list, so we check it.
3697 (or (memq type gnus-visual)
3698 (memq class gnus-visual))
3701 (defun gnus-parent-id (references)
3702 "Return the last Message-ID in REFERENCES."
3703 (when (and references
3704 (string-match "\\(<[^<>]+>\\)[ \t\n]*\\'" references))
3705 (substring references (match-beginning 1) (match-end 1))))
3707 (defun gnus-split-references (references)
3708 "Return a list of Message-IDs in REFERENCES."
3711 (while (string-match "<[^>]+>" references beg)
3712 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3716 (defun gnus-buffer-live-p (buffer)
3717 "Say whether BUFFER is alive or not."
3720 (buffer-name (get-buffer buffer))))
3722 (defun gnus-ephemeral-group-p (group)
3723 "Say whether GROUP is ephemeral or not."
3724 (gnus-group-get-parameter group 'quit-config))
3726 (defun gnus-group-quit-config (group)
3727 "Return the quit-config of GROUP."
3728 (gnus-group-get-parameter group 'quit-config))
3730 (defun gnus-simplify-mode-line ()
3731 "Make mode lines a bit simpler."
3732 (setq mode-line-modified "-- ")
3733 (when (listp mode-line-format)
3734 (make-local-variable 'mode-line-format)
3735 (setq mode-line-format (copy-sequence mode-line-format))
3736 (when (equal (nth 3 mode-line-format) " ")
3737 (setcar (nthcdr 3 mode-line-format) " "))))
3739 ;;; List and range functions
3741 (defun gnus-last-element (list)
3742 "Return last element of LIST."
3744 (setq list (cdr list)))
3747 (defun gnus-copy-sequence (list)
3748 "Do a complete, total copy of a list."
3749 (if (and (consp list) (not (consp (cdr list))))
3750 (cons (car list) (cdr list))
3751 (mapcar (lambda (elem) (if (consp elem)
3752 (if (consp (cdr elem))
3753 (gnus-copy-sequence elem)
3754 (cons (car elem) (cdr elem)))
3758 (defun gnus-set-difference (list1 list2)
3759 "Return a list of elements of LIST1 that do not appear in LIST2."
3760 (let ((list1 (copy-sequence list1)))
3762 (setq list1 (delq (car list2) list1))
3763 (setq list2 (cdr list2)))
3766 (defun gnus-sorted-complement (list1 list2)
3767 "Return a list of elements of LIST1 that do not appear in LIST2.
3768 Both lists have to be sorted over <."
3770 (if (or (null list1) (null list2))
3772 (while (and list1 list2)
3773 (cond ((= (car list1) (car list2))
3774 (setq list1 (cdr list1)
3776 ((< (car list1) (car list2))
3777 (setq out (cons (car list1) out))
3778 (setq list1 (cdr list1)))
3780 (setq out (cons (car list2) out))
3781 (setq list2 (cdr list2)))))
3782 (nconc (nreverse out) (or list1 list2)))))
3784 (defun gnus-intersection (list1 list2)
3787 (if (memq (car list2) list1)
3788 (setq result (cons (car list2) result)))
3789 (setq list2 (cdr list2)))
3792 (defun gnus-sorted-intersection (list1 list2)
3793 ;; LIST1 and LIST2 have to be sorted over <.
3795 (while (and list1 list2)
3796 (cond ((= (car list1) (car list2))
3797 (setq out (cons (car list1) out)
3800 ((< (car list1) (car list2))
3801 (setq list1 (cdr list1)))
3803 (setq list2 (cdr list2)))))
3806 (defun gnus-set-sorted-intersection (list1 list2)
3807 ;; LIST1 and LIST2 have to be sorted over <.
3808 ;; This function modifies LIST1.
3809 (let* ((top (cons nil list1))
3811 (while (and list1 list2)
3812 (cond ((= (car list1) (car list2))
3816 ((< (car list1) (car list2))
3817 (setcdr prev (cdr list1))
3818 (setq list1 (cdr list1)))
3820 (setq list2 (cdr list2)))))
3824 (defun gnus-compress-sequence (numbers &optional always-list)
3825 "Convert list of numbers to a list of ranges or a single range.
3826 If ALWAYS-LIST is non-nil, this function will always release a list of
3828 (let* ((first (car numbers))
3829 (last (car numbers))
3833 (if (not (listp (cdr numbers)))
3836 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3837 ((= (1+ last) (car numbers)) ;Still in sequence
3838 (setq last (car numbers)))
3839 (t ;End of one sequence
3841 (cons (if (= first last) first
3842 (cons first last)) result))
3843 (setq first (car numbers))
3844 (setq last (car numbers))))
3845 (setq numbers (cdr numbers)))
3846 (if (and (not always-list) (null result))
3847 (if (= first last) (list first) (cons first last))
3848 (nreverse (cons (if (= first last) first (cons first last))
3851 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3852 (defun gnus-uncompress-range (ranges)
3853 "Expand a list of ranges into a list of numbers.
3854 RANGES is either a single range on the form `(num . num)' or a list of
3856 (let (first last result)
3860 ((not (listp (cdr ranges)))
3861 (setq first (car ranges))
3862 (setq last (cdr ranges))
3863 (while (<= first last)
3864 (setq result (cons first result))
3865 (setq first (1+ first)))
3869 (if (atom (car ranges))
3870 (if (numberp (car ranges))
3871 (setq result (cons (car ranges) result)))
3872 (setq first (caar ranges))
3873 (setq last (cdar ranges))
3874 (while (<= first last)
3875 (setq result (cons first result))
3876 (setq first (1+ first))))
3877 (setq ranges (cdr ranges)))
3878 (nreverse result)))))
3880 (defun gnus-add-to-range (ranges list)
3881 "Return a list of ranges that has all articles from both RANGES and LIST.
3882 Note: LIST has to be sorted over `<'."
3884 (gnus-compress-sequence list t)
3885 (setq list (copy-sequence list))
3886 (or (listp (cdr ranges))
3887 (setq ranges (list ranges)))
3889 ilist lowest highest temp)
3890 (while (and ranges list)
3892 (setq lowest (or (and (atom (car ranges)) (car ranges))
3894 (while (and list (cdr list) (< (cadr list) lowest))
3895 (setq list (cdr list)))
3896 (if (< (car ilist) lowest)
3899 (setq list (cdr list))
3901 (setq out (nconc (gnus-compress-sequence ilist t) out))))
3902 (setq highest (or (and (atom (car ranges)) (car ranges))
3904 (while (and list (<= (car list) highest))
3905 (setq list (cdr list)))
3906 (setq ranges (cdr ranges)))
3908 (setq out (nconc (gnus-compress-sequence list t) out)))
3909 (setq out (sort out (lambda (r1 r2)
3910 (< (or (and (atom r1) r1) (car r1))
3911 (or (and (atom r2) r2) (car r2))))))
3914 (if (atom (car ranges))
3916 (if (atom (cadr ranges))
3917 (if (= (1+ (car ranges)) (cadr ranges))
3919 (setcar ranges (cons (car ranges)
3921 (setcdr ranges (cddr ranges))))
3922 (if (= (1+ (car ranges)) (caadr ranges))
3924 (setcar (cadr ranges) (car ranges))
3925 (setcar ranges (cadr ranges))
3926 (setcdr ranges (cddr ranges))))))
3928 (if (atom (cadr ranges))
3929 (if (= (1+ (cdar ranges)) (cadr ranges))
3931 (setcdr (car ranges) (cadr ranges))
3932 (setcdr ranges (cddr ranges))))
3933 (if (= (1+ (cdar ranges)) (caadr ranges))
3935 (setcdr (car ranges) (cdadr ranges))
3936 (setcdr ranges (cddr ranges)))))))
3937 (setq ranges (cdr ranges)))
3940 (defun gnus-remove-from-range (ranges list)
3941 "Return a list of ranges that has all articles from LIST removed from RANGES.
3942 Note: LIST has to be sorted over `<'."
3943 ;; !!! This function shouldn't look like this, but I've got a headache.
3944 (gnus-compress-sequence
3945 (gnus-sorted-complement
3946 (gnus-uncompress-range ranges) list)))
3948 (defun gnus-member-of-range (number ranges)
3949 (if (not (listp (cdr ranges)))
3950 (and (>= number (car ranges))
3951 (<= number (cdr ranges)))
3954 (if (numberp (car ranges))
3955 (>= number (car ranges))
3956 (>= number (caar ranges)))
3958 (if (if (numberp (car ranges))
3959 (= number (car ranges))
3960 (and (>= number (caar ranges))
3961 (<= number (cdar ranges))))
3962 (setq not-stop nil))
3963 (setq ranges (cdr ranges)))
3966 (defun gnus-range-length (range)
3967 "Return the length RANGE would have if uncompressed."
3968 (length (gnus-uncompress-range range)))
3970 (defun gnus-sublist-p (list sublist)
3971 "Test whether all elements in SUBLIST are members of LIST."
3974 (unless (memq (pop sublist) list)
3984 (defvar gnus-group-mode-map nil)
3985 (put 'gnus-group-mode 'mode-class 'special)
3987 (unless gnus-group-mode-map
3988 (setq gnus-group-mode-map (make-keymap))
3989 (suppress-keymap gnus-group-mode-map)
3991 (gnus-define-keys gnus-group-mode-map
3992 " " gnus-group-read-group
3993 "=" gnus-group-select-group
3994 "\r" gnus-group-select-group
3995 "\M-\r" gnus-group-quick-select-group
3996 "j" gnus-group-jump-to-group
3997 "n" gnus-group-next-unread-group
3998 "p" gnus-group-prev-unread-group
3999 "\177" gnus-group-prev-unread-group
4000 [delete] gnus-group-prev-unread-group
4001 "N" gnus-group-next-group
4002 "P" gnus-group-prev-group
4003 "\M-n" gnus-group-next-unread-group-same-level
4004 "\M-p" gnus-group-prev-unread-group-same-level
4005 "," gnus-group-best-unread-group
4006 "." gnus-group-first-unread-group
4007 "u" gnus-group-unsubscribe-current-group
4008 "U" gnus-group-unsubscribe-group
4009 "c" gnus-group-catchup-current
4010 "C" gnus-group-catchup-current-all
4011 "l" gnus-group-list-groups
4012 "L" gnus-group-list-all-groups
4014 "g" gnus-group-get-new-news
4015 "\M-g" gnus-group-get-new-news-this-group
4016 "R" gnus-group-restart
4017 "r" gnus-group-read-init-file
4018 "B" gnus-group-browse-foreign-server
4019 "b" gnus-group-check-bogus-groups
4020 "F" gnus-find-new-newsgroups
4021 "\C-c\C-d" gnus-group-describe-group
4022 "\M-d" gnus-group-describe-all-groups
4023 "\C-c\C-a" gnus-group-apropos
4024 "\C-c\M-\C-a" gnus-group-description-apropos
4025 "a" gnus-group-post-news
4026 "\ek" gnus-group-edit-local-kill
4027 "\eK" gnus-group-edit-global-kill
4028 "\C-k" gnus-group-kill-group
4029 "\C-y" gnus-group-yank-group
4030 "\C-w" gnus-group-kill-region
4031 "\C-x\C-t" gnus-group-transpose-groups
4032 "\C-c\C-l" gnus-group-list-killed
4033 "\C-c\C-x" gnus-group-expire-articles
4034 "\C-c\M-\C-x" gnus-group-expire-all-groups
4036 "s" gnus-group-save-newsrc
4037 "z" gnus-group-suspend
4038 "Z" gnus-group-clear-dribble
4041 "?" gnus-group-describe-briefly
4042 "\C-c\C-i" gnus-info-find-node
4043 "\M-e" gnus-group-edit-group-method
4044 "^" gnus-group-enter-server-mode
4045 gnus-mouse-2 gnus-mouse-pick-group
4046 "<" beginning-of-buffer
4049 "\C-c\C-s" gnus-group-sort-groups
4051 "\C-c\M-g" gnus-activate-all-groups
4052 "\M-&" gnus-group-universal-argument
4053 "#" gnus-group-mark-group
4054 "\M-#" gnus-group-unmark-group)
4056 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4057 "m" gnus-group-mark-group
4058 "u" gnus-group-unmark-group
4059 "w" gnus-group-mark-region
4060 "m" gnus-group-mark-buffer
4061 "r" gnus-group-mark-regexp
4062 "U" gnus-group-unmark-all-groups)
4064 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4065 "d" gnus-group-make-directory-group
4066 "h" gnus-group-make-help-group
4067 "a" gnus-group-make-archive-group
4068 "k" gnus-group-make-kiboze-group
4069 "m" gnus-group-make-group
4070 "E" gnus-group-edit-group
4071 "e" gnus-group-edit-group-method
4072 "p" gnus-group-edit-group-parameters
4073 "v" gnus-group-add-to-virtual
4074 "V" gnus-group-make-empty-virtual
4075 "D" gnus-group-enter-directory
4076 "f" gnus-group-make-doc-group
4077 "r" gnus-group-rename-group
4078 "\177" gnus-group-delete-group
4079 [delete] gnus-group-delete-group)
4081 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4082 "b" gnus-group-brew-soup
4083 "w" gnus-soup-save-areas
4084 "s" gnus-soup-send-replies
4085 "p" gnus-soup-pack-packet
4086 "r" nnsoup-pack-replies)
4088 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4089 "s" gnus-group-sort-groups
4090 "a" gnus-group-sort-groups-by-alphabet
4091 "u" gnus-group-sort-groups-by-unread
4092 "l" gnus-group-sort-groups-by-level
4093 "v" gnus-group-sort-groups-by-score
4094 "r" gnus-group-sort-groups-by-rank
4095 "m" gnus-group-sort-groups-by-method)
4097 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4098 "k" gnus-group-list-killed
4099 "z" gnus-group-list-zombies
4100 "s" gnus-group-list-groups
4101 "u" gnus-group-list-all-groups
4102 "A" gnus-group-list-active
4103 "a" gnus-group-apropos
4104 "d" gnus-group-description-apropos
4105 "m" gnus-group-list-matching
4106 "M" gnus-group-list-all-matching
4107 "l" gnus-group-list-level)
4109 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4110 "f" gnus-score-flush-cache)
4112 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4113 "f" gnus-group-fetch-faq)
4115 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4116 "l" gnus-group-set-current-level
4117 "t" gnus-group-unsubscribe-current-group
4118 "s" gnus-group-unsubscribe-group
4119 "k" gnus-group-kill-group
4120 "y" gnus-group-yank-group
4121 "w" gnus-group-kill-region
4122 "\C-k" gnus-group-kill-level
4123 "z" gnus-group-kill-all-zombies))
4125 (defun gnus-group-mode ()
4126 "Major mode for reading news.
4128 All normal editing commands are switched off.
4129 \\<gnus-group-mode-map>
4130 The group buffer lists (some of) the groups available. For instance,
4131 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4132 lists all zombie groups.
4134 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4135 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4137 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4139 The following commands are available:
4141 \\{gnus-group-mode-map}"
4143 (when (and menu-bar-mode
4144 (gnus-visual-p 'group-menu 'menu))
4145 (gnus-group-make-menu-bar))
4146 (kill-all-local-variables)
4147 (gnus-simplify-mode-line)
4148 (setq major-mode 'gnus-group-mode)
4149 (setq mode-name "Group")
4150 (gnus-group-set-mode-line)
4151 (setq mode-line-process nil)
4152 (use-local-map gnus-group-mode-map)
4153 (buffer-disable-undo (current-buffer))
4154 (setq truncate-lines t)
4155 (setq buffer-read-only t)
4156 (run-hooks 'gnus-group-mode-hook))
4158 (defun gnus-mouse-pick-group (e)
4159 "Enter the group under the mouse pointer."
4162 (gnus-group-read-group nil))
4164 ;; Look at LEVEL and find out what the level is really supposed to be.
4165 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4166 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4167 (defun gnus-group-default-level (&optional level number-or-nil)
4169 (gnus-group-use-permanent-levels
4170 (setq gnus-group-default-list-level
4171 (or level gnus-group-default-list-level))
4172 (or gnus-group-default-list-level gnus-level-subscribed))
4176 (or level gnus-group-default-list-level gnus-level-subscribed))))
4179 (defun gnus-slave-no-server (&optional arg)
4180 "Read network news as a slave, without connecting to local server"
4182 (gnus-no-server arg t))
4185 (defun gnus-no-server (&optional arg slave)
4187 If ARG is a positive number, Gnus will use that as the
4188 startup level. If ARG is nil, Gnus will be started at level 2.
4189 If ARG is non-nil and not a positive number, Gnus will
4190 prompt the user for the name of an NNTP server to use.
4191 As opposed to `gnus', this command will not connect to the local server."
4193 (let ((gnus-group-use-permanent-levels t))
4194 (gnus (or arg (1- gnus-level-default-subscribed)) t slave))
4195 (make-local-variable 'gnus-group-use-permanent-levels)
4196 (setq gnus-group-use-permanent-levels t))
4199 (defun gnus-slave (&optional arg)
4200 "Read news as a slave."
4202 (gnus arg nil 'slave))
4205 (defun gnus-other-frame (&optional arg)
4206 "Pop up a frame to read news."
4208 (if (get-buffer gnus-group-buffer)
4209 (let ((pop-up-frames t))
4211 (select-frame (make-frame))
4215 (defun gnus (&optional arg dont-connect slave)
4217 If ARG is non-nil and a positive number, Gnus will use that as the
4218 startup level. If ARG is non-nil and not a positive number, Gnus will
4219 prompt the user for the name of an NNTP server to use."
4222 (if (get-buffer gnus-group-buffer)
4224 (switch-to-buffer gnus-group-buffer)
4225 (gnus-group-get-new-news))
4228 (nnheader-init-server-buffer)
4229 (gnus-read-init-file)
4230 (setq gnus-slave slave)
4232 (gnus-group-setup-buffer)
4233 (let ((buffer-read-only nil))
4235 (if (not gnus-inhibit-startup-message)
4237 (gnus-group-startup-message)
4240 (let ((level (and (numberp arg) (> arg 0) arg))
4246 (gnus-start-news-server (and arg (not level))))))
4247 (if (and (not dont-connect)
4250 (run-hooks 'gnus-startup-hook)
4251 ;; NNTP server is successfully open.
4253 ;; Find the current startup file name.
4254 (setq gnus-current-startup-file
4255 (gnus-make-newsrc-file gnus-startup-file))
4257 ;; Read the dribble file.
4258 (and (or gnus-slave gnus-use-dribble-file) (gnus-dribble-read-file))
4260 ;; Allow using GroupLens predictions.
4261 (when gnus-use-grouplens
4263 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4265 (gnus-summary-make-display-table)
4266 ;; Do the actual startup.
4267 (gnus-setup-news nil level dont-connect)
4268 ;; Generate the group buffer.
4269 (gnus-group-list-groups level)
4270 (gnus-group-first-unread-group)
4271 (gnus-configure-windows 'group)
4272 (gnus-group-set-mode-line))))))
4274 (defun gnus-unload ()
4275 "Unload all Gnus features."
4277 (or (boundp 'load-history)
4278 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4279 (let ((history load-history)
4282 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4283 (setq feature (cdr (assq 'provide (car history))))
4284 (unload-feature feature 'force))
4285 (setq history (cdr history)))))
4287 (defun gnus-compile ()
4288 "Byte-compile the user-defined format specs."
4290 (let ((entries gnus-format-specs)
4291 entry gnus-tmp-func)
4293 (gnus-message 7 "Compiling format specs...")
4296 (setq entry (pop entries))
4297 (if (eq (car entry) 'version)
4298 (setq gnus-format-specs (delq entry gnus-format-specs))
4299 (when (and (listp (caddr entry))
4300 (not (eq 'byte-code (caaddr entry))))
4301 (fset 'gnus-tmp-func
4302 `(lambda () ,(caddr entry)))
4303 (byte-compile 'gnus-tmp-func)
4304 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4306 (push (cons 'version emacs-version) gnus-format-specs)
4308 (gnus-message 7 "Compiling user specs...done"))))
4310 (defun gnus-indent-rigidly (start end arg)
4311 "Indent rigidly using only spaces and no tabs."
4314 (narrow-to-region start end)
4315 (indent-rigidly start end arg)
4316 (goto-char (point-min))
4317 (while (search-forward "\t" nil t)
4318 (replace-match " " t t)))))
4320 (defun gnus-group-startup-message (&optional x y)
4321 "Insert startup message in current buffer."
4322 ;; Insert the message.
4327 _ ___ __ ___ __ _ ___
4346 ;; And then hack it.
4347 (gnus-indent-rigidly (point-min) (point-max)
4348 (/ (max (- (window-width) (or x 46)) 0) 2))
4349 (goto-char (point-min))
4351 (let* ((pheight (count-lines (point-min) (point-max)))
4352 (wheight (window-height))
4353 (rest (- wheight pheight)))
4354 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4356 (goto-char (point-min))
4357 (and (search-forward "Praxis" nil t)
4358 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4359 (goto-char (point-min))
4360 (let* ((mode-string (gnus-group-set-mode-line)))
4361 (setq mode-line-buffer-identification
4362 (list (concat gnus-version (substring (car mode-string) 4))))
4363 (set-buffer-modified-p t)))
4365 (defun gnus-group-setup-buffer ()
4366 (or (get-buffer gnus-group-buffer)
4368 (switch-to-buffer gnus-group-buffer)
4369 (gnus-add-current-to-buffer-list)
4371 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4373 (defun gnus-group-list-groups (&optional level unread lowest)
4374 "List newsgroups with level LEVEL or lower that have unread articles.
4375 Default is all subscribed groups.
4376 If argument UNREAD is non-nil, groups with no unread articles are also
4378 (interactive (list (if current-prefix-arg
4379 (prefix-numeric-value current-prefix-arg)
4381 (gnus-group-default-level nil t)
4382 gnus-group-default-list-level
4383 gnus-level-subscribed))))
4385 (setq level (car gnus-group-list-mode)
4386 unread (cdr gnus-group-list-mode)))
4387 (setq level (gnus-group-default-level level))
4388 (gnus-group-setup-buffer) ;May call from out of group buffer
4389 (gnus-update-format-specifications)
4390 (let ((case-fold-search nil)
4391 (props (text-properties-at (gnus-point-at-bol)))
4392 (group (gnus-group-group-name)))
4393 (set-buffer gnus-group-buffer)
4394 (funcall gnus-group-prepare-function level unread lowest)
4395 (if (zerop (buffer-size))
4396 (gnus-message 5 gnus-no-groups-message)
4397 (goto-char (point-max))
4398 (when (or (not gnus-group-goto-next-group-function)
4399 (not (funcall gnus-group-goto-next-group-function
4402 ;; Go to the first group with unread articles.
4403 (gnus-group-search-forward t)
4404 ;; Find the right group to put point on. If the current group
4405 ;; has disappeared in the new listing, try to find the next
4406 ;; one. If no next one can be found, just leave point at the
4407 ;; first newsgroup in the buffer.
4408 (if (not (gnus-goto-char
4410 (point-min) (point-max)
4411 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4412 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4414 (not (gnus-goto-char
4416 (point-min) (point-max) 'gnus-group
4418 (caar newsrc) gnus-active-hashtb)))))
4419 (setq newsrc (cdr newsrc)))
4420 (or newsrc (progn (goto-char (point-max))
4421 (forward-line -1)))))))
4422 ;; Adjust cursor point.
4423 (gnus-group-position-point))))
4425 (defun gnus-group-list-level (level &optional all)
4426 "List groups on LEVEL.
4427 If ALL (the prefix), also list groups that have no unread articles."
4428 (interactive "nList groups on level: \nP")
4429 (gnus-group-list-groups level all level))
4431 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4432 "List all newsgroups with unread articles of level LEVEL or lower.
4433 If ALL is non-nil, list groups that have no unread articles.
4434 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4435 If REGEXP, only list groups matching REGEXP."
4436 (set-buffer gnus-group-buffer)
4437 (let ((buffer-read-only nil)
4438 (newsrc (cdr gnus-newsrc-alist))
4439 (lowest (or lowest 1))
4440 info clevel unread group params)
4442 (if (< lowest gnus-level-zombie)
4443 ;; List living groups.
4445 (setq info (car newsrc)
4446 group (gnus-info-group info)
4447 params (gnus-info-params info)
4449 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4450 (and unread ; This group might be bogus
4452 (string-match regexp group))
4453 (<= (setq clevel (gnus-info-level info)) level)
4455 (or all ; We list all groups?
4456 (if (eq unread t) ; Unactivated?
4457 gnus-group-list-inactive-groups ; We list unactivated
4458 (> unread 0)) ; We list groups with unread articles
4459 (and gnus-list-groups-with-ticked-articles
4460 (cdr (assq 'tick (gnus-info-marks info))))
4461 ; And groups with tickeds
4462 ;; Check for permanent visibility.
4463 (and gnus-permanently-visible-groups
4464 (string-match gnus-permanently-visible-groups
4466 (memq 'visible params)
4467 (cdr (assq 'visible params)))
4468 (gnus-group-insert-group-line
4469 group (gnus-info-level info)
4470 (gnus-info-marks info) unread (gnus-info-method info)))))
4472 ;; List dead groups.
4473 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4474 (gnus-group-prepare-flat-list-dead
4475 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4476 gnus-level-zombie ?Z
4478 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4479 (gnus-group-prepare-flat-list-dead
4480 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4481 gnus-level-killed ?K regexp))
4483 (gnus-group-set-mode-line)
4484 (setq gnus-group-list-mode (cons level all))
4485 (run-hooks 'gnus-group-prepare-hook)))
4487 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4488 ;; List zombies and killed lists somewhat faster, which was
4489 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4490 ;; this by ignoring the group format specification altogether.
4493 ;; This loop is used when listing groups that match some
4496 (setq group (pop groups))
4497 (when (string-match regexp group)
4498 (add-text-properties
4499 (point) (prog1 (1+ (point))
4500 (insert " " mark " *: " group "\n"))
4501 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4503 'gnus-level level))))
4504 ;; This loop is used when listing all groups.
4506 (add-text-properties
4507 (point) (prog1 (1+ (point))
4508 (insert " " mark " *: "
4509 (setq group (pop groups)) "\n"))
4510 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4512 'gnus-level level))))))
4514 (defmacro gnus-group-real-name (group)
4515 "Find the real name of a foreign newsgroup."
4516 `(let ((gname ,group))
4517 (if (string-match ":[^:]+$" gname)
4518 (substring gname (1+ (match-beginning 0)))
4521 (defsubst gnus-server-add-address (method)
4522 (let ((method-name (symbol-name (car method))))
4523 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4524 (not (assq (intern (concat method-name "-address")) method)))
4525 (append method (list (list (intern (concat method-name "-address"))
4529 (defsubst gnus-server-get-method (group method)
4530 ;; Input either a server name, and extended server name, or a
4531 ;; select method, and return a select method.
4532 (cond ((stringp method)
4533 (gnus-server-to-method method))
4534 ((and (stringp (car method)) group)
4535 (gnus-server-extend-method group method))
4537 (gnus-server-add-address method))))
4539 (defun gnus-server-to-method (server)
4540 "Map virtual server names to select methods."
4542 ;; Perhaps this is the native server?
4543 (and (equal server "native") gnus-select-method)
4544 ;; It should be in the server alist.
4545 (cdr (assoc server gnus-server-alist))
4546 ;; If not, we look through all the opened server
4547 ;; to see whether we can find it there.
4548 (let ((opened gnus-opened-servers))
4550 (not (equal server (format "%s:%s" (caaar opened)
4555 (defmacro gnus-method-equal (ss1 ss2)
4556 "Say whether two servers are equal."
4560 (and (= (length s1) (length s2))
4562 (while (and s1 (member (car s1) s2))
4566 (defun gnus-server-equal (m1 m2)
4567 "Say whether two methods are equal."
4568 (let ((m1 (cond ((null m1) gnus-select-method)
4569 ((stringp m1) (gnus-server-to-method m1))
4571 (m2 (cond ((null m2) gnus-select-method)
4572 ((stringp m2) (gnus-server-to-method m2))
4574 (gnus-method-equal m1 m2)))
4576 (defun gnus-group-prefixed-name (group method)
4577 "Return the whole name from GROUP and METHOD."
4578 (and (stringp method) (setq method (gnus-server-to-method method)))
4579 (concat (format "%s" (car method))
4581 (or (assoc (format "%s" (car method))
4582 (gnus-methods-using 'address))
4583 (gnus-server-equal method gnus-message-archive-method))
4585 (not (string= (nth 1 method) "")))
4586 (concat "+" (nth 1 method)))
4589 (defun gnus-group-real-prefix (group)
4590 "Return the prefix of the current group name."
4591 (if (string-match "^[^:]+:" group)
4592 (substring group 0 (match-end 0))
4595 (defun gnus-group-method (group)
4596 "Return the server or method used for selecting GROUP."
4597 (let ((prefix (gnus-group-real-prefix group)))
4598 (if (equal prefix "")
4600 (let ((servers gnus-opened-servers)
4602 backend possible found)
4603 (if (string-match "^[^\\+]+\\+" prefix)
4604 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4605 server (substring prefix (match-end 0) (1- (length prefix))))
4606 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4608 (when (eq (caaar servers) backend)
4609 (setq possible (caar servers))
4610 (when (equal (cadaar servers) server)
4611 (setq found (caar servers))))
4613 (or (car (rassoc found gnus-server-alist))
4615 (car (rassoc possible gnus-server-alist))
4617 (list backend server))))))
4619 (defsubst gnus-secondary-method-p (method)
4620 "Return whether METHOD is a secondary select method."
4621 (let ((methods gnus-secondary-select-methods)
4622 (gmethod (gnus-server-get-method nil method)))
4624 (not (equal (gnus-server-get-method nil (car methods))
4626 (setq methods (cdr methods)))
4629 (defun gnus-group-foreign-p (group)
4630 "Say whether a group is foreign or not."
4631 (and (not (gnus-group-native-p group))
4632 (not (gnus-group-secondary-p group))))
4634 (defun gnus-group-native-p (group)
4635 "Say whether the group is native or not."
4636 (not (string-match ":" group)))
4638 (defun gnus-group-secondary-p (group)
4639 "Say whether the group is secondary or not."
4640 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4642 (defun gnus-group-get-parameter (group &optional symbol)
4643 "Returns the group parameters for GROUP.
4644 If SYMBOL, return the value of that symbol in the group parameters."
4645 (let ((params (gnus-info-params (gnus-get-info group))))
4647 (gnus-group-parameter-value params symbol)
4650 (defun gnus-group-parameter-value (params symbol)
4651 "Return the value of SYMBOL in group PARAMS."
4652 (or (car (memq symbol params)) ; It's either a simple symbol
4653 (cdr (assq symbol params)))) ; or a cons.
4655 (defun gnus-group-add-parameter (group param)
4656 "Add parameter PARAM to GROUP."
4657 (let ((info (gnus-get-info group)))
4659 () ; This is a dead group. We just ignore it.
4660 ;; Cons the new param to the old one and update.
4661 (gnus-group-set-info (cons param (gnus-info-params info))
4664 (defun gnus-group-set-parameter (group name value)
4665 "Set parameter NAME to VALUE in GROUP."
4666 (let ((info (gnus-get-info group)))
4668 () ; This is a dead group. We just ignore it.
4669 (let ((old-params (gnus-info-params info))
4670 (new-params (list (cons name value))))
4672 (if (or (not (listp (car old-params)))
4673 (not (eq (caar old-params) name)))
4674 (setq new-params (append new-params (list (car old-params)))))
4675 (setq old-params (cdr old-params)))
4676 (gnus-group-set-info new-params group 'params)))))
4678 (defun gnus-group-add-score (group &optional score)
4679 "Add SCORE to the GROUP score.
4680 If SCORE is nil, add 1 to the score of GROUP."
4681 (let ((info (gnus-get-info group)))
4683 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4685 (defun gnus-summary-bubble-group ()
4686 "Increase the score of the current group.
4687 This is a handy function to add to `gnus-summary-exit-hook' to
4688 increase the score of each group you read."
4689 (gnus-group-add-score gnus-newsgroup-name))
4691 (defun gnus-group-set-info (info &optional method-only-group part)
4692 (let* ((entry (gnus-gethash
4693 (or method-only-group (gnus-info-group info))
4694 gnus-newsrc-hashtb))
4696 (info (if method-only-group (nth 2 entry) info))
4698 (when method-only-group
4700 (error "Trying to change non-existent group %s" method-only-group))
4701 ;; We have received parts of the actual group info - either the
4702 ;; select method or the group parameters. We first check
4703 ;; whether we have to extend the info, and if so, do that.
4704 (let ((len (length info))
4705 (total (if (eq part 'method) 5 6)))
4707 (setcdr (nthcdr (1- len) info)
4708 (make-list (- total len) nil)))
4709 ;; Then we enter the new info.
4710 (setcar (nthcdr (1- total) info) part-info)))
4712 ;; This is a new group, so we just create it.
4714 (set-buffer gnus-group-buffer)
4715 (setq method (gnus-info-method info))
4716 (when (gnus-server-equal method "native")
4719 ;; It's a foreign group...
4720 (gnus-group-make-group
4721 (gnus-group-real-name (gnus-info-group info))
4722 (if (stringp method) method
4723 (prin1-to-string (car method)))
4725 (nth 1 (gnus-info-method info))))
4726 ;; It's a native group.
4727 (gnus-group-make-group (gnus-info-group info)))
4728 (gnus-message 6 "Note: New group created")
4730 (gnus-gethash (gnus-group-prefixed-name
4731 (gnus-group-real-name (gnus-info-group info))
4732 (or (gnus-info-method info) gnus-select-method))
4733 gnus-newsrc-hashtb))))
4734 ;; Whether it was a new group or not, we now have the entry, so we
4735 ;; can do the update.
4738 (setcar (nthcdr 2 entry) info)
4739 (when (and (not (eq (car entry) t))
4740 (gnus-active (gnus-info-group info)))
4741 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4742 (error "No such group: %s" (gnus-info-group info)))))
4744 (defun gnus-group-set-method-info (group select-method)
4745 (gnus-group-set-info select-method group 'method))
4747 (defun gnus-group-set-params-info (group params)
4748 (gnus-group-set-info params group 'params))
4750 (defun gnus-group-update-group-line ()
4751 "Update the current line in the group buffer."
4752 (let* ((buffer-read-only nil)
4753 (group (gnus-group-group-name))
4754 (gnus-group-indentation (gnus-group-group-indentation))
4755 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
4757 (not (gnus-ephemeral-group-p group))
4759 (concat "(gnus-group-set-info '"
4760 (prin1-to-string (nth 2 entry)) ")")))
4762 (gnus-group-insert-group-line-info group)
4764 (gnus-group-position-point)))
4766 (defun gnus-group-insert-group-line-info (group)
4767 "Insert GROUP on the current line."
4768 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4772 ;; (Un)subscribed group.
4773 (setq info (nth 2 entry))
4774 (gnus-group-insert-group-line
4775 group (gnus-info-level info) (gnus-info-marks info)
4776 (or (car entry) t) (gnus-info-method info)))
4777 ;; This group is dead.
4778 (gnus-group-insert-group-line
4780 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4782 (if (setq active (gnus-active group))
4783 (- (1+ (cdr active)) (car active)) 0)
4786 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
4787 gnus-tmp-marked number
4789 "Insert a group line in the group buffer."
4790 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4791 (gnus-tmp-number-total
4793 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4795 (gnus-tmp-number-of-unread
4796 (if (numberp number) (int-to-string (max 0 number))
4798 (gnus-tmp-number-of-read
4799 (if (numberp number)
4800 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4802 (gnus-tmp-subscribed
4803 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4804 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4805 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4807 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4808 (gnus-tmp-newsgroup-description
4809 (if gnus-description-hashtb
4810 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4813 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4814 (gnus-tmp-moderated-string
4815 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4817 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4818 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4819 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4820 (gnus-tmp-news-method-string
4822 (format "(%s:%s)" (car gnus-tmp-method)
4823 (cadr gnus-tmp-method)) ""))
4824 (gnus-tmp-marked-mark
4825 (if (and (numberp number)
4827 (cdr (assq 'tick gnus-tmp-marked)))
4829 (gnus-tmp-process-marked
4830 (if (member gnus-tmp-group gnus-group-marked)
4831 gnus-process-mark ? ))
4833 (or (and gnus-use-grouplens
4834 (bbb-grouplens-group-p gnus-tmp-group))
4836 (buffer-read-only nil)
4837 header gnus-tmp-header) ; passed as parameter to user-funcs.
4839 (add-text-properties
4843 (eval gnus-group-line-format-spec))
4844 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
4845 gnus-unread ,(if (numberp number)
4846 (string-to-int gnus-tmp-number-of-unread)
4848 gnus-marked ,gnus-tmp-marked-mark
4849 gnus-indentation ,gnus-group-indentation
4850 gnus-level ,gnus-tmp-level))
4851 (when (inline (gnus-visual-p 'group-highlight 'highlight))
4853 (run-hooks 'gnus-group-update-hook)
4855 ;; Allow XEmacs to remove front-sticky text properties.
4856 (gnus-group-remove-excess-properties)))
4858 (defun gnus-group-update-group (group &optional visible-only)
4859 "Update all lines where GROUP appear.
4860 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
4863 (set-buffer gnus-group-buffer)
4864 ;; The buffer may be narrowed.
4867 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
4869 found buffer-read-only)
4870 ;; Enter the current status into the dribble buffer.
4871 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
4872 (if (and entry (not (gnus-ephemeral-group-p group)))
4874 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
4876 ;; Find all group instances. If topics are in use, each group
4877 ;; may be listed in more than once.
4878 (while (setq loc (text-property-any
4879 loc (point-max) 'gnus-group ident))
4882 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4884 (gnus-group-insert-group-line-info group))
4885 (setq loc (1+ loc)))
4886 (unless (or found visible-only)
4887 ;; No such line in the buffer, find out where it's supposed to
4888 ;; go, and insert it there (or at the end of the buffer).
4889 (if gnus-goto-missing-group-function
4890 (funcall gnus-goto-missing-group-function group)
4891 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
4892 (while (and entry (car entry)
4896 (point-min) (point-max)
4897 'gnus-group (gnus-intern-safe
4898 (caar entry) gnus-active-hashtb)))))
4899 (setq entry (cdr entry)))
4900 (or entry (goto-char (point-max)))))
4901 ;; Finally insert the line.
4902 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4903 (gnus-group-insert-group-line-info group)))
4904 (gnus-group-set-mode-line)))))
4906 (defun gnus-group-set-mode-line ()
4907 (when (memq 'group gnus-updated-mode-lines)
4908 (let* ((gformat (or gnus-group-mode-line-format-spec
4909 (setq gnus-group-mode-line-format-spec
4911 gnus-group-mode-line-format
4912 gnus-group-mode-line-format-alist))))
4913 (gnus-tmp-news-server (cadr gnus-select-method))
4914 (gnus-tmp-news-method (car gnus-select-method))
4916 gnus-tmp-header ;Dummy binding for user-defined formats
4917 ;; Get the resulting string.
4918 (mode-string (eval gformat)))
4919 ;; If the line is too long, we chop it off.
4920 (when (> (length mode-string) max-len)
4921 (setq mode-string (substring mode-string 0 (- max-len 4))))
4923 (setq mode-line-buffer-identification (list mode-string))
4924 (set-buffer-modified-p t)))))
4926 (defun gnus-group-group-name ()
4927 "Get the name of the newsgroup on the current line."
4928 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
4929 (and group (symbol-name group))))
4931 (defun gnus-group-group-level ()
4932 "Get the level of the newsgroup on the current line."
4933 (get-text-property (gnus-point-at-bol) 'gnus-level))
4935 (defun gnus-group-group-indentation ()
4936 "Get the indentation of the newsgroup on the current line."
4937 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
4938 (and gnus-group-indentation-function
4939 (funcall gnus-group-indentation-function))
4942 (defun gnus-group-group-unread ()
4943 "Get the number of unread articles of the newsgroup on the current line."
4944 (get-text-property (gnus-point-at-bol) 'gnus-unread))
4946 (defun gnus-group-search-forward (&optional backward all level first-too)
4947 "Find the next newsgroup with unread articles.
4948 If BACKWARD is non-nil, find the previous newsgroup instead.
4949 If ALL is non-nil, just find any newsgroup.
4950 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
4952 If FIRST-TOO, the current line is also eligible as a target."
4953 (let ((way (if backward -1 1))
4954 (low gnus-level-killed)
4957 (if (and backward (progn (beginning-of-line)) (bobp))
4959 (or first-too (forward-line way))
4967 (get-text-property (point) 'gnus-unread)))
4968 (and (numberp unread) (> unread 0)))
4969 (setq lev (get-text-property (point)
4971 (<= lev gnus-level-subscribed)))
4973 (and (setq lev (get-text-property (point)
4982 (zerop (forward-line way)))))
4984 (progn (gnus-group-position-point) t)
4985 (goto-char (or pos beg))
4988 ;;; Gnus group mode commands
4992 (defun gnus-group-mark-group (n &optional unmark no-advance)
4993 "Mark the current group."
4995 (let ((buffer-read-only nil)
4999 (setq group (gnus-group-group-name))
5003 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5008 (setq gnus-group-marked (delete group gnus-group-marked)))
5010 (setq gnus-group-marked
5011 (cons group (delete group gnus-group-marked))))
5013 (or no-advance (zerop (gnus-group-next-group 1))))
5015 (gnus-summary-position-point)
5018 (defun gnus-group-unmark-group (n)
5019 "Remove the mark from the current group."
5021 (gnus-group-mark-group n 'unmark)
5022 (gnus-group-position-point))
5024 (defun gnus-group-unmark-all-groups ()
5025 "Unmark all groups."
5027 (let ((groups gnus-group-marked))
5030 (gnus-group-remove-mark (pop groups)))))
5031 (gnus-group-position-point))
5033 (defun gnus-group-mark-region (unmark beg end)
5034 "Mark all groups between point and mark.
5035 If UNMARK, remove the mark instead."
5036 (interactive "P\nr")
5037 (let ((num (count-lines beg end)))
5040 (- num (gnus-group-mark-group num unmark)))))
5042 (defun gnus-group-mark-buffer (&optional unmark)
5043 "Mark all groups in the buffer.
5044 If UNMARK, remove the mark instead."
5046 (gnus-group-mark-region unmark (point-min) (point-max)))
5048 (defun gnus-group-mark-regexp (regexp)
5049 "Mark all groups that match some regexp."
5050 (interactive "sMark (regexp): ")
5051 (let ((alist (cdr gnus-newsrc-alist))
5054 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5055 (gnus-group-set-mark group))))
5056 (gnus-group-position-point))
5058 (defun gnus-group-remove-mark (group)
5059 "Remove the process mark from GROUP and move point there.
5060 Return nil if the group isn't displayed."
5061 (if (gnus-group-goto-group group)
5063 (gnus-group-mark-group 1 'unmark t)
5065 (setq gnus-group-marked
5066 (delete group gnus-group-marked))
5069 (defun gnus-group-set-mark (group)
5070 "Set the process mark on GROUP."
5071 (if (gnus-group-goto-group group)
5073 (gnus-group-mark-group 1 nil t))
5074 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5076 (defun gnus-group-universal-argument (arg &optional groups func)
5077 "Perform any command on all groups accoring to the process/prefix convention."
5079 (let ((groups (or groups (gnus-group-process-prefix arg)))
5081 (if (eq (setq func (or func
5084 (substitute-command-keys
5085 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5088 (message "Undefined key")
5091 (gnus-group-remove-mark (setq group (pop groups)))
5092 (command-execute func))))
5093 (gnus-group-position-point))
5095 (defun gnus-group-process-prefix (n)
5096 "Return a list of groups to work on.
5097 Take into consideration N (the prefix) and the list of marked groups."
5100 (setq n (prefix-numeric-value n))
5101 ;; There is a prefix, so we return a list of the N next
5103 (let ((way (if (< n 0) -1 1))
5108 (setq group (gnus-group-group-name)))
5109 (setq groups (cons group groups))
5111 (gnus-group-next-group way)))
5113 ((and (boundp 'transient-mark-mode)
5116 ;; Work on the region between point and mark.
5117 (let ((max (max (point) (mark)))
5120 (goto-char (min (point) (mark)))
5123 (push (gnus-group-group-name) groups)
5124 (zerop (gnus-group-next-group 1))
5126 (nreverse groups))))
5128 ;; No prefix, but a list of marked articles.
5129 (reverse gnus-group-marked))
5131 ;; Neither marked articles or a prefix, so we return the
5133 (let ((group (gnus-group-group-name)))
5134 (and group (list group))))))
5136 ;; Selecting groups.
5138 (defun gnus-group-read-group (&optional all no-article group)
5139 "Read news in this newsgroup.
5140 If the prefix argument ALL is non-nil, already read articles become
5141 readable. IF ALL is a number, fetch this number of articles. If the
5142 optional argument NO-ARTICLE is non-nil, no article will be
5143 auto-selected upon group entry. If GROUP is non-nil, fetch that
5146 (let ((group (or group (gnus-group-group-name)))
5147 number active marked entry)
5148 (or group (error "No group on current line"))
5149 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5150 group gnus-newsrc-hashtb)))))
5151 ;; This group might be a dead group. In that case we have to get
5152 ;; the number of unread articles from `gnus-active-hashtb'.
5154 (cond ((numberp all) all)
5156 ((setq active (gnus-active group))
5157 (- (1+ (cdr active)) (car active)))))
5158 (gnus-summary-read-group
5159 group (or all (and (numberp number)
5160 (zerop (+ number (length (cdr (assq 'tick marked)))
5161 (length (cdr (assq 'dormant marked)))))))
5164 (defun gnus-group-select-group (&optional all)
5165 "Select this newsgroup.
5166 No article is selected automatically.
5167 If ALL is non-nil, already read articles become readable.
5168 If ALL is a number, fetch this number of articles."
5170 (gnus-group-read-group all t))
5172 (defun gnus-group-quick-select-group (&optional all)
5173 "Select the current group \"quickly\".
5174 This means that no highlighting or scoring will be performed."
5177 gnus-score-find-score-files-function
5178 gnus-apply-kill-hook
5179 gnus-summary-expunge-below)
5180 (gnus-group-read-group all t)))
5182 (defun gnus-group-visible-select-group (&optional all)
5183 "Select the current group without hiding any articles."
5185 (let ((gnus-inhibit-limiting t))
5186 (gnus-group-read-group all t)))
5189 (defun gnus-fetch-group (group)
5190 "Start Gnus if necessary and enter GROUP.
5191 Returns whether the fetching was successful or not."
5192 (interactive "sGroup name: ")
5193 (or (get-buffer gnus-group-buffer)
5195 (gnus-group-read-group nil nil group))
5197 ;; Enter a group that is not in the group buffer. Non-nil is returned
5198 ;; if selection was successful.
5199 (defun gnus-group-read-ephemeral-group
5200 (group method &optional activate quit-config)
5201 (let ((group (if (gnus-group-foreign-p group) group
5202 (gnus-group-prefixed-name group method))))
5205 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5206 ((quit-config . ,(if quit-config quit-config
5207 (cons (current-buffer) 'summary))))))
5209 (set-buffer gnus-group-buffer)
5210 (or (gnus-check-server method)
5211 (error "Unable to contact server: %s" (gnus-status-message method)))
5212 (if activate (or (gnus-request-group group)
5213 (error "Couldn't request group")))
5215 (gnus-group-read-group t t group)
5219 (defun gnus-group-jump-to-group (group)
5220 "Jump to newsgroup GROUP."
5222 (list (completing-read
5223 "Group: " gnus-active-hashtb nil
5224 (memq gnus-select-method gnus-have-read-active-file))))
5226 (if (equal group "")
5227 (error "Empty group name"))
5229 (let ((b (text-property-any
5230 (point-min) (point-max)
5231 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5232 (unless (gnus-ephemeral-group-p group)
5234 ;; Either go to the line in the group buffer...
5236 ;; ... or insert the line.
5239 (gnus-activate-group group)
5240 (error "%s error: %s" group (gnus-status-message group)))
5242 (gnus-group-update-group group)
5243 (goto-char (text-property-any
5244 (point-min) (point-max)
5245 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5246 ;; Adjust cursor point.
5247 (gnus-group-position-point)))
5249 (defun gnus-group-goto-group (group)
5250 "Goto to newsgroup GROUP."
5252 (let ((b (text-property-any (point-min) (point-max)
5253 'gnus-group (gnus-intern-safe
5254 group gnus-active-hashtb))))
5255 (and b (goto-char b)))))
5257 (defun gnus-group-next-group (n)
5258 "Go to next N'th newsgroup.
5259 If N is negative, search backward instead.
5260 Returns the difference between N and the number of skips actually
5263 (gnus-group-next-unread-group n t))
5265 (defun gnus-group-next-unread-group (n &optional all level)
5266 "Go to next N'th unread newsgroup.
5267 If N is negative, search backward instead.
5268 If ALL is non-nil, choose any newsgroup, unread or not.
5269 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5270 such group can be found, the next group with a level higher than
5272 Returns the difference between N and the number of skips actually
5275 (let ((backward (< n 0))
5278 (gnus-group-search-forward
5279 backward (or (not gnus-group-goto-unread) all) level))
5281 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5282 (if level " on this level or higher" "")))
5285 (defun gnus-group-prev-group (n)
5286 "Go to previous N'th newsgroup.
5287 Returns the difference between N and the number of skips actually
5290 (gnus-group-next-unread-group (- n) t))
5292 (defun gnus-group-prev-unread-group (n)
5293 "Go to previous N'th unread newsgroup.
5294 Returns the difference between N and the number of skips actually
5297 (gnus-group-next-unread-group (- n)))
5299 (defun gnus-group-next-unread-group-same-level (n)
5300 "Go to next N'th unread newsgroup on the same level.
5301 If N is negative, search backward instead.
5302 Returns the difference between N and the number of skips actually
5305 (gnus-group-next-unread-group n t (gnus-group-group-level))
5306 (gnus-group-position-point))
5308 (defun gnus-group-prev-unread-group-same-level (n)
5309 "Go to next N'th unread newsgroup on the same level.
5310 Returns the difference between N and the number of skips actually
5313 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5314 (gnus-group-position-point))
5316 (defun gnus-group-best-unread-group (&optional exclude-group)
5317 "Go to the group with the highest level.
5318 If EXCLUDE-GROUP, do not go to that group."
5320 (goto-char (point-min))
5323 (while (setq unread (get-text-property (point) 'gnus-unread))
5324 (if (and (numberp unread) (> unread 0))
5326 (if (and (get-text-property (point) 'gnus-level)
5327 (< (get-text-property (point) 'gnus-level) best)
5328 (or (not exclude-group)
5329 (not (equal exclude-group (gnus-group-group-name)))))
5331 (setq best (get-text-property (point) 'gnus-level))
5332 (setq best-point (point))))))
5334 (if best-point (goto-char best-point))
5335 (gnus-summary-position-point)
5336 (and best-point (gnus-group-group-name))))
5338 (defun gnus-group-first-unread-group ()
5339 "Go to the first group with unread articles."
5342 (let ((opoint (point))
5344 (goto-char (point-min))
5345 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5346 (and (numberp unread) ; Not a topic.
5347 (not (zerop unread))) ; Has unread articles.
5348 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5351 nil)) ; Not success.
5352 (gnus-group-position-point)))
5354 (defun gnus-group-enter-server-mode ()
5355 "Jump to the server buffer."
5357 (gnus-enter-server-buffer))
5359 (defun gnus-group-make-group (name &optional method address)
5360 "Add a new newsgroup.
5361 The user will be prompted for a NAME, for a select METHOD, and an
5365 (read-string "Group name: ")
5368 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5370 (cond ((assoc method gnus-valid-select-methods)
5372 (if (memq 'prompt-address
5373 (assoc method gnus-valid-select-methods))
5374 (read-string "Address: ")
5376 ((assoc method gnus-server-alist)
5379 (list method ""))))))
5382 (set-buffer gnus-group-buffer)
5383 (let* ((meth (and method (if address (list (intern method) address)
5385 (nname (if method (gnus-group-prefixed-name name meth) name))
5387 (and (gnus-gethash nname gnus-newsrc-hashtb)
5388 (error "Group %s already exists" nname))
5389 (gnus-group-change-level
5390 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5391 gnus-level-default-subscribed gnus-level-killed
5392 (and (gnus-group-group-name)
5393 (gnus-gethash (gnus-group-group-name)
5394 gnus-newsrc-hashtb))
5396 (gnus-set-active nname (cons 1 0))
5397 (or (gnus-ephemeral-group-p name)
5399 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5400 (gnus-group-insert-group-line-info nname)
5402 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5404 gnus-valid-select-methods)
5406 (gnus-check-server meth)
5407 (and (gnus-check-backend-function 'request-create-group nname)
5408 (gnus-request-create-group nname))
5411 (defun gnus-group-delete-group (group &optional force)
5412 "Delete the current group.
5413 If FORCE (the prefix) is non-nil, all the articles in the group will
5414 be deleted. This is \"deleted\" as in \"removed forever from the face
5415 of the Earth\". There is no undo."
5417 (list (gnus-group-group-name)
5418 current-prefix-arg))
5419 (or group (error "No group to rename"))
5420 (or (gnus-check-backend-function 'request-delete-group group)
5421 (error "This backend does not support group deletion"))
5423 (if (not (gnus-yes-or-no-p
5425 "Do you really want to delete %s%s? "
5426 group (if force " and all its contents" ""))))
5428 (gnus-message 6 "Deleting group %s..." group)
5429 (if (not (gnus-request-delete-group group force))
5431 (gnus-message 3 "Couldn't delete group %s" group)
5433 (gnus-message 6 "Deleting group %s...done" group)
5434 (gnus-group-goto-group group)
5435 (gnus-group-kill-group 1 t)
5436 (gnus-sethash group nil gnus-active-hashtb)
5438 (gnus-group-position-point)))
5440 (defun gnus-group-rename-group (group new-name)
5443 (gnus-group-group-name)
5445 (or (gnus-check-backend-function
5446 'request-rename-group (gnus-group-group-name))
5447 (error "This backend does not support renaming groups"))
5448 (read-string "New group name: "))))
5450 (or (gnus-check-backend-function 'request-rename-group group)
5451 (error "This backend does not support renaming groups"))
5453 (or group (error "No group to rename"))
5454 (and (string-match "^[ \t]*$" new-name)
5455 (error "Not a valid group name"))
5457 ;; We find the proper prefixed name.
5459 (gnus-group-prefixed-name
5460 (gnus-group-real-name new-name)
5461 (gnus-info-method (gnus-get-info group))))
5463 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5465 (if (not (gnus-request-rename-group group new-name))
5467 (gnus-message 3 "Couldn't rename group %s to %s" group new-name)
5469 ;; We rename the group internally by killing it...
5470 (gnus-group-goto-group group)
5471 (gnus-group-kill-group)
5472 ;; ... changing its name ...
5473 (setcar (cdar gnus-list-of-killed-groups) new-name)
5474 ;; ... and then yanking it. Magic!
5475 (gnus-group-yank-group)
5476 (gnus-set-active new-name (gnus-active group))
5477 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5479 (gnus-group-position-point)))
5481 (defun gnus-group-edit-group (group &optional part)
5482 "Edit the group on the current line."
5483 (interactive (list (gnus-group-group-name)))
5484 (let* ((part (or part 'info))
5485 (done-func `(lambda ()
5486 "Exit editing mode and update the information."
5488 (gnus-group-edit-group-done ',part ,group)))
5489 (winconf (current-window-configuration))
5491 (or group (error "No group on current line"))
5492 (or (setq info (gnus-get-info group))
5493 (error "Killed group; can't be edited"))
5494 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5495 (gnus-configure-windows 'edit-group)
5496 (gnus-add-current-to-buffer-list)
5498 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5499 (use-local-map (copy-keymap emacs-lisp-mode-map))
5500 (local-set-key "\C-c\C-c" done-func)
5501 (make-local-variable 'gnus-prev-winconf)
5502 (setq gnus-prev-winconf winconf)
5507 ";; Type `C-c C-c' after editing the select method.\n\n")
5509 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5511 ";; Type `C-c C-c' after editing the group info.\n\n")))
5514 (cond ((eq part 'method)
5515 (or (gnus-info-method info) "native"))
5517 (gnus-info-params info))
5521 (defun gnus-group-edit-group-method (group)
5522 "Edit the select method of GROUP."
5523 (interactive (list (gnus-group-group-name)))
5524 (gnus-group-edit-group group 'method))
5526 (defun gnus-group-edit-group-parameters (group)
5527 "Edit the group parameters of GROUP."
5528 (interactive (list (gnus-group-group-name)))
5529 (gnus-group-edit-group group 'params))
5531 (defun gnus-group-edit-group-done (part group)
5532 "Get info from buffer, update variables and jump to the group buffer."
5533 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5534 (goto-char (point-min))
5535 (let* ((form (read (current-buffer)))
5536 (winconf gnus-prev-winconf)
5537 (method (cond ((eq part 'info) (nth 4 form))
5538 ((eq part 'method) form)
5540 (info (cond ((eq part 'info) form)
5541 ((eq part 'method) (gnus-get-info group))
5544 (if (or (not method)
5546 gnus-select-method method))
5547 (gnus-group-real-name (car info))
5548 (gnus-group-prefixed-name
5549 (gnus-group-real-name (car info)) method))
5551 (when (and new-group
5552 (not (equal new-group group)))
5553 (when (gnus-group-goto-group group)
5554 (gnus-group-kill-group 1))
5555 (gnus-activate-group new-group))
5557 (if (and info new-group)
5559 (setq info (gnus-copy-sequence info))
5560 (setcar info new-group)
5561 (unless (gnus-server-equal method "native")
5562 (unless (nthcdr 3 info)
5563 (nconc info (list nil nil)))
5564 (unless (nthcdr 4 info)
5565 (nconc info (list nil)))
5566 (gnus-info-set-method info method))
5567 (gnus-group-set-info info))
5568 (gnus-group-set-info form (or new-group group) part))
5569 (kill-buffer (current-buffer))
5570 (and winconf (set-window-configuration winconf))
5571 (set-buffer gnus-group-buffer)
5572 (gnus-group-update-group (or new-group group))
5573 (gnus-group-position-point)))
5575 (defun gnus-group-make-help-group ()
5576 "Create the Gnus documentation group."
5578 (let ((path load-path)
5579 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5581 (and (gnus-gethash name gnus-newsrc-hashtb)
5582 (error "Documentation group already exists"))
5584 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5586 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5588 (setq file (concat (file-name-directory
5589 (directory-file-name dir))
5590 "etc/gnus-tut.txt"))))
5593 (message "Couldn't find doc group")
5594 (gnus-group-make-group
5595 (gnus-group-real-name name)
5596 (list 'nndoc "gnus-help"
5597 (list 'nndoc-address file)
5598 (list 'nndoc-article-type 'mbox)))))
5599 (gnus-group-position-point))
5601 (defun gnus-group-make-doc-group (file type)
5602 "Create a group that uses a single file as the source."
5604 (list (read-file-name "File name: ")
5605 (and current-prefix-arg 'ask)))
5606 (when (eq type 'ask)
5611 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5613 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5614 ((= char ?b) 'babyl)
5615 ((= char ?d) 'digest)
5616 ((= char ?f) 'forward)
5618 (t (setq err (format "%c unknown. " char))
5621 (let* ((file (expand-file-name file))
5622 (name (gnus-generate-new-group-name
5623 (gnus-group-prefixed-name
5624 (file-name-nondirectory file) '(nndoc "")))))
5625 (gnus-group-make-group
5626 (gnus-group-real-name name)
5627 (list 'nndoc (file-name-nondirectory file)
5628 (list 'nndoc-address file)
5629 (list 'nndoc-article-type (or type 'guess))))
5631 (gnus-group-position-point)))
5633 (defun gnus-group-make-archive-group (&optional all)
5634 "Create the (ding) Gnus archive group of the most recent articles.
5635 Given a prefix, create a full group."
5637 (let ((group (gnus-group-prefixed-name
5638 (if all "ding.archives" "ding.recent") '(nndir ""))))
5639 (and (gnus-gethash group gnus-newsrc-hashtb)
5640 (error "Archive group already exists"))
5641 (gnus-group-make-group
5642 (gnus-group-real-name group)
5643 (list 'nndir (if all "hpc" "edu")
5644 (list 'nndir-directory
5645 (if all gnus-group-archive-directory
5646 gnus-group-recent-archive-directory)))))
5648 (gnus-group-position-point))
5650 (defun gnus-group-make-directory-group (dir)
5651 "Create an nndir group.
5652 The user will be prompted for a directory. The contents of this
5653 directory will be used as a newsgroup. The directory should contain
5654 mail messages or news articles in files that have numeric names."
5656 (list (read-file-name "Create group from directory: ")))
5657 (or (file-exists-p dir) (error "No such directory"))
5658 (or (file-directory-p dir) (error "Not a directory"))
5662 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5664 (gnus-group-prefixed-name
5665 (concat (file-name-as-directory (directory-file-name dir))
5668 (setq ext (format "<%d>" (setq i (1+ i)))))
5669 (gnus-group-make-group
5670 (gnus-group-real-name group)
5671 (list 'nndir group (list 'nndir-directory dir))))
5673 (gnus-group-position-point))
5675 (defun gnus-group-make-kiboze-group (group address scores)
5676 "Create an nnkiboze group.
5677 The user will be prompted for a name, a regexp to match groups, and
5678 score file entries for articles to include in the group."
5681 (read-string "nnkiboze group name: ")
5682 (read-string "Source groups (regexp): ")
5683 (let ((headers (mapcar (lambda (group) (list group))
5684 '("subject" "from" "number" "date" "message-id"
5685 "references" "chars" "lines" "xref"
5686 "followup" "all" "body" "head")))
5687 scores header regexp regexps)
5688 (while (not (equal "" (setq header (completing-read
5689 "Match on header: " headers nil t))))
5691 (while (not (equal "" (setq regexp (read-string
5692 (format "Match on %s (string): "
5694 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5695 (setq scores (cons (cons header regexps) scores)))
5697 (gnus-group-make-group group "nnkiboze" address)
5699 (gnus-set-work-buffer)
5700 (let (emacs-lisp-mode-hook)
5701 (pp scores (current-buffer)))
5702 (write-region (point-min) (point-max)
5703 (gnus-score-file-name (concat "nnkiboze:" group))))
5705 (gnus-group-position-point))
5707 (defun gnus-group-add-to-virtual (n vgroup)
5708 "Add the current group to a virtual group."
5710 (list current-prefix-arg
5711 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5713 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5714 (error "%s is not an nnvirtual group" vgroup))
5715 (let* ((groups (gnus-group-process-prefix n))
5716 (method (gnus-info-method (gnus-get-info vgroup))))
5717 (setcar (cdr method)
5719 (nth 1 method) "\\|"
5722 (gnus-group-remove-mark s)
5723 (concat "\\(^" (regexp-quote s) "$\\)"))
5725 (gnus-group-position-point))
5727 (defun gnus-group-make-empty-virtual (group)
5728 "Create a new, fresh, empty virtual group."
5729 (interactive "sCreate new, empty virtual group: ")
5730 (let* ((method (list 'nnvirtual "^$"))
5731 (pgroup (gnus-group-prefixed-name group method)))
5732 ;; Check whether it exists already.
5733 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5734 (error "Group %s already exists." pgroup))
5735 ;; Subscribe the new group after the group on the current line.
5736 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5737 (gnus-group-update-group pgroup)
5739 (gnus-group-position-point)))
5741 (defun gnus-group-enter-directory (dir)
5742 "Enter an ephemeral nneething group."
5743 (interactive "DDirectory to read: ")
5744 (let* ((method (list 'nneething dir))
5745 (leaf (gnus-group-prefixed-name
5746 (file-name-nondirectory (directory-file-name dir))
5748 (name (gnus-generate-new-group-name leaf)))
5749 (let ((nneething-read-only t))
5750 (or (gnus-group-read-ephemeral-group
5752 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5754 (error "Couldn't enter %s" dir)))))
5756 ;; Group sorting commands
5757 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5759 (defun gnus-group-sort-groups (func &optional reverse)
5760 "Sort the group buffer according to FUNC.
5761 If REVERSE, reverse the sorting order."
5762 (interactive (list gnus-group-sort-function
5763 current-prefix-arg))
5765 ((not (listp func)) func)
5767 ((= 1 (length func)) (car func))
5769 ,(gnus-make-sort-function
5770 (reverse func)))))))
5771 ;; We peel off the dummy group from the alist.
5773 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5774 (pop gnus-newsrc-alist))
5776 (setq gnus-newsrc-alist
5777 (sort gnus-newsrc-alist func))
5779 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5780 ;; Regenerate the hash table.
5781 (gnus-make-hashtable-from-newsrc-alist)
5782 (gnus-group-list-groups))))
5784 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5785 "Sort the group buffer alphabetically by group name.
5786 If REVERSE, sort in reverse order."
5788 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5790 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5791 "Sort the group buffer by number of unread articles.
5792 If REVERSE, sort in reverse order."
5794 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5796 (defun gnus-group-sort-groups-by-level (&optional reverse)
5797 "Sort the group buffer by group level.
5798 If REVERSE, sort in reverse order."
5800 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5802 (defun gnus-group-sort-groups-by-score (&optional reverse)
5803 "Sort the group buffer by group score.
5804 If REVERSE, sort in reverse order."
5806 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5808 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5809 "Sort the group buffer by group rank.
5810 If REVERSE, sort in reverse order."
5812 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5814 (defun gnus-group-sort-groups-by-method (&optional reverse)
5815 "Sort the group buffer alphabetically by backend name.
5816 If REVERSE, sort in reverse order."
5818 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
5820 (defun gnus-group-sort-by-alphabet (info1 info2)
5821 "Sort alphabetically."
5822 (string< (gnus-info-group info1) (gnus-info-group info2)))
5824 (defun gnus-group-sort-by-unread (info1 info2)
5825 "Sort by number of unread articles."
5826 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
5827 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
5828 (< (or (and (numberp n1) n1) 0)
5829 (or (and (numberp n2) n2) 0))))
5831 (defun gnus-group-sort-by-level (info1 info2)
5833 (< (gnus-info-level info1) (gnus-info-level info2)))
5835 (defun gnus-group-sort-by-method (info1 info2)
5836 "Sort alphabetically by backend name."
5837 (string< (symbol-name (car (gnus-find-method-for-group
5838 (gnus-info-group info1) info1)))
5839 (symbol-name (car (gnus-find-method-for-group
5840 (gnus-info-group info2) info2)))))
5842 (defun gnus-group-sort-by-score (info1 info2)
5843 "Sort by group score."
5844 (< (gnus-info-score info1) (gnus-info-score info2)))
5846 (defun gnus-group-sort-by-rank (info1 info2)
5847 "Sort by level and score."
5848 (let ((level1 (gnus-info-level info1))
5849 (level2 (gnus-info-level info2)))
5850 (or (< level1 level2)
5851 (and (= level1 level2)
5852 (< (gnus-info-score info1) (gnus-info-score info2))))))
5854 ;; Group catching up.
5856 (defun gnus-group-clear-data (n)
5857 "Clear all marks and read ranges from the current group."
5859 (let ((groups (gnus-group-process-prefix n))
5861 (while (setq group (pop groups))
5862 (setq info (gnus-get-info group))
5863 (gnus-info-set-read info nil)
5864 (when (gnus-info-marks info)
5865 (gnus-info-set-marks info nil))
5866 (gnus-get-unread-articles-in-group info (gnus-active group) t)
5867 (when (gnus-group-goto-group group)
5868 (gnus-group-remove-mark group)
5869 (gnus-group-update-group-line)))))
5871 (defun gnus-group-catchup-current (&optional n all)
5872 "Mark all articles not marked as unread in current newsgroup as read.
5873 If prefix argument N is numeric, the ARG next newsgroups will be
5874 caught up. If ALL is non-nil, marked articles will also be marked as
5875 read. Cross references (Xref: header) of articles are ignored.
5876 The difference between N and actual number of newsgroups that were
5877 caught up is returned."
5879 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
5883 "Do you really want to mark all articles as read? "
5884 "Mark all unread articles as read? "))))
5886 (let ((groups (gnus-group-process-prefix n))
5889 ;; Virtual groups have to be given special treatment.
5890 (let ((method (gnus-find-method-for-group (car groups))))
5891 (if (eq 'nnvirtual (car method))
5892 (nnvirtual-catchup-group
5893 (gnus-group-real-name (car groups)) (nth 1 method) all)))
5894 (gnus-group-remove-mark (car groups))
5896 (gnus-group-goto-group (car groups))
5897 (gnus-group-catchup (car groups) all))
5898 (gnus-group-update-group-line)
5899 (setq ret (1+ ret)))
5900 (setq groups (cdr groups)))
5901 (gnus-group-next-unread-group 1)
5904 (defun gnus-group-catchup-current-all (&optional n)
5905 "Mark all articles in current newsgroup as read.
5906 Cross references (Xref: header) of articles are ignored."
5908 (gnus-group-catchup-current n 'all))
5910 (defun gnus-group-catchup (group &optional all)
5911 "Mark all articles in GROUP as read.
5912 If ALL is non-nil, all articles are marked as read.
5913 The return value is the number of articles that were marked as read,
5914 or nil if no action could be taken."
5915 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5917 ;; Do the updating only if the newsgroup isn't killed.
5918 (if (not (numberp (car entry)))
5919 (gnus-message 1 "Can't catch up; non-active group")
5920 ;; Do auto-expirable marks if that's required.
5921 (when (gnus-group-auto-expirable-p group)
5922 (gnus-add-marked-articles
5923 group 'expire (gnus-list-of-unread-articles group))
5925 (let ((marks (nth 3 (nth 2 entry))))
5926 (gnus-add-marked-articles
5927 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
5928 (gnus-add-marked-articles
5929 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
5931 (gnus-update-read-articles group nil)
5932 ;; Also nix out the lists of marks and dormants.
5934 (gnus-add-marked-articles group 'tick nil nil 'force)
5935 (gnus-add-marked-articles group 'dormant nil nil 'force))
5936 (run-hooks 'gnus-group-catchup-group-hook)
5939 (defun gnus-group-expire-articles (&optional n)
5940 "Expire all expirable articles in the current newsgroup."
5942 (let ((groups (gnus-group-process-prefix n))
5945 (error "No groups to expire"))
5946 (while (setq group (pop groups))
5947 (gnus-group-remove-mark group)
5948 (when (gnus-check-backend-function 'request-expire-articles group)
5949 (gnus-message 6 "Expiring articles in %s..." group)
5950 (let* ((info (gnus-get-info group))
5951 (expirable (if (gnus-group-total-expirable-p group)
5952 (cons nil (gnus-list-of-read-articles group))
5953 (assq 'expire (gnus-info-marks info))))
5954 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
5958 (gnus-compress-sequence
5960 ;; We set the expiry variables to the groupp
5962 (let ((nnmail-expiry-wait-function nil)
5963 (nnmail-expiry-wait expiry-wait))
5964 (gnus-request-expire-articles
5965 (gnus-uncompress-sequence (cdr expirable)) group))
5966 ;; Just expire using the normal expiry values.
5967 (gnus-request-expire-articles
5968 (gnus-uncompress-sequence (cdr expirable)) group)))))
5969 (gnus-message 6 "Expiring articles in %s...done" group)))
5970 (gnus-group-position-point))))
5972 (defun gnus-group-expire-all-groups ()
5973 "Expire all expirable articles in all newsgroups."
5976 (gnus-message 5 "Expiring...")
5977 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
5978 (cdr gnus-newsrc-alist))))
5979 (gnus-group-expire-articles nil)))
5980 (gnus-group-position-point)
5981 (gnus-message 5 "Expiring...done"))
5983 (defun gnus-group-set-current-level (n level)
5984 "Set the level of the next N groups to LEVEL."
5989 (let ((s (read-string
5990 (format "Level (default %s): "
5991 (or (gnus-group-group-level)
5992 gnus-level-default-subscribed)))))
5993 (if (string-match "^\\s-*$" s)
5994 (int-to-string (or (gnus-group-group-level)
5995 gnus-level-default-subscribed))
5997 (or (and (>= level 1) (<= level gnus-level-killed))
5998 (error "Illegal level: %d" level))
5999 (let ((groups (gnus-group-process-prefix n))
6001 (while (setq group (pop groups))
6002 (gnus-group-remove-mark group)
6003 (gnus-message 6 "Changed level of %s from %d to %d"
6004 group (or (gnus-group-group-level) gnus-level-killed)
6006 (gnus-group-change-level
6007 group level (or (gnus-group-group-level) gnus-level-killed))
6008 (gnus-group-update-group-line)))
6009 (gnus-group-position-point))
6011 (defun gnus-group-unsubscribe-current-group (&optional n)
6012 "Toggle subscription of the current group.
6013 If given numerical prefix, toggle the N next groups."
6015 (let ((groups (gnus-group-process-prefix n))
6018 (setq group (car groups)
6019 groups (cdr groups))
6020 (gnus-group-remove-mark group)
6021 (gnus-group-unsubscribe-group
6022 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6023 gnus-level-default-unsubscribed
6024 gnus-level-default-subscribed) t)
6025 (gnus-group-update-group-line))
6026 (gnus-group-next-group 1)))
6028 (defun gnus-group-unsubscribe-group (group &optional level silent)
6029 "Toggle subscription to GROUP.
6030 Killed newsgroups are subscribed. If SILENT, don't try to update the
6033 (list (completing-read
6034 "Group: " gnus-active-hashtb nil
6035 (memq gnus-select-method gnus-have-read-active-file))))
6036 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6038 ((string-match "^[ \t]$" group)
6039 (error "Empty group name"))
6041 ;; Toggle subscription flag.
6042 (gnus-group-change-level
6043 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6044 gnus-level-subscribed)
6045 (1+ gnus-level-subscribed)
6046 gnus-level-default-subscribed)))
6048 (gnus-group-update-group group)))
6049 ((and (stringp group)
6050 (or (not (memq gnus-select-method gnus-have-read-active-file))
6051 (gnus-active group)))
6052 ;; Add new newsgroup.
6053 (gnus-group-change-level
6055 (if level level gnus-level-default-subscribed)
6056 (or (and (member group gnus-zombie-list)
6059 (and (gnus-group-group-name)
6060 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6062 (gnus-group-update-group group)))
6063 (t (error "No such newsgroup: %s" group)))
6064 (gnus-group-position-point)))
6066 (defun gnus-group-transpose-groups (n)
6067 "Move the current newsgroup up N places.
6068 If given a negative prefix, move down instead. The difference between
6069 N and the number of steps taken is returned."
6071 (or (gnus-group-group-name)
6072 (error "No group on current line"))
6073 (gnus-group-kill-group 1)
6075 (forward-line (- n))
6076 (gnus-group-yank-group)
6077 (gnus-group-position-point)))
6079 (defun gnus-group-kill-all-zombies ()
6080 "Kill all zombie newsgroups."
6082 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6083 (setq gnus-zombie-list nil)
6084 (gnus-group-list-groups))
6086 (defun gnus-group-kill-region (begin end)
6087 "Kill newsgroups in current region (excluding current point).
6088 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6103 (beginning-of-line) ;Important when LINES < 1
6104 (gnus-group-kill-group lines)))
6106 (defun gnus-group-kill-group (&optional n discard)
6107 "Kill the next N groups.
6108 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6109 However, only groups that were alive can be yanked; already killed
6110 groups or zombie groups can't be yanked.
6111 The return value is the name of the group that was killed, or a list
6114 (let ((buffer-read-only nil)
6115 (groups (gnus-group-process-prefix n))
6116 group entry level out)
6117 (if (< (length groups) 10)
6118 ;; This is faster when there are few groups.
6120 (push (setq group (pop groups)) out)
6121 (gnus-group-remove-mark group)
6122 (setq level (gnus-group-group-level))
6124 (when (and (not discard)
6125 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6126 (push (cons (car entry) (nth 2 entry))
6127 gnus-list-of-killed-groups))
6128 (gnus-group-change-level
6129 (if entry entry group) gnus-level-killed (if entry nil level)))
6130 ;; If there are lots and lots of groups to be killed, we use
6131 ;; this thing instead.
6133 (setq groups (nreverse groups))
6135 (gnus-group-remove-mark (setq group (pop groups)))
6138 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6139 (push (cons (car entry) (nth 2 entry))
6140 gnus-list-of-killed-groups)
6141 (setcdr (cdr entry) (cdddr entry)))
6142 ((member group gnus-zombie-list)
6143 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6144 (gnus-make-hashtable-from-newsrc-alist)))
6146 (gnus-group-position-point)
6147 (if (< (length out) 2) (car out) (nreverse out))))
6149 (defun gnus-group-yank-group (&optional arg)
6150 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6151 inserting it before the current newsgroup. The numeric ARG specifies
6152 how many newsgroups are to be yanked. The name of the newsgroup yanked
6153 is returned, or (if several groups are yanked) a list of yanked groups
6156 (setq arg (or arg 1))
6157 (let (info group prev out)
6158 (while (>= (decf arg) 0)
6159 (if (not (setq info (pop gnus-list-of-killed-groups)))
6160 (error "No more newsgroups to yank"))
6161 (push (setq group (nth 1 info)) out)
6162 ;; Find which newsgroup to insert this one before - search
6163 ;; backward until something suitable is found. If there are no
6164 ;; other newsgroups in this buffer, just make this newsgroup the
6166 (setq prev (gnus-group-group-name))
6167 (gnus-group-change-level
6168 info (gnus-info-level (cdr info)) gnus-level-killed
6169 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6171 (gnus-group-insert-group-line-info group))
6173 (gnus-group-position-point)
6174 (if (< (length out) 2) (car out) (nreverse out))))
6176 (defun gnus-group-kill-level (level)
6177 "Kill all groups that is on a certain LEVEL."
6178 (interactive "nKill all groups on level: ")
6180 ((= level gnus-level-zombie)
6181 (setq gnus-killed-list
6182 (nconc gnus-zombie-list gnus-killed-list))
6183 (setq gnus-zombie-list nil))
6184 ((and (< level gnus-level-zombie)
6186 (or gnus-expert-user
6189 "Do you really want to kill all groups on level %d? "
6191 (let* ((prev gnus-newsrc-alist)
6194 (if (= (gnus-info-level level) level)
6195 (setcdr prev (cdr alist))
6197 (setq alist (cdr alist)))
6198 (gnus-make-hashtable-from-newsrc-alist)
6199 (gnus-group-list-groups)))
6201 (error "Can't kill; illegal level: %d" level))))
6203 (defun gnus-group-list-all-groups (&optional arg)
6204 "List all newsgroups with level ARG or lower.
6205 Default is gnus-level-unsubscribed, which lists all subscribed and most
6206 unsubscribed groups."
6208 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6210 ;; Redefine this to list ALL killed groups if prefix arg used.
6211 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6212 (defun gnus-group-list-killed (&optional arg)
6213 "List all killed newsgroups in the group buffer.
6214 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6215 entail asking the server for the groups."
6217 ;; Find all possible killed newsgroups if arg.
6219 ;; First make sure active file has been read.
6220 (unless gnus-have-read-active-file
6221 (let ((gnus-read-active-file t))
6222 (gnus-read-active-file)))
6223 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
6224 ;; Go through all newsgroups that are known to Gnus - enlarge kill list
6228 (group (symbol-name sym)))
6229 (if (or (null group)
6230 (gnus-gethash group gnus-killed-hashtb)
6231 (gnus-gethash group gnus-newsrc-hashtb))
6233 (let ((do-sub (gnus-matches-options-n group)))
6234 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
6236 (setq groups (1+ groups))
6237 (setq gnus-killed-list
6238 (cons group gnus-killed-list))
6239 (gnus-sethash group group gnus-killed-hashtb))))))
6240 gnus-active-hashtb))
6241 (if (not gnus-killed-list)
6242 (gnus-message 6 "No killed groups")
6243 (let (gnus-group-list-mode)
6244 (funcall gnus-group-prepare-function
6245 gnus-level-killed t gnus-level-killed))
6246 (goto-char (point-min)))
6247 (gnus-group-position-point))
6249 (defun gnus-group-list-zombies ()
6250 "List all zombie newsgroups in the group buffer."
6252 (if (not gnus-zombie-list)
6253 (gnus-message 6 "No zombie groups")
6254 (let (gnus-group-list-mode)
6255 (funcall gnus-group-prepare-function
6256 gnus-level-zombie t gnus-level-zombie))
6257 (goto-char (point-min)))
6258 (gnus-group-position-point))
6260 (defun gnus-group-list-active ()
6261 "List all groups that are available from the server(s)."
6263 ;; First we make sure that we have really read the active file.
6264 (unless gnus-have-read-active-file
6265 (let ((gnus-read-active-file t))
6266 (gnus-read-active-file)))
6267 ;; Find all groups and sort them.
6273 (and (symbol-value sym)
6274 (setq list (cons (symbol-name sym) list))))
6278 (buffer-read-only nil))
6281 (gnus-group-insert-group-line-info (pop groups)))
6282 (goto-char (point-min))))
6284 (defun gnus-activate-all-groups (level)
6285 "Activate absolutely all groups."
6286 (interactive (list 7))
6287 (let ((gnus-activate-level level)
6288 (gnus-activate-foreign-newsgroups level))
6289 (gnus-group-get-new-news)))
6291 (defun gnus-group-get-new-news (&optional arg)
6292 "Get newly arrived articles.
6293 If ARG is a number, it specifies which levels you are interested in
6294 re-scanning. If ARG is non-nil and not a number, this will force
6295 \"hard\" re-reading of the active files from all servers."
6297 (run-hooks 'gnus-get-new-news-hook)
6298 ;; We might read in new NoCeM messages here.
6299 (when (and gnus-use-nocem
6301 (gnus-nocem-scan-groups))
6302 ;; If ARG is not a number, then we read the active file.
6303 (when (and arg (not (numberp arg)))
6304 (let ((gnus-read-active-file t))
6305 (gnus-read-active-file))
6308 (setq arg (gnus-group-default-level arg t))
6309 (if (and gnus-read-active-file (not arg))
6311 (gnus-read-active-file)
6312 (gnus-get-unread-articles arg))
6313 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6314 (gnus-get-unread-articles arg)))
6315 (run-hooks 'gnus-after-getting-new-news-hook)
6316 (gnus-group-list-groups))
6318 (defun gnus-group-get-new-news-this-group (&optional n)
6319 "Check for newly arrived news in the current group (and the N-1 next groups).
6320 The difference between N and the number of newsgroup checked is returned.
6321 If N is negative, this group and the N-1 previous groups will be checked."
6323 (let* ((groups (gnus-group-process-prefix n))
6324 (ret (if (numberp n) (- n (length groups)) 0))
6327 (setq group (car groups)
6328 groups (cdr groups))
6329 (gnus-group-remove-mark group)
6330 (unless (gnus-get-new-news-in-group group)
6332 (gnus-message 3 "%s error: %s" group (gnus-status-message group))))
6333 (when gnus-goto-next-group-when-activating
6334 (gnus-group-next-unread-group 1 t))
6335 (gnus-summary-position-point)
6338 (defun gnus-get-new-news-in-group (group)
6339 (when (and group (gnus-activate-group group 'scan))
6340 (gnus-get-unread-articles-in-group
6341 (gnus-get-info group) (gnus-active group) t)
6342 (gnus-close-group group)
6343 (when (gnus-group-goto-group group)
6344 (gnus-group-update-group-line))
6347 (defun gnus-group-fetch-faq (group &optional faq-dir)
6348 "Fetch the FAQ for the current group."
6351 (gnus-group-real-name (gnus-group-group-name))
6352 (cond (current-prefix-arg
6354 "Faq dir: " (and (listp gnus-group-faq-directory)
6355 gnus-group-faq-directory))))))
6357 (setq faq-dir (if (listp gnus-group-faq-directory)
6358 (car gnus-group-faq-directory)
6359 gnus-group-faq-directory)))
6360 (or group (error "No group name given"))
6361 (let ((file (concat (file-name-as-directory faq-dir)
6362 (gnus-group-real-name group))))
6363 (if (not (file-exists-p file))
6364 (error "No such file: %s" file)
6367 (defun gnus-group-describe-group (force &optional group)
6368 "Display a description of the current newsgroup."
6369 (interactive (list current-prefix-arg (gnus-group-group-name)))
6370 (and force (setq gnus-description-hashtb nil))
6371 (let ((method (gnus-find-method-for-group group))
6373 (or group (error "No group name given"))
6374 (and (or (and gnus-description-hashtb
6375 ;; We check whether this group's method has been
6376 ;; queried for a description file.
6378 (gnus-group-prefixed-name "" method)
6379 gnus-description-hashtb))
6380 (setq desc (gnus-group-get-description group))
6381 (gnus-read-descriptions-file method))
6383 (or desc (gnus-gethash group gnus-description-hashtb)
6384 "No description available")))))
6386 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6387 (defun gnus-group-describe-all-groups (&optional force)
6388 "Pop up a buffer with descriptions of all newsgroups."
6390 (and force (setq gnus-description-hashtb nil))
6391 (if (not (or gnus-description-hashtb
6392 (gnus-read-all-descriptions-files)))
6393 (error "Couldn't request descriptions file"))
6394 (let ((buffer-read-only nil)
6400 (insert (format " *: %-20s %s\n" (symbol-name group)
6401 (symbol-value group)))
6402 (add-text-properties
6403 b (1+ b) (list 'gnus-group group
6404 'gnus-unread t 'gnus-marked nil
6405 'gnus-level (1+ gnus-level-subscribed))))
6406 gnus-description-hashtb)
6407 (goto-char (point-min))
6408 (gnus-group-position-point)))
6410 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6411 (defun gnus-group-apropos (regexp &optional search-description)
6412 "List all newsgroups that have names that match a regexp."
6413 (interactive "sGnus apropos (regexp): ")
6415 (obuf (current-buffer))
6417 ;; Go through all newsgroups that are known to Gnus.
6420 (and (symbol-name group)
6421 (string-match regexp (symbol-name group))
6422 (setq groups (cons (symbol-name group) groups))))
6424 ;; Also go through all descriptions that are known to Gnus.
6425 (when search-description
6428 (and (string-match regexp (symbol-value group))
6429 (gnus-active (symbol-name group))
6430 (setq groups (cons (symbol-name group) groups))))
6431 gnus-description-hashtb))
6433 (gnus-message 3 "No groups matched \"%s\"." regexp)
6434 ;; Print out all the groups.
6436 (pop-to-buffer "*Gnus Help*")
6437 (buffer-disable-undo (current-buffer))
6439 (setq groups (sort groups 'string<))
6441 ;; Groups may be entered twice into the list of groups.
6442 (if (not (string= (car groups) prev))
6444 (insert (setq prev (car groups)) "\n")
6445 (if (and gnus-description-hashtb
6446 (setq des (gnus-gethash (car groups)
6447 gnus-description-hashtb)))
6448 (insert " " des "\n"))))
6449 (setq groups (cdr groups)))
6450 (goto-char (point-min))))
6451 (pop-to-buffer obuf)))
6453 (defun gnus-group-description-apropos (regexp)
6454 "List all newsgroups that have names or descriptions that match a regexp."
6455 (interactive "sGnus description apropos (regexp): ")
6456 (if (not (or gnus-description-hashtb
6457 (gnus-read-all-descriptions-files)))
6458 (error "Couldn't request descriptions file"))
6459 (gnus-group-apropos regexp t))
6461 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6462 (defun gnus-group-list-matching (level regexp &optional all lowest)
6463 "List all groups with unread articles that match REGEXP.
6464 If the prefix LEVEL is non-nil, it should be a number that says which
6465 level to cut off listing groups.
6466 If ALL, also list groups with no unread articles.
6467 If LOWEST, don't list groups with level lower than LOWEST."
6468 (interactive "P\nsList newsgroups matching: ")
6469 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6470 all (or lowest 1) regexp)
6471 (goto-char (point-min))
6472 (gnus-group-position-point))
6474 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6475 "List all groups that match REGEXP.
6476 If the prefix LEVEL is non-nil, it should be a number that says which
6477 level to cut off listing groups.
6478 If LOWEST, don't list groups with level lower than LOWEST."
6479 (interactive "P\nsList newsgroups matching: ")
6480 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6482 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6483 (defun gnus-group-save-newsrc (&optional force)
6484 "Save the Gnus startup files.
6485 If FORCE, force saving whether it is necessary or not."
6487 (gnus-save-newsrc-file force))
6489 (defun gnus-group-restart (&optional arg)
6490 "Force Gnus to read the .newsrc file."
6492 (when (gnus-yes-or-no-p
6493 (format "Are you sure you want to read %s? "
6494 gnus-current-startup-file))
6495 (gnus-save-newsrc-file)
6496 (gnus-setup-news 'force)
6497 (gnus-group-list-groups arg)))
6499 (defun gnus-group-read-init-file ()
6500 "Read the Gnus elisp init file."
6502 (gnus-read-init-file))
6504 (defun gnus-group-check-bogus-groups (&optional silent)
6505 "Check bogus newsgroups.
6506 If given a prefix, don't ask for confirmation before removing a bogus
6509 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6510 (gnus-group-list-groups))
6512 (defun gnus-group-edit-global-kill (&optional article group)
6513 "Edit the global kill file.
6514 If GROUP, edit that local kill file instead."
6516 (setq gnus-current-kill-article article)
6517 (gnus-kill-file-edit-file group)
6520 (substitute-command-keys
6521 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6522 (if group "local" "global")))))
6524 (defun gnus-group-edit-local-kill (article group)
6525 "Edit a local kill file."
6526 (interactive (list nil (gnus-group-group-name)))
6527 (gnus-group-edit-global-kill article group))
6529 (defun gnus-group-force-update ()
6530 "Update `.newsrc' file."
6532 (gnus-save-newsrc-file))
6534 (defun gnus-group-suspend ()
6535 "Suspend the current Gnus session.
6536 In fact, cleanup buffers except for group mode buffer.
6537 The hook gnus-suspend-gnus-hook is called before actually suspending."
6539 (run-hooks 'gnus-suspend-gnus-hook)
6540 ;; Kill Gnus buffers except for group mode buffer.
6541 (let ((group-buf (get-buffer gnus-group-buffer)))
6542 ;; Do this on a separate list in case the user does a ^G before we finish
6543 (let ((gnus-buffer-list
6544 (delq group-buf (delq gnus-dribble-buffer
6545 (append gnus-buffer-list nil)))))
6546 (while gnus-buffer-list
6547 (gnus-kill-buffer (car gnus-buffer-list))
6548 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6551 (setq gnus-buffer-list (list group-buf))
6552 (bury-buffer group-buf)
6553 (delete-windows-on group-buf t)))))
6555 (defun gnus-group-clear-dribble ()
6556 "Clear all information from the dribble buffer."
6558 (gnus-dribble-clear)
6559 (gnus-message 7 "Cleared dribble buffer"))
6561 (defun gnus-group-exit ()
6562 "Quit reading news after updating .newsrc.eld and .newsrc.
6563 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6566 (or noninteractive ;For gnus-batch-kill
6567 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
6568 (not gnus-interactive-exit) ;Without confirmation
6570 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6571 (run-hooks 'gnus-exit-gnus-hook)
6572 ;; Offer to save data from non-quitted summary buffers.
6573 (gnus-offer-save-summaries)
6574 ;; Save the newsrc file(s).
6575 (gnus-save-newsrc-file)
6577 (gnus-close-backends)
6578 ;; Reset everything.
6580 ;; Allow the user to do things after cleaning up.
6581 (run-hooks 'gnus-after-exiting-gnus-hook)))
6583 (defun gnus-close-backends ()
6584 ;; Send a close request to all backends that support such a request.
6585 (let ((methods gnus-valid-select-methods)
6588 (if (fboundp (setq func (intern (concat (caar methods)
6589 "-request-close"))))
6591 (setq methods (cdr methods)))))
6593 (defun gnus-group-quit ()
6594 "Quit reading news without updating .newsrc.eld or .newsrc.
6595 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6597 (when (or noninteractive ;For gnus-batch-kill
6598 (zerop (buffer-size))
6599 (not (gnus-server-opened gnus-select-method))
6601 (not gnus-current-startup-file)
6603 (format "Quit reading news without saving %s? "
6604 (file-name-nondirectory gnus-current-startup-file))))
6605 (run-hooks 'gnus-exit-gnus-hook)
6606 (if gnus-use-full-window
6607 (delete-other-windows)
6608 (gnus-remove-some-windows))
6610 (gnus-close-backends)
6612 ;; Allow the user to do things after cleaning up.
6613 (run-hooks 'gnus-after-exiting-gnus-hook)))
6615 (defun gnus-offer-save-summaries ()
6616 "Offer to save all active summary buffers."
6618 (let ((buflist (buffer-list))
6620 ;; Go through all buffers and find all summaries.
6622 (and (setq bufname (buffer-name (car buflist)))
6623 (string-match "Summary" bufname)
6625 (set-buffer bufname)
6626 ;; We check that this is, indeed, a summary buffer.
6627 (and (eq major-mode 'gnus-summary-mode)
6628 ;; Also make sure this isn't bogus.
6629 gnus-newsgroup-prepared))
6630 (push bufname buffers))
6631 (setq buflist (cdr buflist)))
6632 ;; Go through all these summary buffers and offer to save them.
6635 "Update summary buffer %s? "
6636 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6639 (defun gnus-group-describe-briefly ()
6640 "Give a one line description of the group mode commands."
6642 (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")))
6644 (defun gnus-group-browse-foreign-server (method)
6645 "Browse a foreign news server.
6646 If called interactively, this function will ask for a select method
6647 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6648 If not, METHOD should be a list where the first element is the method
6649 and the second element is the address."
6651 (list (let ((how (completing-read
6653 (append gnus-valid-select-methods gnus-server-alist)
6654 nil t (cons "nntp" 0))))
6655 ;; We either got a backend name or a virtual server name.
6656 ;; If the first, we also need an address.
6657 (if (assoc how gnus-valid-select-methods)
6659 ;; Suggested by mapjph@bath.ac.uk.
6662 (mapcar (lambda (server) (list server))
6663 gnus-secondary-servers)))
6664 ;; We got a server name, so we find the method.
6665 (gnus-server-to-method how)))))
6666 (gnus-browse-foreign-server method))
6670 ;;; Gnus summary mode
6673 (defvar gnus-summary-mode-map nil)
6675 (put 'gnus-summary-mode 'mode-class 'special)
6677 (unless gnus-summary-mode-map
6678 (setq gnus-summary-mode-map (make-keymap))
6679 (suppress-keymap gnus-summary-mode-map)
6681 ;; Non-orthogonal keys
6683 (gnus-define-keys gnus-summary-mode-map
6684 " " gnus-summary-next-page
6685 "\177" gnus-summary-prev-page
6686 [delete] gnus-summary-prev-page
6687 "\r" gnus-summary-scroll-up
6688 "n" gnus-summary-next-unread-article
6689 "p" gnus-summary-prev-unread-article
6690 "N" gnus-summary-next-article
6691 "P" gnus-summary-prev-article
6692 "\M-\C-n" gnus-summary-next-same-subject
6693 "\M-\C-p" gnus-summary-prev-same-subject
6694 "\M-n" gnus-summary-next-unread-subject
6695 "\M-p" gnus-summary-prev-unread-subject
6696 "." gnus-summary-first-unread-article
6697 "," gnus-summary-best-unread-article
6698 "\M-s" gnus-summary-search-article-forward
6699 "\M-r" gnus-summary-search-article-backward
6700 "<" gnus-summary-beginning-of-article
6701 ">" gnus-summary-end-of-article
6702 "j" gnus-summary-goto-article
6703 "^" gnus-summary-refer-parent-article
6704 "\M-^" gnus-summary-refer-article
6705 "u" gnus-summary-tick-article-forward
6706 "!" gnus-summary-tick-article-forward
6707 "U" gnus-summary-tick-article-backward
6708 "d" gnus-summary-mark-as-read-forward
6709 "D" gnus-summary-mark-as-read-backward
6710 "E" gnus-summary-mark-as-expirable
6711 "\M-u" gnus-summary-clear-mark-forward
6712 "\M-U" gnus-summary-clear-mark-backward
6713 "k" gnus-summary-kill-same-subject-and-select
6714 "\C-k" gnus-summary-kill-same-subject
6715 "\M-\C-k" gnus-summary-kill-thread
6716 "\M-\C-l" gnus-summary-lower-thread
6717 "e" gnus-summary-edit-article
6718 "#" gnus-summary-mark-as-processable
6719 "\M-#" gnus-summary-unmark-as-processable
6720 "\M-\C-t" gnus-summary-toggle-threads
6721 "\M-\C-s" gnus-summary-show-thread
6722 "\M-\C-h" gnus-summary-hide-thread
6723 "\M-\C-f" gnus-summary-next-thread
6724 "\M-\C-b" gnus-summary-prev-thread
6725 "\M-\C-u" gnus-summary-up-thread
6726 "\M-\C-d" gnus-summary-down-thread
6727 "&" gnus-summary-execute-command
6728 "c" gnus-summary-catchup-and-exit
6729 "\C-w" gnus-summary-mark-region-as-read
6730 "\C-t" gnus-summary-toggle-truncation
6731 "?" gnus-summary-mark-as-dormant
6732 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6733 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6734 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6735 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6736 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6737 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6738 "=" gnus-summary-expand-window
6739 "\C-x\C-s" gnus-summary-reselect-current-group
6740 "\M-g" gnus-summary-rescan-group
6741 "w" gnus-summary-stop-page-breaking
6742 "\C-c\C-r" gnus-summary-caesar-message
6743 "\M-t" gnus-summary-toggle-mime
6744 "f" gnus-summary-followup
6745 "F" gnus-summary-followup-with-original
6746 "C" gnus-summary-cancel-article
6747 "r" gnus-summary-reply
6748 "R" gnus-summary-reply-with-original
6749 "\C-c\C-f" gnus-summary-mail-forward
6750 "o" gnus-summary-save-article
6751 "\C-o" gnus-summary-save-article-mail
6752 "|" gnus-summary-pipe-output
6753 "\M-k" gnus-summary-edit-local-kill
6754 "\M-K" gnus-summary-edit-global-kill
6756 "\C-c\C-d" gnus-summary-describe-group
6757 "q" gnus-summary-exit
6758 "Q" gnus-summary-exit-no-update
6759 "\C-c\C-i" gnus-info-find-node
6760 gnus-mouse-2 gnus-mouse-pick-article
6761 "m" gnus-summary-mail-other-window
6762 "a" gnus-summary-post-news
6763 "x" gnus-summary-limit-to-unread
6764 "s" gnus-summary-isearch-article
6765 "t" gnus-article-hide-headers
6766 "g" gnus-summary-show-article
6767 "l" gnus-summary-goto-last-article
6768 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6769 "\C-d" gnus-summary-enter-digest-group
6771 "*" gnus-cache-enter-article
6772 "\M-*" gnus-cache-remove-article
6773 "\M-&" gnus-summary-universal-argument
6774 "\C-l" gnus-recenter
6775 "I" gnus-summary-increase-score
6776 "L" gnus-summary-lower-score
6778 "V" gnus-summary-score-map
6779 "X" gnus-uu-extract-map
6780 "S" gnus-summary-send-map)
6782 ;; Sort of orthogonal keymap
6783 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6784 "t" gnus-summary-tick-article-forward
6785 "!" gnus-summary-tick-article-forward
6786 "d" gnus-summary-mark-as-read-forward
6787 "r" gnus-summary-mark-as-read-forward
6788 "c" gnus-summary-clear-mark-forward
6789 " " gnus-summary-clear-mark-forward
6790 "e" gnus-summary-mark-as-expirable
6791 "x" gnus-summary-mark-as-expirable
6792 "?" gnus-summary-mark-as-dormant
6793 "b" gnus-summary-set-bookmark
6794 "B" gnus-summary-remove-bookmark
6795 "#" gnus-summary-mark-as-processable
6796 "\M-#" gnus-summary-unmark-as-processable
6797 "S" gnus-summary-limit-include-expunged
6798 "C" gnus-summary-catchup
6799 "H" gnus-summary-catchup-to-here
6800 "\C-c" gnus-summary-catchup-all
6801 "k" gnus-summary-kill-same-subject-and-select
6802 "K" gnus-summary-kill-same-subject
6803 "P" gnus-uu-mark-map)
6805 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6806 "c" gnus-summary-clear-above
6807 "u" gnus-summary-tick-above
6808 "m" gnus-summary-mark-above
6809 "k" gnus-summary-kill-below)
6811 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6812 "/" gnus-summary-limit-to-subject
6813 "n" gnus-summary-limit-to-articles
6814 "w" gnus-summary-pop-limit
6815 "s" gnus-summary-limit-to-subject
6816 "a" gnus-summary-limit-to-author
6817 "u" gnus-summary-limit-to-unread
6818 "m" gnus-summary-limit-to-marks
6819 "v" gnus-summary-limit-to-score
6820 "D" gnus-summary-limit-include-dormant
6821 "d" gnus-summary-limit-exclude-dormant
6822 ;; "t" gnus-summary-limit-exclude-thread
6823 "E" gnus-summary-limit-include-expunged
6824 "c" gnus-summary-limit-exclude-childless-dormant
6825 "C" gnus-summary-limit-mark-excluded-as-read)
6827 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
6828 "n" gnus-summary-next-unread-article
6829 "p" gnus-summary-prev-unread-article
6830 "N" gnus-summary-next-article
6831 "P" gnus-summary-prev-article
6832 "\C-n" gnus-summary-next-same-subject
6833 "\C-p" gnus-summary-prev-same-subject
6834 "\M-n" gnus-summary-next-unread-subject
6835 "\M-p" gnus-summary-prev-unread-subject
6836 "f" gnus-summary-first-unread-article
6837 "b" gnus-summary-best-unread-article
6838 "j" gnus-summary-goto-article
6839 "g" gnus-summary-goto-subject
6840 "l" gnus-summary-goto-last-article
6841 "p" gnus-summary-pop-article)
6843 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
6844 "k" gnus-summary-kill-thread
6845 "l" gnus-summary-lower-thread
6846 "i" gnus-summary-raise-thread
6847 "T" gnus-summary-toggle-threads
6848 "t" gnus-summary-rethread-current
6849 "^" gnus-summary-reparent-thread
6850 "s" gnus-summary-show-thread
6851 "S" gnus-summary-show-all-threads
6852 "h" gnus-summary-hide-thread
6853 "H" gnus-summary-hide-all-threads
6854 "n" gnus-summary-next-thread
6855 "p" gnus-summary-prev-thread
6856 "u" gnus-summary-up-thread
6857 "o" gnus-summary-top-thread
6858 "d" gnus-summary-down-thread
6859 "#" gnus-uu-mark-thread
6860 "\M-#" gnus-uu-unmark-thread)
6862 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
6863 "c" gnus-summary-catchup-and-exit
6864 "C" gnus-summary-catchup-all-and-exit
6865 "E" gnus-summary-exit-no-update
6866 "Q" gnus-summary-exit
6867 "Z" gnus-summary-exit
6868 "n" gnus-summary-catchup-and-goto-next-group
6869 "R" gnus-summary-reselect-current-group
6870 "G" gnus-summary-rescan-group
6871 "N" gnus-summary-next-group
6872 "P" gnus-summary-prev-group)
6874 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
6875 " " gnus-summary-next-page
6876 "n" gnus-summary-next-page
6877 "\177" gnus-summary-prev-page
6878 [delete] gnus-summary-prev-page
6879 "p" gnus-summary-prev-page
6880 "\r" gnus-summary-scroll-up
6881 "<" gnus-summary-beginning-of-article
6882 ">" gnus-summary-end-of-article
6883 "b" gnus-summary-beginning-of-article
6884 "e" gnus-summary-end-of-article
6885 "^" gnus-summary-refer-parent-article
6886 "r" gnus-summary-refer-parent-article
6887 "R" gnus-summary-refer-references
6888 "g" gnus-summary-show-article
6889 "s" gnus-summary-isearch-article)
6891 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
6892 "b" gnus-article-add-buttons
6893 "B" gnus-article-add-buttons-to-head
6894 "o" gnus-article-treat-overstrike
6895 ;; "w" gnus-article-word-wrap
6896 "w" gnus-article-fill-cited-article
6897 "c" gnus-article-remove-cr
6898 "L" gnus-article-remove-trailing-blank-lines
6899 "q" gnus-article-de-quoted-unreadable
6900 "f" gnus-article-display-x-face
6901 "l" gnus-summary-stop-page-breaking
6902 "r" gnus-summary-caesar-message
6903 "t" gnus-article-hide-headers
6904 "v" gnus-summary-verbose-headers
6905 "m" gnus-summary-toggle-mime)
6907 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
6908 "a" gnus-article-hide
6909 "h" gnus-article-hide-headers
6910 "b" gnus-article-hide-boring-headers
6911 "s" gnus-article-hide-signature
6912 "c" gnus-article-hide-citation
6913 "p" gnus-article-hide-pgp
6914 "\C-c" gnus-article-hide-citation-maybe)
6916 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
6917 "a" gnus-article-highlight
6918 "h" gnus-article-highlight-headers
6919 "c" gnus-article-highlight-citation
6920 "s" gnus-article-highlight-signature)
6922 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
6923 "z" gnus-article-date-ut
6924 "u" gnus-article-date-ut
6925 "l" gnus-article-date-local
6926 "e" gnus-article-date-lapsed
6927 "o" gnus-article-date-original)
6929 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
6931 "f" gnus-summary-fetch-faq
6932 "d" gnus-summary-describe-group
6933 "h" gnus-summary-describe-briefly
6934 "i" gnus-info-find-node)
6936 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
6937 "e" gnus-summary-expire-articles
6938 "\M-\C-e" gnus-summary-expire-articles-now
6939 "\177" gnus-summary-delete-article
6940 [delete] gnus-summary-delete-article
6941 "m" gnus-summary-move-article
6942 "r" gnus-summary-respool-article
6943 "w" gnus-summary-edit-article
6944 "c" gnus-summary-copy-article
6945 "B" gnus-summary-crosspost-article
6946 "q" gnus-summary-respool-query
6947 "i" gnus-summary-import-article)
6949 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
6950 "o" gnus-summary-save-article
6951 "m" gnus-summary-save-article-mail
6952 "r" gnus-summary-save-article-rmail
6953 "f" gnus-summary-save-article-file
6954 "b" gnus-summary-save-article-body-file
6955 "h" gnus-summary-save-article-folder
6956 "v" gnus-summary-save-article-vm
6957 "p" gnus-summary-pipe-output
6958 "s" gnus-soup-add-article)
6963 (defun gnus-summary-mode (&optional group)
6964 "Major mode for reading articles.
6966 All normal editing commands are switched off.
6967 \\<gnus-summary-mode-map>
6968 Each line in this buffer represents one article. To read an
6969 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
6970 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
6973 You can also post articles and send mail from this buffer. To
6974 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
6975 of an article, type `\\[gnus-summary-reply]'.
6977 There are approx. one gazillion commands you can execute in this
6978 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
6980 The following commands are available:
6982 \\{gnus-summary-mode-map}"
6984 (when (and menu-bar-mode
6985 (gnus-visual-p 'summary-menu 'menu))
6986 (gnus-summary-make-menu-bar))
6987 (kill-all-local-variables)
6988 (let ((locals gnus-summary-local-variables))
6990 (if (consp (car locals))
6992 (make-local-variable (caar locals))
6993 (set (caar locals) (eval (cdar locals))))
6994 (make-local-variable (car locals))
6995 (set (car locals) nil))
6996 (setq locals (cdr locals))))
6997 (gnus-make-thread-indent-array)
6998 (gnus-simplify-mode-line)
6999 (setq major-mode 'gnus-summary-mode)
7000 (setq mode-name "Summary")
7001 (make-local-variable 'minor-mode-alist)
7002 (use-local-map gnus-summary-mode-map)
7003 (buffer-disable-undo (current-buffer))
7004 (setq buffer-read-only t) ;Disable modification
7005 (setq truncate-lines t)
7006 (setq selective-display t)
7007 (setq selective-display-ellipses t) ;Display `...'
7008 (setq buffer-display-table gnus-summary-display-table)
7009 (setq gnus-newsgroup-name group)
7010 (run-hooks 'gnus-summary-mode-hook))
7012 (defun gnus-summary-make-display-table ()
7013 ;; Change the display table. Odd characters have a tendency to mess
7014 ;; up nicely formatted displays - we make all possible glyphs
7015 ;; display only a single character.
7017 ;; We start from the standard display table, if any.
7018 (setq gnus-summary-display-table
7019 (or (copy-sequence standard-display-table)
7020 (make-display-table)))
7021 ;; Nix out all the control chars...
7023 (while (>= (setq i (1- i)) 0)
7024 (aset gnus-summary-display-table i [??])))
7025 ;; ... but not newline and cr, of course. (cr is necessary for the
7026 ;; selective display).
7027 (aset gnus-summary-display-table ?\n nil)
7028 (aset gnus-summary-display-table ?\r nil)
7029 ;; We nix out any glyphs over 126 that are not set already.
7031 (while (>= (setq i (1- i)) 127)
7032 ;; Only modify if the entry is nil.
7033 (or (aref gnus-summary-display-table i)
7034 (aset gnus-summary-display-table i [??])))))
7036 (defun gnus-summary-clear-local-variables ()
7037 (let ((locals gnus-summary-local-variables))
7039 (if (consp (car locals))
7040 (and (vectorp (caar locals))
7041 (set (caar locals) nil))
7042 (and (vectorp (car locals))
7043 (set (car locals) nil)))
7044 (setq locals (cdr locals)))))
7046 ;; Summary data functions.
7048 (defmacro gnus-data-number (data)
7051 (defmacro gnus-data-set-number (data number)
7052 `(setcar ,data ,number))
7054 (defmacro gnus-data-mark (data)
7057 (defmacro gnus-data-set-mark (data mark)
7058 `(setcar (nthcdr 1 ,data) ,mark))
7060 (defmacro gnus-data-pos (data)
7063 (defmacro gnus-data-set-pos (data pos)
7064 `(setcar (nthcdr 2 ,data) ,pos))
7066 (defmacro gnus-data-header (data)
7069 (defmacro gnus-data-level (data)
7072 (defmacro gnus-data-unread-p (data)
7073 `(= (nth 1 ,data) gnus-unread-mark))
7075 (defmacro gnus-data-pseudo-p (data)
7076 `(consp (nth 3 ,data)))
7078 (defmacro gnus-data-find (number)
7079 `(assq ,number gnus-newsgroup-data))
7081 (defmacro gnus-data-find-list (number &optional data)
7082 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7083 (memq (assq ,number bdata)
7086 (defmacro gnus-data-make (number mark pos header level)
7087 `(list ,number ,mark ,pos ,header ,level))
7089 (defun gnus-data-enter (after-article number mark pos header level offset)
7090 (let ((data (gnus-data-find-list after-article)))
7091 (or data (error "No such article: %d" after-article))
7092 (setcdr data (cons (gnus-data-make number mark pos header level)
7094 (setq gnus-newsgroup-data-reverse nil)
7095 (gnus-data-update-list (cddr data) offset)))
7097 (defun gnus-data-enter-list (after-article list &optional offset)
7099 (let ((data (and after-article (gnus-data-find-list after-article)))
7101 (or data (not after-article) (error "No such article: %d" after-article))
7102 ;; Find the last element in the list to be spliced into the main
7105 (setq list (cdr list)))
7108 (setcdr list gnus-newsgroup-data)
7109 (setq gnus-newsgroup-data ilist)
7110 (and offset (gnus-data-update-list (cdr list) offset)))
7111 (setcdr list (cdr data))
7113 (and offset (gnus-data-update-list (cdr data) offset)))
7114 (setq gnus-newsgroup-data-reverse nil))))
7116 (defun gnus-data-remove (article &optional offset)
7117 (let ((data gnus-newsgroup-data))
7118 (if (= (gnus-data-number (car data)) article)
7119 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7120 gnus-newsgroup-data-reverse nil)
7122 (and (= (gnus-data-number (cadr data)) article)
7124 (setcdr data (cddr data))
7125 (and offset (gnus-data-update-list (cdr data) offset))
7127 gnus-newsgroup-data-reverse nil)))
7128 (setq data (cdr data))))))
7130 (defmacro gnus-data-list (backward)
7132 (or gnus-newsgroup-data-reverse
7133 (setq gnus-newsgroup-data-reverse
7134 (reverse gnus-newsgroup-data)))
7135 gnus-newsgroup-data))
7137 (defun gnus-data-update-list (data offset)
7138 "Add OFFSET to the POS of all data entries in DATA."
7140 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7141 (setq data (cdr data))))
7143 (defun gnus-data-compute-positions ()
7144 "Compute the positions of all articles."
7145 (let ((data gnus-newsgroup-data)
7148 (when (setq pos (text-property-any
7149 (point-min) (point-max)
7150 'gnus-number (gnus-data-number (car data))))
7151 (gnus-data-set-pos (car data) (+ pos 3)))
7152 (setq data (cdr data)))))
7154 (defun gnus-summary-article-pseudo-p (article)
7155 "Say whether this article is a pseudo article or not."
7156 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7158 (defun gnus-article-parent-p (number)
7159 "Say whether this article is a parent or not."
7160 (let ((data (gnus-data-find-list number)))
7161 (and (cdr data) ; There has to be an article after...
7162 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7163 (gnus-data-level (nth 1 data))))))
7165 (defun gnus-article-children (number)
7166 "Return a list of all children to NUMBER."
7167 (let* ((data (gnus-data-find-list number))
7168 (level (gnus-data-level (car data)))
7170 (setq data (cdr data))
7172 (= (gnus-data-level (car data)) (1+ level)))
7173 (push (gnus-data-number (car data)) children)
7174 (setq data (cdr data)))
7177 (defmacro gnus-summary-skip-intangible ()
7178 "If the current article is intangible, then jump to a different article."
7179 '(let ((to (get-text-property (point) 'gnus-intangible)))
7180 (and to (gnus-summary-goto-subject to))))
7182 (defmacro gnus-summary-article-intangible-p ()
7183 "Say whether this article is intangible or not."
7184 '(get-text-property (point) 'gnus-intangible))
7186 ;; Some summary mode macros.
7188 (defmacro gnus-summary-article-number ()
7189 "The article number of the article on the current line.
7190 If there isn's an article number here, then we return the current
7193 (gnus-summary-skip-intangible)
7194 (or (get-text-property (point) 'gnus-number)
7195 (gnus-summary-last-subject))))
7197 (defmacro gnus-summary-article-header (&optional number)
7198 `(gnus-data-header (gnus-data-find
7199 ,(or number '(gnus-summary-article-number)))))
7201 (defmacro gnus-summary-thread-level (&optional number)
7202 `(if (and (eq gnus-summary-make-false-root 'dummy)
7203 (get-text-property (point) 'gnus-intangible))
7205 (gnus-data-level (gnus-data-find
7206 ,(or number '(gnus-summary-article-number))))))
7208 (defmacro gnus-summary-article-mark (&optional number)
7209 `(gnus-data-mark (gnus-data-find
7210 ,(or number '(gnus-summary-article-number)))))
7212 (defmacro gnus-summary-article-pos (&optional number)
7213 `(gnus-data-pos (gnus-data-find
7214 ,(or number '(gnus-summary-article-number)))))
7216 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7217 (defmacro gnus-summary-article-subject (&optional number)
7218 "Return current subject string or nil if nothing."
7221 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7222 '(gnus-data-header (assq (gnus-summary-article-number)
7223 gnus-newsgroup-data)))))
7226 (mail-header-subject headers))))
7228 (defmacro gnus-summary-article-score (&optional number)
7229 "Return current article score."
7230 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7231 gnus-newsgroup-scored))
7232 gnus-summary-default-score 0))
7234 (defun gnus-summary-article-children (&optional number)
7235 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7236 (level (gnus-data-level (car data)))
7238 (while (and (setq data (cdr data))
7239 (> (setq l (gnus-data-level (car data))) level))
7240 (and (= (1+ level) l)
7241 (setq children (cons (gnus-data-number (car data))
7243 (nreverse children)))
7245 (defun gnus-summary-article-parent (&optional number)
7246 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7247 (gnus-data-list t)))
7248 (level (gnus-data-level (car data))))
7250 () ; This is a root.
7251 ;; We search until we find an article with a level less than
7252 ;; this one. That function has to be the parent.
7253 (while (and (setq data (cdr data))
7254 (not (< (gnus-data-level (car data)) level))))
7255 (and data (gnus-data-number (car data))))))
7257 (defun gnus-unread-mark-p (mark)
7258 "Say whether MARK is the unread mark."
7259 (= mark gnus-unread-mark))
7261 (defun gnus-read-mark-p (mark)
7262 "Say whether MARK is one of the marks that mark as read.
7263 This is all marks except unread, ticked, dormant, and expirable."
7264 (not (or (= mark gnus-unread-mark)
7265 (= mark gnus-ticked-mark)
7266 (= mark gnus-dormant-mark)
7267 (= mark gnus-expirable-mark))))
7269 ;; Various summary mode internalish functions.
7271 (defun gnus-mouse-pick-article (e)
7274 (gnus-summary-next-page nil t))
7276 (defun gnus-summary-setup-buffer (group)
7277 "Initialize summary buffer."
7278 (let ((buffer (concat "*Summary " group "*")))
7279 (if (get-buffer buffer)
7282 (setq gnus-summary-buffer (current-buffer))
7283 (not gnus-newsgroup-prepared))
7284 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7285 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7286 (gnus-add-current-to-buffer-list)
7287 (gnus-summary-mode group)
7289 (gnus-carpal-setup-buffer 'summary))
7290 (unless gnus-single-article-buffer
7291 (make-local-variable 'gnus-article-buffer)
7292 (make-local-variable 'gnus-article-current)
7293 (make-local-variable 'gnus-original-article-buffer))
7294 (setq gnus-newsgroup-name group)
7297 (defun gnus-set-global-variables ()
7298 ;; Set the global equivalents of the summary buffer-local variables
7299 ;; to the latest values they had. These reflect the summary buffer
7300 ;; that was in action when the last article was fetched.
7301 (when (eq major-mode 'gnus-summary-mode)
7302 (setq gnus-summary-buffer (current-buffer))
7303 (let ((name gnus-newsgroup-name)
7304 (marked gnus-newsgroup-marked)
7305 (unread gnus-newsgroup-unreads)
7306 (headers gnus-current-headers)
7307 (data gnus-newsgroup-data)
7308 (summary gnus-summary-buffer)
7309 (article-buffer gnus-article-buffer)
7310 (original gnus-original-article-buffer)
7311 (gac gnus-article-current)
7312 (score-file gnus-current-score-file))
7314 (set-buffer gnus-group-buffer)
7315 (setq gnus-newsgroup-name name)
7316 (setq gnus-newsgroup-marked marked)
7317 (setq gnus-newsgroup-unreads unread)
7318 (setq gnus-current-headers headers)
7319 (setq gnus-newsgroup-data data)
7320 (setq gnus-article-current gac)
7321 (setq gnus-summary-buffer summary)
7322 (setq gnus-article-buffer article-buffer)
7323 (setq gnus-original-article-buffer original)
7324 (setq gnus-current-score-file score-file)))))
7326 (defun gnus-summary-last-article-p (&optional article)
7327 "Return whether ARTICLE is the last article in the buffer."
7328 (if (not (setq article (or article (gnus-summary-article-number))))
7329 t ; All non-existant numbers are the last article. :-)
7330 (cdr (gnus-data-find-list article))))
7332 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7333 "Insert a dummy root in the summary buffer."
7335 (add-text-properties
7336 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7337 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7339 (defvar gnus-thread-indent-array nil)
7340 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
7341 (defun gnus-make-thread-indent-array ()
7343 (unless (and gnus-thread-indent-array
7344 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7345 (setq gnus-thread-indent-array (make-vector 201 "")
7346 gnus-thread-indent-array-level gnus-thread-indent-level)
7348 (aset gnus-thread-indent-array n
7349 (make-string (* n gnus-thread-indent-level) ? ))
7352 (defun gnus-summary-insert-line
7353 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7354 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7355 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7356 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7357 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7358 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7359 (gnus-tmp-score-char
7360 (if (or (null gnus-summary-default-score)
7361 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7362 gnus-summary-zcore-fuzz)) ?
7363 (if (< gnus-tmp-score gnus-summary-default-score)
7364 gnus-score-below-mark gnus-score-over-mark)))
7365 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7366 ((memq gnus-tmp-current gnus-newsgroup-cached)
7368 (gnus-tmp-replied gnus-replied-mark)
7369 ((memq gnus-tmp-current gnus-newsgroup-saved)
7371 (t gnus-unread-mark)))
7372 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7375 ((string-match "(.+)" gnus-tmp-from)
7376 (substring gnus-tmp-from
7377 (1+ (match-beginning 0)) (1- (match-end 0))))
7378 ((string-match "<[^>]+> *$" gnus-tmp-from)
7379 (let ((beg (match-beginning 0)))
7380 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7381 (substring gnus-tmp-from (1+ (match-beginning 0))
7382 (1- (match-end 0))))
7383 (substring gnus-tmp-from 0 beg))))
7385 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7386 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7387 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7388 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7389 (buffer-read-only nil))
7390 (when (string= gnus-tmp-name "")
7391 (setq gnus-tmp-name gnus-tmp-from))
7392 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7395 (progn (eval gnus-summary-line-format-spec) (point))
7396 'gnus-number gnus-tmp-number)
7397 (when (gnus-visual-p 'summary-highlight 'highlight)
7399 (run-hooks 'gnus-summary-update-hook)
7402 (defun gnus-summary-update-line (&optional dont-update)
7403 ;; Update summary line after change.
7404 (when (and gnus-summary-default-score
7405 (not gnus-summary-inhibit-highlight))
7406 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7407 (article (gnus-summary-article-number))
7408 (score (gnus-summary-article-score article)))
7410 (if (and gnus-summary-mark-below
7411 (< (gnus-summary-article-score)
7412 gnus-summary-mark-below))
7413 ;; This article has a low score, so we mark it as read.
7414 (when (memq article gnus-newsgroup-unreads)
7415 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7416 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7417 ;; This article was previously marked as read on account
7418 ;; of a low score, but now it has risen, so we mark it as
7420 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7421 (gnus-summary-update-mark
7422 (if (or (null gnus-summary-default-score)
7423 (<= (abs (- score gnus-summary-default-score))
7424 gnus-summary-zcore-fuzz)) ?
7425 (if (< score gnus-summary-default-score)
7426 gnus-score-below-mark gnus-score-over-mark)) 'score))
7427 ;; Do visual highlighting.
7428 (when (gnus-visual-p 'summary-highlight 'highlight)
7429 (run-hooks 'gnus-summary-update-hook)))))
7431 (defvar gnus-tmp-new-adopts nil)
7433 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7434 ;; Sum up all elements (and sub-elements) in a list.
7436 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7438 ((and (consp thread) (cdr thread))
7441 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7444 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7447 (when (and level (zerop level) gnus-tmp-new-adopts)
7450 'gnus-summary-number-of-articles-in-thread
7451 gnus-tmp-new-adopts))))
7453 (if (> number 1) gnus-not-empty-thread-mark
7454 gnus-empty-thread-mark)
7457 (defun gnus-summary-set-local-parameters (group)
7458 "Go through the local params of GROUP and set all variable specs in that list."
7459 (let ((params (gnus-info-params (gnus-get-info group)))
7462 (setq elem (car params)
7463 params (cdr params))
7464 (and (consp elem) ; Has to be a cons.
7465 (consp (cdr elem)) ; The cdr has to be a list.
7466 (symbolp (car elem)) ; Has to be a symbol in there.
7467 (not (memq (car elem)
7468 '(quit-config to-address to-list to-group)))
7469 (progn ; So we set it.
7470 (make-local-variable (car elem))
7471 (set (car elem) (eval (nth 1 elem))))))))
7473 (defun gnus-summary-read-group (group &optional show-all no-article
7474 kill-buffer no-display)
7475 "Start reading news in newsgroup GROUP.
7476 If SHOW-ALL is non-nil, already read articles are also listed.
7477 If NO-ARTICLE is non-nil, no article is selected initially.
7478 If NO-DISPLAY, don't generate a summary buffer."
7479 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7480 (let* ((new-group (gnus-summary-setup-buffer group))
7481 (quit-config (gnus-group-quit-config group))
7482 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7484 ;; This summary buffer exists already, so we just select it.
7486 (gnus-set-global-variables)
7488 (gnus-kill-or-deaden-summary kill-buffer))
7489 (gnus-configure-windows 'summary 'force)
7490 (gnus-set-mode-line 'summary)
7491 (gnus-summary-position-point)
7494 ;; We couldn't select this group.
7496 (when (and (eq major-mode 'gnus-summary-mode)
7497 (not (equal (current-buffer) kill-buffer)))
7498 (kill-buffer (current-buffer))
7499 (if (not quit-config)
7501 (set-buffer gnus-group-buffer)
7502 (gnus-group-jump-to-group group)
7503 (gnus-group-next-unread-group 1))
7504 (if (not (buffer-name (car quit-config)))
7505 (gnus-configure-windows 'group 'force)
7506 (set-buffer (car quit-config))
7507 (and (eq major-mode 'gnus-summary-mode)
7508 (gnus-set-global-variables))
7509 (gnus-configure-windows (cdr quit-config)))))
7510 (gnus-message 3 "Can't select group")
7512 ;; The user did a `C-g' while prompting for number of articles,
7513 ;; so we exit this group.
7514 ((eq did-select 'quit)
7515 (and (eq major-mode 'gnus-summary-mode)
7516 (not (equal (current-buffer) kill-buffer))
7517 (kill-buffer (current-buffer)))
7519 (gnus-kill-or-deaden-summary kill-buffer))
7520 (if (not quit-config)
7522 (set-buffer gnus-group-buffer)
7523 (gnus-group-jump-to-group group)
7524 (gnus-group-next-unread-group 1)
7525 (gnus-configure-windows 'group 'force))
7526 (if (not (buffer-name (car quit-config)))
7527 (gnus-configure-windows 'group 'force)
7528 (set-buffer (car quit-config))
7529 (and (eq major-mode 'gnus-summary-mode)
7530 (gnus-set-global-variables))
7531 (gnus-configure-windows (cdr quit-config))))
7532 ;; Finally signal the quit.
7534 ;; The group was successfully selected.
7536 (gnus-set-global-variables)
7537 ;; Save the active value in effect when the group was entered.
7538 (setq gnus-newsgroup-active
7540 (gnus-active gnus-newsgroup-name)))
7541 ;; You can change the summary buffer in some way with this hook.
7542 (run-hooks 'gnus-select-group-hook)
7543 ;; Set any local variables in the group parameters.
7544 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7545 (gnus-update-format-specifications)
7546 ;; Do score processing.
7547 (when gnus-use-scoring
7548 (gnus-possibly-score-headers))
7549 ;; Check whether to fill in the gaps in the threads.
7550 (when gnus-build-sparse-threads
7551 (gnus-build-sparse-threads))
7552 ;; Find the initial limit.
7554 (let ((gnus-newsgroup-dormant nil))
7555 (gnus-summary-initial-limit show-all))
7556 (gnus-summary-initial-limit show-all))
7557 ;; Generate the summary buffer.
7559 (gnus-summary-prepare))
7560 (when gnus-use-trees
7561 (gnus-tree-open group)
7562 (setq gnus-summary-highlight-line-function
7563 'gnus-tree-highlight-article))
7564 ;; If the summary buffer is empty, but there are some low-scored
7565 ;; articles or some excluded dormants, we include these in the
7567 (when (and (zerop (buffer-size))
7569 (cond (gnus-newsgroup-dormant
7570 (gnus-summary-limit-include-dormant))
7571 ((and gnus-newsgroup-scored show-all)
7572 (gnus-summary-limit-include-expunged))))
7573 ;; Function `gnus-apply-kill-file' must be called in this hook.
7574 (run-hooks 'gnus-apply-kill-hook)
7575 (if (and (zerop (buffer-size))
7578 ;; This newsgroup is empty.
7579 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7580 (gnus-message 6 "No unread news")
7582 (gnus-kill-or-deaden-summary kill-buffer))
7583 ;; Return nil from this function.
7585 ;; Hide conversation thread subtrees. We cannot do this in
7586 ;; gnus-summary-prepare-hook since kill processing may not
7587 ;; work with hidden articles.
7588 (and gnus-show-threads
7589 gnus-thread-hide-subtree
7590 (gnus-summary-hide-all-threads))
7591 ;; Show first unread article if requested.
7592 (if (and (not no-article)
7594 gnus-newsgroup-unreads
7595 gnus-auto-select-first)
7596 (if (eq gnus-auto-select-first 'best)
7597 (gnus-summary-best-unread-article)
7598 (gnus-summary-first-unread-article))
7599 ;; Don't select any articles, just move point to the first
7600 ;; article in the group.
7601 (goto-char (point-min))
7602 (gnus-summary-position-point)
7603 (gnus-set-mode-line 'summary)
7604 (gnus-configure-windows 'summary 'force))
7605 ;; If we are in async mode, we send some info to the backend.
7606 (when gnus-newsgroup-async
7607 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7609 (gnus-kill-or-deaden-summary kill-buffer))
7610 (when (get-buffer-window gnus-group-buffer t)
7611 ;; Gotta use windows, because recenter does wierd stuff if
7612 ;; the current buffer ain't the displayed window.
7613 (let ((owin (selected-window)))
7614 (select-window (get-buffer-window gnus-group-buffer t))
7615 (when (gnus-group-goto-group group)
7617 (select-window owin))))
7618 ;; Mark this buffer as "prepared".
7619 (setq gnus-newsgroup-prepared t)
7622 (defun gnus-summary-prepare ()
7623 "Generate the summary buffer."
7624 (let ((buffer-read-only nil))
7626 (setq gnus-newsgroup-data nil
7627 gnus-newsgroup-data-reverse nil)
7628 (run-hooks 'gnus-summary-generate-hook)
7629 ;; Generate the buffer, either with threads or without.
7630 (when gnus-newsgroup-headers
7631 (gnus-summary-prepare-threads
7632 (if gnus-show-threads
7633 (gnus-sort-gathered-threads
7634 (funcall gnus-summary-thread-gathering-function
7636 (gnus-cut-threads (gnus-make-threads)))))
7637 ;; Unthreaded display.
7638 (gnus-sort-articles gnus-newsgroup-headers))))
7639 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7640 ;; Call hooks for modifying summary buffer.
7641 (goto-char (point-min))
7642 (run-hooks 'gnus-summary-prepare-hook)))
7644 (defun gnus-gather-threads-by-subject (threads)
7645 "Gather threads by looking at Subject headers."
7646 (if (not gnus-summary-make-false-root)
7648 (let ((hashtb (gnus-make-hashtable 1023))
7651 subject hthread whole-subject)
7653 (setq whole-subject (mail-header-subject (caar threads)))
7656 ;; Truncate the subject.
7657 ((numberp gnus-summary-gather-subject-limit)
7658 (setq subject (gnus-simplify-subject-re whole-subject))
7659 (if (> (length subject) gnus-summary-gather-subject-limit)
7660 (substring subject 0 gnus-summary-gather-subject-limit)
7662 ;; Fuzzily simplify it.
7663 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7664 (gnus-simplify-subject-fuzzy whole-subject))
7665 ;; Just remove the leading "Re:".
7667 (gnus-simplify-subject-re whole-subject))))
7669 (if (and gnus-summary-gather-exclude-subject
7670 (string-match gnus-summary-gather-exclude-subject
7672 () ; We don't want to do anything with this article.
7673 ;; We simplify the subject before looking it up in the
7676 (if (setq hthread (gnus-gethash subject hashtb))
7678 ;; We enter a dummy root into the thread, if we
7679 ;; haven't done that already.
7680 (unless (stringp (caar hthread))
7681 (setcar hthread (list whole-subject (car hthread))))
7682 ;; We add this new gathered thread to this gathered
7684 (setcdr (car hthread)
7685 (nconc (cdar hthread) (list (car threads))))
7686 ;; Remove it from the list of threads.
7687 (setcdr prev (cdr threads))
7688 (setq threads prev))
7689 ;; Enter this thread into the hash table.
7690 (gnus-sethash subject threads hashtb)))
7692 (setq threads (cdr threads)))
7695 (defun gnus-gather-threads-by-references (threads)
7696 "Gather threads by looking at References headers."
7697 (let ((idhashtb (gnus-make-hashtable 1023))
7698 (thhashtb (gnus-make-hashtable 1023))
7701 ids references id gthread gid entered)
7703 (when (setq references (mail-header-references (caar threads)))
7704 (setq id (mail-header-id (caar threads)))
7705 (setq ids (gnus-split-references references))
7708 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7710 (gnus-sethash (car ids) id idhashtb)
7711 (gnus-sethash id threads thhashtb))
7712 (setq gthread (gnus-gethash gid thhashtb))
7714 ;; We enter a dummy root into the thread, if we
7715 ;; haven't done that already.
7716 (unless (stringp (caar gthread))
7717 (setcar gthread (list (mail-header-subject (caar gthread))
7719 ;; We add this new gathered thread to this gathered
7721 (setcdr (car gthread)
7722 (nconc (cdar gthread) (list (car threads)))))
7723 ;; Add it into the thread hash table.
7724 (gnus-sethash id gthread thhashtb)
7726 ;; Remove it from the list of threads.
7727 (setcdr prev (cdr threads))
7728 (setq threads prev))
7729 (setq ids (cdr ids))))
7731 (setq threads (cdr threads)))
7734 (defun gnus-sort-gathered-threads (threads)
7735 "Sort subtreads inside each gathered thread by article number."
7736 (let ((result threads))
7738 (when (stringp (caar threads))
7739 (setcdr (car threads)
7740 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7741 (setq threads (cdr threads)))
7744 (defun gnus-make-threads ()
7745 "Go through the dependency hashtb and find the roots. Return all threads."
7749 (unless (car (symbol-value refs))
7750 ;; These threads do not refer back to any other articles,
7751 ;; so they're roots.
7752 (setq threads (append (cdr (symbol-value refs)) threads))))
7753 gnus-newsgroup-dependencies)
7756 (defun gnus-build-sparse-threads ()
7757 (let ((headers gnus-newsgroup-headers)
7758 (deps gnus-newsgroup-dependencies)
7759 header references generation relations
7760 cthread subject child end pthread relation)
7761 ;; First we create an alist of generations/relations, where
7762 ;; generations is how much we trust the ralation, and the relation
7764 (gnus-message 7 "Making sparse threads...")
7766 (nnheader-set-temp-buffer " *gnus sparse threads*")
7767 (while (setq header (pop headers))
7768 (when (and (setq references (mail-header-references header))
7769 (not (string= references "")))
7771 (setq child (mail-header-id header)
7772 subject (mail-header-subject header))
7774 (while (search-backward ">" nil t)
7775 (setq end (1+ (point)))
7776 (when (search-backward "<" nil t)
7777 (push (list (incf generation)
7778 child (setq child (buffer-substring (point) end))
7781 (push (list (1+ generation) child nil subject) relations)
7783 (kill-buffer (current-buffer)))
7784 ;; Sort over trustworthiness.
7785 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
7786 (while (setq relation (pop relations))
7787 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
7788 (unless (car (symbol-value cthread))
7789 ;; Make this article the parent of these threads.
7790 (setcar (symbol-value cthread)
7791 (vector gnus-reffed-article-number
7795 (or (caddr relation) "") 0 0 "")))
7796 (set cthread (list (vector gnus-reffed-article-number
7798 "" "" (cadr relation)
7799 (or (caddr relation) "") 0 0 ""))))
7800 (push gnus-reffed-article-number gnus-newsgroup-limit)
7801 (push gnus-reffed-article-number gnus-newsgroup-sparse)
7802 (push (cons gnus-reffed-article-number gnus-sparse-mark)
7803 gnus-newsgroup-reads)
7804 (decf gnus-reffed-article-number)
7805 ;; Make this new thread the child of its parent.
7806 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
7807 (setcdr (symbol-value pthread)
7808 (nconc (cdr (symbol-value pthread))
7809 (list (symbol-value cthread))))
7810 (set pthread (list nil (symbol-value cthread))))))
7811 (gnus-message 7 "Making sparse threads...done")))
7813 (defun gnus-build-old-threads ()
7814 ;; Look at all the articles that refer back to old articles, and
7815 ;; fetch the headers for the articles that aren't there. This will
7816 ;; build complete threads - if the roots haven't been expired by the
7821 (when (not (car (symbol-value refs)))
7822 (setq heads (cdr (symbol-value refs)))
7824 (if (memq (mail-header-number (caar heads))
7825 gnus-newsgroup-dormant)
7826 (setq heads (cdr heads))
7827 (setq id (symbol-name refs))
7828 (while (and (setq id (gnus-build-get-header id))
7829 (not (car (gnus-gethash
7830 id gnus-newsgroup-dependencies)))))
7831 (setq heads nil)))))
7832 gnus-newsgroup-dependencies)))
7834 (defun gnus-build-get-header (id)
7835 ;; Look through the buffer of NOV lines and find the header to
7836 ;; ID. Enter this line into the dependencies hash table, and return
7837 ;; the id of the parent article (if any).
7838 (let ((deps gnus-newsgroup-dependencies)
7842 (set-buffer nntp-server-buffer)
7843 (goto-char (point-min))
7844 (while (and (not found) (search-forward id nil t))
7846 (setq found (looking-at
7847 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
7848 (regexp-quote id))))
7849 (or found (beginning-of-line 2)))
7853 (setq header (gnus-nov-parse-line
7854 (read (current-buffer)) deps))
7855 (gnus-parent-id (mail-header-references header)))))
7857 (let ((number (mail-header-number header)))
7858 (push number gnus-newsgroup-limit)
7859 (push header gnus-newsgroup-headers)
7860 (if (memq number gnus-newsgroup-unselected)
7862 (push number gnus-newsgroup-unreads)
7863 (setq gnus-newsgroup-unselected
7864 (delq number gnus-newsgroup-unselected)))
7865 (push number gnus-newsgroup-ancient)))))))
7867 (defun gnus-summary-update-article (article &optional header)
7868 "Update ARTICLE in the summary buffer."
7869 (set-buffer gnus-summary-buffer)
7870 (let* ((header (or header (gnus-summary-article-header article)))
7871 (id (mail-header-id header))
7872 (data (gnus-data-find article))
7873 (thread (gnus-id-to-thread id))
7875 (gnus-id-to-thread (or (gnus-parent-id
7876 (mail-header-references header))
7878 (buffer-read-only nil)
7880 (number (mail-header-number header))
7885 (delq thread parent))
7886 (if (gnus-summary-insert-subject id header)
7887 ;; Set the (possibly) new article number in the data structure.
7888 (gnus-data-set-number data (gnus-id-to-article id))
7892 (defun gnus-rebuild-thread (id)
7893 "Rebuild the thread containing ID."
7894 (let ((buffer-read-only nil)
7895 current thread data)
7896 (if (not gnus-show-threads)
7897 (setq thread (list (car (gnus-id-to-thread id))))
7898 ;; Get the thread this article is part of.
7899 (setq thread (gnus-remove-thread id)))
7900 (setq current (save-excursion
7901 (and (zerop (forward-line -1))
7902 (gnus-summary-article-number))))
7903 ;; If this is a gathered thread, we have to go some re-gathering.
7904 (when (stringp (car thread))
7905 (let ((subject (car thread))
7907 (setq thread (cdr thread))
7909 (unless (memq (setq thr (gnus-id-to-thread
7911 (mail-header-id (caar thread)))))
7914 (setq thread (cdr thread)))
7915 ;; We now have all (unique) roots.
7916 (if (= (length roots) 1)
7917 ;; All the loose roots are now one solid root.
7918 (setq thread (car roots))
7919 (setq thread (cons subject (gnus-sort-threads roots))))))
7921 ;; We then insert this thread into the summary buffer.
7922 (let (gnus-newsgroup-data gnus-newsgroup-threads)
7923 (gnus-summary-prepare-threads (list thread))
7924 (setq data (nreverse gnus-newsgroup-data))
7925 (setq threads gnus-newsgroup-threads))
7926 ;; We splice the new data into the data structure.
7927 (gnus-data-enter-list current data)
7928 (gnus-data-compute-positions)
7929 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
7931 (defun gnus-id-to-thread (id)
7932 "Return the (sub-)thread where ID appears."
7933 (gnus-gethash id gnus-newsgroup-dependencies))
7935 (defun gnus-id-to-article (id)
7936 "Return the article number of ID."
7937 (let ((thread (gnus-id-to-thread id)))
7939 (mail-header-number (car thread)))))
7941 (defun gnus-id-to-header (id)
7942 "Return the article headers of ID."
7943 (car (gnus-id-to-thread id)))
7945 (defun gnus-article-displayed-root-p (article)
7946 "Say whether ARTICLE is a root(ish) article."
7947 (let ((level (gnus-summary-thread-level article))
7953 (null (setq particle (gnus-id-to-article
7955 (mail-header-references
7956 (gnus-summary-article-header article))))))
7957 (null (gnus-summary-thread-level particle)))))))
7959 (defun gnus-root-id (id)
7960 "Return the id of the root of the thread where ID appears."
7962 (while (and id (setq prev (car (gnus-gethash
7963 id gnus-newsgroup-dependencies))))
7965 id (gnus-parent-id (mail-header-references prev))))
7968 (defun gnus-remove-thread (id &optional dont-remove)
7969 "Remove the thread that has ID in it."
7970 (let ((dep gnus-newsgroup-dependencies)
7971 headers thread last-id)
7972 ;; First go up in this thread until we find the root.
7973 (setq last-id (gnus-root-id id))
7974 (setq headers (list (car (gnus-id-to-thread last-id))
7975 (caadr (gnus-id-to-thread last-id))))
7976 ;; We have now found the real root of this thread. It might have
7977 ;; been gathered into some loose thread, so we have to search
7978 ;; through the threads to find the thread we wanted.
7979 (let ((threads gnus-newsgroup-threads)
7982 (setq sub (car threads))
7983 (if (stringp (car sub))
7984 ;; This is a gathered threads, so we look at the roots
7985 ;; below it to find whether this article in in this
7988 (setq sub (cdr sub))
7990 (when (member (caar sub) headers)
7991 (setq thread (car threads)
7994 (setq sub (cdr sub))))
7995 ;; It's an ordinary thread, so we check it.
7996 (when (eq (car sub) (car headers))
7999 (setq threads (cdr threads)))
8000 ;; If this article is in no thread, then it's a root.
8003 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8004 (setq thread (gnus-gethash last-id dep)))
8007 thread ; We return this thread.
8009 (if (stringp (car thread))
8011 ;; If we use dummy roots, then we have to remove the
8012 ;; dummy root as well.
8013 (when (eq gnus-summary-make-false-root 'dummy)
8016 (setq thread (cdr thread))
8018 (gnus-remove-thread-1 (car thread))
8019 (setq thread (cdr thread))))
8020 (gnus-remove-thread-1 thread))))))))
8022 (defun gnus-remove-thread-1 (thread)
8023 "Remove the thread THREAD recursively."
8024 (let ((number (mail-header-number (car thread)))
8026 (when (setq pos (text-property-any
8027 (point-min) (point-max) 'gnus-number number))
8030 (gnus-data-remove number))
8031 (setq thread (cdr thread))
8033 (gnus-remove-thread-1 (pop thread)))))
8035 (defun gnus-sort-threads (threads)
8037 (if (not gnus-thread-sort-functions)
8039 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8040 (car gnus-thread-sort-functions)
8042 ,(gnus-make-sort-function
8043 (reverse gnus-thread-sort-functions))))))
8044 (gnus-message 7 "Sorting threads...")
8047 (gnus-message 7 "Sorting threads...done")))))
8049 (defun gnus-sort-articles (articles)
8051 (when gnus-article-sort-functions
8052 (let ((func (if (= 1 (length gnus-article-sort-functions))
8053 (car gnus-article-sort-functions)
8055 ,(gnus-make-sort-function
8056 (reverse gnus-article-sort-functions))))))
8057 (gnus-message 7 "Sorting articles...")
8059 (setq gnus-newsgroup-headers (sort articles func))
8060 (gnus-message 7 "Sorting articles...done")))))
8062 (defun gnus-make-sort-function (funs)
8063 "Return a composite sort condition based on the functions in FUNC."
8065 `(or (,(car funs) t1 t2)
8066 (and (not (,(car funs) t2 t1))
8067 ,(gnus-make-sort-function (cdr funs))))
8068 `(,(car funs) t1 t2)))
8070 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8071 (defmacro gnus-thread-header (thread)
8072 ;; Return header of first article in THREAD.
8073 ;; Note that THREAD must never, ever be anything else than a variable -
8074 ;; using some other form will lead to serious barfage.
8075 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8076 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8077 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8080 (defsubst gnus-article-sort-by-number (h1 h2)
8081 "Sort articles by article number."
8082 (< (mail-header-number h1)
8083 (mail-header-number h2)))
8085 (defun gnus-thread-sort-by-number (h1 h2)
8086 "Sort threads by root article number."
8087 (gnus-article-sort-by-number
8088 (gnus-thread-header h1) (gnus-thread-header h2)))
8090 (defsubst gnus-article-sort-by-author (h1 h2)
8091 "Sort articles by root author."
8093 (let ((extract (funcall
8094 gnus-extract-address-components
8095 (mail-header-from h1))))
8096 (or (car extract) (cdr extract)))
8097 (let ((extract (funcall
8098 gnus-extract-address-components
8099 (mail-header-from h2))))
8100 (or (car extract) (cdr extract)))))
8102 (defun gnus-thread-sort-by-author (h1 h2)
8103 "Sort threads by root author."
8104 (gnus-article-sort-by-author
8105 (gnus-thread-header h1) (gnus-thread-header h2)))
8107 (defsubst gnus-article-sort-by-subject (h1 h2)
8108 "Sort articles by root subject."
8110 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8111 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8113 (defun gnus-thread-sort-by-subject (h1 h2)
8114 "Sort threads by root subject."
8115 (gnus-article-sort-by-subject
8116 (gnus-thread-header h1) (gnus-thread-header h2)))
8118 (defsubst gnus-article-sort-by-date (h1 h2)
8119 "Sort articles by root article date."
8121 (gnus-sortable-date (mail-header-date h1))
8122 (gnus-sortable-date (mail-header-date h2))))
8124 (defun gnus-thread-sort-by-date (h1 h2)
8125 "Sort threads by root article date."
8126 (gnus-article-sort-by-date
8127 (gnus-thread-header h1) (gnus-thread-header h2)))
8129 (defsubst gnus-article-sort-by-score (h1 h2)
8130 "Sort articles by root article score.
8131 Unscored articles will be counted as having a score of zero."
8132 (> (or (cdr (assq (mail-header-number h1)
8133 gnus-newsgroup-scored))
8134 gnus-summary-default-score 0)
8135 (or (cdr (assq (mail-header-number h2)
8136 gnus-newsgroup-scored))
8137 gnus-summary-default-score 0)))
8139 (defun gnus-thread-sort-by-score (h1 h2)
8140 "Sort threads by root article score."
8141 (gnus-article-sort-by-score
8142 (gnus-thread-header h1) (gnus-thread-header h2)))
8144 (defun gnus-thread-sort-by-total-score (h1 h2)
8145 "Sort threads by the sum of all scores in the thread.
8146 Unscored articles will be counted as having a score of zero."
8147 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8149 (defun gnus-thread-total-score (thread)
8150 ;; This function find the total score of THREAD.
8152 (if (stringp (car thread))
8153 (apply gnus-thread-score-function 0
8154 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8155 (gnus-thread-total-score-1 thread))
8156 (gnus-thread-total-score-1 (list thread))))
8158 (defun gnus-thread-total-score-1 (root)
8159 ;; This function find the total score of the thread below ROOT.
8160 (setq root (car root))
8161 (apply gnus-thread-score-function
8162 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8163 gnus-summary-default-score 0)
8164 (mapcar 'gnus-thread-total-score
8165 (cdr (gnus-gethash (mail-header-id root)
8166 gnus-newsgroup-dependencies)))))
8168 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8169 (defvar gnus-tmp-prev-subject nil)
8170 (defvar gnus-tmp-false-parent nil)
8171 (defvar gnus-tmp-root-expunged nil)
8172 (defvar gnus-tmp-dummy-line nil)
8174 (defun gnus-summary-prepare-threads (threads)
8175 "Prepare summary buffer from THREADS and indentation LEVEL.
8176 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8177 or a straight list of headers."
8178 (gnus-message 7 "Generating summary...")
8180 (setq gnus-newsgroup-threads threads)
8183 (let ((gnus-tmp-level 0)
8184 (default-score (or gnus-summary-default-score 0))
8185 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8186 thread number subject stack state gnus-tmp-gathered beg-match
8187 new-roots gnus-tmp-new-adopts thread-end
8188 gnus-tmp-header gnus-tmp-unread
8189 gnus-tmp-replied gnus-tmp-subject-or-nil
8190 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8191 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8192 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8194 (setq gnus-tmp-prev-subject nil)
8196 (if (vectorp (car threads))
8197 ;; If this is a straight (sic) list of headers, then a
8198 ;; threaded summary display isn't required, so we just create
8199 ;; an unthreaded one.
8200 (gnus-summary-prepare-unthreaded threads)
8202 ;; Do the threaded display.
8204 (while (or threads stack gnus-tmp-new-adopts new-roots)
8206 (if (and (= gnus-tmp-level 0)
8207 (not (setq gnus-tmp-dummy-line nil))
8210 (not gnus-tmp-false-parent)
8211 (or gnus-tmp-new-adopts new-roots))
8212 (if gnus-tmp-new-adopts
8213 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8214 thread (list (car gnus-tmp-new-adopts))
8215 gnus-tmp-header (caar thread)
8216 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8218 (setq thread (list (car new-roots))
8219 gnus-tmp-header (caar thread)
8220 new-roots (cdr new-roots))))
8223 ;; If there are some threads, we do them before the
8224 ;; threads on the stack.
8225 (setq thread threads
8226 gnus-tmp-header (caar thread))
8227 ;; There were no current threads, so we pop something off
8229 (setq state (car stack)
8230 gnus-tmp-level (car state)
8233 gnus-tmp-header (caar thread))))
8235 (setq gnus-tmp-false-parent nil)
8236 (setq gnus-tmp-root-expunged nil)
8237 (setq thread-end nil)
8239 (if (stringp gnus-tmp-header)
8240 ;; The header is a dummy root.
8242 ((eq gnus-summary-make-false-root 'adopt)
8243 ;; We let the first article adopt the rest.
8244 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8246 (setq gnus-tmp-gathered
8248 (lambda (h) (mail-header-number (car h)))
8251 (setq thread (cons (list (caar thread)
8254 (setq gnus-tmp-level -1
8255 gnus-tmp-false-parent t))
8256 ((eq gnus-summary-make-false-root 'empty)
8257 ;; We print adopted articles with empty subject fields.
8258 (setq gnus-tmp-gathered
8260 (lambda (h) (mail-header-number (car h)))
8263 (setq gnus-tmp-level -1))
8264 ((eq gnus-summary-make-false-root 'dummy)
8265 ;; We remember that we probably want to output a dummy
8267 (setq gnus-tmp-dummy-line gnus-tmp-header)
8268 (setq gnus-tmp-prev-subject gnus-tmp-header))
8270 ;; We do not make a root for the gathered
8271 ;; sub-threads at all.
8272 (setq gnus-tmp-level -1)))
8274 (setq number (mail-header-number gnus-tmp-header)
8275 subject (mail-header-subject gnus-tmp-header))
8278 ;; If the thread has changed subject, we might want to make
8279 ;; this subthread into a root.
8280 ((and (null gnus-thread-ignore-subject)
8281 (not (zerop gnus-tmp-level))
8282 gnus-tmp-prev-subject
8284 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8285 (setq new-roots (nconc new-roots (list (car thread)))
8287 gnus-tmp-header nil))
8288 ;; If the article lies outside the current limit,
8289 ;; then we do not display it.
8290 ((and (not (memq number gnus-newsgroup-limit))
8291 (not gnus-tmp-dummy-line))
8292 (setq gnus-tmp-gathered
8294 (lambda (h) (mail-header-number (car h)))
8297 (setq gnus-tmp-new-adopts (if (cdar thread)
8298 (append gnus-tmp-new-adopts
8300 gnus-tmp-new-adopts)
8302 gnus-tmp-header nil)
8303 (when (zerop gnus-tmp-level)
8304 (setq gnus-tmp-root-expunged t)))
8305 ;; Perhaps this article is to be marked as read?
8306 ((and gnus-summary-mark-below
8307 (< (or (cdr (assq number gnus-newsgroup-scored))
8309 gnus-summary-mark-below)
8310 ;; Don't touch sparse articles.
8311 (not (memq number gnus-newsgroup-sparse)))
8312 (setq gnus-newsgroup-unreads
8313 (delq number gnus-newsgroup-unreads))
8314 (if gnus-newsgroup-auto-expire
8315 (push number gnus-newsgroup-expirable)
8316 (push (cons number gnus-low-score-mark)
8317 gnus-newsgroup-reads))))
8319 (when gnus-tmp-header
8320 ;; We may have an old dummy line to output before this
8322 (when gnus-tmp-dummy-line
8323 (gnus-summary-insert-dummy-line
8324 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8325 (setq gnus-tmp-dummy-line nil))
8327 ;; Compute the mark.
8331 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8332 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8333 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8334 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8335 (t (or (cdr (assq number gnus-newsgroup-reads))
8336 gnus-ancient-mark))))
8338 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8339 gnus-tmp-header gnus-tmp-level)
8340 gnus-newsgroup-data)
8342 ;; Actually insert the line.
8344 gnus-tmp-subject-or-nil
8346 ((and gnus-thread-ignore-subject
8347 gnus-tmp-prev-subject
8348 (not (inline (gnus-subject-equal
8349 gnus-tmp-prev-subject subject))))
8351 ((zerop gnus-tmp-level)
8352 (if (and (eq gnus-summary-make-false-root 'empty)
8353 (memq number gnus-tmp-gathered)
8354 gnus-tmp-prev-subject
8355 (inline (gnus-subject-equal
8356 gnus-tmp-prev-subject subject)))
8357 gnus-summary-same-subject
8359 (t gnus-summary-same-subject)))
8360 (if (and (eq gnus-summary-make-false-root 'adopt)
8361 (= gnus-tmp-level 1)
8362 (memq number gnus-tmp-gathered))
8363 (setq gnus-tmp-opening-bracket ?\<
8364 gnus-tmp-closing-bracket ?\>)
8365 (setq gnus-tmp-opening-bracket ?\[
8366 gnus-tmp-closing-bracket ?\]))
8368 gnus-tmp-indentation
8369 (aref gnus-thread-indent-array gnus-tmp-level)
8370 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8371 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8372 gnus-summary-default-score 0)
8374 (if (or (null gnus-summary-default-score)
8375 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8376 gnus-summary-zcore-fuzz)) ?
8377 (if (< gnus-tmp-score gnus-summary-default-score)
8378 gnus-score-below-mark gnus-score-over-mark))
8380 (cond ((memq number gnus-newsgroup-processable)
8382 ((memq number gnus-newsgroup-cached)
8384 ((memq number gnus-newsgroup-replied)
8386 (t gnus-unread-mark))
8387 gnus-tmp-from (mail-header-from gnus-tmp-header)
8390 ((string-match "(.+)" gnus-tmp-from)
8391 (substring gnus-tmp-from
8392 (1+ (match-beginning 0)) (1- (match-end 0))))
8393 ((string-match "<[^>]+> *$" gnus-tmp-from)
8394 (setq beg-match (match-beginning 0))
8395 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8396 (substring gnus-tmp-from (1+ (match-beginning 0))
8397 (1- (match-end 0))))
8398 (substring gnus-tmp-from 0 beg-match)))
8400 (when (string= gnus-tmp-name "")
8401 (setq gnus-tmp-name gnus-tmp-from))
8402 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8405 (progn (eval gnus-summary-line-format-spec) (point))
8406 'gnus-number number)
8409 (run-hooks 'gnus-summary-update-hook)
8412 (setq gnus-tmp-prev-subject subject)))
8414 (when (nth 1 thread)
8415 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8416 (incf gnus-tmp-level)
8417 (setq threads (if thread-end nil (cdar thread)))
8419 (setq gnus-tmp-level 0)))))
8420 (gnus-message 7 "Generating summary...done"))
8422 (defun gnus-summary-prepare-unthreaded (headers)
8423 "Generate an unthreaded summary buffer based on HEADERS."
8424 (let (header number mark)
8427 (setq header (car headers)
8428 headers (cdr headers)
8429 number (mail-header-number header))
8431 ;; We may have to root out some bad articles...
8432 (when (memq number gnus-newsgroup-limit)
8433 (when (and gnus-summary-mark-below
8434 (< (or (cdr (assq number gnus-newsgroup-scored))
8435 gnus-summary-default-score 0)
8436 gnus-summary-mark-below))
8437 (setq gnus-newsgroup-unreads
8438 (delq number gnus-newsgroup-unreads))
8439 (if gnus-newsgroup-auto-expire
8440 (push number gnus-newsgroup-expirable)
8441 (push (cons number gnus-low-score-mark)
8442 gnus-newsgroup-reads)))
8446 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8447 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8448 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8449 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8450 (t (or (cdr (assq number gnus-newsgroup-reads))
8451 gnus-ancient-mark))))
8452 (setq gnus-newsgroup-data
8453 (cons (gnus-data-make number mark (1+ (point)) header 0)
8454 gnus-newsgroup-data))
8455 (gnus-summary-insert-line
8456 header 0 nil mark (memq number gnus-newsgroup-replied)
8457 (memq number gnus-newsgroup-expirable)
8458 (mail-header-subject header) nil
8459 (cdr (assq number gnus-newsgroup-scored))
8460 (memq number gnus-newsgroup-processable))))))
8462 (defun gnus-select-newsgroup (group &optional read-all)
8463 "Select newsgroup GROUP.
8464 If READ-ALL is non-nil, all articles in the group are selected."
8465 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8466 (info (nth 2 entry))
8467 articles fetched-articles cached)
8469 (or (gnus-check-server
8470 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8471 (error "Couldn't open server"))
8473 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8474 (gnus-activate-group group) ; Or we can activate it...
8475 (progn ; Or we bug out.
8476 (when (equal major-mode 'gnus-summary-mode)
8477 (kill-buffer (current-buffer)))
8478 (error "Couldn't request group %s: %s"
8479 group (gnus-status-message group))))
8481 (setq gnus-newsgroup-name group)
8482 (setq gnus-newsgroup-unselected nil)
8483 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8485 (and gnus-asynchronous
8486 (gnus-check-backend-function
8487 'request-asynchronous gnus-newsgroup-name)
8488 (setq gnus-newsgroup-async
8489 (gnus-request-asynchronous gnus-newsgroup-name)))
8491 ;; Adjust and set lists of article marks.
8493 (gnus-adjust-marked-articles info))
8495 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8496 (when (gnus-virtual-group-p group)
8497 (setq cached gnus-newsgroup-cached))
8499 (setq gnus-newsgroup-unreads
8500 (gnus-set-difference
8501 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8502 gnus-newsgroup-dormant))
8504 (setq gnus-newsgroup-processable nil)
8506 (setq articles (gnus-articles-to-read group read-all))
8510 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8512 ((eq articles 0) nil)
8514 ;; Init the dependencies hash table.
8515 (setq gnus-newsgroup-dependencies
8516 (gnus-make-hashtable (length articles)))
8517 ;; Retrieve the headers and read them in.
8518 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8519 (setq gnus-newsgroup-headers
8521 (setq gnus-headers-retrieved-by
8522 (gnus-retrieve-headers
8523 articles gnus-newsgroup-name
8524 ;; We might want to fetch old headers, but
8525 ;; not if there is only 1 article.
8526 (and gnus-fetch-old-headers
8528 (not (eq gnus-fetch-old-headers 'some))
8529 (not (numberp gnus-fetch-old-headers)))
8530 (> (length articles) 1))))))
8531 (gnus-get-newsgroup-headers-xover articles)
8532 (gnus-get-newsgroup-headers)))
8533 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8535 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8537 (setq gnus-newsgroup-cached cached))
8539 ;; Set the initial limit.
8540 (setq gnus-newsgroup-limit (copy-sequence articles))
8541 ;; Remove canceled articles from the list of unread articles.
8542 (setq gnus-newsgroup-unreads
8543 (gnus-set-sorted-intersection
8544 gnus-newsgroup-unreads
8545 (setq fetched-articles
8546 (mapcar (lambda (headers) (mail-header-number headers))
8547 gnus-newsgroup-headers))))
8548 ;; Removed marked articles that do not exist.
8549 (gnus-update-missing-marks
8550 (gnus-sorted-complement fetched-articles articles))
8551 ;; We might want to build some more threads first.
8552 (and gnus-fetch-old-headers
8553 (eq gnus-headers-retrieved-by 'nov)
8554 (gnus-build-old-threads))
8555 ;; Check whether auto-expire is to be done in this group.
8556 (setq gnus-newsgroup-auto-expire
8557 (gnus-group-auto-expirable-p group))
8558 ;; Set up the article buffer now, if necessary.
8559 (unless gnus-single-article-buffer
8560 (gnus-article-setup-buffer))
8561 ;; First and last article in this newsgroup.
8562 (and gnus-newsgroup-headers
8563 (setq gnus-newsgroup-begin
8564 (mail-header-number (car gnus-newsgroup-headers)))
8565 (setq gnus-newsgroup-end
8567 (gnus-last-element gnus-newsgroup-headers))))
8568 (setq gnus-reffed-article-number -1)
8569 ;; GROUP is successfully selected.
8570 (or gnus-newsgroup-headers t)))))
8572 (defun gnus-articles-to-read (group read-all)
8573 ;; Find out what articles the user wants to read.
8575 ;; Select all articles if `read-all' is non-nil, or if there
8576 ;; are no unread articles.
8578 (and (zerop (length gnus-newsgroup-marked))
8579 (zerop (length gnus-newsgroup-unreads))))
8580 (gnus-uncompress-range (gnus-active group))
8581 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8582 (copy-sequence gnus-newsgroup-unreads))
8584 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8585 (scored (length scored-list))
8586 (number (length articles))
8587 (marked (+ (length gnus-newsgroup-marked)
8588 (length gnus-newsgroup-dormant)))
8596 ((and (or (<= scored marked) (= scored number))
8597 (numberp gnus-large-newsgroup)
8598 (> number gnus-large-newsgroup))
8602 "How many articles from %s (default %d): "
8603 gnus-newsgroup-name number))))
8604 (if (string-match "^[ \t]*$" input) number input)))
8605 ((and (> scored marked) (< scored number))
8608 (format "%s %s (%d scored, %d total): "
8609 "How many articles from"
8610 group scored number))))
8611 (if (string-match "^[ \t]*$" input)
8615 (setq select (if (stringp select) (string-to-number select) select))
8616 (if (or (null select) (zerop select))
8618 (if (and (not (zerop scored)) (<= (abs select) scored))
8620 (setq articles (sort scored-list '<))
8621 (setq number (length articles)))
8622 (setq articles (copy-sequence articles)))
8624 (if (< (abs select) number)
8626 ;; Select the N oldest articles.
8627 (setcdr (nthcdr (1- (abs select)) articles) nil)
8628 ;; Select the N most recent articles.
8629 (setq articles (nthcdr (- number select) articles))))
8630 (setq gnus-newsgroup-unselected
8631 (gnus-sorted-intersection
8632 gnus-newsgroup-unreads
8633 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8636 (defun gnus-killed-articles (killed articles)
8639 (if (inline (gnus-member-of-range (car articles) killed))
8640 (setq out (cons (car articles) out)))
8641 (setq articles (cdr articles)))
8644 (defun gnus-uncompress-marks (marks)
8645 "Uncompress the mark ranges in MARKS."
8646 (let ((uncompressed '(score bookmark))
8649 (if (memq (caar marks) uncompressed)
8650 (push (car marks) out)
8651 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8652 (setq marks (cdr marks)))
8655 (defun gnus-adjust-marked-articles (info)
8656 "Set all article lists and remove all marks that are no longer legal."
8657 (let* ((marked-lists (gnus-info-marks info))
8658 (active (gnus-active (gnus-info-group info)))
8661 (types gnus-article-mark-lists)
8662 (uncompressed '(score bookmark))
8663 marks var articles article mark)
8666 (setq marks (pop marked-lists))
8667 (set (setq var (intern (format "gnus-newsgroup-%s"
8668 (car (rassq (setq mark (car marks))
8670 (if (memq (car marks) uncompressed) (cdr marks)
8671 (gnus-uncompress-range (cdr marks))))
8673 (setq articles (symbol-value var))
8675 ;; All articles have to be subsets of the active articles.
8677 ;; Adjust "simple" lists.
8678 ((memq mark '(tick dormant expirable reply killed save))
8680 (when (or (< (setq article (pop articles)) min) (> article max))
8681 (set var (delq article (symbol-value var))))))
8683 ((memq mark '(score bookmark))
8685 (when (or (< (car (setq article (pop articles))) min)
8686 (> (car article) max))
8687 (set var (delq article (symbol-value var))))))))))
8689 (defun gnus-update-missing-marks (missing)
8690 "Go through the list of MISSING articles and remove them mark lists."
8692 (let ((types gnus-article-mark-lists)
8694 ;; Go through all types.
8696 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8697 (when (symbol-value var)
8698 ;; This list has articles. So we delete all missing articles
8702 (set var (delq (pop m) (symbol-value var)))))))))
8704 (defun gnus-update-marks ()
8705 "Enter the various lists of marked articles into the newsgroup info list."
8706 (let ((types gnus-article-mark-lists)
8707 (info (gnus-get-info gnus-newsgroup-name))
8708 (uncompressed '(score bookmark killed))
8709 type list newmarked symbol)
8711 ;; Add all marks lists that are non-nil to the list of marks lists.
8713 (setq type (pop types))
8714 (when (setq list (symbol-value
8716 (intern (format "gnus-newsgroup-%s"
8718 (push (cons (cdr type)
8719 (if (memq (cdr type) uncompressed) list
8720 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8723 ;; Enter these new marks into the info of the group.
8725 (setcar (nthcdr 3 info) newmarked)
8726 ;; Add the marks lists to the end of the info.
8728 (setcdr (nthcdr 2 info) (list newmarked))))
8730 ;; Cut off the end of the info if there's nothing else there.
8734 (when (nthcdr (decf i) info)
8735 (setcdr (nthcdr i info) nil)))))))
8737 (defun gnus-add-marked-articles (group type articles &optional info force)
8738 ;; Add ARTICLES of TYPE to the info of GROUP.
8739 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8740 ;; add, but replace marked articles of TYPE with ARTICLES.
8741 (let ((info (or info (gnus-get-info group)))
8742 (uncompressed '(score bookmark killed))
8745 (and (not (setq marked (nthcdr 3 info)))
8747 (setcdr (nthcdr 2 info)
8748 (list (list (cons type (gnus-compress-sequence
8750 (and (not (setq m (assq type (car marked))))
8753 (cons (cons type (gnus-compress-sequence articles t) )
8757 (setcar (nthcdr 3 info)
8758 (delq (assq type (car marked)) (car marked)))
8759 (setcdr m (gnus-compress-sequence articles t)))
8760 (setcdr m (gnus-compress-sequence
8761 (sort (nconc (gnus-uncompress-range (cdr m))
8762 (copy-sequence articles)) '<) t))))))
8764 (defun gnus-set-mode-line (where)
8765 "This function sets the mode line of the article or summary buffers.
8766 If WHERE is `summary', the summary mode line format will be used."
8767 ;; Is this mode line one we keep updated?
8768 (when (memq where gnus-updated-mode-lines)
8771 ;; We evaluate this in the summary buffer since these
8772 ;; variables are buffer-local to that buffer.
8773 (set-buffer gnus-summary-buffer)
8774 ;; We bind all these variables that are used in the `eval' form
8776 (let* ((mformat (symbol-value
8778 (format "gnus-%s-mode-line-format-spec" where))))
8779 (gnus-tmp-group-name gnus-newsgroup-name)
8780 (gnus-tmp-article-number (or gnus-current-article 0))
8781 (gnus-tmp-unread gnus-newsgroup-unreads)
8782 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
8783 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
8784 (gnus-tmp-unread-and-unselected
8785 (cond ((and (zerop gnus-tmp-unread-and-unticked)
8786 (zerop gnus-tmp-unselected)) "")
8787 ((zerop gnus-tmp-unselected)
8788 (format "{%d more}" gnus-tmp-unread-and-unticked))
8789 (t (format "{%d(+%d) more}"
8790 gnus-tmp-unread-and-unticked
8791 gnus-tmp-unselected))))
8793 (if (and gnus-current-headers
8794 (vectorp gnus-current-headers))
8795 (mail-header-subject gnus-current-headers) ""))
8797 gnus-tmp-header);; passed as argument to any user-format-funcs
8798 (setq mode-string (eval mformat))
8799 (setq max-len (max 4 (if gnus-mode-non-string-length
8801 gnus-mode-non-string-length)
8802 (length mode-string))))
8803 ;; We might have to chop a bit of the string off...
8804 (when (> (length mode-string) max-len)
8806 (concat (gnus-truncate-string mode-string (- max-len 3))
8808 ;; Pad the mode string a bit.
8809 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
8810 ;; Update the mode line.
8811 (setq mode-line-buffer-identification (list mode-string))
8812 (set-buffer-modified-p t))))
8814 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
8815 "Go through the HEADERS list and add all Xrefs to a hash table.
8816 The resulting hash table is returned, or nil if no Xrefs were found."
8817 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
8818 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
8819 (xref-hashtb (make-vector 63 0))
8820 start group entry number xrefs header)
8822 (setq header (pop headers))
8823 (when (and (setq xrefs (mail-header-xref header))
8824 (not (memq (setq number (mail-header-number header))
8827 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
8828 (setq start (match-end 0))
8829 (setq group (if prefix
8830 (concat prefix (substring xrefs (match-beginning 1)
8832 (substring xrefs (match-beginning 1) (match-end 1))))
8834 (string-to-int (substring xrefs (match-beginning 2)
8836 (if (setq entry (gnus-gethash group xref-hashtb))
8837 (setcdr entry (cons number (cdr entry)))
8838 (gnus-sethash group (cons number nil) xref-hashtb)))))
8839 (and start xref-hashtb)))
8841 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
8842 "Look through all the headers and mark the Xrefs as read."
8843 (let ((virtual (gnus-virtual-group-p from-newsgroup))
8844 name entry info xref-hashtb idlist method nth4)
8846 (set-buffer gnus-group-buffer)
8847 (when (setq xref-hashtb
8848 (gnus-create-xref-hashtb from-newsgroup headers unreads))
8851 (unless (string= from-newsgroup (setq name (symbol-name group)))
8852 (setq idlist (symbol-value group))
8853 ;; Dead groups are not updated.
8855 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
8857 (if (stringp (setq nth4 (gnus-info-method info)))
8858 (setq nth4 (gnus-server-to-method nth4))))
8859 ;; Only do the xrefs if the group has the same
8860 ;; select method as the group we have just read.
8861 (or (gnus-methods-equal-p
8862 nth4 (gnus-find-method-for-group from-newsgroup))
8864 (equal nth4 (setq method (gnus-find-method-for-group
8866 (and (equal (car nth4) (car method))
8867 (equal (nth 1 nth4) (nth 1 method))))
8868 gnus-use-cross-reference
8869 (or (not (eq gnus-use-cross-reference t))
8871 ;; Only do cross-references on subscribed
8872 ;; groups, if that is what is wanted.
8873 (<= (gnus-info-level info) gnus-level-subscribed))
8874 (gnus-group-make-articles-read name idlist))))
8877 (defun gnus-group-make-articles-read (group articles)
8879 (entry (gnus-gethash group gnus-newsrc-hashtb))
8880 (info (nth 2 entry))
8881 (active (gnus-active group))
8883 ;; First peel off all illegal article numbers.
8885 (let ((ids articles)
8889 (if (and first (> id (cdr active)))
8891 ;; We'll end up in this situation in one particular
8892 ;; obscure situation. If you re-scan a group and get
8893 ;; a new article that is cross-posted to a different
8894 ;; group that has not been re-scanned, you might get
8895 ;; crossposted article that has a higher number than
8896 ;; Gnus believes possible. So we re-activate this
8897 ;; group as well. This might mean doing the
8898 ;; crossposting thingy will *increase* the number
8899 ;; of articles in some groups. Tsk, tsk.
8900 (setq active (or (gnus-activate-group group) active))))
8901 (if (or (> id (cdr active))
8902 (< id (car active)))
8903 (setq articles (delq id articles)))
8904 (setq ids (cdr ids)))))
8905 ;; If the read list is nil, we init it.
8907 (null (gnus-info-read info))
8909 (gnus-info-set-read info (cons 1 (1- (car active)))))
8910 ;; Then we add the read articles to the range.
8915 (gnus-info-read info) (setq articles (sort articles '<)))))
8916 ;; Then we have to re-compute how many unread
8917 ;; articles there are in this group.
8922 (setq num (- (1+ (cdr active)) (car active))))
8923 ((not (listp (cdr range)))
8924 (setq num (- (cdr active) (- (1+ (cdr range))
8928 (if (numberp (car range))
8930 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
8931 (setq range (cdr range)))
8932 (setq num (- (cdr active) num))))
8933 ;; Update the number of unread articles.
8935 ;; Update the group buffer.
8936 (gnus-group-update-group group t)))))
8938 (defun gnus-methods-equal-p (m1 m2)
8939 (let ((m1 (or m1 gnus-select-method))
8940 (m2 (or m2 gnus-select-method)))
8942 (and (eq (car m1) (car m2))
8943 (or (not (memq 'address (assoc (symbol-name (car m1))
8944 gnus-valid-select-methods)))
8945 (equal (nth 1 m1) (nth 1 m2)))))))
8947 (defsubst gnus-header-value ()
8948 (buffer-substring (match-end 0) (gnus-point-at-eol)))
8950 (defvar gnus-newsgroup-none-id 0)
8952 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
8953 (let ((cur nntp-server-buffer)
8956 (save-excursion (set-buffer gnus-summary-buffer)
8957 gnus-newsgroup-dependencies)))
8958 headers id id-dep ref-dep end ref)
8960 (set-buffer nntp-server-buffer)
8961 (let ((case-fold-search t)
8962 in-reply-to header p lines)
8963 (goto-char (point-min))
8964 ;; Search to the beginning of the next header. Error messages
8965 ;; do not begin with 2 or 3.
8966 (while (re-search-forward "^[23][0-9]+ " nil t)
8969 ;; This implementation of this function, with nine
8970 ;; search-forwards instead of the one re-search-forward and
8971 ;; a case (which basically was the old function) is actually
8972 ;; about twice as fast, even though it looks messier. You
8973 ;; can't have everything, I guess. Speed and elegance
8974 ;; doesn't always go hand in hand.
8983 (narrow-to-region (point)
8984 (or (and (search-forward "\n.\n" nil t)
8990 (if (search-forward "\nsubject: " nil t)
8991 (gnus-header-value) "(none)"))
8995 (if (search-forward "\nfrom: " nil t)
8996 (gnus-header-value) "(nobody)"))
9000 (if (search-forward "\ndate: " nil t)
9001 (gnus-header-value) ""))
9005 (if (search-forward "\nmessage-id: " nil t)
9006 (setq id (gnus-header-value))
9007 ;; If there was no message-id, we just fake one to make
9008 ;; subsequent routines simpler.
9009 (setq id (concat "none+"
9011 (setq gnus-newsgroup-none-id
9012 (1+ gnus-newsgroup-none-id)))))))
9016 (if (search-forward "\nreferences: " nil t)
9019 (setq end (match-end 0))
9025 (search-backward ">" end t)
9028 (search-backward "<" end t)
9030 ;; Get the references from the in-reply-to header if there
9031 ;; were no references and the in-reply-to header looks
9033 (if (and (search-forward "\nin-reply-to: " nil t)
9034 (setq in-reply-to (gnus-header-value))
9035 (string-match "<[^>]+>" in-reply-to))
9036 (setq ref (substring in-reply-to (match-beginning 0)
9044 (if (search-forward "\nlines: " nil t)
9045 (if (numberp (setq lines (read cur)))
9051 (and (search-forward "\nxref: " nil t)
9052 (gnus-header-value)))))
9053 ;; We do the threading while we read the headers. The
9054 ;; message-id and the last reference are both entered into
9055 ;; the same hash table. Some tippy-toeing around has to be
9056 ;; done in case an article has arrived before the article
9057 ;; which it refers to.
9058 (if (boundp (setq id-dep (intern id dependencies)))
9059 (if (and (car (symbol-value id-dep))
9061 ;; An article with this Message-ID has already
9062 ;; been seen, so we ignore this one, except we add
9063 ;; any additional Xrefs (in case the two articles
9064 ;; came from different servers).
9066 (mail-header-set-xref
9067 (car (symbol-value id-dep))
9068 (concat (or (mail-header-xref
9069 (car (symbol-value id-dep))) "")
9070 (or (mail-header-xref header) "")))
9072 (setcar (symbol-value id-dep) header))
9073 (set id-dep (list header)))
9075 (if (boundp (setq ref-dep (intern ref dependencies)))
9076 (setcdr (symbol-value ref-dep)
9077 (nconc (cdr (symbol-value ref-dep))
9078 (list (symbol-value id-dep))))
9079 (set ref-dep (list nil (symbol-value id-dep))))
9080 (setq headers (cons header headers)))
9081 (goto-char (point-max))
9083 (nreverse headers)))))
9085 ;; The following macros and functions were written by Felix Lee
9086 ;; <flee@cse.psu.edu>.
9088 (defmacro gnus-nov-read-integer ()
9090 (if (= (following-char) ?\t)
9092 (let ((num (condition-case nil (read buffer) (error nil))))
9093 (if (numberp num) num 0)))
9094 (or (eobp) (forward-char 1))))
9096 (defmacro gnus-nov-skip-field ()
9097 '(search-forward "\t" eol 'move))
9099 (defmacro gnus-nov-field ()
9100 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9102 ;; Goes through the xover lines and returns a list of vectors
9103 (defun gnus-get-newsgroup-headers-xover (sequence &optional force-new)
9104 "Parse the news overview data in the server buffer, and return a
9105 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9106 ;; Get the Xref when the users reads the articles since most/some
9107 ;; NNTP servers do not include Xrefs when using XOVER.
9108 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9109 (let ((cur nntp-server-buffer)
9110 (dependencies gnus-newsgroup-dependencies)
9111 number headers header)
9113 (set-buffer nntp-server-buffer)
9114 ;; Allow the user to mangle the headers before parsing them.
9115 (run-hooks 'gnus-parse-headers-hook)
9116 ;; Allow the user to mangle the headers before parsing them.
9117 (run-hooks 'gnus-parse-headers-hook)
9118 (goto-char (point-min))
9119 (while (and sequence (not (eobp)))
9120 (setq number (read cur))
9121 (while (and sequence (< (car sequence) number))
9122 (setq sequence (cdr sequence)))
9124 (eq number (car sequence))
9126 (setq sequence (cdr sequence))
9128 (inline (gnus-nov-parse-line
9129 number dependencies force-new)))
9130 (setq headers (cons header headers)))))
9132 (setq headers (nreverse headers)))
9135 ;; This function has to be called with point after the article number
9136 ;; on the beginning of the line.
9137 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9139 (eol (gnus-point-at-eol))
9140 (buffer (current-buffer))
9141 header ref id id-dep ref-dep)
9143 ;; overview: [num subject from date id refs chars lines misc]
9144 (narrow-to-region (point) eol)
9145 (or (eobp) (forward-char))
9151 (gnus-nov-field) ; subject
9152 (gnus-nov-field) ; from
9153 (gnus-nov-field) ; date
9154 (setq id (or (gnus-nov-field)
9157 (setq none (1+ none)))))) ; id
9160 (let ((beg (point)))
9161 (search-forward "\t" eol)
9162 (if (search-backward ">" beg t)
9166 (search-backward "<" beg t)))
9168 (gnus-nov-field)) ; refs
9169 (gnus-nov-read-integer) ; chars
9170 (gnus-nov-read-integer) ; lines
9171 (if (= (following-char) ?\n)
9173 (gnus-nov-field)) ; misc
9177 (gnus-message 4 "Strange nov line")
9183 ;; We build the thread tree.
9185 (if (boundp (setq id-dep (intern id dependencies)))
9186 (if (and (car (symbol-value id-dep))
9188 ;; An article with this Message-ID has already been seen,
9189 ;; so we ignore this one, except we add any additional
9190 ;; Xrefs (in case the two articles came from different
9193 (mail-header-set-xref
9194 (car (symbol-value id-dep))
9195 (concat (or (mail-header-xref
9196 (car (symbol-value id-dep))) "")
9197 (or (mail-header-xref header) "")))
9199 (setcar (symbol-value id-dep) header))
9200 (set id-dep (list header))))
9203 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9204 (setcdr (symbol-value ref-dep)
9205 (nconc (cdr (symbol-value ref-dep))
9206 (list (symbol-value id-dep))))
9207 (set ref-dep (list nil (symbol-value id-dep))))))
9210 (defun gnus-article-get-xrefs ()
9211 "Fill in the Xref value in `gnus-current-headers', if necessary.
9212 This is meant to be called in `gnus-article-internal-prepare-hook'."
9213 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9214 gnus-current-headers)))
9215 (or (not gnus-use-cross-reference)
9217 (and (mail-header-xref headers)
9218 (not (string= (mail-header-xref headers) "")))
9219 (let ((case-fold-search t)
9222 (nnheader-narrow-to-headers)
9223 (goto-char (point-min))
9224 (if (or (and (eq (downcase (following-char)) ?x)
9225 (looking-at "Xref:"))
9226 (search-forward "\nXref:" nil t))
9228 (goto-char (1+ (match-end 0)))
9229 (setq xref (buffer-substring (point)
9230 (progn (end-of-line) (point))))
9231 (mail-header-set-xref headers xref))))))))
9233 (defun gnus-summary-insert-subject (id &optional old-header)
9234 "Find article ID and insert the summary line for that article."
9235 (let ((header (gnus-read-header id))
9236 (number (and (numberp id) id))
9239 ;; Rebuild the thread that this article is part of and go to the
9240 ;; article we have fetched.
9242 (when (setq pos (text-property-any
9243 (point-min) (point-max) 'gnus-number
9244 (mail-header-number old-header)))
9247 (gnus-data-remove (mail-header-number old-header))))
9248 (gnus-rebuild-thread (mail-header-id header))
9249 (gnus-summary-goto-subject (setq number (mail-header-number header))))
9250 (when (and (numberp number)
9252 ;; We have to update the boundaries even if we can't fetch the
9253 ;; article if ID is a number -- so that the next `P' or `N'
9254 ;; command will fetch the previous (or next) article even
9255 ;; if the one we tried to fetch this time has been canceled.
9256 (and (> number gnus-newsgroup-end)
9257 (setq gnus-newsgroup-end number))
9258 (and (< number gnus-newsgroup-begin)
9259 (setq gnus-newsgroup-begin number))
9260 (setq gnus-newsgroup-unselected
9261 (delq number gnus-newsgroup-unselected)))
9262 ;; Report back a success?
9263 (and header (mail-header-number header))))
9265 (defun gnus-summary-work-articles (n)
9266 "Return a list of articles to be worked upon. The prefix argument,
9267 the list of process marked articles, and the current article will be
9268 taken into consideration."
9270 ((and n (numberp n))
9271 ;; A numerical prefix has been given.
9272 (let ((backward (< n 0))
9278 (push (setq article (gnus-summary-article-number))
9281 (gnus-summary-find-prev nil article)
9282 (gnus-summary-find-next nil article)))
9284 (nreverse articles)))
9285 ((and (boundp 'transient-mark-mode)
9288 ;; Work on the region between point and mark.
9289 (let ((max (max (point) (mark)))
9292 (goto-char (min (point) (mark)))
9295 (push (setq article (gnus-summary-article-number)) articles)
9296 (gnus-summary-find-next nil article)
9298 (nreverse articles))))
9299 (gnus-newsgroup-processable
9300 ;; There are process-marked articles present.
9301 (reverse gnus-newsgroup-processable))
9303 ;; Just return the current article.
9304 (list (gnus-summary-article-number)))))
9306 (defun gnus-summary-search-group (&optional backward use-level)
9307 "Search for next unread newsgroup.
9308 If optional argument BACKWARD is non-nil, search backward instead."
9310 (set-buffer gnus-group-buffer)
9311 (if (gnus-group-search-forward
9312 backward nil (if use-level (gnus-group-group-level) nil))
9313 (gnus-group-group-name))))
9315 (defun gnus-summary-best-group (&optional exclude-group)
9316 "Find the name of the best unread group.
9317 If EXCLUDE-GROUP, do not go to this group."
9319 (set-buffer gnus-group-buffer)
9321 (gnus-group-best-unread-group exclude-group))))
9323 (defun gnus-summary-find-next (&optional unread article backward)
9324 (if backward (gnus-summary-find-prev)
9325 (let* ((article (or article (gnus-summary-article-number)))
9326 (arts (gnus-data-find-list article))
9328 (when (or (not gnus-summary-check-current)
9330 (not (gnus-data-unread-p (car arts))))
9331 (setq arts (cdr arts)))
9336 (when (gnus-data-unread-p (car arts))
9337 (setq result (car arts)
9339 (setq arts (cdr arts)))
9342 (goto-char (gnus-data-pos result))
9343 (gnus-data-number result)))))
9345 (defun gnus-summary-find-prev (&optional unread article)
9346 (let* ((article (or article (gnus-summary-article-number)))
9347 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9349 (when (or (not gnus-summary-check-current)
9351 (not (gnus-data-unread-p (car arts))))
9352 (setq arts (cdr arts)))
9357 (and (gnus-data-unread-p (car arts))
9358 (setq result (car arts)
9360 (setq arts (cdr arts)))
9364 (goto-char (gnus-data-pos result))
9365 (gnus-data-number result)))))
9367 (defun gnus-summary-find-subject (subject &optional unread backward article)
9368 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9369 (article (or article (gnus-summary-article-number)))
9370 (articles (gnus-data-list backward))
9371 (arts (gnus-data-find-list article articles))
9373 (when (or (not gnus-summary-check-current)
9375 (not (gnus-data-unread-p (car arts))))
9376 (setq arts (cdr arts)))
9378 (and (or (not unread)
9379 (gnus-data-unread-p (car arts)))
9380 (vectorp (gnus-data-header (car arts)))
9382 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9383 (setq result (car arts)
9385 (setq arts (cdr arts)))
9387 (goto-char (gnus-data-pos result))
9388 (gnus-data-number result))))
9390 (defun gnus-summary-search-forward (&optional unread subject backward)
9391 "Search forward for an article.
9392 If UNREAD, look for unread articles. If SUBJECT, look for
9393 articles with that subject. If BACKWARD, search backward instead."
9394 (cond (subject (gnus-summary-find-subject subject unread backward))
9395 (backward (gnus-summary-find-prev unread))
9396 (t (gnus-summary-find-next unread))))
9398 (defun gnus-recenter (&optional n)
9399 "Center point in window and redisplay frame.
9400 Also do horizontal recentering."
9402 (when (and gnus-auto-center-summary
9403 (not (eq gnus-auto-center-summary 'vertical)))
9404 (gnus-horizontal-recenter))
9407 (defun gnus-summary-recenter ()
9408 "Center point in the summary window.
9409 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9410 displayed, no centering will be performed."
9411 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9412 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9413 (let* ((top (cond ((< (window-height) 4) 0)
9414 ((< (window-height) 7) 1)
9416 (height (1- (window-height)))
9417 (bottom (save-excursion (goto-char (point-max))
9418 (forward-line (- height))
9420 (window (get-buffer-window (current-buffer))))
9421 ;; The user has to want it.
9422 (when gnus-auto-center-summary
9423 (when (get-buffer-window gnus-article-buffer)
9424 ;; Only do recentering when the article buffer is displayed,
9425 ;; Set the window start to either `bottom', which is the biggest
9426 ;; possible valid number, or the second line from the top,
9427 ;; whichever is the least.
9429 window (min bottom (save-excursion
9430 (forward-line (- top)) (point)))))
9431 ;; Do horizontal recentering while we're at it.
9432 (when (and (get-buffer-window (current-buffer) t)
9433 (not (eq gnus-auto-center-summary 'vertical)))
9434 (let ((selected (selected-window)))
9435 (select-window (get-buffer-window (current-buffer) t))
9436 (gnus-summary-position-point)
9437 (gnus-horizontal-recenter)
9438 (select-window selected))))))
9440 (defun gnus-horizontal-recenter ()
9441 "Recenter the current buffer horizontally."
9442 (if (< (current-column) (/ (window-width) 2))
9443 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9444 (let* ((orig (point))
9445 (end (window-end (get-buffer-window (current-buffer) t)))
9447 ;; Find the longest line currently displayed in the window.
9448 (goto-char (window-start))
9449 (while (and (not (eobp))
9452 (setq max (max max (current-column)))
9455 ;; Scroll horizontally to center (sort of) the point.
9456 (if (> max (window-width))
9458 (get-buffer-window (current-buffer) t)
9459 (min (- (current-column) (/ (window-width) 3))
9460 (+ 2 (- max (window-width)))))
9461 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9464 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9465 (defun gnus-short-group-name (group &optional levels)
9466 "Collapse GROUP name LEVELS."
9473 (while (string-match "\\." group skip)
9474 (setq skip (match-end 0)
9477 (if (string-match ":" group)
9478 (setq foreign (substring group 0 (match-end 0))
9479 group (substring group (match-end 0))))
9481 (if (and (string-match "\\." group)
9482 (> levels (- gnus-group-uncollapsed-levels 1)))
9483 (setq name (concat name (substring group 0 1))
9484 group (substring group (match-end 0))
9486 name (concat name "."))
9487 (setq name (concat foreign name group)
9491 (defun gnus-summary-jump-to-group (newsgroup)
9492 "Move point to NEWSGROUP in group mode buffer."
9493 ;; Keep update point of group mode buffer if visible.
9494 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9495 (save-window-excursion
9496 ;; Take care of tree window mode.
9497 (if (get-buffer-window gnus-group-buffer)
9498 (pop-to-buffer gnus-group-buffer))
9499 (gnus-group-jump-to-group newsgroup))
9501 ;; Take care of tree window mode.
9502 (if (get-buffer-window gnus-group-buffer)
9503 (pop-to-buffer gnus-group-buffer)
9504 (set-buffer gnus-group-buffer))
9505 (gnus-group-jump-to-group newsgroup))))
9507 ;; This function returns a list of article numbers based on the
9508 ;; difference between the ranges of read articles in this group and
9509 ;; the range of active articles.
9510 (defun gnus-list-of-unread-articles (group)
9511 (let* ((read (gnus-info-read (gnus-get-info group)))
9512 (active (gnus-active group))
9515 ;; If none are read, then all are unread.
9517 (setq first (car active))
9518 ;; If the range of read articles is a single range, then the
9519 ;; first unread article is the article after the last read
9520 ;; article. Sounds logical, doesn't it?
9521 (if (not (listp (cdr read)))
9522 (setq first (1+ (cdr read)))
9523 ;; `read' is a list of ranges.
9524 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9529 (while (< first nlast)
9530 (setq unread (cons first unread))
9531 (setq first (1+ first))))
9532 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9533 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9534 (setq read (cdr read)))))
9535 ;; And add the last unread articles.
9536 (while (<= first last)
9537 (setq unread (cons first unread))
9538 (setq first (1+ first)))
9539 ;; Return the list of unread articles.
9542 (defun gnus-list-of-read-articles (group)
9543 "Return a list of unread, unticked and non-dormant articles."
9544 (let* ((info (gnus-get-info group))
9545 (marked (gnus-info-marks info))
9546 (active (gnus-active group)))
9548 (gnus-set-difference
9549 (gnus-sorted-complement
9550 (gnus-uncompress-range active)
9551 (gnus-list-of-unread-articles group))
9553 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9554 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9556 ;; Various summary commands
9558 (defun gnus-summary-universal-argument (arg)
9559 "Perform any operation on all articles that are process/prefixed."
9561 (gnus-set-global-variables)
9562 (let ((articles (gnus-summary-work-articles arg))
9569 (substitute-command-keys
9570 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9574 (message "Undefined key")
9578 (gnus-summary-goto-subject (setq article (pop articles)))
9579 (command-execute func)
9580 (gnus-summary-remove-process-mark article)))))
9581 (gnus-summary-position-point))
9583 (defun gnus-summary-toggle-truncation (&optional arg)
9584 "Toggle truncation of summary lines.
9585 With arg, turn line truncation on iff arg is positive."
9587 (setq truncate-lines
9588 (if (null arg) (not truncate-lines)
9589 (> (prefix-numeric-value arg) 0)))
9592 (defun gnus-summary-reselect-current-group (&optional all rescan)
9593 "Exit and then reselect the current newsgroup.
9594 The prefix argument ALL means to select all articles."
9596 (gnus-set-global-variables)
9597 (let ((current-subject (gnus-summary-article-number))
9598 (group gnus-newsgroup-name))
9599 (setq gnus-newsgroup-begin nil)
9601 ;; We have to adjust the point of group mode buffer because the
9602 ;; current point was moved to the next unread newsgroup by
9604 (gnus-summary-jump-to-group group)
9607 (gnus-group-get-new-news-this-group 1)))
9608 (gnus-group-read-group all t)
9609 (gnus-summary-goto-subject current-subject)))
9611 (defun gnus-summary-rescan-group (&optional all)
9612 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9614 (gnus-summary-reselect-current-group all t))
9616 (defun gnus-summary-update-info ()
9617 (let* ((group gnus-newsgroup-name))
9618 (when gnus-newsgroup-kill-headers
9619 (setq gnus-newsgroup-killed
9620 (gnus-compress-sequence
9622 (gnus-set-sorted-intersection
9623 (gnus-uncompress-range gnus-newsgroup-killed)
9624 (setq gnus-newsgroup-unselected
9625 (sort gnus-newsgroup-unselected '<)))
9626 (setq gnus-newsgroup-unreads
9627 (sort gnus-newsgroup-unreads '<))) t)))
9628 (unless (listp (cdr gnus-newsgroup-killed))
9629 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9630 (let ((headers gnus-newsgroup-headers))
9631 (run-hooks 'gnus-exit-group-hook)
9632 (unless gnus-save-score
9633 (setq gnus-newsgroup-scored nil))
9634 ;; Set the new ranges of read articles.
9635 (gnus-update-read-articles
9636 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9637 ;; Set the current article marks.
9639 ;; Do the cross-ref thing.
9640 (when gnus-use-cross-reference
9641 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9642 ;; Do adaptive scoring, and possibly save score files.
9643 (when gnus-newsgroup-adaptive
9644 (gnus-score-adaptive))
9645 (when gnus-use-scoring
9647 ;; Do not switch windows but change the buffer to work.
9648 (set-buffer gnus-group-buffer)
9649 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9650 (gnus-group-update-group group)))))
9652 (defun gnus-summary-exit (&optional temporary)
9653 "Exit reading current newsgroup, and then return to group selection mode.
9654 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9656 (gnus-set-global-variables)
9657 (gnus-kill-save-kill-buffer)
9658 (let* ((group gnus-newsgroup-name)
9659 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9661 (buf (current-buffer)))
9663 (run-hooks 'gnus-summary-prepare-exit-hook))
9664 ;; If we have several article buffers, we kill them at exit.
9665 (unless gnus-single-article-buffer
9666 (gnus-kill-buffer gnus-article-buffer)
9667 (gnus-kill-buffer gnus-original-article-buffer)
9668 (setq gnus-article-current nil))
9669 (when gnus-use-cache
9670 (gnus-cache-possibly-remove-articles)
9671 (gnus-cache-save-buffers))
9672 (when gnus-use-trees
9673 (gnus-tree-close group))
9674 ;; Make all changes in this group permanent.
9676 (gnus-summary-update-info))
9677 (gnus-close-group group)
9678 ;; Make sure where I was, and go to next newsgroup.
9679 (set-buffer gnus-group-buffer)
9681 (gnus-group-jump-to-group group)
9682 (gnus-group-next-unread-group 1))
9683 (run-hooks 'gnus-summary-exit-hook)
9684 (unless gnus-single-article-buffer
9685 (setq gnus-article-current nil))
9688 ;; If we have several article buffers, we kill them at exit.
9689 (unless gnus-single-article-buffer
9690 (gnus-kill-buffer gnus-article-buffer)
9691 (gnus-kill-buffer gnus-original-article-buffer)
9692 (setq gnus-article-current nil))
9694 (if (not gnus-kill-summary-on-exit)
9695 (gnus-deaden-summary)
9696 ;; We set all buffer-local variables to nil. It is unclear why
9697 ;; this is needed, but if we don't, buffer-local variables are
9698 ;; not garbage-collected, it seems. This would the lead to en
9699 ;; ever-growing Emacs.
9700 (gnus-summary-clear-local-variables)
9701 (when (get-buffer gnus-article-buffer)
9702 (bury-buffer gnus-article-buffer))
9703 ;; We clear the global counterparts of the buffer-local
9704 ;; variables as well, just to be on the safe side.
9705 (gnus-configure-windows 'group 'force)
9706 (gnus-summary-clear-local-variables)
9707 ;; Return to group mode buffer.
9708 (if (eq mode 'gnus-summary-mode)
9709 (gnus-kill-buffer buf)))
9710 (setq gnus-current-select-method gnus-select-method)
9711 (pop-to-buffer gnus-group-buffer)
9712 ;; Clear the current group name.
9713 (if (not quit-config)
9715 (gnus-group-jump-to-group group)
9716 (gnus-group-next-unread-group 1)
9717 (gnus-configure-windows 'group 'force))
9718 (if (not (buffer-name (car quit-config)))
9719 (gnus-configure-windows 'group 'force)
9720 (set-buffer (car quit-config))
9721 (and (eq major-mode 'gnus-summary-mode)
9722 (gnus-set-global-variables))
9723 (gnus-configure-windows (cdr quit-config))))
9725 (setq gnus-newsgroup-name nil)))))
9727 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9728 (defun gnus-summary-exit-no-update (&optional no-questions)
9729 "Quit reading current newsgroup without updating read article info."
9731 (gnus-set-global-variables)
9732 (let* ((group gnus-newsgroup-name)
9733 (quit-config (gnus-group-quit-config group)))
9734 (when (or no-questions
9736 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9737 ;; If we have several article buffers, we kill them at exit.
9738 (unless gnus-single-article-buffer
9739 (gnus-kill-buffer gnus-article-buffer)
9740 (gnus-kill-buffer gnus-original-article-buffer)
9741 (setq gnus-article-current nil))
9742 (if (not gnus-kill-summary-on-exit)
9743 (gnus-deaden-summary)
9744 (gnus-close-group group)
9745 (gnus-summary-clear-local-variables)
9746 (set-buffer gnus-group-buffer)
9747 (gnus-summary-clear-local-variables)
9748 (when (get-buffer gnus-summary-buffer)
9749 (kill-buffer gnus-summary-buffer)))
9750 (unless gnus-single-article-buffer
9751 (setq gnus-article-current nil))
9752 (when gnus-use-trees
9753 (gnus-tree-close group))
9754 (when (get-buffer gnus-article-buffer)
9755 (bury-buffer gnus-article-buffer))
9756 ;; Return to the group buffer.
9757 (gnus-configure-windows 'group 'force)
9758 ;; Clear the current group name.
9759 (setq gnus-newsgroup-name nil)
9760 (when (equal (gnus-group-group-name) group)
9761 (gnus-group-next-unread-group 1))
9763 (if (not (buffer-name (car quit-config)))
9764 (gnus-configure-windows 'group 'force)
9765 (set-buffer (car quit-config))
9766 (when (eq major-mode 'gnus-summary-mode)
9767 (gnus-set-global-variables))
9768 (gnus-configure-windows (cdr quit-config)))))))
9772 (defvar gnus-dead-summary-mode-map nil)
9774 (if gnus-dead-summary-mode-map
9776 (setq gnus-dead-summary-mode-map (make-keymap))
9777 (suppress-keymap gnus-dead-summary-mode-map)
9778 (substitute-key-definition
9779 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
9780 (let ((keys '("\C-d" "\r" "\177")))
9782 (define-key gnus-dead-summary-mode-map
9783 (pop keys) 'gnus-summary-wake-up-the-dead))))
9785 (defvar gnus-dead-summary-mode nil
9786 "Minor mode for Gnus summary buffers.")
9788 (defun gnus-dead-summary-mode (&optional arg)
9789 "Minor mode for Gnus summary buffers."
9791 (when (eq major-mode 'gnus-summary-mode)
9792 (make-local-variable 'gnus-dead-summary-mode)
9793 (setq gnus-dead-summary-mode
9794 (if (null arg) (not gnus-dead-summary-mode)
9795 (> (prefix-numeric-value arg) 0)))
9796 (when gnus-dead-summary-mode
9797 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
9798 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
9799 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
9800 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
9801 minor-mode-map-alist)))))
9803 (defun gnus-deaden-summary ()
9804 "Make the current summary buffer into a dead summary buffer."
9805 ;; Kill any previous dead summary buffer.
9806 (when (and gnus-dead-summary
9807 (buffer-name gnus-dead-summary))
9809 (set-buffer gnus-dead-summary)
9810 (when gnus-dead-summary-mode
9811 (kill-buffer (current-buffer)))))
9812 ;; Make this the current dead summary.
9813 (setq gnus-dead-summary (current-buffer))
9814 (gnus-dead-summary-mode 1)
9815 (let ((name (buffer-name)))
9816 (when (string-match "Summary" name)
9818 (concat (substring name 0 (match-beginning 0)) "Dead "
9819 (substring name (match-beginning 0))) t))))
9821 (defun gnus-kill-or-deaden-summary (buffer)
9822 "Kill or deaden the summary BUFFER."
9823 (cond (gnus-kill-summary-on-exit
9824 (when (and gnus-use-trees
9825 (and (get-buffer buffer)
9826 (buffer-name (get-buffer buffer))))
9828 (set-buffer (get-buffer buffer))
9829 (gnus-tree-close gnus-newsgroup-name)))
9830 (gnus-kill-buffer buffer))
9831 ((and (get-buffer buffer)
9832 (buffer-name (get-buffer buffer)))
9835 (gnus-deaden-summary)))))
9837 (defun gnus-summary-wake-up-the-dead (&rest args)
9838 "Wake up the dead summary buffer."
9840 (gnus-dead-summary-mode -1)
9841 (let ((name (buffer-name)))
9842 (when (string-match "Dead " name)
9844 (concat (substring name 0 (match-beginning 0))
9845 (substring name (match-end 0))) t)))
9846 (gnus-message 3 "This dead summary is now alive again"))
9848 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
9849 (defun gnus-summary-fetch-faq (&optional faq-dir)
9850 "Fetch the FAQ for the current group.
9851 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
9855 (if current-prefix-arg
9857 "Faq dir: " (and (listp gnus-group-faq-directory)
9858 gnus-group-faq-directory)))))
9859 (let (gnus-faq-buffer)
9860 (and (setq gnus-faq-buffer
9861 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
9862 (gnus-configure-windows 'summary-faq))))
9864 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
9865 (defun gnus-summary-describe-group (&optional force)
9866 "Describe the current newsgroup."
9868 (gnus-group-describe-group force gnus-newsgroup-name))
9870 (defun gnus-summary-describe-briefly ()
9871 "Describe summary mode commands briefly."
9874 (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")))
9876 ;; Walking around group mode buffer from summary mode.
9878 (defun gnus-summary-next-group (&optional no-article target-group backward)
9879 "Exit current newsgroup and then select next unread newsgroup.
9880 If prefix argument NO-ARTICLE is non-nil, no article is selected
9881 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
9882 previous group instead."
9884 (gnus-set-global-variables)
9885 (let ((current-group gnus-newsgroup-name)
9886 (current-buffer (current-buffer))
9888 ;; First we semi-exit this group to update Xrefs and all variables.
9889 ;; We can't do a real exit, because the window conf must remain
9890 ;; the same in case the user is prompted for info, and we don't
9891 ;; want the window conf to change before that...
9892 (gnus-summary-exit t)
9893 (while (not entered)
9894 ;; Then we find what group we are supposed to enter.
9895 (set-buffer gnus-group-buffer)
9896 (gnus-group-jump-to-group current-group)
9899 (if (eq gnus-keep-same-level 'best)
9900 (gnus-summary-best-group gnus-newsgroup-name)
9901 (gnus-summary-search-group backward gnus-keep-same-level))))
9902 (if (not target-group)
9903 ;; There are no further groups, so we return to the group
9906 (gnus-message 5 "Returning to the group buffer")
9908 (set-buffer current-buffer)
9909 (gnus-summary-exit))
9910 ;; We try to enter the target group.
9911 (gnus-group-jump-to-group target-group)
9912 (let ((unreads (gnus-group-group-unread)))
9913 (if (and (or (eq t unreads)
9914 (and unreads (not (zerop unreads))))
9915 (gnus-summary-read-group
9916 target-group nil no-article current-buffer))
9918 (setq current-group target-group
9919 target-group nil)))))))
9921 (defun gnus-summary-prev-group (&optional no-article)
9922 "Exit current newsgroup and then select previous unread newsgroup.
9923 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
9925 (gnus-summary-next-group no-article nil t))
9927 ;; Walking around summary lines.
9929 (defun gnus-summary-first-subject (&optional unread)
9930 "Go to the first unread subject.
9931 If UNREAD is non-nil, go to the first unread article.
9932 Returns the article selected or nil if there are no unread articles."
9937 ((null gnus-newsgroup-data)
9938 (gnus-message 3 "No articles in the group")
9940 ;; Pick the first article.
9942 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
9943 (gnus-data-number (car gnus-newsgroup-data)))
9944 ;; No unread articles.
9945 ((null gnus-newsgroup-unreads)
9946 (gnus-message 3 "No more unread articles")
9948 ;; Find the first unread article.
9950 (let ((data gnus-newsgroup-data))
9952 (not (gnus-data-unread-p (car data))))
9953 (setq data (cdr data)))
9956 (goto-char (gnus-data-pos (car data)))
9957 (gnus-data-number (car data)))))))
9958 (gnus-summary-position-point)))
9960 (defun gnus-summary-next-subject (n &optional unread dont-display)
9961 "Go to next N'th summary line.
9962 If N is negative, go to the previous N'th subject line.
9963 If UNREAD is non-nil, only unread articles are selected.
9964 The difference between N and the actual number of steps taken is
9967 (let ((backward (< n 0))
9971 (gnus-summary-find-prev unread)
9972 (gnus-summary-find-next unread)))
9974 (if (/= 0 n) (gnus-message 7 "No more%s articles"
9975 (if unread " unread" "")))
9976 (unless dont-display
9977 (gnus-summary-recenter)
9978 (gnus-summary-position-point))
9981 (defun gnus-summary-next-unread-subject (n)
9982 "Go to next N'th unread summary line."
9984 (gnus-summary-next-subject n t))
9986 (defun gnus-summary-prev-subject (n &optional unread)
9987 "Go to previous N'th summary line.
9988 If optional argument UNREAD is non-nil, only unread article is selected."
9990 (gnus-summary-next-subject (- n) unread))
9992 (defun gnus-summary-prev-unread-subject (n)
9993 "Go to previous N'th unread summary line."
9995 (gnus-summary-next-subject (- n) t))
9997 (defun gnus-summary-goto-subject (article &optional force silent)
9998 "Go the subject line of ARTICLE.
9999 If FORCE, also allow jumping to articles not currently shown."
10001 (data (gnus-data-find article)))
10002 ;; We read in the article if we have to.
10005 (gnus-summary-insert-subject article)
10006 (setq data (gnus-data-find article)))
10011 (gnus-message 3 "Can't find article %d" article))
10013 (goto-char (gnus-data-pos data))
10016 ;; Walking around summary lines with displaying articles.
10018 (defun gnus-summary-expand-window (&optional arg)
10019 "Make the summary buffer take up the entire Emacs frame.
10020 Given a prefix, will force an `article' buffer configuration."
10022 (gnus-set-global-variables)
10024 (gnus-configure-windows 'article 'force)
10025 (gnus-configure-windows 'summary 'force)))
10027 (defun gnus-summary-display-article (article &optional all-header)
10028 "Display ARTICLE in article buffer."
10029 (gnus-set-global-variables)
10033 (if gnus-summary-display-article-function
10034 (funcall gnus-summary-display-article-function article all-header)
10035 (gnus-article-prepare article all-header))
10036 (run-hooks 'gnus-select-article-hook)
10037 (gnus-summary-recenter)
10038 (gnus-summary-goto-subject article)
10039 (when gnus-use-trees
10040 (gnus-possibly-generate-tree article)
10041 (gnus-highlight-selected-tree article))
10042 ;; Successfully display article.
10043 (gnus-article-set-window-start
10044 (cdr (assq article gnus-newsgroup-bookmarks)))
10047 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10048 "Select the current article.
10049 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10050 non-nil, the article will be re-fetched even if it already present in
10051 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10053 (let ((article (or article (gnus-summary-article-number)))
10054 (all-headers (not (not all-headers))) ;Must be T or NIL.
10055 gnus-summary-display-article-function
10058 (gnus-summary-article-pseudo-p article)
10059 (error "This is a pseudo-article."))
10062 (set-buffer gnus-summary-buffer)
10063 (if (or (and gnus-single-article-buffer
10064 (or (null gnus-current-article)
10065 (null gnus-article-current)
10066 (null (get-buffer gnus-article-buffer))
10067 (not (eq article (cdr gnus-article-current)))
10068 (not (equal (car gnus-article-current)
10069 gnus-newsgroup-name))))
10070 (and (not gnus-single-article-buffer)
10071 (or (null gnus-current-article)
10072 (not (eq gnus-current-article article))))
10074 ;; The requested article is different from the current article.
10076 (gnus-summary-display-article article all-headers)
10077 (setq did article))
10078 (if (or all-headers gnus-show-all-headers)
10079 (gnus-article-show-all-headers))
10082 (gnus-article-set-window-start
10083 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10085 (defun gnus-summary-set-current-mark (&optional current-mark)
10086 "Obsolete function."
10089 (defun gnus-summary-next-article (&optional unread subject backward push)
10090 "Select the next article.
10091 If UNREAD, only unread articles are selected.
10092 If SUBJECT, only articles with SUBJECT are selected.
10093 If BACKWARD, the previous article is selected instead of the next."
10095 (gnus-set-global-variables)
10097 ;; Is there such an article?
10098 ((and (gnus-summary-search-forward unread subject backward)
10099 (or (gnus-summary-display-article (gnus-summary-article-number))
10100 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10101 (gnus-summary-position-point))
10102 ;; If not, we try the first unread, if that is wanted.
10104 gnus-auto-select-same
10105 (or (gnus-summary-first-unread-article)
10106 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10107 (gnus-summary-position-point)
10108 (gnus-message 6 "Wrapped"))
10109 ;; Try to get next/previous article not displayed in this group.
10110 ((and gnus-auto-extend-newsgroup
10111 (not unread) (not subject))
10112 (gnus-summary-goto-article
10113 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10115 ;; Go to next/previous group.
10117 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10118 (gnus-summary-jump-to-group gnus-newsgroup-name))
10119 (let ((cmd last-command-char)
10121 (if (eq gnus-keep-same-level 'best)
10122 (gnus-summary-best-group gnus-newsgroup-name)
10123 (gnus-summary-search-group backward gnus-keep-same-level))))
10124 ;; For some reason, the group window gets selected. We change
10126 (select-window (get-buffer-window (current-buffer)))
10127 ;; Select next unread newsgroup automagically.
10129 ((not gnus-auto-select-next)
10130 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10131 ((or (eq gnus-auto-select-next 'quietly)
10132 (and (eq gnus-auto-select-next 'slightly-quietly)
10134 (and (eq gnus-auto-select-next 'almost-quietly)
10135 (gnus-summary-last-article-p)))
10137 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10138 (gnus-summary-exit)
10139 (gnus-message 7 "No more%s articles (%s)..."
10140 (if unread " unread" "")
10141 (if group (concat "selecting " group)
10143 (gnus-summary-next-group nil group backward)))
10145 (gnus-summary-walk-group-buffer
10146 gnus-newsgroup-name cmd unread backward)))))))
10148 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10149 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10150 (?\C-p (gnus-group-prev-unread-group 1))))
10151 keve key group ended)
10153 (set-buffer gnus-group-buffer)
10154 (gnus-summary-jump-to-group from-group)
10156 (if (eq gnus-keep-same-level 'best)
10157 (gnus-summary-best-group gnus-newsgroup-name)
10158 (gnus-summary-search-group backward gnus-keep-same-level))))
10161 5 "No more%s articles%s" (if unread " unread" "")
10163 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10164 (format " (Type %s for %s [%s])"
10165 (single-key-description cmd) group
10166 (car (gnus-gethash group gnus-newsrc-hashtb)))
10167 (format " (Type %s to exit %s)"
10168 (single-key-description cmd)
10169 gnus-newsgroup-name)))
10170 ;; Confirm auto selection.
10171 (setq key (car (setq keve (gnus-read-event-char))))
10174 ((assq key keystrokes)
10175 (let ((obuf (current-buffer)))
10176 (switch-to-buffer gnus-group-buffer)
10178 (gnus-group-jump-to-group group))
10179 (eval (cadr (assq key keystrokes)))
10180 (setq group (gnus-group-group-name))
10181 (switch-to-buffer obuf))
10184 (if (or (not group)
10185 (gnus-ephemeral-group-p gnus-newsgroup-name))
10186 (gnus-summary-exit)
10187 (gnus-summary-next-group nil group backward)))
10189 (push (cdr keve) unread-command-events))))))
10191 (defun gnus-read-event-char ()
10192 "Get the next event."
10193 (let ((event (read-event)))
10194 (cons (and (numberp event) event) event)))
10196 (defun gnus-summary-next-unread-article ()
10197 "Select unread article after current one."
10199 (gnus-summary-next-article t (and gnus-auto-select-same
10200 (gnus-summary-article-subject))))
10202 (defun gnus-summary-prev-article (&optional unread subject)
10203 "Select the article after the current one.
10204 If UNREAD is non-nil, only unread articles are selected."
10206 (gnus-summary-next-article unread subject t))
10208 (defun gnus-summary-prev-unread-article ()
10209 "Select unred article before current one."
10211 (gnus-summary-prev-article t (and gnus-auto-select-same
10212 (gnus-summary-article-subject))))
10214 (defun gnus-summary-next-page (&optional lines circular)
10215 "Show next page of the selected article.
10216 If at the end of the current article, select the next article.
10217 LINES says how many lines should be scrolled up.
10219 If CIRCULAR is non-nil, go to the start of the article instead of
10220 selecting the next article when reaching the end of the current
10223 (setq gnus-summary-buffer (current-buffer))
10224 (gnus-set-global-variables)
10225 (let ((article (gnus-summary-article-number))
10227 (gnus-configure-windows 'article)
10228 (if (or (null gnus-current-article)
10229 (null gnus-article-current)
10230 (/= article (cdr gnus-article-current))
10231 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10232 ;; Selected subject is different from current article's.
10233 (gnus-summary-display-article article)
10234 (gnus-eval-in-buffer-window
10235 gnus-article-buffer
10236 (setq endp (gnus-article-next-page lines)))
10239 (gnus-summary-beginning-of-article))
10241 (gnus-message 3 "End of message"))
10243 (if (and (eq gnus-summary-goto-unread 'never)
10244 (not (gnus-summary-last-article-p article)))
10245 (gnus-summary-next-article)
10246 (gnus-summary-next-unread-article))))))
10247 (gnus-summary-recenter)
10248 (gnus-summary-position-point)))
10250 (defun gnus-summary-prev-page (&optional lines)
10251 "Show previous page of selected article.
10252 Argument LINES specifies lines to be scrolled down."
10254 (gnus-set-global-variables)
10255 (let ((article (gnus-summary-article-number)))
10256 (gnus-configure-windows 'article)
10257 (if (or (null gnus-current-article)
10258 (null gnus-article-current)
10259 (/= article (cdr gnus-article-current))
10260 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10261 ;; Selected subject is different from current article's.
10262 (gnus-summary-display-article article)
10263 (gnus-summary-recenter)
10264 (gnus-eval-in-buffer-window gnus-article-buffer
10265 (gnus-article-prev-page lines))))
10266 (gnus-summary-position-point))
10268 (defun gnus-summary-scroll-up (lines)
10269 "Scroll up (or down) one line current article.
10270 Argument LINES specifies lines to be scrolled up (or down if negative)."
10272 (gnus-set-global-variables)
10273 (gnus-configure-windows 'article)
10274 (gnus-summary-show-thread)
10275 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10276 (gnus-eval-in-buffer-window
10277 gnus-article-buffer
10279 (if (gnus-article-next-page lines)
10280 (gnus-message 3 "End of message")))
10282 (gnus-article-prev-page (- lines))))))
10283 (gnus-summary-recenter)
10284 (gnus-summary-position-point))
10286 (defun gnus-summary-next-same-subject ()
10287 "Select next article which has the same subject as current one."
10289 (gnus-set-global-variables)
10290 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10292 (defun gnus-summary-prev-same-subject ()
10293 "Select previous article which has the same subject as current one."
10295 (gnus-set-global-variables)
10296 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10298 (defun gnus-summary-next-unread-same-subject ()
10299 "Select next unread article which has the same subject as current one."
10301 (gnus-set-global-variables)
10302 (gnus-summary-next-article t (gnus-summary-article-subject)))
10304 (defun gnus-summary-prev-unread-same-subject ()
10305 "Select previous unread article which has the same subject as current one."
10307 (gnus-set-global-variables)
10308 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10310 (defun gnus-summary-first-unread-article ()
10311 "Select the first unread article.
10312 Return nil if there are no unread articles."
10314 (gnus-set-global-variables)
10316 (if (gnus-summary-first-subject t)
10318 (gnus-summary-show-thread)
10319 (gnus-summary-first-subject t)
10320 (gnus-summary-display-article (gnus-summary-article-number))))
10321 (gnus-summary-position-point)))
10323 (defun gnus-summary-best-unread-article ()
10324 "Select the unread article with the highest score."
10326 (gnus-set-global-variables)
10327 (let ((best -1000000)
10328 (data gnus-newsgroup-data)
10331 (and (gnus-data-unread-p (car data))
10333 (gnus-summary-article-score (gnus-data-number (car data))))
10336 article (gnus-data-number (car data))))
10337 (setq data (cdr data)))
10339 (gnus-summary-goto-article article)
10340 (error "No unread articles"))
10341 (gnus-summary-position-point)))
10343 (defun gnus-summary-last-subject ()
10344 "Go to the last displayed subject line in the group."
10345 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10347 (gnus-summary-goto-subject article))))
10349 (defun gnus-summary-goto-article (article &optional all-headers force)
10350 "Fetch ARTICLE and display it if it exists.
10351 If ALL-HEADERS is non-nil, no header lines are hidden."
10357 (mapcar (lambda (number) (list (int-to-string number)))
10358 gnus-newsgroup-limit)))
10362 (if (gnus-summary-goto-subject article force)
10363 (gnus-summary-display-article article all-headers)
10364 (gnus-message 4 "Couldn't go to article %s" article) nil)
10365 (gnus-summary-position-point)))
10367 (defun gnus-summary-goto-last-article ()
10368 "Go to the previously read article."
10371 (and gnus-last-article
10372 (gnus-summary-goto-article gnus-last-article))
10373 (gnus-summary-position-point)))
10375 (defun gnus-summary-pop-article (number)
10376 "Pop one article off the history and go to the previous.
10377 NUMBER articles will be popped off."
10380 (setq gnus-newsgroup-history
10381 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10383 (gnus-summary-goto-article (car to))
10384 (error "Article history empty")))
10385 (gnus-summary-position-point))
10387 ;; Summary commands and functions for limiting the summary buffer.
10389 (defun gnus-summary-limit-to-articles (n)
10390 "Limit the summary buffer to the next N articles.
10391 If not given a prefix, use the process marked articles instead."
10393 (gnus-set-global-variables)
10395 (let ((articles (gnus-summary-work-articles n)))
10396 (setq gnus-newsgroup-processable nil)
10397 (gnus-summary-limit articles))
10398 (gnus-summary-position-point)))
10400 (defun gnus-summary-pop-limit (&optional total)
10401 "Restore the previous limit.
10402 If given a prefix, remove all limits."
10404 (gnus-set-global-variables)
10406 (setq gnus-newsgroup-limits
10407 (list (mapcar (lambda (h) (mail-header-number h))
10408 gnus-newsgroup-headers))))
10409 (unless gnus-newsgroup-limits
10410 (error "No limit to pop"))
10412 (gnus-summary-limit nil 'pop)
10413 (gnus-summary-position-point)))
10415 (defun gnus-summary-limit-to-subject (subject &optional header)
10416 "Limit the summary buffer to articles that have subjects that match a regexp."
10417 (interactive "sRegexp: ")
10419 (setq header "subject"))
10420 (when (not (equal "" subject))
10422 (let ((articles (gnus-summary-find-matching
10423 (or header "subject") subject 'all)))
10424 (or articles (error "Found no matches for \"%s\"" subject))
10425 (gnus-summary-limit articles))
10426 (gnus-summary-position-point))))
10428 (defun gnus-summary-limit-to-author (from)
10429 "Limit the summary buffer to articles that have authors that match a regexp."
10430 (interactive "sRegexp: ")
10431 (gnus-summary-limit-to-subject from "from"))
10433 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10435 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10437 (defun gnus-summary-limit-to-unread (&optional all)
10438 "Limit the summary buffer to articles that are not marked as read.
10439 If ALL is non-nil, limit strictly to unread articles."
10442 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10443 (gnus-summary-limit-to-marks
10444 ;; Concat all the marks that say that an article is read and have
10446 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10447 gnus-killed-mark gnus-kill-file-mark
10448 gnus-low-score-mark gnus-expirable-mark
10449 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10452 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10453 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10455 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10456 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10457 If REVERSE, limit the summary buffer to articles that are not marked
10458 with MARKS. MARKS can either be a string of marks or a list of marks.
10459 Returns how many articles were removed."
10460 (interactive "sMarks: ")
10461 (gnus-set-global-variables)
10463 (let ((data gnus-newsgroup-data)
10464 (marks (if (listp marks) marks
10465 (append marks nil))) ; Transform to list.
10468 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10469 (memq (gnus-data-mark (car data)) marks))
10470 (setq articles (cons (gnus-data-number (car data)) articles)))
10471 (setq data (cdr data)))
10472 (gnus-summary-limit articles))
10473 (gnus-summary-position-point)))
10475 (defun gnus-summary-limit-to-score (&optional score)
10476 "Limit to articles with score at or above SCORE."
10478 (gnus-set-global-variables)
10479 (setq score (if score
10480 (prefix-numeric-value score)
10481 (or gnus-summary-default-score 0)))
10482 (let ((data gnus-newsgroup-data)
10485 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10487 (push (gnus-data-number (car data)) articles))
10488 (setq data (cdr data)))
10490 (gnus-summary-limit articles)
10491 (gnus-summary-position-point))))
10493 (defun gnus-summary-limit-include-dormant ()
10494 "Display all the hidden articles that are marked as dormant."
10496 (gnus-set-global-variables)
10497 (or gnus-newsgroup-dormant
10498 (error "There are no dormant articles in this group"))
10500 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10501 (gnus-summary-position-point)))
10503 (defun gnus-summary-limit-exclude-dormant ()
10504 "Hide all dormant articles."
10506 (gnus-set-global-variables)
10508 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10509 (gnus-summary-position-point)))
10511 (defun gnus-summary-limit-exclude-childless-dormant ()
10512 "Hide all dormant articles that have no children."
10514 (gnus-set-global-variables)
10515 (let ((data (gnus-data-list t))
10516 articles d children)
10517 ;; Find all articles that are either not dormant or have
10519 (while (setq d (pop data))
10520 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10521 (and (setq children
10522 (gnus-article-children (gnus-data-number d)))
10525 (when (memq (car children) articles)
10530 (push (gnus-data-number d) articles)))
10531 ;; Do the limiting.
10533 (gnus-summary-limit articles)
10534 (gnus-summary-position-point))))
10536 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10537 "Mark all unread excluded articles as read.
10538 If ALL, mark even excluded ticked and dormants as read."
10540 (let ((articles (gnus-sorted-complement
10542 (mapcar (lambda (h) (mail-header-number h))
10543 gnus-newsgroup-headers)
10545 (sort gnus-newsgroup-limit '<)))
10547 (setq gnus-newsgroup-unreads nil)
10549 (setq gnus-newsgroup-dormant nil
10550 gnus-newsgroup-marked nil
10551 gnus-newsgroup-reads
10553 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10554 gnus-newsgroup-reads))
10555 (while (setq article (pop articles))
10556 (unless (or (memq article gnus-newsgroup-dormant)
10557 (memq article gnus-newsgroup-marked))
10558 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10560 (defun gnus-summary-limit (articles &optional pop)
10562 ;; We pop the previous limit off the stack and use that.
10563 (setq articles (car gnus-newsgroup-limits)
10564 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10565 ;; We use the new limit, so we push the old limit on the stack.
10566 (setq gnus-newsgroup-limits
10567 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10569 (setq gnus-newsgroup-limit articles)
10570 (let ((total (length gnus-newsgroup-data))
10571 (data (gnus-data-find-list (gnus-summary-article-number)))
10573 ;; This will do all the work of generating the new summary buffer
10574 ;; according to the new limit.
10575 (gnus-summary-prepare)
10576 ;; Hide any threads, possibly.
10577 (and gnus-show-threads
10578 gnus-thread-hide-subtree
10579 (gnus-summary-hide-all-threads))
10580 ;; Try to return to the article you were at, or one in the
10583 ;; We try to find some article after the current one.
10585 (and (gnus-summary-goto-subject
10586 (gnus-data-number (car data)) nil t)
10589 (setq data (cdr data))))
10591 ;; If there is no data, that means that we were after the last
10592 ;; article. The same goes when we can't find any articles
10593 ;; after the current one.
10595 (goto-char (point-max))
10596 (gnus-summary-find-prev)))
10597 ;; We return how many articles were removed from the summary
10598 ;; buffer as a result of the new limit.
10599 (- total (length gnus-newsgroup-data))))
10601 (defsubst gnus-cut-thread (thread)
10602 "Go forwards in the thread until we find an article that we want to display."
10603 (when (eq gnus-fetch-old-headers 'some)
10604 ;; Deal with old-fetched headers.
10606 (memq (mail-header-number (car thread))
10607 gnus-newsgroup-ancient)
10608 (<= (length (cdr thread)) 1))
10609 (setq thread (cadr thread))))
10610 ;; Deal with sparse threads.
10611 (when (or (eq gnus-build-sparse-threads 'some)
10612 (eq gnus-build-sparse-threads 'more))
10614 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10615 (= (length (cdr thread)) 1))
10616 (setq thread (cadr thread))))
10619 (defun gnus-cut-threads (threads)
10620 "Cut off all uninteresting articles from the beginning of threads."
10621 (when (or (eq gnus-fetch-old-headers 'some)
10622 (eq gnus-build-sparse-threads 'some)
10623 (eq gnus-build-sparse-threads 'more))
10624 (let ((th threads))
10626 (setcar th (gnus-cut-thread (car th)))
10627 (setq th (cdr th)))))
10628 ;; Remove nixed out threads.
10629 (delq nil threads))
10631 (defun gnus-summary-initial-limit (&optional show-if-empty)
10632 "Figure out what the initial limit is supposed to be on group entry.
10633 This entails weeding out unwanted dormants, low-scored articles,
10634 fetch-old-headers verbiage, and so on."
10635 ;; Most groups have nothing to remove.
10636 (if (or gnus-inhibit-limiting
10637 (and (null gnus-newsgroup-dormant)
10638 (not (eq gnus-fetch-old-headers 'some))
10639 (null gnus-summary-expunge-below)
10640 (not (eq gnus-build-sparse-threads 'some))
10641 (not (eq gnus-build-sparse-threads 'more))
10642 (null gnus-thread-expunge-below)
10643 (not gnus-use-nocem)))
10645 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10646 (setq gnus-newsgroup-limit nil)
10649 (unless (car (symbol-value node))
10650 ;; These threads have no parents -- they are roots.
10651 (let ((nodes (cdr (symbol-value node)))
10654 (if (and gnus-thread-expunge-below
10655 (< (gnus-thread-total-score (car nodes))
10656 gnus-thread-expunge-below))
10657 (gnus-expunge-thread (pop nodes))
10658 (setq thread (pop nodes))
10659 (gnus-summary-limit-children thread))))))
10660 gnus-newsgroup-dependencies)
10661 ;; If this limitation resulted in an empty group, we might
10662 ;; pop the previous limit and use it instead.
10663 (when (and (not gnus-newsgroup-limit)
10665 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10666 gnus-newsgroup-limit))
10668 (defun gnus-summary-limit-children (thread)
10669 "Return 1 if this subthread is visible and 0 if it is not."
10670 ;; First we get the number of visible children to this thread. This
10671 ;; is done by recursing down the thread using this function, so this
10672 ;; will really go down to a leaf article first, before slowly
10673 ;; working its way up towards the root.
10677 (apply '+ (mapcar 'gnus-summary-limit-children
10680 (number (mail-header-number (car thread)))
10683 ;; If this article is dormant and has absolutely no visible
10684 ;; children, then this article isn't visible.
10685 (and (memq number gnus-newsgroup-dormant)
10687 ;; If this is a "fetch-old-headered" and there is only one
10688 ;; visible child (or less), then we don't want this article.
10689 (and (eq gnus-fetch-old-headers 'some)
10690 (memq number gnus-newsgroup-ancient)
10692 ;; If this is a sparsely inserted article with no children,
10693 ;; we don't want it.
10694 (and (eq gnus-build-sparse-threads 'some)
10695 (memq number gnus-newsgroup-sparse)
10697 ;; If we use expunging, and this article is really
10698 ;; low-scored, then we don't want this article.
10699 (when (and gnus-summary-expunge-below
10701 (or (cdr (assq number gnus-newsgroup-scored))
10702 gnus-summary-default-score))
10703 gnus-summary-expunge-below))
10704 ;; We increase the expunge-tally here, but that has
10705 ;; nothing to do with the limits, really.
10706 (incf gnus-newsgroup-expunged-tally)
10707 ;; We also mark as read here, if that's wanted.
10708 (when (and gnus-summary-mark-below
10709 (< score gnus-summary-mark-below))
10710 (setq gnus-newsgroup-unreads
10711 (delq number gnus-newsgroup-unreads))
10712 (if gnus-newsgroup-auto-expire
10713 (push number gnus-newsgroup-expirable)
10714 (push (cons number gnus-low-score-mark)
10715 gnus-newsgroup-reads)))
10717 (and gnus-use-nocem
10718 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
10719 ;; Nope, invisible article.
10721 ;; Ok, this article is to be visible, so we add it to the limit
10723 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
10726 (defun gnus-expunge-thread (thread)
10727 "Mark all articles in THREAD as read."
10728 (let* ((number (mail-header-number (car thread))))
10729 (incf gnus-newsgroup-expunged-tally)
10730 ;; We also mark as read here, if that's wanted.
10731 (setq gnus-newsgroup-unreads
10732 (delq number gnus-newsgroup-unreads))
10733 (if gnus-newsgroup-auto-expire
10734 (push number gnus-newsgroup-expirable)
10735 (push (cons number gnus-low-score-mark)
10736 gnus-newsgroup-reads)))
10737 ;; Go recursively through all subthreads.
10738 (mapcar 'gnus-expunge-thread (cdr thread)))
10740 ;; Summary article oriented commands
10742 (defun gnus-summary-refer-parent-article (n)
10743 "Refer parent article N times.
10744 The difference between N and the number of articles fetched is returned."
10746 (gnus-set-global-variables)
10750 (let* ((header (gnus-summary-article-header))
10752 ;; If we try to find the parent of the currently
10753 ;; displayed article, then we take a look at the actual
10754 ;; References header, since this is slightly more
10755 ;; reliable than the References field we got from the
10757 (if (and (eq (mail-header-number header)
10758 (cdr gnus-article-current))
10759 (equal gnus-newsgroup-name
10760 (car gnus-article-current)))
10762 (set-buffer gnus-original-article-buffer)
10763 (nnheader-narrow-to-headers)
10765 (mail-fetch-field "references")
10767 ;; It's not the current article, so we take a bet on
10768 ;; the value we got from the server.
10769 (mail-header-references header))))
10770 (if (setq ref (or ref (mail-header-references header)))
10771 (or (gnus-summary-refer-article (gnus-parent-id ref))
10772 (gnus-message 1 "Couldn't find parent"))
10773 (gnus-message 1 "No references in article %d"
10774 (gnus-summary-article-number))
10777 (gnus-summary-position-point)
10780 (defun gnus-summary-refer-references ()
10781 "Fetch all articles mentioned in the References header.
10782 Return how many articles were fetched."
10784 (gnus-set-global-variables)
10785 (let ((ref (mail-header-references (gnus-summary-article-header)))
10786 (current (gnus-summary-article-number))
10788 ;; For each Message-ID in the References header...
10789 (while (string-match "<[^>]*>" ref)
10791 ;; ... fetch that article.
10792 (gnus-summary-refer-article
10793 (prog1 (match-string 0 ref)
10794 (setq ref (substring ref (match-end 0))))))
10795 (gnus-summary-goto-subject current)
10796 (gnus-summary-position-point)
10799 (defun gnus-summary-refer-article (message-id)
10800 "Fetch an article specified by MESSAGE-ID."
10801 (interactive "sMessage-ID: ")
10802 (when (and (stringp message-id)
10803 (not (zerop (length message-id))))
10804 ;; Construct the correct Message-ID if necessary.
10805 ;; Suggested by tale@pawl.rpi.edu.
10806 (unless (string-match "^<" message-id)
10807 (setq message-id (concat "<" message-id)))
10808 (unless (string-match ">$" message-id)
10809 (setq message-id (concat message-id ">")))
10810 (let ((header (car (gnus-gethash message-id
10811 gnus-newsgroup-dependencies))))
10813 ;; The article is present in the buffer, to we just go to it.
10814 (gnus-summary-goto-article (mail-header-number header) nil t)
10815 ;; We fetch the article
10816 (let ((gnus-override-method gnus-refer-article-method)
10818 ;; Start the special refer-article method, if necessary.
10819 (when gnus-refer-article-method
10820 (gnus-check-server gnus-refer-article-method))
10821 ;; Fetch the header, and display the article.
10822 (if (setq number (gnus-summary-insert-subject message-id))
10823 (gnus-summary-select-article nil nil nil number)
10824 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
10826 (defun gnus-summary-enter-digest-group (&optional force)
10827 "Enter a digest group based on the current article."
10829 (gnus-set-global-variables)
10830 (gnus-summary-select-article)
10831 (let ((name (format "%s-%d"
10832 (gnus-group-prefixed-name
10833 gnus-newsgroup-name (list 'nndoc ""))
10834 gnus-current-article))
10835 (ogroup gnus-newsgroup-name)
10836 (case-fold-search t)
10837 (buf (current-buffer))
10840 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
10841 (insert-buffer-substring gnus-original-article-buffer)
10843 (goto-char (point-min))
10844 (or (search-forward "\n\n" nil t) (point)))
10845 (goto-char (point-min))
10846 (delete-matching-lines "^\\(Path\\):\\|^From ")
10849 (if (gnus-group-read-ephemeral-group
10850 name `(nndoc ,name (nndoc-address
10852 (nndoc-article-type ,(if force 'digest 'guess))) t)
10853 ;; Make all postings to this group go to the parent group.
10854 (nconc (gnus-info-params (gnus-get-info name))
10855 (list (cons 'to-group ogroup)))
10856 ;; Couldn't select this doc group.
10857 (switch-to-buffer buf)
10858 (gnus-set-global-variables)
10859 (gnus-configure-windows 'summary)
10860 (gnus-message 3 "Article couldn't be entered?"))
10861 (kill-buffer dig))))
10863 (defun gnus-summary-isearch-article (&optional regexp-p)
10864 "Do incremental search forward on the current article.
10865 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
10867 (gnus-set-global-variables)
10868 (gnus-summary-select-article)
10869 (gnus-configure-windows 'article)
10870 (gnus-eval-in-buffer-window
10871 gnus-article-buffer
10872 (goto-char (point-min))
10873 (isearch-forward regexp-p)))
10875 (defun gnus-summary-search-article-forward (regexp &optional backward)
10876 "Search for an article containing REGEXP forward.
10877 If BACKWARD, search backward instead."
10880 (format "Search article %s (regexp%s): "
10881 (if current-prefix-arg "backward" "forward")
10882 (if gnus-last-search-regexp
10883 (concat ", default " gnus-last-search-regexp)
10885 current-prefix-arg))
10886 (gnus-set-global-variables)
10887 (if (string-equal regexp "")
10888 (setq regexp (or gnus-last-search-regexp ""))
10889 (setq gnus-last-search-regexp regexp))
10890 (if (gnus-summary-search-article regexp backward)
10891 (gnus-article-set-window-start
10892 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
10893 (error "Search failed: \"%s\"" regexp)))
10895 (defun gnus-summary-search-article-backward (regexp)
10896 "Search for an article containing REGEXP backward."
10899 (format "Search article backward (regexp%s): "
10900 (if gnus-last-search-regexp
10901 (concat ", default " gnus-last-search-regexp)
10903 (gnus-summary-search-article-forward regexp 'backward))
10905 (defun gnus-summary-search-article (regexp &optional backward)
10906 "Search for an article containing REGEXP.
10907 Optional argument BACKWARD means do search for backward.
10908 gnus-select-article-hook is not called during the search."
10909 (let ((gnus-select-article-hook nil) ;Disable hook.
10910 (gnus-mark-article-hook nil) ;Inhibit marking as read.
10913 (function re-search-backward) (function re-search-forward)))
10916 ;; Hidden thread subtrees must be searched for ,too.
10917 (gnus-summary-show-all-threads)
10918 ;; First of all, search current article.
10919 ;; We don't want to read article again from NNTP server nor reset
10921 (gnus-summary-select-article)
10922 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10923 (setq last gnus-current-article)
10924 (gnus-eval-in-buffer-window
10925 gnus-article-buffer
10928 ;; Begin search from current point.
10929 (setq found (funcall re-search regexp nil t))))
10930 ;; Then search next articles.
10931 (while (and (not found)
10932 (gnus-summary-display-article
10933 (if backward (gnus-summary-find-prev)
10934 (gnus-summary-find-next))))
10935 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10936 (gnus-eval-in-buffer-window
10937 gnus-article-buffer
10940 (goto-char (if backward (point-max) (point-min)))
10941 (setq found (funcall re-search regexp nil t)))))
10943 ;; Adjust article pointer.
10944 (or (eq last gnus-current-article)
10945 (setq gnus-last-article last))
10946 ;; Return T if found such article.
10949 (defun gnus-summary-find-matching (header regexp &optional backward unread
10951 "Return a list of all articles that match REGEXP on HEADER.
10952 The search stars on the current article and goes forwards unless
10953 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
10954 If UNREAD is non-nil, only unread articles will
10955 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
10956 in the comparisons."
10957 (let ((data (if (eq backward 'all) gnus-newsgroup-data
10958 (gnus-data-find-list
10959 (gnus-summary-article-number) (gnus-data-list backward))))
10960 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
10961 (case-fold-search (not not-case-fold))
10963 (or (fboundp (intern (concat "mail-header-" header)))
10964 (error "%s is not a valid header" header))
10966 (setq d (car data))
10967 (and (or (not unread) ; We want all articles...
10968 (gnus-data-unread-p d)) ; Or just unreads.
10969 (vectorp (gnus-data-header d)) ; It's not a pseudo.
10970 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
10971 (setq articles (cons (gnus-data-number d) articles))) ; Success!
10972 (setq data (cdr data)))
10973 (nreverse articles)))
10975 (defun gnus-summary-execute-command (header regexp command &optional backward)
10976 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
10977 If HEADER is an empty string (or nil), the match is done on the entire
10978 article. If BACKWARD (the prefix) is non-nil, search backward instead."
10980 (list (let ((completion-ignore-case t))
10983 (mapcar (lambda (string) (list string))
10984 '("Number" "Subject" "From" "Lines" "Date"
10985 "Message-ID" "Xref" "References" "Body"))
10986 nil 'require-match))
10987 (read-string "Regexp: ")
10988 (read-key-sequence "Command: ")
10989 current-prefix-arg))
10990 (when (equal header "Body")
10992 (gnus-set-global-variables)
10993 ;; Hidden thread subtrees must be searched as well.
10994 (gnus-summary-show-all-threads)
10995 ;; We don't want to change current point nor window configuration.
10997 (save-window-excursion
10998 (gnus-message 6 "Executing %s..." (key-description command))
10999 ;; We'd like to execute COMMAND interactively so as to give arguments.
11000 (gnus-execute header regexp
11001 `(lambda () (call-interactively ',(key-binding command)))
11003 (gnus-message 6 "Executing %s...done" (key-description command)))))
11005 (defun gnus-summary-beginning-of-article ()
11006 "Scroll the article back to the beginning."
11008 (gnus-set-global-variables)
11009 (gnus-summary-select-article)
11010 (gnus-configure-windows 'article)
11011 (gnus-eval-in-buffer-window
11012 gnus-article-buffer
11014 (goto-char (point-min))
11015 (and gnus-break-pages (gnus-narrow-to-page))))
11017 (defun gnus-summary-end-of-article ()
11018 "Scroll to the end of the article."
11020 (gnus-set-global-variables)
11021 (gnus-summary-select-article)
11022 (gnus-configure-windows 'article)
11023 (gnus-eval-in-buffer-window
11024 gnus-article-buffer
11026 (goto-char (point-max))
11028 (and gnus-break-pages (gnus-narrow-to-page))))
11030 (defun gnus-summary-show-article (&optional arg)
11031 "Force re-fetching of the current article.
11032 If ARG (the prefix) is non-nil, show the raw article without any
11033 article massaging functions being run."
11035 (gnus-set-global-variables)
11037 ;; Select the article the normal way.
11038 (gnus-summary-select-article nil 'force)
11039 ;; Bind the article treatment functions to nil.
11040 (let ((gnus-have-all-headers t)
11041 gnus-article-display-hook
11042 gnus-article-prepare-hook
11044 (gnus-summary-select-article nil 'force)))
11045 ; (gnus-configure-windows 'article)
11046 (gnus-summary-position-point))
11048 (defun gnus-summary-verbose-headers (&optional arg)
11049 "Toggle permanent full header display.
11050 If ARG is a positive number, turn header display on.
11051 If ARG is a negative number, turn header display off."
11053 (gnus-set-global-variables)
11054 (gnus-summary-toggle-header arg)
11055 (setq gnus-show-all-headers
11056 (cond ((or (not (numberp arg))
11058 (not gnus-show-all-headers))
11062 (defun gnus-summary-toggle-header (&optional arg)
11063 "Show the headers if they are hidden, or hide them if they are shown.
11064 If ARG is a positive number, show the entire header.
11065 If ARG is a negative number, hide the unwanted header lines."
11067 (gnus-set-global-variables)
11069 (set-buffer gnus-article-buffer)
11070 (let* ((buffer-read-only nil)
11071 (inhibit-point-motion-hooks t)
11072 (hidden (text-property-any
11073 (goto-char (point-min)) (search-forward "\n\n")
11076 (goto-char (point-min))
11077 (when (search-forward "\n\n" nil t)
11078 (delete-region (point-min) (1- (point))))
11079 (goto-char (point-min))
11081 (set-buffer gnus-original-article-buffer)
11082 (goto-char (point-min))
11083 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11084 (insert-buffer-substring gnus-original-article-buffer 1 e)
11085 (let ((gnus-inhibit-hiding t))
11086 (run-hooks 'gnus-article-display-hook))
11087 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11088 (gnus-article-hide-headers)))))
11090 (defun gnus-summary-show-all-headers ()
11091 "Make all header lines visible."
11093 (gnus-set-global-variables)
11094 (gnus-article-show-all-headers))
11096 (defun gnus-summary-toggle-mime (&optional arg)
11097 "Toggle MIME processing.
11098 If ARG is a positive number, turn MIME processing on."
11100 (gnus-set-global-variables)
11101 (setq gnus-show-mime
11102 (if (null arg) (not gnus-show-mime)
11103 (> (prefix-numeric-value arg) 0)))
11104 (gnus-summary-select-article t 'force))
11106 (defun gnus-summary-caesar-message (&optional arg)
11107 "Caesar rotate the current article by 13.
11108 The numerical prefix specifies how manu places to rotate each letter
11111 (gnus-set-global-variables)
11112 (gnus-summary-select-article)
11113 (let ((mail-header-separator ""))
11114 (gnus-eval-in-buffer-window
11115 gnus-article-buffer
11118 (let ((start (window-start)))
11119 (news-caesar-buffer-body arg)
11120 (set-window-start (get-buffer-window (current-buffer)) start))))))
11122 (defun gnus-summary-stop-page-breaking ()
11123 "Stop page breaking in the current article."
11125 (gnus-set-global-variables)
11126 (gnus-summary-select-article)
11127 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
11129 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11130 "Move the current article to a different newsgroup.
11131 If N is a positive number, move the N next articles.
11132 If N is a negative number, move the N previous articles.
11133 If N is nil and any articles have been marked with the process mark,
11134 move those articles instead.
11135 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11136 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
11137 re-spool using this method.
11139 For this function to work, both the current newsgroup and the
11140 newsgroup that you want to move to have to support the `request-move'
11141 and `request-accept' functions."
11143 (unless action (setq action 'move))
11144 (gnus-set-global-variables)
11145 ;; Check whether the source group supports the required functions.
11146 (cond ((and (eq action 'move)
11147 (not (gnus-check-backend-function
11148 'request-move-article gnus-newsgroup-name)))
11149 (error "The current group does not support article moving"))
11150 ((and (eq action 'crosspost)
11151 (not (gnus-check-backend-function
11152 'request-replace-article gnus-newsgroup-name)))
11153 (error "The current group does not support article editing")))
11154 (let ((articles (gnus-summary-work-articles n))
11155 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11156 (names '((move "move" "Moving")
11157 (copy "copy" "Copying")
11158 (crosspost "crosspost" "Crossposting")))
11159 (copy-buf (save-excursion
11160 (nnheader-set-temp-buffer " *copy article*")))
11161 art-group to-method new-xref article to-groups)
11162 (unless (assq action names)
11163 (error "Unknown action %s" action))
11164 ;; Read the newsgroup name.
11165 (when (and (not to-newsgroup)
11166 (not select-method))
11168 (gnus-read-move-group-name
11169 (cadr (assq action names))
11170 gnus-current-move-group articles prefix))
11171 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11172 (setq to-method (if select-method (list select-method "")
11173 (gnus-find-method-for-group to-newsgroup)))
11174 ;;(when (equal to-newsgroup gnus-newsgroup-name)
11175 ;;(error "Can't %s to the same group you're already in" action))
11176 ;; Check the method we are to move this article to...
11177 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11178 (error "%s does not support article copying" (car to-method)))
11179 (or (gnus-check-server to-method)
11180 (error "Can't open server %s" (car to-method)))
11181 (gnus-message 6 "%s to %s: %s..."
11182 (caddr (assq action names))
11183 (or select-method to-newsgroup) articles)
11185 (setq article (pop articles))
11189 ;; Move the article.
11191 (gnus-request-move-article
11192 article ; Article to move
11193 gnus-newsgroup-name ; From newsgrouo
11194 (nth 1 (gnus-find-method-for-group
11195 gnus-newsgroup-name)) ; Server
11196 (list 'gnus-request-accept-article
11198 (list 'quote select-method)
11200 (not articles)) ; Accept form
11201 (not articles))) ; Only save nov last time
11202 ;; Copy the article.
11205 (set-buffer copy-buf)
11206 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11207 (gnus-request-accept-article
11208 (if select-method select-method to-newsgroup)
11210 ;; Crosspost the article.
11211 ((eq action 'crosspost)
11212 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11213 (setq new-xref (concat gnus-newsgroup-name ":" article))
11214 (if (and xref (not (string= xref "")))
11216 (when (string-match "^Xref: " xref)
11217 (setq xref (substring xref (match-end 0))))
11218 (setq new-xref (concat xref " " new-xref)))
11219 (setq new-xref (concat (system-name) " " new-xref)))
11221 (set-buffer copy-buf)
11222 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11223 (nnheader-replace-header "xref" new-xref)
11224 (gnus-request-accept-article
11225 (if select-method select-method to-newsgroup)
11226 (not articles)))))))
11227 (if (not art-group)
11228 (gnus-message 1 "Couldn't %s article %s"
11229 (cadr (assq action names)) article)
11232 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11234 (gnus-group-prefixed-name
11236 (if select-method (list select-method "")
11237 (gnus-find-method-for-group to-newsgroup)))
11238 gnus-newsrc-hashtb)))
11239 (info (nth 2 entry))
11240 (to-group (gnus-info-group info)))
11241 ;; Update the group that has been moved to.
11243 (memq action '(move copy)))
11244 (unless (member to-group to-groups)
11245 (push to-group to-groups))
11247 (unless (memq article gnus-newsgroup-unreads)
11248 (gnus-info-set-read
11249 info (gnus-add-to-range (gnus-info-read info)
11250 (list (cdr art-group)))))
11252 ;; Copy any marks over to the new group.
11253 (let ((marks gnus-article-mark-lists)
11254 (to-article (cdr art-group)))
11256 ;; See whether the article is to be put in the cache.
11257 (when gnus-use-cache
11258 (gnus-cache-possibly-enter-article
11259 to-group to-article
11260 (let ((header (copy-sequence
11261 (gnus-summary-article-header article))))
11262 (mail-header-set-number header to-article)
11264 (memq article gnus-newsgroup-marked)
11265 (memq article gnus-newsgroup-dormant)
11266 (memq article gnus-newsgroup-unreads)))
11269 (when (memq article (symbol-value
11270 (intern (format "gnus-newsgroup-%s"
11272 ;; If the other group is the same as this group,
11273 ;; then we have to add the mark to the list.
11274 (when (equal to-group gnus-newsgroup-name)
11275 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11278 (intern (format "gnus-newsgroup-%s"
11280 ;; Copy mark to other group.
11281 (gnus-add-marked-articles
11282 to-group (cdar marks) (list to-article) info))
11283 (setq marks (cdr marks)))))
11285 ;; Update the Xref header in this article to point to
11286 ;; the new crossposted article we have just created.
11287 (when (eq action 'crosspost)
11289 (set-buffer copy-buf)
11290 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11291 (nnheader-replace-header
11292 "xref" (concat new-xref " " (gnus-group-prefixed-name
11293 (car art-group) to-method)
11294 ":" (cdr art-group)))
11295 (gnus-request-replace-article
11296 article gnus-newsgroup-name (current-buffer)))))
11298 (gnus-summary-goto-subject article)
11299 (when (eq action 'move)
11300 (gnus-summary-mark-article article gnus-canceled-mark)))
11301 (gnus-summary-remove-process-mark article))
11302 ;; Re-activate all groups that have been moved to.
11304 (gnus-activate-group (pop to-groups)))
11306 (gnus-kill-buffer copy-buf)
11307 (gnus-summary-position-point)
11308 (gnus-set-mode-line 'summary)))
11310 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11311 "Move the current article to a different newsgroup.
11312 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11313 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
11314 re-spool using this method."
11316 (gnus-summary-move-article n nil select-method 'copy))
11318 (defun gnus-summary-crosspost-article (&optional n)
11319 "Crosspost the current article to some other group."
11321 (gnus-summary-move-article n nil nil 'crosspost))
11323 (defun gnus-summary-respool-article (&optional n respool-method)
11324 "Respool the current article.
11325 The article will be squeezed through the mail spooling process again,
11326 which means that it will be put in some mail newsgroup or other
11327 depending on `nnmail-split-methods'.
11328 If N is a positive number, respool the N next articles.
11329 If N is a negative number, respool the N previous articles.
11330 If N is nil and any articles have been marked with the process mark,
11331 respool those articles instead.
11333 Respooling can be done both from mail groups and \"real\" newsgroups.
11334 In the former case, the articles in question will be moved from the
11335 current group into whatever groups they are destined to. In the
11336 latter case, they will be copied into the relevant groups."
11338 (gnus-set-global-variables)
11339 (let ((respool-methods (gnus-methods-using 'respool))
11341 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
11342 (unless respool-method
11343 (setq respool-method
11345 "What method do you want to use when respooling? "
11346 respool-methods nil t (cons methname 0))))
11347 (unless (string= respool-method "")
11348 (if (assoc (symbol-name
11349 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11351 (gnus-summary-move-article n nil (intern respool-method))
11352 (gnus-summary-copy-article n nil (intern respool-method))))))
11354 (defun gnus-summary-import-article (file)
11355 "Import a random file into a mail newsgroup."
11356 (interactive "fImport file: ")
11357 (gnus-set-global-variables)
11358 (let ((group gnus-newsgroup-name)
11359 (now (current-time))
11361 (or (gnus-check-backend-function 'request-accept-article group)
11362 (error "%s does not support article importing" group))
11363 (or (file-readable-p file)
11364 (not (file-regular-p file))
11365 (error "Can't read %s" file))
11367 (set-buffer (get-buffer-create " *import file*"))
11368 (buffer-disable-undo (current-buffer))
11370 (insert-file-contents file)
11371 (goto-char (point-min))
11372 (unless (nnheader-article-p)
11373 ;; This doesn't look like an article, so we fudge some headers.
11374 (setq atts (file-attributes file)
11375 lines (count-lines (point-min) (point-max)))
11376 (insert "From: " (read-string "From: ") "\n"
11377 "Subject: " (read-string "Subject: ") "\n"
11378 "Date: " (timezone-make-date-arpa-standard
11379 (current-time-string (nth 5 atts))
11380 (current-time-zone now)
11381 (current-time-zone now)) "\n"
11382 "Message-ID: " (gnus-inews-message-id) "\n"
11383 "Lines: " (int-to-string lines) "\n"
11384 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11385 (gnus-request-accept-article group t)
11386 (kill-buffer (current-buffer)))))
11388 (defun gnus-summary-expire-articles ()
11389 "Expire all articles that are marked as expirable in the current group."
11391 (gnus-set-global-variables)
11392 (when (gnus-check-backend-function
11393 'request-expire-articles gnus-newsgroup-name)
11394 ;; This backend supports expiry.
11395 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11396 (expirable (if total
11397 (gnus-list-of-read-articles gnus-newsgroup-name)
11398 (setq gnus-newsgroup-expirable
11399 (sort gnus-newsgroup-expirable '<))))
11400 (expiry-wait (gnus-group-get-parameter
11401 gnus-newsgroup-name 'expiry-wait))
11404 ;; There are expirable articles in this group, so we run them
11405 ;; through the expiry process.
11406 (gnus-message 6 "Expiring articles...")
11407 ;; The list of articles that weren't expired is returned.
11409 (let ((nnmail-expiry-wait-function nil)
11410 (nnmail-expiry-wait expiry-wait))
11411 (setq es (gnus-request-expire-articles
11412 expirable gnus-newsgroup-name)))
11413 (setq es (gnus-request-expire-articles
11414 expirable gnus-newsgroup-name)))
11415 (or total (setq gnus-newsgroup-expirable es))
11416 ;; We go through the old list of expirable, and mark all
11417 ;; really expired articles as nonexistent.
11418 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11419 (let ((gnus-use-cache nil))
11421 (unless (memq (car expirable) es)
11422 (when (gnus-data-find (car expirable))
11423 (gnus-summary-mark-article
11424 (car expirable) gnus-canceled-mark)))
11425 (setq expirable (cdr expirable)))))
11426 (gnus-message 6 "Expiring articles...done")))))
11428 (defun gnus-summary-expire-articles-now ()
11429 "Expunge all expirable articles in the current group.
11430 This means that *all* articles that are marked as expirable will be
11431 deleted forever, right now."
11433 (gnus-set-global-variables)
11434 (or gnus-expert-user
11436 "Are you really, really, really sure you want to expunge? ")
11438 (let ((nnmail-expiry-wait 'immediate)
11439 (nnmail-expiry-wait-function nil))
11440 (gnus-summary-expire-articles)))
11442 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11443 (defun gnus-summary-delete-article (&optional n)
11444 "Delete the N next (mail) articles.
11445 This command actually deletes articles. This is not a marking
11446 command. The article will disappear forever from your life, never to
11448 If N is negative, delete backwards.
11449 If N is nil and articles have been marked with the process mark,
11450 delete these instead."
11452 (gnus-set-global-variables)
11453 (or (gnus-check-backend-function 'request-expire-articles
11454 gnus-newsgroup-name)
11455 (error "The current newsgroup does not support article deletion."))
11456 ;; Compute the list of articles to delete.
11457 (let ((articles (gnus-summary-work-articles n))
11459 (if (and gnus-novice-user
11460 (not (gnus-y-or-n-p
11461 (format "Do you really want to delete %s forever? "
11462 (if (> (length articles) 1) "these articles"
11463 "this article")))))
11465 ;; Delete the articles.
11466 (setq not-deleted (gnus-request-expire-articles
11467 articles gnus-newsgroup-name 'force))
11469 (gnus-summary-remove-process-mark (car articles))
11470 ;; The backend might not have been able to delete the article
11472 (or (memq (car articles) not-deleted)
11473 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11474 (setq articles (cdr articles))))
11475 (gnus-summary-position-point)
11476 (gnus-set-mode-line 'summary)
11479 (defun gnus-summary-edit-article (&optional force)
11480 "Enter into a buffer and edit the current article.
11481 This will have permanent effect only in mail groups.
11482 If FORCE is non-nil, allow editing of articles even in read-only
11486 (set-buffer gnus-summary-buffer)
11487 (gnus-set-global-variables)
11488 (when (and (not force)
11489 (gnus-group-read-only-p))
11490 (error "The current newsgroup does not support article editing."))
11491 (gnus-summary-select-article t nil t)
11492 (gnus-configure-windows 'article)
11493 (select-window (get-buffer-window gnus-article-buffer))
11494 (gnus-message 6 "C-c C-c to end edits")
11495 (setq buffer-read-only nil)
11497 (use-local-map (copy-keymap (current-local-map)))
11498 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11499 (buffer-enable-undo)
11501 (goto-char (point-min))
11502 (search-forward "\n\n" nil t)))
11504 (defun gnus-summary-edit-article-done ()
11505 "Make edits to the current article permanent."
11507 (if (gnus-group-read-only-p)
11509 (gnus-summary-edit-article-postpone)
11511 1 "The current newsgroup does not support article editing.")
11513 (let ((buf (format "%s" (buffer-string))))
11516 (if (not (gnus-request-replace-article
11517 (cdr gnus-article-current) (car gnus-article-current)
11519 (error "Couldn't replace article.")
11520 (gnus-article-mode)
11521 (use-local-map gnus-article-mode-map)
11522 (setq buffer-read-only t)
11523 (buffer-disable-undo (current-buffer))
11524 (gnus-configure-windows 'summary)
11525 (gnus-summary-update-article (cdr gnus-article-current))
11526 (when gnus-use-cache
11527 (gnus-cache-update-article
11528 (cdr gnus-article-current) (car gnus-article-current))))
11529 (run-hooks 'gnus-article-display-hook)
11530 (and (gnus-visual-p 'summary-highlight 'highlight)
11531 (run-hooks 'gnus-visual-mark-article-hook)))))
11533 (defun gnus-summary-edit-article-postpone ()
11534 "Postpone changes to the current article."
11536 (gnus-article-mode)
11537 (use-local-map gnus-article-mode-map)
11538 (setq buffer-read-only t)
11539 (buffer-disable-undo (current-buffer))
11540 (gnus-configure-windows 'summary)
11541 (and (gnus-visual-p 'summary-highlight 'highlight)
11542 (run-hooks 'gnus-visual-mark-article-hook)))
11544 (defun gnus-summary-respool-query ()
11545 "Query where the respool algorithm would put this article."
11547 (gnus-set-global-variables)
11548 (gnus-summary-select-article)
11550 (set-buffer gnus-article-buffer)
11552 (goto-char (point-min))
11553 (search-forward "\n\n")
11554 (narrow-to-region (point-min) (point))
11555 (pp-eval-expression
11556 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11558 ;; Summary score commands.
11560 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
11562 (defun gnus-summary-raise-score (n)
11563 "Raise the score of the current article by N."
11565 (gnus-set-global-variables)
11566 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
11568 (defun gnus-summary-set-score (n)
11569 "Set the score of the current article to N."
11571 (gnus-set-global-variables)
11573 (gnus-summary-show-thread)
11574 (let ((buffer-read-only nil))
11576 (gnus-summary-update-mark
11577 (if (= n (or gnus-summary-default-score 0)) ?
11578 (if (< n (or gnus-summary-default-score 0))
11579 gnus-score-below-mark gnus-score-over-mark)) 'score))
11580 (let* ((article (gnus-summary-article-number))
11581 (score (assq article gnus-newsgroup-scored)))
11582 (if score (setcdr score n)
11583 (setq gnus-newsgroup-scored
11584 (cons (cons article n) gnus-newsgroup-scored))))
11585 (gnus-summary-update-line)))
11587 (defun gnus-summary-current-score ()
11588 "Return the score of the current article."
11590 (gnus-set-global-variables)
11591 (message "%s" (gnus-summary-article-score)))
11593 ;; Summary marking commands.
11595 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11596 "Mark articles which has the same subject as read, and then select the next.
11597 If UNMARK is positive, remove any kind of mark.
11598 If UNMARK is negative, tick articles."
11600 (gnus-set-global-variables)
11602 (setq unmark (prefix-numeric-value unmark)))
11604 (gnus-summary-mark-same-subject
11605 (gnus-summary-article-subject) unmark)))
11606 ;; Select next unread article. If auto-select-same mode, should
11607 ;; select the first unread article.
11608 (gnus-summary-next-article t (and gnus-auto-select-same
11609 (gnus-summary-article-subject)))
11610 (gnus-message 7 "%d article%s marked as %s"
11611 count (if (= count 1) " is" "s are")
11612 (if unmark "unread" "read"))))
11614 (defun gnus-summary-kill-same-subject (&optional unmark)
11615 "Mark articles which has the same subject as read.
11616 If UNMARK is positive, remove any kind of mark.
11617 If UNMARK is negative, tick articles."
11619 (gnus-set-global-variables)
11621 (setq unmark (prefix-numeric-value unmark)))
11623 (gnus-summary-mark-same-subject
11624 (gnus-summary-article-subject) unmark)))
11625 ;; If marked as read, go to next unread subject.
11627 ;; Go to next unread subject.
11628 (gnus-summary-next-subject 1 t))
11629 (gnus-message 7 "%d articles are marked as %s"
11630 count (if unmark "unread" "read"))))
11632 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11633 "Mark articles with same SUBJECT as read, and return marked number.
11634 If optional argument UNMARK is positive, remove any kinds of marks.
11635 If optional argument UNMARK is negative, mark articles as unread instead."
11639 ((null unmark) ; Mark as read.
11642 (gnus-summary-mark-article-as-read gnus-killed-mark)
11643 (gnus-summary-show-thread) t)
11644 (gnus-summary-find-subject subject))
11645 (setq count (1+ count))))
11646 ((> unmark 0) ; Tick.
11649 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11650 (gnus-summary-show-thread) t)
11651 (gnus-summary-find-subject subject))
11652 (setq count (1+ count))))
11653 (t ; Mark as unread.
11656 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11657 (gnus-summary-show-thread) t)
11658 (gnus-summary-find-subject subject))
11659 (setq count (1+ count)))))
11660 (gnus-set-mode-line 'summary)
11661 ;; Return the number of marked articles.
11664 (defun gnus-summary-mark-as-processable (n &optional unmark)
11665 "Set the process mark on the next N articles.
11666 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11667 the process mark instead. The difference between N and the actual
11668 number of articles marked is returned."
11670 (gnus-set-global-variables)
11671 (let ((backward (< n 0))
11676 (gnus-summary-remove-process-mark
11677 (gnus-summary-article-number))
11678 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11679 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11681 (if (/= 0 n) (gnus-message 7 "No more articles"))
11682 (gnus-summary-recenter)
11683 (gnus-summary-position-point)
11686 (defun gnus-summary-unmark-as-processable (n)
11687 "Remove the process mark from the next N articles.
11688 If N is negative, mark backward instead. The difference between N and
11689 the actual number of articles marked is returned."
11691 (gnus-set-global-variables)
11692 (gnus-summary-mark-as-processable n t))
11694 (defun gnus-summary-unmark-all-processable ()
11695 "Remove the process mark from all articles."
11697 (gnus-set-global-variables)
11699 (while gnus-newsgroup-processable
11700 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11701 (gnus-summary-position-point))
11703 (defun gnus-summary-mark-as-expirable (n)
11704 "Mark N articles forward as expirable.
11705 If N is negative, mark backward instead. The difference between N and
11706 the actual number of articles marked is returned."
11708 (gnus-set-global-variables)
11709 (gnus-summary-mark-forward n gnus-expirable-mark))
11711 (defun gnus-summary-mark-article-as-replied (article)
11712 "Mark ARTICLE replied and update the summary line."
11713 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11714 (let ((buffer-read-only nil))
11715 (when (gnus-summary-goto-subject article)
11716 (gnus-summary-update-secondary-mark article))))
11718 (defun gnus-summary-set-bookmark (article)
11719 "Set a bookmark in current article."
11720 (interactive (list (gnus-summary-article-number)))
11721 (gnus-set-global-variables)
11722 (if (or (not (get-buffer gnus-article-buffer))
11723 (not gnus-current-article)
11724 (not gnus-article-current)
11725 (not (equal gnus-newsgroup-name (car gnus-article-current))))
11726 (error "No current article selected"))
11727 ;; Remove old bookmark, if one exists.
11728 (let ((old (assq article gnus-newsgroup-bookmarks)))
11729 (if old (setq gnus-newsgroup-bookmarks
11730 (delq old gnus-newsgroup-bookmarks))))
11731 ;; Set the new bookmark, which is on the form
11732 ;; (article-number . line-number-in-body).
11733 (setq gnus-newsgroup-bookmarks
11737 (set-buffer gnus-article-buffer)
11741 (goto-char (point-min))
11742 (search-forward "\n\n" nil t)
11745 gnus-newsgroup-bookmarks))
11746 (gnus-message 6 "A bookmark has been added to the current article."))
11748 (defun gnus-summary-remove-bookmark (article)
11749 "Remove the bookmark from the current article."
11750 (interactive (list (gnus-summary-article-number)))
11751 (gnus-set-global-variables)
11752 ;; Remove old bookmark, if one exists.
11753 (let ((old (assq article gnus-newsgroup-bookmarks)))
11756 (setq gnus-newsgroup-bookmarks
11757 (delq old gnus-newsgroup-bookmarks))
11758 (gnus-message 6 "Removed bookmark."))
11759 (gnus-message 6 "No bookmark in current article."))))
11761 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11762 (defun gnus-summary-mark-as-dormant (n)
11763 "Mark N articles forward as dormant.
11764 If N is negative, mark backward instead. The difference between N and
11765 the actual number of articles marked is returned."
11767 (gnus-set-global-variables)
11768 (gnus-summary-mark-forward n gnus-dormant-mark))
11770 (defun gnus-summary-set-process-mark (article)
11771 "Set the process mark on ARTICLE and update the summary line."
11772 (setq gnus-newsgroup-processable
11774 (delq article gnus-newsgroup-processable)))
11775 (when (gnus-summary-goto-subject article)
11776 (gnus-summary-show-thread)
11777 (gnus-summary-update-secondary-mark article)))
11779 (defun gnus-summary-remove-process-mark (article)
11780 "Remove the process mark from ARTICLE and update the summary line."
11781 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
11782 (when (gnus-summary-goto-subject article)
11783 (gnus-summary-show-thread)
11784 (gnus-summary-update-secondary-mark article)))
11786 (defun gnus-summary-set-saved-mark (article)
11787 "Set the process mark on ARTICLE and update the summary line."
11788 (push article gnus-newsgroup-saved)
11789 (when (gnus-summary-goto-subject article)
11790 (gnus-summary-update-secondary-mark article)))
11792 (defun gnus-summary-mark-forward (n &optional mark no-expire)
11793 "Mark N articles as read forwards.
11794 If N is negative, mark backwards instead.
11795 Mark with MARK. If MARK is ? , ?! or ??, articles will be
11797 The difference between N and the actual number of articles marked is
11800 (gnus-set-global-variables)
11801 (let ((backward (< n 0))
11802 (gnus-summary-goto-unread
11803 (and gnus-summary-goto-unread
11804 (not (eq gnus-summary-goto-unread 'never))
11805 (not (memq mark (list gnus-unread-mark
11806 gnus-ticked-mark gnus-dormant-mark)))))
11808 (mark (or mark gnus-del-mark)))
11809 (while (and (> n 0)
11810 (gnus-summary-mark-article nil mark no-expire)
11811 (zerop (gnus-summary-next-subject
11813 (and gnus-summary-goto-unread
11814 (not (eq gnus-summary-goto-unread 'never)))
11817 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11818 (gnus-summary-recenter)
11819 (gnus-summary-position-point)
11820 (gnus-set-mode-line 'summary)
11823 (defun gnus-summary-mark-article-as-read (mark)
11824 "Mark the current article quickly as read with MARK."
11825 (let ((article (gnus-summary-article-number)))
11826 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11827 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11828 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11829 (setq gnus-newsgroup-reads
11830 (cons (cons article mark) gnus-newsgroup-reads))
11831 ;; Possibly remove from cache, if that is used.
11832 (and gnus-use-cache (gnus-cache-enter-remove-article article))
11833 ;; Allow the backend to change the mark.
11834 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11835 ;; Check for auto-expiry.
11836 (when (and gnus-newsgroup-auto-expire
11837 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11838 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11839 (= mark gnus-ancient-mark)
11840 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
11841 (setq mark gnus-expirable-mark)
11842 (push article gnus-newsgroup-expirable))
11843 ;; Set the mark in the buffer.
11844 (gnus-summary-update-mark mark 'unread)
11847 (defun gnus-summary-mark-article-as-unread (mark)
11848 "Mark the current article quickly as unread with MARK."
11849 (let ((article (gnus-summary-article-number)))
11850 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11851 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11852 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11853 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11854 (cond ((= mark gnus-ticked-mark)
11855 (push article gnus-newsgroup-marked))
11856 ((= mark gnus-dormant-mark)
11857 (push article gnus-newsgroup-dormant))
11859 (push article gnus-newsgroup-unreads)))
11860 (setq gnus-newsgroup-reads
11861 (delq (assq article gnus-newsgroup-reads)
11862 gnus-newsgroup-reads))
11864 ;; See whether the article is to be put in the cache.
11865 (and gnus-use-cache
11866 (vectorp (gnus-summary-article-header article))
11868 (gnus-cache-possibly-enter-article
11869 gnus-newsgroup-name article
11870 (gnus-summary-article-header article)
11871 (= mark gnus-ticked-mark)
11872 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11875 (gnus-summary-update-mark mark 'unread)
11878 (defun gnus-summary-mark-article (&optional article mark no-expire)
11879 "Mark ARTICLE with MARK. MARK can be any character.
11880 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11881 `??' (dormant) and `?E' (expirable).
11882 If MARK is nil, then the default character `?D' is used.
11883 If ARTICLE is nil, then the article on the current line will be
11885 ;; The mark might be a string.
11886 (and (stringp mark)
11887 (setq mark (aref mark 0)))
11888 ;; If no mark is given, then we check auto-expiring.
11889 (and (not no-expire)
11890 gnus-newsgroup-auto-expire
11892 (and (numberp mark)
11893 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11894 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11895 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
11896 (setq mark gnus-expirable-mark))
11897 (let* ((mark (or mark gnus-del-mark))
11898 (article (or article (gnus-summary-article-number))))
11899 (or article (error "No article on current line"))
11900 (if (or (= mark gnus-unread-mark)
11901 (= mark gnus-ticked-mark)
11902 (= mark gnus-dormant-mark))
11903 (gnus-mark-article-as-unread article mark)
11904 (gnus-mark-article-as-read article mark))
11906 ;; See whether the article is to be put in the cache.
11907 (and gnus-use-cache
11908 (not (= mark gnus-canceled-mark))
11909 (vectorp (gnus-summary-article-header article))
11911 (gnus-cache-possibly-enter-article
11912 gnus-newsgroup-name article
11913 (gnus-summary-article-header article)
11914 (= mark gnus-ticked-mark)
11915 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11917 (if (gnus-summary-goto-subject article nil t)
11918 (let ((buffer-read-only nil))
11919 (gnus-summary-show-thread)
11921 (gnus-summary-update-mark mark 'unread)
11924 (defun gnus-summary-update-secondary-mark (article)
11925 "Update the secondary (read, process, cache) mark."
11926 (gnus-summary-update-mark
11927 (cond ((memq article gnus-newsgroup-processable)
11929 ((memq article gnus-newsgroup-cached)
11931 ((memq article gnus-newsgroup-replied)
11933 ((memq article gnus-newsgroup-saved)
11935 (t gnus-unread-mark))
11937 (when (gnus-visual-p 'summary-highlight 'highlight)
11938 (run-hooks 'gnus-summary-update-hook))
11941 (defun gnus-summary-update-mark (mark type)
11942 (beginning-of-line)
11943 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11944 (buffer-read-only nil))
11946 ;; Go to the right position on the line.
11947 (forward-char forward)
11948 ;; Replace the old mark with the new mark.
11949 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
11950 ;; Optionally update the marks by some user rule.
11951 (when (eq type 'unread)
11952 (gnus-data-set-mark
11953 (gnus-data-find (gnus-summary-article-number)) mark)
11954 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
11956 (defun gnus-mark-article-as-read (article &optional mark)
11957 "Enter ARTICLE in the pertinent lists and remove it from others."
11958 ;; Make the article expirable.
11959 (let ((mark (or mark gnus-del-mark)))
11960 (if (= mark gnus-expirable-mark)
11961 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
11962 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
11963 ;; Remove from unread and marked lists.
11964 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11965 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11966 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11967 (push (cons article mark) gnus-newsgroup-reads)
11968 ;; Possibly remove from cache, if that is used.
11969 (when gnus-use-cache
11970 (gnus-cache-enter-remove-article article))))
11972 (defun gnus-mark-article-as-unread (article &optional mark)
11973 "Enter ARTICLE in the pertinent lists and remove it from others."
11974 (let ((mark (or mark gnus-ticked-mark)))
11975 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11976 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11977 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11978 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11979 (cond ((= mark gnus-ticked-mark)
11980 (push article gnus-newsgroup-marked))
11981 ((= mark gnus-dormant-mark)
11982 (push article gnus-newsgroup-dormant))
11984 (push article gnus-newsgroup-unreads)))
11985 (setq gnus-newsgroup-reads
11986 (delq (assq article gnus-newsgroup-reads)
11987 gnus-newsgroup-reads))))
11989 (defalias 'gnus-summary-mark-as-unread-forward
11990 'gnus-summary-tick-article-forward)
11991 (make-obsolete 'gnus-summary-mark-as-unread-forward
11992 'gnus-summary-tick-article-forward)
11993 (defun gnus-summary-tick-article-forward (n)
11994 "Tick N articles forwards.
11995 If N is negative, tick backwards instead.
11996 The difference between N and the number of articles ticked is returned."
11998 (gnus-summary-mark-forward n gnus-ticked-mark))
12000 (defalias 'gnus-summary-mark-as-unread-backward
12001 'gnus-summary-tick-article-backward)
12002 (make-obsolete 'gnus-summary-mark-as-unread-backward
12003 'gnus-summary-tick-article-backward)
12004 (defun gnus-summary-tick-article-backward (n)
12005 "Tick N articles backwards.
12006 The difference between N and the number of articles ticked is returned."
12008 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12010 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12011 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12012 (defun gnus-summary-tick-article (&optional article clear-mark)
12013 "Mark current article as unread.
12014 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12015 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12017 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12018 gnus-ticked-mark)))
12020 (defun gnus-summary-mark-as-read-forward (n)
12021 "Mark N articles as read forwards.
12022 If N is negative, mark backwards instead.
12023 The difference between N and the actual number of articles marked is
12026 (gnus-summary-mark-forward n gnus-del-mark t))
12028 (defun gnus-summary-mark-as-read-backward (n)
12029 "Mark the N articles as read backwards.
12030 The difference between N and the actual number of articles marked is
12033 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12035 (defun gnus-summary-mark-as-read (&optional article mark)
12036 "Mark current article as read.
12037 ARTICLE specifies the article to be marked as read.
12038 MARK specifies a string to be inserted at the beginning of the line."
12039 (gnus-summary-mark-article article mark))
12041 (defun gnus-summary-clear-mark-forward (n)
12042 "Clear marks from N articles forward.
12043 If N is negative, clear backward instead.
12044 The difference between N and the number of marks cleared is returned."
12046 (gnus-summary-mark-forward n gnus-unread-mark))
12048 (defun gnus-summary-clear-mark-backward (n)
12049 "Clear marks from N articles backward.
12050 The difference between N and the number of marks cleared is returned."
12052 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12054 (defun gnus-summary-mark-unread-as-read ()
12055 "Intended to be used by `gnus-summary-mark-article-hook'."
12056 (when (memq gnus-current-article gnus-newsgroup-unreads)
12057 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12059 (defun gnus-summary-mark-read-and-unread-as-read ()
12060 "Intended to be used by `gnus-summary-mark-article-hook'."
12061 (let ((mark (gnus-summary-article-mark)))
12062 (when (or (gnus-unread-mark-p mark)
12063 (gnus-read-mark-p mark))
12064 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12066 (defun gnus-summary-mark-region-as-read (point mark all)
12067 "Mark all unread articles between point and mark as read.
12068 If given a prefix, mark all articles between point and mark as read,
12069 even ticked and dormant ones."
12070 (interactive "r\nP")
12074 (beginning-of-line)
12079 (memq (setq article (gnus-summary-article-number))
12080 gnus-newsgroup-unreads))
12081 (gnus-summary-mark-article article gnus-del-mark))
12083 (gnus-summary-find-next))))))
12085 (defun gnus-summary-mark-below (score mark)
12086 "Mark articles with score less than SCORE with MARK."
12087 (interactive "P\ncMark: ")
12088 (gnus-set-global-variables)
12089 (setq score (if score
12090 (prefix-numeric-value score)
12091 (or gnus-summary-default-score 0)))
12093 (set-buffer gnus-summary-buffer)
12094 (goto-char (point-min))
12097 (and (< (gnus-summary-article-score) score)
12098 (gnus-summary-mark-article nil mark))
12099 (gnus-summary-find-next)))))
12101 (defun gnus-summary-kill-below (&optional score)
12102 "Mark articles with score below SCORE as read."
12104 (gnus-set-global-variables)
12105 (gnus-summary-mark-below score gnus-killed-mark))
12107 (defun gnus-summary-clear-above (&optional score)
12108 "Clear all marks from articles with score above SCORE."
12110 (gnus-set-global-variables)
12111 (gnus-summary-mark-above score gnus-unread-mark))
12113 (defun gnus-summary-tick-above (&optional score)
12114 "Tick all articles with score above SCORE."
12116 (gnus-set-global-variables)
12117 (gnus-summary-mark-above score gnus-ticked-mark))
12119 (defun gnus-summary-mark-above (score mark)
12120 "Mark articles with score over SCORE with MARK."
12121 (interactive "P\ncMark: ")
12122 (gnus-set-global-variables)
12123 (setq score (if score
12124 (prefix-numeric-value score)
12125 (or gnus-summary-default-score 0)))
12127 (set-buffer gnus-summary-buffer)
12128 (goto-char (point-min))
12130 (if (> (gnus-summary-article-score) score)
12131 (gnus-summary-mark-article nil mark))
12133 (gnus-summary-find-next)))))
12135 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12136 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12137 (defun gnus-summary-limit-include-expunged ()
12138 "Display all the hidden articles that were expunged for low scores."
12140 (gnus-set-global-variables)
12141 (let ((buffer-read-only nil))
12142 (let ((scored gnus-newsgroup-scored)
12145 (or (gnus-summary-goto-subject (caar scored))
12146 (and (setq h (gnus-summary-article-header (caar scored)))
12147 (< (cdar scored) gnus-summary-expunge-below)
12148 (setq headers (cons h headers))))
12149 (setq scored (cdr scored)))
12150 (or headers (error "No expunged articles hidden."))
12151 (goto-char (point-min))
12152 (gnus-summary-prepare-unthreaded (nreverse headers)))
12153 (goto-char (point-min))
12154 (gnus-summary-position-point)))
12156 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12157 "Mark all articles not marked as unread in this newsgroup as read.
12158 If prefix argument ALL is non-nil, all articles are marked as read.
12159 If QUIETLY is non-nil, no questions will be asked.
12160 If TO-HERE is non-nil, it should be a point in the buffer. All
12161 articles before this point will be marked as read.
12162 The number of articles marked as read is returned."
12164 (gnus-set-global-variables)
12167 (not gnus-interactive-catchup) ;Without confirmation?
12171 "Mark absolutely all articles as read? "
12172 "Mark all unread articles as read? ")))
12174 (not gnus-newsgroup-adaptive)
12175 (not gnus-newsgroup-auto-expire))
12178 (setq gnus-newsgroup-marked nil
12179 gnus-newsgroup-dormant nil))
12180 (setq gnus-newsgroup-unreads nil))
12181 ;; We actually mark all articles as canceled, which we
12182 ;; have to do when using auto-expiry or adaptive scoring.
12183 (gnus-summary-show-all-threads)
12184 (if (gnus-summary-first-subject (not all))
12186 (if to-here (< (point) to-here) t)
12187 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12188 (gnus-summary-find-next (not all)))))
12190 (setq gnus-newsgroup-unreads nil))
12191 (gnus-set-mode-line 'summary)))
12192 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12193 (if (and (not to-here) (eq 'nnvirtual (car method)))
12194 (nnvirtual-catchup-group
12195 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12196 (gnus-summary-position-point)))
12198 (defun gnus-summary-catchup-to-here (&optional all)
12199 "Mark all unticked articles before the current one as read.
12200 If ALL is non-nil, also mark ticked and dormant articles as read."
12202 (gnus-set-global-variables)
12204 (let ((beg (point)))
12205 ;; We check that there are unread articles.
12206 (when (or all (gnus-summary-find-prev))
12207 (gnus-summary-catchup all t beg))))
12208 (gnus-summary-position-point))
12210 (defun gnus-summary-catchup-all (&optional quietly)
12211 "Mark all articles in this newsgroup as read."
12213 (gnus-set-global-variables)
12214 (gnus-summary-catchup t quietly))
12216 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12217 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12218 If prefix argument ALL is non-nil, all articles are marked as read."
12220 (gnus-set-global-variables)
12221 (gnus-summary-catchup all quietly nil 'fast)
12222 ;; Select next newsgroup or exit.
12223 (if (eq gnus-auto-select-next 'quietly)
12224 (gnus-summary-next-group nil)
12225 (gnus-summary-exit)))
12227 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12228 "Mark all articles in this newsgroup as read, and then exit."
12230 (gnus-set-global-variables)
12231 (gnus-summary-catchup-and-exit t quietly))
12233 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12234 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12235 "Mark all articles in this group as read and select the next group.
12236 If given a prefix, mark all articles, unread as well as ticked, as
12239 (gnus-set-global-variables)
12241 (gnus-summary-catchup all))
12242 (gnus-summary-next-article t nil nil t))
12244 ;; Thread-based commands.
12246 (defun gnus-summary-articles-in-thread (&optional article)
12247 "Return a list of all articles in the current thread.
12248 If ARTICLE is non-nil, return all articles in the thread that starts
12249 with that article."
12250 (let* ((article (or article (gnus-summary-article-number)))
12251 (data (gnus-data-find-list article))
12252 (top-level (gnus-data-level (car data)))
12254 (cond ((null gnus-thread-operation-ignore-subject)
12255 (gnus-simplify-subject-re
12256 (mail-header-subject (gnus-data-header (car data)))))
12257 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12258 (gnus-simplify-subject-fuzzy
12259 (mail-header-subject (gnus-data-header (car data)))))
12263 () ; This article doesn't exist.
12265 (and (or (not top-subject)
12266 (string= top-subject
12267 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12268 (gnus-simplify-subject-fuzzy
12269 (mail-header-subject
12270 (gnus-data-header (car data))))
12271 (gnus-simplify-subject-re
12272 (mail-header-subject
12273 (gnus-data-header (car data)))))))
12274 (setq articles (cons (gnus-data-number (car data)) articles)))
12275 (if (and (setq data (cdr data))
12276 (> (gnus-data-level (car data)) top-level))
12279 ;; Return the list of articles.
12280 (nreverse articles))))
12282 (defun gnus-summary-rethread-current ()
12283 "Rethread the thread the current article is part of."
12285 (gnus-set-global-variables)
12286 (let* ((gnus-show-threads t)
12287 (article (gnus-summary-article-number))
12288 (id (mail-header-id (gnus-summary-article-header)))
12289 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12291 (error "No article on the current line"))
12292 (gnus-rebuild-thread id)
12293 (gnus-summary-goto-subject article)))
12295 (defun gnus-summary-reparent-thread ()
12296 "Make current article child of the marked (or previous) article.
12298 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12299 is non-nil or the Subject: of both articles are the same."
12301 (or (not (gnus-group-read-only-p))
12302 (error "The current newsgroup does not support article editing."))
12303 (or (<= (length gnus-newsgroup-processable) 1)
12304 (error "No more than one article may be marked."))
12305 (save-window-excursion
12306 (let ((gnus-article-buffer " *reparent*")
12307 (current-article (gnus-summary-article-number))
12308 ; first grab the marked article, otherwise one line up.
12309 (parent-article (if (not (null gnus-newsgroup-processable))
12310 (car gnus-newsgroup-processable)
12312 (if (eq (forward-line -1) 0)
12313 (gnus-summary-article-number)
12314 (error "Beginning of summary buffer."))))))
12315 (or (not (eq current-article parent-article))
12316 (error "An article may not be self-referential."))
12317 (let ((message-id (mail-header-id
12318 (gnus-summary-article-header parent-article))))
12319 (or (and message-id (not (equal message-id "")))
12320 (error "No message-id in desired parent."))
12321 (gnus-summary-select-article t t nil current-article)
12322 (set-buffer gnus-article-buffer)
12323 (setq buffer-read-only nil)
12324 (let ((buf (format "%s" (buffer-string))))
12327 (goto-char (point-min))
12328 (if (search-forward-regexp "^References: " nil t)
12329 (insert message-id " " )
12330 (insert "References: " message-id "\n"))
12331 (or (gnus-request-replace-article current-article
12332 (car gnus-article-current)
12333 gnus-article-buffer)
12334 (error "Couldn't replace article."))
12335 (set-buffer gnus-summary-buffer)
12336 (gnus-summary-unmark-all-processable)
12337 (gnus-summary-rethread-current)
12338 (message "Article %d is now the child of article %d."
12339 current-article parent-article)))))
12341 (defun gnus-summary-toggle-threads (&optional arg)
12342 "Toggle showing conversation threads.
12343 If ARG is positive number, turn showing conversation threads on."
12345 (gnus-set-global-variables)
12346 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12347 (setq gnus-show-threads
12348 (if (null arg) (not gnus-show-threads)
12349 (> (prefix-numeric-value arg) 0)))
12350 (gnus-summary-prepare)
12351 (gnus-summary-goto-subject current)
12352 (gnus-summary-position-point)))
12354 (defun gnus-summary-show-all-threads ()
12355 "Show all threads."
12357 (gnus-set-global-variables)
12359 (let ((buffer-read-only nil))
12360 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12361 (gnus-summary-position-point))
12363 (defun gnus-summary-show-thread ()
12364 "Show thread subtrees.
12365 Returns nil if no thread was there to be shown."
12367 (gnus-set-global-variables)
12368 (let ((buffer-read-only nil)
12370 ;; first goto end then to beg, to have point at beg after let
12371 (end (progn (end-of-line) (point)))
12372 (beg (progn (beginning-of-line) (point))))
12374 ;; Any hidden lines here?
12375 (search-forward "\r" end t)
12376 (subst-char-in-region beg end ?\^M ?\n t)
12378 (gnus-summary-position-point))))
12380 (defun gnus-summary-hide-all-threads ()
12381 "Hide all thread subtrees."
12383 (gnus-set-global-variables)
12385 (goto-char (point-min))
12386 (gnus-summary-hide-thread)
12387 (while (zerop (gnus-summary-next-thread 1 t))
12388 (gnus-summary-hide-thread)))
12389 (gnus-summary-position-point))
12391 (defun gnus-summary-hide-thread ()
12392 "Hide thread subtrees.
12393 Returns nil if no threads were there to be hidden."
12395 (gnus-set-global-variables)
12396 (let ((buffer-read-only nil)
12398 (article (gnus-summary-article-number)))
12400 ;; Go forward until either the buffer ends or the subthread
12402 (when (and (not (eobp))
12403 (or (zerop (gnus-summary-next-thread 1 t))
12404 (goto-char (point-max))))
12406 (if (and (> (point) start)
12407 (search-backward "\n" start t))
12409 (subst-char-in-region start (point) ?\n ?\^M)
12410 (gnus-summary-goto-subject article))
12413 ;;(gnus-summary-position-point)
12416 (defun gnus-summary-go-to-next-thread (&optional previous)
12417 "Go to the same level (or less) next thread.
12418 If PREVIOUS is non-nil, go to previous thread instead.
12419 Return the article number moved to, or nil if moving was impossible."
12420 (let ((level (gnus-summary-thread-level))
12421 (way (if previous -1 1))
12424 (while (and (not (eobp))
12425 (< level (gnus-summary-thread-level)))
12426 (forward-line way))
12433 (gnus-summary-article-number)
12434 (goto-char beg)))))
12436 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12437 "Go to the same level (or less) next thread.
12438 If PREVIOUS is non-nil, go to previous thread instead.
12439 Return the article number moved to, or nil if moving was impossible."
12440 (if (and (eq gnus-summary-make-false-root 'dummy)
12441 (gnus-summary-article-intangible-p))
12442 (let ((beg (point)))
12443 (while (and (zerop (forward-line 1))
12444 (not (gnus-summary-article-intangible-p))
12445 (not (zerop (save-excursion
12446 (gnus-summary-thread-level))))))
12452 (let* ((level (gnus-summary-thread-level))
12453 (article (gnus-summary-article-number))
12454 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12457 (if (<= (gnus-data-level (car data)) level)
12458 (setq oart (gnus-data-number (car data))
12460 (setq data (cdr data))))
12462 (gnus-summary-goto-subject oart)))))
12464 (defun gnus-summary-next-thread (n &optional silent)
12465 "Go to the same level next N'th thread.
12466 If N is negative, search backward instead.
12467 Returns the difference between N and the number of skips actually
12470 If SILENT, don't output messages."
12472 (gnus-set-global-variables)
12473 (let ((backward (< n 0))
12476 (while (and (> n 0)
12477 (gnus-summary-go-to-next-thread backward))
12480 (gnus-summary-position-point))
12481 (when (and (not silent) (/= 0 n))
12482 (gnus-message 7 "No more threads"))
12485 (defun gnus-summary-prev-thread (n)
12486 "Go to the same level previous N'th thread.
12487 Returns the difference between N and the number of skips actually
12490 (gnus-set-global-variables)
12491 (gnus-summary-next-thread (- n)))
12493 (defun gnus-summary-go-down-thread ()
12494 "Go down one level in the current thread."
12495 (let ((children (gnus-summary-article-children)))
12497 (gnus-summary-goto-subject (car children)))))
12499 (defun gnus-summary-go-up-thread ()
12500 "Go up one level in the current thread."
12501 (let ((parent (gnus-summary-article-parent)))
12503 (gnus-summary-goto-subject parent))))
12505 (defun gnus-summary-down-thread (n)
12506 "Go down thread N steps.
12507 If N is negative, go up instead.
12508 Returns the difference between N and how many steps down that were
12511 (gnus-set-global-variables)
12514 (while (and (> n 0)
12515 (if up (gnus-summary-go-up-thread)
12516 (gnus-summary-go-down-thread)))
12518 (gnus-summary-position-point)
12519 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12522 (defun gnus-summary-up-thread (n)
12523 "Go up thread N steps.
12524 If N is negative, go up instead.
12525 Returns the difference between N and how many steps down that were
12528 (gnus-set-global-variables)
12529 (gnus-summary-down-thread (- n)))
12531 (defun gnus-summary-top-thread ()
12532 "Go to the top of the thread."
12534 (gnus-set-global-variables)
12535 (while (gnus-summary-go-up-thread))
12536 (gnus-summary-article-number))
12538 (defun gnus-summary-kill-thread (&optional unmark)
12539 "Mark articles under current thread as read.
12540 If the prefix argument is positive, remove any kinds of marks.
12541 If the prefix argument is negative, tick articles instead."
12543 (gnus-set-global-variables)
12545 (setq unmark (prefix-numeric-value unmark)))
12546 (let ((articles (gnus-summary-articles-in-thread)))
12548 ;; Expand the thread.
12549 (gnus-summary-show-thread)
12550 ;; Mark all the articles.
12552 (gnus-summary-goto-subject (car articles))
12553 (cond ((null unmark)
12554 (gnus-summary-mark-article-as-read gnus-killed-mark))
12556 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12558 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12559 (setq articles (cdr articles))))
12560 ;; Hide killed subtrees.
12562 gnus-thread-hide-killed
12563 (gnus-summary-hide-thread))
12564 ;; If marked as read, go to next unread subject.
12566 ;; Go to next unread subject.
12567 (gnus-summary-next-subject 1 t)))
12568 (gnus-set-mode-line 'summary))
12570 ;; Summary sorting commands
12572 (defun gnus-summary-sort-by-number (&optional reverse)
12573 "Sort summary buffer by article number.
12574 Argument REVERSE means reverse order."
12576 (gnus-summary-sort 'number reverse))
12578 (defun gnus-summary-sort-by-author (&optional reverse)
12579 "Sort summary buffer by author name alphabetically.
12580 If case-fold-search is non-nil, case of letters is ignored.
12581 Argument REVERSE means reverse order."
12583 (gnus-summary-sort 'author reverse))
12585 (defun gnus-summary-sort-by-subject (&optional reverse)
12586 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12587 If case-fold-search is non-nil, case of letters is ignored.
12588 Argument REVERSE means reverse order."
12590 (gnus-summary-sort 'subject reverse))
12592 (defun gnus-summary-sort-by-date (&optional reverse)
12593 "Sort summary buffer by date.
12594 Argument REVERSE means reverse order."
12596 (gnus-summary-sort 'date reverse))
12598 (defun gnus-summary-sort-by-score (&optional reverse)
12599 "Sort summary buffer by score.
12600 Argument REVERSE means reverse order."
12602 (gnus-summary-sort 'score reverse))
12604 (defun gnus-summary-sort (predicate reverse)
12605 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12606 (gnus-set-global-variables)
12607 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12608 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12609 (gnus-thread-sort-functions
12614 (,thread t2 t1)))))
12615 (gnus-article-sort-functions
12620 (,article t2 t1)))))
12622 (gnus-summary-prepare-hook nil))
12623 ;; We do the sorting by regenerating the threads.
12624 (gnus-summary-prepare)
12625 ;; Hide subthreads if needed.
12626 (when (and gnus-show-threads gnus-thread-hide-subtree)
12627 (gnus-summary-hide-all-threads)))
12628 ;; If in async mode, we send some info to the backend.
12629 (when gnus-newsgroup-async
12630 (gnus-request-asynchronous
12631 gnus-newsgroup-name gnus-newsgroup-data)))
12633 (defun gnus-sortable-date (date)
12634 "Make sortable string by string-lessp from DATE.
12635 Timezone package is used."
12636 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
12637 (year (aref date 0))
12638 (month (aref date 1))
12639 (day (aref date 2)))
12640 (timezone-make-sortable-date
12642 (timezone-make-time-string
12643 (aref date 3) (aref date 4) (aref date 5)))))
12645 ;; Summary saving commands.
12647 (defun gnus-summary-save-article (&optional n not-saved)
12648 "Save the current article using the default saver function.
12649 If N is a positive number, save the N next articles.
12650 If N is a negative number, save the N previous articles.
12651 If N is nil and any articles have been marked with the process mark,
12652 save those articles instead.
12653 The variable `gnus-default-article-saver' specifies the saver function."
12655 (gnus-set-global-variables)
12656 (let ((articles (gnus-summary-work-articles n))
12657 file header article)
12659 (setq header (gnus-summary-article-header
12660 (setq article (pop articles))))
12661 (if (not (vectorp header))
12662 ;; This is a pseudo-article.
12663 (if (assq 'name header)
12664 (gnus-copy-file (cdr (assq 'name header)))
12665 (gnus-message 1 "Article %d is unsaveable" article))
12666 ;; This is a real article.
12667 (save-window-excursion
12668 (gnus-summary-select-article t nil nil article))
12669 (unless gnus-save-all-headers
12670 ;; Remove headers accoring to `gnus-saved-headers'.
12671 (let ((gnus-visible-headers
12672 (or gnus-saved-headers gnus-visible-headers)))
12673 (gnus-article-hide-headers nil t)))
12674 ;; Remove any X-Gnus lines.
12676 (set-buffer gnus-article-buffer)
12678 (let ((buffer-read-only nil))
12679 (nnheader-narrow-to-headers)
12680 (while (re-search-forward "^X-Gnus" nil t)
12681 (gnus-delete-line)))))
12682 (save-window-excursion
12683 (if (not gnus-default-article-saver)
12684 (error "No default saver is defined.")
12685 (setq file (funcall
12686 gnus-default-article-saver
12688 ((not gnus-prompt-before-saving)
12690 ((eq gnus-prompt-before-saving 'always)
12693 (gnus-summary-remove-process-mark article)
12695 (gnus-summary-set-saved-mark article))))
12696 (gnus-summary-position-point)
12699 (defun gnus-summary-pipe-output (&optional arg)
12700 "Pipe the current article to a subprocess.
12701 If N is a positive number, pipe the N next articles.
12702 If N is a negative number, pipe the N previous articles.
12703 If N is nil and any articles have been marked with the process mark,
12704 pipe those articles instead."
12706 (gnus-set-global-variables)
12707 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12708 (gnus-summary-save-article arg t))
12709 (gnus-configure-windows 'pipe))
12711 (defun gnus-summary-save-article-mail (&optional arg)
12712 "Append the current article to an mail file.
12713 If N is a positive number, save the N next articles.
12714 If N is a negative number, save the N previous articles.
12715 If N is nil and any articles have been marked with the process mark,
12716 save those articles instead."
12718 (gnus-set-global-variables)
12719 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12720 (gnus-summary-save-article arg)))
12722 (defun gnus-summary-save-article-rmail (&optional arg)
12723 "Append the current article to an rmail file.
12724 If N is a positive number, save the N next articles.
12725 If N is a negative number, save the N previous articles.
12726 If N is nil and any articles have been marked with the process mark,
12727 save those articles instead."
12729 (gnus-set-global-variables)
12730 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12731 (gnus-summary-save-article arg)))
12733 (defun gnus-summary-save-article-file (&optional arg)
12734 "Append the current article to a file.
12735 If N is a positive number, save the N next articles.
12736 If N is a negative number, save the N previous articles.
12737 If N is nil and any articles have been marked with the process mark,
12738 save those articles instead."
12740 (gnus-set-global-variables)
12741 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12742 (gnus-summary-save-article arg)))
12744 (defun gnus-summary-save-article-body-file (&optional arg)
12745 "Append the current article body to a file.
12746 If N is a positive number, save the N next articles.
12747 If N is a negative number, save the N previous articles.
12748 If N is nil and any articles have been marked with the process mark,
12749 save those articles instead."
12751 (gnus-set-global-variables)
12752 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12753 (gnus-summary-save-article arg)))
12755 (defun gnus-get-split-value (methods)
12756 "Return a value based on the split METHODS."
12757 (let (split-name method result match)
12760 (set-buffer gnus-original-article-buffer)
12762 (nnheader-narrow-to-headers)
12764 (goto-char (point-min))
12765 (setq method (pop methods))
12766 (setq match (car method))
12769 ;; Regular expression.
12771 (re-search-forward match nil t)
12773 ((gnus-functionp match)
12777 (setq result (funcall match gnus-newsgroup-name))))
12782 (setq result (eval match)))))
12783 (setq split-name (append (cdr method) split-name))
12784 (cond ((stringp result)
12785 (push result split-name))
12787 (setq split-name (append result split-name)))))))))
12790 (defun gnus-read-move-group-name (prompt default articles prefix)
12791 "Read a group name."
12792 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12794 (format "Where do you want to %s %s? "
12796 (if (> (length articles) 1)
12797 (format "these %d articles" (length articles))
12805 (format "(default %s) " default)
12807 gnus-active-hashtb nil nil prefix))
12808 ((= 1 (length split-name))
12809 (completing-read prom gnus-active-hashtb
12810 nil nil (cons (car split-name) 0)))
12813 prom (mapcar (lambda (el) (list el)) (nreverse split-name)))))))
12816 (if (or (string= to-newsgroup "")
12817 (string= to-newsgroup prefix))
12818 (setq to-newsgroup (or default "")))
12819 (or (gnus-active to-newsgroup)
12820 (gnus-activate-group to-newsgroup)
12821 (error "No such group: %s" to-newsgroup)))
12824 (defun gnus-read-save-file-name (prompt default-name)
12825 (let* ((split-name (gnus-get-split-value gnus-split-methods))
12827 ;; Let the split methods have their say.
12829 ;; No split name was found.
12832 (concat prompt " (default "
12833 (file-name-nondirectory default-name) ") ")
12834 (file-name-directory default-name)
12836 ;; A single split name was found
12837 ((= 1 (length split-name))
12839 (concat prompt " (default " (car split-name) ") ")
12840 gnus-article-save-directory
12841 (concat gnus-article-save-directory (car split-name))))
12842 ;; A list of splits was found.
12844 (setq split-name (mapcar (lambda (el) (list el))
12845 (nreverse split-name)))
12846 (let ((result (completing-read
12847 (concat prompt " ") split-name nil nil)))
12848 (concat gnus-article-save-directory
12849 (if (string= result "")
12852 ;; If we have read a directory, we append the default file name.
12853 (when (file-directory-p file)
12854 (setq file (concat (file-name-as-directory file)
12855 (file-name-nondirectory default-name))))
12856 ;; Possibly translate some charaters.
12857 (nnheader-translate-file-chars file)))
12859 (defun gnus-article-archive-name (group)
12860 "Return the first instance of an \"Archive-name\" in the current buffer."
12861 (let ((case-fold-search t))
12862 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
12863 (match-string 1))))
12865 (defun gnus-summary-save-in-rmail (&optional filename)
12866 "Append this article to Rmail file.
12867 Optional argument FILENAME specifies file name.
12868 Directory to save to is default to `gnus-article-save-directory' which
12869 is initialized from the SAVEDIR environment variable."
12871 (gnus-set-global-variables)
12872 (let ((default-name
12873 (funcall gnus-rmail-save-name gnus-newsgroup-name
12874 gnus-current-headers gnus-newsgroup-last-rmail)))
12876 (cond ((eq filename 'default)
12878 (filename filename)
12879 (t (gnus-read-save-file-name
12880 "Save in rmail file:" default-name))))
12881 (gnus-make-directory (file-name-directory filename))
12882 (gnus-eval-in-buffer-window
12883 gnus-original-article-buffer
12887 (gnus-output-to-rmail filename))))
12888 ;; Remember the directory name to save articles
12889 (setq gnus-newsgroup-last-rmail filename)))
12891 (defun gnus-summary-save-in-mail (&optional filename)
12892 "Append this article to Unix mail file.
12893 Optional argument FILENAME specifies file name.
12894 Directory to save to is default to `gnus-article-save-directory' which
12895 is initialized from the SAVEDIR environment variable."
12897 (gnus-set-global-variables)
12898 (let ((default-name
12899 (funcall gnus-mail-save-name gnus-newsgroup-name
12900 gnus-current-headers gnus-newsgroup-last-mail)))
12902 (cond ((eq filename 'default)
12904 (filename filename)
12905 (t (gnus-read-save-file-name
12906 "Save in Unix mail file:" default-name))))
12908 (expand-file-name filename
12910 (file-name-directory default-name))))
12911 (gnus-make-directory (file-name-directory filename))
12912 (gnus-eval-in-buffer-window
12913 gnus-original-article-buffer
12917 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
12918 (gnus-output-to-rmail filename)
12919 (let ((mail-use-rfc822 t))
12920 (rmail-output filename 1 t t))))))
12921 ;; Remember the directory name to save articles.
12922 (setq gnus-newsgroup-last-mail filename)))
12924 (defun gnus-summary-save-in-file (&optional filename)
12925 "Append this article to file.
12926 Optional argument FILENAME specifies file name.
12927 Directory to save to is default to `gnus-article-save-directory' which
12928 is initialized from the SAVEDIR environment variable."
12930 (gnus-set-global-variables)
12931 (let ((default-name
12932 (funcall gnus-file-save-name gnus-newsgroup-name
12933 gnus-current-headers gnus-newsgroup-last-file)))
12935 (cond ((eq filename 'default)
12937 (filename filename)
12938 (t (gnus-read-save-file-name
12939 "Save in file:" default-name))))
12940 (gnus-make-directory (file-name-directory filename))
12941 (gnus-eval-in-buffer-window
12942 gnus-original-article-buffer
12946 (gnus-output-to-file filename))))
12947 ;; Remember the directory name to save articles.
12948 (setq gnus-newsgroup-last-file filename)))
12950 (defun gnus-summary-save-body-in-file (&optional filename)
12951 "Append this article body to a file.
12952 Optional argument FILENAME specifies file name.
12953 The directory to save in defaults to `gnus-article-save-directory' which
12954 is initialized from the SAVEDIR environment variable."
12956 (gnus-set-global-variables)
12957 (let ((default-name
12958 (funcall gnus-file-save-name gnus-newsgroup-name
12959 gnus-current-headers gnus-newsgroup-last-file)))
12961 (cond ((eq filename 'default)
12963 (filename filename)
12964 (t (gnus-read-save-file-name
12965 "Save body in file:" default-name))))
12966 (gnus-make-directory (file-name-directory filename))
12967 (gnus-eval-in-buffer-window
12968 gnus-article-buffer
12972 (goto-char (point-min))
12973 (and (search-forward "\n\n" nil t)
12974 (narrow-to-region (point) (point-max)))
12975 (gnus-output-to-file filename))))
12976 ;; Remember the directory name to save articles.
12977 (setq gnus-newsgroup-last-file filename)))
12979 (defun gnus-summary-save-in-pipe (&optional command)
12980 "Pipe this article to subprocess."
12982 (gnus-set-global-variables)
12984 (cond ((eq command 'default)
12985 gnus-last-shell-command)
12987 (t (read-string "Shell command on article: "
12988 gnus-last-shell-command))))
12989 (if (string-equal command "")
12990 (setq command gnus-last-shell-command))
12991 (gnus-eval-in-buffer-window
12992 gnus-article-buffer
12995 (shell-command-on-region (point-min) (point-max) command nil)))
12996 (setq gnus-last-shell-command command))
12998 ;; Summary extract commands
13000 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13001 (let ((buffer-read-only nil)
13002 (article (gnus-summary-article-number))
13004 (or (gnus-summary-goto-subject article)
13005 (error (format "No such article: %d" article)))
13006 (gnus-summary-position-point)
13007 ;; If all commands are to be bunched up on one line, we collect
13009 (if gnus-view-pseudos-separately
13011 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13014 (setq action (cdr (assq 'action (car ps))))
13015 (setq files (list (cdr (assq 'name (car ps)))))
13016 (while (and ps (cdr ps)
13017 (string= (or action "1")
13018 (or (cdr (assq 'action (cadr ps))) "2")))
13019 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13020 (setcdr ps (cddr ps)))
13023 (if (not (string-match "%s" action))
13024 (setq files (cons " " files)))
13025 (setq files (cons " " files))
13026 (and (assq 'execute (car ps))
13027 (setcdr (assq 'execute (car ps))
13028 (funcall (if (string-match "%s" action)
13031 (mapconcat (lambda (f) f) files " ")))))
13032 (setq ps (cdr ps)))))
13033 (if (and gnus-view-pseudos (not not-view))
13035 (and (assq 'execute (car pslist))
13036 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13037 (eq gnus-view-pseudos 'not-confirm)))
13038 (setq pslist (cdr pslist)))
13041 (setq after-article (or (cdr (assq 'article (car pslist)))
13042 (gnus-summary-article-number)))
13043 (gnus-summary-goto-subject after-article)
13046 (insert " " (file-name-nondirectory
13047 (cdr (assq 'name (car pslist))))
13048 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13050 (forward-line -1) ; back to `b'
13051 (add-text-properties
13052 b e (list 'gnus-number gnus-reffed-article-number
13053 gnus-mouse-face-prop gnus-mouse-face))
13055 after-article gnus-reffed-article-number
13056 gnus-unread-mark b (car pslist) 0 (- e b))
13057 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13058 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13059 (setq pslist (cdr pslist)))))))
13061 (defun gnus-pseudos< (p1 p2)
13062 (let ((c1 (cdr (assq 'action p1)))
13063 (c2 (cdr (assq 'action p2))))
13064 (and c1 c2 (string< c1 c2))))
13066 (defun gnus-request-pseudo-article (props)
13067 (cond ((assq 'execute props)
13068 (gnus-execute-command (cdr (assq 'execute props)))))
13069 (let ((gnus-current-article (gnus-summary-article-number)))
13070 (run-hooks 'gnus-mark-article-hook)))
13072 (defun gnus-execute-command (command &optional automatic)
13074 (gnus-article-setup-buffer)
13075 (set-buffer gnus-article-buffer)
13076 (let ((command (if automatic command (read-string "Command: " command)))
13077 (buffer-read-only nil))
13079 (insert "$ " command "\n\n")
13080 (if gnus-view-pseudo-asynchronously
13081 (start-process "gnus-execute" nil "sh" "-c" command)
13082 (call-process "sh" nil t nil "-c" command)))))
13084 (defun gnus-copy-file (file &optional to)
13087 (list (read-file-name "Copy file: " default-directory)
13088 (read-file-name "Copy file to: " default-directory)))
13089 (gnus-set-global-variables)
13090 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13091 (and (file-directory-p to)
13092 (setq to (concat (file-name-as-directory to)
13093 (file-name-nondirectory file))))
13094 (copy-file file to))
13096 ;; Summary kill commands.
13098 (defun gnus-summary-edit-global-kill (article)
13099 "Edit the \"global\" kill file."
13100 (interactive (list (gnus-summary-article-number)))
13101 (gnus-set-global-variables)
13102 (gnus-group-edit-global-kill article))
13104 (defun gnus-summary-edit-local-kill ()
13105 "Edit a local kill file applied to the current newsgroup."
13107 (gnus-set-global-variables)
13108 (setq gnus-current-headers (gnus-summary-article-header))
13109 (gnus-set-global-variables)
13110 (gnus-group-edit-local-kill
13111 (gnus-summary-article-number) gnus-newsgroup-name))
13115 ;;; Gnus article mode
13118 (put 'gnus-article-mode 'mode-class 'special)
13120 (if gnus-article-mode-map
13122 (setq gnus-article-mode-map (make-keymap))
13123 (suppress-keymap gnus-article-mode-map)
13125 (gnus-define-keys gnus-article-mode-map
13126 " " gnus-article-goto-next-page
13127 "\177" gnus-article-goto-prev-page
13128 [delete] gnus-article-goto-prev-page
13129 "\C-c^" gnus-article-refer-article
13130 "h" gnus-article-show-summary
13131 "s" gnus-article-show-summary
13132 "\C-c\C-m" gnus-article-mail
13133 "?" gnus-article-describe-briefly
13134 gnus-mouse-2 gnus-article-push-button
13135 "\r" gnus-article-press-button
13136 "\t" gnus-article-next-button
13137 "\M-\t" gnus-article-prev-button
13138 "\C-c\C-b" gnus-bug)
13140 (substitute-key-definition
13141 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13143 (defun gnus-article-mode ()
13144 "Major mode for displaying an article.
13146 All normal editing commands are switched off.
13148 The following commands are available:
13150 \\<gnus-article-mode-map>
13151 \\[gnus-article-next-page]\t Scroll the article one page forwards
13152 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13153 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13154 \\[gnus-article-show-summary]\t Display the summary buffer
13155 \\[gnus-article-mail]\t Send a reply to the address near point
13156 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13157 \\[gnus-info-find-node]\t Go to the Gnus info node"
13159 (when (and menu-bar-mode
13160 (gnus-visual-p 'article-menu 'menu))
13161 (gnus-article-make-menu-bar))
13162 (kill-all-local-variables)
13163 (gnus-simplify-mode-line)
13164 (setq mode-name "Article")
13165 (setq major-mode 'gnus-article-mode)
13166 (make-local-variable 'minor-mode-alist)
13167 (or (assq 'gnus-show-mime minor-mode-alist)
13168 (setq minor-mode-alist
13169 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13170 (use-local-map gnus-article-mode-map)
13171 (make-local-variable 'page-delimiter)
13172 (setq page-delimiter gnus-page-delimiter)
13173 (buffer-disable-undo (current-buffer))
13174 (setq buffer-read-only t) ;Disable modification
13175 (run-hooks 'gnus-article-mode-hook))
13177 (defun gnus-article-setup-buffer ()
13178 "Initialize the article buffer."
13179 (let* ((name (if gnus-single-article-buffer "*Article*"
13180 (concat "*Article " gnus-newsgroup-name "*")))
13182 (progn (string-match "\\*Article" name)
13183 (concat " *Original Article"
13184 (substring name (match-end 0))))))
13185 (setq gnus-article-buffer name)
13186 (setq gnus-original-article-buffer original)
13187 ;; This might be a variable local to the summary buffer.
13188 (unless gnus-single-article-buffer
13190 (set-buffer gnus-summary-buffer)
13191 (setq gnus-article-buffer name)
13192 (setq gnus-original-article-buffer original)
13193 (gnus-set-global-variables))
13194 (make-local-variable 'gnus-summary-buffer))
13195 ;; Init original article buffer.
13197 (set-buffer (get-buffer-create gnus-original-article-buffer))
13198 (buffer-disable-undo (current-buffer))
13199 (setq major-mode 'gnus-original-article-mode)
13200 (make-local-variable 'gnus-original-article))
13201 (if (get-buffer name)
13204 (buffer-disable-undo (current-buffer))
13205 (setq buffer-read-only t)
13206 (gnus-add-current-to-buffer-list)
13207 (or (eq major-mode 'gnus-article-mode)
13208 (gnus-article-mode))
13211 (set-buffer (get-buffer-create name))
13212 (gnus-add-current-to-buffer-list)
13213 (gnus-article-mode)
13214 (current-buffer)))))
13216 ;; Set article window start at LINE, where LINE is the number of lines
13217 ;; from the head of the article.
13218 (defun gnus-article-set-window-start (&optional line)
13220 (get-buffer-window gnus-article-buffer)
13222 (set-buffer gnus-article-buffer)
13223 (goto-char (point-min))
13226 (gnus-message 6 "Moved to bookmark")
13227 (search-forward "\n\n" nil t)
13228 (forward-line line)
13231 (defun gnus-kill-all-overlays ()
13232 "Delete all overlays in the current buffer."
13233 (when (fboundp 'overlay-lists)
13234 (let* ((overlayss (overlay-lists))
13235 (buffer-read-only nil)
13236 (overlays (nconc (car overlayss) (cdr overlayss))))
13238 (delete-overlay (pop overlays))))))
13240 (defun gnus-request-article-this-buffer (article group)
13241 "Get an article and insert it into this buffer."
13242 (let (do-update-line)
13246 (gnus-kill-all-overlays)
13247 (setq group (or group gnus-newsgroup-name))
13249 ;; Open server if it has closed.
13250 (gnus-check-server (gnus-find-method-for-group group))
13252 ;; Using `gnus-request-article' directly will insert the article into
13253 ;; `nntp-server-buffer' - so we'll save some time by not having to
13254 ;; copy it from the server buffer into the article buffer.
13256 ;; We only request an article by message-id when we do not have the
13257 ;; headers for it, so we'll have to get those.
13258 (when (stringp article)
13259 (let ((gnus-override-method gnus-refer-article-method))
13260 (gnus-read-header article)))
13262 ;; If the article number is negative, that means that this article
13263 ;; doesn't belong in this newsgroup (possibly), so we find its
13264 ;; message-id and request it by id instead of number.
13265 (when (and (numberp article)
13266 gnus-summary-buffer
13267 (get-buffer gnus-summary-buffer)
13268 (buffer-name (get-buffer gnus-summary-buffer)))
13270 (set-buffer gnus-summary-buffer)
13271 (let ((header (gnus-summary-article-header article)))
13274 ((memq article gnus-newsgroup-sparse)
13275 ;; This is a sparse gap article.
13276 (setq do-update-line article)
13277 (setq article (mail-header-id header))
13278 (let ((gnus-override-method gnus-refer-article-method))
13279 (gnus-read-header article)))
13281 ;; It's a real article.
13282 (setq article (mail-header-id header)))
13284 ;; It is an extracted pseudo-article.
13285 (setq article 'pseudo)
13286 (gnus-request-pseudo-article header))))
13288 (let ((method (gnus-find-method-for-group
13289 gnus-newsgroup-name)))
13290 (if (not (eq (car method) 'nneething))
13292 (let ((dir (concat (file-name-as-directory (nth 1 method))
13293 (mail-header-subject header))))
13294 (if (file-directory-p dir)
13296 (setq article 'nneething)
13297 (gnus-group-enter-directory dir)))))))))
13300 ;; We first check `gnus-original-article-buffer'.
13301 ((and (get-buffer gnus-original-article-buffer)
13303 (set-buffer gnus-original-article-buffer)
13304 (and (equal (car gnus-original-article) group)
13305 (eq (cdr gnus-original-article) article))))
13306 (insert-buffer-substring gnus-original-article-buffer)
13308 ;; Check the backlog.
13309 ((and gnus-keep-backlog
13310 (gnus-backlog-request-article group article (current-buffer)))
13312 ;; Check the cache.
13313 ((and gnus-use-cache
13315 (gnus-cache-request-article article group))
13317 ;; Get the article and put into the article buffer.
13318 ((or (stringp article) (numberp article))
13319 (let ((gnus-override-method
13320 (and (stringp article) gnus-refer-article-method))
13321 (buffer-read-only nil))
13323 (gnus-kill-all-overlays)
13324 (if (gnus-request-article article group (current-buffer))
13326 (and gnus-keep-backlog
13327 (gnus-backlog-enter-article
13328 group article (current-buffer)))
13330 ;; It was a pseudo.
13333 ;; Take the article from the original article buffer
13334 ;; and place it in the buffer it's supposed to be in.
13335 (when (and (get-buffer gnus-article-buffer)
13336 (equal (buffer-name (current-buffer))
13337 (buffer-name (get-buffer gnus-article-buffer))))
13339 (if (get-buffer gnus-original-article-buffer)
13340 (set-buffer (get-buffer gnus-original-article-buffer))
13341 (set-buffer (get-buffer-create gnus-original-article-buffer))
13342 (buffer-disable-undo (current-buffer))
13343 (setq major-mode 'gnus-original-article-mode)
13344 (setq buffer-read-only t)
13345 (gnus-add-current-to-buffer-list))
13346 (let (buffer-read-only)
13348 (insert-buffer-substring gnus-article-buffer))
13349 (setq gnus-original-article (cons group article))))
13351 ;; Update sparse articles.
13352 (when do-update-line
13354 (set-buffer gnus-summary-buffer)
13355 (gnus-summary-update-article do-update-line)
13356 (gnus-summary-goto-subject do-update-line)
13357 (set-window-point (get-buffer-window (current-buffer) t)
13360 (defun gnus-read-header (id &optional header)
13361 "Read the headers of article ID and enter them into the Gnus system."
13362 (let ((group gnus-newsgroup-name)
13364 ;; First we check to see whether the header in question is already
13367 ;; This is a Message-ID.
13368 (setq header (or header (gnus-id-to-header id)))
13369 ;; This is an article number.
13370 (setq header (or header (gnus-summary-article-header id))))
13372 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13373 ;; We have found the header.
13375 ;; We have to really fetch the header to this article.
13377 (if (gnus-check-backend-function 'request-head group)
13378 (gnus-request-head id group)
13379 (gnus-request-article id group)))
13381 (set-buffer nntp-server-buffer)
13382 (and (search-forward "\n\n" nil t)
13383 (delete-region (1- (point)) (point-max)))
13384 (goto-char (point-max))
13386 (goto-char (point-min))
13390 ((cdr where) (cdr where))
13391 (header (mail-header-number header))
13392 (t gnus-reffed-article-number))
13394 (insert " Article retrieved.\n"))
13396 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13397 ; (setcar (gnus-id-to-thread id) nil))
13398 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13399 () ; Malformed head.
13400 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13401 (if (and (stringp id)
13402 (not (string= (gnus-group-real-name group)
13404 ;; If we fetched by Message-ID and the article came
13405 ;; from a different group, we fudge some bogus article
13406 ;; numbers for this article.
13407 (mail-header-set-number header gnus-reffed-article-number))
13408 (decf gnus-reffed-article-number)
13409 (push header gnus-newsgroup-headers)
13410 (setq gnus-current-headers header)
13411 (push (mail-header-number header) gnus-newsgroup-limit))
13414 (defun gnus-article-prepare (article &optional all-headers header)
13415 "Prepare ARTICLE in article mode buffer.
13416 ARTICLE should either be an article number or a Message-ID.
13417 If ARTICLE is an id, HEADER should be the article headers.
13418 If ALL-HEADERS is non-nil, no headers are hidden."
13420 ;; Make sure we start in a summary buffer.
13421 (unless (eq major-mode 'gnus-summary-mode)
13422 (set-buffer gnus-summary-buffer))
13423 (setq gnus-summary-buffer (current-buffer))
13424 ;; Make sure the connection to the server is alive.
13425 (unless (gnus-server-opened
13426 (gnus-find-method-for-group gnus-newsgroup-name))
13427 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13428 (gnus-request-group gnus-newsgroup-name t))
13429 (let* ((article (if header (mail-header-number header) article))
13430 (summary-buffer (current-buffer))
13431 (internal-hook gnus-article-internal-prepare-hook)
13432 (group gnus-newsgroup-name)
13435 (gnus-article-setup-buffer)
13436 (set-buffer gnus-article-buffer)
13437 ;; Deactivate active regions.
13438 (when (and (boundp 'transient-mark-mode)
13439 transient-mark-mode)
13440 (setq mark-active nil))
13441 (if (not (setq result (let ((buffer-read-only nil))
13442 (gnus-request-article-this-buffer
13444 ;; There is no such article.
13446 (when (and (numberp article)
13447 (not (memq article gnus-newsgroup-sparse)))
13448 (setq gnus-article-current
13449 (cons gnus-newsgroup-name article))
13450 (set-buffer gnus-summary-buffer)
13451 (setq gnus-current-article article)
13452 (gnus-summary-mark-article article gnus-canceled-mark))
13453 (unless (memq article gnus-newsgroup-sparse)
13455 1 "No such article (may have expired or been canceled)")
13458 (if (or (eq result 'pseudo) (eq result 'nneething))
13461 (set-buffer summary-buffer)
13462 (setq gnus-last-article gnus-current-article
13463 gnus-newsgroup-history (cons gnus-current-article
13464 gnus-newsgroup-history)
13465 gnus-current-article 0
13466 gnus-current-headers nil
13467 gnus-article-current nil)
13468 (if (eq result 'nneething)
13469 (gnus-configure-windows 'summary)
13470 (gnus-configure-windows 'article))
13471 (gnus-set-global-variables))
13472 (gnus-set-mode-line 'article))
13473 ;; The result from the `request' was an actual article -
13474 ;; or at least some text that is now displayed in the
13476 (if (and (numberp article)
13477 (not (eq article gnus-current-article)))
13478 ;; Seems like a new article has been selected.
13479 ;; `gnus-current-article' must be an article number.
13481 (set-buffer summary-buffer)
13482 (setq gnus-last-article gnus-current-article
13483 gnus-newsgroup-history (cons gnus-current-article
13484 gnus-newsgroup-history)
13485 gnus-current-article article
13486 gnus-current-headers
13487 (gnus-summary-article-header gnus-current-article)
13488 gnus-article-current
13489 (cons gnus-newsgroup-name gnus-current-article))
13490 (unless (vectorp gnus-current-headers)
13491 (setq gnus-current-headers nil))
13492 (gnus-summary-show-thread)
13493 (run-hooks 'gnus-mark-article-hook)
13494 (gnus-set-mode-line 'summary)
13495 (and (gnus-visual-p 'article-highlight 'highlight)
13496 (run-hooks 'gnus-visual-mark-article-hook))
13497 ;; Set the global newsgroup variables here.
13498 ;; Suggested by Jim Sisolak
13499 ;; <sisolak@trans4.neep.wisc.edu>.
13500 (gnus-set-global-variables)
13501 (setq gnus-have-all-headers
13502 (or all-headers gnus-show-all-headers))
13503 (and gnus-use-cache
13504 (vectorp (gnus-summary-article-header article))
13505 (gnus-cache-possibly-enter-article
13507 (gnus-summary-article-header article)
13508 (memq article gnus-newsgroup-marked)
13509 (memq article gnus-newsgroup-dormant)
13510 (memq article gnus-newsgroup-unreads)))))
13511 ;; Hooks for getting information from the article.
13512 ;; This hook must be called before being narrowed.
13513 (let (buffer-read-only)
13514 (run-hooks 'internal-hook)
13515 (run-hooks 'gnus-article-prepare-hook)
13516 ;; Decode MIME message.
13518 (if (or (not gnus-strict-mime)
13519 (gnus-fetch-field "Mime-Version"))
13520 (funcall gnus-show-mime-method)
13521 (funcall gnus-decode-encoded-word-method)))
13522 ;; Perform the article display hooks.
13523 (run-hooks 'gnus-article-display-hook))
13525 (goto-char (point-min))
13526 (and gnus-break-pages (gnus-narrow-to-page))
13527 (gnus-set-mode-line 'article)
13528 (gnus-configure-windows 'article)
13529 (goto-char (point-min))
13532 (defun gnus-article-show-all-headers ()
13533 "Show all article headers in article mode buffer."
13535 (gnus-article-setup-buffer)
13536 (set-buffer gnus-article-buffer)
13537 (let ((buffer-read-only nil))
13538 (gnus-unhide-text (point-min) (point-max)))))
13540 (defun gnus-article-hide-headers-if-wanted ()
13541 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13542 Provided for backwards compatibility."
13543 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13544 gnus-inhibit-hiding
13545 (gnus-article-hide-headers)))
13547 (defun gnus-article-hide-headers (&optional arg delete)
13548 "Toggle whether to hide unwanted headers and possibly sort them as well.
13549 If given a negative prefix, always show; if given a positive prefix,
13552 (unless (gnus-article-check-hidden-text 'headers arg)
13553 ;; This function might be inhibited.
13554 (unless gnus-inhibit-hiding
13556 (set-buffer gnus-article-buffer)
13558 (let ((buffer-read-only nil)
13559 (props (nconc (list 'gnus-type 'headers)
13560 gnus-hidden-properties))
13561 (ignored (when (not (stringp gnus-visible-headers))
13562 (cond ((stringp gnus-ignored-headers)
13563 gnus-ignored-headers)
13564 ((listp gnus-ignored-headers)
13565 (mapconcat 'identity gnus-ignored-headers
13568 (cond ((stringp gnus-visible-headers)
13569 gnus-visible-headers)
13570 ((and gnus-visible-headers
13571 (listp gnus-visible-headers))
13572 (mapconcat 'identity gnus-visible-headers "\\|"))))
13574 ;; First we narrow to just the headers.
13576 (goto-char (point-min))
13577 ;; Hide any "From " lines at the beginning of (mail) articles.
13578 (while (looking-at "From ")
13581 (gnus-hide-text (point-min) (point) props))
13582 ;; Then treat the rest of the header lines.
13585 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13586 ;; Then we use the two regular expressions
13587 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13588 ;; select which header lines is to remain visible in the
13590 (goto-char (point-min))
13591 (while (re-search-forward "^[^ \t]*:" nil t)
13592 (beginning-of-line)
13593 ;; We add the headers we want to keep to a list and delete
13594 ;; them from the buffer.
13595 (if (or (and visible (looking-at visible))
13596 (and ignored (not (looking-at ignored))))
13598 (push (buffer-substring
13602 ;; Be sure to get multi-line headers...
13603 (re-search-forward "^[^ \t]*:" nil t)
13604 (beginning-of-line)
13607 (delete-region beg (point)))
13609 ;; Sort the headers that we want to display.
13610 (setq want-list (sort want-list 'gnus-article-header-less))
13611 (goto-char (point-min))
13613 (insert (pop want-list)))
13614 ;; We make the unwanted headers invisible.
13616 (delete-region (point-min) (point-max))
13617 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13618 (gnus-hide-text-type (point) (point-max) 'headers))))))))
13620 (defsubst gnus-article-header-rank (header)
13621 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13622 (let ((list gnus-sorted-header-list)
13625 (when (string-match (car list) header)
13627 (setq list (cdr list))
13631 (defun gnus-article-header-less (h1 h2)
13632 "Say whether string H1 is \"less\" than string H2."
13633 (< (gnus-article-header-rank h1)
13634 (gnus-article-header-rank h2)))
13636 (defun gnus-article-hide-boring-headers (&optional arg)
13637 "Toggle hiding of headers that aren't very interesting.
13638 If given a negative prefix, always show; if given a positive prefix,
13641 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13643 (set-buffer gnus-article-buffer)
13645 (let ((buffer-read-only nil)
13646 (list gnus-boring-article-headers)
13647 (inhibit-point-motion-hooks t)
13649 (nnheader-narrow-to-headers)
13651 (setq elem (pop list))
13652 (goto-char (point-min))
13654 ;; Hide empty headers.
13656 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13658 (gnus-hide-text-type
13659 (progn (beginning-of-line) (point))
13662 (if (re-search-forward "^[^ \t]" nil t)
13663 (match-beginning 0)
13666 ;; Hide boring Newsgroups header.
13667 ((eq elem 'newsgroups)
13668 (when (equal (mail-fetch-field "newsgroups")
13669 (gnus-group-real-name gnus-newsgroup-name))
13670 (gnus-article-hide-header "newsgroups")))
13671 ((eq elem 'followup-to)
13672 (when (equal (mail-fetch-field "followup-to")
13673 (mail-fetch-field "newsgroups"))
13674 (gnus-article-hide-header "followup-to")))
13675 ((eq elem 'reply-to)
13676 (let ((from (mail-fetch-field "from"))
13677 (reply-to (mail-fetch-field "reply-to")))
13681 (nth 1 (funcall gnus-extract-address-components from))
13682 (nth 1 (funcall gnus-extract-address-components
13684 (gnus-article-hide-header "reply-to"))))
13686 (let ((date (mail-fetch-field "date")))
13688 (< (gnus-days-between date (current-time-string))
13690 (gnus-article-hide-header "date")))))))))))
13692 (defun gnus-article-hide-header (header)
13694 (goto-char (point-min))
13695 (when (re-search-forward (concat "^" header ":") nil t)
13696 (gnus-hide-text-type
13697 (progn (beginning-of-line) (point))
13700 (if (re-search-forward "^[^ \t]" nil t)
13701 (match-beginning 0)
13703 'boring-headers))))
13705 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
13706 (defun gnus-article-treat-overstrike ()
13707 "Translate overstrikes into bold text."
13710 (set-buffer gnus-article-buffer)
13711 (let ((buffer-read-only nil))
13712 (while (search-forward "\b" nil t)
13713 (let ((next (following-char))
13714 (previous (char-after (- (point) 2))))
13715 (cond ((eq next previous)
13716 (put-text-property (- (point) 2) (point) 'invisible t)
13717 (put-text-property (point) (1+ (point)) 'face 'bold))
13719 (put-text-property (1- (point)) (1+ (point)) 'invisible t)
13721 (- (point) 2) (1- (point)) 'face 'underline))
13723 (put-text-property (- (point) 2) (point) 'invisible t)
13725 (point) (1+ (point)) 'face 'underline))))))))
13727 (defun gnus-article-word-wrap ()
13728 "Format too long lines."
13731 (set-buffer gnus-article-buffer)
13732 (let ((buffer-read-only nil))
13734 (goto-char (point-min))
13735 (search-forward "\n\n" nil t)
13737 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
13738 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
13739 (adaptive-fill-mode t))
13740 (while (not (eobp))
13741 (and (>= (current-column) (min fill-column (window-width)))
13742 (/= (preceding-char) ?:)
13743 (fill-paragraph nil))
13744 (end-of-line 2))))))
13746 (defun gnus-article-remove-cr ()
13747 "Remove carriage returns from an article."
13750 (set-buffer gnus-article-buffer)
13751 (let ((buffer-read-only nil))
13752 (goto-char (point-min))
13753 (while (search-forward "\r" nil t)
13754 (replace-match "" t t)))))
13756 (defun gnus-article-remove-trailing-blank-lines ()
13757 "Remove all trailing blank lines from the article."
13760 (set-buffer gnus-article-buffer)
13761 (let ((buffer-read-only nil))
13762 (goto-char (point-max))
13766 (while (looking-at "^[ \t]*$")
13771 (defun gnus-article-display-x-face (&optional force)
13772 "Look for an X-Face header and display it if present."
13773 (interactive (list 'force))
13775 (set-buffer gnus-article-buffer)
13776 ;; Delete the old process, if any.
13777 (when (process-status "gnus-x-face")
13778 (delete-process "gnus-x-face"))
13779 (let ((inhibit-point-motion-hooks t)
13780 (case-fold-search nil)
13783 (nnheader-narrow-to-headers)
13784 (setq from (mail-fetch-field "from"))
13785 (goto-char (point-min))
13786 (when (and gnus-article-x-face-command
13788 ;; Check whether this face is censored.
13789 (not gnus-article-x-face-too-ugly)
13790 (and gnus-article-x-face-too-ugly from
13791 (not (string-match gnus-article-x-face-too-ugly
13793 ;; Has to be present.
13794 (re-search-forward "^X-Face: " nil t))
13795 ;; We now have the area of the buffer where the X-Face is stored.
13796 (let ((beg (point))
13797 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
13798 ;; We display the face.
13799 (if (symbolp gnus-article-x-face-command)
13800 ;; The command is a lisp function, so we call it.
13801 (if (gnus-functionp gnus-article-x-face-command)
13802 (funcall gnus-article-x-face-command beg end)
13803 (error "%s is not a function" gnus-article-x-face-command))
13804 ;; The command is a string, so we interpret the command
13805 ;; as a, well, command, and fork it off.
13806 (let ((process-connection-type nil))
13807 (process-kill-without-query
13809 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
13810 (process-send-region "gnus-x-face" beg end)
13811 (process-send-eof "gnus-x-face")))))))))
13813 (defun gnus-headers-decode-quoted-printable ()
13814 "Hack to remove QP encoding from headers."
13815 (let ((case-fold-search t)
13816 (inhibit-point-motion-hooks t)
13818 (goto-char (point-min))
13819 (while (re-search-forward "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
13820 (setq string (match-string 1))
13821 (narrow-to-region (match-beginning 0) (match-end 0))
13822 (delete-region (point-min) (point-max))
13824 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
13825 (subst-char-in-region (point-min) (point-max) ?_ ? )
13827 (goto-char (point-min)))))
13829 (defun gnus-article-de-quoted-unreadable (&optional force)
13830 "Do a naive translation of a quoted-printable-encoded article.
13831 This is in no way, shape or form meant as a replacement for real MIME
13832 processing, but is simply a stop-gap measure until MIME support is
13834 If FORCE, decode the article whether it is marked as quoted-printable
13836 (interactive (list 'force))
13838 (set-buffer gnus-article-buffer)
13839 (let ((case-fold-search t)
13840 (buffer-read-only nil)
13841 (type (gnus-fetch-field "content-transfer-encoding")))
13843 (and type (string-match "quoted-printable" type)))
13844 (gnus-headers-decode-quoted-printable)
13845 (goto-char (point-min))
13846 (search-forward "\n\n" nil 'move)
13847 (gnus-mime-decode-quoted-printable (point) (point-max))))))
13849 (defun gnus-mime-decode-quoted-printable (from to)
13850 "Decode Quoted-Printable in the region between FROM and TO."
13852 (while (search-forward "=" to t)
13853 (cond ((eq (following-char) ?\n)
13856 ((looking-at "[0-9A-F][0-9A-F]")
13858 (insert (hexl-hex-string-to-integer
13859 (buffer-substring (point) (+ 2 (point)))))
13863 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
13865 (defun gnus-article-hide-pgp (&optional arg)
13866 "Toggle hiding of any PGP headers and signatures in the current article.
13867 If given a negative prefix, always show; if given a positive prefix,
13870 (unless (gnus-article-check-hidden-text 'pgp arg)
13872 (set-buffer gnus-article-buffer)
13873 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
13874 buffer-read-only beg end)
13876 (goto-char (point-min))
13877 ;; Hide the "header".
13878 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
13879 (gnus-hide-text (match-beginning 0) (match-end 0) props))
13881 ;; Hide the actual signature.
13882 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
13883 (setq end (1+ (match-beginning 0)))
13886 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
13888 ;; Perhaps we shouldn't hide to the end of the buffer
13889 ;; if there is no end to the signature?
13892 ;; Hide "- " PGP quotation markers.
13893 (when (and beg end)
13894 (narrow-to-region beg end)
13895 (goto-char (point-min))
13896 (while (re-search-forward "^- " nil t)
13897 (gnus-hide-text (match-beginning 0) (match-end 0) props))
13900 (defun gnus-article-hide-signature (&optional arg)
13901 "Hide the signature in the current article.
13902 If given a negative prefix, always show; if given a positive prefix,
13905 (unless (gnus-article-check-hidden-text 'signature arg)
13907 (set-buffer gnus-article-buffer)
13909 (let ((buffer-read-only nil))
13910 (when (gnus-narrow-to-signature)
13911 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
13913 (defun gnus-article-strip-leading-blank-lines ()
13914 "Remove all blank lines from the beginning of the article."
13917 (set-buffer gnus-article-buffer)
13918 (let (buffer-read-only)
13919 (goto-char (point-min))
13920 (when (search-forward "\n\n" nil t)
13921 (while (looking-at "[ \t]$")
13922 (gnus-delete-line))))))
13924 (defun gnus-narrow-to-signature ()
13925 "Narrow to the signature."
13927 (goto-char (point-max))
13928 (when (re-search-backward gnus-signature-separator nil t)
13930 (when (or (null gnus-signature-limit)
13931 (and (numberp gnus-signature-limit)
13932 (< (- (point-max) (point)) gnus-signature-limit))
13933 (and (gnus-functionp gnus-signature-limit)
13934 (funcall gnus-signature-limit))
13935 (and (stringp gnus-signature-limit)
13936 (not (re-search-forward gnus-signature-limit nil t))))
13937 (narrow-to-region (point) (point-max))
13940 (defun gnus-article-check-hidden-text (type arg)
13941 "Return nil if hiding is necessary."
13943 (set-buffer gnus-article-buffer)
13944 (let ((hide (gnus-article-hidden-text-p type)))
13945 (cond ((or (and (null arg) (eq hide 'hidden))
13946 (and arg (< 0 (prefix-numeric-value arg))))
13947 (gnus-article-show-hidden-text type))
13949 (gnus-article-show-hidden-text type t))
13952 (defun gnus-article-hidden-text-p (type)
13953 "Say whether the current buffer contains hidden text of type TYPE."
13954 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
13956 (if (get-text-property pos 'invisible)
13960 (defun gnus-article-hide (&optional arg force)
13961 "Hide all the gruft in the current article.
13962 This means that PGP stuff, signatures, cited text and (some)
13963 headers will be hidden.
13964 If given a prefix, show the hidden text instead."
13965 (interactive (list current-prefix-arg 'force))
13966 (gnus-article-hide-headers arg)
13967 (gnus-article-hide-pgp arg)
13968 (gnus-article-hide-citation-maybe arg force)
13969 (gnus-article-hide-signature arg))
13971 (defun gnus-article-show-hidden-text (type &optional hide)
13972 "Show all hidden text of type TYPE.
13973 If HIDE, hide the text instead."
13975 (set-buffer gnus-article-buffer)
13976 (let ((buffer-read-only nil)
13977 (inhibit-point-motion-hooks t)
13979 (while (gnus-goto-char (text-property-any
13980 beg (point-max) 'gnus-type type))
13984 (gnus-hide-text beg (point) gnus-hidden-properties)
13985 (gnus-unhide-text beg (point)))
13986 (setq beg (point)))
13989 (defvar gnus-article-time-units
13990 `((year . ,(* 365.25 24 60 60))
13991 (week . ,(* 7 24 60 60))
13992 (day . ,(* 24 60 60))
13993 (hour . ,(* 60 60))
13996 "Mapping from time units to seconds.")
13998 (defun gnus-article-date-ut (&optional type highlight)
13999 "Convert DATE date to universal time in the current article.
14000 If TYPE is `local', convert to local time; if it is `lapsed', output
14001 how much time has lapsed since DATE."
14002 (interactive (list 'ut t))
14003 (let* ((header (or gnus-current-headers
14004 (gnus-summary-article-header) ""))
14005 (date (and (vectorp header) (mail-header-date header)))
14006 (date-regexp "^Date: \\|^X-Sent: ")
14007 (now (current-time))
14008 (inhibit-point-motion-hooks t))
14009 (when (and date (not (string= date "")))
14011 (set-buffer gnus-article-buffer)
14013 (nnheader-narrow-to-headers)
14014 (let ((buffer-read-only nil))
14015 ;; Delete any old Date headers.
14016 (if (zerop (message-remove-header date-regexp t))
14017 (beginning-of-line)
14018 (goto-char (point-max)))
14021 ;; Convert to the local timezone. We have to slap a
14022 ;; `condition-case' round the calls to the timezone
14023 ;; functions since they aren't particularly resistant to
14026 (concat "Date: " (condition-case ()
14027 (timezone-make-date-arpa-standard date)
14030 ;; Convert to Universal Time.
14034 (timezone-make-date-arpa-standard date nil "UT")
14037 ;; Get the original date from the article.
14038 ((eq type 'original)
14039 (concat "Date: " date "\n"))
14040 ;; Do an X-Sent lapsed format.
14042 ;; If the date is seriously mangled, the timezone
14043 ;; functions are liable to bug out, so we condition-case
14044 ;; the entire thing.
14049 (timezone-make-date-arpa-standard
14050 (current-time-string now)
14051 (current-time-zone now) "UT"))
14053 (timezone-make-date-arpa-standard
14056 (real-sec (+ (* (float (car real-time)) 65536)
14058 (sec (abs real-sec))
14064 ;; This is a bit convoluted, but basically we go
14065 ;; through the time units for years, weeks, etc,
14066 ;; and divide things to see whether that results
14067 ;; in positive answers.
14070 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14071 ;; The (remaining) seconds are too few to
14072 ;; be divided into this time unit.
14074 ;; It's big enough, so we output it.
14075 (setq sec (- sec (* num (cdr unit))))
14077 (concat (if prev ", " "") (int-to-string
14079 " " (symbol-name (car unit))
14080 (if (> num 1) "s" ""))
14082 gnus-article-time-units "")
14083 ;; If dates are odd, then it might appear like the
14084 ;; article was sent in the future.
14087 " in the future\n")))))
14089 (error "Unknown conversion type: %s" type)))))
14090 ;; Do highlighting.
14091 (when (and highlight (gnus-visual-p 'article-highlight 'highlight))
14092 (gnus-article-highlight-headers)))))))
14094 (defun gnus-article-date-local (&optional highlight)
14095 "Convert the current article date to the local timezone."
14096 (interactive (list t))
14097 (gnus-article-date-ut 'local highlight))
14099 (defun gnus-article-date-original (&optional highlight)
14100 "Convert the current article date to what it was originally.
14101 This is only useful if you have used some other date conversion
14102 function and want to see what the date was before converting."
14103 (interactive (list t))
14104 (gnus-article-date-ut 'original highlight))
14106 (defun gnus-article-date-lapsed (&optional highlight)
14107 "Convert the current article date to time lapsed since it was sent."
14108 (interactive (list t))
14109 (gnus-article-date-ut 'lapsed highlight))
14111 (defun gnus-article-maybe-highlight ()
14112 "Do some article highlighting if `gnus-visual' is non-nil."
14113 (if (gnus-visual-p 'article-highlight 'highlight)
14114 (gnus-article-highlight-some)))
14118 (defun gnus-output-to-rmail (file-name)
14119 "Append the current article to an Rmail file named FILE-NAME."
14121 ;; Most of these codes are borrowed from rmailout.el.
14122 (setq file-name (expand-file-name file-name))
14123 (setq rmail-default-rmail-file file-name)
14124 (let ((artbuf (current-buffer))
14125 (tmpbuf (get-buffer-create " *Gnus-output*")))
14127 (or (get-file-buffer file-name)
14128 (file-exists-p file-name)
14129 (if (gnus-yes-or-no-p
14130 (concat "\"" file-name "\" does not exist, create it? "))
14131 (let ((file-buffer (create-file-buffer file-name)))
14133 (set-buffer file-buffer)
14134 (rmail-insert-rmail-file-header)
14135 (let ((require-final-newline nil))
14136 (write-region (point-min) (point-max) file-name t 1)))
14137 (kill-buffer file-buffer))
14138 (error "Output file does not exist")))
14139 (set-buffer tmpbuf)
14140 (buffer-disable-undo (current-buffer))
14142 (insert-buffer-substring artbuf)
14143 (gnus-convert-article-to-rmail)
14144 ;; Decide whether to append to a file or to an Emacs buffer.
14145 (let ((outbuf (get-file-buffer file-name)))
14147 (append-to-file (point-min) (point-max) file-name)
14148 ;; File has been visited, in buffer OUTBUF.
14149 (set-buffer outbuf)
14150 (let ((buffer-read-only nil)
14151 (msg (and (boundp 'rmail-current-message)
14152 (symbol-value 'rmail-current-message))))
14153 ;; If MSG is non-nil, buffer is in RMAIL mode.
14156 (narrow-to-region (point-max) (point-max))))
14157 (insert-buffer-substring tmpbuf)
14160 (goto-char (point-min))
14162 (search-backward "\^_")
14163 (narrow-to-region (point) (point-max))
14164 (goto-char (1+ (point-min)))
14165 (rmail-count-new-messages t)
14166 (rmail-show-message msg)))))))
14167 (kill-buffer tmpbuf)))
14169 (defun gnus-output-to-file (file-name)
14170 "Append the current article to a file named FILE-NAME."
14171 (setq file-name (expand-file-name file-name))
14172 (let ((artbuf (current-buffer))
14173 (tmpbuf (get-buffer-create " *Gnus-output*")))
14175 (set-buffer tmpbuf)
14176 (buffer-disable-undo (current-buffer))
14178 (insert-buffer-substring artbuf)
14179 ;; Append newline at end of the buffer as separator, and then
14180 ;; save it to file.
14181 (goto-char (point-max))
14183 (append-to-file (point-min) (point-max) file-name))
14184 (kill-buffer tmpbuf)))
14186 (defun gnus-convert-article-to-rmail ()
14187 "Convert article in current buffer to Rmail message format."
14188 (let ((buffer-read-only nil))
14189 ;; Convert article directly into Babyl format.
14190 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14191 (goto-char (point-min))
14192 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14193 (while (search-forward "\n\^_" nil t) ;single char
14194 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14195 (goto-char (point-max))
14198 (defun gnus-narrow-to-page (&optional arg)
14199 "Narrow the article buffer to a page.
14200 If given a numerical ARG, move forward ARG pages."
14202 (setq arg (if arg (prefix-numeric-value arg) 0))
14204 (set-buffer gnus-article-buffer)
14205 (goto-char (point-min))
14207 (when (gnus-visual-p 'page-marker)
14208 (let ((buffer-read-only nil))
14209 (gnus-remove-text-with-property 'gnus-prev)
14210 (gnus-remove-text-with-property 'gnus-next)))
14213 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14215 (re-search-forward page-delimiter nil 'move arg)))
14216 (goto-char (match-end 0)))
14219 (if (re-search-forward page-delimiter nil 'move)
14220 (match-beginning 0)
14222 (when (and (gnus-visual-p 'page-marker)
14223 (not (= (point-min) 1)))
14225 (goto-char (point-min))
14226 (gnus-insert-prev-page-button)))
14227 (when (and (gnus-visual-p 'page-marker)
14228 (not (= (1- (point-max)) (buffer-size))))
14230 (goto-char (point-max))
14231 (gnus-insert-next-page-button)))))
14233 ;; Article mode commands
14235 (defun gnus-article-goto-next-page ()
14236 "Show the next page of the article."
14238 (when (gnus-article-next-page)
14239 (gnus-article-read-summary-keys nil ?n)))
14241 (defun gnus-article-goto-prev-page ()
14242 "Show the next page of the article."
14244 (if (bobp) (gnus-article-read-summary-keys nil ?n)
14245 (gnus-article-prev-page nil)))
14247 (defun gnus-article-next-page (&optional lines)
14248 "Show the next page of the current article.
14249 If end of article, return non-nil. Otherwise return nil.
14250 Argument LINES specifies lines to be scrolled up."
14252 (move-to-window-line -1)
14253 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14254 (if (save-excursion
14256 (and (pos-visible-in-window-p) ;Not continuation line.
14258 ;; Nothing in this page.
14259 (if (or (not gnus-break-pages)
14262 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14264 (gnus-narrow-to-page 1) ;Go to next page.
14266 ;; More in this page.
14270 ;; Long lines may cause an end-of-buffer error.
14271 (goto-char (point-max))))
14272 (move-to-window-line 0)
14275 (defun gnus-article-prev-page (&optional lines)
14276 "Show previous page of current article.
14277 Argument LINES specifies lines to be scrolled down."
14279 (move-to-window-line 0)
14280 (if (and gnus-break-pages
14282 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14284 (gnus-narrow-to-page -1) ;Go to previous page.
14285 (goto-char (point-max))
14289 (scroll-down lines)
14291 (move-to-window-line 0))))
14293 (defun gnus-article-refer-article ()
14294 "Read article specified by message-id around point."
14296 (let ((point (point)))
14297 (search-forward ">" nil t) ;Move point to end of "<....>".
14298 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14299 (let ((message-id (match-string 1)))
14301 (set-buffer gnus-summary-buffer)
14302 (gnus-summary-refer-article message-id))
14303 (goto-char (point))
14304 (error "No references around point"))))
14306 (defun gnus-article-show-summary ()
14307 "Reconfigure windows to show summary buffer."
14309 (gnus-configure-windows 'article)
14310 (gnus-summary-goto-subject gnus-current-article))
14312 (defun gnus-article-describe-briefly ()
14313 "Describe article mode commands briefly."
14316 (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")))
14318 (defun gnus-article-summary-command ()
14319 "Execute the last keystroke in the summary buffer."
14321 (let ((obuf (current-buffer))
14322 (owin (current-window-configuration))
14324 (switch-to-buffer gnus-summary-buffer 'norecord)
14325 (setq func (lookup-key (current-local-map) (this-command-keys)))
14326 (call-interactively func)
14328 (set-window-configuration owin)
14329 (set-window-point (get-buffer-window (current-buffer)) (point))))
14331 (defun gnus-article-summary-command-nosave ()
14332 "Execute the last keystroke in the summary buffer."
14335 (pop-to-buffer gnus-summary-buffer 'norecord)
14336 (setq func (lookup-key (current-local-map) (this-command-keys)))
14337 (call-interactively func)))
14339 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14340 "Read a summary buffer key sequence and execute it from the article buffer."
14343 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14344 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14348 (set-buffer gnus-summary-buffer)
14349 (push (or key last-command-event) unread-command-events)
14350 (setq keys (read-key-sequence nil)))
14353 (if (member keys nosaves)
14355 (pop-to-buffer gnus-summary-buffer 'norecord)
14356 (if (setq func (lookup-key (current-local-map) keys))
14357 (call-interactively func)
14359 (let ((obuf (current-buffer))
14360 (owin (current-window-configuration))
14363 (if not-restore-window
14364 (pop-to-buffer gnus-summary-buffer 'norecord)
14365 (switch-to-buffer gnus-summary-buffer 'norecord))
14366 (setq in-buffer (current-buffer))
14367 (if (setq func (lookup-key (current-local-map) keys))
14368 (call-interactively func)
14370 (when (eq in-buffer (current-buffer))
14372 (unless not-restore-window
14373 (set-window-configuration owin))
14374 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14378 ;;; Kill file handling.
14382 (defalias 'gnus-batch-kill 'gnus-batch-score)
14384 (defun gnus-batch-score ()
14385 "Run batched scoring.
14386 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14387 Newsgroups is a list of strings in Bnews format. If you want to score
14388 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14389 score the alt hierarchy, you'd say \"!alt.all\"."
14392 (gnus-newsrc-parse-options
14393 (apply (function concat)
14394 (mapcar (lambda (g) (concat g " "))
14395 command-line-args-left))))
14396 (gnus-expert-user t)
14397 (nnmail-spool-file nil)
14398 (gnus-use-dribble-file nil)
14399 (yes (car yes-and-no))
14400 (no (cdr yes-and-no))
14402 ;; Disable verbose message.
14403 gnus-novice-user gnus-large-newsgroup)
14404 ;; Eat all arguments.
14405 (setq command-line-args-left nil)
14408 ;; Apply kills to specified newsgroups in command line arguments.
14409 (setq newsrc (cdr gnus-newsrc-alist))
14411 (setq group (caar newsrc))
14412 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14413 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14415 (or (eq (car entry) t)
14416 (not (zerop (car entry)))))
14417 (if yes (string-match yes group) t)
14418 (or (null no) (not (string-match no group))))
14420 (gnus-summary-read-group group nil t nil t)
14421 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14422 (gnus-summary-exit))))
14423 (setq newsrc (cdr newsrc)))
14425 (switch-to-buffer gnus-group-buffer)
14426 (gnus-group-save-newsrc)))
14428 (defun gnus-apply-kill-file ()
14429 "Apply a kill file to the current newsgroup.
14430 Returns the number of articles marked as read."
14431 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14432 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14433 (gnus-apply-kill-file-internal)
14436 (defun gnus-kill-save-kill-buffer ()
14437 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14438 (when (get-file-buffer file)
14440 (set-buffer (get-file-buffer file))
14441 (and (buffer-modified-p) (save-buffer))
14442 (kill-buffer (current-buffer))))))
14444 (defvar gnus-kill-file-name "KILL"
14445 "Suffix of the kill files.")
14447 (defun gnus-newsgroup-kill-file (newsgroup)
14448 "Return the name of a kill file name for NEWSGROUP.
14449 If NEWSGROUP is nil, return the global kill file name instead."
14451 ;; The global KILL file is placed at top of the directory.
14452 ((or (null newsgroup)
14453 (string-equal newsgroup ""))
14454 (expand-file-name gnus-kill-file-name
14455 (or gnus-kill-files-directory "~/News")))
14456 ;; Append ".KILL" to newsgroup name.
14457 ((gnus-use-long-file-name 'not-kill)
14458 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14459 "." gnus-kill-file-name)
14460 (or gnus-kill-files-directory "~/News")))
14461 ;; Place "KILL" under the hierarchical directory.
14463 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14464 "/" gnus-kill-file-name)
14465 (or gnus-kill-files-directory "~/News")))))
14472 (defvar gnus-dribble-ignore nil)
14473 (defvar gnus-dribble-eval-file nil)
14475 (defun gnus-dribble-file-name ()
14476 "Return the dribble file for the current .newsrc."
14478 (if gnus-dribble-directory
14479 (concat (file-name-as-directory gnus-dribble-directory)
14480 (file-name-nondirectory gnus-current-startup-file))
14481 gnus-current-startup-file)
14484 (defun gnus-dribble-enter (string)
14485 "Enter STRING into the dribble buffer."
14486 (if (and (not gnus-dribble-ignore)
14487 gnus-dribble-buffer
14488 (buffer-name gnus-dribble-buffer))
14489 (let ((obuf (current-buffer)))
14490 (set-buffer gnus-dribble-buffer)
14491 (insert string "\n")
14492 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14493 (set-buffer obuf))))
14495 (defun gnus-dribble-read-file ()
14496 "Read the dribble file from disk."
14497 (let ((dribble-file (gnus-dribble-file-name)))
14499 (set-buffer (setq gnus-dribble-buffer
14501 (file-name-nondirectory dribble-file))))
14502 (gnus-add-current-to-buffer-list)
14504 (setq buffer-file-name dribble-file)
14506 (buffer-disable-undo (current-buffer))
14507 (bury-buffer (current-buffer))
14508 (set-buffer-modified-p nil)
14509 (let ((auto (make-auto-save-file-name))
14510 (gnus-dribble-ignore t))
14511 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14512 ;; Load whichever file is newest -- the auto save file
14513 ;; or the "real" file.
14514 (if (file-newer-than-file-p auto dribble-file)
14515 (insert-file-contents auto)
14516 (insert-file-contents dribble-file))
14517 (unless (zerop (buffer-size))
14518 (set-buffer-modified-p t))
14519 ;; Set the file modes to reflect the .newsrc file modes.
14521 (when (file-exists-p gnus-current-startup-file)
14522 (set-file-modes dribble-file
14523 (file-modes gnus-current-startup-file)))
14524 ;; Possibly eval the file later.
14525 (when (gnus-y-or-n-p
14526 "Auto-save file exists. Do you want to read it? ")
14527 (setq gnus-dribble-eval-file t)))))))
14529 (defun gnus-dribble-eval-file ()
14530 (if (not gnus-dribble-eval-file)
14532 (setq gnus-dribble-eval-file nil)
14534 (let ((gnus-dribble-ignore t))
14535 (set-buffer gnus-dribble-buffer)
14536 (eval-buffer (current-buffer))))))
14538 (defun gnus-dribble-delete-file ()
14539 (if (file-exists-p (gnus-dribble-file-name))
14540 (delete-file (gnus-dribble-file-name)))
14541 (if gnus-dribble-buffer
14543 (set-buffer gnus-dribble-buffer)
14544 (let ((auto (make-auto-save-file-name)))
14545 (if (file-exists-p auto)
14546 (delete-file auto))
14548 (set-buffer-modified-p nil)))))
14550 (defun gnus-dribble-save ()
14551 (if (and gnus-dribble-buffer
14552 (buffer-name gnus-dribble-buffer))
14554 (set-buffer gnus-dribble-buffer)
14557 (defun gnus-dribble-clear ()
14559 (if (gnus-buffer-exists-p gnus-dribble-buffer)
14561 (set-buffer gnus-dribble-buffer)
14563 (set-buffer-modified-p nil)
14564 (setq buffer-saved-size (buffer-size))))))
14568 ;;; Server Communication
14571 (defun gnus-start-news-server (&optional confirm)
14572 "Open a method for getting news.
14573 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14575 (if gnus-current-select-method
14576 ;; Stream is already opened.
14578 ;; Open NNTP server.
14579 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14582 ;; Read server name with completion.
14583 (setq gnus-nntp-server
14584 (completing-read "NNTP server: "
14585 (mapcar (lambda (server) (list server))
14586 (cons (list gnus-nntp-server)
14587 gnus-secondary-servers))
14588 nil nil gnus-nntp-server))))
14590 (if (and gnus-nntp-server
14591 (stringp gnus-nntp-server)
14592 (not (string= gnus-nntp-server "")))
14593 (setq gnus-select-method
14594 (cond ((or (string= gnus-nntp-server "")
14595 (string= gnus-nntp-server "::"))
14596 (list 'nnspool (system-name)))
14597 ((string-match "^:" gnus-nntp-server)
14598 (list 'nnmh gnus-nntp-server
14599 (list 'nnmh-directory
14600 (file-name-as-directory
14602 (concat "~/" (substring
14603 gnus-nntp-server 1)))))
14604 (list 'nnmh-get-new-mail nil)))
14606 (list 'nntp gnus-nntp-server)))))
14608 (setq how (car gnus-select-method))
14609 (cond ((eq how 'nnspool)
14611 (gnus-message 5 "Looking up local news spool..."))
14614 (gnus-message 5 "Looking up mh spool..."))
14617 (setq gnus-current-select-method gnus-select-method)
14618 (run-hooks 'gnus-open-server-hook)
14620 ;; gnus-open-server-hook might have opened it
14621 (gnus-server-opened gnus-select-method)
14622 (gnus-open-server gnus-select-method)
14625 "%s (%s) open error: '%s'. Continue? "
14626 (car gnus-select-method) (cadr gnus-select-method)
14627 (gnus-status-message gnus-select-method)))
14629 (gnus-message 1 "Couldn't open server on %s"
14630 (nth 1 gnus-select-method))
14634 (defun gnus-check-group (group)
14635 "Try to make sure that the server where GROUP exists is alive."
14636 (let ((method (gnus-find-method-for-group group)))
14637 (or (gnus-server-opened method)
14638 (gnus-open-server method))))
14640 (defun gnus-check-server (&optional method silent)
14641 "Check whether the connection to METHOD is down.
14642 If METHOD is nil, use `gnus-select-method'.
14643 If it is down, start it up (again)."
14644 (let ((method (or method gnus-select-method)))
14645 ;; Transform virtual server names into select methods.
14646 (when (stringp method)
14647 (setq method (gnus-server-to-method method)))
14648 (if (gnus-server-opened method)
14649 ;; The stream is already opened.
14651 ;; Open the server.
14653 (gnus-message 5 "Opening %s server%s..." (car method)
14654 (if (equal (nth 1 method) "") ""
14655 (format " on %s" (nth 1 method)))))
14656 (run-hooks 'gnus-open-server-hook)
14658 (gnus-open-server method)
14662 (defun gnus-get-function (method function)
14663 "Return a function symbol based on METHOD and FUNCTION."
14664 ;; Translate server names into methods.
14666 (error "Attempted use of a nil select method"))
14667 (when (stringp method)
14668 (setq method (gnus-server-to-method method)))
14669 (let ((func (intern (format "%s-%s" (car method) function))))
14670 ;; If the functions isn't bound, we require the backend in
14672 (unless (fboundp func)
14673 (require (car method))
14674 (unless (fboundp func)
14675 ;; This backend doesn't implement this function.
14676 (error "No such function: %s" func)))
14681 ;;; Interface functions to the backends.
14684 (defun gnus-open-server (method)
14685 "Open a connection to METHOD."
14686 (when (stringp method)
14687 (setq method (gnus-server-to-method method)))
14688 (let ((elem (assoc method gnus-opened-servers)))
14689 ;; If this method was previously denied, we just return nil.
14690 (if (eq (nth 1 elem) 'denied)
14692 (gnus-message 1 "Denied server")
14694 ;; Open the server.
14696 (funcall (gnus-get-function method 'open-server)
14697 (nth 1 method) (nthcdr 2 method))))
14698 ;; If this hasn't been opened before, we add it to the list.
14700 (setq elem (list method nil)
14701 gnus-opened-servers (cons elem gnus-opened-servers)))
14702 ;; Set the status of this server.
14703 (setcar (cdr elem) (if result 'ok 'denied))
14704 ;; Return the result from the "open" call.
14707 (defun gnus-close-server (method)
14708 "Close the connection to METHOD."
14709 (when (stringp method)
14710 (setq method (gnus-server-to-method method)))
14711 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
14713 (defun gnus-request-list (method)
14714 "Request the active file from METHOD."
14715 (when (stringp method)
14716 (setq method (gnus-server-to-method method)))
14717 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
14719 (defun gnus-request-list-newsgroups (method)
14720 "Request the newsgroups file from METHOD."
14721 (when (stringp method)
14722 (setq method (gnus-server-to-method method)))
14723 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
14725 (defun gnus-request-newgroups (date method)
14726 "Request all new groups since DATE from METHOD."
14727 (when (stringp method)
14728 (setq method (gnus-server-to-method method)))
14729 (funcall (gnus-get-function method 'request-newgroups)
14730 date (nth 1 method)))
14732 (defun gnus-server-opened (method)
14733 "Check whether a connection to METHOD has been opened."
14734 (when (stringp method)
14735 (setq method (gnus-server-to-method method)))
14736 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
14738 (defun gnus-status-message (method)
14739 "Return the status message from METHOD.
14740 If METHOD is a string, it is interpreted as a group name. The method
14741 this group uses will be queried."
14742 (let ((method (if (stringp method) (gnus-find-method-for-group method)
14744 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
14746 (defun gnus-request-group (group &optional dont-check method)
14747 "Request GROUP. If DONT-CHECK, no information is required."
14748 (let ((method (or method (gnus-find-method-for-group group))))
14749 (when (stringp method)
14750 (setq method (gnus-server-to-method method)))
14751 (funcall (gnus-get-function method 'request-group)
14752 (gnus-group-real-name group) (nth 1 method) dont-check)))
14754 (defun gnus-request-asynchronous (group &optional articles)
14755 "Request that GROUP behave asynchronously.
14756 ARTICLES is the `data' of the group."
14757 (let ((method (gnus-find-method-for-group group)))
14758 (funcall (gnus-get-function method 'request-asynchronous)
14759 (gnus-group-real-name group) (nth 1 method) articles)))
14761 (defun gnus-list-active-group (group)
14762 "Request active information on GROUP."
14763 (let ((method (gnus-find-method-for-group group))
14764 (func 'list-active-group))
14765 (when (gnus-check-backend-function func group)
14766 (funcall (gnus-get-function method func)
14767 (gnus-group-real-name group) (nth 1 method)))))
14769 (defun gnus-request-group-description (group)
14770 "Request a description of GROUP."
14771 (let ((method (gnus-find-method-for-group group))
14772 (func 'request-group-description))
14773 (when (gnus-check-backend-function func group)
14774 (funcall (gnus-get-function method func)
14775 (gnus-group-real-name group) (nth 1 method)))))
14777 (defun gnus-close-group (group)
14778 "Request the GROUP be closed."
14779 (let ((method (gnus-find-method-for-group group)))
14780 (funcall (gnus-get-function method 'close-group)
14781 (gnus-group-real-name group) (nth 1 method))))
14783 (defun gnus-retrieve-headers (articles group &optional fetch-old)
14784 "Request headers for ARTICLES in GROUP.
14785 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
14786 (let ((method (gnus-find-method-for-group group)))
14787 (if (and gnus-use-cache (numberp (car articles)))
14788 (gnus-cache-retrieve-headers articles group fetch-old)
14789 (funcall (gnus-get-function method 'retrieve-headers)
14790 articles (gnus-group-real-name group) (nth 1 method)
14793 (defun gnus-retrieve-groups (groups method)
14794 "Request active information on GROUPS from METHOD."
14795 (when (stringp method)
14796 (setq method (gnus-server-to-method method)))
14797 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
14799 (defun gnus-request-type (group &optional article)
14800 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14801 (let ((method (gnus-find-method-for-group group)))
14802 (if (not (gnus-check-backend-function 'request-type (car method)))
14804 (funcall (gnus-get-function method 'request-type)
14805 (gnus-group-real-name group) article))))
14807 (defun gnus-request-update-mark (group article mark)
14808 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14809 (let ((method (gnus-find-method-for-group group)))
14810 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
14812 (funcall (gnus-get-function method 'request-update-mark)
14813 (gnus-group-real-name group) article mark))))
14815 (defun gnus-request-article (article group &optional buffer)
14816 "Request the ARTICLE in GROUP.
14817 ARTICLE can either be an article number or an article Message-ID.
14818 If BUFFER, insert the article in that group."
14819 (let ((method (gnus-find-method-for-group group)))
14820 (funcall (gnus-get-function method 'request-article)
14821 article (gnus-group-real-name group) (nth 1 method) buffer)))
14823 (defun gnus-request-head (article group)
14824 "Request the head of ARTICLE in GROUP."
14825 (let ((method (gnus-find-method-for-group group)))
14826 (funcall (gnus-get-function method 'request-head)
14827 article (gnus-group-real-name group) (nth 1 method))))
14829 (defun gnus-request-body (article group)
14830 "Request the body of ARTICLE in GROUP."
14831 (let ((method (gnus-find-method-for-group group)))
14832 (funcall (gnus-get-function method 'request-body)
14833 article (gnus-group-real-name group) (nth 1 method))))
14835 (defun gnus-request-post (method)
14836 "Post the current buffer using METHOD."
14837 (when (stringp method)
14838 (setq method (gnus-server-to-method method)))
14839 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
14841 (defun gnus-request-scan (group method)
14842 "Request a SCAN being performed in GROUP from METHOD.
14843 If GROUP is nil, all groups on METHOD are scanned."
14844 (let ((method (if group (gnus-find-method-for-group group) method)))
14845 (funcall (gnus-get-function method 'request-scan)
14846 (and group (gnus-group-real-name group)) (nth 1 method))))
14848 (defsubst gnus-request-update-info (info method)
14849 "Request that METHOD update INFO."
14850 (when (stringp method)
14851 (setq method (gnus-server-to-method method)))
14852 (when (gnus-check-backend-function 'request-update-info (car method))
14853 (funcall (gnus-get-function method 'request-update-info)
14854 (gnus-group-real-name (gnus-info-group info))
14855 info (nth 1 method))))
14857 (defun gnus-request-expire-articles (articles group &optional force)
14858 (let ((method (gnus-find-method-for-group group)))
14859 (funcall (gnus-get-function method 'request-expire-articles)
14860 articles (gnus-group-real-name group) (nth 1 method)
14863 (defun gnus-request-move-article
14864 (article group server accept-function &optional last)
14865 (let ((method (gnus-find-method-for-group group)))
14866 (funcall (gnus-get-function method 'request-move-article)
14867 article (gnus-group-real-name group)
14868 (nth 1 method) accept-function last)))
14870 (defun gnus-request-accept-article (group &optional last method)
14871 ;; Make sure there's a newline at the end of the article.
14872 (when (stringp method)
14873 (setq method (gnus-server-to-method method)))
14874 (goto-char (point-max))
14877 (let ((func (if (symbolp group) group
14878 (car (or method (gnus-find-method-for-group group))))))
14879 (funcall (intern (format "%s-request-accept-article" func))
14880 (if (stringp group) (gnus-group-real-name group) group)
14883 (defun gnus-request-replace-article (article group buffer)
14884 (let ((func (car (gnus-find-method-for-group group))))
14885 (funcall (intern (format "%s-request-replace-article" func))
14886 article (gnus-group-real-name group) buffer)))
14888 (defun gnus-request-associate-buffer (group)
14889 (let ((method (gnus-find-method-for-group group)))
14890 (funcall (gnus-get-function method 'request-associate-buffer)
14891 (gnus-group-real-name group))))
14893 (defun gnus-request-restore-buffer (article group)
14894 "Request a new buffer restored to the state of ARTICLE."
14895 (let ((method (gnus-find-method-for-group group)))
14896 (funcall (gnus-get-function method 'request-restore-buffer)
14897 article (gnus-group-real-name group) (nth 1 method))))
14899 (defun gnus-request-create-group (group &optional method)
14900 (when (stringp method)
14901 (setq method (gnus-server-to-method method)))
14902 (let ((method (or method (gnus-find-method-for-group group))))
14903 (funcall (gnus-get-function method 'request-create-group)
14904 (gnus-group-real-name group) (nth 1 method))))
14906 (defun gnus-request-delete-group (group &optional force)
14907 (let ((method (gnus-find-method-for-group group)))
14908 (funcall (gnus-get-function method 'request-delete-group)
14909 (gnus-group-real-name group) force (nth 1 method))))
14911 (defun gnus-request-rename-group (group new-name)
14912 (let ((method (gnus-find-method-for-group group)))
14913 (funcall (gnus-get-function method 'request-rename-group)
14914 (gnus-group-real-name group)
14915 (gnus-group-real-name new-name) (nth 1 method))))
14917 (defun gnus-member-of-valid (symbol group)
14918 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
14919 (memq symbol (assoc
14920 (symbol-name (car (gnus-find-method-for-group group)))
14921 gnus-valid-select-methods)))
14923 (defun gnus-method-option-p (method option)
14924 "Return non-nil if select METHOD has OPTION as a parameter."
14925 (when (stringp method)
14926 (setq method (gnus-server-to-method method)))
14927 (memq option (assoc (format "%s" (car method))
14928 gnus-valid-select-methods)))
14930 (defun gnus-server-extend-method (group method)
14931 ;; This function "extends" a virtual server. If the server is
14932 ;; "hello", and the select method is ("hello" (my-var "something"))
14933 ;; in the group "alt.alt", this will result in a new virtual server
14934 ;; called "hello+alt.alt".
14936 (gnus-copy-sequence
14937 (if (equal (car method) "native") gnus-select-method
14938 (cdr (assoc (car method) gnus-server-alist))))))
14939 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
14940 (nconc entry (cdr method))))
14942 (defun gnus-find-method-for-group (group &optional info)
14943 "Find the select method that GROUP uses."
14944 (or gnus-override-method
14946 gnus-select-method)
14947 (let ((info (or info (gnus-get-info group)))
14950 (not (setq method (gnus-info-method info)))
14951 (equal method "native"))
14954 (cond ((stringp method)
14955 (gnus-server-to-method method))
14956 ((stringp (car method))
14957 (gnus-server-extend-method group method))
14960 (if (equal (cadr method) "")
14962 (gnus-server-add-address method))))))
14964 (defun gnus-check-backend-function (func group)
14965 "Check whether GROUP supports function FUNC."
14966 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
14968 (fboundp (intern (format "%s-%s" method func)))))
14970 (defun gnus-methods-using (feature)
14971 "Find all methods that have FEATURE."
14972 (let ((valids gnus-valid-select-methods)
14975 (if (memq feature (car valids))
14976 (setq outs (cons (car valids) outs)))
14977 (setq valids (cdr valids)))
14982 ;;; Active & Newsrc File Handling
14985 (defun gnus-setup-news (&optional rawfile level dont-connect)
14986 "Setup news information.
14987 If RAWFILE is non-nil, the .newsrc file will also be read.
14988 If LEVEL is non-nil, the news will be set up at level LEVEL."
14989 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
14992 ;; Clear some variables to re-initialize news information.
14993 (setq gnus-newsrc-alist nil
14994 gnus-active-hashtb nil)
14995 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
14996 (gnus-read-newsrc-file rawfile))
14998 (when (and (not (assoc "archive" gnus-server-alist))
14999 gnus-message-archive-method)
15000 (push (cons "archive" gnus-message-archive-method)
15001 gnus-server-alist))
15003 ;; If we don't read the complete active file, we fill in the
15005 (if (or (null gnus-read-active-file)
15006 (eq gnus-read-active-file 'some))
15007 (gnus-update-active-hashtb-from-killed))
15009 ;; Read the active file and create `gnus-active-hashtb'.
15010 ;; If `gnus-read-active-file' is nil, then we just create an empty
15011 ;; hash table. The partial filling out of the hash table will be
15012 ;; done in `gnus-get-unread-articles'.
15013 (and gnus-read-active-file
15015 (gnus-read-active-file))
15017 (or gnus-active-hashtb
15018 (setq gnus-active-hashtb (make-vector 4095 0)))
15020 ;; Initialize the cache.
15021 (when gnus-use-cache
15024 ;; Possibly eval the dribble file.
15025 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15027 (gnus-update-format-specifications)
15029 ;; See whether we need to read the description file.
15030 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15031 (not gnus-description-hashtb)
15033 gnus-read-active-file)
15034 (gnus-read-all-descriptions-files))
15036 ;; Find new newsgroups and treat them.
15037 (if (and init gnus-check-new-newsgroups (not level)
15038 (gnus-check-server gnus-select-method))
15039 (gnus-find-new-newsgroups))
15041 ;; We might read in new NoCeM messages here.
15042 (when gnus-use-nocem
15043 (gnus-nocem-scan-groups))
15045 ;; Find the number of unread articles in each non-dead group.
15046 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15047 (gnus-get-unread-articles level))
15049 (if (and init gnus-check-bogus-newsgroups
15050 gnus-read-active-file (not level)
15051 (gnus-server-opened gnus-select-method))
15052 (gnus-check-bogus-newsgroups))))
15054 (defun gnus-find-new-newsgroups (&optional arg)
15055 "Search for new newsgroups and add them.
15056 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15057 The `-n' option line from .newsrc is respected.
15058 If ARG (the prefix), use the `ask-server' method to query
15059 the server for new groups."
15061 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15062 (null gnus-read-active-file)
15063 (eq gnus-read-active-file 'some))
15064 'ask-server gnus-check-new-newsgroups)))
15065 (unless (gnus-check-first-time-used)
15066 (if (or (consp check)
15067 (eq check 'ask-server))
15068 ;; Ask the server for new groups.
15069 (gnus-ask-server-for-new-groups)
15070 ;; Go through the active hashtb and look for new groups.
15072 group new-newsgroups)
15073 (gnus-message 5 "Looking for new newsgroups...")
15074 (unless gnus-have-read-active-file
15075 (gnus-read-active-file))
15076 (setq gnus-newsrc-last-checked-date (current-time-string))
15077 (unless gnus-killed-hashtb
15078 (gnus-make-hashtable-from-killed))
15079 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15080 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15083 (if (or (null (setq group (symbol-name sym)))
15085 (null (symbol-value sym))
15086 (gnus-gethash group gnus-killed-hashtb)
15087 (gnus-gethash group gnus-newsrc-hashtb))
15089 (let ((do-sub (gnus-matches-options-n group)))
15091 ((eq do-sub 'subscribe)
15092 (setq groups (1+ groups))
15093 (gnus-sethash group group gnus-killed-hashtb)
15094 (funcall gnus-subscribe-options-newsgroup-method group))
15095 ((eq do-sub 'ignore)
15098 (setq groups (1+ groups))
15099 (gnus-sethash group group gnus-killed-hashtb)
15100 (if gnus-subscribe-hierarchical-interactive
15101 (setq new-newsgroups (cons group new-newsgroups))
15102 (funcall gnus-subscribe-newsgroup-method group)))))))
15103 gnus-active-hashtb)
15104 (when new-newsgroups
15105 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15106 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15108 (gnus-message 6 "%d new newsgroup%s arrived."
15109 groups (if (> groups 1) "s have" " has"))
15110 (gnus-message 6 "No new newsgroups.")))))))
15112 (defun gnus-matches-options-n (group)
15113 ;; Returns `subscribe' if the group is to be unconditionally
15114 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15115 ;; no match for the group.
15117 ;; First we check the two user variables.
15119 ((and gnus-options-subscribe
15120 (string-match gnus-options-subscribe group))
15122 ((and gnus-auto-subscribed-groups
15123 (string-match gnus-auto-subscribed-groups group))
15125 ((and gnus-options-not-subscribe
15126 (string-match gnus-options-not-subscribe group))
15128 ;; Then we go through the list that was retrieved from the .newsrc
15129 ;; file. This list has elements on the form
15130 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15131 ;; is in the reverse order of the options line) is returned.
15133 (let ((regs gnus-newsrc-options-n))
15135 (not (string-match (caar regs) group)))
15136 (setq regs (cdr regs)))
15137 (and regs (cdar regs))))))
15139 (defun gnus-ask-server-for-new-groups ()
15140 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15141 (methods (cons gnus-select-method
15143 (when gnus-message-archive-method
15146 (and (consp gnus-check-new-newsgroups)
15147 gnus-check-new-newsgroups)
15148 gnus-secondary-select-methods))))
15150 (new-date (current-time-string))
15151 group new-newsgroups got-new method hashtb
15152 gnus-override-subscribe-method)
15153 ;; Go through both primary and secondary select methods and
15154 ;; request new newsgroups.
15155 (while (setq method (gnus-server-get-method nil (pop methods)))
15156 (setq new-newsgroups nil)
15157 (setq gnus-override-subscribe-method method)
15158 (when (and (gnus-check-server method)
15159 (gnus-request-newgroups date method))
15162 (setq hashtb (gnus-make-hashtable 100))
15163 (set-buffer nntp-server-buffer)
15164 ;; Enter all the new groups into a hashtable.
15165 (gnus-active-to-gnus-format method hashtb 'ignore)))
15166 ;; Now all new groups from `method' are in `hashtb'.
15168 (lambda (group-sym)
15169 (if (or (null (setq group (symbol-name group-sym)))
15170 (null (symbol-value group-sym))
15171 (gnus-gethash group gnus-newsrc-hashtb)
15172 (member group gnus-zombie-list)
15173 (member group gnus-killed-list))
15174 ;; The group is already known.
15176 ;; Make this group active.
15177 (when (symbol-value group-sym)
15178 (gnus-set-active group (symbol-value group-sym)))
15179 ;; Check whether we want it or not.
15180 (let ((do-sub (gnus-matches-options-n group)))
15182 ((eq do-sub 'subscribe)
15184 (gnus-sethash group group gnus-killed-hashtb)
15185 (funcall gnus-subscribe-options-newsgroup-method group))
15186 ((eq do-sub 'ignore)
15190 (gnus-sethash group group gnus-killed-hashtb)
15191 (if gnus-subscribe-hierarchical-interactive
15192 (push group new-newsgroups)
15193 (funcall gnus-subscribe-newsgroup-method group)))))))
15195 (when new-newsgroups
15196 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15197 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15199 (gnus-message 6 "%d new newsgroup%s arrived."
15200 groups (if (> groups 1) "s have" " has")))
15201 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15204 (defun gnus-check-first-time-used ()
15205 (if (or (> (length gnus-newsrc-alist) 1)
15206 (file-exists-p gnus-startup-file)
15207 (file-exists-p (concat gnus-startup-file ".el"))
15208 (file-exists-p (concat gnus-startup-file ".eld")))
15210 (gnus-message 6 "First time user; subscribing you to default groups")
15211 (unless gnus-have-read-active-file
15212 (gnus-read-active-file))
15213 (setq gnus-newsrc-last-checked-date (current-time-string))
15214 (let ((groups gnus-default-subscribed-newsgroups)
15218 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15221 (if (null (setq group (symbol-name sym)))
15223 (let ((do-sub (gnus-matches-options-n group)))
15225 ((eq do-sub 'subscribe)
15226 (gnus-sethash group group gnus-killed-hashtb)
15227 (funcall gnus-subscribe-options-newsgroup-method group))
15228 ((eq do-sub 'ignore)
15231 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15232 gnus-active-hashtb)
15234 (if (gnus-active (car groups))
15235 (gnus-group-change-level
15236 (car groups) gnus-level-default-subscribed gnus-level-killed))
15237 (setq groups (cdr groups)))
15238 (gnus-group-make-help-group)
15239 (and gnus-novice-user
15240 (gnus-message 7 "`A k' to list killed groups"))))))
15242 (defun gnus-subscribe-group (group previous &optional method)
15243 (gnus-group-change-level
15245 (list t group gnus-level-default-subscribed nil nil method)
15247 gnus-level-default-subscribed gnus-level-killed previous t))
15249 ;; `gnus-group-change-level' is the fundamental function for changing
15250 ;; subscription levels of newsgroups. This might mean just changing
15251 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15252 ;; again, which subscribes/unsubscribes a group, which is equally
15253 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15254 ;; from 8-9 to 1-7 means that you remove the group from the list of
15255 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15256 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15257 ;; which is trivial.
15258 ;; ENTRY can either be a string (newsgroup name) or a list (if
15259 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15260 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15262 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15263 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15265 (defun gnus-group-change-level (entry level &optional oldlevel
15266 previous fromkilled)
15267 (let (group info active num)
15268 ;; Glean what info we can from the arguments
15270 (if fromkilled (setq group (nth 1 entry))
15271 (setq group (car (nth 2 entry))))
15272 (setq group entry))
15273 (if (and (stringp entry)
15275 (< oldlevel gnus-level-zombie))
15276 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15277 (if (and (not oldlevel)
15279 (setq oldlevel (gnus-info-level (nth 2 entry)))
15280 (setq oldlevel (or oldlevel 9)))
15281 (if (stringp previous)
15282 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15284 (if (and (>= oldlevel gnus-level-zombie)
15285 (gnus-gethash group gnus-newsrc-hashtb))
15286 ;; We are trying to subscribe a group that is already
15290 (or (gnus-ephemeral-group-p group)
15291 (gnus-dribble-enter
15292 (format "(gnus-group-change-level %S %S %S %S %S)"
15293 group level oldlevel (car (nth 2 previous)) fromkilled)))
15295 ;; Then we remove the newgroup from any old structures, if needed.
15296 ;; If the group was killed, we remove it from the killed or zombie
15297 ;; list. If not, and it is in fact going to be killed, we remove
15298 ;; it from the newsrc hash table and assoc.
15300 ((>= oldlevel gnus-level-zombie)
15301 (if (= oldlevel gnus-level-zombie)
15302 (setq gnus-zombie-list (delete group gnus-zombie-list))
15303 (setq gnus-killed-list (delete group gnus-killed-list))))
15305 (if (and (>= level gnus-level-zombie)
15308 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15310 (setcdr (gnus-gethash (car (nth 3 entry))
15311 gnus-newsrc-hashtb)
15313 (setcdr (cdr entry) (cdddr entry))))))
15315 ;; Finally we enter (if needed) the list where it is supposed to
15316 ;; go, and change the subscription level. If it is to be killed,
15317 ;; we enter it into the killed or zombie list.
15319 ((>= level gnus-level-zombie)
15320 ;; Remove from the hash table.
15321 (gnus-sethash group nil gnus-newsrc-hashtb)
15322 ;; We do not enter foreign groups into the list of dead
15324 (unless (gnus-group-foreign-p group)
15325 (if (= level gnus-level-zombie)
15326 (setq gnus-zombie-list (cons group gnus-zombie-list))
15327 (setq gnus-killed-list (cons group gnus-killed-list)))))
15329 ;; If the list is to be entered into the newsrc assoc, and
15330 ;; it was killed, we have to create an entry in the newsrc
15331 ;; hashtb format and fix the pointers in the newsrc assoc.
15332 (if (< oldlevel gnus-level-zombie)
15333 ;; It was alive, and it is going to stay alive, so we
15334 ;; just change the level and don't change any pointers or
15335 ;; hash table entries.
15336 (setcar (cdaddr entry) level)
15338 (setq info (cdr entry)
15340 (setq active (gnus-active group))
15342 (if active (- (1+ (cdr active)) (car active)) t))
15343 ;; Check whether the group is foreign. If so, the
15344 ;; foreign select method has to be entered into the
15346 (let ((method (or gnus-override-subscribe-method
15347 (gnus-group-method group))))
15348 (if (eq method gnus-select-method)
15349 (setq info (list group level nil))
15350 (setq info (list group level nil nil method)))))
15353 (let ((p gnus-newsrc-alist))
15357 (setq entry (cons info (cddr previous)))
15360 (setcdr (cdr previous) entry)
15361 (gnus-sethash group (cons num (cdr previous))
15362 gnus-newsrc-hashtb))
15363 (setcdr previous entry)
15364 (gnus-sethash group (cons num previous)
15365 gnus-newsrc-hashtb))
15367 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15368 (when gnus-group-change-level-function
15369 (funcall gnus-group-change-level-function group level oldlevel)))))
15371 (defun gnus-kill-newsgroup (newsgroup)
15372 "Obsolete function. Kills a newsgroup."
15373 (gnus-group-change-level
15374 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15376 (defun gnus-check-bogus-newsgroups (&optional confirm)
15377 "Remove bogus newsgroups.
15378 If CONFIRM is non-nil, the user has to confirm the deletion of every
15380 (let ((newsrc (cdr gnus-newsrc-alist))
15381 bogus group entry info)
15382 (gnus-message 5 "Checking bogus newsgroups...")
15383 (unless gnus-have-read-active-file
15384 (gnus-read-active-file))
15385 (when (member gnus-select-method gnus-have-read-active-file)
15386 ;; Find all bogus newsgroup that are subscribed.
15388 (setq info (pop newsrc)
15389 group (gnus-info-group info))
15390 (unless (or (gnus-active group) ; Active
15391 (gnus-info-method info) ; Foreign
15393 (not (gnus-y-or-n-p
15394 (format "Remove bogus newsgroup: %s " group)))))
15395 ;; Found a bogus newsgroup.
15396 (push group bogus)))
15397 ;; Remove all bogus subscribed groups by first killing them, and
15398 ;; then removing them from the list of killed groups.
15400 (when (setq entry (gnus-gethash (setq group (pop bogus))
15401 gnus-newsrc-hashtb))
15402 (gnus-group-change-level entry gnus-level-killed)
15403 (setq gnus-killed-list (delete group gnus-killed-list))))
15404 ;; Then we remove all bogus groups from the list of killed and
15405 ;; zombie groups. They are are removed without confirmation.
15406 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15409 (setq killed (symbol-value (car dead-lists)))
15411 (unless (gnus-active (setq group (pop killed)))
15412 ;; The group is bogus.
15413 ;; !!!Slow as hell.
15414 (set (car dead-lists)
15415 (delete group (symbol-value (car dead-lists))))))
15416 (setq dead-lists (cdr dead-lists))))
15417 (gnus-message 5 "Checking bogus newsgroups...done"))))
15419 (defun gnus-check-duplicate-killed-groups ()
15420 "Remove duplicates from the list of killed groups."
15422 (let ((killed gnus-killed-list))
15424 (gnus-message 9 "%d" (length killed))
15425 (setcdr killed (delete (car killed) (cdr killed)))
15426 (setq killed (cdr killed)))))
15428 ;; We want to inline a function from gnus-cache, so we cheat here:
15431 (require 'gnus-cache))
15433 (defun gnus-get-unread-articles-in-group (info active &optional update)
15435 ;; Allow the backend to update the info in the group.
15437 (gnus-request-update-info
15438 info (gnus-find-method-for-group (gnus-info-group info))))
15439 (gnus-activate-group (gnus-info-group info)))
15440 (let* ((range (gnus-info-read info))
15442 ;; If a cache is present, we may have to alter the active info.
15443 (when (and gnus-use-cache info)
15444 (inline (gnus-cache-possibly-alter-active
15445 (gnus-info-group info) active)))
15446 ;; Modify the list of read articles according to what articles
15447 ;; are available; then tally the unread articles and add the
15448 ;; number to the group hash table entry.
15450 ((zerop (cdr active))
15453 (setq num (- (1+ (cdr active)) (car active))))
15454 ((not (listp (cdr range)))
15455 ;; Fix a single (num . num) range according to the
15456 ;; active hash table.
15457 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15458 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15459 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15460 ;; Compute number of unread articles.
15461 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15463 ;; The read list is a list of ranges. Fix them according to
15464 ;; the active hash table.
15465 ;; First peel off any elements that are below the lower
15467 (while (and (cdr range)
15469 (or (and (atom (cadr range)) (cadr range))
15471 (if (numberp (car range))
15474 (or (and (numberp (cadr range))
15477 (setcdr (car range)
15478 (or (and (numberp (nth 1 range)) (nth 1 range))
15480 (setcdr range (cddr range)))
15481 ;; Adjust the first element to be the same as the lower limit.
15482 (if (and (not (atom (car range)))
15483 (< (cdar range) (car active)))
15484 (setcdr (car range) (1- (car active))))
15485 ;; Then we want to peel off any elements that are higher
15486 ;; than the upper active limit.
15487 (let ((srange range))
15488 ;; Go past all legal elements.
15489 (while (and (cdr srange)
15490 (<= (or (and (atom (cadr srange))
15492 (caadr srange)) (cdr active)))
15493 (setq srange (cdr srange)))
15495 ;; Nuke all remaining illegal elements.
15496 (setcdr srange nil))
15498 ;; Adjust the final element.
15499 (if (and (not (atom (car srange)))
15500 (> (cdar srange) (cdr active)))
15501 (setcdr (car srange) (cdr active))))
15502 ;; Compute the number of unread articles.
15504 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15506 (or (and (atom (car range)) (car range))
15508 (setq range (cdr range)))
15509 (setq num (max 0 (- (cdr active) num)))))
15510 ;; Set the number of unread articles.
15512 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
15515 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15516 ;; and compute how many unread articles there are in each group.
15517 (defun gnus-get-unread-articles (&optional level)
15518 (let* ((newsrc (cdr gnus-newsrc-alist))
15519 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15522 (cond ((and gnus-activate-foreign-newsgroups
15523 (not (numberp gnus-activate-foreign-newsgroups)))
15524 (1+ gnus-level-subscribed))
15525 ((numberp gnus-activate-foreign-newsgroups)
15526 gnus-activate-foreign-newsgroups)
15529 info group active method)
15530 (gnus-message 5 "Checking new news...")
15533 (setq active (gnus-active (setq group (gnus-info-group
15534 (setq info (pop newsrc))))))
15536 ;; Check newsgroups. If the user doesn't want to check them, or
15537 ;; they can't be checked (for instance, if the news server can't
15538 ;; be reached) we just set the number of unread articles in this
15539 ;; newsgroup to t. This means that Gnus thinks that there are
15540 ;; unread articles, but it has no idea how many.
15541 (if (and (setq method (gnus-info-method info))
15542 (not (gnus-server-equal
15544 (setq method (gnus-server-get-method nil method))))
15545 (not (gnus-secondary-method-p method)))
15546 ;; These groups are foreign. Check the level.
15547 (when (<= (gnus-info-level info) foreign-level)
15548 (setq active (gnus-activate-group group 'scan))
15549 (gnus-close-group group))
15551 ;; These groups are native or secondary.
15552 (when (and (<= (gnus-info-level info) level)
15553 (not gnus-read-active-file))
15554 (setq active (gnus-activate-group group 'scan))
15555 (gnus-close-group group)))
15558 (inline (gnus-get-unread-articles-in-group
15561 (fboundp (intern (concat (symbol-name (car method))
15562 "-request-scan"))))))
15563 ;; The group couldn't be reached, so we nix out the number of
15564 ;; unread articles and stuff.
15565 (gnus-set-active group nil)
15566 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
15568 (gnus-message 5 "Checking new news...done")))
15570 ;; Create a hash table out of the newsrc alist. The `car's of the
15571 ;; alist elements are used as keys.
15572 (defun gnus-make-hashtable-from-newsrc-alist ()
15573 (let ((alist gnus-newsrc-alist)
15574 (ohashtb gnus-newsrc-hashtb)
15576 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15578 (setq prev (setq gnus-newsrc-alist
15579 (if (equal (caar gnus-newsrc-alist)
15582 (cons (list "dummy.group" 0 nil) alist)))))
15586 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
15588 gnus-newsrc-hashtb)
15590 alist (cdr alist)))))
15592 (defun gnus-make-hashtable-from-killed ()
15593 "Create a hash table from the killed and zombie lists."
15594 (let ((lists '(gnus-killed-list gnus-zombie-list))
15596 (setq gnus-killed-hashtb
15597 (gnus-make-hashtable
15598 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15599 (while (setq list (symbol-value (pop lists)))
15601 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
15603 (defun gnus-activate-group (group &optional scan)
15604 ;; Check whether a group has been activated or not.
15605 ;; If SCAN, request a scan of that group as well.
15606 (let ((method (gnus-find-method-for-group group))
15608 (and (gnus-check-server method)
15609 ;; We escape all bugs and quit here to make it possible to
15610 ;; continue if a group is so out-there that it reports bugs
15614 (gnus-check-backend-function 'request-scan (car method))
15615 (gnus-request-scan group method))
15618 (gnus-request-group group)
15622 (set-buffer nntp-server-buffer)
15623 (goto-char (point-min))
15624 ;; Parse the result we got from `gnus-request-group'.
15625 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
15627 (goto-char (match-beginning 1))
15629 group (setq active (cons (read (current-buffer))
15630 (read (current-buffer)))))
15631 ;; Return the new active info.
15634 (defun gnus-update-read-articles (group unread)
15635 "Update the list of read and ticked articles in GROUP using the
15636 UNREAD and TICKED lists.
15637 Note: UNSELECTED has to be sorted over `<'.
15638 Returns whether the updating was successful."
15639 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
15640 (entry (gnus-gethash group gnus-newsrc-hashtb))
15641 (info (nth 2 entry))
15643 (unread (sort (copy-sequence unread) '<))
15645 (if (or (not info) (not active))
15646 ;; There is no info on this group if it was, in fact,
15647 ;; killed. Gnus stores no information on killed groups, so
15648 ;; there's nothing to be done.
15649 ;; One could store the information somewhere temporarily,
15650 ;; perhaps... Hmmm...
15652 ;; Remove any negative articles numbers.
15653 (while (and unread (< (car unread) 0))
15654 (setq unread (cdr unread)))
15655 ;; Remove any expired article numbers
15656 (while (and unread (< (car unread) (car active)))
15657 (setq unread (cdr unread)))
15658 ;; Compute the ranges of read articles by looking at the list of
15659 ;; unread articles.
15661 (if (/= (car unread) prev)
15662 (setq read (cons (if (= prev (1- (car unread))) prev
15663 (cons prev (1- (car unread)))) read)))
15664 (setq prev (1+ (car unread)))
15665 (setq unread (cdr unread)))
15666 (when (<= prev (cdr active))
15667 (setq read (cons (cons prev (cdr active)) read)))
15668 ;; Enter this list into the group info.
15669 (gnus-info-set-read
15670 info (if (> (length read) 1) (nreverse read) read))
15671 ;; Set the number of unread articles in gnus-newsrc-hashtb.
15672 (gnus-get-unread-articles-in-group info (gnus-active group))
15675 (defun gnus-make-articles-unread (group articles)
15676 "Mark ARTICLES in GROUP as unread."
15677 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
15678 (gnus-gethash (gnus-group-real-name group)
15679 gnus-newsrc-hashtb))))
15680 (ranges (gnus-info-read info))
15683 (when (gnus-member-of-range
15684 (setq article (pop articles)) ranges)
15685 (setq news (cons article news))))
15687 (gnus-info-set-read
15688 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
15689 (gnus-group-update-group group t))))
15691 ;; Enter all dead groups into the hashtb.
15692 (defun gnus-update-active-hashtb-from-killed ()
15693 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
15694 (lists (list gnus-killed-list gnus-zombie-list))
15697 (setq killed (car lists))
15699 (gnus-sethash (car killed) nil hashtb)
15700 (setq killed (cdr killed)))
15701 (setq lists (cdr lists)))))
15703 ;; Get the active file(s) from the backend(s).
15704 (defun gnus-read-active-file ()
15705 (gnus-group-set-mode-line)
15708 (if (gnus-check-server gnus-select-method)
15709 ;; The native server is available.
15710 (cons gnus-select-method gnus-secondary-select-methods)
15711 ;; The native server is down, so we just do the
15713 gnus-secondary-select-methods)
15714 ;; Also read from the archive server.
15715 (when gnus-message-archive-method
15716 (list "archive"))))
15718 (setq gnus-have-read-active-file nil)
15720 (set-buffer nntp-server-buffer)
15722 (let* ((method (if (stringp (car methods))
15723 (gnus-server-get-method nil (car methods))
15725 (where (nth 1 method))
15726 (mesg (format "Reading active file%s via %s..."
15727 (if (and where (not (zerop (length where))))
15728 (concat " from " where) "")
15730 (gnus-message 5 mesg)
15731 (when (gnus-check-server method)
15732 ;; Request that the backend scan its incoming messages.
15733 (and (gnus-check-backend-function 'request-scan (car method))
15734 (gnus-request-scan nil method))
15736 ((and (eq gnus-read-active-file 'some)
15737 (gnus-check-backend-function 'retrieve-groups (car method)))
15738 (let ((newsrc (cdr gnus-newsrc-alist))
15739 (gmethod (if (stringp method)
15740 (gnus-server-get-method nil method)
15743 (while (setq info (pop newsrc))
15744 (when (gnus-server-equal
15745 (gnus-find-method-for-group
15746 (gnus-info-group info) info)
15748 (push (gnus-group-real-name (gnus-info-group info))
15751 (gnus-check-server method)
15752 (setq list-type (gnus-retrieve-groups groups method))
15756 1 "Cannot read partial active file from %s server."
15760 ((eq list-type 'active)
15761 (gnus-active-to-gnus-format method gnus-active-hashtb))
15763 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
15765 (if (not (gnus-request-list method))
15767 (unless (equal method gnus-message-archive-method)
15768 (gnus-message 1 "Cannot read active file from %s server."
15771 (gnus-active-to-gnus-format method)
15772 ;; We mark this active file as read.
15773 (push method gnus-have-read-active-file)
15774 (gnus-message 5 "%sdone" mesg))))))
15775 (setq methods (cdr methods))))))
15777 ;; Read an active file and place the results in `gnus-active-hashtb'.
15778 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
15780 (setq method gnus-select-method))
15781 (let ((cur (current-buffer))
15783 (if (and gnus-active-hashtb
15784 (not (equal method gnus-select-method)))
15786 (setq gnus-active-hashtb
15787 (if (equal method gnus-select-method)
15788 (gnus-make-hashtable
15789 (count-lines (point-min) (point-max)))
15790 (gnus-make-hashtable 4096)))))))
15791 ;; Delete unnecessary lines.
15792 (goto-char (point-min))
15793 (while (search-forward "\nto." nil t)
15794 (delete-region (1+ (match-beginning 0))
15795 (progn (forward-line 1) (point))))
15796 (or (string= gnus-ignored-newsgroups "")
15798 (goto-char (point-min))
15799 (delete-matching-lines gnus-ignored-newsgroups)))
15800 ;; Make the group names readable as a lisp expression even if they
15801 ;; contain special characters.
15802 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
15803 (goto-char (point-max))
15804 (while (re-search-backward "[][';?()#]" nil t)
15806 ;; If these are groups from a foreign select method, we insert the
15807 ;; group prefix in front of the group names.
15808 (and method (not (gnus-server-equal
15809 (gnus-server-get-method nil method)
15810 (gnus-server-get-method nil gnus-select-method)))
15811 (let ((prefix (gnus-group-prefixed-name "" method)))
15812 (goto-char (point-min))
15813 (while (and (not (eobp))
15814 (progn (insert prefix)
15815 (zerop (forward-line 1)))))))
15816 ;; Store the active file in a hash table.
15817 (goto-char (point-min))
15818 (if (string-match "%[oO]" gnus-group-line-format)
15819 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
15820 ;; If we want information on moderated groups, we use this
15822 (let* ((mod-hashtb (make-vector 7 0))
15823 (m (intern "m" mod-hashtb))
15825 (while (not (eobp))
15826 (condition-case nil
15828 (narrow-to-region (point) (gnus-point-at-eol))
15829 (setq group (let ((obarray hashtb)) (read cur)))
15830 (if (and (numberp (setq max (read cur)))
15831 (numberp (setq min (read cur)))
15833 (skip-chars-forward " \t")
15835 (or (= (following-char) ?=)
15836 (= (following-char) ?x)
15837 (= (following-char) ?j)))))
15838 (set group (cons min max))
15840 ;; Enter moderated groups into a list.
15841 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
15842 (setq gnus-moderated-list
15843 (cons (symbol-name group) gnus-moderated-list))))
15850 ;; And if we do not care about moderation, we use this loop,
15851 ;; which is faster.
15852 (let (group max min)
15853 (while (not (eobp))
15856 (narrow-to-region (point) (gnus-point-at-eol))
15857 ;; group gets set to a symbol interned in the hash table
15858 ;; (what a hack!!) - jwz
15859 (setq group (let ((obarray hashtb)) (read cur)))
15860 (if (and (numberp (setq max (read cur)))
15861 (numberp (setq min (read cur)))
15863 (skip-chars-forward " \t")
15865 (or (= (following-char) ?=)
15866 (= (following-char) ?x)
15867 (= (following-char) ?j)))))
15868 (set group (cons min max))
15876 (gnus-message 3 "Warning - illegal active: %s"
15878 (gnus-point-at-bol) (gnus-point-at-eol)))))))
15880 (forward-line 1))))))
15882 (defun gnus-groups-to-gnus-format (method &optional hashtb)
15883 ;; Parse a "groups" active file.
15884 (let ((cur (current-buffer))
15886 (if (and method gnus-active-hashtb)
15888 (setq gnus-active-hashtb
15889 (gnus-make-hashtable
15890 (count-lines (point-min) (point-max)))))))
15891 (prefix (and method
15892 (not (gnus-server-equal
15893 (gnus-server-get-method nil method)
15894 (gnus-server-get-method nil gnus-select-method)))
15895 (gnus-group-prefixed-name "" method))))
15897 (goto-char (point-min))
15898 ;; We split this into to separate loops, one with the prefix
15899 ;; and one without to speed the reading up somewhat.
15901 (let (min max opoint group)
15902 (while (not (eobp))
15905 (read cur) (read cur)
15906 (setq min (read cur)
15909 (skip-chars-forward " \t")
15912 (set (let ((obarray hashtb)) (read cur))
15914 (error (and group (symbolp group) (set group nil))))
15916 (let (min max group)
15917 (while (not (eobp))
15919 (if (= (following-char) ?2)
15921 (read cur) (read cur)
15922 (setq min (read cur)
15924 (set (setq group (let ((obarray hashtb)) (read cur)))
15926 (error (and group (symbolp group) (set group nil))))
15927 (forward-line 1))))))
15929 (defun gnus-read-newsrc-file (&optional force)
15930 "Read startup file.
15931 If FORCE is non-nil, the .newsrc file is read."
15932 ;; Reset variables that might be defined in the .newsrc.eld file.
15933 (let ((variables gnus-variable-list))
15935 (set (car variables) nil)
15936 (setq variables (cdr variables))))
15937 (let* ((newsrc-file gnus-current-startup-file)
15938 (quick-file (concat newsrc-file ".el")))
15940 ;; We always load the .newsrc.eld file. If always contains
15941 ;; much information that can not be gotten from the .newsrc
15942 ;; file (ticked articles, killed groups, foreign methods, etc.)
15943 (gnus-read-newsrc-el-file quick-file)
15945 (if (and (file-exists-p gnus-current-startup-file)
15947 (and (file-newer-than-file-p newsrc-file quick-file)
15948 (file-newer-than-file-p newsrc-file
15949 (concat quick-file "d")))
15950 (not gnus-newsrc-alist)))
15951 ;; We read the .newsrc file. Note that if there if a
15952 ;; .newsrc.eld file exists, it has already been read, and
15953 ;; the `gnus-newsrc-hashtb' has been created. While reading
15954 ;; the .newsrc file, Gnus will only use the information it
15955 ;; can find there for changing the data already read -
15956 ;; ie. reading the .newsrc file will not trash the data
15957 ;; already read (except for read articles).
15959 (gnus-message 5 "Reading %s..." newsrc-file)
15960 (set-buffer (find-file-noselect newsrc-file))
15961 (buffer-disable-undo (current-buffer))
15962 (gnus-newsrc-to-gnus-format)
15963 (kill-buffer (current-buffer))
15964 (gnus-message 5 "Reading %s...done" newsrc-file)))
15966 ;; Read any slave files.
15968 (gnus-master-read-slave-newsrc)))))
15970 (defun gnus-read-newsrc-el-file (file)
15971 (let ((ding-file (concat file "d")))
15972 ;; We always, always read the .eld file.
15973 (gnus-message 5 "Reading %s..." ding-file)
15974 (let (gnus-newsrc-assoc)
15975 (condition-case nil
15976 (load ding-file t t t)
15978 (gnus-message 1 "Error in %s" ding-file)
15980 (when gnus-newsrc-assoc
15981 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
15982 (gnus-make-hashtable-from-newsrc-alist)
15983 (when (file-newer-than-file-p file ding-file)
15984 ;; Old format quick file
15985 (gnus-message 5 "Reading %s..." file)
15986 ;; The .el file is newer than the .eld file, so we read that one
15988 (gnus-read-old-newsrc-el-file file))))
15990 ;; Parse the old-style quick startup file
15991 (defun gnus-read-old-newsrc-el-file (file)
15992 (let (newsrc killed marked group m info)
15994 (let ((gnus-killed-assoc nil)
15995 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
15997 (condition-case nil
16000 (setq newsrc gnus-newsrc-assoc
16001 killed gnus-killed-assoc
16002 marked gnus-marked-assoc)))
16003 (setq gnus-newsrc-alist nil)
16004 (while (setq info (gnus-get-info (setq group (pop newsrc))))
16007 (gnus-info-set-read info (cddr group))
16008 (gnus-info-set-level
16009 info (if (nth 1 group) gnus-level-default-subscribed
16010 gnus-level-default-unsubscribed))
16011 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16014 (if (nth 1 group) gnus-level-default-subscribed
16015 gnus-level-default-unsubscribed)
16017 gnus-newsrc-alist))
16018 ;; Copy marks into info.
16019 (when (setq m (assoc (car group) marked))
16020 (unless (nthcdr 3 info)
16021 (nconc info (list nil)))
16022 (gnus-info-set-marks
16023 info (list (cons 'tick (gnus-compress-sequence
16024 (sort (cdr m) '<) t))))))
16025 (setq newsrc killed)
16027 (setcar newsrc (caar newsrc))
16028 (setq newsrc (cdr newsrc)))
16029 (setq gnus-killed-list killed))
16030 ;; The .el file version of this variable does not begin with
16031 ;; "options", while the .eld version does, so we just add it if it
16034 gnus-newsrc-options
16036 (and (not (string-match "^ *options" gnus-newsrc-options))
16037 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16038 (and (not (string-match "\n$" gnus-newsrc-options))
16039 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16040 ;; Finally, if we read some options lines, we parse them.
16041 (or (string= gnus-newsrc-options "")
16042 (gnus-newsrc-parse-options gnus-newsrc-options))))
16044 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16045 (gnus-make-hashtable-from-newsrc-alist)))
16047 (defun gnus-make-newsrc-file (file)
16048 "Make server dependent file name by catenating FILE and server host name."
16049 (let* ((file (expand-file-name file nil))
16050 (real-file (concat file "-" (nth 1 gnus-select-method))))
16051 (if (or (file-exists-p real-file)
16052 (file-exists-p (concat real-file ".el"))
16053 (file-exists-p (concat real-file ".eld")))
16056 (defun gnus-newsrc-to-gnus-format ()
16057 (setq gnus-newsrc-options "")
16058 (setq gnus-newsrc-options-n nil)
16060 (or gnus-active-hashtb
16061 (setq gnus-active-hashtb (make-vector 4095 0)))
16062 (let ((buf (current-buffer))
16063 (already-read (> (length gnus-newsrc-alist) 1))
16064 group subscribed options-symbol newsrc Options-symbol
16066 (goto-char (point-min))
16067 ;; We intern the symbol `options' in the active hashtb so that we
16068 ;; can `eq' against it later.
16069 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16070 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16072 (while (not (eobp))
16073 ;; We first read the first word on the line by narrowing and
16074 ;; then reading into `gnus-active-hashtb'. Most groups will
16075 ;; already exist in that hashtb, so this will save some string
16079 (progn (skip-chars-forward "^ \t!:\n") (point)))
16080 (goto-char (point-min))
16082 (and (/= (point-min) (point-max))
16083 (let ((obarray gnus-active-hashtb)) (read buf))))
16085 ;; Now, the symbol we have read is either `options' or a group
16086 ;; name. If it is an options line, we just add it to a string.
16088 ((or (eq symbol options-symbol)
16089 (eq symbol Options-symbol))
16090 (setq gnus-newsrc-options
16091 ;; This concating is quite inefficient, but since our
16092 ;; thorough studies show that approx 99.37% of all
16093 ;; .newsrc files only contain a single options line, we
16094 ;; don't give a damn, frankly, my dear.
16095 (concat gnus-newsrc-options
16097 (gnus-point-at-bol)
16098 ;; Options may continue on the next line.
16099 (or (and (re-search-forward "^[^ \t]" nil 'move)
16100 (progn (beginning-of-line) (point)))
16104 ;; Group names can be just numbers.
16105 (when (numberp symbol)
16106 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16107 (or (boundp symbol) (set symbol nil))
16108 ;; It was a group name.
16109 (setq subscribed (= (following-char) ?:)
16110 group (symbol-name symbol)
16113 ;; If the line ends here, this is clearly a buggy line, so
16114 ;; we put point a the beginning of line and let the cond
16115 ;; below do the error handling.
16116 (beginning-of-line)
16117 ;; We skip to the beginning of the ranges.
16118 (skip-chars-forward "!: \t"))
16119 ;; We are now at the beginning of the list of read articles.
16120 ;; We read them range by range.
16123 ((looking-at "[0-9]+")
16124 ;; We narrow and read a number instead of buffer-substring/
16125 ;; string-to-int because it's faster. narrow/widen is
16126 ;; faster than save-restriction/narrow, and save-restriction
16127 ;; produces a garbage object.
16129 (narrow-to-region (match-beginning 0) (match-end 0))
16132 ;; If the next character is a dash, then this is a range.
16133 (if (= (following-char) ?-)
16135 ;; We read the upper bound of the range.
16137 (if (not (looking-at "[0-9]+"))
16138 ;; This is a buggy line, by we pretend that
16139 ;; it's kinda OK. Perhaps the user should be
16141 (setq reads (cons num1 reads))
16146 (narrow-to-region (match-beginning 0)
16151 ;; It was just a simple number, so we add it to the
16153 (setq reads (cons num1 reads)))
16154 ;; If the next char in ?\n, then we have reached the end
16155 ;; of the line and return nil.
16156 (/= (following-char) ?\n))
16157 ((= (following-char) ?\n)
16158 ;; End of line, so we end.
16161 ;; Not numbers and not eol, so this might be a buggy
16164 ;; If it was eob instead of ?\n, we allow it.
16166 ;; The line was buggy.
16168 (gnus-message 3 "Mangled line: %s"
16169 (buffer-substring (gnus-point-at-bol)
16170 (gnus-point-at-eol)))
16174 ;; Skip past ", ". Spaces are illegal in these ranges, but
16175 ;; we allow them, because it's a common mistake to put a
16176 ;; space after the comma.
16177 (skip-chars-forward ", "))
16179 ;; We have already read .newsrc.eld, so we gently update the
16180 ;; data in the hash table with the information we have just
16183 (let ((info (gnus-get-info group))
16186 ;; There is an entry for this file in the alist.
16188 (gnus-info-set-read info (nreverse reads))
16189 ;; We update the level very gently. In fact, we
16190 ;; only change it if there's been a status change
16191 ;; from subscribed to unsubscribed, or vice versa.
16192 (setq level (gnus-info-level info))
16193 (cond ((and (<= level gnus-level-subscribed)
16195 (setq level (if reads
16196 gnus-level-default-unsubscribed
16197 (1+ gnus-level-default-unsubscribed))))
16198 ((and (> level gnus-level-subscribed) subscribed)
16199 (setq level gnus-level-default-subscribed)))
16200 (gnus-info-set-level info level))
16201 ;; This is a new group.
16202 (setq info (list group
16204 gnus-level-default-subscribed
16206 (1+ gnus-level-subscribed)
16207 gnus-level-default-unsubscribed))
16208 (nreverse reads))))
16209 (setq newsrc (cons info newsrc))))))
16212 (setq newsrc (nreverse newsrc))
16214 (if (not already-read)
16216 ;; We now have two newsrc lists - `newsrc', which is what we
16217 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16218 ;; what we've read from .newsrc.eld. We have to merge these
16219 ;; lists. We do this by "attaching" any (foreign) groups in the
16220 ;; gnus-newsrc-alist to the (native) group that precedes them.
16221 (let ((rc (cdr gnus-newsrc-alist))
16222 (prev gnus-newsrc-alist)
16225 (or (null (nth 4 (car rc))) ; It's a native group.
16226 (assoc (caar rc) newsrc) ; It's already in the alist.
16227 (if (setq entry (assoc (caar prev) newsrc))
16228 (setcdr (setq mentry (memq entry newsrc))
16229 (cons (car rc) (cdr mentry)))
16230 (setq newsrc (cons (car rc) newsrc))))
16234 (setq gnus-newsrc-alist newsrc)
16235 ;; We make the newsrc hashtb.
16236 (gnus-make-hashtable-from-newsrc-alist)
16238 ;; Finally, if we read some options lines, we parse them.
16239 (or (string= gnus-newsrc-options "")
16240 (gnus-newsrc-parse-options gnus-newsrc-options))))
16242 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16243 ;; The return value will be a list on the form
16244 ;; ((regexp1 . ignore)
16245 ;; (regexp2 . subscribe)...)
16246 ;; When handling new newsgroups, groups that match a `ignore' regexp
16247 ;; will be ignored, and groups that match a `subscribe' regexp will be
16248 ;; subscribed. A line like
16249 ;; options -n !all rec.all
16250 ;; will lead to a list that looks like
16251 ;; (("^rec\\..+" . subscribe)
16252 ;; ("^.+" . ignore))
16253 ;; So all "rec.*" groups will be subscribed, while all the other
16254 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16255 ;; different from "options -n rec.all !all".
16256 (defun gnus-newsrc-parse-options (options)
16259 (gnus-set-work-buffer)
16260 (insert (regexp-quote options))
16261 ;; First we treat all continuation lines.
16262 (goto-char (point-min))
16263 (while (re-search-forward "\n[ \t]+" nil t)
16264 (replace-match " " t t))
16265 ;; Then we transform all "all"s into ".+"s.
16266 (goto-char (point-min))
16267 (while (re-search-forward "\\ball\\b" nil t)
16268 (replace-match ".+" t t))
16269 (goto-char (point-min))
16270 ;; We remove all other options than the "-n" ones.
16271 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16272 (replace-match " ")
16274 (goto-char (point-min))
16276 ;; We are only interested in "options -n" lines - we
16277 ;; ignore the other option lines.
16278 (while (re-search-forward "[ \t]-n" nil t)
16280 (or (save-excursion
16281 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16283 (gnus-point-at-eol)))
16284 ;; Search for all "words"...
16285 (while (re-search-forward "[^ \t,\n]+" eol t)
16286 (if (= (char-after (match-beginning 0)) ?!)
16287 ;; If the word begins with a bang (!), this is a "not"
16288 ;; spec. We put this spec (minus the bang) and the
16289 ;; symbol `ignore' into the list.
16290 (setq out (cons (cons (concat
16291 "^" (buffer-substring
16292 (1+ (match-beginning 0))
16295 ;; There was no bang, so this is a "yes" spec.
16296 (setq out (cons (cons (concat "^" (match-string 0))
16297 'subscribe) out)))))
16299 (setq gnus-newsrc-options-n out))))
16301 (defun gnus-save-newsrc-file (&optional force)
16302 "Save .newsrc file."
16303 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16304 ;; from the variable gnus-newsrc-alist.
16305 (when (and (or gnus-newsrc-alist gnus-killed-list)
16306 gnus-current-startup-file)
16308 (if (and (or gnus-use-dribble-file gnus-slave)
16310 (or (not gnus-dribble-buffer)
16311 (not (buffer-name gnus-dribble-buffer))
16312 (zerop (save-excursion
16313 (set-buffer gnus-dribble-buffer)
16315 (gnus-message 4 "(No changes need to be saved)")
16316 (run-hooks 'gnus-save-newsrc-hook)
16318 (gnus-slave-save-newsrc)
16320 (when gnus-save-newsrc-file
16321 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16322 (gnus-gnus-to-newsrc-format)
16323 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16324 ;; Save .newsrc.eld.
16325 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16326 (make-local-variable 'version-control)
16327 (setq version-control 'never)
16328 (setq buffer-file-name
16329 (concat gnus-current-startup-file ".eld"))
16330 (gnus-add-current-to-buffer-list)
16331 (buffer-disable-undo (current-buffer))
16333 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16334 (gnus-gnus-to-quick-newsrc-format)
16335 (run-hooks 'gnus-save-quick-newsrc-hook)
16337 (kill-buffer (current-buffer))
16339 5 "Saving %s.eld...done" gnus-current-startup-file))
16340 (gnus-dribble-delete-file)))))
16342 (defun gnus-gnus-to-quick-newsrc-format ()
16343 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16344 (insert ";; Gnus startup file.\n")
16345 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16346 (insert ";; to read .newsrc.\n")
16347 (insert "(setq gnus-newsrc-file-version "
16348 (prin1-to-string gnus-version) ")\n")
16350 (if gnus-save-killed-list gnus-variable-list
16351 ;; Remove the `gnus-killed-list' from the list of variables
16352 ;; to be saved, if required.
16353 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16354 ;; Peel off the "dummy" group.
16355 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16357 ;; Insert the variables into the file.
16359 (when (and (boundp (setq variable (pop variables)))
16360 (symbol-value variable))
16361 (insert "(setq " (symbol-name variable) " '")
16362 (prin1 (symbol-value variable) (current-buffer))
16365 (defun gnus-gnus-to-newsrc-format ()
16366 ;; Generate and save the .newsrc file.
16368 (set-buffer (create-file-buffer gnus-current-startup-file))
16369 (let ((newsrc (cdr gnus-newsrc-alist))
16370 (standard-output (current-buffer))
16371 info ranges range method)
16372 (setq buffer-file-name gnus-current-startup-file)
16373 (buffer-disable-undo (current-buffer))
16376 (if gnus-newsrc-options (insert gnus-newsrc-options))
16377 ;; Write subscribed and unsubscribed.
16378 (while (setq info (pop newsrc))
16379 ;; Don't write foreign groups to .newsrc.
16380 (when (or (null (setq method (gnus-info-method info)))
16381 (equal method "native")
16382 (gnus-server-equal method gnus-select-method))
16383 (insert (gnus-info-group info)
16384 (if (> (gnus-info-level info) gnus-level-subscribed)
16386 (when (setq ranges (gnus-info-read info))
16388 (if (not (listp (cdr ranges)))
16389 (if (= (car ranges) (cdr ranges))
16390 (princ (car ranges))
16391 (princ (car ranges))
16393 (princ (cdr ranges)))
16394 (while (setq range (pop ranges))
16395 (if (or (atom range) (= (car range) (cdr range)))
16396 (princ (or (and (atom range) range) (car range)))
16397 (princ (car range))
16399 (princ (cdr range)))
16400 (if ranges (insert ",")))))
16402 (make-local-variable 'version-control)
16403 (setq version-control 'never)
16404 ;; It has been reported that sometime the modtime on the .newsrc
16405 ;; file seems to be off. We really do want to overwrite it, so
16406 ;; we clear the modtime here before saving. It's a bit odd,
16408 ;; sometimes the modtime clear isn't sufficient. most brute force:
16409 ;; delete the silly thing entirely first. but this fails to provide
16410 ;; such niceties as .newsrc~ creation.
16411 (if gnus-modtime-botch
16412 (delete-file gnus-startup-file)
16413 (clear-visited-file-modtime))
16414 (run-hooks 'gnus-save-standard-newsrc-hook)
16416 (kill-buffer (current-buffer)))))
16420 ;;; Slave functions.
16423 (defun gnus-slave-save-newsrc ()
16425 (set-buffer gnus-dribble-buffer)
16427 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16428 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16430 (defun gnus-master-read-slave-newsrc ()
16433 (file-name-directory gnus-current-startup-file)
16437 (file-name-nondirectory gnus-current-startup-file)
16441 (if (not slave-files)
16442 () ; There are no slave files to read.
16443 (gnus-message 7 "Reading slave newsrcs...")
16445 (set-buffer (get-buffer-create " *gnus slave*"))
16446 (buffer-disable-undo (current-buffer))
16448 (sort (mapcar (lambda (file)
16449 (list (nth 5 (file-attributes file)) file))
16452 (or (< (caar f1) (caar f2))
16453 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16456 (setq file (nth 1 (car slave-files)))
16457 (insert-file-contents file)
16458 (if (condition-case ()
16460 (eval-buffer (current-buffer))
16463 (gnus-message 3 "Possible error in %s" file)
16467 (or gnus-slave ; Slaves shouldn't delete these files.
16471 (setq slave-files (cdr slave-files))))
16472 (gnus-message 7 "Reading slave newsrcs...done"))))
16476 ;;; Group description.
16479 (defun gnus-read-all-descriptions-files ()
16480 (let ((methods (cons gnus-select-method
16482 (when gnus-message-archive-method
16484 gnus-secondary-select-methods))))
16486 (gnus-read-descriptions-file (car methods))
16487 (setq methods (cdr methods)))
16490 (defun gnus-read-descriptions-file (&optional method)
16491 (let ((method (or method gnus-select-method)))
16492 (when (stringp method)
16493 (setq method (gnus-server-to-method method)))
16494 ;; We create the hashtable whether we manage to read the desc file
16495 ;; to avoid trying to re-read after a failed read.
16496 (or gnus-description-hashtb
16497 (setq gnus-description-hashtb
16498 (gnus-make-hashtable (length gnus-active-hashtb))))
16499 ;; Mark this method's desc file as read.
16500 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16501 gnus-description-hashtb)
16503 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16505 ((not (gnus-check-server method))
16506 (gnus-message 1 "Couldn't open server")
16508 ((not (gnus-request-list-newsgroups method))
16509 (gnus-message 1 "Couldn't read newsgroups descriptions")
16515 (set-buffer nntp-server-buffer)
16516 (goto-char (point-min))
16517 (if (or (search-forward "\n.\n" nil t)
16518 (goto-char (point-max)))
16520 (beginning-of-line)
16521 (narrow-to-region (point-min) (point))))
16522 (goto-char (point-min))
16523 (while (not (eobp))
16524 ;; If we get an error, we set group to 0, which is not a
16528 (let ((obarray gnus-description-hashtb))
16529 ;; Group is set to a symbol interned in this
16531 (read nntp-server-buffer))
16533 (skip-chars-forward " \t")
16534 ;; ... which leads to this line being effectively ignored.
16535 (and (symbolp group)
16536 (set group (buffer-substring
16537 (point) (progn (end-of-line) (point)))))
16538 (forward-line 1))))
16539 (gnus-message 5 "Reading descriptions file...done")
16542 (defun gnus-group-get-description (group)
16543 "Get the description of a group by sending XGTITLE to the server."
16544 (when (gnus-request-group-description group)
16546 (set-buffer nntp-server-buffer)
16547 (goto-char (point-min))
16548 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
16549 (match-string 1)))))
16553 ;;; Buffering of read articles.
16556 (defvar gnus-backlog-buffer " *Gnus Backlog*")
16557 (defvar gnus-backlog-articles nil)
16558 (defvar gnus-backlog-hashtb nil)
16560 (defun gnus-backlog-buffer ()
16561 "Return the backlog buffer."
16562 (or (get-buffer gnus-backlog-buffer)
16564 (set-buffer (get-buffer-create gnus-backlog-buffer))
16565 (buffer-disable-undo (current-buffer))
16566 (setq buffer-read-only t)
16567 (gnus-add-current-to-buffer-list)
16568 (get-buffer gnus-backlog-buffer))))
16570 (defun gnus-backlog-setup ()
16571 "Initialize backlog variables."
16572 (unless gnus-backlog-hashtb
16573 (setq gnus-backlog-hashtb (make-vector 1023 0))))
16575 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
16577 (defun gnus-backlog-shutdown ()
16578 "Clear all backlog variables and buffers."
16579 (when (get-buffer gnus-backlog-buffer)
16580 (kill-buffer gnus-backlog-buffer))
16581 (setq gnus-backlog-hashtb nil
16582 gnus-backlog-articles nil))
16584 (defun gnus-backlog-enter-article (group number buffer)
16585 (gnus-backlog-setup)
16586 (let ((ident (intern (concat group ":" (int-to-string number))
16587 gnus-backlog-hashtb))
16589 (if (memq ident gnus-backlog-articles)
16590 () ; It's already kept.
16591 ;; Remove the oldest article, if necessary.
16592 (and (numberp gnus-keep-backlog)
16593 (>= (length gnus-backlog-articles) gnus-keep-backlog)
16594 (gnus-backlog-remove-oldest-article))
16595 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
16596 ;; Insert the new article.
16598 (set-buffer (gnus-backlog-buffer))
16599 (let (buffer-read-only)
16600 (goto-char (point-max))
16601 (or (bolp) (insert "\n"))
16603 (insert-buffer-substring buffer)
16604 ;; Tag the beginning of the article with the ident.
16605 (put-text-property b (1+ b) 'gnus-backlog ident))))))
16607 (defun gnus-backlog-remove-oldest-article ()
16609 (set-buffer (gnus-backlog-buffer))
16610 (goto-char (point-min))
16611 (if (zerop (buffer-size))
16612 () ; The buffer is empty.
16613 (let ((ident (get-text-property (point) 'gnus-backlog))
16615 ;; Remove the ident from the list of articles.
16617 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16618 ;; Delete the article itself.
16620 (point) (next-single-property-change
16621 (1+ (point)) 'gnus-backlog nil (point-max)))))))
16623 (defun gnus-backlog-request-article (group number buffer)
16624 (when (numberp number)
16625 (gnus-backlog-setup)
16626 (let ((ident (intern (concat group ":" (int-to-string number))
16627 gnus-backlog-hashtb))
16629 (when (memq ident gnus-backlog-articles)
16630 ;; It was in the backlog.
16632 (set-buffer (gnus-backlog-buffer))
16633 (if (not (setq beg (text-property-any
16634 (point-min) (point-max) 'gnus-backlog
16636 ;; It wasn't in the backlog after all.
16638 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16639 ;; Find the end (i. e., the beginning of the next article).
16641 (next-single-property-change
16642 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
16643 (let ((buffer-read-only nil))
16645 (insert-buffer-substring gnus-backlog-buffer beg end)
16648 ;; Allow redefinition of Gnus functions.
16650 (gnus-ems-redefine)
16654 ;;; gnus.el ends here