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))
38 (eval-when-compile (require 'cl))
41 (defvar gnus-directory (or (getenv "SAVEDIR") "~/News/")
42 "*Directory variable from which all other Gnus file variables are derived.")
44 ;; Site dependent variables. These variables should be defined in
47 (defvar gnus-default-nntp-server nil
48 "Specify a default NNTP server.
49 This variable should be defined in paths.el, and should never be set
51 If you want to change servers, you should use `gnus-select-method'.
52 See the documentation to that variable.")
54 (defvar gnus-backup-default-subscribed-newsgroups
55 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
56 "Default default new newsgroups the first time Gnus is run.
57 Should be set in paths.el, and shouldn't be touched by the user.")
59 (defvar gnus-local-domain nil
60 "Local domain name without a host name.
61 The DOMAINNAME environment variable is used instead if it is defined.
62 If the `system-name' function returns the full Internet name, there is
63 no need to set this variable.")
65 (defvar gnus-local-organization nil
66 "String with a description of what organization (if any) the user belongs to.
67 The ORGANIZATION environment variable is used instead if it is defined.
68 If this variable contains a function, this function will be called
69 with the current newsgroup name as the argument. The function should
72 In any case, if the string (either in the variable, in the environment
73 variable, or returned by the function) is a file name, the contents of
74 this file will be used as the organization.")
76 ;; Customization variables
78 ;; Don't touch this variable.
79 (defvar gnus-nntp-service "nntp"
80 "*NNTP service name (\"nntp\" or 119).
81 This is an obsolete variable, which is scarcely used. If you use an
82 nntp server for your newsgroup and want to change the port number
83 used to 899, you would say something along these lines:
85 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
87 (defvar gnus-nntpserver-file "/etc/nntpserver"
88 "*A file with only the name of the nntp server in it.")
90 ;; This function is used to check both the environment variable
91 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
92 ;; an nntp server name default.
93 (defun gnus-getenv-nntpserver ()
94 (or (getenv "NNTPSERVER")
95 (and (file-readable-p gnus-nntpserver-file)
97 (set-buffer (get-buffer-create " *gnus nntp*"))
98 (buffer-disable-undo (current-buffer))
99 (insert-file-contents gnus-nntpserver-file)
100 (let ((name (buffer-string)))
102 (if (string-match "^[ \t\n]*$" name)
105 (kill-buffer (current-buffer))))))))
107 (defvar gnus-select-method
109 (list 'nntp (or (condition-case ()
110 (gnus-getenv-nntpserver)
112 (if (and gnus-default-nntp-server
113 (not (string= gnus-default-nntp-server "")))
114 gnus-default-nntp-server)
116 (if (or (null gnus-nntp-service)
117 (equal gnus-nntp-service "nntp"))
119 (list gnus-nntp-service)))
120 "*Default method for selecting a newsgroup.
121 This variable should be a list, where the first element is how the
122 news is to be fetched, the second is the address.
124 For instance, if you want to get your news via NNTP from
125 \"flab.flab.edu\", you could say:
127 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
129 If you want to use your local spool, say:
131 (setq gnus-select-method (list 'nnspool (system-name)))
133 If you use this variable, you must set `gnus-nntp-server' to nil.
135 There is a lot more to know about select methods and virtual servers -
136 see the manual for details.")
138 (defvar gnus-message-archive-method
141 (nnfolder-directory ,(nnheader-concat message-directory "archive"))
142 (nnfolder-active-file
143 ,(nnheader-concat message-directory "archive/active"))
144 (nnfolder-get-new-mail nil)
145 (nnfolder-inhibit-expiry t))
146 "*Method used for archiving messages you've sent.
147 This should be a mail method.")
149 (defvar gnus-refer-article-method nil
150 "*Preferred method for fetching an article by Message-ID.
151 If you are reading news from the local spool (with nnspool), fetching
152 articles by Message-ID is painfully slow. By setting this method to an
153 nntp method, you might get acceptable results.
155 The value of this variable must be a valid select method as discussed
156 in the documentation of `gnus-select-method'.")
158 (defvar gnus-secondary-select-methods nil
159 "*A list of secondary methods that will be used for reading news.
160 This is a list where each element is a complete select method (see
161 `gnus-select-method').
163 If, for instance, you want to read your mail with the nnml backend,
164 you could set this variable:
166 (setq gnus-secondary-select-methods '((nnml \"\")))")
168 (defvar gnus-secondary-servers nil
169 "*List of NNTP servers that the user can choose between interactively.
170 To make Gnus query you for a server, you have to give `gnus' a
171 non-numeric prefix - `C-u M-x gnus', in short.")
173 (defvar gnus-nntp-server nil
174 "*The name of the host running the NNTP server.
175 This variable is semi-obsolete. Use the `gnus-select-method'
178 (defvar gnus-startup-file "~/.newsrc"
179 "*Your `.newsrc' file.
180 `.newsrc-SERVER' will be used instead if that exists.")
182 (defvar gnus-init-file "~/.gnus"
183 "*Your Gnus elisp startup file.
184 If a file with the .el or .elc suffixes exist, it will be read
187 (defvar gnus-group-faq-directory
188 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
189 "/ftp@sunsite.auc.dk:/pub/usenet/"
190 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
191 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
192 "/ftp@rtfm.mit.edu:/pub/usenet/"
193 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
194 "/ftp@ftp.sunet.se:/pub/usenet/"
195 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
196 "/ftp@hwarang.postech.ac.kr:/pub/usenet/"
197 "/ftp@ftp.hk.super.net:/mirror/faqs/")
198 "*Directory where the group FAQs are stored.
199 This will most commonly be on a remote machine, and the file will be
202 This variable can also be a list of directories. In that case, the
203 first element in the list will be used by default, and the others will
204 be used as backup sites.
206 Note that Gnus uses an aol machine as the default directory. If this
207 feels fundamentally unclean, just think of it as a way to finally get
208 something of value back from them.
210 If the default site is too slow, try one of these:
212 North America: mirrors.aol.com /pub/rtfm/usenet
213 ftp.seas.gwu.edu /pub/rtfm
214 rtfm.mit.edu /pub/usenet
215 Europe: ftp.uni-paderborn.de /pub/FAQ
216 src.doc.ic.ac.uk /usenet/news-FAQS
217 ftp.sunet.se /pub/usenet
218 sunsite.auc.dk /pub/usenet
219 Asia: nctuccca.edu.tw /USENET/FAQ
220 hwarang.postech.ac.kr /pub/usenet
221 ftp.hk.super.net /mirror/faqs")
223 (defvar gnus-group-archive-directory
224 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
225 "*The address of the (ding) archives.")
227 (defvar gnus-group-recent-archive-directory
228 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
229 "*The address of the most recent (ding) articles.")
231 (defvar gnus-default-subscribed-newsgroups nil
232 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
233 It should be a list of strings.
234 If it is `t', Gnus will not do anything special the first time it is
235 started; it'll just use the normal newsgroups subscription methods.")
237 (defvar gnus-use-cross-reference t
238 "*Non-nil means that cross referenced articles will be marked as read.
239 If nil, ignore cross references. If t, mark articles as read in
240 subscribed newsgroups. If neither t nor nil, mark as read in all
243 (defvar gnus-single-article-buffer t
244 "*If non-nil, display all articles in the same buffer.
245 If nil, each group will get its own article buffer.")
247 (defvar gnus-use-dribble-file t
248 "*Non-nil means that Gnus will use a dribble file to store user updates.
249 If Emacs should crash without saving the .newsrc files, complete
250 information can be restored from the dribble file.")
252 (defvar gnus-dribble-directory nil
253 "*The directory where dribble files will be saved.
254 If this variable is nil, the directory where the .newsrc files are
255 saved will be used.")
257 (defvar gnus-asynchronous nil
258 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
260 (defvar gnus-kill-summary-on-exit t
261 "*If non-nil, kill the summary buffer when you exit from it.
262 If nil, the summary will become a \"*Dead Summary*\" buffer, and
263 it will be killed sometime later.")
265 (defvar gnus-large-newsgroup 200
266 "*The number of articles which indicates a large newsgroup.
267 If the number of articles in a newsgroup is greater than this value,
268 confirmation is required for selecting the newsgroup.")
270 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
271 (defvar gnus-no-groups-message "No news is horrible news"
272 "*Message displayed by Gnus when no groups are available.")
274 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
275 "*Non-nil means that the default name of a file to save articles in is the group name.
276 If it's nil, the directory form of the group name is used instead.
278 If this variable is a list, and the list contains the element
279 `not-score', long file names will not be used for score files; if it
280 contains the element `not-save', long file names will not be used for
281 saving; and if it contains the element `not-kill', long file names
282 will not be used for kill files.")
284 (defvar gnus-article-save-directory gnus-directory
285 "*Name of the directory articles will be saved in (default \"~/News\").")
287 (defvar gnus-kill-files-directory gnus-directory
288 "*Name of the directory where kill files will be stored (default \"~/News\").")
290 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
291 "*A function to save articles in your favorite format.
292 The function must be interactively callable (in other words, it must
293 be an Emacs command).
295 Gnus provides the following functions:
297 * gnus-summary-save-in-rmail (Rmail format)
298 * gnus-summary-save-in-mail (Unix mail format)
299 * gnus-summary-save-in-folder (MH folder)
300 * gnus-summary-save-in-file (article format).
301 * gnus-summary-save-in-vm (use VM's folder format).")
303 (defvar gnus-prompt-before-saving 'always
304 "*This variable says how much prompting is to be done when saving articles.
305 If it is nil, no prompting will be done, and the articles will be
306 saved to the default files. If this variable is `always', each and
307 every article that is saved will be preceded by a prompt, even when
308 saving large batches of articles. If this variable is neither nil not
309 `always', there the user will be prompted once for a file name for
310 each invocation of the saving commands.")
312 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
313 "*A function generating a file name to save articles in Rmail format.
314 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
316 (defvar gnus-mail-save-name (function gnus-plain-save-name)
317 "*A function generating a file name to save articles in Unix mail format.
318 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
320 (defvar gnus-folder-save-name (function gnus-folder-save-name)
321 "*A function generating a file name to save articles in MH folder.
322 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
324 (defvar gnus-file-save-name (function gnus-numeric-save-name)
325 "*A function generating a file name to save articles in article format.
326 The function is called with NEWSGROUP, HEADERS, and optional
329 (defvar gnus-split-methods
330 '((gnus-article-archive-name))
331 "*Variable used to suggest where articles are to be saved.
332 For instance, if you would like to save articles related to Gnus in
333 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
334 you could set this variable to something like:
336 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
337 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
339 This variable is an alist where the where the key is the match and the
340 value is a list of possible files to save in if the match is non-nil.
342 If the match is a string, it is used as a regexp match on the
343 article. If the match is a symbol, that symbol will be funcalled
344 from the buffer of the article to be saved with the newsgroup as the
345 parameter. If it is a list, it will be evaled in the same buffer.
347 If this form or function returns a string, this string will be used as
348 a possible file name; and if it returns a non-nil list, that list will
349 be used as possible file names.")
351 (defvar gnus-move-split-methods nil
352 "*Variable used to suggest where articles are to be moved to.
353 It uses the same syntax as the `gnus-split-methods' variable.")
355 (defvar gnus-save-score nil
356 "*If non-nil, save group scoring info.")
358 (defvar gnus-use-adaptive-scoring nil
359 "*If non-nil, use some adaptive scoring scheme.")
361 (defvar gnus-use-cache 'passive
362 "*If nil, Gnus will ignore the article cache.
363 If `passive', it will allow entering (and reading) articles
364 explicitly entered into the cache. If anything else, use the
365 cache to the full extent of the law.")
367 (defvar gnus-use-trees nil
368 "*If non-nil, display a thread tree buffer.")
370 (defvar gnus-use-grouplens nil
371 "*If non-nil, use GroupLens ratings.")
373 (defvar gnus-keep-backlog nil
374 "*If non-nil, Gnus will keep read articles for later re-retrieval.
375 If it is a number N, then Gnus will only keep the last N articles
376 read. If it is neither nil nor a number, Gnus will keep all read
377 articles. This is not a good idea.")
379 (defvar gnus-use-nocem nil
380 "*If non-nil, Gnus will read NoCeM cancel messages.")
382 (defvar gnus-use-demon nil
383 "If non-nil, Gnus might use some demons.")
385 (defvar gnus-use-scoring t
386 "*If non-nil, enable scoring.")
388 (defvar gnus-use-picons nil
389 "*If non-nil, display picons.")
391 (defvar gnus-fetch-old-headers nil
392 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
393 If an unread article in the group refers to an older, already read (or
394 just marked as read) article, the old article will not normally be
395 displayed in the Summary buffer. If this variable is non-nil, Gnus
396 will attempt to grab the headers to the old articles, and thereby
397 build complete threads. If it has the value `some', only enough
398 headers to connect otherwise loose threads will be displayed.
399 This variable can also be a number. In that case, no more than that
400 number of old headers will be fetched.
402 The server has to support NOV for any of this to work.")
405 ;(defvar gnus-visual t
406 ; "*If non-nil, will do various highlighting.
407 ;If nil, no mouse highlights (or any other highlights) will be
408 ;performed. This might speed up Gnus some when generating large group
409 ;and summary buffers.")
411 (defvar gnus-novice-user t
412 "*Non-nil means that you are a usenet novice.
413 If non-nil, verbose messages may be displayed and confirmations may be
416 (defvar gnus-expert-user nil
417 "*Non-nil means that you will never be asked for confirmation about anything.
418 And that means *anything*.")
420 (defvar gnus-verbose 7
421 "*Integer that says how verbose Gnus should be.
422 The higher the number, the more messages Gnus will flash to say what
423 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
424 display most important messages; and at ten, Gnus will keep on
425 jabbering all the time.")
427 (defvar gnus-keep-same-level nil
428 "*Non-nil means that the next newsgroup after the current will be on the same level.
429 When you type, for instance, `n' after reading the last article in the
430 current newsgroup, you will go to the next newsgroup. If this variable
431 is nil, the next newsgroup will be the next from the group
433 If this variable is non-nil, Gnus will either put you in the
434 next newsgroup with the same level, or, if no such newsgroup is
435 available, the next newsgroup with the lowest possible level higher
436 than the current level.
437 If this variable is `best', Gnus will make the next newsgroup the one
438 with the best level.")
440 (defvar gnus-summary-make-false-root 'adopt
441 "*nil means that Gnus won't gather loose threads.
442 If the root of a thread has expired or been read in a previous
443 session, the information necessary to build a complete thread has been
444 lost. Instead of having many small sub-threads from this original thread
445 scattered all over the summary buffer, Gnus can gather them.
447 If non-nil, Gnus will try to gather all loose sub-threads from an
448 original thread into one large thread.
450 If this variable is non-nil, it should be one of `none', `adopt',
453 If this variable is `none', Gnus will not make a false root, but just
454 present the sub-threads after another.
455 If this variable is `dummy', Gnus will create a dummy root that will
456 have all the sub-threads as children.
457 If this variable is `adopt', Gnus will make one of the \"children\"
458 the parent and mark all the step-children as such.
459 If this variable is `empty', the \"children\" are printed with empty
460 subject fields. (Or rather, they will be printed with a string
461 given by the `gnus-summary-same-subject' variable.)")
463 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
464 "*A regexp to match subjects to be excluded from loose thread gathering.
465 As loose thread gathering is done on subjects only, that means that
466 there can be many false gatherings performed. By rooting out certain
467 common subjects, gathering might become saner.")
469 (defvar gnus-summary-gather-subject-limit nil
470 "*Maximum length of subject comparisons when gathering loose threads.
471 Use nil to compare full subjects. Setting this variable to a low
472 number will help gather threads that have been corrupted by
473 newsreaders chopping off subject lines, but it might also mean that
474 unrelated articles that have subject that happen to begin with the
475 same few characters will be incorrectly gathered.
477 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
478 comparing subjects.")
480 (defvar gnus-simplify-ignored-prefixes nil
481 "*Regexp, matches for which are removed from subject lines when simplifying.")
483 (defvar gnus-build-sparse-threads nil
484 "*If non-nil, fill in the gaps in threads.
485 If `some', only fill in the gaps that are needed to tie loose threads
486 together. If `more', fill in all leaf nodes that Gnus can find. If
487 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
489 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
490 "Function used for gathering loose threads.
491 There are two pre-defined functions: `gnus-gather-threads-by-subject',
492 which only takes Subjects into consideration; and
493 `gnus-gather-threads-by-references', which compared the References
494 headers of the articles to find matches.")
496 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
497 (defvar gnus-summary-same-subject ""
498 "*String indicating that the current article has the same subject as the previous.
499 This variable will only be used if the value of
500 `gnus-summary-make-false-root' is `empty'.")
502 (defvar gnus-summary-goto-unread t
503 "*If non-nil, marking commands will go to the next unread article.
504 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
505 whether it is read or not.")
507 (defvar gnus-group-goto-unread t
508 "*If non-nil, movement commands will go to the next unread and subscribed group.")
510 (defvar gnus-goto-next-group-when-activating t
511 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
513 (defvar gnus-check-new-newsgroups t
514 "*Non-nil means that Gnus will add new newsgroups at startup.
515 If this variable is `ask-server', Gnus will ask the server for new
516 groups since the last time it checked. This means that the killed list
517 is no longer necessary, so you could set `gnus-save-killed-list' to
520 A variant is to have this variable be a list of select methods. Gnus
521 will then use the `ask-server' method on all these select methods to
522 query for new groups from all those servers.
525 (setq gnus-check-new-newsgroups
526 '((nntp \"some.server\") (nntp \"other.server\")))
528 If this variable is nil, then you have to tell Gnus explicitly to
529 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
531 (defvar gnus-check-bogus-newsgroups nil
532 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
533 If this variable is nil, then you have to tell Gnus explicitly to
534 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
536 (defvar gnus-read-active-file t
537 "*Non-nil means that Gnus will read the entire active file at startup.
538 If this variable is nil, Gnus will only know about the groups in your
541 If this variable is `some', Gnus will try to only read the relevant
542 parts of the active file from the server. Not all servers support
543 this, and it might be quite slow with other servers, but this should
544 generally be faster than both the t and nil value.
546 If you set this variable to nil or `some', you probably still want to
547 be told about new newsgroups that arrive. To do that, set
548 `gnus-check-new-newsgroups' to `ask-server'. This may not work
549 properly with all servers.")
551 (defvar gnus-level-subscribed 5
552 "*Groups with levels less than or equal to this variable are subscribed.")
554 (defvar gnus-level-unsubscribed 7
555 "*Groups with levels less than or equal to this variable are unsubscribed.
556 Groups with levels less than `gnus-level-subscribed', which should be
557 less than this variable, are subscribed.")
559 (defvar gnus-level-zombie 8
560 "*Groups with this level are zombie groups.")
562 (defvar gnus-level-killed 9
563 "*Groups with this level are killed.")
565 (defvar gnus-level-default-subscribed 3
566 "*New subscribed groups will be subscribed at this level.")
568 (defvar gnus-level-default-unsubscribed 6
569 "*New unsubscribed groups will be unsubscribed at this level.")
571 (defvar gnus-activate-level (1+ gnus-level-subscribed)
572 "*Groups higher than this level won't be activated on startup.
573 Setting this variable to something log might save lots of time when
574 you have many groups that you aren't interested in.")
576 (defvar gnus-activate-foreign-newsgroups 4
577 "*If nil, Gnus will not check foreign newsgroups at startup.
578 If it is non-nil, it should be a number between one and nine. Foreign
579 newsgroups that have a level lower or equal to this number will be
580 activated on startup. For instance, if you want to active all
581 subscribed newsgroups, but not the rest, you'd set this variable to
582 `gnus-level-subscribed'.
584 If you subscribe to lots of newsgroups from different servers, startup
585 might take a while. By setting this variable to nil, you'll save time,
586 but you won't be told how many unread articles there are in the
589 (defvar gnus-save-newsrc-file t
590 "*Non-nil means that Gnus will save the `.newsrc' file.
591 Gnus always saves its own startup file, which is called
592 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
593 be readily understood by other newsreaders. If you don't plan on
594 using other newsreaders, set this variable to nil to save some time on
597 (defvar gnus-save-killed-list t
598 "*If non-nil, save the list of killed groups to the startup file.
599 If you set this variable to nil, you'll save both time (when starting
600 and quitting) and space (both memory and disk), but it will also mean
601 that Gnus has no record of which groups are new and which are old, so
602 the automatic new newsgroups subscription methods become meaningless.
604 You should always set `gnus-check-new-newsgroups' to `ask-server' or
605 nil if you set this variable to nil.")
607 (defvar gnus-interactive-catchup t
608 "*If non-nil, require your confirmation when catching up a group.")
610 (defvar gnus-interactive-exit t
611 "*If non-nil, require your confirmation when exiting Gnus.")
613 (defvar gnus-kill-killed t
614 "*If non-nil, Gnus will apply kill files to already killed articles.
615 If it is nil, Gnus will never apply kill files to articles that have
616 already been through the scoring process, which might very well save lots
619 (defvar gnus-extract-address-components 'gnus-extract-address-components
620 "*Function for extracting address components from a From header.
621 Two pre-defined function exist: `gnus-extract-address-components',
622 which is the default, quite fast, and too simplistic solution, and
623 `mail-extract-address-components', which works much better, but is
626 (defvar gnus-summary-default-score 0
627 "*Default article score level.
628 If this variable is nil, scoring will be disabled.")
630 (defvar gnus-summary-zcore-fuzz 0
631 "*Fuzziness factor for the zcore in the summary buffer.
632 Articles with scores closer than this to `gnus-summary-default-score'
633 will not be marked.")
635 (defvar gnus-simplify-subject-fuzzy-regexp nil
636 "*Strings to be removed when doing fuzzy matches.
637 This can either be a regular expression or list of regular expressions
638 that will be removed from subject strings if fuzzy subject
639 simplification is selected.")
641 (defvar gnus-permanently-visible-groups nil
642 "*Regexp to match groups that should always be listed in the group buffer.
643 This means that they will still be listed when there are no unread
644 articles in the groups.")
646 (defvar gnus-list-groups-with-ticked-articles t
647 "*If non-nil, list groups that have only ticked articles.
648 If nil, only list groups that have unread articles.")
650 (defvar gnus-group-default-list-level gnus-level-subscribed
651 "*Default listing level.
652 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
654 (defvar gnus-group-use-permanent-levels nil
655 "*If non-nil, once you set a level, Gnus will use this level.")
657 (defvar gnus-group-list-inactive-groups t
658 "*If non-nil, inactive groups will be listed.")
660 (defvar gnus-show-mime nil
661 "*If non-nil, do mime processing of articles.
662 The articles will simply be fed to the function given by
663 `gnus-show-mime-method'.")
665 (defvar gnus-strict-mime t
666 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
668 (defvar gnus-show-mime-method 'metamail-buffer
669 "*Function to process a MIME message.
670 The function is called from the article buffer.")
672 (defvar gnus-decode-encoded-word-method (lambda ())
673 "*Function to decode a MIME encoded-words.
674 The function is called from the article buffer.")
676 (defvar gnus-show-threads t
677 "*If non-nil, display threads in summary mode.")
679 (defvar gnus-thread-hide-subtree nil
680 "*If non-nil, hide all threads initially.
681 If threads are hidden, you have to run the command
682 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
683 to expose hidden threads.")
685 (defvar gnus-thread-hide-killed t
686 "*If non-nil, hide killed threads automatically.")
688 (defvar gnus-thread-ignore-subject nil
689 "*If non-nil, ignore subjects and do all threading based on the Reference header.
690 If nil, which is the default, articles that have different subjects
691 from their parents will start separate threads.")
693 (defvar gnus-thread-operation-ignore-subject t
694 "*If non-nil, subjects will be ignored when doing thread commands.
695 This affects commands like `gnus-summary-kill-thread' and
696 `gnus-summary-lower-thread'.
698 If this variable is nil, articles in the same thread with different
699 subjects will not be included in the operation in question. If this
700 variable is `fuzzy', only articles that have subjects that are fuzzily
701 equal will be included.")
703 (defvar gnus-thread-indent-level 4
704 "*Number that says how much each sub-thread should be indented.")
706 (defvar gnus-ignored-newsgroups
707 (purecopy (mapconcat 'identity
708 '("^to\\." ; not "real" groups
709 "^[0-9. \t]+ " ; all digits in name
710 "[][\"#'()]" ; bogus characters
713 "*A regexp to match uninteresting newsgroups in the active file.
714 Any lines in the active file matching this regular expression are
715 removed from the newsgroup list before anything else is done to it,
716 thus making them effectively non-existent.")
718 (defvar gnus-ignored-headers
719 "^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:"
720 "*All headers that match this regexp will be hidden.
721 This variable can also be a list of regexps of headers to be ignored.
722 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
724 (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-"
725 "*All headers that do not match this regexp will be hidden.
726 This variable can also be a list of regexp of headers to remain visible.
727 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
729 (defvar gnus-sorted-header-list
730 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
731 "^Cc:" "^Date:" "^Organization:")
732 "*This variable is a list of regular expressions.
733 If it is non-nil, headers that match the regular expressions will
734 be placed first in the article buffer in the sequence specified by
737 (defvar gnus-boring-article-headers
738 '(empty followup-to reply-to)
739 "*Headers that are only to be displayed if they have interesting data.
740 Possible values in this list are `empty', `newsgroups', `followup-to',
741 `reply-to', and `date'.")
743 (defvar gnus-show-all-headers nil
744 "*If non-nil, don't hide any headers.")
746 (defvar gnus-save-all-headers t
747 "*If non-nil, don't remove any headers before saving.")
749 (defvar gnus-saved-headers gnus-visible-headers
750 "*Headers to keep if `gnus-save-all-headers' is nil.
751 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
752 If that variable is nil, however, all headers that match this regexp
753 will be kept while the rest will be deleted before saving.")
755 (defvar gnus-inhibit-startup-message nil
756 "*If non-nil, the startup message will not be displayed.")
758 (defvar gnus-signature-separator "^-- *$"
759 "Regexp matching signature separator.")
761 (defvar gnus-signature-limit nil
762 "Provide a limit to what is considered a signature.
763 If it is a number, no signature may not be longer (in characters) than
764 that number. If it is a function, the function will be called without
765 any parameters, and if it returns nil, there is no signature in the
766 buffer. If it is a string, it will be used as a regexp. If it
767 matches, the text in question is not a signature.")
769 (defvar gnus-auto-extend-newsgroup t
770 "*If non-nil, extend newsgroup forward and backward when requested.")
772 (defvar gnus-auto-select-first t
773 "*If nil, don't select the first unread article when entering a group.
774 If this variable is `best', select the highest-scored unread article
775 in the group. If neither nil nor `best', select the first unread
778 If you want to prevent automatic selection of the first unread article
779 in some newsgroups, set the variable to nil in
780 `gnus-select-group-hook'.")
782 (defvar gnus-auto-select-next t
783 "*If non-nil, offer to go to the next group from the end of the previous.
784 If the value is t and the next newsgroup is empty, Gnus will exit
785 summary mode and go back to group mode. If the value is neither nil
786 nor t, Gnus will select the following unread newsgroup. In
787 particular, if the value is the symbol `quietly', the next unread
788 newsgroup will be selected without any confirmation, and if it is
789 `almost-quietly', the next group will be selected without any
790 confirmation if you are located on the last article in the group.
791 Finally, if this variable is `slightly-quietly', the `Z n' command
792 will go to the next group without confirmation.")
794 (defvar gnus-auto-select-same nil
795 "*If non-nil, select the next article with the same subject.")
797 (defvar gnus-summary-check-current nil
798 "*If non-nil, consider the current article when moving.
799 The \"unread\" movement commands will stay on the same line if the
800 current article is unread.")
802 (defvar gnus-auto-center-summary t
803 "*If non-nil, always center the current summary buffer.
804 In particular, if `vertical' do only vertical recentering. If non-nil
805 and non-`vertical', do both horizontal and vertical recentering.")
807 (defvar gnus-break-pages t
808 "*If non-nil, do page breaking on articles.
809 The page delimiter is specified by the `gnus-page-delimiter'
812 (defvar gnus-page-delimiter "^\^L"
813 "*Regexp describing what to use as article page delimiters.
814 The default value is \"^\^L\", which is a form linefeed at the
815 beginning of a line.")
817 (defvar gnus-use-full-window t
818 "*If non-nil, use the entire Emacs screen.")
820 (defvar gnus-window-configuration nil
821 "Obsolete variable. See `gnus-buffer-configuration'.")
823 (defvar gnus-window-min-width 2
824 "*Minimum width of Gnus buffers.")
826 (defvar gnus-window-min-height 1
827 "*Minimum height of Gnus buffers.")
829 (defvar gnus-buffer-configuration
833 (if gnus-carpal '(group-carpal 4))))
837 (if gnus-carpal '(summary-carpal 4))))
844 (if gnus-carpal '(summary-carpal 4))
846 (vertical ((height . 5) (width . 15)
848 (left . -1) (top . 1))
858 (if gnus-carpal '(summary-carpal 4))
859 (if gnus-use-trees '(tree 0.25))
864 (if gnus-carpal '(server-carpal 2))))
868 (if gnus-carpal '(browse-carpal 2))))
871 (message 1.0 point)))
874 (article 1.0 point)))
885 (edit-group 1.0 point)))
889 (edit-server 1.0 point)))
893 (edit-score 1.0 point)))
900 (message 1.0 point)))
903 (message 1.0 point)))
906 (message 1.0 point)))
910 (message 1.0 point)))
917 (if gnus-carpal '(summary-carpal 4))
918 ("*Shell Command Output*" 1.0)))
921 ("*Gnus Help Bug*" 0.5)
922 ("*Gnus Bug*" 1.0 point)))
926 (message 1.0 point))))
927 "Window configuration for all possible Gnus buffers.
928 This variable is a list of lists. Each of these lists has a NAME and
929 a RULE. The NAMEs are commonsense names like `group', which names a
930 rule used when displaying the group buffer; `summary', which names a
931 rule for what happens when you enter a group and do not display an
932 article buffer; and so on. See the value of this variable for a
933 complete list of NAMEs.
935 Each RULE is a list of vectors. The first element in this vector is
936 the name of the buffer to be displayed; the second element is the
937 percentage of the screen this buffer is to occupy (a number in the
938 0.0-0.99 range); the optional third element is `point', which should
939 be present to denote which buffer point is to go to after making this
940 buffer configuration.")
942 (defvar gnus-window-to-buffer
943 '((group . gnus-group-buffer)
944 (summary . gnus-summary-buffer)
945 (article . gnus-article-buffer)
946 (server . gnus-server-buffer)
947 (browse . "*Gnus Browse Server*")
948 (edit-group . gnus-group-edit-buffer)
949 (edit-server . gnus-server-edit-buffer)
950 (group-carpal . gnus-carpal-group-buffer)
951 (summary-carpal . gnus-carpal-summary-buffer)
952 (server-carpal . gnus-carpal-server-buffer)
953 (browse-carpal . gnus-carpal-browse-buffer)
954 (edit-score . gnus-score-edit-buffer)
955 (message . gnus-message-buffer)
956 (mail . gnus-message-buffer)
957 (post-news . gnus-message-buffer)
958 (faq . gnus-faq-buffer)
959 (picons . "*Picons*")
960 (tree . gnus-tree-buffer)
961 (info . gnus-info-buffer)
962 (article-copy . gnus-article-copy)
963 (draft . gnus-draft-buffer))
964 "Mapping from short symbols to buffer names or buffer variables.")
966 (defvar gnus-carpal nil
967 "*If non-nil, display clickable icons.")
969 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
970 "*Function called with a group name when new group is detected.
971 A few pre-made functions are supplied: `gnus-subscribe-randomly'
972 inserts new groups at the beginning of the list of groups;
973 `gnus-subscribe-alphabetically' inserts new groups in strict
974 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
975 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
976 for your decision; `gnus-subscribe-killed' kills all new groups;
977 `gnus-subscribe-zombies' will make all new groups into zombies.")
979 ;; Suggested by a bug report by Hallvard B Furuseth.
980 ;; <h.b.furuseth@usit.uio.no>.
981 (defvar gnus-subscribe-options-newsgroup-method
982 (function gnus-subscribe-alphabetically)
983 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
984 If, for instance, you want to subscribe to all newsgroups in the
985 \"no\" and \"alt\" hierarchies, you'd put the following in your
988 options -n no.all alt.all
990 Gnus will the subscribe all new newsgroups in these hierarchies with
991 the subscription method in this variable.")
993 (defvar gnus-subscribe-hierarchical-interactive nil
994 "*If non-nil, Gnus will offer to subscribe hierarchically.
995 When a new hierarchy appears, Gnus will ask the user:
997 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
999 If the user pressed `d', Gnus will descend the hierarchy, `y' will
1000 subscribe to all newsgroups in the hierarchy and `s' will skip this
1001 hierarchy in its entirety.")
1003 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1004 "*Function used for sorting the group buffer.
1005 This function will be called with group info entries as the arguments
1006 for the groups to be sorted. Pre-made functions include
1007 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1008 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1009 `gnus-group-sort-by-rank'.
1011 This variable can also be a list of sorting functions. In that case,
1012 the most significant sort function should be the last function in the
1015 ;; Mark variables suggested by Thomas Michanek
1016 ;; <Thomas.Michanek@telelogic.se>.
1017 (defvar gnus-unread-mark ?
1018 "*Mark used for unread articles.")
1019 (defvar gnus-ticked-mark ?!
1020 "*Mark used for ticked articles.")
1021 (defvar gnus-dormant-mark ??
1022 "*Mark used for dormant articles.")
1023 (defvar gnus-del-mark ?r
1024 "*Mark used for del'd articles.")
1025 (defvar gnus-read-mark ?R
1026 "*Mark used for read articles.")
1027 (defvar gnus-expirable-mark ?E
1028 "*Mark used for expirable articles.")
1029 (defvar gnus-killed-mark ?K
1030 "*Mark used for killed articles.")
1031 (defvar gnus-souped-mark ?F
1032 "*Mark used for killed articles.")
1033 (defvar gnus-kill-file-mark ?X
1034 "*Mark used for articles killed by kill files.")
1035 (defvar gnus-low-score-mark ?Y
1036 "*Mark used for articles with a low score.")
1037 (defvar gnus-catchup-mark ?C
1038 "*Mark used for articles that are caught up.")
1039 (defvar gnus-replied-mark ?A
1040 "*Mark used for articles that have been replied to.")
1041 (defvar gnus-cached-mark ?*
1042 "*Mark used for articles that are in the cache.")
1043 (defvar gnus-saved-mark ?S
1044 "*Mark used for articles that have been saved to.")
1045 (defvar gnus-process-mark ?#
1047 (defvar gnus-ancient-mark ?O
1048 "*Mark used for ancient articles.")
1049 (defvar gnus-sparse-mark ?Q
1050 "*Mark used for sparsely reffed articles.")
1051 (defvar gnus-canceled-mark ?G
1052 "*Mark used for canceled articles.")
1053 (defvar gnus-score-over-mark ?+
1054 "*Score mark used for articles with high scores.")
1055 (defvar gnus-score-below-mark ?-
1056 "*Score mark used for articles with low scores.")
1057 (defvar gnus-empty-thread-mark ?
1058 "*There is no thread under the article.")
1059 (defvar gnus-not-empty-thread-mark ?=
1060 "*There is a thread under the article.")
1062 (defvar gnus-view-pseudo-asynchronously nil
1063 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1065 (defvar gnus-view-pseudos nil
1066 "*If `automatic', pseudo-articles will be viewed automatically.
1067 If `not-confirm', pseudos will be viewed automatically, and the user
1068 will not be asked to confirm the command.")
1070 (defvar gnus-view-pseudos-separately t
1071 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1072 If nil, all files that use the same viewing command will be given as a
1073 list of parameters to that command.")
1075 (defvar gnus-insert-pseudo-articles t
1076 "*If non-nil, insert pseudo-articles when decoding articles.")
1078 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1079 "*Format of group lines.
1080 It works along the same lines as a normal formatting string,
1081 with some simple extensions.
1083 %M Only marked articles (character, \"*\" or \" \")
1084 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1085 %L Level of subscribedness (integer)
1086 %N Number of unread articles (integer)
1087 %I Number of dormant articles (integer)
1088 %i Number of ticked and dormant (integer)
1089 %T Number of ticked articles (integer)
1090 %R Number of read articles (integer)
1091 %t Total number of articles (integer)
1092 %y Number of unread, unticked articles (integer)
1093 %G Group name (string)
1094 %g Qualified group name (string)
1095 %D Group description (string)
1096 %s Select method (string)
1097 %o Moderated group (char, \"m\")
1098 %p Process mark (char)
1099 %O Moderated group (string, \"(m)\" or \"\")
1100 %P Topic indentation (string)
1101 %l Whether there are GroupLens predictions for this group (string)
1102 %n Select from where (string)
1103 %z A string that look like `<%s:%n>' if a foreign select method is used
1104 %u User defined specifier. The next character in the format string should
1105 be a letter. Gnus will call the function gnus-user-format-function-X,
1106 where X is the letter following %u. The function will be passed the
1107 current header as argument. The function should return a string, which
1108 will be inserted into the buffer just like information from any other
1111 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1112 the mouse point move inside the area. There can only be one such area.
1114 Note that this format specification is not always respected. For
1115 reasons of efficiency, when listing killed groups, this specification
1116 is ignored altogether. If the spec is changed considerably, your
1117 output may end up looking strange when listing both alive and killed
1120 If you use %o or %O, reading the active file will be slower and quite
1121 a bit of extra memory will be used. %D will also worsen performance.
1122 Also note that if you change the format specification to include any
1123 of these specs, you must probably re-start Gnus to see them go into
1126 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1127 "*The format specification of the lines in the summary buffer.
1129 It works along the same lines as a normal formatting string,
1130 with some simple extensions.
1132 %N Article number, left padded with spaces (string)
1134 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1135 %n Name of the poster (string)
1136 %a Extracted name of the poster (string)
1137 %A Extracted address of the poster (string)
1138 %F Contents of the From: header (string)
1139 %x Contents of the Xref: header (string)
1140 %D Date of the article (string)
1141 %d Date of the article (string) in DD-MMM format
1142 %M Message-id of the article (string)
1143 %r References of the article (string)
1144 %c Number of characters in the article (integer)
1145 %L Number of lines in the article (integer)
1146 %I Indentation based on thread level (a string of spaces)
1147 %T A string with two possible values: 80 spaces if the article
1148 is on thread level two or larger and 0 spaces on level one
1149 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1150 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1151 %[ Opening bracket (character, \"[\" or \"<\")
1152 %] Closing bracket (character, \"]\" or \">\")
1153 %> Spaces of length thread-level (string)
1154 %< Spaces of length (- 20 thread-level) (string)
1155 %i Article score (number)
1156 %z Article zcore (character)
1157 %t Number of articles under the current thread (number).
1158 %e Whether the thread is empty or not (character).
1159 %l GroupLens score (string).
1160 %u User defined specifier. The next character in the format string should
1161 be a letter. Gnus will call the function gnus-user-format-function-X,
1162 where X is the letter following %u. The function will be passed the
1163 current header as argument. The function should return a string, which
1164 will be inserted into the summary just like information from any other
1167 Text between %( and %) will be highlighted with `gnus-mouse-face'
1168 when the mouse point is placed inside the area. There can only be one
1171 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1172 with care. For reasons of efficiency, Gnus will compute what column
1173 these characters will end up in, and \"hard-code\" that. This means that
1174 it is illegal to have these specs after a variable-length spec. Well,
1175 you might not be arrested, but your summary buffer will look strange,
1176 which is bad enough.
1178 The smart choice is to have these specs as for to the left as
1181 This restriction may disappear in later versions of Gnus.")
1183 (defvar gnus-summary-dummy-line-format
1185 "*The format specification for the dummy roots in the summary buffer.
1186 It works along the same lines as a normal formatting string,
1187 with some simple extensions.
1191 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1192 "*The format specification for the summary mode line.
1193 It works along the same lines as a normal formatting string,
1194 with some simple extensions:
1197 %p Unprefixed group name
1198 %A Current article number
1200 %U Number of unread articles in the group
1201 %e Number of unselected articles in the group
1202 %Z A string with unread/unselected article counts
1203 %g Shortish group name
1204 %S Subject of the current article
1205 %u User-defined spec
1206 %s Current score file name
1207 %d Number of dormant articles
1208 %r Number of articles that have been marked as read in this session
1209 %E Number of articles expunged by the score files")
1211 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1212 "*The format specification for the article mode line.
1213 See `gnus-summary-mode-line-format' for a closer description.")
1215 (defvar gnus-group-mode-line-format "Gnus: %%b {%M%:%S}"
1216 "*The format specification for the group mode line.
1217 It works along the same lines as a normal formatting string,
1218 with some simple extensions:
1220 %S The native news server.
1221 %M The native select method.
1222 %: \":\" if %S isn't \"\".")
1224 (defvar gnus-valid-select-methods
1225 '(("nntp" post address prompt-address)
1226 ("nnspool" post address)
1227 ("nnvirtual" post-mail virtual prompt-address)
1228 ("nnmbox" mail respool address)
1229 ("nnml" mail respool address)
1230 ("nnmh" mail respool address)
1231 ("nndir" post-mail prompt-address address)
1232 ("nneething" none address prompt-address)
1233 ("nndoc" none address prompt-address)
1234 ("nnbabyl" mail address respool)
1235 ("nnkiboze" post address virtual)
1236 ("nnsoup" post-mail address)
1237 ("nndraft" post-mail)
1238 ("nnfolder" mail respool address))
1239 "An alist of valid select methods.
1240 The first element of each list lists should be a string with the name
1241 of the select method. The other elements may be be the category of
1242 this method (ie. `post', `mail', `none' or whatever) or other
1243 properties that this method has (like being respoolable).
1244 If you implement a new select method, all you should have to change is
1245 this variable. I think.")
1247 (defvar gnus-updated-mode-lines '(group article summary tree)
1248 "*List of buffers that should update their mode lines.
1249 The list may contain the symbols `group', `article' and `summary'. If
1250 the corresponding symbol is present, Gnus will keep that mode line
1251 updated with information that may be pertinent.
1252 If this variable is nil, screen refresh may be quicker.")
1254 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1255 (defvar gnus-mode-non-string-length nil
1256 "*Max length of mode-line non-string contents.
1257 If this is nil, Gnus will take space as is needed, leaving the rest
1258 of the modeline intact.")
1261 ;(defvar gnus-mouse-face 'highlight
1262 ; "*Face used for mouse highlighting in Gnus.
1263 ;No mouse highlights will be done if `gnus-visual' is nil.")
1265 (defvar gnus-summary-mark-below 0
1266 "*Mark all articles with a score below this variable as read.
1267 This variable is local to each summary buffer and usually set by the
1270 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1271 "*List of functions used for sorting articles in the summary buffer.
1272 This variable is only used when not using a threaded display.")
1274 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1275 "*List of functions used for sorting threads in the summary buffer.
1276 By default, threads are sorted by article number.
1278 Each function takes two threads and return non-nil if the first thread
1279 should be sorted before the other. If you use more than one function,
1280 the primary sort function should be the last. You should probably
1281 always include `gnus-thread-sort-by-number' in the list of sorting
1282 functions -- preferably first.
1284 Ready-mady functions include `gnus-thread-sort-by-number',
1285 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1286 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1287 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1289 (defvar gnus-thread-score-function '+
1290 "*Function used for calculating the total score of a thread.
1292 The function is called with the scores of the article and each
1293 subthread and should then return the score of the thread.
1295 Some functions you can use are `+', `max', or `min'.")
1297 (defvar gnus-summary-expunge-below nil
1298 "All articles that have a score less than this variable will be expunged.")
1300 (defvar gnus-thread-expunge-below nil
1301 "All threads that have a total score less than this variable will be expunged.
1302 See `gnus-thread-score-function' for en explanation of what a
1303 \"thread score\" is.")
1305 (defvar gnus-auto-subscribed-groups
1306 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1307 "*All new groups that match this regexp will be subscribed automatically.
1308 Note that this variable only deals with new groups. It has no effect
1309 whatsoever on old groups.")
1311 (defvar gnus-options-subscribe nil
1312 "*All new groups matching this regexp will be subscribed unconditionally.
1313 Note that this variable deals only with new newsgroups. This variable
1314 does not affect old newsgroups.")
1316 (defvar gnus-options-not-subscribe nil
1317 "*All new groups matching this regexp will be ignored.
1318 Note that this variable deals only with new newsgroups. This variable
1319 does not affect old (already subscribed) newsgroups.")
1321 (defvar gnus-auto-expirable-newsgroups nil
1322 "*Groups in which to automatically mark read articles as expirable.
1323 If non-nil, this should be a regexp that should match all groups in
1324 which to perform auto-expiry. This only makes sense for mail groups.")
1326 (defvar gnus-total-expirable-newsgroups nil
1327 "*Groups in which to perform expiry of all read articles.
1328 Use with extreme caution. All groups that match this regexp will be
1329 expiring - which means that all read articles will be deleted after
1330 (say) one week. (This only goes for mail groups and the like, of
1333 (defvar gnus-group-uncollapsed-levels 1
1334 "Number of group name elements to leave alone when making a short group name.")
1336 (defvar gnus-hidden-properties '(invisible t intangible t)
1337 "Property list to use for hiding text.")
1339 (defvar gnus-modtime-botch nil
1340 "*Non-nil means .newsrc should be deleted prior to save.
1341 Its use is due to the bogus appearance that .newsrc was modified on
1346 (defvar gnus-group-mode-hook nil
1347 "*A hook for Gnus group mode.")
1349 (defvar gnus-summary-mode-hook nil
1350 "*A hook for Gnus summary mode.
1351 This hook is run before any variables are set in the summary buffer.")
1353 (defvar gnus-article-mode-hook nil
1354 "*A hook for Gnus article mode.")
1356 (defvar gnus-summary-prepare-exit-hook nil
1357 "*A hook called when preparing to exit from the summary buffer.
1358 It calls `gnus-summary-expire-articles' by default.")
1359 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1361 (defvar gnus-summary-exit-hook nil
1362 "*A hook called on exit from the summary buffer.")
1364 (defvar gnus-group-catchup-group-hook nil
1365 "*A hook run when catching up a group from the group buffer.")
1367 (defvar gnus-group-update-group-hook nil
1368 "*A hook called when updating group lines.")
1370 (defvar gnus-open-server-hook nil
1371 "*A hook called just before opening connection to the news server.")
1373 (defvar gnus-load-hook nil
1374 "*A hook run while Gnus is loaded.")
1376 (defvar gnus-startup-hook nil
1377 "*A hook called at startup.
1378 This hook is called after Gnus is connected to the NNTP server.")
1380 (defvar gnus-get-new-news-hook nil
1381 "*A hook run just before Gnus checks for new news.")
1383 (defvar gnus-after-getting-new-news-hook nil
1384 "*A hook run after Gnus checks for new news.")
1386 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1387 "*A function that is called to generate the group buffer.
1388 The function is called with three arguments: The first is a number;
1389 all group with a level less or equal to that number should be listed,
1390 if the second is non-nil, empty groups should also be displayed. If
1391 the third is non-nil, it is a number. No groups with a level lower
1392 than this number should be displayed.
1394 The only current function implemented is `gnus-group-prepare-flat'.")
1396 (defvar gnus-group-prepare-hook nil
1397 "*A hook called after the group buffer has been generated.
1398 If you want to modify the group buffer, you can use this hook.")
1400 (defvar gnus-summary-prepare-hook nil
1401 "*A hook called after the summary buffer has been generated.
1402 If you want to modify the summary buffer, you can use this hook.")
1404 (defvar gnus-summary-generate-hook nil
1405 "*A hook run just before generating the summary buffer.
1406 This hook is commonly used to customize threading variables and the
1409 (defvar gnus-article-prepare-hook nil
1410 "*A hook called after an article has been prepared in the article buffer.
1411 If you want to run a special decoding program like nkf, use this hook.")
1413 ;(defvar gnus-article-display-hook nil
1414 ; "*A hook called after the article is displayed in the article buffer.
1415 ;The hook is designed to change the contents of the article
1416 ;buffer. Typical functions that this hook may contain are
1417 ;`gnus-article-hide-headers' (hide selected headers),
1418 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1419 ;`gnus-article-hide-signature' (hide signature) and
1420 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1421 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1422 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1423 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1425 (defvar gnus-article-x-face-command
1426 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1427 "String or function to be executed to display an X-Face header.
1428 If it is a string, the command will be executed in a sub-shell
1429 asynchronously. The compressed face will be piped to this command.")
1431 (defvar gnus-article-x-face-too-ugly nil
1432 "Regexp matching posters whose face shouldn't be shown automatically.")
1434 (defvar gnus-select-group-hook nil
1435 "*A hook called when a newsgroup is selected.
1437 If you'd like to simplify subjects like the
1438 `gnus-summary-next-same-subject' command does, you can use the
1441 (setq gnus-select-group-hook
1444 (mapcar (lambda (header)
1445 (mail-header-set-subject
1447 (gnus-simplify-subject
1448 (mail-header-subject header) 're-only)))
1449 gnus-newsgroup-headers))))")
1451 (defvar gnus-select-article-hook nil
1452 "*A hook called when an article is selected.")
1454 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1455 "*A hook called to apply kill files to a group.
1456 This hook is intended to apply a kill file to the selected newsgroup.
1457 The function `gnus-apply-kill-file' is called by default.
1459 Since a general kill file is too heavy to use only for a few
1460 newsgroups, I recommend you to use a lighter hook function. For
1461 example, if you'd like to apply a kill file to articles which contains
1462 a string `rmgroup' in subject in newsgroup `control', you can use the
1465 (setq gnus-apply-kill-hook
1468 (cond ((string-match \"control\" gnus-newsgroup-name)
1469 (gnus-kill \"Subject\" \"rmgroup\")
1470 (gnus-expunge \"X\"))))))")
1472 (defvar gnus-visual-mark-article-hook
1473 (list 'gnus-highlight-selected-summary)
1474 "*Hook run after selecting an article in the summary buffer.
1475 It is meant to be used for highlighting the article in some way. It
1476 is not run if `gnus-visual' is nil.")
1478 (defvar gnus-parse-headers-hook nil
1479 "*A hook called before parsing the headers.")
1480 (add-hook 'gnus-parse-headers-hook 'gnus-decode-rfc1522)
1482 (defvar gnus-exit-group-hook nil
1483 "*A hook called when exiting (not quitting) summary mode.")
1485 (defvar gnus-suspend-gnus-hook nil
1486 "*A hook called when suspending (not exiting) Gnus.")
1488 (defvar gnus-exit-gnus-hook nil
1489 "*A hook called when exiting Gnus.")
1491 (defvar gnus-after-exiting-gnus-hook nil
1492 "*A hook called after exiting Gnus.")
1494 (defvar gnus-save-newsrc-hook nil
1495 "*A hook called before saving any of the newsrc files.")
1497 (defvar gnus-save-quick-newsrc-hook nil
1498 "*A hook called just before saving the quick newsrc file.
1499 Can be used to turn version control on or off.")
1501 (defvar gnus-save-standard-newsrc-hook nil
1502 "*A hook called just before saving the standard newsrc file.
1503 Can be used to turn version control on or off.")
1505 (defvar gnus-summary-update-hook
1506 (list 'gnus-summary-highlight-line)
1507 "*A hook called when a summary line is changed.
1508 The hook will not be called if `gnus-visual' is nil.
1510 The default function `gnus-summary-highlight-line' will
1511 highlight the line according to the `gnus-summary-highlight'
1514 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1515 "*A hook called when a group line is changed.
1516 The hook will not be called if `gnus-visual' is nil.
1518 The default function `gnus-group-highlight-line' will
1519 highlight the line according to the `gnus-group-highlight'
1522 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1523 "*A hook called when an article is selected for the first time.
1524 The hook is intended to mark an article as read (or unread)
1525 automatically when it is selected.")
1527 (defvar gnus-group-change-level-function nil
1528 "Function run when a group level is changed.
1529 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1531 ;; Remove any hilit infestation.
1532 (add-hook 'gnus-startup-hook
1534 (remove-hook 'gnus-summary-prepare-hook
1535 'hilit-rehighlight-buffer-quietly)
1536 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1537 (setq gnus-mark-article-hook
1538 '(gnus-summary-mark-read-and-unread-as-read))
1539 (remove-hook 'gnus-article-prepare-hook
1540 'hilit-rehighlight-buffer-quietly)))
1543 ;; Internal variables
1545 (defvar gnus-tree-buffer "*Tree*"
1546 "Buffer where Gnus thread trees are displayed.")
1549 (defvar gnus-use-generic-from nil)
1551 (defvar gnus-thread-indent-array nil)
1552 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1554 (defvar gnus-newsrc-file-version nil)
1556 (defvar gnus-method-history nil)
1557 ;; Variable holding the user answers to all method prompts.
1559 (defvar gnus-group-history nil)
1560 ;; Variable holding the user answers to all group prompts.
1562 (defvar gnus-server-alist nil
1563 "List of available servers.")
1565 (defvar gnus-group-indentation-function nil)
1567 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1569 (defvar gnus-goto-missing-group-function nil)
1571 (defvar gnus-override-subscribe-method nil)
1573 (defvar gnus-group-goto-next-group-function nil
1574 "Function to override finding the next group after listing groups.")
1576 (defconst gnus-article-mark-lists
1577 '((marked . tick) (replied . reply)
1578 (expirable . expire) (killed . killed)
1579 (bookmarks . bookmark) (dormant . dormant)
1580 (scored . score) (saved . save)
1584 ;; Avoid highlighting in kill files.
1585 (defvar gnus-summary-inhibit-highlight nil)
1586 (defvar gnus-newsgroup-selected-overlay nil)
1588 (defvar gnus-inhibit-hiding nil)
1589 (defvar gnus-group-indentation "")
1590 (defvar gnus-inhibit-limiting nil)
1591 (defvar gnus-created-frames nil)
1593 (defvar gnus-article-mode-map nil)
1594 (defvar gnus-dribble-buffer nil)
1595 (defvar gnus-headers-retrieved-by nil)
1596 (defvar gnus-article-reply nil)
1597 (defvar gnus-override-method nil)
1598 (defvar gnus-article-check-size nil)
1600 (defvar gnus-current-score-file nil)
1601 (defvar gnus-newsgroup-adaptive-score-file nil)
1602 (defvar gnus-scores-exclude-files nil)
1604 (defvar gnus-opened-servers nil)
1606 (defvar gnus-current-move-group nil)
1607 (defvar gnus-current-copy-group nil)
1608 (defvar gnus-current-crosspost-group nil)
1610 (defvar gnus-newsgroup-dependencies nil)
1611 (defvar gnus-newsgroup-async nil)
1612 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1614 (defvar gnus-newsgroup-adaptive nil)
1616 (defvar gnus-summary-display-table nil)
1617 (defvar gnus-summary-display-article-function nil)
1619 (defvar gnus-summary-highlight-line-function nil
1620 "Function called after highlighting a summary line.")
1622 (defvar gnus-group-line-format-alist
1623 `((?M gnus-tmp-marked-mark ?c)
1624 (?S gnus-tmp-subscribed ?c)
1625 (?L gnus-tmp-level ?d)
1626 (?N (cond ((eq number t) "*" )
1630 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1631 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1633 (?R gnus-tmp-number-of-read ?s)
1634 (?t gnus-tmp-number-total ?d)
1635 (?y gnus-tmp-number-of-unread ?s)
1636 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1637 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1638 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1639 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1640 (?g gnus-tmp-group ?s)
1641 (?G gnus-tmp-qualified-group ?s)
1642 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1643 (?D gnus-tmp-newsgroup-description ?s)
1644 (?o gnus-tmp-moderated ?c)
1645 (?O gnus-tmp-moderated-string ?s)
1646 (?p gnus-tmp-process-marked ?c)
1647 (?s gnus-tmp-news-server ?s)
1648 (?n gnus-tmp-news-method ?s)
1649 (?P gnus-group-indentation ?s)
1650 (?l gnus-tmp-grouplens ?s)
1651 (?z gnus-tmp-news-method-string ?s)
1652 (?u gnus-tmp-user-defined ?s)))
1654 (defvar gnus-summary-line-format-alist
1655 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1656 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1657 (?s gnus-tmp-subject-or-nil ?s)
1658 (?n gnus-tmp-name ?s)
1659 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1661 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1663 (?F gnus-tmp-from ?s)
1664 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1665 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1666 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1667 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1668 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1669 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1670 (?L gnus-tmp-lines ?d)
1671 (?I gnus-tmp-indentation ?s)
1672 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1673 (?R gnus-tmp-replied ?c)
1674 (?\[ gnus-tmp-opening-bracket ?c)
1675 (?\] gnus-tmp-closing-bracket ?c)
1676 (?\> (make-string gnus-tmp-level ? ) ?s)
1677 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1678 (?i gnus-tmp-score ?d)
1679 (?z gnus-tmp-score-char ?c)
1680 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1681 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1682 (?U gnus-tmp-unread ?c)
1683 (?t (gnus-summary-number-of-articles-in-thread
1684 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1686 (?e (gnus-summary-number-of-articles-in-thread
1687 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1689 (?u gnus-tmp-user-defined ?s))
1690 "An alist of format specifications that can appear in summary lines,
1691 and what variables they correspond with, along with the type of the
1692 variable (string, integer, character, etc).")
1694 (defvar gnus-summary-dummy-line-format-alist
1695 `((?S gnus-tmp-subject ?s)
1696 (?N gnus-tmp-number ?d)
1697 (?u gnus-tmp-user-defined ?s)))
1699 (defvar gnus-summary-mode-line-format-alist
1700 `((?G gnus-tmp-group-name ?s)
1701 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1702 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1703 (?A gnus-tmp-article-number ?d)
1704 (?Z gnus-tmp-unread-and-unselected ?s)
1705 (?V gnus-version ?s)
1706 (?U gnus-tmp-unread ?d)
1707 (?S gnus-tmp-subject ?s)
1708 (?e gnus-tmp-unselected ?d)
1709 (?u gnus-tmp-user-defined ?s)
1710 (?d (length gnus-newsgroup-dormant) ?d)
1711 (?t (length gnus-newsgroup-marked) ?d)
1712 (?r (length gnus-newsgroup-reads) ?d)
1713 (?E gnus-newsgroup-expunged-tally ?d)
1714 (?s (gnus-current-score-file-nondirectory) ?s)))
1716 (defvar gnus-article-mode-line-format-alist
1717 gnus-summary-mode-line-format-alist)
1719 (defvar gnus-group-mode-line-format-alist
1720 `((?S gnus-tmp-news-server ?s)
1721 (?M gnus-tmp-news-method ?s)
1722 (?u gnus-tmp-user-defined ?s)
1723 (?: gnus-tmp-colon ?s)))
1725 (defvar gnus-have-read-active-file nil)
1727 (defconst gnus-maintainer
1728 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1729 "The mail address of the Gnus maintainers.")
1731 (defconst gnus-version-number "5.2.7"
1732 "Version number for this version of Gnus.")
1734 (defconst gnus-version (format "Gnus v%s" gnus-version-number)
1735 "Version string for this version of Gnus.")
1737 (defvar gnus-info-nodes
1738 '((gnus-group-mode "(gnus)The Group Buffer")
1739 (gnus-summary-mode "(gnus)The Summary Buffer")
1740 (gnus-article-mode "(gnus)The Article Buffer"))
1741 "Alist of major modes and related Info nodes.")
1743 (defvar gnus-group-buffer "*Group*")
1744 (defvar gnus-summary-buffer "*Summary*")
1745 (defvar gnus-article-buffer "*Article*")
1746 (defvar gnus-server-buffer "*Server*")
1748 (defvar gnus-work-buffer " *gnus work*")
1750 (defvar gnus-original-article-buffer " *Original Article*")
1751 (defvar gnus-original-article nil)
1753 (defvar gnus-buffer-list nil
1754 "Gnus buffers that should be killed on exit.")
1756 (defvar gnus-slave nil
1757 "Whether this Gnus is a slave or not.")
1759 (defvar gnus-variable-list
1760 '(gnus-newsrc-options gnus-newsrc-options-n
1761 gnus-newsrc-last-checked-date
1762 gnus-newsrc-alist gnus-server-alist
1763 gnus-killed-list gnus-zombie-list
1764 gnus-topic-topology gnus-topic-alist
1766 "Gnus variables saved in the quick startup file.")
1768 (defvar gnus-newsrc-options nil
1769 "Options line in the .newsrc file.")
1771 (defvar gnus-newsrc-options-n nil
1772 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1774 (defvar gnus-newsrc-last-checked-date nil
1775 "Date Gnus last asked server for new newsgroups.")
1777 (defvar gnus-topic-topology nil
1778 "The complete topic hierarchy.")
1780 (defvar gnus-topic-alist nil
1781 "The complete topic-group alist.")
1783 (defvar gnus-newsrc-alist nil
1784 "Assoc list of read articles.
1785 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1787 (defvar gnus-newsrc-hashtb nil
1788 "Hashtable of gnus-newsrc-alist.")
1790 (defvar gnus-killed-list nil
1791 "List of killed newsgroups.")
1793 (defvar gnus-killed-hashtb nil
1794 "Hash table equivalent of gnus-killed-list.")
1796 (defvar gnus-zombie-list nil
1797 "List of almost dead newsgroups.")
1799 (defvar gnus-description-hashtb nil
1800 "Descriptions of newsgroups.")
1802 (defvar gnus-list-of-killed-groups nil
1803 "List of newsgroups that have recently been killed by the user.")
1805 (defvar gnus-active-hashtb nil
1806 "Hashtable of active articles.")
1808 (defvar gnus-moderated-list nil
1809 "List of moderated newsgroups.")
1811 (defvar gnus-group-marked nil)
1813 (defvar gnus-current-startup-file nil
1814 "Startup file for the current host.")
1816 (defvar gnus-last-search-regexp nil
1817 "Default regexp for article search command.")
1819 (defvar gnus-last-shell-command nil
1820 "Default shell command on article.")
1822 (defvar gnus-current-select-method nil
1823 "The current method for selecting a newsgroup.")
1825 (defvar gnus-group-list-mode nil)
1827 (defvar gnus-article-internal-prepare-hook nil)
1829 (defvar gnus-newsgroup-name nil)
1830 (defvar gnus-newsgroup-begin nil)
1831 (defvar gnus-newsgroup-end nil)
1832 (defvar gnus-newsgroup-last-rmail nil)
1833 (defvar gnus-newsgroup-last-mail nil)
1834 (defvar gnus-newsgroup-last-folder nil)
1835 (defvar gnus-newsgroup-last-file nil)
1836 (defvar gnus-newsgroup-auto-expire nil)
1837 (defvar gnus-newsgroup-active nil)
1839 (defvar gnus-newsgroup-data nil)
1840 (defvar gnus-newsgroup-data-reverse nil)
1841 (defvar gnus-newsgroup-limit nil)
1842 (defvar gnus-newsgroup-limits nil)
1844 (defvar gnus-newsgroup-unreads nil
1845 "List of unread articles in the current newsgroup.")
1847 (defvar gnus-newsgroup-unselected nil
1848 "List of unselected unread articles in the current newsgroup.")
1850 (defvar gnus-newsgroup-reads nil
1851 "Alist of read articles and article marks in the current newsgroup.")
1853 (defvar gnus-newsgroup-expunged-tally nil)
1855 (defvar gnus-newsgroup-marked nil
1856 "List of ticked articles in the current newsgroup (a subset of unread art).")
1858 (defvar gnus-newsgroup-killed nil
1859 "List of ranges of articles that have been through the scoring process.")
1861 (defvar gnus-newsgroup-cached nil
1862 "List of articles that come from the article cache.")
1864 (defvar gnus-newsgroup-saved nil
1865 "List of articles that have been saved.")
1867 (defvar gnus-newsgroup-kill-headers nil)
1869 (defvar gnus-newsgroup-replied nil
1870 "List of articles that have been replied to in the current newsgroup.")
1872 (defvar gnus-newsgroup-expirable nil
1873 "List of articles in the current newsgroup that can be expired.")
1875 (defvar gnus-newsgroup-processable nil
1876 "List of articles in the current newsgroup that can be processed.")
1878 (defvar gnus-newsgroup-bookmarks nil
1879 "List of articles in the current newsgroup that have bookmarks.")
1881 (defvar gnus-newsgroup-dormant nil
1882 "List of dormant articles in the current newsgroup.")
1884 (defvar gnus-newsgroup-scored nil
1885 "List of scored articles in the current newsgroup.")
1887 (defvar gnus-newsgroup-headers nil
1888 "List of article headers in the current newsgroup.")
1890 (defvar gnus-newsgroup-threads nil)
1892 (defvar gnus-newsgroup-prepared nil
1893 "Whether the current group has been prepared properly.")
1895 (defvar gnus-newsgroup-ancient nil
1896 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1898 (defvar gnus-newsgroup-sparse nil)
1900 (defvar gnus-current-article nil)
1901 (defvar gnus-article-current nil)
1902 (defvar gnus-current-headers nil)
1903 (defvar gnus-have-all-headers nil)
1904 (defvar gnus-last-article nil)
1905 (defvar gnus-newsgroup-history nil)
1906 (defvar gnus-current-kill-article nil)
1908 ;; Save window configuration.
1909 (defvar gnus-prev-winconf nil)
1911 (defvar gnus-summary-mark-positions nil)
1912 (defvar gnus-group-mark-positions nil)
1914 (defvar gnus-reffed-article-number nil)
1916 ;;; Let the byte-compiler know that we know about this variable.
1917 (defvar rmail-default-rmail-file)
1919 (defvar gnus-cache-removable-articles nil)
1921 (defvar gnus-dead-summary nil)
1923 (defconst gnus-summary-local-variables
1924 '(gnus-newsgroup-name
1925 gnus-newsgroup-begin gnus-newsgroup-end
1926 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1927 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1928 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1929 gnus-newsgroup-unselected gnus-newsgroup-marked
1930 gnus-newsgroup-reads gnus-newsgroup-saved
1931 gnus-newsgroup-replied gnus-newsgroup-expirable
1932 gnus-newsgroup-processable gnus-newsgroup-killed
1933 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1934 gnus-newsgroup-headers gnus-newsgroup-threads
1935 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1936 gnus-current-article gnus-current-headers gnus-have-all-headers
1937 gnus-last-article gnus-article-internal-prepare-hook
1938 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1939 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1940 gnus-newsgroup-async gnus-thread-expunge-below
1941 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1942 (gnus-summary-mark-below . global)
1943 gnus-newsgroup-active gnus-scores-exclude-files
1944 gnus-newsgroup-history gnus-newsgroup-ancient
1945 gnus-newsgroup-sparse
1946 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1947 gnus-newsgroup-adaptive-score-file
1948 (gnus-newsgroup-expunged-tally . 0)
1949 gnus-cache-removable-articles gnus-newsgroup-cached
1950 gnus-newsgroup-data gnus-newsgroup-data-reverse
1951 gnus-newsgroup-limit gnus-newsgroup-limits)
1952 "Variables that are buffer-local to the summary buffers.")
1954 (defconst gnus-bug-message
1955 "Sending a bug report to the Gnus Towers.
1956 ========================================
1958 The buffer below is a mail buffer. When you press `C-c C-c', it will
1959 be sent to the Gnus Bug Exterminators.
1961 At the bottom of the buffer you'll see lots of variable settings.
1962 Please do not delete those. They will tell the Bug People what your
1963 environment is, so that it will be easier to locate the bugs.
1965 If you have found a bug that makes Emacs go \"beep\", set
1966 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1967 and include the backtrace in your bug report.
1969 Please describe the bug in annoying, painstaking detail.
1971 Thank you for your help in stamping out bugs.
1974 ;;; End of variables.
1976 ;; Define some autoload functions Gnus might use.
1979 ;; This little mapcar goes through the list below and marks the
1980 ;; symbols in question as autoloaded functions.
1983 (let ((interactive (nth 1 (memq ':interactive package))))
1987 (when (consp function)
1988 (setq keymap (car (memq 'keymap function)))
1989 (setq function (car function)))
1990 (autoload function (car package) nil interactive keymap)))
1991 (if (eq (nth 1 package) ':interactive)
1994 '(("metamail" metamail-buffer)
1995 ("info" Info-goto-node)
1996 ("hexl" hexl-hex-string-to-integer)
1997 ("pp" pp pp-to-string pp-eval-expression)
1998 ("mail-extr" mail-extract-address-components)
1999 ("nnmail" nnmail-split-fancy nnmail-article-group)
2000 ("nnvirtual" nnvirtual-catchup-group)
2001 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
2002 timezone-make-sortable-date timezone-make-time-string)
2003 ("rmailout" rmail-output)
2004 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
2006 ("gnus-soup" :interactive t
2007 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
2008 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
2009 ("nnsoup" nnsoup-pack-replies)
2010 ("gnus-scomo" :interactive t gnus-score-mode)
2011 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
2012 gnus-Folder-save-name gnus-folder-save-name)
2013 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
2014 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2015 gnus-server-make-menu-bar gnus-article-make-menu-bar
2016 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2017 gnus-summary-highlight-line gnus-carpal-setup-buffer
2018 gnus-group-highlight-line
2019 gnus-article-add-button gnus-insert-next-page-button
2020 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2021 ("gnus-vis" :interactive t
2022 gnus-article-push-button gnus-article-press-button
2023 gnus-article-highlight gnus-article-highlight-some
2024 gnus-article-highlight-headers gnus-article-highlight-signature
2025 gnus-article-add-buttons gnus-article-add-buttons-to-head
2026 gnus-article-next-button gnus-article-prev-button)
2027 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2028 gnus-demon-add-disconnection gnus-demon-add-handler
2029 gnus-demon-remove-handler)
2030 ("gnus-demon" :interactive t
2031 gnus-demon-init gnus-demon-cancel)
2032 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2033 gnus-tree-open gnus-tree-close)
2034 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2035 gnus-nocem-unwanted-article-p)
2036 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2037 ("gnus-srvr" gnus-browse-foreign-server)
2038 ("gnus-cite" :interactive t
2039 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2040 gnus-article-hide-citation gnus-article-fill-cited-article
2041 gnus-article-hide-citation-in-followups)
2042 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2043 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2044 gnus-execute gnus-expunge)
2045 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2046 gnus-cache-possibly-remove-articles gnus-cache-request-article
2047 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2048 gnus-cache-enter-remove-article gnus-cached-article-p
2049 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2050 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2051 gnus-cache-remove-article)
2052 ("gnus-score" :interactive t
2053 gnus-summary-increase-score gnus-summary-lower-score
2054 gnus-score-flush-cache gnus-score-close
2055 gnus-score-raise-same-subject-and-select
2056 gnus-score-raise-same-subject gnus-score-default
2057 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2058 gnus-score-lower-same-subject gnus-score-lower-thread
2059 gnus-possibly-score-headers gnus-summary-raise-score
2060 gnus-summary-set-score gnus-summary-current-score)
2062 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2063 gnus-current-score-file-nondirectory gnus-score-adaptive
2064 gnus-score-find-trace gnus-score-file-name)
2065 ("gnus-edit" :interactive t gnus-score-customize)
2066 ("gnus-topic" :interactive t gnus-topic-mode)
2067 ("gnus-topic" gnus-topic-remove-group)
2068 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2069 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2070 ("gnus-uu" :interactive t
2071 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2072 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2073 gnus-uu-mark-by-regexp gnus-uu-mark-all
2074 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2075 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2076 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2077 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2078 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2079 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2080 gnus-uu-decode-binhex-view)
2081 ("gnus-msg" (gnus-summary-send-map keymap)
2082 gnus-mail-yank-original gnus-mail-send-and-exit
2083 gnus-sendmail-setup-mail gnus-article-mail
2084 gnus-inews-message-id gnus-new-mail gnus-mail-reply)
2085 ("gnus-msg" :interactive t
2086 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2087 gnus-summary-followup gnus-summary-followup-with-original
2088 gnus-summary-cancel-article gnus-summary-supersede-article
2089 gnus-post-news gnus-inews-news gnus-cancel-news
2090 gnus-summary-reply gnus-summary-reply-with-original
2091 gnus-summary-mail-forward gnus-summary-mail-other-window
2093 ("gnus-picon" :interactive t gnus-article-display-picons
2094 gnus-group-display-picons gnus-picons-article-display-x-face)
2095 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2096 gnus-grouplens-mode)
2097 ("gnus-vm" gnus-vm-mail-setup)
2098 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2099 gnus-summary-save-article-vm))))
2103 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2104 ;; If you want the cursor to go somewhere else, set these two
2105 ;; functions in some startup hook to whatever you want.
2106 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2107 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2109 ;;; Various macros and substs.
2111 (defun gnus-header-from (header)
2112 (mail-header-from header))
2114 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2115 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2116 (let ((tempvar (make-symbol "GnusStartBufferWindow"))
2117 (w (make-symbol "w"))
2118 (buf (make-symbol "buf")))
2119 `(let* ((,tempvar (selected-window))
2121 (,w (get-buffer-window ,buf 'visible)))
2126 (pop-to-buffer ,buf))
2128 (select-window ,tempvar)))))
2130 (defmacro gnus-gethash (string hashtable)
2131 "Get hash value of STRING in HASHTABLE."
2132 `(symbol-value (intern-soft ,string ,hashtable)))
2134 (defmacro gnus-sethash (string value hashtable)
2135 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2136 `(set (intern ,string ,hashtable) ,value))
2138 (defmacro gnus-intern-safe (string hashtable)
2139 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2140 `(let ((symbol (intern ,string ,hashtable)))
2145 (defmacro gnus-group-unread (group)
2146 "Get the currently computed number of unread articles in GROUP."
2147 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2149 (defmacro gnus-group-entry (group)
2150 "Get the newsrc entry for GROUP."
2151 `(gnus-gethash ,group gnus-newsrc-hashtb))
2153 (defmacro gnus-active (group)
2154 "Get active info on GROUP."
2155 `(gnus-gethash ,group gnus-active-hashtb))
2157 (defmacro gnus-set-active (group active)
2158 "Set GROUP's active info."
2159 `(gnus-sethash ,group ,active gnus-active-hashtb))
2161 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2162 ;; function `substring' might cut on a middle of multi-octet
2164 (defun gnus-truncate-string (str width)
2165 (substring str 0 width))
2167 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2168 ;; to limit the length of a string. This function is necessary since
2169 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2170 (defsubst gnus-limit-string (str width)
2171 (if (> (length str) width)
2172 (substring str 0 width)
2175 (defsubst gnus-simplify-subject-re (subject)
2176 "Remove \"Re:\" from subject lines."
2177 (if (string-match "^[Rr][Ee]: *" subject)
2178 (substring subject (match-end 0))
2181 (defsubst gnus-functionp (form)
2182 "Return non-nil if FORM is funcallable."
2183 (or (and (symbolp form) (fboundp form))
2184 (and (listp form) (eq (car form) 'lambda))))
2186 (defsubst gnus-goto-char (point)
2187 (and point (goto-char point)))
2189 (defmacro gnus-buffer-exists-p (buffer)
2190 `(let ((buffer ,buffer))
2192 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2195 (defmacro gnus-kill-buffer (buffer)
2196 `(let ((buf ,buffer))
2197 (if (gnus-buffer-exists-p buf)
2198 (kill-buffer buf))))
2200 (defsubst gnus-point-at-bol ()
2201 "Return point at the beginning of the line."
2208 (defsubst gnus-point-at-eol ()
2209 "Return point at the end of the line."
2216 (defun gnus-alive-p ()
2217 "Say whether Gnus is running or not."
2218 (and gnus-group-buffer
2219 (get-buffer gnus-group-buffer)))
2221 (defun gnus-delete-first (elt list)
2222 "Delete by side effect the first occurrence of ELT as a member of LIST."
2223 (if (equal (car list) elt)
2226 (while (and (cdr list)
2227 (not (equal (cadr list) elt)))
2228 (setq list (cdr list)))
2230 (setcdr list (cddr list)))
2233 ;; Delete the current line (and the next N lines.);
2234 (defmacro gnus-delete-line (&optional n)
2235 `(delete-region (progn (beginning-of-line) (point))
2236 (progn (forward-line ,(or n 1)) (point))))
2238 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2239 (defvar gnus-init-inhibit nil)
2240 (defun gnus-read-init-file (&optional inhibit-next)
2241 (if gnus-init-inhibit
2242 (setq gnus-init-inhibit nil)
2243 (setq gnus-init-inhibit inhibit-next)
2245 (or (and (file-exists-p gnus-init-file)
2246 ;; Don't try to load a directory.
2247 (not (file-directory-p gnus-init-file)))
2248 (file-exists-p (concat gnus-init-file ".el"))
2249 (file-exists-p (concat gnus-init-file ".elc")))
2251 (load gnus-init-file nil t)
2253 (error "Error in %s: %s" gnus-init-file var))))))
2255 ;; Info access macros.
2257 (defmacro gnus-info-group (info)
2259 (defmacro gnus-info-rank (info)
2261 (defmacro gnus-info-read (info)
2263 (defmacro gnus-info-marks (info)
2265 (defmacro gnus-info-method (info)
2267 (defmacro gnus-info-params (info)
2270 (defmacro gnus-info-level (info)
2271 `(let ((rank (gnus-info-rank ,info)))
2275 (defmacro gnus-info-score (info)
2276 `(let ((rank (gnus-info-rank ,info)))
2277 (or (and (consp rank) (cdr rank)) 0)))
2279 (defmacro gnus-info-set-group (info group)
2280 `(setcar ,info ,group))
2281 (defmacro gnus-info-set-rank (info rank)
2282 `(setcar (nthcdr 1 ,info) ,rank))
2283 (defmacro gnus-info-set-read (info read)
2284 `(setcar (nthcdr 2 ,info) ,read))
2285 (defmacro gnus-info-set-marks (info marks)
2286 `(setcar (nthcdr 3 ,info) ,marks))
2287 (defmacro gnus-info-set-method (info method)
2288 `(setcar (nthcdr 4 ,info) ,method))
2289 (defmacro gnus-info-set-params (info params)
2290 `(setcar (nthcdr 5 ,info) ,params))
2292 (defmacro gnus-info-set-level (info level)
2293 `(let ((rank (cdr ,info)))
2294 (if (consp (car rank))
2295 (setcar (car rank) ,level)
2296 (setcar rank ,level))))
2297 (defmacro gnus-info-set-score (info score)
2298 `(let ((rank (cdr ,info)))
2299 (if (consp (car rank))
2300 (setcdr (car rank) ,score)
2301 (setcar rank (cons (car rank) ,score)))))
2303 (defmacro gnus-get-info (group)
2304 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2306 (defun gnus-byte-code (func)
2307 "Return a form that can be `eval'ed based on FUNC."
2308 (let ((fval (symbol-function func)))
2309 (if (byte-code-function-p fval)
2310 (let ((flist (append fval nil)))
2311 (setcar flist 'byte-code)
2313 (cons 'progn (cddr fval)))))
2315 ;;; Load the compatability functions.
2325 (defvar gnus-shutdown-alist nil)
2327 (defun gnus-add-shutdown (function &rest symbols)
2328 "Run FUNCTION whenever one of SYMBOLS is shut down."
2329 (push (cons function symbols) gnus-shutdown-alist))
2331 (defun gnus-shutdown (symbol)
2332 "Shut down everything that waits for SYMBOL."
2333 (let ((alist gnus-shutdown-alist)
2335 (while (setq entry (pop alist))
2336 (when (memq symbol (cdr entry))
2337 (funcall (car entry))))))
2341 ;; Format specs. The chunks below are the machine-generated forms
2342 ;; that are to be evaled as the result of the default format strings.
2343 ;; We write them in here to get them byte-compiled. That way the
2344 ;; default actions will be quite fast, while still retaining the full
2345 ;; flexibility of the user-defined format specs.
2347 ;; First we have lots of dummy defvars to let the compiler know these
2348 ;; are really dynamic variables.
2350 (defvar gnus-tmp-unread)
2351 (defvar gnus-tmp-replied)
2352 (defvar gnus-tmp-score-char)
2353 (defvar gnus-tmp-indentation)
2354 (defvar gnus-tmp-opening-bracket)
2355 (defvar gnus-tmp-lines)
2356 (defvar gnus-tmp-name)
2357 (defvar gnus-tmp-closing-bracket)
2358 (defvar gnus-tmp-subject-or-nil)
2359 (defvar gnus-tmp-subject)
2360 (defvar gnus-tmp-marked)
2361 (defvar gnus-tmp-marked-mark)
2362 (defvar gnus-tmp-subscribed)
2363 (defvar gnus-tmp-process-marked)
2364 (defvar gnus-tmp-number-of-unread)
2365 (defvar gnus-tmp-group-name)
2366 (defvar gnus-tmp-group)
2367 (defvar gnus-tmp-article-number)
2368 (defvar gnus-tmp-unread-and-unselected)
2369 (defvar gnus-tmp-news-method)
2370 (defvar gnus-tmp-news-server)
2371 (defvar gnus-tmp-article-number)
2372 (defvar gnus-mouse-face)
2373 (defvar gnus-mouse-face-prop)
2375 (defun gnus-summary-line-format-spec ()
2376 (insert gnus-tmp-unread gnus-tmp-replied
2377 gnus-tmp-score-char gnus-tmp-indentation)
2378 (gnus-put-text-property
2382 gnus-tmp-opening-bracket
2383 (format "%4d: %-20s"
2385 (if (> (length gnus-tmp-name) 20)
2386 (substring gnus-tmp-name 0 20)
2388 gnus-tmp-closing-bracket)
2390 gnus-mouse-face-prop gnus-mouse-face)
2391 (insert " " gnus-tmp-subject-or-nil "\n"))
2393 (defvar gnus-summary-line-format-spec
2394 (gnus-byte-code 'gnus-summary-line-format-spec))
2396 (defun gnus-summary-dummy-line-format-spec ()
2398 (gnus-put-text-property
2403 gnus-mouse-face-prop gnus-mouse-face)
2404 (insert " " gnus-tmp-subject "\n"))
2406 (defvar gnus-summary-dummy-line-format-spec
2407 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2409 (defun gnus-group-line-format-spec ()
2410 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2411 gnus-tmp-process-marked
2412 gnus-group-indentation
2413 (format "%5s: " gnus-tmp-number-of-unread))
2414 (gnus-put-text-property
2417 (insert gnus-tmp-group "\n")
2419 gnus-mouse-face-prop gnus-mouse-face))
2420 (defvar gnus-group-line-format-spec
2421 (gnus-byte-code 'gnus-group-line-format-spec))
2423 (defvar gnus-format-specs
2424 `((version . ,emacs-version)
2425 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2426 (summary-dummy ,gnus-summary-dummy-line-format
2427 ,gnus-summary-dummy-line-format-spec)
2428 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2430 (defvar gnus-article-mode-line-format-spec nil)
2431 (defvar gnus-summary-mode-line-format-spec nil)
2432 (defvar gnus-group-mode-line-format-spec nil)
2434 ;;; Phew. All that gruft is over, fortunately.
2438 ;;; Gnus Utility Functions
2441 (defun gnus-extract-address-components (from)
2443 ;; First find the address - the thing with the @ in it. This may
2444 ;; not be accurate in mail addresses, but does the trick most of
2445 ;; the time in news messages.
2446 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2447 (setq address (substring from (match-beginning 0) (match-end 0))))
2448 ;; Then we check whether the "name <address>" format is used.
2450 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2451 ;; Linear white space is not required.
2452 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2453 (and (setq name (substring from 0 (match-beginning 0)))
2454 ;; Strip any quotes from the name.
2455 (string-match "\".*\"" name)
2456 (setq name (substring name 1 (1- (match-end 0))))))
2457 ;; If not, then "address (name)" is used.
2459 (and (string-match "(.+)" from)
2460 (setq name (substring from (1+ (match-beginning 0))
2461 (1- (match-end 0)))))
2462 (and (string-match "()" from)
2463 (setq name address))
2464 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2465 ;; XOVER might not support folded From headers.
2466 (and (string-match "(.*" from)
2467 (setq name (substring from (1+ (match-beginning 0))
2469 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2470 (list (or name from) (or address from))))
2472 (defun gnus-fetch-field (field)
2473 "Return the value of the header FIELD of current article."
2476 (let ((case-fold-search t)
2477 (inhibit-point-motion-hooks t))
2478 (nnheader-narrow-to-headers)
2479 (message-fetch-field field)))))
2481 (defun gnus-goto-colon ()
2483 (search-forward ":" (gnus-point-at-eol) t))
2486 (defun gnus-update-format (var)
2487 "Update the format specification near point."
2492 ;; Find the end of the current word.
2493 (re-search-forward "[ \t\n]" nil t)
2495 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2496 (match-string 1)))))
2497 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2498 (match-string 1 var))))
2499 (entry (assq type gnus-format-specs))
2502 (setq gnus-format-specs (delq entry gnus-format-specs)))
2504 (intern (format "%s-spec" var))
2505 (gnus-parse-format (setq value (symbol-value (intern var)))
2506 (symbol-value (intern (format "%s-alist" var)))
2507 (not (string-match "mode" var))))
2508 (setq spec (symbol-value (intern (format "%s-spec" var))))
2509 (push (list type value spec) gnus-format-specs)
2511 (pop-to-buffer "*Gnus Format*")
2513 (lisp-interaction-mode)
2514 (insert (pp-to-string spec))))
2516 (defun gnus-update-format-specifications (&optional force)
2517 "Update all (necessary) format specifications."
2518 ;; Make the indentation array.
2519 (gnus-make-thread-indent-array)
2521 ;; See whether all the stored info needs to be flushed.
2523 (not (equal emacs-version
2524 (cdr (assq 'version gnus-format-specs)))))
2525 (setq gnus-format-specs nil))
2527 ;; Go through all the formats and see whether they need updating.
2528 (let ((types '(summary summary-dummy group
2529 summary-mode group-mode article-mode))
2530 new-format entry type val)
2531 (while (setq type (pop types))
2532 ;; Jump to the proper buffer to find out the value of
2533 ;; the variable, if possible. (It may be buffer-local.)
2535 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2537 (when (and (boundp buffer)
2538 (setq val (symbol-value buffer))
2540 (buffer-name (get-buffer val)))
2541 (set-buffer (get-buffer val)))
2542 (setq new-format (symbol-value
2543 (intern (format "gnus-%s-line-format" type))))))
2544 (setq entry (cdr (assq type gnus-format-specs)))
2546 (equal (car entry) new-format))
2547 ;; Use the old format.
2548 (set (intern (format "gnus-%s-line-format-spec" type))
2550 ;; This is a new format.
2552 (if (not (stringp new-format))
2553 ;; This is a function call or something.
2555 ;; This is a "real" format.
2559 (intern (format "gnus-%s-line-format-alist"
2560 (if (eq type 'article-mode)
2561 'summary-mode type))))
2562 (not (string-match "mode$" (symbol-name type))))))
2563 ;; Enter the new format spec into the list.
2566 (setcar (cdr entry) val)
2567 (setcar entry new-format))
2568 (push (list type new-format val) gnus-format-specs))
2569 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2571 (unless (assq 'version gnus-format-specs)
2572 (push (cons 'version emacs-version) gnus-format-specs))
2574 (gnus-update-group-mark-positions)
2575 (gnus-update-summary-mark-positions))
2577 (defun gnus-update-summary-mark-positions ()
2578 "Compute where the summary marks are to go."
2580 (when (and gnus-summary-buffer
2581 (get-buffer gnus-summary-buffer)
2582 (buffer-name (get-buffer gnus-summary-buffer)))
2583 (set-buffer gnus-summary-buffer))
2584 (let ((gnus-replied-mark 129)
2585 (gnus-score-below-mark 130)
2586 (gnus-score-over-mark 130)
2589 (spec gnus-summary-line-format-spec)
2592 (gnus-set-work-buffer)
2593 (let ((gnus-summary-line-format-spec spec))
2594 (gnus-summary-insert-line
2595 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2596 (goto-char (point-min))
2597 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2599 (goto-char (point-min))
2600 (push (cons 'replied (and (search-forward "\201" nil t)
2603 (goto-char (point-min))
2604 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2606 (setq gnus-summary-mark-positions pos))))
2608 (defun gnus-update-group-mark-positions ()
2610 (let ((gnus-process-mark 128)
2611 (gnus-group-marked '("dummy.group"))
2612 (gnus-active-hashtb (make-vector 10 0)))
2613 (gnus-set-active "dummy.group" '(0 . 0))
2614 (gnus-set-work-buffer)
2615 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2616 (goto-char (point-min))
2617 (setq gnus-group-mark-positions
2618 (list (cons 'process (and (search-forward "\200" nil t)
2619 (- (point) 2))))))))
2621 (defvar gnus-mouse-face-0 'highlight)
2622 (defvar gnus-mouse-face-1 'highlight)
2623 (defvar gnus-mouse-face-2 'highlight)
2624 (defvar gnus-mouse-face-3 'highlight)
2625 (defvar gnus-mouse-face-4 'highlight)
2627 (defun gnus-mouse-face-function (form type)
2628 `(gnus-put-text-property
2629 (point) (progn ,@form (point))
2630 gnus-mouse-face-prop
2633 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2635 (defvar gnus-face-0 'bold)
2636 (defvar gnus-face-1 'italic)
2637 (defvar gnus-face-2 'bold-italic)
2638 (defvar gnus-face-3 'bold)
2639 (defvar gnus-face-4 'bold)
2641 (defun gnus-face-face-function (form type)
2642 `(gnus-put-text-property
2643 (point) (progn ,@form (point))
2644 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2646 (defun gnus-max-width-function (el max-width)
2647 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2649 `(if (> (length ,el) ,max-width)
2650 (substring ,el 0 ,max-width)
2652 `(let ((val (eval ,el)))
2654 (setq val (int-to-string val)))
2655 (if (> (length val) ,max-width)
2656 (substring val 0 ,max-width)
2659 (defun gnus-parse-format (format spec-alist &optional insert)
2660 ;; This function parses the FORMAT string with the help of the
2661 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2662 ;; string. If the FORMAT string contains the specifiers %( and %)
2663 ;; the text between them will have the mouse-face text property.
2665 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2667 (gnus-parse-complex-format format spec-alist)
2668 ;; This is a simple format.
2669 (gnus-parse-simple-format format spec-alist insert)))
2671 (defun gnus-parse-complex-format (format spec-alist)
2673 (gnus-set-work-buffer)
2675 (goto-char (point-min))
2676 (while (re-search-forward "\"" nil t)
2677 (replace-match "\\\"" nil t))
2678 (goto-char (point-min))
2680 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2681 (let ((number (if (match-beginning 1)
2682 (match-string 1) "0"))
2683 (delim (aref (match-string 2) 0)))
2684 (if (or (= delim ?\() (= delim ?\{))
2685 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2687 (replace-match "\")\""))))
2688 (goto-char (point-max))
2690 (goto-char (point-min))
2691 (let ((form (read (current-buffer))))
2692 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2694 (defun gnus-complex-form-to-spec (form spec-alist)
2699 (gnus-parse-simple-format sform spec-alist t)
2700 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2701 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2705 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2706 ;; This function parses the FORMAT string with the help of the
2707 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2710 spec flist fstring newspec elem beg result dontinsert)
2712 (gnus-set-work-buffer)
2714 (goto-char (point-min))
2715 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2717 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2719 beg (1+ (match-beginning 0)))
2720 ;; First check if there are any specs that look anything like
2721 ;; "%12,12A", ie. with a "max width specification". These have
2722 ;; to be treated specially.
2723 (if (setq beg (match-beginning 1))
2727 (1+ (match-beginning 1)) (match-end 1))))
2729 (setq beg (match-beginning 2)))
2730 ;; Find the specification from `spec-alist'.
2731 (unless (setq elem (cdr (assq spec spec-alist)))
2732 (setq elem '("*" ?s)))
2733 ;; Treat user defined format specifiers specially.
2734 (when (eq (car elem) 'gnus-tmp-user-defined)
2737 (list (intern (concat "gnus-user-format-function-"
2739 'gnus-tmp-header) ?s))
2740 (delete-region (match-beginning 3) (match-end 3)))
2741 (if (not (zerop max-width))
2742 (let ((el (car elem)))
2743 (cond ((= (cadr elem) ?c)
2744 (setq el (list 'char-to-string el)))
2746 (setq el (list 'int-to-string el))))
2747 (setq flist (cons (gnus-max-width-function el max-width)
2751 (setq flist (cons (car elem) flist))
2752 (setq newspec (cadr elem)))))
2753 ;; Remove the old specification (and possibly a ",12" string).
2754 (delete-region beg (match-end 2))
2755 ;; Insert the new specification.
2758 (setq fstring (buffer-substring 1 (point-max))))
2759 ;; Do some postprocessing to increase efficiency.
2764 ((string= fstring "")
2766 ;; Not a format string.
2767 ((not (string-match "%" fstring))
2769 ;; A format string with just a single string spec.
2770 ((string= fstring "%s")
2772 ;; A single character.
2773 ((string= fstring "%c")
2776 ((string= fstring "%d")
2779 (list `(princ ,(car flist)))
2780 (list `(int-to-string ,(car flist)))))
2781 ;; Just lots of chars and strings.
2782 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2784 ;; A single string spec at the beginning of the spec.
2785 ((string-match "\\`%[sc][^%]+\\'" fstring)
2786 (list (car flist) (substring fstring 2)))
2787 ;; A single string spec in the middle of the spec.
2788 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2789 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2790 ;; A single string spec in the end of the spec.
2791 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2792 (list (match-string 1 fstring) (car flist)))
2793 ;; A more complex spec.
2795 (list (cons 'format (cons fstring (nreverse flist)))))))
2801 (cons 'insert result)))
2802 (cond ((stringp result)
2805 (cons 'concat result))
2808 (defun gnus-eval-format (format &optional alist props)
2809 "Eval the format variable FORMAT, using ALIST.
2810 If PROPS, insert the result."
2811 (let ((form (gnus-parse-format format alist props)))
2813 (gnus-add-text-properties (point) (progn (eval form) (point)) props)
2816 (defun gnus-remove-text-with-property (prop)
2817 "Delete all text in the current buffer with text property PROP."
2819 (goto-char (point-min))
2821 (while (get-text-property (point) prop)
2823 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2825 (defun gnus-set-work-buffer ()
2826 (if (get-buffer gnus-work-buffer)
2828 (set-buffer gnus-work-buffer)
2830 (set-buffer (get-buffer-create gnus-work-buffer))
2831 (kill-all-local-variables)
2832 (buffer-disable-undo (current-buffer))
2833 (gnus-add-current-to-buffer-list)))
2835 ;; Article file names when saving.
2837 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2838 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2839 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2840 Otherwise, it is like ~/News/news/group/num."
2843 (concat (if (gnus-use-long-file-name 'not-save)
2844 (gnus-capitalize-newsgroup newsgroup)
2845 (gnus-newsgroup-directory-form newsgroup))
2846 "/" (int-to-string (mail-header-number headers)))
2847 gnus-article-save-directory)))
2849 (string-equal (file-name-directory default)
2850 (file-name-directory last-file))
2851 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2853 (or last-file default))))
2855 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2856 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2857 If variable `gnus-use-long-file-name' is non-nil, it is
2858 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2861 (concat (if (gnus-use-long-file-name 'not-save)
2863 (gnus-newsgroup-directory-form newsgroup))
2864 "/" (int-to-string (mail-header-number headers)))
2865 gnus-article-save-directory)))
2867 (string-equal (file-name-directory default)
2868 (file-name-directory last-file))
2869 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2871 (or last-file default))))
2873 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2874 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2875 If variable `gnus-use-long-file-name' is non-nil, it is
2876 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2879 (if (gnus-use-long-file-name 'not-save)
2880 (gnus-capitalize-newsgroup newsgroup)
2881 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2882 gnus-article-save-directory)))
2884 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2885 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2886 If variable `gnus-use-long-file-name' is non-nil, it is
2887 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2890 (if (gnus-use-long-file-name 'not-save)
2892 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2893 gnus-article-save-directory)))
2895 ;; For subscribing new newsgroup
2897 (defun gnus-subscribe-hierarchical-interactive (groups)
2898 (let ((groups (sort groups 'string<))
2899 prefixes prefix start ans group starts)
2901 (setq prefixes (list "^"))
2902 (while (and groups prefixes)
2903 (while (not (string-match (car prefixes) (car groups)))
2904 (setq prefixes (cdr prefixes)))
2905 (setq prefix (car prefixes))
2906 (setq start (1- (length prefix)))
2907 (if (and (string-match "[^\\.]\\." (car groups) start)
2910 (concat "^" (substring (car groups) 0 (match-end 0))))
2911 (string-match prefix (cadr groups)))
2913 (setq prefixes (cons prefix prefixes))
2914 (message "Descend hierarchy %s? ([y]nsq): "
2915 (substring prefix 1 (1- (length prefix))))
2916 (while (not (memq (setq ans (read-char)) '(?y ?\n ?n ?s ?q)))
2918 (message "Descend hierarchy %s? ([y]nsq): "
2919 (substring prefix 1 (1- (length prefix)))))
2922 (string-match prefix
2923 (setq group (car groups))))
2924 (setq gnus-killed-list
2925 (cons group gnus-killed-list))
2926 (gnus-sethash group group gnus-killed-hashtb)
2927 (setq groups (cdr groups)))
2928 (setq starts (cdr starts)))
2931 (string-match prefix
2932 (setq group (car groups))))
2933 (gnus-sethash group group gnus-killed-hashtb)
2934 (gnus-subscribe-alphabetically (car groups))
2935 (setq groups (cdr groups)))
2936 (setq starts (cdr starts)))
2939 (setq group (car groups))
2940 (setq gnus-killed-list (cons group gnus-killed-list))
2941 (gnus-sethash group group gnus-killed-hashtb)
2942 (setq groups (cdr groups))))
2944 (message "Subscribe %s? ([n]yq)" (car groups))
2945 (while (not (memq (setq ans (read-char)) '(?y ?\n ?q ?n)))
2947 (message "Subscribe %s? ([n]yq)" (car groups)))
2948 (setq group (car groups))
2950 (gnus-subscribe-alphabetically (car groups))
2951 (gnus-sethash group group gnus-killed-hashtb))
2954 (setq group (car groups))
2955 (setq gnus-killed-list (cons group gnus-killed-list))
2956 (gnus-sethash group group gnus-killed-hashtb)
2957 (setq groups (cdr groups))))
2959 (setq gnus-killed-list (cons group gnus-killed-list))
2960 (gnus-sethash group group gnus-killed-hashtb)))
2961 (setq groups (cdr groups)))))))
2963 (defun gnus-subscribe-randomly (newsgroup)
2964 "Subscribe new NEWSGROUP by making it the first newsgroup."
2965 (gnus-subscribe-newsgroup newsgroup))
2967 (defun gnus-subscribe-alphabetically (newgroup)
2968 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2969 (let ((groups (cdr gnus-newsrc-alist))
2971 (while (and (not before) groups)
2972 (if (string< newgroup (caar groups))
2973 (setq before (caar groups))
2974 (setq groups (cdr groups))))
2975 (gnus-subscribe-newsgroup newgroup before)))
2977 (defun gnus-subscribe-hierarchically (newgroup)
2978 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2979 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2981 (set-buffer (find-file-noselect gnus-current-startup-file))
2982 (let ((groupkey newgroup)
2984 (while (and (not before) groupkey)
2985 (goto-char (point-min))
2987 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2988 (while (and (re-search-forward groupkey-re nil t)
2990 (setq before (match-string 1))
2991 (string< before newgroup)))))
2992 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2994 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2995 (substring groupkey (match-beginning 1) (match-end 1)))))
2996 (gnus-subscribe-newsgroup newgroup before))))
2998 (defun gnus-subscribe-interactively (group)
2999 "Subscribe the new GROUP interactively.
3000 It is inserted in hierarchical newsgroup order if subscribed. If not,
3002 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
3003 (gnus-subscribe-hierarchically group)
3004 (push group gnus-killed-list)))
3006 (defun gnus-subscribe-zombies (group)
3007 "Make the new GROUP into a zombie group."
3008 (push group gnus-zombie-list))
3010 (defun gnus-subscribe-killed (group)
3011 "Make the new GROUP a killed group."
3012 (push group gnus-killed-list))
3014 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
3015 "Subscribe new NEWSGROUP.
3016 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
3017 the first newsgroup."
3018 ;; We subscribe the group by changing its level to `subscribed'.
3019 (gnus-group-change-level
3020 newsgroup gnus-level-default-subscribed
3021 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
3022 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
3026 (defun gnus-newsgroup-directory-form (newsgroup)
3027 "Make hierarchical directory name from NEWSGROUP name."
3028 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
3029 (len (length newsgroup))
3031 ;; If this is a foreign group, we don't want to translate the
3033 (if (setq idx (string-match ":" newsgroup))
3034 (aset newsgroup idx ?/)
3036 ;; Replace all occurrences of `.' with `/'.
3038 (if (= (aref newsgroup idx) ?.)
3039 (aset newsgroup idx ?/))
3040 (setq idx (1+ idx)))
3043 (defun gnus-newsgroup-savable-name (group)
3044 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
3046 (nnheader-replace-chars-in-string group ?/ ?.))
3048 (defun gnus-make-directory (dir)
3049 "Make DIRECTORY recursively."
3050 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
3051 ;; of the many mysteries of the universe.
3052 (let* ((dir (expand-file-name dir default-directory))
3054 (if (string-match "/$" dir)
3055 (setq dir (substring dir 0 (match-beginning 0))))
3056 ;; First go down the path until we find a directory that exists.
3057 (while (not (file-exists-p dir))
3058 (setq dirs (cons dir dirs))
3059 (string-match "/[^/]+$" dir)
3060 (setq dir (substring dir 0 (match-beginning 0))))
3061 ;; Then create all the subdirs.
3062 (while (and dirs (not err))
3064 (make-directory (car dirs))
3065 (error (setq err t)))
3066 (setq dirs (cdr dirs)))
3067 ;; We return whether we were successful or not.
3070 (defun gnus-capitalize-newsgroup (newsgroup)
3071 "Capitalize NEWSGROUP name."
3072 (and (not (zerop (length newsgroup)))
3073 (concat (char-to-string (upcase (aref newsgroup 0)))
3074 (substring newsgroup 1))))
3076 ;; Various... things.
3078 (defun gnus-simplify-subject (subject &optional re-only)
3079 "Remove `Re:' and words in parentheses.
3080 If RE-ONLY is non-nil, strip leading `Re:'s only."
3081 (let ((case-fold-search t)) ;Ignore case.
3082 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3083 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3084 (setq subject (substring subject (match-end 0))))
3085 ;; Remove uninteresting prefixes.
3086 (if (and (not re-only)
3087 gnus-simplify-ignored-prefixes
3088 (string-match gnus-simplify-ignored-prefixes subject))
3089 (setq subject (substring subject (match-end 0))))
3090 ;; Remove words in parentheses from end.
3092 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3093 (setq subject (substring subject 0 (match-beginning 0)))))
3094 ;; Return subject string.
3097 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3099 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3100 (defun gnus-simplify-buffer-fuzzy ()
3101 (goto-char (point-min))
3102 (while (search-forward "\t" nil t)
3103 (replace-match " " t t))
3104 (goto-char (point-min))
3105 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3106 (goto-char (match-beginning 0))
3108 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3109 (looking-at "^[[].*: .*[]]$"))
3110 (goto-char (point-min))
3111 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3113 (replace-match "" t t))
3114 (goto-char (point-min))
3115 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3116 (goto-char (match-end 0))
3119 (progn (goto-char (match-beginning 0)))
3120 (re-search-forward ":"))))
3121 (goto-char (point-min))
3122 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3123 (replace-match "" t t))
3124 (goto-char (point-min))
3125 (while (re-search-forward " +" nil t)
3126 (replace-match " " t t))
3127 (goto-char (point-min))
3128 (while (re-search-forward " $" nil t)
3129 (replace-match "" t t))
3130 (goto-char (point-min))
3131 (while (re-search-forward "^ +" nil t)
3132 (replace-match "" t t))
3133 (goto-char (point-min))
3134 (when gnus-simplify-subject-fuzzy-regexp
3135 (if (listp gnus-simplify-subject-fuzzy-regexp)
3136 (let ((list gnus-simplify-subject-fuzzy-regexp))
3138 (goto-char (point-min))
3139 (while (re-search-forward (car list) nil t)
3140 (replace-match "" t t))
3141 (setq list (cdr list))))
3142 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3143 (replace-match "" t t)))))
3145 (defun gnus-simplify-subject-fuzzy (subject)
3146 "Siplify a subject string fuzzily."
3148 (gnus-set-work-buffer)
3149 (let ((case-fold-search t))
3151 (inline (gnus-simplify-buffer-fuzzy))
3154 ;; Add the current buffer to the list of buffers to be killed on exit.
3155 (defun gnus-add-current-to-buffer-list ()
3156 (or (memq (current-buffer) gnus-buffer-list)
3157 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3159 (defun gnus-string> (s1 s2)
3160 (not (or (string< s1 s2)
3163 (defun gnus-read-active-file-p ()
3164 "Say whether the active file has been read from `gnus-select-method'."
3165 (memq gnus-select-method gnus-have-read-active-file))
3167 ;;; General various misc type functions.
3169 (defun gnus-clear-system ()
3170 "Clear all variables and buffers."
3171 ;; Clear Gnus variables.
3172 (let ((variables gnus-variable-list))
3174 (set (car variables) nil)
3175 (setq variables (cdr variables))))
3176 ;; Clear other internal variables.
3177 (setq gnus-list-of-killed-groups nil
3178 gnus-have-read-active-file nil
3179 gnus-newsrc-alist nil
3180 gnus-newsrc-hashtb nil
3181 gnus-killed-list nil
3182 gnus-zombie-list nil
3183 gnus-killed-hashtb nil
3184 gnus-active-hashtb nil
3185 gnus-moderated-list nil
3186 gnus-description-hashtb nil
3187 gnus-current-headers nil
3188 gnus-thread-indent-array nil
3189 gnus-newsgroup-headers nil
3190 gnus-newsgroup-name nil
3191 gnus-server-alist nil
3192 gnus-group-list-mode nil
3193 gnus-opened-servers nil
3194 gnus-current-select-method nil)
3195 (gnus-shutdown 'gnus)
3196 ;; Kill the startup file.
3197 (and gnus-current-startup-file
3198 (get-file-buffer gnus-current-startup-file)
3199 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3200 ;; Clear the dribble buffer.
3201 (gnus-dribble-clear)
3202 ;; Kill global KILL file buffer.
3203 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3204 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3205 (gnus-kill-buffer nntp-server-buffer)
3206 ;; Kill Gnus buffers.
3207 (while gnus-buffer-list
3208 (gnus-kill-buffer (pop gnus-buffer-list)))
3209 ;; Remove Gnus frames.
3210 (while gnus-created-frames
3211 (when (frame-live-p (car gnus-created-frames))
3212 ;; We slap a condition-case around this `delete-frame' to ensure
3213 ;; agains errors if we try do delete the single frame that's left.
3215 (delete-frame (car gnus-created-frames))
3217 (pop gnus-created-frames)))
3219 (defun gnus-windows-old-to-new (setting)
3220 ;; First we take care of the really, really old Gnus 3 actions.
3221 (when (symbolp setting)
3223 ;; Take care of ooold GNUS 3.x values.
3224 (cond ((eq setting 'SelectArticle) 'article)
3225 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3226 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3228 (if (or (listp setting)
3229 (not (and gnus-window-configuration
3230 (memq setting '(group summary article)))))
3232 (let* ((setting (if (eq setting 'group)
3233 (if (assq 'newsgroup gnus-window-configuration)
3235 'newsgroups) setting))
3236 (elem (cadr (assq setting gnus-window-configuration)))
3237 (total (apply '+ elem))
3238 (types '(group summary article))
3239 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3244 (or (not (numberp (nth i elem)))
3245 (zerop (nth i elem))
3247 (setq perc (/ (float (nth 0 elem)) total))
3248 (setq out (cons (if (eq pbuf (nth i types))
3249 (vector (nth i types) perc 'point)
3250 (vector (nth i types) perc))
3253 (list (nreverse out)))))
3256 (defun gnus-add-configuration (conf)
3257 "Add the window configuration CONF to `gnus-buffer-configuration'."
3258 (setq gnus-buffer-configuration
3259 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3260 gnus-buffer-configuration))))
3262 (defvar gnus-frame-list nil)
3264 (defun gnus-configure-frame (split &optional window)
3265 "Split WINDOW according to SPLIT."
3267 (setq window (get-buffer-window (current-buffer))))
3268 (select-window window)
3269 ;; This might be an old-stylee buffer config.
3270 (when (vectorp split)
3271 (setq split (append split nil)))
3272 (when (or (consp (car split))
3273 (vectorp (car split)))
3275 (push 'vertical split))
3276 ;; The SPLIT might be something that is to be evaled to
3277 ;; return a new SPLIT.
3278 (while (and (not (assq (car split) gnus-window-to-buffer))
3279 (gnus-functionp (car split)))
3280 (setq split (eval split)))
3281 (let* ((type (car split))
3283 (len (if (eq type 'horizontal) (window-width) (window-height)))
3285 (window-min-width (or gnus-window-min-width window-min-width))
3286 (window-min-height (or gnus-window-min-height window-min-height))
3287 s result new-win rest comp-subs size sub)
3289 ;; Nothing to do here.
3291 ;; Don't switch buffers.
3293 (and (memq 'point split) window))
3294 ;; This is a buffer to be selected.
3295 ((not (memq type '(frame horizontal vertical)))
3296 (let ((buffer (cond ((stringp type) type)
3297 (t (cdr (assq type gnus-window-to-buffer)))))
3300 (error "Illegal buffer type: %s" type))
3301 (unless (setq buf (get-buffer (if (symbolp buffer)
3302 (symbol-value buffer) buffer)))
3303 (setq buf (get-buffer-create (if (symbolp buffer)
3304 (symbol-value buffer) buffer))))
3305 (switch-to-buffer buf)
3306 ;; We return the window if it has the `point' spec.
3307 (and (memq 'point split) window)))
3308 ;; This is a frame split.
3310 (unless gnus-frame-list
3311 (setq gnus-frame-list (list (window-frame
3312 (get-buffer-window (current-buffer))))))
3314 params frame fresult)
3315 (while (< i (length subs))
3316 ;; Frame parameter is gotten from the sub-split.
3317 (setq params (cadr (elt subs i)))
3318 ;; It should be a list.
3319 (unless (listp params)
3321 ;; Create a new frame?
3322 (unless (setq frame (elt gnus-frame-list i))
3323 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3324 (push frame gnus-created-frames))
3325 ;; Is the old frame still alive?
3326 (unless (frame-live-p frame)
3327 (setcar (nthcdr i gnus-frame-list)
3328 (setq frame (make-frame params))))
3329 ;; Select the frame in question and do more splits there.
3330 (select-frame frame)
3331 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3333 ;; Select the frame that has the selected buffer.
3335 (select-frame (window-frame fresult)))))
3336 ;; This is a normal split.
3338 (when (> (length subs) 0)
3339 ;; First we have to compute the sizes of all new windows.
3341 (setq sub (append (pop subs) nil))
3342 (while (and (not (assq (car sub) gnus-window-to-buffer))
3343 (gnus-functionp (car sub)))
3344 (setq sub (eval sub)))
3346 (push sub comp-subs)
3347 (setq size (cadar comp-subs))
3348 (cond ((equal size 1.0)
3349 (setq rest (car comp-subs))
3352 (setq s (floor (* size len))))
3356 (error "Illegal size: %s" size)))
3357 ;; Try to make sure that we are inside the safe limits.
3359 ((eq type 'horizontal)
3360 (setq s (max s window-min-width)))
3361 ((eq type 'vertical)
3362 (setq s (max s window-min-height))))
3363 (setcar (cdar comp-subs) s)
3365 ;; Take care of the "1.0" spec.
3367 (setcar (cdr rest) (- len total))
3368 (error "No 1.0 specs in %s" split))
3369 ;; The we do the actual splitting in a nice recursive
3371 (setq comp-subs (nreverse comp-subs))
3373 (if (null (cdr comp-subs))
3374 (setq new-win window)
3376 (split-window window (cadar comp-subs)
3377 (eq type 'horizontal))))
3378 (setq result (or (gnus-configure-frame
3379 (car comp-subs) window) result))
3380 (select-window new-win)
3381 (setq window new-win)
3382 (setq comp-subs (cdr comp-subs))))
3383 ;; Return the proper window, if any.
3385 (select-window result))))))
3387 (defvar gnus-frame-split-p nil)
3389 (defun gnus-configure-windows (setting &optional force)
3390 (setq setting (gnus-windows-old-to-new setting))
3391 (let ((split (if (symbolp setting)
3392 (cadr (assq setting gnus-buffer-configuration))
3396 (setq gnus-frame-split-p nil)
3399 (error "No such setting: %s" setting))
3401 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3403 ;; All the windows mentioned are already visible, so we just
3404 ;; put point in the assigned buffer, and do not touch the
3406 (select-window all-visible)
3408 ;; Either remove all windows or just remove all Gnus windows.
3409 (let ((frame (selected-frame)))
3411 (if gnus-use-full-window
3412 ;; We want to remove all other windows.
3413 (if (not gnus-frame-split-p)
3414 ;; This is not a `frame' split, so we ignore the
3416 (delete-other-windows)
3417 ;; This is a `frame' split, so we delete all windows
3421 (unless (eq (cdr (assq 'minibuffer
3422 (frame-parameters frame)))
3424 (select-frame frame)
3425 (delete-other-windows)))
3427 ;; Just remove some windows.
3428 (gnus-remove-some-windows)
3429 (switch-to-buffer nntp-server-buffer))
3430 (select-frame frame)))
3432 (switch-to-buffer nntp-server-buffer)
3433 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3435 (defun gnus-all-windows-visible-p (split)
3436 "Say whether all buffers in SPLIT are currently visible.
3437 In particular, the value returned will be the window that
3439 (let ((stack (list split))
3441 type buffer win buf)
3442 (while (and (setq split (pop stack))
3444 ;; Be backwards compatible.
3445 (when (vectorp split)
3446 (setq split (append split nil)))
3447 (when (or (consp (car split))
3448 (vectorp (car split)))
3450 (push 'vertical split))
3451 ;; The SPLIT might be something that is to be evaled to
3452 ;; return a new SPLIT.
3453 (while (and (not (assq (car split) gnus-window-to-buffer))
3454 (gnus-functionp (car split)))
3455 (setq split (eval split)))
3457 (setq type (elt split 0))
3462 ((not (memq type '(horizontal vertical frame)))
3463 (setq buffer (cond ((stringp type) type)
3464 (t (cdr (assq type gnus-window-to-buffer)))))
3466 (error "Illegal buffer type: %s" type))
3467 (when (setq buf (get-buffer (if (symbolp buffer)
3468 (symbol-value buffer)
3470 (setq win (get-buffer-window buf t)))
3472 (when (memq 'point split)
3473 (setq all-visible win))
3474 (setq all-visible nil)))
3476 (when (eq type 'frame)
3477 (setq gnus-frame-split-p t))
3478 (setq stack (append (cddr split) stack)))))
3479 (unless (eq all-visible t)
3482 (defun gnus-window-top-edge (&optional window)
3483 (nth 1 (window-edges window)))
3485 (defun gnus-remove-some-windows ()
3486 (let ((buffers gnus-window-to-buffer)
3487 buf bufs lowest-buf lowest)
3489 ;; Remove windows on all known Gnus buffers.
3491 (setq buf (cdar buffers))
3493 (setq buf (and (boundp buf) (symbol-value buf))))
3495 (get-buffer-window buf)
3497 (setq bufs (cons buf bufs))
3499 (if (or (not lowest)
3500 (< (gnus-window-top-edge) lowest))
3502 (setq lowest (gnus-window-top-edge))
3503 (setq lowest-buf buf)))))
3504 (setq buffers (cdr buffers)))
3505 ;; Remove windows on *all* summary buffers.
3508 (let ((buf (window-buffer win)))
3509 (if (string-match "^\\*Summary" (buffer-name buf))
3511 (setq bufs (cons buf bufs))
3513 (if (or (not lowest)
3514 (< (gnus-window-top-edge) lowest))
3516 (setq lowest-buf buf)
3517 (setq lowest (gnus-window-top-edge)))))))))
3520 (pop-to-buffer lowest-buf)
3521 (switch-to-buffer nntp-server-buffer)))
3523 (and (not (eq (car bufs) lowest-buf))
3524 (delete-windows-on (car bufs)))
3525 (setq bufs (cdr bufs))))))
3527 (defun gnus-version (&optional arg)
3528 "Version number of this version of Gnus.
3529 If ARG, insert string at point."
3531 (let ((methods gnus-valid-select-methods)
3534 ;; Go through all the legal select methods and add their version
3535 ;; numbers to the total version string. Only the backends that are
3536 ;; currently in use will have their message numbers taken into
3539 (setq meth (intern (concat (caar methods) "-version")))
3541 (stringp (symbol-value meth))
3542 (setq mess (concat mess "; " (symbol-value meth))))
3543 (setq methods (cdr methods)))
3545 (insert (message mess))
3548 (defun gnus-info-find-node ()
3549 "Find Info documentation of Gnus."
3551 ;; Enlarge info window if needed.
3552 (let ((mode major-mode)
3554 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3555 (setq gnus-info-buffer (current-buffer))
3556 (gnus-configure-windows 'info)))
3558 (defun gnus-days-between (date1 date2)
3559 ;; Return the number of days between date1 and date2.
3560 (- (gnus-day-number date1) (gnus-day-number date2)))
3562 (defun gnus-day-number (date)
3563 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3564 (timezone-parse-date date))))
3565 (timezone-absolute-from-gregorian
3566 (nth 1 dat) (nth 2 dat) (car dat))))
3568 (defun gnus-encode-date (date)
3569 "Convert DATE to internal time."
3570 (let* ((parse (timezone-parse-date date))
3571 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3572 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3573 (encode-time (caddr time) (cadr time) (car time)
3574 (caddr date) (cadr date) (car date) (nth 4 date))))
3576 (defun gnus-time-minus (t1 t2)
3577 "Subtract two internal times."
3578 (let ((borrow (< (cadr t1) (cadr t2))))
3579 (list (- (car t1) (car t2) (if borrow 1 0))
3580 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3582 (defun gnus-file-newer-than (file date)
3583 (let ((fdate (nth 5 (file-attributes file))))
3584 (or (> (car fdate) (car date))
3585 (and (= (car fdate) (car date))
3586 (> (nth 1 fdate) (nth 1 date))))))
3588 (defmacro gnus-local-set-keys (&rest plist)
3589 "Set the keys in PLIST in the current keymap."
3590 `(gnus-define-keys-1 (current-local-map) ',plist))
3592 (defmacro gnus-define-keys (keymap &rest plist)
3593 "Define all keys in PLIST in KEYMAP."
3594 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3596 (put 'gnus-define-keys 'lisp-indent-function 1)
3597 (put 'gnus-define-keys 'lisp-indent-hook 1)
3598 (put 'gnus-define-keymap 'lisp-indent-function 1)
3599 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3601 (defmacro gnus-define-keymap (keymap &rest plist)
3602 "Define all keys in PLIST in KEYMAP."
3603 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3605 (defun gnus-define-keys-1 (keymap plist)
3607 (error "Can't set keys in a null keymap"))
3608 (cond ((symbolp keymap)
3609 (setq keymap (symbol-value keymap)))
3612 (set (car keymap) nil)
3613 (define-prefix-command (car keymap))
3614 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3615 (setq keymap (symbol-value (car keymap)))))
3618 (when (symbolp (setq key (pop plist)))
3619 (setq key (symbol-value key)))
3620 (define-key keymap key (pop plist)))))
3622 (defun gnus-group-read-only-p (&optional group)
3623 "Check whether GROUP supports editing or not.
3624 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3625 that that variable is buffer-local to the summary buffers."
3626 (let ((group (or group gnus-newsgroup-name)))
3627 (not (gnus-check-backend-function 'request-replace-article group))))
3629 (defun gnus-group-total-expirable-p (group)
3630 "Check whether GROUP is total-expirable or not."
3631 (let ((params (gnus-info-params (gnus-get-info group))))
3632 (or (memq 'total-expire params)
3633 (cdr (assq 'total-expire params)) ; (total-expire . t)
3634 (and gnus-total-expirable-newsgroups ; Check var.
3635 (string-match gnus-total-expirable-newsgroups group)))))
3637 (defun gnus-group-auto-expirable-p (group)
3638 "Check whether GROUP is total-expirable or not."
3639 (let ((params (gnus-info-params (gnus-get-info group))))
3640 (or (memq 'auto-expire params)
3641 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3642 (and gnus-auto-expirable-newsgroups ; Check var.
3643 (string-match gnus-auto-expirable-newsgroups group)))))
3645 (defun gnus-virtual-group-p (group)
3646 "Say whether GROUP is virtual or not."
3647 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3648 gnus-valid-select-methods)))
3650 (defun gnus-news-group-p (group &optional article)
3651 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3652 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3653 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3654 (eq (gnus-request-type group article) 'news))))
3656 (defsubst gnus-simplify-subject-fully (subject)
3657 "Simplify a subject string according to the user's wishes."
3659 ((null gnus-summary-gather-subject-limit)
3660 (gnus-simplify-subject-re subject))
3661 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3662 (gnus-simplify-subject-fuzzy subject))
3663 ((numberp gnus-summary-gather-subject-limit)
3664 (gnus-limit-string (gnus-simplify-subject-re subject)
3665 gnus-summary-gather-subject-limit))
3669 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3670 "Check whether two subjects are equal. If optional argument
3671 simple-first is t, first argument is already simplified."
3673 ((null simple-first)
3674 (equal (gnus-simplify-subject-fully s1)
3675 (gnus-simplify-subject-fully s2)))
3678 (gnus-simplify-subject-fully s2)))))
3680 ;; Returns a list of writable groups.
3681 (defun gnus-writable-groups ()
3682 (let ((alist gnus-newsrc-alist)
3684 (while (setq group (car (pop alist)))
3685 (unless (gnus-group-read-only-p group)
3686 (push group groups)))
3689 (defun gnus-completing-read (default prompt &rest args)
3690 ;; Like `completing-read', except that DEFAULT is the default argument.
3691 (let* ((prompt (if default
3692 (concat prompt " (default " default ") ")
3693 (concat prompt " ")))
3694 (answer (apply 'completing-read prompt args)))
3695 (if (or (null answer) (zerop (length answer)))
3699 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3701 (defun gnus-y-or-n-p (prompt)
3706 (defun gnus-yes-or-no-p (prompt)
3708 (yes-or-no-p prompt)
3711 ;; Check whether to use long file names.
3712 (defun gnus-use-long-file-name (symbol)
3713 ;; The variable has to be set...
3714 (and gnus-use-long-file-name
3715 ;; If it isn't a list, then we return t.
3716 (or (not (listp gnus-use-long-file-name))
3717 ;; If it is a list, and the list contains `symbol', we
3719 (not (memq symbol gnus-use-long-file-name)))))
3721 ;; I suspect there's a better way, but I haven't taken the time to do
3722 ;; it yet. -erik selberg@cs.washington.edu
3723 (defun gnus-dd-mmm (messy-date)
3724 "Return a string like DD-MMM from a big messy string"
3725 (let ((datevec (condition-case () (timezone-parse-date messy-date)
3731 ;; Make sure leading zeroes are stripped.
3732 (number-to-string (string-to-number (aref datevec 2)))
3736 (nth (1- (string-to-number (aref datevec 1)))
3737 timezone-months-assoc))
3740 (defun gnus-mode-string-quote (string)
3741 "Quote all \"%\" in STRING."
3743 (gnus-set-work-buffer)
3745 (goto-char (point-min))
3746 (while (search-forward "%" nil t)
3750 ;; Make a hash table (default and minimum size is 255).
3751 ;; Optional argument HASHSIZE specifies the table size.
3752 (defun gnus-make-hashtable (&optional hashsize)
3753 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3755 ;; Make a number that is suitable for hashing; bigger than MIN and one
3757 (defun gnus-create-hash-size (min)
3763 ;; Show message if message has a lower level than `gnus-verbose'.
3764 ;; Guideline for numbers:
3765 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3766 ;; for things that take a long time, 7 - not very important messages
3767 ;; on stuff, 9 - messages inside loops.
3768 (defun gnus-message (level &rest args)
3769 (if (<= level gnus-verbose)
3770 (apply 'message args)
3771 ;; We have to do this format thingy here even if the result isn't
3772 ;; shown - the return value has to be the same as the return value
3774 (apply 'format args)))
3776 (defun gnus-error (level &rest args)
3777 "Beep an error if `gnus-verbose' is on LEVEL or less."
3778 (when (<= (floor level) gnus-verbose)
3779 (apply 'message args)
3782 (when (and (floatp level)
3783 (not (zerop (setq duration (* 10 (- level (floor level)))))))
3784 (sit-for duration))))
3787 ;; Generate a unique new group name.
3788 (defun gnus-generate-new-group-name (leaf)
3791 (while (gnus-gethash name gnus-newsrc-hashtb)
3792 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3795 (defsubst gnus-hide-text (b e props)
3796 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
3797 (gnus-add-text-properties b e props)
3798 (when (memq 'intangible props)
3799 (gnus-put-text-property (max (1- b) (point-min))
3800 b 'intangible (cddr (memq 'intangible props)))))
3802 (defsubst gnus-unhide-text (b e)
3803 "Remove hidden text properties from region between B and E."
3804 (remove-text-properties b e gnus-hidden-properties)
3805 (when (memq 'intangible gnus-hidden-properties)
3806 (gnus-put-text-property (max (1- b) (point-min))
3807 b 'intangible nil)))
3809 (defun gnus-hide-text-type (b e type)
3810 "Hide text of TYPE between B and E."
3811 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3813 ;; Find out whether the gnus-visual TYPE is wanted.
3814 (defun gnus-visual-p (&optional type class)
3815 (and gnus-visual ; Has to be non-nil, at least.
3816 (if (not type) ; We don't care about type.
3818 (if (listp gnus-visual) ; It's a list, so we check it.
3819 (or (memq type gnus-visual)
3820 (memq class gnus-visual))
3823 (defun gnus-parent-headers (headers &optional generation)
3824 "Return the headers of the GENERATIONeth parent of HEADERS."
3826 (setq generation 1))
3827 (let (references parent)
3828 (while (and headers (not (zerop generation)))
3829 (setq references (mail-header-references headers))
3830 (when (and references
3831 (setq parent (gnus-parent-id references))
3832 (setq headers (car (gnus-id-to-thread parent))))
3836 (defun gnus-parent-id (references)
3837 "Return the last Message-ID in REFERENCES."
3838 (when (and references
3839 (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references))
3840 (substring references (match-beginning 1) (match-end 1))))
3842 (defun gnus-split-references (references)
3843 "Return a list of Message-IDs in REFERENCES."
3846 (while (string-match "<[^>]+>" references beg)
3847 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3851 (defun gnus-buffer-live-p (buffer)
3852 "Say whether BUFFER is alive or not."
3855 (buffer-name (get-buffer buffer))))
3857 (defun gnus-ephemeral-group-p (group)
3858 "Say whether GROUP is ephemeral or not."
3859 (gnus-group-get-parameter group 'quit-config))
3861 (defun gnus-group-quit-config (group)
3862 "Return the quit-config of GROUP."
3863 (gnus-group-get-parameter group 'quit-config))
3865 (defun gnus-simplify-mode-line ()
3866 "Make mode lines a bit simpler."
3867 (setq mode-line-modified "-- ")
3868 (when (listp mode-line-format)
3869 (make-local-variable 'mode-line-format)
3870 (setq mode-line-format (copy-sequence mode-line-format))
3871 (when (equal (nth 3 mode-line-format) " ")
3872 (setcar (nthcdr 3 mode-line-format) " "))))
3874 ;;; List and range functions
3876 (defun gnus-last-element (list)
3877 "Return last element of LIST."
3879 (setq list (cdr list)))
3882 (defun gnus-copy-sequence (list)
3883 "Do a complete, total copy of a list."
3884 (if (and (consp list) (not (consp (cdr list))))
3885 (cons (car list) (cdr list))
3886 (mapcar (lambda (elem) (if (consp elem)
3887 (if (consp (cdr elem))
3888 (gnus-copy-sequence elem)
3889 (cons (car elem) (cdr elem)))
3893 (defun gnus-set-difference (list1 list2)
3894 "Return a list of elements of LIST1 that do not appear in LIST2."
3895 (let ((list1 (copy-sequence list1)))
3897 (setq list1 (delq (car list2) list1))
3898 (setq list2 (cdr list2)))
3901 (defun gnus-sorted-complement (list1 list2)
3902 "Return a list of elements of LIST1 that do not appear in LIST2.
3903 Both lists have to be sorted over <."
3905 (if (or (null list1) (null list2))
3907 (while (and list1 list2)
3908 (cond ((= (car list1) (car list2))
3909 (setq list1 (cdr list1)
3911 ((< (car list1) (car list2))
3912 (setq out (cons (car list1) out))
3913 (setq list1 (cdr list1)))
3915 (setq out (cons (car list2) out))
3916 (setq list2 (cdr list2)))))
3917 (nconc (nreverse out) (or list1 list2)))))
3919 (defun gnus-intersection (list1 list2)
3922 (if (memq (car list2) list1)
3923 (setq result (cons (car list2) result)))
3924 (setq list2 (cdr list2)))
3927 (defun gnus-sorted-intersection (list1 list2)
3928 ;; LIST1 and LIST2 have to be sorted over <.
3930 (while (and list1 list2)
3931 (cond ((= (car list1) (car list2))
3932 (setq out (cons (car list1) out)
3935 ((< (car list1) (car list2))
3936 (setq list1 (cdr list1)))
3938 (setq list2 (cdr list2)))))
3941 (defun gnus-set-sorted-intersection (list1 list2)
3942 ;; LIST1 and LIST2 have to be sorted over <.
3943 ;; This function modifies LIST1.
3944 (let* ((top (cons nil list1))
3946 (while (and list1 list2)
3947 (cond ((= (car list1) (car list2))
3951 ((< (car list1) (car list2))
3952 (setcdr prev (cdr list1))
3953 (setq list1 (cdr list1)))
3955 (setq list2 (cdr list2)))))
3959 (defun gnus-compress-sequence (numbers &optional always-list)
3960 "Convert list of numbers to a list of ranges or a single range.
3961 If ALWAYS-LIST is non-nil, this function will always release a list of
3963 (let* ((first (car numbers))
3964 (last (car numbers))
3968 (if (not (listp (cdr numbers)))
3971 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3972 ((= (1+ last) (car numbers)) ;Still in sequence
3973 (setq last (car numbers)))
3974 (t ;End of one sequence
3976 (cons (if (= first last) first
3977 (cons first last)) result))
3978 (setq first (car numbers))
3979 (setq last (car numbers))))
3980 (setq numbers (cdr numbers)))
3981 (if (and (not always-list) (null result))
3982 (if (= first last) (list first) (cons first last))
3983 (nreverse (cons (if (= first last) first (cons first last))
3986 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3987 (defun gnus-uncompress-range (ranges)
3988 "Expand a list of ranges into a list of numbers.
3989 RANGES is either a single range on the form `(num . num)' or a list of
3991 (let (first last result)
3995 ((not (listp (cdr ranges)))
3996 (setq first (car ranges))
3997 (setq last (cdr ranges))
3998 (while (<= first last)
3999 (setq result (cons first result))
4000 (setq first (1+ first)))
4004 (if (atom (car ranges))
4005 (if (numberp (car ranges))
4006 (setq result (cons (car ranges) result)))
4007 (setq first (caar ranges))
4008 (setq last (cdar ranges))
4009 (while (<= first last)
4010 (setq result (cons first result))
4011 (setq first (1+ first))))
4012 (setq ranges (cdr ranges)))
4013 (nreverse result)))))
4015 (defun gnus-add-to-range (ranges list)
4016 "Return a list of ranges that has all articles from both RANGES and LIST.
4017 Note: LIST has to be sorted over `<'."
4019 (gnus-compress-sequence list t)
4020 (setq list (copy-sequence list))
4021 (or (listp (cdr ranges))
4022 (setq ranges (list ranges)))
4024 ilist lowest highest temp)
4025 (while (and ranges list)
4027 (setq lowest (or (and (atom (car ranges)) (car ranges))
4029 (while (and list (cdr list) (< (cadr list) lowest))
4030 (setq list (cdr list)))
4031 (if (< (car ilist) lowest)
4034 (setq list (cdr list))
4036 (setq out (nconc (gnus-compress-sequence ilist t) out))))
4037 (setq highest (or (and (atom (car ranges)) (car ranges))
4039 (while (and list (<= (car list) highest))
4040 (setq list (cdr list)))
4041 (setq ranges (cdr ranges)))
4043 (setq out (nconc (gnus-compress-sequence list t) out)))
4044 (setq out (sort out (lambda (r1 r2)
4045 (< (or (and (atom r1) r1) (car r1))
4046 (or (and (atom r2) r2) (car r2))))))
4049 (if (atom (car ranges))
4051 (if (atom (cadr ranges))
4052 (if (= (1+ (car ranges)) (cadr ranges))
4054 (setcar ranges (cons (car ranges)
4056 (setcdr ranges (cddr ranges))))
4057 (if (= (1+ (car ranges)) (caadr ranges))
4059 (setcar (cadr ranges) (car ranges))
4060 (setcar ranges (cadr ranges))
4061 (setcdr ranges (cddr ranges))))))
4063 (if (atom (cadr ranges))
4064 (if (= (1+ (cdar ranges)) (cadr ranges))
4066 (setcdr (car ranges) (cadr ranges))
4067 (setcdr ranges (cddr ranges))))
4068 (if (= (1+ (cdar ranges)) (caadr ranges))
4070 (setcdr (car ranges) (cdadr ranges))
4071 (setcdr ranges (cddr ranges)))))))
4072 (setq ranges (cdr ranges)))
4075 (defun gnus-remove-from-range (ranges list)
4076 "Return a list of ranges that has all articles from LIST removed from RANGES.
4077 Note: LIST has to be sorted over `<'."
4078 ;; !!! This function shouldn't look like this, but I've got a headache.
4079 (gnus-compress-sequence
4080 (gnus-sorted-complement
4081 (gnus-uncompress-range ranges) list)))
4083 (defun gnus-member-of-range (number ranges)
4084 (if (not (listp (cdr ranges)))
4085 (and (>= number (car ranges))
4086 (<= number (cdr ranges)))
4089 (if (numberp (car ranges))
4090 (>= number (car ranges))
4091 (>= number (caar ranges)))
4093 (if (if (numberp (car ranges))
4094 (= number (car ranges))
4095 (and (>= number (caar ranges))
4096 (<= number (cdar ranges))))
4097 (setq not-stop nil))
4098 (setq ranges (cdr ranges)))
4101 (defun gnus-range-length (range)
4102 "Return the length RANGE would have if uncompressed."
4103 (length (gnus-uncompress-range range)))
4105 (defun gnus-sublist-p (list sublist)
4106 "Test whether all elements in SUBLIST are members of LIST."
4109 (unless (memq (pop sublist) list)
4119 (defvar gnus-group-mode-map nil)
4120 (put 'gnus-group-mode 'mode-class 'special)
4122 (unless gnus-group-mode-map
4123 (setq gnus-group-mode-map (make-keymap))
4124 (suppress-keymap gnus-group-mode-map)
4126 (gnus-define-keys gnus-group-mode-map
4127 " " gnus-group-read-group
4128 "=" gnus-group-select-group
4129 "\r" gnus-group-select-group
4130 "\M-\r" gnus-group-quick-select-group
4131 "j" gnus-group-jump-to-group
4132 "n" gnus-group-next-unread-group
4133 "p" gnus-group-prev-unread-group
4134 "\177" gnus-group-prev-unread-group
4135 [delete] gnus-group-prev-unread-group
4136 "N" gnus-group-next-group
4137 "P" gnus-group-prev-group
4138 "\M-n" gnus-group-next-unread-group-same-level
4139 "\M-p" gnus-group-prev-unread-group-same-level
4140 "," gnus-group-best-unread-group
4141 "." gnus-group-first-unread-group
4142 "u" gnus-group-unsubscribe-current-group
4143 "U" gnus-group-unsubscribe-group
4144 "c" gnus-group-catchup-current
4145 "C" gnus-group-catchup-current-all
4146 "l" gnus-group-list-groups
4147 "L" gnus-group-list-all-groups
4149 "g" gnus-group-get-new-news
4150 "\M-g" gnus-group-get-new-news-this-group
4151 "R" gnus-group-restart
4152 "r" gnus-group-read-init-file
4153 "B" gnus-group-browse-foreign-server
4154 "b" gnus-group-check-bogus-groups
4155 "F" gnus-find-new-newsgroups
4156 "\C-c\C-d" gnus-group-describe-group
4157 "\M-d" gnus-group-describe-all-groups
4158 "\C-c\C-a" gnus-group-apropos
4159 "\C-c\M-\C-a" gnus-group-description-apropos
4160 "a" gnus-group-post-news
4161 "\ek" gnus-group-edit-local-kill
4162 "\eK" gnus-group-edit-global-kill
4163 "\C-k" gnus-group-kill-group
4164 "\C-y" gnus-group-yank-group
4165 "\C-w" gnus-group-kill-region
4166 "\C-x\C-t" gnus-group-transpose-groups
4167 "\C-c\C-l" gnus-group-list-killed
4168 "\C-c\C-x" gnus-group-expire-articles
4169 "\C-c\M-\C-x" gnus-group-expire-all-groups
4171 "s" gnus-group-save-newsrc
4172 "z" gnus-group-suspend
4173 "Z" gnus-group-clear-dribble
4176 "?" gnus-group-describe-briefly
4177 "\C-c\C-i" gnus-info-find-node
4178 "\M-e" gnus-group-edit-group-method
4179 "^" gnus-group-enter-server-mode
4180 gnus-mouse-2 gnus-mouse-pick-group
4181 "<" beginning-of-buffer
4184 "\C-c\C-s" gnus-group-sort-groups
4186 "\C-c\M-g" gnus-activate-all-groups
4187 "\M-&" gnus-group-universal-argument
4188 "#" gnus-group-mark-group
4189 "\M-#" gnus-group-unmark-group)
4191 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4192 "m" gnus-group-mark-group
4193 "u" gnus-group-unmark-group
4194 "w" gnus-group-mark-region
4195 "m" gnus-group-mark-buffer
4196 "r" gnus-group-mark-regexp
4197 "U" gnus-group-unmark-all-groups)
4199 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4200 "d" gnus-group-make-directory-group
4201 "h" gnus-group-make-help-group
4202 "a" gnus-group-make-archive-group
4203 "k" gnus-group-make-kiboze-group
4204 "m" gnus-group-make-group
4205 "E" gnus-group-edit-group
4206 "e" gnus-group-edit-group-method
4207 "p" gnus-group-edit-group-parameters
4208 "v" gnus-group-add-to-virtual
4209 "V" gnus-group-make-empty-virtual
4210 "D" gnus-group-enter-directory
4211 "f" gnus-group-make-doc-group
4212 "r" gnus-group-rename-group
4213 "\177" gnus-group-delete-group
4214 [delete] gnus-group-delete-group)
4216 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4217 "b" gnus-group-brew-soup
4218 "w" gnus-soup-save-areas
4219 "s" gnus-soup-send-replies
4220 "p" gnus-soup-pack-packet
4221 "r" nnsoup-pack-replies)
4223 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4224 "s" gnus-group-sort-groups
4225 "a" gnus-group-sort-groups-by-alphabet
4226 "u" gnus-group-sort-groups-by-unread
4227 "l" gnus-group-sort-groups-by-level
4228 "v" gnus-group-sort-groups-by-score
4229 "r" gnus-group-sort-groups-by-rank
4230 "m" gnus-group-sort-groups-by-method)
4232 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4233 "k" gnus-group-list-killed
4234 "z" gnus-group-list-zombies
4235 "s" gnus-group-list-groups
4236 "u" gnus-group-list-all-groups
4237 "A" gnus-group-list-active
4238 "a" gnus-group-apropos
4239 "d" gnus-group-description-apropos
4240 "m" gnus-group-list-matching
4241 "M" gnus-group-list-all-matching
4242 "l" gnus-group-list-level)
4244 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4245 "f" gnus-score-flush-cache)
4247 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4248 "f" gnus-group-fetch-faq)
4250 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4251 "l" gnus-group-set-current-level
4252 "t" gnus-group-unsubscribe-current-group
4253 "s" gnus-group-unsubscribe-group
4254 "k" gnus-group-kill-group
4255 "y" gnus-group-yank-group
4256 "w" gnus-group-kill-region
4257 "\C-k" gnus-group-kill-level
4258 "z" gnus-group-kill-all-zombies))
4260 (defun gnus-group-mode ()
4261 "Major mode for reading news.
4263 All normal editing commands are switched off.
4264 \\<gnus-group-mode-map>
4265 The group buffer lists (some of) the groups available. For instance,
4266 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4267 lists all zombie groups.
4269 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4270 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4272 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4274 The following commands are available:
4276 \\{gnus-group-mode-map}"
4278 (when (and menu-bar-mode
4279 (gnus-visual-p 'group-menu 'menu))
4280 (gnus-group-make-menu-bar))
4281 (kill-all-local-variables)
4282 (gnus-simplify-mode-line)
4283 (setq major-mode 'gnus-group-mode)
4284 (setq mode-name "Group")
4285 (gnus-group-set-mode-line)
4286 (setq mode-line-process nil)
4287 (use-local-map gnus-group-mode-map)
4288 (buffer-disable-undo (current-buffer))
4289 (setq truncate-lines t)
4290 (setq buffer-read-only t)
4291 (gnus-make-local-hook 'post-command-hook)
4292 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
4293 (run-hooks 'gnus-group-mode-hook))
4295 (defun gnus-clear-inboxes-moved ()
4296 (setq nnmail-moved-inboxes nil))
4298 (defun gnus-mouse-pick-group (e)
4299 "Enter the group under the mouse pointer."
4302 (gnus-group-read-group nil))
4304 ;; Look at LEVEL and find out what the level is really supposed to be.
4305 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4306 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4307 (defun gnus-group-default-level (&optional level number-or-nil)
4309 (gnus-group-use-permanent-levels
4310 (or (setq gnus-group-use-permanent-levels
4311 (or level (if (numberp gnus-group-use-permanent-levels)
4312 gnus-group-use-permanent-levels
4313 (or gnus-group-default-list-level
4314 gnus-level-subscribed))))
4315 gnus-group-default-list-level gnus-level-subscribed))
4319 (or level gnus-group-default-list-level gnus-level-subscribed))))
4322 (defun gnus-slave-no-server (&optional arg)
4323 "Read network news as a slave, without connecting to local server"
4325 (gnus-no-server arg t))
4328 (defun gnus-no-server (&optional arg slave)
4330 If ARG is a positive number, Gnus will use that as the
4331 startup level. If ARG is nil, Gnus will be started at level 2.
4332 If ARG is non-nil and not a positive number, Gnus will
4333 prompt the user for the name of an NNTP server to use.
4334 As opposed to `gnus', this command will not connect to the local server."
4336 (let ((val (or arg (1- gnus-level-default-subscribed))))
4338 (make-local-variable 'gnus-group-use-permanent-levels)
4339 (setq gnus-group-use-permanent-levels val)))
4342 (defun gnus-slave (&optional arg)
4343 "Read news as a slave."
4345 (gnus arg nil 'slave))
4348 (defun gnus-other-frame (&optional arg)
4349 "Pop up a frame to read news."
4351 (if (get-buffer gnus-group-buffer)
4352 (let ((pop-up-frames t))
4354 (select-frame (make-frame))
4358 (defun gnus (&optional arg dont-connect slave)
4360 If ARG is non-nil and a positive number, Gnus will use that as the
4361 startup level. If ARG is non-nil and not a positive number, Gnus will
4362 prompt the user for the name of an NNTP server to use."
4365 (if (get-buffer gnus-group-buffer)
4367 (switch-to-buffer gnus-group-buffer)
4368 (gnus-group-get-new-news))
4371 (nnheader-init-server-buffer)
4372 (gnus-read-init-file)
4373 (setq gnus-slave slave)
4375 (gnus-group-setup-buffer)
4376 (let ((buffer-read-only nil))
4378 (if (not gnus-inhibit-startup-message)
4380 (gnus-group-startup-message)
4383 (let ((level (and (numberp arg) (> arg 0) arg))
4389 (gnus-start-news-server (and arg (not level))))))
4390 (if (and (not dont-connect)
4393 (run-hooks 'gnus-startup-hook)
4394 ;; NNTP server is successfully open.
4396 ;; Find the current startup file name.
4397 (setq gnus-current-startup-file
4398 (gnus-make-newsrc-file gnus-startup-file))
4400 ;; Read the dribble file.
4401 (when (or gnus-slave gnus-use-dribble-file)
4402 (gnus-dribble-read-file))
4404 ;; Allow using GroupLens predictions.
4405 (when gnus-use-grouplens
4407 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4409 (gnus-summary-make-display-table)
4410 ;; Do the actual startup.
4411 (gnus-setup-news nil level dont-connect)
4412 ;; Generate the group buffer.
4413 (gnus-group-list-groups level)
4414 (gnus-group-first-unread-group)
4415 (gnus-configure-windows 'group)
4416 (gnus-group-set-mode-line))))))
4418 (defun gnus-unload ()
4419 "Unload all Gnus features."
4421 (or (boundp 'load-history)
4422 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4423 (let ((history load-history)
4426 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4427 (setq feature (cdr (assq 'provide (car history))))
4428 (unload-feature feature 'force))
4429 (setq history (cdr history)))))
4431 (defun gnus-compile ()
4432 "Byte-compile the user-defined format specs."
4434 (let ((entries gnus-format-specs)
4435 entry gnus-tmp-func)
4437 (gnus-message 7 "Compiling format specs...")
4440 (setq entry (pop entries))
4441 (if (eq (car entry) 'version)
4442 (setq gnus-format-specs (delq entry gnus-format-specs))
4443 (when (and (listp (caddr entry))
4444 (not (eq 'byte-code (caaddr entry))))
4445 (fset 'gnus-tmp-func
4446 `(lambda () ,(caddr entry)))
4447 (byte-compile 'gnus-tmp-func)
4448 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4450 (push (cons 'version emacs-version) gnus-format-specs)
4452 (gnus-message 7 "Compiling user specs...done"))))
4454 (defun gnus-indent-rigidly (start end arg)
4455 "Indent rigidly using only spaces and no tabs."
4458 (narrow-to-region start end)
4459 (indent-rigidly start end arg)
4460 (goto-char (point-min))
4461 (while (search-forward "\t" nil t)
4462 (replace-match " " t t)))))
4464 (defun gnus-group-startup-message (&optional x y)
4465 "Insert startup message in current buffer."
4466 ;; Insert the message.
4471 _ ___ __ ___ __ _ ___
4490 ;; And then hack it.
4491 (gnus-indent-rigidly (point-min) (point-max)
4492 (/ (max (- (window-width) (or x 46)) 0) 2))
4493 (goto-char (point-min))
4495 (let* ((pheight (count-lines (point-min) (point-max)))
4496 (wheight (window-height))
4497 (rest (- wheight pheight)))
4498 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4500 (goto-char (point-min))
4501 (and (search-forward "Praxis" nil t)
4502 (gnus-put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4503 (goto-char (point-min))
4504 (let* ((mode-string (gnus-group-set-mode-line)))
4505 (setq mode-line-buffer-identification
4506 (list (concat gnus-version (substring (car mode-string) 4))))
4507 (set-buffer-modified-p t)))
4509 (defun gnus-group-setup-buffer ()
4510 (or (get-buffer gnus-group-buffer)
4512 (switch-to-buffer gnus-group-buffer)
4513 (gnus-add-current-to-buffer-list)
4515 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4517 (defun gnus-group-list-groups (&optional level unread lowest)
4518 "List newsgroups with level LEVEL or lower that have unread articles.
4519 Default is all subscribed groups.
4520 If argument UNREAD is non-nil, groups with no unread articles are also
4522 (interactive (list (if current-prefix-arg
4523 (prefix-numeric-value current-prefix-arg)
4525 (gnus-group-default-level nil t)
4526 gnus-group-default-list-level
4527 gnus-level-subscribed))))
4529 (setq level (car gnus-group-list-mode)
4530 unread (cdr gnus-group-list-mode)))
4531 (setq level (gnus-group-default-level level))
4532 (gnus-group-setup-buffer) ;May call from out of group buffer
4533 (gnus-update-format-specifications)
4534 (let ((case-fold-search nil)
4535 (props (text-properties-at (gnus-point-at-bol)))
4536 (group (gnus-group-group-name)))
4537 (set-buffer gnus-group-buffer)
4538 (funcall gnus-group-prepare-function level unread lowest)
4539 (if (zerop (buffer-size))
4540 (gnus-message 5 gnus-no-groups-message)
4541 (goto-char (point-max))
4542 (when (or (not gnus-group-goto-next-group-function)
4543 (not (funcall gnus-group-goto-next-group-function
4546 ;; Go to the first group with unread articles.
4547 (gnus-group-search-forward t)
4548 ;; Find the right group to put point on. If the current group
4549 ;; has disappeared in the new listing, try to find the next
4550 ;; one. If no next one can be found, just leave point at the
4551 ;; first newsgroup in the buffer.
4552 (if (not (gnus-goto-char
4554 (point-min) (point-max)
4555 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4556 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4558 (not (gnus-goto-char
4560 (point-min) (point-max) 'gnus-group
4562 (caar newsrc) gnus-active-hashtb)))))
4563 (setq newsrc (cdr newsrc)))
4564 (or newsrc (progn (goto-char (point-max))
4565 (forward-line -1)))))))
4566 ;; Adjust cursor point.
4567 (gnus-group-position-point))))
4569 (defun gnus-group-list-level (level &optional all)
4570 "List groups on LEVEL.
4571 If ALL (the prefix), also list groups that have no unread articles."
4572 (interactive "nList groups on level: \nP")
4573 (gnus-group-list-groups level all level))
4575 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4576 "List all newsgroups with unread articles of level LEVEL or lower.
4577 If ALL is non-nil, list groups that have no unread articles.
4578 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4579 If REGEXP, only list groups matching REGEXP."
4580 (set-buffer gnus-group-buffer)
4581 (let ((buffer-read-only nil)
4582 (newsrc (cdr gnus-newsrc-alist))
4583 (lowest (or lowest 1))
4584 info clevel unread group params)
4586 (if (< lowest gnus-level-zombie)
4587 ;; List living groups.
4589 (setq info (car newsrc)
4590 group (gnus-info-group info)
4591 params (gnus-info-params info)
4593 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4594 (and unread ; This group might be bogus
4596 (string-match regexp group))
4597 (<= (setq clevel (gnus-info-level info)) level)
4599 (or all ; We list all groups?
4600 (if (eq unread t) ; Unactivated?
4601 gnus-group-list-inactive-groups ; We list unactivated
4602 (> unread 0)) ; We list groups with unread articles
4603 (and gnus-list-groups-with-ticked-articles
4604 (cdr (assq 'tick (gnus-info-marks info))))
4605 ; And groups with tickeds
4606 ;; Check for permanent visibility.
4607 (and gnus-permanently-visible-groups
4608 (string-match gnus-permanently-visible-groups
4610 (memq 'visible params)
4611 (cdr (assq 'visible params)))
4612 (gnus-group-insert-group-line
4613 group (gnus-info-level info)
4614 (gnus-info-marks info) unread (gnus-info-method info)))))
4616 ;; List dead groups.
4617 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4618 (gnus-group-prepare-flat-list-dead
4619 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4620 gnus-level-zombie ?Z
4622 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4623 (gnus-group-prepare-flat-list-dead
4624 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4625 gnus-level-killed ?K regexp))
4627 (gnus-group-set-mode-line)
4628 (setq gnus-group-list-mode (cons level all))
4629 (run-hooks 'gnus-group-prepare-hook)))
4631 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4632 ;; List zombies and killed lists somewhat faster, which was
4633 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4634 ;; this by ignoring the group format specification altogether.
4637 ;; This loop is used when listing groups that match some
4640 (setq group (pop groups))
4641 (when (string-match regexp group)
4642 (gnus-add-text-properties
4643 (point) (prog1 (1+ (point))
4644 (insert " " mark " *: " group "\n"))
4645 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4647 'gnus-level level))))
4648 ;; This loop is used when listing all groups.
4650 (gnus-add-text-properties
4651 (point) (prog1 (1+ (point))
4652 (insert " " mark " *: "
4653 (setq group (pop groups)) "\n"))
4654 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4656 'gnus-level level))))))
4658 (defmacro gnus-group-real-name (group)
4659 "Find the real name of a foreign newsgroup."
4660 `(let ((gname ,group))
4661 (if (string-match ":[^:]+$" gname)
4662 (substring gname (1+ (match-beginning 0)))
4665 (defsubst gnus-server-add-address (method)
4666 (let ((method-name (symbol-name (car method))))
4667 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4668 (not (assq (intern (concat method-name "-address")) method)))
4669 (append method (list (list (intern (concat method-name "-address"))
4673 (defsubst gnus-server-get-method (group method)
4674 ;; Input either a server name, and extended server name, or a
4675 ;; select method, and return a select method.
4676 (cond ((stringp method)
4677 (gnus-server-to-method method))
4678 ((equal method gnus-select-method)
4680 ((and (stringp (car method)) group)
4681 (gnus-server-extend-method group method))
4682 ((and method (not group)
4683 (equal (cadr method) ""))
4686 (gnus-server-add-address method))))
4688 (defun gnus-server-to-method (server)
4689 "Map virtual server names to select methods."
4691 ;; Is this a method, perhaps?
4692 (and server (listp server) server)
4693 ;; Perhaps this is the native server?
4694 (and (equal server "native") gnus-select-method)
4695 ;; It should be in the server alist.
4696 (cdr (assoc server gnus-server-alist))
4697 ;; If not, we look through all the opened server
4698 ;; to see whether we can find it there.
4699 (let ((opened gnus-opened-servers))
4701 (not (equal server (format "%s:%s" (caaar opened)
4706 (defmacro gnus-method-equal (ss1 ss2)
4707 "Say whether two servers are equal."
4711 (and (= (length s1) (length s2))
4713 (while (and s1 (member (car s1) s2))
4717 (defun gnus-server-equal (m1 m2)
4718 "Say whether two methods are equal."
4719 (let ((m1 (cond ((null m1) gnus-select-method)
4720 ((stringp m1) (gnus-server-to-method m1))
4722 (m2 (cond ((null m2) gnus-select-method)
4723 ((stringp m2) (gnus-server-to-method m2))
4725 (gnus-method-equal m1 m2)))
4727 (defun gnus-servers-using-backend (backend)
4728 "Return a list of known servers using BACKEND."
4729 (let ((opened gnus-opened-servers)
4732 (when (eq backend (caaar opened))
4733 (push (caar opened) out))
4737 (defun gnus-group-prefixed-name (group method)
4738 "Return the whole name from GROUP and METHOD."
4739 (and (stringp method) (setq method (gnus-server-to-method method)))
4740 (concat (format "%s" (car method))
4742 (or (assoc (format "%s" (car method))
4743 (gnus-methods-using 'address))
4744 (gnus-server-equal method gnus-message-archive-method))
4746 (not (string= (nth 1 method) "")))
4747 (concat "+" (nth 1 method)))
4750 (defun gnus-group-real-prefix (group)
4751 "Return the prefix of the current group name."
4752 (if (string-match "^[^:]+:" group)
4753 (substring group 0 (match-end 0))
4756 (defun gnus-group-method (group)
4757 "Return the server or method used for selecting GROUP."
4758 (let ((prefix (gnus-group-real-prefix group)))
4759 (if (equal prefix "")
4761 (let ((servers gnus-opened-servers)
4763 backend possible found)
4764 (if (string-match "^[^\\+]+\\+" prefix)
4765 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4766 server (substring prefix (match-end 0) (1- (length prefix))))
4767 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4769 (when (eq (caaar servers) backend)
4770 (setq possible (caar servers))
4771 (when (equal (cadaar servers) server)
4772 (setq found (caar servers))))
4774 (or (car (rassoc found gnus-server-alist))
4776 (car (rassoc possible gnus-server-alist))
4778 (list backend server))))))
4780 (defsubst gnus-secondary-method-p (method)
4781 "Return whether METHOD is a secondary select method."
4782 (let ((methods gnus-secondary-select-methods)
4783 (gmethod (gnus-server-get-method nil method)))
4785 (not (equal (gnus-server-get-method nil (car methods))
4787 (setq methods (cdr methods)))
4790 (defun gnus-group-foreign-p (group)
4791 "Say whether a group is foreign or not."
4792 (and (not (gnus-group-native-p group))
4793 (not (gnus-group-secondary-p group))))
4795 (defun gnus-group-native-p (group)
4796 "Say whether the group is native or not."
4797 (not (string-match ":" group)))
4799 (defun gnus-group-secondary-p (group)
4800 "Say whether the group is secondary or not."
4801 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4803 (defun gnus-group-get-parameter (group &optional symbol)
4804 "Returns the group parameters for GROUP.
4805 If SYMBOL, return the value of that symbol in the group parameters."
4806 (let ((params (gnus-info-params (gnus-get-info group))))
4808 (gnus-group-parameter-value params symbol)
4811 (defun gnus-group-parameter-value (params symbol)
4812 "Return the value of SYMBOL in group PARAMS."
4813 (or (car (memq symbol params)) ; It's either a simple symbol
4814 (cdr (assq symbol params)))) ; or a cons.
4816 (defun gnus-group-add-parameter (group param)
4817 "Add parameter PARAM to GROUP."
4818 (let ((info (gnus-get-info group)))
4820 () ; This is a dead group. We just ignore it.
4821 ;; Cons the new param to the old one and update.
4822 (gnus-group-set-info (cons param (gnus-info-params info))
4825 (defun gnus-group-set-parameter (group name value)
4826 "Set parameter NAME to VALUE in GROUP."
4827 (let ((info (gnus-get-info group)))
4829 () ; This is a dead group. We just ignore it.
4830 (let ((old-params (gnus-info-params info))
4831 (new-params (list (cons name value))))
4833 (if (or (not (listp (car old-params)))
4834 (not (eq (caar old-params) name)))
4835 (setq new-params (append new-params (list (car old-params)))))
4836 (setq old-params (cdr old-params)))
4837 (gnus-group-set-info new-params group 'params)))))
4839 (defun gnus-group-add-score (group &optional score)
4840 "Add SCORE to the GROUP score.
4841 If SCORE is nil, add 1 to the score of GROUP."
4842 (let ((info (gnus-get-info group)))
4844 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4846 (defun gnus-summary-bubble-group ()
4847 "Increase the score of the current group.
4848 This is a handy function to add to `gnus-summary-exit-hook' to
4849 increase the score of each group you read."
4850 (gnus-group-add-score gnus-newsgroup-name))
4852 (defun gnus-group-set-info (info &optional method-only-group part)
4853 (let* ((entry (gnus-gethash
4854 (or method-only-group (gnus-info-group info))
4855 gnus-newsrc-hashtb))
4857 (info (if method-only-group (nth 2 entry) info))
4859 (when method-only-group
4861 (error "Trying to change non-existent group %s" method-only-group))
4862 ;; We have received parts of the actual group info - either the
4863 ;; select method or the group parameters. We first check
4864 ;; whether we have to extend the info, and if so, do that.
4865 (let ((len (length info))
4866 (total (if (eq part 'method) 5 6)))
4868 (setcdr (nthcdr (1- len) info)
4869 (make-list (- total len) nil)))
4870 ;; Then we enter the new info.
4871 (setcar (nthcdr (1- total) info) part-info)))
4873 ;; This is a new group, so we just create it.
4875 (set-buffer gnus-group-buffer)
4876 (setq method (gnus-info-method info))
4877 (when (gnus-server-equal method "native")
4880 (set-buffer gnus-group-buffer)
4882 ;; It's a foreign group...
4883 (gnus-group-make-group
4884 (gnus-group-real-name (gnus-info-group info))
4885 (if (stringp method) method
4886 (prin1-to-string (car method)))
4888 (nth 1 (gnus-info-method info))))
4889 ;; It's a native group.
4890 (gnus-group-make-group (gnus-info-group info))))
4891 (gnus-message 6 "Note: New group created")
4893 (gnus-gethash (gnus-group-prefixed-name
4894 (gnus-group-real-name (gnus-info-group info))
4895 (or (gnus-info-method info) gnus-select-method))
4896 gnus-newsrc-hashtb))))
4897 ;; Whether it was a new group or not, we now have the entry, so we
4898 ;; can do the update.
4901 (setcar (nthcdr 2 entry) info)
4902 (when (and (not (eq (car entry) t))
4903 (gnus-active (gnus-info-group info)))
4904 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4905 (error "No such group: %s" (gnus-info-group info)))))
4907 (defun gnus-group-set-method-info (group select-method)
4908 (gnus-group-set-info select-method group 'method))
4910 (defun gnus-group-set-params-info (group params)
4911 (gnus-group-set-info params group 'params))
4913 (defun gnus-group-update-group-line ()
4914 "Update the current line in the group buffer."
4915 (let* ((buffer-read-only nil)
4916 (group (gnus-group-group-name))
4917 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
4918 gnus-group-indentation)
4920 (not (gnus-ephemeral-group-p group))
4922 (concat "(gnus-group-set-info '"
4923 (prin1-to-string (nth 2 entry)) ")")))
4924 (setq gnus-group-indentation (gnus-group-group-indentation))
4926 (gnus-group-insert-group-line-info group)
4928 (gnus-group-position-point)))
4930 (defun gnus-group-insert-group-line-info (group)
4931 "Insert GROUP on the current line."
4932 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4936 ;; (Un)subscribed group.
4937 (setq info (nth 2 entry))
4938 (gnus-group-insert-group-line
4939 group (gnus-info-level info) (gnus-info-marks info)
4940 (or (car entry) t) (gnus-info-method info)))
4941 ;; This group is dead.
4942 (gnus-group-insert-group-line
4944 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4946 (if (setq active (gnus-active group))
4947 (- (1+ (cdr active)) (car active)) 0)
4950 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
4951 gnus-tmp-marked number
4953 "Insert a group line in the group buffer."
4954 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4955 (gnus-tmp-number-total
4957 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4959 (gnus-tmp-number-of-unread
4960 (if (numberp number) (int-to-string (max 0 number))
4962 (gnus-tmp-number-of-read
4963 (if (numberp number)
4964 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4966 (gnus-tmp-subscribed
4967 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4968 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4969 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4971 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4972 (gnus-tmp-newsgroup-description
4973 (if gnus-description-hashtb
4974 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4977 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4978 (gnus-tmp-moderated-string
4979 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4981 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4982 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4983 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4984 (gnus-tmp-news-method-string
4986 (format "(%s:%s)" (car gnus-tmp-method)
4987 (cadr gnus-tmp-method)) ""))
4988 (gnus-tmp-marked-mark
4989 (if (and (numberp number)
4991 (cdr (assq 'tick gnus-tmp-marked)))
4993 (gnus-tmp-process-marked
4994 (if (member gnus-tmp-group gnus-group-marked)
4995 gnus-process-mark ? ))
4997 (or (and gnus-use-grouplens
4998 (bbb-grouplens-group-p gnus-tmp-group))
5000 (buffer-read-only nil)
5001 header gnus-tmp-header) ; passed as parameter to user-funcs.
5003 (gnus-add-text-properties
5007 (eval gnus-group-line-format-spec))
5008 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
5009 gnus-unread ,(if (numberp number)
5010 (string-to-int gnus-tmp-number-of-unread)
5012 gnus-marked ,gnus-tmp-marked-mark
5013 gnus-indentation ,gnus-group-indentation
5014 gnus-level ,gnus-tmp-level))
5015 (when (inline (gnus-visual-p 'group-highlight 'highlight))
5017 (run-hooks 'gnus-group-update-hook)
5019 ;; Allow XEmacs to remove front-sticky text properties.
5020 (gnus-group-remove-excess-properties)))
5022 (defun gnus-group-update-group (group &optional visible-only)
5023 "Update all lines where GROUP appear.
5024 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
5027 (set-buffer gnus-group-buffer)
5028 ;; The buffer may be narrowed.
5031 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
5033 found buffer-read-only)
5034 ;; Enter the current status into the dribble buffer.
5035 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
5036 (if (and entry (not (gnus-ephemeral-group-p group)))
5038 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
5040 ;; Find all group instances. If topics are in use, each group
5041 ;; may be listed in more than once.
5042 (while (setq loc (text-property-any
5043 loc (point-max) 'gnus-group ident))
5046 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5048 (gnus-group-insert-group-line-info group)
5051 (run-hooks 'gnus-group-update-group-hook)))
5052 (setq loc (1+ loc)))
5053 (unless (or found visible-only)
5054 ;; No such line in the buffer, find out where it's supposed to
5055 ;; go, and insert it there (or at the end of the buffer).
5056 (if gnus-goto-missing-group-function
5057 (funcall gnus-goto-missing-group-function group)
5058 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
5059 (while (and entry (car entry)
5063 (point-min) (point-max)
5064 'gnus-group (gnus-intern-safe
5065 (caar entry) gnus-active-hashtb)))))
5066 (setq entry (cdr entry)))
5067 (or entry (goto-char (point-max)))))
5068 ;; Finally insert the line.
5069 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5070 (gnus-group-insert-group-line-info group)
5073 (run-hooks 'gnus-group-update-group-hook))))
5074 (gnus-group-set-mode-line)))))
5076 (defun gnus-group-set-mode-line ()
5077 "Update the mode line in the group buffer."
5078 (when (memq 'group gnus-updated-mode-lines)
5079 ;; Yes, we want to keep this mode line updated.
5081 (set-buffer gnus-group-buffer)
5082 (let* ((gformat (or gnus-group-mode-line-format-spec
5083 (setq gnus-group-mode-line-format-spec
5085 gnus-group-mode-line-format
5086 gnus-group-mode-line-format-alist))))
5087 (gnus-tmp-news-server (cadr gnus-select-method))
5088 (gnus-tmp-news-method (car gnus-select-method))
5089 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
5091 gnus-tmp-header ;Dummy binding for user-defined formats
5092 ;; Get the resulting string.
5093 (mode-string (eval gformat)))
5094 ;; Say whether the dribble buffer has been modified.
5095 (setq mode-line-modified
5096 (if (and gnus-dribble-buffer
5097 (buffer-name gnus-dribble-buffer)
5098 (buffer-modified-p gnus-dribble-buffer)
5100 (set-buffer gnus-dribble-buffer)
5101 (not (zerop (buffer-size)))))
5103 ;; If the line is too long, we chop it off.
5104 (when (> (length mode-string) max-len)
5105 (setq mode-string (substring mode-string 0 (- max-len 4))))
5107 (setq mode-line-buffer-identification
5109 (set-buffer-modified-p t))))))
5111 (defun gnus-group-group-name ()
5112 "Get the name of the newsgroup on the current line."
5113 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
5114 (and group (symbol-name group))))
5116 (defun gnus-group-group-level ()
5117 "Get the level of the newsgroup on the current line."
5118 (get-text-property (gnus-point-at-bol) 'gnus-level))
5120 (defun gnus-group-group-indentation ()
5121 "Get the indentation of the newsgroup on the current line."
5122 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
5123 (and gnus-group-indentation-function
5124 (funcall gnus-group-indentation-function))
5127 (defun gnus-group-group-unread ()
5128 "Get the number of unread articles of the newsgroup on the current line."
5129 (get-text-property (gnus-point-at-bol) 'gnus-unread))
5131 (defun gnus-group-search-forward (&optional backward all level first-too)
5132 "Find the next newsgroup with unread articles.
5133 If BACKWARD is non-nil, find the previous newsgroup instead.
5134 If ALL is non-nil, just find any newsgroup.
5135 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
5137 If FIRST-TOO, the current line is also eligible as a target."
5138 (let ((way (if backward -1 1))
5139 (low gnus-level-killed)
5142 (if (and backward (progn (beginning-of-line)) (bobp))
5144 (or first-too (forward-line way))
5152 (get-text-property (point) 'gnus-unread)))
5153 (and (numberp unread) (> unread 0)))
5154 (setq lev (get-text-property (point)
5156 (<= lev gnus-level-subscribed)))
5158 (and (setq lev (get-text-property (point)
5167 (zerop (forward-line way)))))
5169 (progn (gnus-group-position-point) t)
5170 (goto-char (or pos beg))
5173 ;;; Gnus group mode commands
5177 (defun gnus-group-mark-group (n &optional unmark no-advance)
5178 "Mark the current group."
5180 (let ((buffer-read-only nil)
5184 (when (setq group (gnus-group-group-name))
5188 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5193 (setq gnus-group-marked (delete group gnus-group-marked)))
5195 (setq gnus-group-marked
5196 (cons group (delete group gnus-group-marked)))))
5197 (or no-advance (gnus-group-next-group 1))
5199 (gnus-summary-position-point)
5202 (defun gnus-group-unmark-group (n)
5203 "Remove the mark from the current group."
5205 (gnus-group-mark-group n 'unmark)
5206 (gnus-group-position-point))
5208 (defun gnus-group-unmark-all-groups ()
5209 "Unmark all groups."
5211 (let ((groups gnus-group-marked))
5214 (gnus-group-remove-mark (pop groups)))))
5215 (gnus-group-position-point))
5217 (defun gnus-group-mark-region (unmark beg end)
5218 "Mark all groups between point and mark.
5219 If UNMARK, remove the mark instead."
5220 (interactive "P\nr")
5221 (let ((num (count-lines beg end)))
5224 (- num (gnus-group-mark-group num unmark)))))
5226 (defun gnus-group-mark-buffer (&optional unmark)
5227 "Mark all groups in the buffer.
5228 If UNMARK, remove the mark instead."
5230 (gnus-group-mark-region unmark (point-min) (point-max)))
5232 (defun gnus-group-mark-regexp (regexp)
5233 "Mark all groups that match some regexp."
5234 (interactive "sMark (regexp): ")
5235 (let ((alist (cdr gnus-newsrc-alist))
5238 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5239 (gnus-group-set-mark group))))
5240 (gnus-group-position-point))
5242 (defun gnus-group-remove-mark (group)
5243 "Remove the process mark from GROUP and move point there.
5244 Return nil if the group isn't displayed."
5245 (if (gnus-group-goto-group group)
5247 (gnus-group-mark-group 1 'unmark t)
5249 (setq gnus-group-marked
5250 (delete group gnus-group-marked))
5253 (defun gnus-group-set-mark (group)
5254 "Set the process mark on GROUP."
5255 (if (gnus-group-goto-group group)
5257 (gnus-group-mark-group 1 nil t))
5258 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5260 (defun gnus-group-universal-argument (arg &optional groups func)
5261 "Perform any command on all groups accoring to the process/prefix convention."
5263 (let ((groups (or groups (gnus-group-process-prefix arg)))
5265 (if (eq (setq func (or func
5268 (substitute-command-keys
5269 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5271 (gnus-error 1 "Undefined key")
5273 (gnus-group-remove-mark (setq group (pop groups)))
5274 (command-execute func))))
5275 (gnus-group-position-point))
5277 (defun gnus-group-process-prefix (n)
5278 "Return a list of groups to work on.
5279 Take into consideration N (the prefix) and the list of marked groups."
5282 (setq n (prefix-numeric-value n))
5283 ;; There is a prefix, so we return a list of the N next
5285 (let ((way (if (< n 0) -1 1))
5290 (setq group (gnus-group-group-name)))
5291 (setq groups (cons group groups))
5293 (gnus-group-next-group way)))
5295 ((and (boundp 'transient-mark-mode)
5297 (boundp 'mark-active)
5299 ;; Work on the region between point and mark.
5300 (let ((max (max (point) (mark)))
5303 (goto-char (min (point) (mark)))
5306 (push (gnus-group-group-name) groups)
5307 (zerop (gnus-group-next-group 1))
5309 (nreverse groups))))
5311 ;; No prefix, but a list of marked articles.
5312 (reverse gnus-group-marked))
5314 ;; Neither marked articles or a prefix, so we return the
5316 (let ((group (gnus-group-group-name)))
5317 (and group (list group))))))
5319 ;; Selecting groups.
5321 (defun gnus-group-read-group (&optional all no-article group)
5322 "Read news in this newsgroup.
5323 If the prefix argument ALL is non-nil, already read articles become
5324 readable. IF ALL is a number, fetch this number of articles. If the
5325 optional argument NO-ARTICLE is non-nil, no article will be
5326 auto-selected upon group entry. If GROUP is non-nil, fetch that
5329 (let ((group (or group (gnus-group-group-name)))
5330 number active marked entry)
5331 (or group (error "No group on current line"))
5332 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5333 group gnus-newsrc-hashtb)))))
5334 ;; This group might be a dead group. In that case we have to get
5335 ;; the number of unread articles from `gnus-active-hashtb'.
5337 (cond ((numberp all) all)
5339 ((setq active (gnus-active group))
5340 (- (1+ (cdr active)) (car active)))))
5341 (gnus-summary-read-group
5342 group (or all (and (numberp number)
5343 (zerop (+ number (length (cdr (assq 'tick marked)))
5344 (length (cdr (assq 'dormant marked)))))))
5347 (defun gnus-group-select-group (&optional all)
5348 "Select this newsgroup.
5349 No article is selected automatically.
5350 If ALL is non-nil, already read articles become readable.
5351 If ALL is a number, fetch this number of articles."
5353 (gnus-group-read-group all t))
5355 (defun gnus-group-quick-select-group (&optional all)
5356 "Select the current group \"quickly\".
5357 This means that no highlighting or scoring will be performed."
5360 gnus-score-find-score-files-function
5361 gnus-apply-kill-hook
5362 gnus-summary-expunge-below)
5363 (gnus-group-read-group all t)))
5365 (defun gnus-group-visible-select-group (&optional all)
5366 "Select the current group without hiding any articles."
5368 (let ((gnus-inhibit-limiting t))
5369 (gnus-group-read-group all t)))
5372 (defun gnus-fetch-group (group)
5373 "Start Gnus if necessary and enter GROUP.
5374 Returns whether the fetching was successful or not."
5375 (interactive "sGroup name: ")
5376 (or (get-buffer gnus-group-buffer)
5378 (gnus-group-read-group nil nil group))
5380 ;; Enter a group that is not in the group buffer. Non-nil is returned
5381 ;; if selection was successful.
5382 (defun gnus-group-read-ephemeral-group
5383 (group method &optional activate quit-config)
5384 (let ((group (if (gnus-group-foreign-p group) group
5385 (gnus-group-prefixed-name group method))))
5388 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5389 ((quit-config . ,(if quit-config quit-config
5390 (cons (current-buffer) 'summary))))))
5392 (set-buffer gnus-group-buffer)
5393 (or (gnus-check-server method)
5394 (error "Unable to contact server: %s" (gnus-status-message method)))
5395 (if activate (or (gnus-request-group group)
5396 (error "Couldn't request group")))
5398 (gnus-group-read-group t t group)
5402 (defun gnus-group-jump-to-group (group)
5403 "Jump to newsgroup GROUP."
5405 (list (completing-read
5406 "Group: " gnus-active-hashtb nil
5407 (gnus-read-active-file-p)
5409 'gnus-group-history)))
5411 (when (equal group "")
5412 (error "Empty group name"))
5414 (when (string-match "[\000-\032]" group)
5415 (error "Control characters in group: %s" group))
5417 (let ((b (text-property-any
5418 (point-min) (point-max)
5419 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5420 (unless (gnus-ephemeral-group-p group)
5422 ;; Either go to the line in the group buffer...
5424 ;; ... or insert the line.
5427 (gnus-activate-group group)
5428 (error "%s error: %s" group (gnus-status-message group)))
5430 (gnus-group-update-group group)
5431 (goto-char (text-property-any
5432 (point-min) (point-max)
5433 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5434 ;; Adjust cursor point.
5435 (gnus-group-position-point)))
5437 (defun gnus-group-goto-group (group)
5438 "Goto to newsgroup GROUP."
5440 (let ((b (text-property-any (point-min) (point-max)
5441 'gnus-group (gnus-intern-safe
5442 group gnus-active-hashtb))))
5443 (and b (goto-char b)))))
5445 (defun gnus-group-next-group (n)
5446 "Go to next N'th newsgroup.
5447 If N is negative, search backward instead.
5448 Returns the difference between N and the number of skips actually
5451 (gnus-group-next-unread-group n t))
5453 (defun gnus-group-next-unread-group (n &optional all level)
5454 "Go to next N'th unread newsgroup.
5455 If N is negative, search backward instead.
5456 If ALL is non-nil, choose any newsgroup, unread or not.
5457 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5458 such group can be found, the next group with a level higher than
5460 Returns the difference between N and the number of skips actually
5463 (let ((backward (< n 0))
5466 (gnus-group-search-forward
5467 backward (or (not gnus-group-goto-unread) all) level))
5469 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5470 (if level " on this level or higher" "")))
5473 (defun gnus-group-prev-group (n)
5474 "Go to previous N'th newsgroup.
5475 Returns the difference between N and the number of skips actually
5478 (gnus-group-next-unread-group (- n) t))
5480 (defun gnus-group-prev-unread-group (n)
5481 "Go to previous N'th unread newsgroup.
5482 Returns the difference between N and the number of skips actually
5485 (gnus-group-next-unread-group (- n)))
5487 (defun gnus-group-next-unread-group-same-level (n)
5488 "Go to next N'th unread newsgroup on the same level.
5489 If N is negative, search backward instead.
5490 Returns the difference between N and the number of skips actually
5493 (gnus-group-next-unread-group n t (gnus-group-group-level))
5494 (gnus-group-position-point))
5496 (defun gnus-group-prev-unread-group-same-level (n)
5497 "Go to next N'th unread newsgroup on the same level.
5498 Returns the difference between N and the number of skips actually
5501 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5502 (gnus-group-position-point))
5504 (defun gnus-group-best-unread-group (&optional exclude-group)
5505 "Go to the group with the highest level.
5506 If EXCLUDE-GROUP, do not go to that group."
5508 (goto-char (point-min))
5512 (setq unread (get-text-property (point) 'gnus-unread))
5513 (if (and (numberp unread) (> unread 0))
5515 (if (and (get-text-property (point) 'gnus-level)
5516 (< (get-text-property (point) 'gnus-level) best)
5517 (or (not exclude-group)
5518 (not (equal exclude-group (gnus-group-group-name)))))
5520 (setq best (get-text-property (point) 'gnus-level))
5521 (setq best-point (point))))))
5523 (if best-point (goto-char best-point))
5524 (gnus-summary-position-point)
5525 (and best-point (gnus-group-group-name))))
5527 (defun gnus-group-first-unread-group ()
5528 "Go to the first group with unread articles."
5531 (let ((opoint (point))
5533 (goto-char (point-min))
5534 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5535 (and (numberp unread) ; Not a topic.
5536 (not (zerop unread))) ; Has unread articles.
5537 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5540 nil)) ; Not success.
5541 (gnus-group-position-point)))
5543 (defun gnus-group-enter-server-mode ()
5544 "Jump to the server buffer."
5546 (gnus-enter-server-buffer))
5548 (defun gnus-group-make-group (name &optional method address)
5549 "Add a new newsgroup.
5550 The user will be prompted for a NAME, for a select METHOD, and an
5554 (read-string "Group name: ")
5557 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5558 nil t nil 'gnus-method-history)))
5559 (cond ((assoc method gnus-valid-select-methods)
5561 (if (memq 'prompt-address
5562 (assoc method gnus-valid-select-methods))
5563 (read-string "Address: ")
5565 ((assoc method gnus-server-alist)
5568 (list method ""))))))
5570 (let* ((meth (and method (if address (list (intern method) address)
5572 (nname (if method (gnus-group-prefixed-name name meth) name))
5574 (when (gnus-gethash nname gnus-newsrc-hashtb)
5575 (error "Group %s already exists" nname))
5576 ;; Subscribe to the new group.
5577 (gnus-group-change-level
5578 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5579 gnus-level-default-subscribed gnus-level-killed
5580 (and (gnus-group-group-name)
5581 (gnus-gethash (gnus-group-group-name)
5582 gnus-newsrc-hashtb))
5585 (gnus-set-active nname (cons 1 0))
5586 (or (gnus-ephemeral-group-p name)
5588 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5590 (gnus-group-insert-group-line-info nname)
5592 (gnus-group-position-point)
5594 ;; Load the backend and try to make the backend create
5595 ;; the group as well.
5596 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5598 gnus-valid-select-methods)
5600 (gnus-check-server meth)
5601 (and (gnus-check-backend-function 'request-create-group nname)
5602 (gnus-request-create-group nname))
5605 (defun gnus-group-delete-group (group &optional force)
5606 "Delete the current group.
5607 If FORCE (the prefix) is non-nil, all the articles in the group will
5608 be deleted. This is \"deleted\" as in \"removed forever from the face
5609 of the Earth\". There is no undo."
5611 (list (gnus-group-group-name)
5612 current-prefix-arg))
5613 (or group (error "No group to rename"))
5614 (or (gnus-check-backend-function 'request-delete-group group)
5615 (error "This backend does not support group deletion"))
5617 (if (not (gnus-yes-or-no-p
5619 "Do you really want to delete %s%s? "
5620 group (if force " and all its contents" ""))))
5622 (gnus-message 6 "Deleting group %s..." group)
5623 (if (not (gnus-request-delete-group group force))
5624 (gnus-error 3 "Couldn't delete group %s" group)
5625 (gnus-message 6 "Deleting group %s...done" group)
5626 (gnus-group-goto-group group)
5627 (gnus-group-kill-group 1 t)
5628 (gnus-sethash group nil gnus-active-hashtb)
5630 (gnus-group-position-point)))
5632 (defun gnus-group-rename-group (group new-name)
5635 (gnus-group-group-name)
5637 (or (gnus-check-backend-function
5638 'request-rename-group (gnus-group-group-name))
5639 (error "This backend does not support renaming groups"))
5640 (read-string "New group name: "))))
5642 (or (gnus-check-backend-function 'request-rename-group group)
5643 (error "This backend does not support renaming groups"))
5645 (or group (error "No group to rename"))
5646 (and (string-match "^[ \t]*$" new-name)
5647 (error "Not a valid group name"))
5649 ;; We find the proper prefixed name.
5651 (gnus-group-prefixed-name
5652 (gnus-group-real-name new-name)
5653 (gnus-info-method (gnus-get-info group))))
5655 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5657 (if (not (gnus-request-rename-group group new-name))
5658 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
5659 ;; We rename the group internally by killing it...
5660 (gnus-group-goto-group group)
5661 (gnus-group-kill-group)
5662 ;; ... changing its name ...
5663 (setcar (cdar gnus-list-of-killed-groups) new-name)
5664 ;; ... and then yanking it. Magic!
5665 (gnus-group-yank-group)
5666 (gnus-set-active new-name (gnus-active group))
5667 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5669 (gnus-group-position-point)))
5671 (defun gnus-group-edit-group (group &optional part)
5672 "Edit the group on the current line."
5673 (interactive (list (gnus-group-group-name)))
5674 (let* ((part (or part 'info))
5675 (done-func `(lambda ()
5676 "Exit editing mode and update the information."
5678 (gnus-group-edit-group-done ',part ,group)))
5679 (winconf (current-window-configuration))
5681 (or group (error "No group on current line"))
5682 (or (setq info (gnus-get-info group))
5683 (error "Killed group; can't be edited"))
5684 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5685 (gnus-configure-windows 'edit-group)
5686 (gnus-add-current-to-buffer-list)
5688 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5689 (use-local-map (copy-keymap emacs-lisp-mode-map))
5690 (local-set-key "\C-c\C-c" done-func)
5691 (make-local-variable 'gnus-prev-winconf)
5692 (setq gnus-prev-winconf winconf)
5697 ";; Type `C-c C-c' after editing the select method.\n\n")
5699 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5701 ";; Type `C-c C-c' after editing the group info.\n\n")))
5704 (cond ((eq part 'method)
5705 (or (gnus-info-method info) "native"))
5707 (gnus-info-params info))
5711 (defun gnus-group-edit-group-method (group)
5712 "Edit the select method of GROUP."
5713 (interactive (list (gnus-group-group-name)))
5714 (gnus-group-edit-group group 'method))
5716 (defun gnus-group-edit-group-parameters (group)
5717 "Edit the group parameters of GROUP."
5718 (interactive (list (gnus-group-group-name)))
5719 (gnus-group-edit-group group 'params))
5721 (defun gnus-group-edit-group-done (part group)
5722 "Get info from buffer, update variables and jump to the group buffer."
5723 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5724 (goto-char (point-min))
5725 (let* ((form (read (current-buffer)))
5726 (winconf gnus-prev-winconf)
5727 (method (cond ((eq part 'info) (nth 4 form))
5728 ((eq part 'method) form)
5730 (info (cond ((eq part 'info) form)
5731 ((eq part 'method) (gnus-get-info group))
5734 (if (or (not method)
5736 gnus-select-method method))
5737 (gnus-group-real-name (car info))
5738 (gnus-group-prefixed-name
5739 (gnus-group-real-name (car info)) method))
5741 (when (and new-group
5742 (not (equal new-group group)))
5743 (when (gnus-group-goto-group group)
5744 (gnus-group-kill-group 1))
5745 (gnus-activate-group new-group))
5747 (if (and info new-group)
5749 (setq info (gnus-copy-sequence info))
5750 (setcar info new-group)
5751 (unless (gnus-server-equal method "native")
5752 (unless (nthcdr 3 info)
5753 (nconc info (list nil nil)))
5754 (unless (nthcdr 4 info)
5755 (nconc info (list nil)))
5756 (gnus-info-set-method info method))
5757 (gnus-group-set-info info))
5758 (gnus-group-set-info form (or new-group group) part))
5759 (kill-buffer (current-buffer))
5760 (and winconf (set-window-configuration winconf))
5761 (set-buffer gnus-group-buffer)
5762 (gnus-group-update-group (or new-group group))
5763 (gnus-group-position-point)))
5765 (defun gnus-group-make-help-group ()
5766 "Create the Gnus documentation group."
5768 (let ((path load-path)
5769 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5771 (and (gnus-gethash name gnus-newsrc-hashtb)
5772 (error "Documentation group already exists"))
5774 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5776 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5778 (setq file (concat (file-name-directory
5779 (directory-file-name dir))
5780 "etc/gnus-tut.txt"))))
5783 (gnus-message 1 "Couldn't find doc group")
5784 (gnus-group-make-group
5785 (gnus-group-real-name name)
5786 (list 'nndoc "gnus-help"
5787 (list 'nndoc-address file)
5788 (list 'nndoc-article-type 'mbox)))))
5789 (gnus-group-position-point))
5791 (defun gnus-group-make-doc-group (file type)
5792 "Create a group that uses a single file as the source."
5794 (list (read-file-name "File name: ")
5795 (and current-prefix-arg 'ask)))
5796 (when (eq type 'ask)
5801 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5803 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5804 ((= char ?b) 'babyl)
5805 ((= char ?d) 'digest)
5806 ((= char ?f) 'forward)
5808 (t (setq err (format "%c unknown. " char))
5811 (let* ((file (expand-file-name file))
5812 (name (gnus-generate-new-group-name
5813 (gnus-group-prefixed-name
5814 (file-name-nondirectory file) '(nndoc "")))))
5815 (gnus-group-make-group
5816 (gnus-group-real-name name)
5817 (list 'nndoc (file-name-nondirectory file)
5818 (list 'nndoc-address file)
5819 (list 'nndoc-article-type (or type 'guess))))))
5821 (defun gnus-group-make-archive-group (&optional all)
5822 "Create the (ding) Gnus archive group of the most recent articles.
5823 Given a prefix, create a full group."
5825 (let ((group (gnus-group-prefixed-name
5826 (if all "ding.archives" "ding.recent") '(nndir ""))))
5827 (and (gnus-gethash group gnus-newsrc-hashtb)
5828 (error "Archive group already exists"))
5829 (gnus-group-make-group
5830 (gnus-group-real-name group)
5831 (list 'nndir (if all "hpc" "edu")
5832 (list 'nndir-directory
5833 (if all gnus-group-archive-directory
5834 gnus-group-recent-archive-directory))))))
5836 (defun gnus-group-make-directory-group (dir)
5837 "Create an nndir group.
5838 The user will be prompted for a directory. The contents of this
5839 directory will be used as a newsgroup. The directory should contain
5840 mail messages or news articles in files that have numeric names."
5842 (list (read-file-name "Create group from directory: ")))
5843 (or (file-exists-p dir) (error "No such directory"))
5844 (or (file-directory-p dir) (error "Not a directory"))
5848 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5850 (gnus-group-prefixed-name
5851 (concat (file-name-as-directory (directory-file-name dir))
5854 (setq ext (format "<%d>" (setq i (1+ i)))))
5855 (gnus-group-make-group
5856 (gnus-group-real-name group)
5857 (list 'nndir group (list 'nndir-directory dir)))))
5859 (defun gnus-group-make-kiboze-group (group address scores)
5860 "Create an nnkiboze group.
5861 The user will be prompted for a name, a regexp to match groups, and
5862 score file entries for articles to include in the group."
5865 (read-string "nnkiboze group name: ")
5866 (read-string "Source groups (regexp): ")
5867 (let ((headers (mapcar (lambda (group) (list group))
5868 '("subject" "from" "number" "date" "message-id"
5869 "references" "chars" "lines" "xref"
5870 "followup" "all" "body" "head")))
5871 scores header regexp regexps)
5872 (while (not (equal "" (setq header (completing-read
5873 "Match on header: " headers nil t))))
5875 (while (not (equal "" (setq regexp (read-string
5876 (format "Match on %s (string): "
5878 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5879 (setq scores (cons (cons header regexps) scores)))
5881 (gnus-group-make-group group "nnkiboze" address)
5882 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
5883 (let (emacs-lisp-mode-hook)
5884 (pp scores (current-buffer)))))
5886 (defun gnus-group-add-to-virtual (n vgroup)
5887 "Add the current group to a virtual group."
5889 (list current-prefix-arg
5890 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5892 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5893 (error "%s is not an nnvirtual group" vgroup))
5894 (let* ((groups (gnus-group-process-prefix n))
5895 (method (gnus-info-method (gnus-get-info vgroup))))
5896 (setcar (cdr method)
5898 (nth 1 method) "\\|"
5901 (gnus-group-remove-mark s)
5902 (concat "\\(^" (regexp-quote s) "$\\)"))
5904 (gnus-group-position-point))
5906 (defun gnus-group-make-empty-virtual (group)
5907 "Create a new, fresh, empty virtual group."
5908 (interactive "sCreate new, empty virtual group: ")
5909 (let* ((method (list 'nnvirtual "^$"))
5910 (pgroup (gnus-group-prefixed-name group method)))
5911 ;; Check whether it exists already.
5912 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5913 (error "Group %s already exists." pgroup))
5914 ;; Subscribe the new group after the group on the current line.
5915 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5916 (gnus-group-update-group pgroup)
5918 (gnus-group-position-point)))
5920 (defun gnus-group-enter-directory (dir)
5921 "Enter an ephemeral nneething group."
5922 (interactive "DDirectory to read: ")
5923 (let* ((method (list 'nneething dir))
5924 (leaf (gnus-group-prefixed-name
5925 (file-name-nondirectory (directory-file-name dir))
5927 (name (gnus-generate-new-group-name leaf)))
5928 (let ((nneething-read-only t))
5929 (or (gnus-group-read-ephemeral-group
5931 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5933 (error "Couldn't enter %s" dir)))))
5935 ;; Group sorting commands
5936 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5938 (defun gnus-group-sort-groups (func &optional reverse)
5939 "Sort the group buffer according to FUNC.
5940 If REVERSE, reverse the sorting order."
5941 (interactive (list gnus-group-sort-function
5942 current-prefix-arg))
5944 ((not (listp func)) func)
5946 ((= 1 (length func)) (car func))
5948 ,(gnus-make-sort-function
5949 (reverse func)))))))
5950 ;; We peel off the dummy group from the alist.
5952 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5953 (pop gnus-newsrc-alist))
5955 (setq gnus-newsrc-alist
5956 (sort gnus-newsrc-alist func))
5958 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5959 ;; Regenerate the hash table.
5960 (gnus-make-hashtable-from-newsrc-alist)
5961 (gnus-group-list-groups))))
5963 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5964 "Sort the group buffer alphabetically by group name.
5965 If REVERSE, sort in reverse order."
5967 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5969 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5970 "Sort the group buffer by number of unread articles.
5971 If REVERSE, sort in reverse order."
5973 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5975 (defun gnus-group-sort-groups-by-level (&optional reverse)
5976 "Sort the group buffer by group level.
5977 If REVERSE, sort in reverse order."
5979 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5981 (defun gnus-group-sort-groups-by-score (&optional reverse)
5982 "Sort the group buffer by group score.
5983 If REVERSE, sort in reverse order."
5985 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5987 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5988 "Sort the group buffer by group rank.
5989 If REVERSE, sort in reverse order."
5991 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5993 (defun gnus-group-sort-groups-by-method (&optional reverse)
5994 "Sort the group buffer alphabetically by backend name.
5995 If REVERSE, sort in reverse order."
5997 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
5999 (defun gnus-group-sort-by-alphabet (info1 info2)
6000 "Sort alphabetically."
6001 (string< (gnus-info-group info1) (gnus-info-group info2)))
6003 (defun gnus-group-sort-by-unread (info1 info2)
6004 "Sort by number of unread articles."
6005 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
6006 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
6007 (< (or (and (numberp n1) n1) 0)
6008 (or (and (numberp n2) n2) 0))))
6010 (defun gnus-group-sort-by-level (info1 info2)
6012 (< (gnus-info-level info1) (gnus-info-level info2)))
6014 (defun gnus-group-sort-by-method (info1 info2)
6015 "Sort alphabetically by backend name."
6016 (string< (symbol-name (car (gnus-find-method-for-group
6017 (gnus-info-group info1) info1)))
6018 (symbol-name (car (gnus-find-method-for-group
6019 (gnus-info-group info2) info2)))))
6021 (defun gnus-group-sort-by-score (info1 info2)
6022 "Sort by group score."
6023 (< (gnus-info-score info1) (gnus-info-score info2)))
6025 (defun gnus-group-sort-by-rank (info1 info2)
6026 "Sort by level and score."
6027 (let ((level1 (gnus-info-level info1))
6028 (level2 (gnus-info-level info2)))
6029 (or (< level1 level2)
6030 (and (= level1 level2)
6031 (> (gnus-info-score info1) (gnus-info-score info2))))))
6033 ;; Group catching up.
6035 (defun gnus-group-clear-data (n)
6036 "Clear all marks and read ranges from the current group."
6038 (let ((groups (gnus-group-process-prefix n))
6040 (while (setq group (pop groups))
6041 (setq info (gnus-get-info group))
6042 (gnus-info-set-read info nil)
6043 (when (gnus-info-marks info)
6044 (gnus-info-set-marks info nil))
6045 (gnus-get-unread-articles-in-group info (gnus-active group) t)
6046 (when (gnus-group-goto-group group)
6047 (gnus-group-remove-mark group)
6048 (gnus-group-update-group-line)))))
6050 (defun gnus-group-catchup-current (&optional n all)
6051 "Mark all articles not marked as unread in current newsgroup as read.
6052 If prefix argument N is numeric, the ARG next newsgroups will be
6053 caught up. If ALL is non-nil, marked articles will also be marked as
6054 read. Cross references (Xref: header) of articles are ignored.
6055 The difference between N and actual number of newsgroups that were
6056 caught up is returned."
6058 (unless (gnus-group-group-name)
6059 (error "No group on the current line"))
6060 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
6064 "Do you really want to mark all articles as read? "
6065 "Mark all unread articles as read? "))))
6067 (let ((groups (gnus-group-process-prefix n))
6070 ;; Virtual groups have to be given special treatment.
6071 (let ((method (gnus-find-method-for-group (car groups))))
6072 (if (eq 'nnvirtual (car method))
6073 (nnvirtual-catchup-group
6074 (gnus-group-real-name (car groups)) (nth 1 method) all)))
6075 (gnus-group-remove-mark (car groups))
6076 (if (>= (gnus-group-group-level) gnus-level-zombie)
6077 (gnus-message 2 "Dead groups can't be caught up")
6079 (gnus-group-goto-group (car groups))
6080 (gnus-group-catchup (car groups) all))
6081 (gnus-group-update-group-line)
6082 (setq ret (1+ ret))))
6083 (setq groups (cdr groups)))
6084 (gnus-group-next-unread-group 1)
6087 (defun gnus-group-catchup-current-all (&optional n)
6088 "Mark all articles in current newsgroup as read.
6089 Cross references (Xref: header) of articles are ignored."
6091 (gnus-group-catchup-current n 'all))
6093 (defun gnus-group-catchup (group &optional all)
6094 "Mark all articles in GROUP as read.
6095 If ALL is non-nil, all articles are marked as read.
6096 The return value is the number of articles that were marked as read,
6097 or nil if no action could be taken."
6098 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6100 ;; Do the updating only if the newsgroup isn't killed.
6101 (if (not (numberp (car entry)))
6102 (gnus-message 1 "Can't catch up; non-active group")
6103 ;; Do auto-expirable marks if that's required.
6104 (when (gnus-group-auto-expirable-p group)
6105 (gnus-add-marked-articles
6106 group 'expire (gnus-list-of-unread-articles group))
6108 (let ((marks (nth 3 (nth 2 entry))))
6109 (gnus-add-marked-articles
6110 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
6111 (gnus-add-marked-articles
6112 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
6114 (gnus-update-read-articles group nil)
6115 ;; Also nix out the lists of marks and dormants.
6117 (gnus-add-marked-articles group 'tick nil nil 'force)
6118 (gnus-add-marked-articles group 'dormant nil nil 'force))
6119 (run-hooks 'gnus-group-catchup-group-hook)
6122 (defun gnus-group-expire-articles (&optional n)
6123 "Expire all expirable articles in the current newsgroup."
6125 (let ((groups (gnus-group-process-prefix n))
6128 (error "No groups to expire"))
6129 (while (setq group (pop groups))
6130 (gnus-group-remove-mark group)
6131 (when (gnus-check-backend-function 'request-expire-articles group)
6132 (gnus-message 6 "Expiring articles in %s..." group)
6133 (let* ((info (gnus-get-info group))
6134 (expirable (if (gnus-group-total-expirable-p group)
6135 (cons nil (gnus-list-of-read-articles group))
6136 (assq 'expire (gnus-info-marks info))))
6137 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
6141 (gnus-compress-sequence
6143 ;; We set the expiry variables to the groupp
6145 (let ((nnmail-expiry-wait-function nil)
6146 (nnmail-expiry-wait expiry-wait))
6147 (gnus-request-expire-articles
6148 (gnus-uncompress-sequence (cdr expirable)) group))
6149 ;; Just expire using the normal expiry values.
6150 (gnus-request-expire-articles
6151 (gnus-uncompress-sequence (cdr expirable)) group)))))
6152 (gnus-message 6 "Expiring articles in %s...done" group)))
6153 (gnus-group-position-point))))
6155 (defun gnus-group-expire-all-groups ()
6156 "Expire all expirable articles in all newsgroups."
6159 (gnus-message 5 "Expiring...")
6160 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6161 (cdr gnus-newsrc-alist))))
6162 (gnus-group-expire-articles nil)))
6163 (gnus-group-position-point)
6164 (gnus-message 5 "Expiring...done"))
6166 (defun gnus-group-set-current-level (n level)
6167 "Set the level of the next N groups to LEVEL."
6172 (let ((s (read-string
6173 (format "Level (default %s): "
6174 (or (gnus-group-group-level)
6175 gnus-level-default-subscribed)))))
6176 (if (string-match "^\\s-*$" s)
6177 (int-to-string (or (gnus-group-group-level)
6178 gnus-level-default-subscribed))
6180 (or (and (>= level 1) (<= level gnus-level-killed))
6181 (error "Illegal level: %d" level))
6182 (let ((groups (gnus-group-process-prefix n))
6184 (while (setq group (pop groups))
6185 (gnus-group-remove-mark group)
6186 (gnus-message 6 "Changed level of %s from %d to %d"
6187 group (or (gnus-group-group-level) gnus-level-killed)
6189 (gnus-group-change-level
6190 group level (or (gnus-group-group-level) gnus-level-killed))
6191 (gnus-group-update-group-line)))
6192 (gnus-group-position-point))
6194 (defun gnus-group-unsubscribe-current-group (&optional n)
6195 "Toggle subscription of the current group.
6196 If given numerical prefix, toggle the N next groups."
6198 (let ((groups (gnus-group-process-prefix n))
6201 (setq group (car groups)
6202 groups (cdr groups))
6203 (gnus-group-remove-mark group)
6204 (gnus-group-unsubscribe-group
6205 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6206 gnus-level-default-unsubscribed
6207 gnus-level-default-subscribed) t)
6208 (gnus-group-update-group-line))
6209 (gnus-group-next-group 1)))
6211 (defun gnus-group-unsubscribe-group (group &optional level silent)
6212 "Toggle subscription to GROUP.
6213 Killed newsgroups are subscribed. If SILENT, don't try to update the
6216 (list (completing-read
6217 "Group: " gnus-active-hashtb nil
6218 (gnus-read-active-file-p)
6220 'gnus-group-history)))
6221 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6223 ((string-match "^[ \t]$" group)
6224 (error "Empty group name"))
6226 ;; Toggle subscription flag.
6227 (gnus-group-change-level
6228 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6229 gnus-level-subscribed)
6230 (1+ gnus-level-subscribed)
6231 gnus-level-default-subscribed)))
6233 (gnus-group-update-group group)))
6234 ((and (stringp group)
6235 (or (not (gnus-read-active-file-p))
6236 (gnus-active group)))
6237 ;; Add new newsgroup.
6238 (gnus-group-change-level
6240 (if level level gnus-level-default-subscribed)
6241 (or (and (member group gnus-zombie-list)
6244 (and (gnus-group-group-name)
6245 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6247 (gnus-group-update-group group)))
6248 (t (error "No such newsgroup: %s" group)))
6249 (gnus-group-position-point)))
6251 (defun gnus-group-transpose-groups (n)
6252 "Move the current newsgroup up N places.
6253 If given a negative prefix, move down instead. The difference between
6254 N and the number of steps taken is returned."
6256 (or (gnus-group-group-name)
6257 (error "No group on current line"))
6258 (gnus-group-kill-group 1)
6260 (forward-line (- n))
6261 (gnus-group-yank-group)
6262 (gnus-group-position-point)))
6264 (defun gnus-group-kill-all-zombies ()
6265 "Kill all zombie newsgroups."
6267 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6268 (setq gnus-zombie-list nil)
6269 (gnus-group-list-groups))
6271 (defun gnus-group-kill-region (begin end)
6272 "Kill newsgroups in current region (excluding current point).
6273 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6288 (beginning-of-line) ;Important when LINES < 1
6289 (gnus-group-kill-group lines)))
6291 (defun gnus-group-kill-group (&optional n discard)
6292 "Kill the next N groups.
6293 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6294 However, only groups that were alive can be yanked; already killed
6295 groups or zombie groups can't be yanked.
6296 The return value is the name of the group that was killed, or a list
6299 (let ((buffer-read-only nil)
6300 (groups (gnus-group-process-prefix n))
6301 group entry level out)
6302 (if (< (length groups) 10)
6303 ;; This is faster when there are few groups.
6305 (push (setq group (pop groups)) out)
6306 (gnus-group-remove-mark group)
6307 (setq level (gnus-group-group-level))
6309 (when (and (not discard)
6310 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6311 (push (cons (car entry) (nth 2 entry))
6312 gnus-list-of-killed-groups))
6313 (gnus-group-change-level
6314 (if entry entry group) gnus-level-killed (if entry nil level)))
6315 ;; If there are lots and lots of groups to be killed, we use
6316 ;; this thing instead.
6318 (setq groups (nreverse groups))
6320 (gnus-group-remove-mark (setq group (pop groups)))
6323 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6324 (push (cons (car entry) (nth 2 entry))
6325 gnus-list-of-killed-groups)
6326 (setcdr (cdr entry) (cdddr entry)))
6327 ((member group gnus-zombie-list)
6328 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6329 (gnus-make-hashtable-from-newsrc-alist)))
6331 (gnus-group-position-point)
6332 (if (< (length out) 2) (car out) (nreverse out))))
6334 (defun gnus-group-yank-group (&optional arg)
6335 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6336 inserting it before the current newsgroup. The numeric ARG specifies
6337 how many newsgroups are to be yanked. The name of the newsgroup yanked
6338 is returned, or (if several groups are yanked) a list of yanked groups
6341 (setq arg (or arg 1))
6342 (let (info group prev out)
6343 (while (>= (decf arg) 0)
6344 (if (not (setq info (pop gnus-list-of-killed-groups)))
6345 (error "No more newsgroups to yank"))
6346 (push (setq group (nth 1 info)) out)
6347 ;; Find which newsgroup to insert this one before - search
6348 ;; backward until something suitable is found. If there are no
6349 ;; other newsgroups in this buffer, just make this newsgroup the
6351 (setq prev (gnus-group-group-name))
6352 (gnus-group-change-level
6353 info (gnus-info-level (cdr info)) gnus-level-killed
6354 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6356 (gnus-group-insert-group-line-info group))
6358 (gnus-group-position-point)
6359 (if (< (length out) 2) (car out) (nreverse out))))
6361 (defun gnus-group-kill-level (level)
6362 "Kill all groups that is on a certain LEVEL."
6363 (interactive "nKill all groups on level: ")
6365 ((= level gnus-level-zombie)
6366 (setq gnus-killed-list
6367 (nconc gnus-zombie-list gnus-killed-list))
6368 (setq gnus-zombie-list nil))
6369 ((and (< level gnus-level-zombie)
6371 (or gnus-expert-user
6374 "Do you really want to kill all groups on level %d? "
6376 (let* ((prev gnus-newsrc-alist)
6379 (if (= (gnus-info-level level) level)
6380 (setcdr prev (cdr alist))
6382 (setq alist (cdr alist)))
6383 (gnus-make-hashtable-from-newsrc-alist)
6384 (gnus-group-list-groups)))
6386 (error "Can't kill; illegal level: %d" level))))
6388 (defun gnus-group-list-all-groups (&optional arg)
6389 "List all newsgroups with level ARG or lower.
6390 Default is gnus-level-unsubscribed, which lists all subscribed and most
6391 unsubscribed groups."
6393 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6395 ;; Redefine this to list ALL killed groups if prefix arg used.
6396 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6397 (defun gnus-group-list-killed (&optional arg)
6398 "List all killed newsgroups in the group buffer.
6399 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6400 entail asking the server for the groups."
6402 ;; Find all possible killed newsgroups if arg.
6404 (gnus-get-killed-groups))
6405 (if (not gnus-killed-list)
6406 (gnus-message 6 "No killed groups")
6407 (let (gnus-group-list-mode)
6408 (funcall gnus-group-prepare-function
6409 gnus-level-killed t gnus-level-killed))
6410 (goto-char (point-min)))
6411 (gnus-group-position-point))
6413 (defun gnus-group-list-zombies ()
6414 "List all zombie newsgroups in the group buffer."
6416 (if (not gnus-zombie-list)
6417 (gnus-message 6 "No zombie groups")
6418 (let (gnus-group-list-mode)
6419 (funcall gnus-group-prepare-function
6420 gnus-level-zombie t gnus-level-zombie))
6421 (goto-char (point-min)))
6422 (gnus-group-position-point))
6424 (defun gnus-group-list-active ()
6425 "List all groups that are available from the server(s)."
6427 ;; First we make sure that we have really read the active file.
6428 (unless (gnus-read-active-file-p)
6429 (let ((gnus-read-active-file t))
6430 (gnus-read-active-file)))
6431 ;; Find all groups and sort them.
6439 (setq list (cons (symbol-name sym) list))))
6443 (buffer-read-only nil))
6446 (gnus-group-insert-group-line-info (pop groups)))
6447 (goto-char (point-min))))
6449 (defun gnus-activate-all-groups (level)
6450 "Activate absolutely all groups."
6451 (interactive (list 7))
6452 (let ((gnus-activate-level level)
6453 (gnus-activate-foreign-newsgroups level))
6454 (gnus-group-get-new-news)))
6456 (defun gnus-group-get-new-news (&optional arg)
6457 "Get newly arrived articles.
6458 If ARG is a number, it specifies which levels you are interested in
6459 re-scanning. If ARG is non-nil and not a number, this will force
6460 \"hard\" re-reading of the active files from all servers."
6462 (run-hooks 'gnus-get-new-news-hook)
6463 ;; We might read in new NoCeM messages here.
6464 (when (and gnus-use-nocem
6466 (gnus-nocem-scan-groups))
6467 ;; If ARG is not a number, then we read the active file.
6468 (when (and arg (not (numberp arg)))
6469 (let ((gnus-read-active-file t))
6470 (gnus-read-active-file))
6473 (setq arg (gnus-group-default-level arg t))
6474 (if (and gnus-read-active-file (not arg))
6476 (gnus-read-active-file)
6477 (gnus-get-unread-articles arg))
6478 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6479 (gnus-get-unread-articles arg)))
6480 (run-hooks 'gnus-after-getting-new-news-hook)
6481 (gnus-group-list-groups))
6483 (defun gnus-group-get-new-news-this-group (&optional n)
6484 "Check for newly arrived news in the current group (and the N-1 next groups).
6485 The difference between N and the number of newsgroup checked is returned.
6486 If N is negative, this group and the N-1 previous groups will be checked."
6488 (let* ((groups (gnus-group-process-prefix n))
6489 (ret (if (numberp n) (- n (length groups)) 0))
6490 (beg (unless n (point)))
6492 (while (setq group (pop groups))
6493 (gnus-group-remove-mark group)
6494 (if (gnus-activate-group group 'scan)
6496 (gnus-get-unread-articles-in-group
6497 (gnus-get-info group) (gnus-active group) t)
6498 (unless (gnus-virtual-group-p group)
6499 (gnus-close-group group))
6500 (gnus-group-update-group group))
6501 (gnus-error 3 "%s error: %s" group (gnus-status-message group))))
6502 (when beg (goto-char beg))
6503 (when gnus-goto-next-group-when-activating
6504 (gnus-group-next-unread-group 1 t))
6505 (gnus-summary-position-point)
6508 (defun gnus-group-fetch-faq (group &optional faq-dir)
6509 "Fetch the FAQ for the current group."
6512 (gnus-group-real-name (gnus-group-group-name))
6513 (cond (current-prefix-arg
6515 "Faq dir: " (and (listp gnus-group-faq-directory)
6516 gnus-group-faq-directory))))))
6518 (setq faq-dir (if (listp gnus-group-faq-directory)
6519 (car gnus-group-faq-directory)
6520 gnus-group-faq-directory)))
6521 (or group (error "No group name given"))
6522 (let ((file (concat (file-name-as-directory faq-dir)
6523 (gnus-group-real-name group))))
6524 (if (not (file-exists-p file))
6525 (error "No such file: %s" file)
6528 (defun gnus-group-describe-group (force &optional group)
6529 "Display a description of the current newsgroup."
6530 (interactive (list current-prefix-arg (gnus-group-group-name)))
6531 (and force (setq gnus-description-hashtb nil))
6532 (let ((method (gnus-find-method-for-group group))
6534 (or group (error "No group name given"))
6535 (and (or (and gnus-description-hashtb
6536 ;; We check whether this group's method has been
6537 ;; queried for a description file.
6539 (gnus-group-prefixed-name "" method)
6540 gnus-description-hashtb))
6541 (setq desc (gnus-group-get-description group))
6542 (gnus-read-descriptions-file method))
6544 (or desc (gnus-gethash group gnus-description-hashtb)
6545 "No description available")))))
6547 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6548 (defun gnus-group-describe-all-groups (&optional force)
6549 "Pop up a buffer with descriptions of all newsgroups."
6551 (and force (setq gnus-description-hashtb nil))
6552 (if (not (or gnus-description-hashtb
6553 (gnus-read-all-descriptions-files)))
6554 (error "Couldn't request descriptions file"))
6555 (let ((buffer-read-only nil)
6561 (insert (format " *: %-20s %s\n" (symbol-name group)
6562 (symbol-value group)))
6563 (gnus-add-text-properties
6564 b (1+ b) (list 'gnus-group group
6565 'gnus-unread t 'gnus-marked nil
6566 'gnus-level (1+ gnus-level-subscribed))))
6567 gnus-description-hashtb)
6568 (goto-char (point-min))
6569 (gnus-group-position-point)))
6571 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6572 (defun gnus-group-apropos (regexp &optional search-description)
6573 "List all newsgroups that have names that match a regexp."
6574 (interactive "sGnus apropos (regexp): ")
6576 (obuf (current-buffer))
6578 ;; Go through all newsgroups that are known to Gnus.
6581 (and (symbol-name group)
6582 (string-match regexp (symbol-name group))
6583 (setq groups (cons (symbol-name group) groups))))
6585 ;; Also go through all descriptions that are known to Gnus.
6586 (when search-description
6589 (and (string-match regexp (symbol-value group))
6590 (gnus-active (symbol-name group))
6591 (setq groups (cons (symbol-name group) groups))))
6592 gnus-description-hashtb))
6594 (gnus-message 3 "No groups matched \"%s\"." regexp)
6595 ;; Print out all the groups.
6597 (pop-to-buffer "*Gnus Help*")
6598 (buffer-disable-undo (current-buffer))
6600 (setq groups (sort groups 'string<))
6602 ;; Groups may be entered twice into the list of groups.
6603 (if (not (string= (car groups) prev))
6605 (insert (setq prev (car groups)) "\n")
6606 (if (and gnus-description-hashtb
6607 (setq des (gnus-gethash (car groups)
6608 gnus-description-hashtb)))
6609 (insert " " des "\n"))))
6610 (setq groups (cdr groups)))
6611 (goto-char (point-min))))
6612 (pop-to-buffer obuf)))
6614 (defun gnus-group-description-apropos (regexp)
6615 "List all newsgroups that have names or descriptions that match a regexp."
6616 (interactive "sGnus description apropos (regexp): ")
6617 (if (not (or gnus-description-hashtb
6618 (gnus-read-all-descriptions-files)))
6619 (error "Couldn't request descriptions file"))
6620 (gnus-group-apropos regexp t))
6622 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6623 (defun gnus-group-list-matching (level regexp &optional all lowest)
6624 "List all groups with unread articles that match REGEXP.
6625 If the prefix LEVEL is non-nil, it should be a number that says which
6626 level to cut off listing groups.
6627 If ALL, also list groups with no unread articles.
6628 If LOWEST, don't list groups with level lower than LOWEST.
6630 This command may read the active file."
6631 (interactive "P\nsList newsgroups matching: ")
6632 ;; First make sure active file has been read.
6634 (> (prefix-numeric-value level) gnus-level-killed))
6635 (gnus-get-killed-groups))
6636 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6637 all (or lowest 1) regexp)
6638 (goto-char (point-min))
6639 (gnus-group-position-point))
6641 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6642 "List all groups that match REGEXP.
6643 If the prefix LEVEL is non-nil, it should be a number that says which
6644 level to cut off listing groups.
6645 If LOWEST, don't list groups with level lower than LOWEST."
6646 (interactive "P\nsList newsgroups matching: ")
6647 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6649 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6650 (defun gnus-group-save-newsrc (&optional force)
6651 "Save the Gnus startup files.
6652 If FORCE, force saving whether it is necessary or not."
6654 (gnus-save-newsrc-file force))
6656 (defun gnus-group-restart (&optional arg)
6657 "Force Gnus to read the .newsrc file."
6659 (when (gnus-yes-or-no-p
6660 (format "Are you sure you want to read %s? "
6661 gnus-current-startup-file))
6662 (gnus-save-newsrc-file)
6663 (gnus-setup-news 'force)
6664 (gnus-group-list-groups arg)))
6666 (defun gnus-group-read-init-file ()
6667 "Read the Gnus elisp init file."
6669 (gnus-read-init-file))
6671 (defun gnus-group-check-bogus-groups (&optional silent)
6672 "Check bogus newsgroups.
6673 If given a prefix, don't ask for confirmation before removing a bogus
6676 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6677 (gnus-group-list-groups))
6679 (defun gnus-group-edit-global-kill (&optional article group)
6680 "Edit the global kill file.
6681 If GROUP, edit that local kill file instead."
6683 (setq gnus-current-kill-article article)
6684 (gnus-kill-file-edit-file group)
6687 (substitute-command-keys
6688 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6689 (if group "local" "global")))))
6691 (defun gnus-group-edit-local-kill (article group)
6692 "Edit a local kill file."
6693 (interactive (list nil (gnus-group-group-name)))
6694 (gnus-group-edit-global-kill article group))
6696 (defun gnus-group-force-update ()
6697 "Update `.newsrc' file."
6699 (gnus-save-newsrc-file))
6701 (defun gnus-group-suspend ()
6702 "Suspend the current Gnus session.
6703 In fact, cleanup buffers except for group mode buffer.
6704 The hook gnus-suspend-gnus-hook is called before actually suspending."
6706 (run-hooks 'gnus-suspend-gnus-hook)
6707 ;; Kill Gnus buffers except for group mode buffer.
6708 (let ((group-buf (get-buffer gnus-group-buffer)))
6709 ;; Do this on a separate list in case the user does a ^G before we finish
6710 (let ((gnus-buffer-list
6711 (delq group-buf (delq gnus-dribble-buffer
6712 (append gnus-buffer-list nil)))))
6713 (while gnus-buffer-list
6714 (gnus-kill-buffer (car gnus-buffer-list))
6715 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6718 (setq gnus-buffer-list (list group-buf))
6719 (bury-buffer group-buf)
6720 (delete-windows-on group-buf t)))))
6722 (defun gnus-group-clear-dribble ()
6723 "Clear all information from the dribble buffer."
6725 (gnus-dribble-clear)
6726 (gnus-message 7 "Cleared dribble buffer"))
6728 (defun gnus-group-exit ()
6729 "Quit reading news after updating .newsrc.eld and .newsrc.
6730 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6733 (or noninteractive ;For gnus-batch-kill
6734 (not gnus-interactive-exit) ;Without confirmation
6736 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6737 (run-hooks 'gnus-exit-gnus-hook)
6738 ;; Offer to save data from non-quitted summary buffers.
6739 (gnus-offer-save-summaries)
6740 ;; Save the newsrc file(s).
6741 (gnus-save-newsrc-file)
6743 (gnus-close-backends)
6744 ;; Reset everything.
6746 ;; Allow the user to do things after cleaning up.
6747 (run-hooks 'gnus-after-exiting-gnus-hook)))
6749 (defun gnus-close-backends ()
6750 ;; Send a close request to all backends that support such a request.
6751 (let ((methods gnus-valid-select-methods)
6754 (if (fboundp (setq func (intern (concat (caar methods)
6755 "-request-close"))))
6757 (setq methods (cdr methods)))))
6759 (defun gnus-group-quit ()
6760 "Quit reading news without updating .newsrc.eld or .newsrc.
6761 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6763 (when (or noninteractive ;For gnus-batch-kill
6764 (zerop (buffer-size))
6765 (not (gnus-server-opened gnus-select-method))
6767 (not gnus-current-startup-file)
6769 (format "Quit reading news without saving %s? "
6770 (file-name-nondirectory gnus-current-startup-file))))
6771 (run-hooks 'gnus-exit-gnus-hook)
6772 (if gnus-use-full-window
6773 (delete-other-windows)
6774 (gnus-remove-some-windows))
6776 (gnus-close-backends)
6778 ;; Allow the user to do things after cleaning up.
6779 (run-hooks 'gnus-after-exiting-gnus-hook)))
6781 (defun gnus-offer-save-summaries ()
6782 "Offer to save all active summary buffers."
6784 (let ((buflist (buffer-list))
6786 ;; Go through all buffers and find all summaries.
6788 (and (setq bufname (buffer-name (car buflist)))
6789 (string-match "Summary" bufname)
6791 (set-buffer bufname)
6792 ;; We check that this is, indeed, a summary buffer.
6793 (and (eq major-mode 'gnus-summary-mode)
6794 ;; Also make sure this isn't bogus.
6795 gnus-newsgroup-prepared))
6796 (push bufname buffers))
6797 (setq buflist (cdr buflist)))
6798 ;; Go through all these summary buffers and offer to save them.
6801 "Update summary buffer %s? "
6802 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6805 (defun gnus-group-describe-briefly ()
6806 "Give a one line description of the group mode commands."
6808 (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")))
6810 (defun gnus-group-browse-foreign-server (method)
6811 "Browse a foreign news server.
6812 If called interactively, this function will ask for a select method
6813 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6814 If not, METHOD should be a list where the first element is the method
6815 and the second element is the address."
6817 (list (let ((how (completing-read
6819 (append gnus-valid-select-methods gnus-server-alist)
6820 nil t (cons "nntp" 0) 'gnus-method-history)))
6821 ;; We either got a backend name or a virtual server name.
6822 ;; If the first, we also need an address.
6823 (if (assoc how gnus-valid-select-methods)
6825 ;; Suggested by mapjph@bath.ac.uk.
6828 (mapcar (lambda (server) (list server))
6829 gnus-secondary-servers)))
6830 ;; We got a server name, so we find the method.
6831 (gnus-server-to-method how)))))
6832 (gnus-browse-foreign-server method))
6836 ;;; Gnus summary mode
6839 (defvar gnus-summary-mode-map nil)
6841 (put 'gnus-summary-mode 'mode-class 'special)
6843 (unless gnus-summary-mode-map
6844 (setq gnus-summary-mode-map (make-keymap))
6845 (suppress-keymap gnus-summary-mode-map)
6847 ;; Non-orthogonal keys
6849 (gnus-define-keys gnus-summary-mode-map
6850 " " gnus-summary-next-page
6851 "\177" gnus-summary-prev-page
6852 [delete] gnus-summary-prev-page
6853 "\r" gnus-summary-scroll-up
6854 "n" gnus-summary-next-unread-article
6855 "p" gnus-summary-prev-unread-article
6856 "N" gnus-summary-next-article
6857 "P" gnus-summary-prev-article
6858 "\M-\C-n" gnus-summary-next-same-subject
6859 "\M-\C-p" gnus-summary-prev-same-subject
6860 "\M-n" gnus-summary-next-unread-subject
6861 "\M-p" gnus-summary-prev-unread-subject
6862 "." gnus-summary-first-unread-article
6863 "," gnus-summary-best-unread-article
6864 "\M-s" gnus-summary-search-article-forward
6865 "\M-r" gnus-summary-search-article-backward
6866 "<" gnus-summary-beginning-of-article
6867 ">" gnus-summary-end-of-article
6868 "j" gnus-summary-goto-article
6869 "^" gnus-summary-refer-parent-article
6870 "\M-^" gnus-summary-refer-article
6871 "u" gnus-summary-tick-article-forward
6872 "!" gnus-summary-tick-article-forward
6873 "U" gnus-summary-tick-article-backward
6874 "d" gnus-summary-mark-as-read-forward
6875 "D" gnus-summary-mark-as-read-backward
6876 "E" gnus-summary-mark-as-expirable
6877 "\M-u" gnus-summary-clear-mark-forward
6878 "\M-U" gnus-summary-clear-mark-backward
6879 "k" gnus-summary-kill-same-subject-and-select
6880 "\C-k" gnus-summary-kill-same-subject
6881 "\M-\C-k" gnus-summary-kill-thread
6882 "\M-\C-l" gnus-summary-lower-thread
6883 "e" gnus-summary-edit-article
6884 "#" gnus-summary-mark-as-processable
6885 "\M-#" gnus-summary-unmark-as-processable
6886 "\M-\C-t" gnus-summary-toggle-threads
6887 "\M-\C-s" gnus-summary-show-thread
6888 "\M-\C-h" gnus-summary-hide-thread
6889 "\M-\C-f" gnus-summary-next-thread
6890 "\M-\C-b" gnus-summary-prev-thread
6891 "\M-\C-u" gnus-summary-up-thread
6892 "\M-\C-d" gnus-summary-down-thread
6893 "&" gnus-summary-execute-command
6894 "c" gnus-summary-catchup-and-exit
6895 "\C-w" gnus-summary-mark-region-as-read
6896 "\C-t" gnus-summary-toggle-truncation
6897 "?" gnus-summary-mark-as-dormant
6898 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6899 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6900 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6901 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6902 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6903 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6904 "=" gnus-summary-expand-window
6905 "\C-x\C-s" gnus-summary-reselect-current-group
6906 "\M-g" gnus-summary-rescan-group
6907 "w" gnus-summary-stop-page-breaking
6908 "\C-c\C-r" gnus-summary-caesar-message
6909 "\M-t" gnus-summary-toggle-mime
6910 "f" gnus-summary-followup
6911 "F" gnus-summary-followup-with-original
6912 "C" gnus-summary-cancel-article
6913 "r" gnus-summary-reply
6914 "R" gnus-summary-reply-with-original
6915 "\C-c\C-f" gnus-summary-mail-forward
6916 "o" gnus-summary-save-article
6917 "\C-o" gnus-summary-save-article-mail
6918 "|" gnus-summary-pipe-output
6919 "\M-k" gnus-summary-edit-local-kill
6920 "\M-K" gnus-summary-edit-global-kill
6922 "\C-c\C-d" gnus-summary-describe-group
6923 "q" gnus-summary-exit
6924 "Q" gnus-summary-exit-no-update
6925 "\C-c\C-i" gnus-info-find-node
6926 gnus-mouse-2 gnus-mouse-pick-article
6927 "m" gnus-summary-mail-other-window
6928 "a" gnus-summary-post-news
6929 "x" gnus-summary-limit-to-unread
6930 "s" gnus-summary-isearch-article
6931 "t" gnus-article-hide-headers
6932 "g" gnus-summary-show-article
6933 "l" gnus-summary-goto-last-article
6934 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6935 "\C-d" gnus-summary-enter-digest-group
6937 "*" gnus-cache-enter-article
6938 "\M-*" gnus-cache-remove-article
6939 "\M-&" gnus-summary-universal-argument
6940 "\C-l" gnus-recenter
6941 "I" gnus-summary-increase-score
6942 "L" gnus-summary-lower-score
6944 "V" gnus-summary-score-map
6945 "X" gnus-uu-extract-map
6946 "S" gnus-summary-send-map)
6948 ;; Sort of orthogonal keymap
6949 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6950 "t" gnus-summary-tick-article-forward
6951 "!" gnus-summary-tick-article-forward
6952 "d" gnus-summary-mark-as-read-forward
6953 "r" gnus-summary-mark-as-read-forward
6954 "c" gnus-summary-clear-mark-forward
6955 " " gnus-summary-clear-mark-forward
6956 "e" gnus-summary-mark-as-expirable
6957 "x" gnus-summary-mark-as-expirable
6958 "?" gnus-summary-mark-as-dormant
6959 "b" gnus-summary-set-bookmark
6960 "B" gnus-summary-remove-bookmark
6961 "#" gnus-summary-mark-as-processable
6962 "\M-#" gnus-summary-unmark-as-processable
6963 "S" gnus-summary-limit-include-expunged
6964 "C" gnus-summary-catchup
6965 "H" gnus-summary-catchup-to-here
6966 "\C-c" gnus-summary-catchup-all
6967 "k" gnus-summary-kill-same-subject-and-select
6968 "K" gnus-summary-kill-same-subject
6969 "P" gnus-uu-mark-map)
6971 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6972 "c" gnus-summary-clear-above
6973 "u" gnus-summary-tick-above
6974 "m" gnus-summary-mark-above
6975 "k" gnus-summary-kill-below)
6977 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6978 "/" gnus-summary-limit-to-subject
6979 "n" gnus-summary-limit-to-articles
6980 "w" gnus-summary-pop-limit
6981 "s" gnus-summary-limit-to-subject
6982 "a" gnus-summary-limit-to-author
6983 "u" gnus-summary-limit-to-unread
6984 "m" gnus-summary-limit-to-marks
6985 "v" gnus-summary-limit-to-score
6986 "D" gnus-summary-limit-include-dormant
6987 "d" gnus-summary-limit-exclude-dormant
6988 ;; "t" gnus-summary-limit-exclude-thread
6989 "E" gnus-summary-limit-include-expunged
6990 "c" gnus-summary-limit-exclude-childless-dormant
6991 "C" gnus-summary-limit-mark-excluded-as-read)
6993 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
6994 "n" gnus-summary-next-unread-article
6995 "p" gnus-summary-prev-unread-article
6996 "N" gnus-summary-next-article
6997 "P" gnus-summary-prev-article
6998 "\C-n" gnus-summary-next-same-subject
6999 "\C-p" gnus-summary-prev-same-subject
7000 "\M-n" gnus-summary-next-unread-subject
7001 "\M-p" gnus-summary-prev-unread-subject
7002 "f" gnus-summary-first-unread-article
7003 "b" gnus-summary-best-unread-article
7004 "j" gnus-summary-goto-article
7005 "g" gnus-summary-goto-subject
7006 "l" gnus-summary-goto-last-article
7007 "p" gnus-summary-pop-article)
7009 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
7010 "k" gnus-summary-kill-thread
7011 "l" gnus-summary-lower-thread
7012 "i" gnus-summary-raise-thread
7013 "T" gnus-summary-toggle-threads
7014 "t" gnus-summary-rethread-current
7015 "^" gnus-summary-reparent-thread
7016 "s" gnus-summary-show-thread
7017 "S" gnus-summary-show-all-threads
7018 "h" gnus-summary-hide-thread
7019 "H" gnus-summary-hide-all-threads
7020 "n" gnus-summary-next-thread
7021 "p" gnus-summary-prev-thread
7022 "u" gnus-summary-up-thread
7023 "o" gnus-summary-top-thread
7024 "d" gnus-summary-down-thread
7025 "#" gnus-uu-mark-thread
7026 "\M-#" gnus-uu-unmark-thread)
7028 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
7029 "c" gnus-summary-catchup-and-exit
7030 "C" gnus-summary-catchup-all-and-exit
7031 "E" gnus-summary-exit-no-update
7032 "Q" gnus-summary-exit
7033 "Z" gnus-summary-exit
7034 "n" gnus-summary-catchup-and-goto-next-group
7035 "R" gnus-summary-reselect-current-group
7036 "G" gnus-summary-rescan-group
7037 "N" gnus-summary-next-group
7038 "P" gnus-summary-prev-group)
7040 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
7041 " " gnus-summary-next-page
7042 "n" gnus-summary-next-page
7043 "\177" gnus-summary-prev-page
7044 [delete] gnus-summary-prev-page
7045 "p" gnus-summary-prev-page
7046 "\r" gnus-summary-scroll-up
7047 "<" gnus-summary-beginning-of-article
7048 ">" gnus-summary-end-of-article
7049 "b" gnus-summary-beginning-of-article
7050 "e" gnus-summary-end-of-article
7051 "^" gnus-summary-refer-parent-article
7052 "r" gnus-summary-refer-parent-article
7053 "R" gnus-summary-refer-references
7054 "g" gnus-summary-show-article
7055 "s" gnus-summary-isearch-article)
7057 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
7058 "b" gnus-article-add-buttons
7059 "B" gnus-article-add-buttons-to-head
7060 "o" gnus-article-treat-overstrike
7061 ;; "w" gnus-article-word-wrap
7062 "w" gnus-article-fill-cited-article
7063 "c" gnus-article-remove-cr
7064 "L" gnus-article-remove-trailing-blank-lines
7065 "q" gnus-article-de-quoted-unreadable
7066 "f" gnus-article-display-x-face
7067 "l" gnus-summary-stop-page-breaking
7068 "r" gnus-summary-caesar-message
7069 "t" gnus-article-hide-headers
7070 "v" gnus-summary-verbose-headers
7071 "m" gnus-summary-toggle-mime)
7073 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
7074 "a" gnus-article-hide
7075 "h" gnus-article-hide-headers
7076 "b" gnus-article-hide-boring-headers
7077 "s" gnus-article-hide-signature
7078 "c" gnus-article-hide-citation
7079 "p" gnus-article-hide-pgp
7080 "\C-c" gnus-article-hide-citation-maybe)
7082 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
7083 "a" gnus-article-highlight
7084 "h" gnus-article-highlight-headers
7085 "c" gnus-article-highlight-citation
7086 "s" gnus-article-highlight-signature)
7088 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
7089 "z" gnus-article-date-ut
7090 "u" gnus-article-date-ut
7091 "l" gnus-article-date-local
7092 "e" gnus-article-date-lapsed
7093 "o" gnus-article-date-original)
7095 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
7097 "f" gnus-summary-fetch-faq
7098 "d" gnus-summary-describe-group
7099 "h" gnus-summary-describe-briefly
7100 "i" gnus-info-find-node)
7102 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
7103 "e" gnus-summary-expire-articles
7104 "\M-\C-e" gnus-summary-expire-articles-now
7105 "\177" gnus-summary-delete-article
7106 [delete] gnus-summary-delete-article
7107 "m" gnus-summary-move-article
7108 "r" gnus-summary-respool-article
7109 "w" gnus-summary-edit-article
7110 "c" gnus-summary-copy-article
7111 "B" gnus-summary-crosspost-article
7112 "q" gnus-summary-respool-query
7113 "i" gnus-summary-import-article)
7115 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
7116 "o" gnus-summary-save-article
7117 "m" gnus-summary-save-article-mail
7118 "r" gnus-summary-save-article-rmail
7119 "f" gnus-summary-save-article-file
7120 "b" gnus-summary-save-article-body-file
7121 "h" gnus-summary-save-article-folder
7122 "v" gnus-summary-save-article-vm
7123 "p" gnus-summary-pipe-output
7124 "s" gnus-soup-add-article)
7129 (defun gnus-summary-mode (&optional group)
7130 "Major mode for reading articles.
7132 All normal editing commands are switched off.
7133 \\<gnus-summary-mode-map>
7134 Each line in this buffer represents one article. To read an
7135 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
7136 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7139 You can also post articles and send mail from this buffer. To
7140 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7141 of an article, type `\\[gnus-summary-reply]'.
7143 There are approx. one gazillion commands you can execute in this
7144 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7146 The following commands are available:
7148 \\{gnus-summary-mode-map}"
7150 (when (and menu-bar-mode
7151 (gnus-visual-p 'summary-menu 'menu))
7152 (gnus-summary-make-menu-bar))
7153 (kill-all-local-variables)
7154 (gnus-summary-make-local-variables)
7155 (gnus-make-thread-indent-array)
7156 (gnus-simplify-mode-line)
7157 (setq major-mode 'gnus-summary-mode)
7158 (setq mode-name "Summary")
7159 (make-local-variable 'minor-mode-alist)
7160 (use-local-map gnus-summary-mode-map)
7161 (buffer-disable-undo (current-buffer))
7162 (setq buffer-read-only t) ;Disable modification
7163 (setq truncate-lines t)
7164 (setq selective-display t)
7165 (setq selective-display-ellipses t) ;Display `...'
7166 (setq buffer-display-table gnus-summary-display-table)
7167 (setq gnus-newsgroup-name group)
7168 (make-local-variable 'gnus-summary-line-format)
7169 (make-local-variable 'gnus-summary-line-format-spec)
7170 (make-local-variable 'gnus-summary-mark-positions)
7171 (run-hooks 'gnus-summary-mode-hook))
7173 (defun gnus-summary-make-local-variables ()
7174 "Make all the local summary buffer variables."
7175 (let ((locals gnus-summary-local-variables)
7177 (while (setq local (pop locals))
7180 (if (eq (cdr local) 'global)
7181 ;; Copy the global value of the variable.
7182 (setq global (symbol-value (car local)))
7183 ;; Use the value from the list.
7184 (setq global (eval (cdr local))))
7185 (make-local-variable (car local))
7186 (set (car local) global))
7187 ;; Simple nil-valued local variable.
7188 (make-local-variable local)
7191 (defun gnus-summary-make-display-table ()
7192 ;; Change the display table. Odd characters have a tendency to mess
7193 ;; up nicely formatted displays - we make all possible glyphs
7194 ;; display only a single character.
7196 ;; We start from the standard display table, if any.
7197 (setq gnus-summary-display-table
7198 (or (copy-sequence standard-display-table)
7199 (make-display-table)))
7200 ;; Nix out all the control chars...
7202 (while (>= (setq i (1- i)) 0)
7203 (aset gnus-summary-display-table i [??])))
7204 ;; ... but not newline and cr, of course. (cr is necessary for the
7205 ;; selective display).
7206 (aset gnus-summary-display-table ?\n nil)
7207 (aset gnus-summary-display-table ?\r nil)
7208 ;; We nix out any glyphs over 126 that are not set already.
7210 (while (>= (setq i (1- i)) 127)
7211 ;; Only modify if the entry is nil.
7212 (or (aref gnus-summary-display-table i)
7213 (aset gnus-summary-display-table i [??])))))
7215 (defun gnus-summary-clear-local-variables ()
7216 (let ((locals gnus-summary-local-variables))
7218 (if (consp (car locals))
7219 (and (vectorp (caar locals))
7220 (set (caar locals) nil))
7221 (and (vectorp (car locals))
7222 (set (car locals) nil)))
7223 (setq locals (cdr locals)))))
7225 ;; Summary data functions.
7227 (defmacro gnus-data-number (data)
7230 (defmacro gnus-data-set-number (data number)
7231 `(setcar ,data ,number))
7233 (defmacro gnus-data-mark (data)
7236 (defmacro gnus-data-set-mark (data mark)
7237 `(setcar (nthcdr 1 ,data) ,mark))
7239 (defmacro gnus-data-pos (data)
7242 (defmacro gnus-data-set-pos (data pos)
7243 `(setcar (nthcdr 2 ,data) ,pos))
7245 (defmacro gnus-data-header (data)
7248 (defmacro gnus-data-level (data)
7251 (defmacro gnus-data-unread-p (data)
7252 `(= (nth 1 ,data) gnus-unread-mark))
7254 (defmacro gnus-data-pseudo-p (data)
7255 `(consp (nth 3 ,data)))
7257 (defmacro gnus-data-find (number)
7258 `(assq ,number gnus-newsgroup-data))
7260 (defmacro gnus-data-find-list (number &optional data)
7261 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7262 (memq (assq ,number bdata)
7265 (defmacro gnus-data-make (number mark pos header level)
7266 `(list ,number ,mark ,pos ,header ,level))
7268 (defun gnus-data-enter (after-article number mark pos header level offset)
7269 (let ((data (gnus-data-find-list after-article)))
7270 (or data (error "No such article: %d" after-article))
7271 (setcdr data (cons (gnus-data-make number mark pos header level)
7273 (setq gnus-newsgroup-data-reverse nil)
7274 (gnus-data-update-list (cddr data) offset)))
7276 (defun gnus-data-enter-list (after-article list &optional offset)
7278 (let ((data (and after-article (gnus-data-find-list after-article)))
7280 (or data (not after-article) (error "No such article: %d" after-article))
7281 ;; Find the last element in the list to be spliced into the main
7284 (setq list (cdr list)))
7287 (setcdr list gnus-newsgroup-data)
7288 (setq gnus-newsgroup-data ilist)
7289 (and offset (gnus-data-update-list (cdr list) offset)))
7290 (setcdr list (cdr data))
7292 (and offset (gnus-data-update-list (cdr data) offset)))
7293 (setq gnus-newsgroup-data-reverse nil))))
7295 (defun gnus-data-remove (article &optional offset)
7296 (let ((data gnus-newsgroup-data))
7297 (if (= (gnus-data-number (car data)) article)
7298 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7299 gnus-newsgroup-data-reverse nil)
7301 (and (= (gnus-data-number (cadr data)) article)
7303 (setcdr data (cddr data))
7304 (and offset (gnus-data-update-list (cdr data) offset))
7306 gnus-newsgroup-data-reverse nil)))
7307 (setq data (cdr data))))))
7309 (defmacro gnus-data-list (backward)
7311 (or gnus-newsgroup-data-reverse
7312 (setq gnus-newsgroup-data-reverse
7313 (reverse gnus-newsgroup-data)))
7314 gnus-newsgroup-data))
7316 (defun gnus-data-update-list (data offset)
7317 "Add OFFSET to the POS of all data entries in DATA."
7319 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7320 (setq data (cdr data))))
7322 (defun gnus-data-compute-positions ()
7323 "Compute the positions of all articles."
7324 (let ((data gnus-newsgroup-data)
7327 (when (setq pos (text-property-any
7328 (point-min) (point-max)
7329 'gnus-number (gnus-data-number (car data))))
7330 (gnus-data-set-pos (car data) (+ pos 3)))
7331 (setq data (cdr data)))))
7333 (defun gnus-summary-article-pseudo-p (article)
7334 "Say whether this article is a pseudo article or not."
7335 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7337 (defun gnus-article-parent-p (number)
7338 "Say whether this article is a parent or not."
7339 (let ((data (gnus-data-find-list number)))
7340 (and (cdr data) ; There has to be an article after...
7341 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7342 (gnus-data-level (nth 1 data))))))
7344 (defun gnus-article-children (number)
7345 "Return a list of all children to NUMBER."
7346 (let* ((data (gnus-data-find-list number))
7347 (level (gnus-data-level (car data)))
7349 (setq data (cdr data))
7351 (= (gnus-data-level (car data)) (1+ level)))
7352 (push (gnus-data-number (car data)) children)
7353 (setq data (cdr data)))
7356 (defmacro gnus-summary-skip-intangible ()
7357 "If the current article is intangible, then jump to a different article."
7358 '(let ((to (get-text-property (point) 'gnus-intangible)))
7359 (and to (gnus-summary-goto-subject to))))
7361 (defmacro gnus-summary-article-intangible-p ()
7362 "Say whether this article is intangible or not."
7363 '(get-text-property (point) 'gnus-intangible))
7365 ;; Some summary mode macros.
7367 (defmacro gnus-summary-article-number ()
7368 "The article number of the article on the current line.
7369 If there isn's an article number here, then we return the current
7372 (gnus-summary-skip-intangible)
7373 (or (get-text-property (point) 'gnus-number)
7374 (gnus-summary-last-subject))))
7376 (defmacro gnus-summary-article-header (&optional number)
7377 `(gnus-data-header (gnus-data-find
7378 ,(or number '(gnus-summary-article-number)))))
7380 (defmacro gnus-summary-thread-level (&optional number)
7381 `(if (and (eq gnus-summary-make-false-root 'dummy)
7382 (get-text-property (point) 'gnus-intangible))
7384 (gnus-data-level (gnus-data-find
7385 ,(or number '(gnus-summary-article-number))))))
7387 (defmacro gnus-summary-article-mark (&optional number)
7388 `(gnus-data-mark (gnus-data-find
7389 ,(or number '(gnus-summary-article-number)))))
7391 (defmacro gnus-summary-article-pos (&optional number)
7392 `(gnus-data-pos (gnus-data-find
7393 ,(or number '(gnus-summary-article-number)))))
7395 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7396 (defmacro gnus-summary-article-subject (&optional number)
7397 "Return current subject string or nil if nothing."
7400 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7401 '(gnus-data-header (assq (gnus-summary-article-number)
7402 gnus-newsgroup-data)))))
7405 (mail-header-subject headers))))
7407 (defmacro gnus-summary-article-score (&optional number)
7408 "Return current article score."
7409 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7410 gnus-newsgroup-scored))
7411 gnus-summary-default-score 0))
7413 (defun gnus-summary-article-children (&optional number)
7414 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7415 (level (gnus-data-level (car data)))
7417 (while (and (setq data (cdr data))
7418 (> (setq l (gnus-data-level (car data))) level))
7419 (and (= (1+ level) l)
7420 (setq children (cons (gnus-data-number (car data))
7422 (nreverse children)))
7424 (defun gnus-summary-article-parent (&optional number)
7425 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7426 (gnus-data-list t)))
7427 (level (gnus-data-level (car data))))
7429 () ; This is a root.
7430 ;; We search until we find an article with a level less than
7431 ;; this one. That function has to be the parent.
7432 (while (and (setq data (cdr data))
7433 (not (< (gnus-data-level (car data)) level))))
7434 (and data (gnus-data-number (car data))))))
7436 (defun gnus-unread-mark-p (mark)
7437 "Say whether MARK is the unread mark."
7438 (= mark gnus-unread-mark))
7440 (defun gnus-read-mark-p (mark)
7441 "Say whether MARK is one of the marks that mark as read.
7442 This is all marks except unread, ticked, dormant, and expirable."
7443 (not (or (= mark gnus-unread-mark)
7444 (= mark gnus-ticked-mark)
7445 (= mark gnus-dormant-mark)
7446 (= mark gnus-expirable-mark))))
7448 ;; Saving hidden threads.
7450 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
7451 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
7452 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
7454 (defmacro gnus-save-hidden-threads (&rest forms)
7455 "Save hidden threads, eval FORMS, and restore the hidden threads."
7456 (let ((config (make-symbol "config")))
7457 `(let ((,config (gnus-hidden-threads-configuration)))
7461 (gnus-restore-hidden-threads-configuration ,config)))))
7463 (defun gnus-hidden-threads-configuration ()
7464 "Return the current hidden threads configuration."
7467 (goto-char (point-min))
7468 (while (search-forward "\r" nil t)
7469 (push (1- (point)) config))
7472 (defun gnus-restore-hidden-threads-configuration (config)
7473 "Restore hidden threads configuration from CONFIG."
7474 (let (point buffer-read-only)
7475 (while (setq point (pop config))
7476 (when (and (< point (point-max))
7478 (= (following-char) ?\n))
7479 (subst-char-in-region point (1+ point) ?\n ?\r)))))
7481 ;; Various summary mode internalish functions.
7483 (defun gnus-mouse-pick-article (e)
7486 (gnus-summary-next-page nil t))
7488 (defun gnus-summary-setup-buffer (group)
7489 "Initialize summary buffer."
7490 (let ((buffer (concat "*Summary " group "*")))
7491 (if (get-buffer buffer)
7494 (setq gnus-summary-buffer (current-buffer))
7495 (not gnus-newsgroup-prepared))
7496 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7497 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7498 (gnus-add-current-to-buffer-list)
7499 (gnus-summary-mode group)
7501 (gnus-carpal-setup-buffer 'summary))
7502 (unless gnus-single-article-buffer
7503 (make-local-variable 'gnus-article-buffer)
7504 (make-local-variable 'gnus-article-current)
7505 (make-local-variable 'gnus-original-article-buffer))
7506 (setq gnus-newsgroup-name group)
7509 (defun gnus-set-global-variables ()
7510 ;; Set the global equivalents of the summary buffer-local variables
7511 ;; to the latest values they had. These reflect the summary buffer
7512 ;; that was in action when the last article was fetched.
7513 (when (eq major-mode 'gnus-summary-mode)
7514 (setq gnus-summary-buffer (current-buffer))
7515 (let ((name gnus-newsgroup-name)
7516 (marked gnus-newsgroup-marked)
7517 (unread gnus-newsgroup-unreads)
7518 (headers gnus-current-headers)
7519 (data gnus-newsgroup-data)
7520 (summary gnus-summary-buffer)
7521 (article-buffer gnus-article-buffer)
7522 (original gnus-original-article-buffer)
7523 (gac gnus-article-current)
7524 (score-file gnus-current-score-file))
7526 (set-buffer gnus-group-buffer)
7527 (setq gnus-newsgroup-name name)
7528 (setq gnus-newsgroup-marked marked)
7529 (setq gnus-newsgroup-unreads unread)
7530 (setq gnus-current-headers headers)
7531 (setq gnus-newsgroup-data data)
7532 (setq gnus-article-current gac)
7533 (setq gnus-summary-buffer summary)
7534 (setq gnus-article-buffer article-buffer)
7535 (setq gnus-original-article-buffer original)
7536 (setq gnus-current-score-file score-file)))))
7538 (defun gnus-summary-last-article-p (&optional article)
7539 "Return whether ARTICLE is the last article in the buffer."
7540 (if (not (setq article (or article (gnus-summary-article-number))))
7541 t ; All non-existant numbers are the last article. :-)
7542 (not (cdr (gnus-data-find-list article)))))
7544 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7545 "Insert a dummy root in the summary buffer."
7547 (gnus-add-text-properties
7548 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7549 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7551 (defun gnus-make-thread-indent-array ()
7553 (unless (and gnus-thread-indent-array
7554 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7555 (setq gnus-thread-indent-array (make-vector 201 "")
7556 gnus-thread-indent-array-level gnus-thread-indent-level)
7558 (aset gnus-thread-indent-array n
7559 (make-string (* n gnus-thread-indent-level) ? ))
7562 (defun gnus-summary-insert-line
7563 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7564 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7565 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7566 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7567 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7568 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7569 (gnus-tmp-score-char
7570 (if (or (null gnus-summary-default-score)
7571 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7572 gnus-summary-zcore-fuzz)) ?
7573 (if (< gnus-tmp-score gnus-summary-default-score)
7574 gnus-score-below-mark gnus-score-over-mark)))
7575 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7576 ((memq gnus-tmp-current gnus-newsgroup-cached)
7578 (gnus-tmp-replied gnus-replied-mark)
7579 ((memq gnus-tmp-current gnus-newsgroup-saved)
7581 (t gnus-unread-mark)))
7582 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7585 ((string-match "(.+)" gnus-tmp-from)
7586 (substring gnus-tmp-from
7587 (1+ (match-beginning 0)) (1- (match-end 0))))
7588 ((string-match "<[^>]+> *$" gnus-tmp-from)
7589 (let ((beg (match-beginning 0)))
7590 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7591 (substring gnus-tmp-from (1+ (match-beginning 0))
7592 (1- (match-end 0))))
7593 (substring gnus-tmp-from 0 beg))))
7595 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7596 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7597 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7598 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7599 (buffer-read-only nil))
7600 (when (string= gnus-tmp-name "")
7601 (setq gnus-tmp-name gnus-tmp-from))
7602 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7603 (gnus-put-text-property
7605 (progn (eval gnus-summary-line-format-spec) (point))
7606 'gnus-number gnus-tmp-number)
7607 (when (gnus-visual-p 'summary-highlight 'highlight)
7609 (run-hooks 'gnus-summary-update-hook)
7612 (defun gnus-summary-update-line (&optional dont-update)
7613 ;; Update summary line after change.
7614 (when (and gnus-summary-default-score
7615 (not gnus-summary-inhibit-highlight))
7616 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7617 (article (gnus-summary-article-number))
7618 (score (gnus-summary-article-score article)))
7620 (if (and gnus-summary-mark-below
7621 (< (gnus-summary-article-score)
7622 gnus-summary-mark-below))
7623 ;; This article has a low score, so we mark it as read.
7624 (when (memq article gnus-newsgroup-unreads)
7625 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7626 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7627 ;; This article was previously marked as read on account
7628 ;; of a low score, but now it has risen, so we mark it as
7630 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7631 (gnus-summary-update-mark
7632 (if (or (null gnus-summary-default-score)
7633 (<= (abs (- score gnus-summary-default-score))
7634 gnus-summary-zcore-fuzz)) ?
7635 (if (< score gnus-summary-default-score)
7636 gnus-score-below-mark gnus-score-over-mark)) 'score))
7637 ;; Do visual highlighting.
7638 (when (gnus-visual-p 'summary-highlight 'highlight)
7639 (run-hooks 'gnus-summary-update-hook)))))
7641 (defvar gnus-tmp-new-adopts nil)
7643 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7644 ;; Sum up all elements (and sub-elements) in a list.
7646 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7648 ((and (consp thread) (cdr thread))
7651 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7654 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7657 (when (and level (zerop level) gnus-tmp-new-adopts)
7660 'gnus-summary-number-of-articles-in-thread
7661 gnus-tmp-new-adopts))))
7663 (if (> number 1) gnus-not-empty-thread-mark
7664 gnus-empty-thread-mark)
7667 (defun gnus-summary-set-local-parameters (group)
7668 "Go through the local params of GROUP and set all variable specs in that list."
7669 (let ((params (gnus-info-params (gnus-get-info group)))
7672 (setq elem (car params)
7673 params (cdr params))
7674 (and (consp elem) ; Has to be a cons.
7675 (consp (cdr elem)) ; The cdr has to be a list.
7676 (symbolp (car elem)) ; Has to be a symbol in there.
7677 (not (memq (car elem)
7678 '(quit-config to-address to-list to-group)))
7679 (progn ; So we set it.
7680 (make-local-variable (car elem))
7681 (set (car elem) (eval (nth 1 elem))))))))
7683 (defun gnus-summary-read-group (group &optional show-all no-article
7684 kill-buffer no-display)
7685 "Start reading news in newsgroup GROUP.
7686 If SHOW-ALL is non-nil, already read articles are also listed.
7687 If NO-ARTICLE is non-nil, no article is selected initially.
7688 If NO-DISPLAY, don't generate a summary buffer."
7689 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7690 (let* ((new-group (gnus-summary-setup-buffer group))
7691 (quit-config (gnus-group-quit-config group))
7692 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7694 ;; This summary buffer exists already, so we just select it.
7696 (gnus-set-global-variables)
7698 (gnus-kill-or-deaden-summary kill-buffer))
7699 (gnus-configure-windows 'summary 'force)
7700 (gnus-set-mode-line 'summary)
7701 (gnus-summary-position-point)
7704 ;; We couldn't select this group.
7706 (when (and (eq major-mode 'gnus-summary-mode)
7707 (not (equal (current-buffer) kill-buffer)))
7708 (kill-buffer (current-buffer))
7709 (if (not quit-config)
7711 (set-buffer gnus-group-buffer)
7712 (gnus-group-jump-to-group group)
7713 (gnus-group-next-unread-group 1))
7714 (if (not (buffer-name (car quit-config)))
7715 (gnus-configure-windows 'group 'force)
7716 (set-buffer (car quit-config))
7717 (and (eq major-mode 'gnus-summary-mode)
7718 (gnus-set-global-variables))
7719 (gnus-configure-windows (cdr quit-config)))))
7720 (gnus-message 3 "Can't select group")
7722 ;; The user did a `C-g' while prompting for number of articles,
7723 ;; so we exit this group.
7724 ((eq did-select 'quit)
7725 (and (eq major-mode 'gnus-summary-mode)
7726 (not (equal (current-buffer) kill-buffer))
7727 (kill-buffer (current-buffer)))
7729 (gnus-kill-or-deaden-summary kill-buffer))
7730 (if (not quit-config)
7732 (set-buffer gnus-group-buffer)
7733 (gnus-group-jump-to-group group)
7734 (gnus-group-next-unread-group 1)
7735 (gnus-configure-windows 'group 'force))
7736 (if (not (buffer-name (car quit-config)))
7737 (gnus-configure-windows 'group 'force)
7738 (set-buffer (car quit-config))
7739 (and (eq major-mode 'gnus-summary-mode)
7740 (gnus-set-global-variables))
7741 (gnus-configure-windows (cdr quit-config))))
7742 ;; Finally signal the quit.
7744 ;; The group was successfully selected.
7746 (gnus-set-global-variables)
7747 ;; Save the active value in effect when the group was entered.
7748 (setq gnus-newsgroup-active
7750 (gnus-active gnus-newsgroup-name)))
7751 ;; You can change the summary buffer in some way with this hook.
7752 (run-hooks 'gnus-select-group-hook)
7753 ;; Set any local variables in the group parameters.
7754 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7755 (gnus-update-format-specifications)
7756 ;; Do score processing.
7757 (when gnus-use-scoring
7758 (gnus-possibly-score-headers))
7759 ;; Check whether to fill in the gaps in the threads.
7760 (when gnus-build-sparse-threads
7761 (gnus-build-sparse-threads))
7762 ;; Find the initial limit.
7763 (if gnus-show-threads
7765 (let ((gnus-newsgroup-dormant nil))
7766 (gnus-summary-initial-limit show-all))
7767 (gnus-summary-initial-limit show-all))
7768 (setq gnus-newsgroup-limit
7770 (lambda (header) (mail-header-number header))
7771 gnus-newsgroup-headers)))
7772 ;; Generate the summary buffer.
7774 (gnus-summary-prepare))
7775 (when gnus-use-trees
7776 (gnus-tree-open group)
7777 (setq gnus-summary-highlight-line-function
7778 'gnus-tree-highlight-article))
7779 ;; If the summary buffer is empty, but there are some low-scored
7780 ;; articles or some excluded dormants, we include these in the
7782 (when (and (zerop (buffer-size))
7784 (cond (gnus-newsgroup-dormant
7785 (gnus-summary-limit-include-dormant))
7786 ((and gnus-newsgroup-scored show-all)
7787 (gnus-summary-limit-include-expunged))))
7788 ;; Function `gnus-apply-kill-file' must be called in this hook.
7789 (run-hooks 'gnus-apply-kill-hook)
7790 (if (and (zerop (buffer-size))
7793 ;; This newsgroup is empty.
7794 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7795 (gnus-message 6 "No unread news")
7797 (gnus-kill-or-deaden-summary kill-buffer))
7798 ;; Return nil from this function.
7800 ;; Hide conversation thread subtrees. We cannot do this in
7801 ;; gnus-summary-prepare-hook since kill processing may not
7802 ;; work with hidden articles.
7803 (and gnus-show-threads
7804 gnus-thread-hide-subtree
7805 (gnus-summary-hide-all-threads))
7806 ;; Show first unread article if requested.
7807 (if (and (not no-article)
7809 gnus-newsgroup-unreads
7810 gnus-auto-select-first)
7811 (unless (if (eq gnus-auto-select-first 'best)
7812 (gnus-summary-best-unread-article)
7813 (gnus-summary-first-unread-article))
7814 (gnus-configure-windows 'summary))
7815 ;; Don't select any articles, just move point to the first
7816 ;; article in the group.
7817 (goto-char (point-min))
7818 (gnus-summary-position-point)
7819 (gnus-set-mode-line 'summary)
7820 (gnus-configure-windows 'summary 'force))
7821 ;; If we are in async mode, we send some info to the backend.
7822 (when gnus-newsgroup-async
7823 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7825 (gnus-kill-or-deaden-summary kill-buffer))
7826 (when (get-buffer-window gnus-group-buffer t)
7827 ;; Gotta use windows, because recenter does wierd stuff if
7828 ;; the current buffer ain't the displayed window.
7829 (let ((owin (selected-window)))
7830 (select-window (get-buffer-window gnus-group-buffer t))
7831 (when (gnus-group-goto-group group)
7833 (select-window owin))))
7834 ;; Mark this buffer as "prepared".
7835 (setq gnus-newsgroup-prepared t)
7838 (defun gnus-summary-prepare ()
7839 "Generate the summary buffer."
7840 (let ((buffer-read-only nil))
7842 (setq gnus-newsgroup-data nil
7843 gnus-newsgroup-data-reverse nil)
7844 (run-hooks 'gnus-summary-generate-hook)
7845 ;; Generate the buffer, either with threads or without.
7846 (when gnus-newsgroup-headers
7847 (gnus-summary-prepare-threads
7848 (if gnus-show-threads
7849 (gnus-sort-gathered-threads
7850 (funcall gnus-summary-thread-gathering-function
7852 (gnus-cut-threads (gnus-make-threads)))))
7853 ;; Unthreaded display.
7854 (gnus-sort-articles gnus-newsgroup-headers))))
7855 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7856 ;; Call hooks for modifying summary buffer.
7857 (goto-char (point-min))
7858 (run-hooks 'gnus-summary-prepare-hook)))
7860 (defun gnus-gather-threads-by-subject (threads)
7861 "Gather threads by looking at Subject headers."
7862 (if (not gnus-summary-make-false-root)
7864 (let ((hashtb (gnus-make-hashtable 1023))
7867 subject hthread whole-subject)
7869 (setq whole-subject (mail-header-subject (caar threads)))
7872 ;; Truncate the subject.
7873 ((numberp gnus-summary-gather-subject-limit)
7874 (setq subject (gnus-simplify-subject-re whole-subject))
7875 (if (> (length subject) gnus-summary-gather-subject-limit)
7876 (substring subject 0 gnus-summary-gather-subject-limit)
7878 ;; Fuzzily simplify it.
7879 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7880 (gnus-simplify-subject-fuzzy whole-subject))
7881 ;; Just remove the leading "Re:".
7883 (gnus-simplify-subject-re whole-subject))))
7885 (if (and gnus-summary-gather-exclude-subject
7886 (string-match gnus-summary-gather-exclude-subject
7888 () ; We don't want to do anything with this article.
7889 ;; We simplify the subject before looking it up in the
7892 (if (setq hthread (gnus-gethash subject hashtb))
7894 ;; We enter a dummy root into the thread, if we
7895 ;; haven't done that already.
7896 (unless (stringp (caar hthread))
7897 (setcar hthread (list whole-subject (car hthread))))
7898 ;; We add this new gathered thread to this gathered
7900 (setcdr (car hthread)
7901 (nconc (cdar hthread) (list (car threads))))
7902 ;; Remove it from the list of threads.
7903 (setcdr prev (cdr threads))
7904 (setq threads prev))
7905 ;; Enter this thread into the hash table.
7906 (gnus-sethash subject threads hashtb)))
7908 (setq threads (cdr threads)))
7911 (defun gnus-gather-threads-by-references (threads)
7912 "Gather threads by looking at References headers."
7913 (let ((idhashtb (gnus-make-hashtable 1023))
7914 (thhashtb (gnus-make-hashtable 1023))
7917 ids references id gthread gid entered)
7919 (when (setq references (mail-header-references (caar threads)))
7920 (setq id (mail-header-id (caar threads)))
7921 (setq ids (gnus-split-references references))
7924 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7926 (gnus-sethash (car ids) id idhashtb)
7927 (gnus-sethash id threads thhashtb))
7928 (setq gthread (gnus-gethash gid thhashtb))
7930 ;; We enter a dummy root into the thread, if we
7931 ;; haven't done that already.
7932 (unless (stringp (caar gthread))
7933 (setcar gthread (list (mail-header-subject (caar gthread))
7935 ;; We add this new gathered thread to this gathered
7937 (setcdr (car gthread)
7938 (nconc (cdar gthread) (list (car threads)))))
7939 ;; Add it into the thread hash table.
7940 (gnus-sethash id gthread thhashtb)
7942 ;; Remove it from the list of threads.
7943 (setcdr prev (cdr threads))
7944 (setq threads prev))
7945 (setq ids (cdr ids))))
7947 (setq threads (cdr threads)))
7950 (defun gnus-sort-gathered-threads (threads)
7951 "Sort subtreads inside each gathered thread by article number."
7952 (let ((result threads))
7954 (when (stringp (caar threads))
7955 (setcdr (car threads)
7956 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7957 (setq threads (cdr threads)))
7960 (defun gnus-make-threads ()
7961 "Go through the dependency hashtb and find the roots. Return all threads."
7965 (unless (car (symbol-value refs))
7966 ;; These threads do not refer back to any other articles,
7967 ;; so they're roots.
7968 (setq threads (append (cdr (symbol-value refs)) threads))))
7969 gnus-newsgroup-dependencies)
7972 (defun gnus-build-sparse-threads ()
7973 (let ((headers gnus-newsgroup-headers)
7974 (deps gnus-newsgroup-dependencies)
7975 header references generation relations
7976 cthread subject child end pthread relation)
7977 ;; First we create an alist of generations/relations, where
7978 ;; generations is how much we trust the ralation, and the relation
7980 (gnus-message 7 "Making sparse threads...")
7982 (nnheader-set-temp-buffer " *gnus sparse threads*")
7983 (while (setq header (pop headers))
7984 (when (and (setq references (mail-header-references header))
7985 (not (string= references "")))
7987 (setq child (mail-header-id header)
7988 subject (mail-header-subject header))
7990 (while (search-backward ">" nil t)
7991 (setq end (1+ (point)))
7992 (when (search-backward "<" nil t)
7993 (push (list (incf generation)
7994 child (setq child (buffer-substring (point) end))
7997 (push (list (1+ generation) child nil subject) relations)
7999 (kill-buffer (current-buffer)))
8000 ;; Sort over trustworthiness.
8001 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
8002 (while (setq relation (pop relations))
8003 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
8004 (unless (car (symbol-value cthread))
8005 ;; Make this article the parent of these threads.
8006 (setcar (symbol-value cthread)
8007 (vector gnus-reffed-article-number
8011 (or (caddr relation) "") 0 0 "")))
8012 (set cthread (list (vector gnus-reffed-article-number
8014 "" "" (cadr relation)
8015 (or (caddr relation) "") 0 0 ""))))
8016 (push gnus-reffed-article-number gnus-newsgroup-limit)
8017 (push gnus-reffed-article-number gnus-newsgroup-sparse)
8018 (push (cons gnus-reffed-article-number gnus-sparse-mark)
8019 gnus-newsgroup-reads)
8020 (decf gnus-reffed-article-number)
8021 ;; Make this new thread the child of its parent.
8022 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
8023 (setcdr (symbol-value pthread)
8024 (nconc (cdr (symbol-value pthread))
8025 (list (symbol-value cthread))))
8026 (set pthread (list nil (symbol-value cthread))))))
8027 (gnus-message 7 "Making sparse threads...done")))
8029 (defun gnus-build-old-threads ()
8030 ;; Look at all the articles that refer back to old articles, and
8031 ;; fetch the headers for the articles that aren't there. This will
8032 ;; build complete threads - if the roots haven't been expired by the
8037 (when (not (car (symbol-value refs)))
8038 (setq heads (cdr (symbol-value refs)))
8040 (if (memq (mail-header-number (caar heads))
8041 gnus-newsgroup-dormant)
8042 (setq heads (cdr heads))
8043 (setq id (symbol-name refs))
8044 (while (and (setq id (gnus-build-get-header id))
8045 (not (car (gnus-gethash
8046 id gnus-newsgroup-dependencies)))))
8047 (setq heads nil)))))
8048 gnus-newsgroup-dependencies)))
8050 (defun gnus-build-get-header (id)
8051 ;; Look through the buffer of NOV lines and find the header to
8052 ;; ID. Enter this line into the dependencies hash table, and return
8053 ;; the id of the parent article (if any).
8054 (let ((deps gnus-newsgroup-dependencies)
8058 (set-buffer nntp-server-buffer)
8059 (goto-char (point-min))
8060 (while (and (not found) (search-forward id nil t))
8062 (setq found (looking-at
8063 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
8064 (regexp-quote id))))
8065 (or found (beginning-of-line 2)))
8069 (setq header (gnus-nov-parse-line
8070 (read (current-buffer)) deps))
8071 (gnus-parent-id (mail-header-references header)))))
8073 (let ((number (mail-header-number header)))
8074 (push number gnus-newsgroup-limit)
8075 (push header gnus-newsgroup-headers)
8076 (if (memq number gnus-newsgroup-unselected)
8078 (push number gnus-newsgroup-unreads)
8079 (setq gnus-newsgroup-unselected
8080 (delq number gnus-newsgroup-unselected)))
8081 (push number gnus-newsgroup-ancient)))))))
8083 (defun gnus-summary-update-article (article &optional iheader)
8084 "Update ARTICLE in the summary buffer."
8085 (set-buffer gnus-summary-buffer)
8086 (let* ((header (or iheader (gnus-summary-article-header article)))
8087 (id (mail-header-id header))
8088 (data (gnus-data-find article))
8089 (thread (gnus-id-to-thread id))
8090 (references (mail-header-references header))
8095 (not (equal "" references)))
8098 (buffer-read-only nil)
8100 (number (mail-header-number header))
8103 ;; !!! Should this be in or not?
8105 (setcar thread nil))
8107 (delq thread parent))
8108 (if (gnus-summary-insert-subject id header iheader)
8109 ;; Set the (possibly) new article number in the data structure.
8110 (gnus-data-set-number data (gnus-id-to-article id))
8114 (defun gnus-rebuild-thread (id)
8115 "Rebuild the thread containing ID."
8116 (let ((buffer-read-only nil)
8117 current thread data)
8118 (if (not gnus-show-threads)
8119 (setq thread (list (car (gnus-id-to-thread id))))
8120 ;; Get the thread this article is part of.
8121 (setq thread (gnus-remove-thread id)))
8122 (setq current (save-excursion
8123 (and (zerop (forward-line -1))
8124 (gnus-summary-article-number))))
8125 ;; If this is a gathered thread, we have to go some re-gathering.
8126 (when (stringp (car thread))
8127 (let ((subject (car thread))
8129 (setq thread (cdr thread))
8131 (unless (memq (setq thr (gnus-id-to-thread
8133 (mail-header-id (caar thread)))))
8136 (setq thread (cdr thread)))
8137 ;; We now have all (unique) roots.
8138 (if (= (length roots) 1)
8139 ;; All the loose roots are now one solid root.
8140 (setq thread (car roots))
8141 (setq thread (cons subject (gnus-sort-threads roots))))))
8143 ;; We then insert this thread into the summary buffer.
8144 (let (gnus-newsgroup-data gnus-newsgroup-threads)
8145 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
8146 (setq data (nreverse gnus-newsgroup-data))
8147 (setq threads gnus-newsgroup-threads))
8148 ;; We splice the new data into the data structure.
8149 (gnus-data-enter-list current data)
8150 (gnus-data-compute-positions)
8151 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
8153 (defun gnus-id-to-thread (id)
8154 "Return the (sub-)thread where ID appears."
8155 (gnus-gethash id gnus-newsgroup-dependencies))
8157 (defun gnus-id-to-article (id)
8158 "Return the article number of ID."
8159 (let ((thread (gnus-id-to-thread id)))
8162 (mail-header-number (car thread)))))
8164 (defun gnus-id-to-header (id)
8165 "Return the article headers of ID."
8166 (car (gnus-id-to-thread id)))
8168 (defun gnus-article-displayed-root-p (article)
8169 "Say whether ARTICLE is a root(ish) article."
8170 (let ((level (gnus-summary-thread-level article))
8171 (refs (mail-header-references (gnus-summary-article-header article)))
8177 ((null (gnus-parent-id refs)) t)
8179 (null (setq particle (gnus-id-to-article
8180 (gnus-parent-id refs))))
8181 (null (gnus-summary-thread-level particle)))))))
8183 (defun gnus-root-id (id)
8184 "Return the id of the root of the thread where ID appears."
8186 (while (and id (setq prev (car (gnus-gethash
8187 id gnus-newsgroup-dependencies))))
8189 id (gnus-parent-id (mail-header-references prev))))
8192 (defun gnus-remove-thread (id &optional dont-remove)
8193 "Remove the thread that has ID in it."
8194 (let ((dep gnus-newsgroup-dependencies)
8195 headers thread last-id)
8196 ;; First go up in this thread until we find the root.
8197 (setq last-id (gnus-root-id id))
8198 (setq headers (list (car (gnus-id-to-thread last-id))
8199 (caadr (gnus-id-to-thread last-id))))
8200 ;; We have now found the real root of this thread. It might have
8201 ;; been gathered into some loose thread, so we have to search
8202 ;; through the threads to find the thread we wanted.
8203 (let ((threads gnus-newsgroup-threads)
8206 (setq sub (car threads))
8207 (if (stringp (car sub))
8208 ;; This is a gathered threads, so we look at the roots
8209 ;; below it to find whether this article in in this
8212 (setq sub (cdr sub))
8214 (when (member (caar sub) headers)
8215 (setq thread (car threads)
8218 (setq sub (cdr sub))))
8219 ;; It's an ordinary thread, so we check it.
8220 (when (eq (car sub) (car headers))
8223 (setq threads (cdr threads)))
8224 ;; If this article is in no thread, then it's a root.
8227 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8228 (setq thread (gnus-gethash last-id dep)))
8231 thread ; We return this thread.
8233 (if (stringp (car thread))
8235 ;; If we use dummy roots, then we have to remove the
8236 ;; dummy root as well.
8237 (when (eq gnus-summary-make-false-root 'dummy)
8240 (setq thread (cdr thread))
8242 (gnus-remove-thread-1 (car thread))
8243 (setq thread (cdr thread))))
8244 (gnus-remove-thread-1 thread))))))))
8246 (defun gnus-remove-thread-1 (thread)
8247 "Remove the thread THREAD recursively."
8248 (let ((number (mail-header-number (car thread)))
8250 (when (setq pos (text-property-any
8251 (point-min) (point-max) 'gnus-number number))
8254 (gnus-data-remove number))
8255 (setq thread (cdr thread))
8257 (gnus-remove-thread-1 (pop thread)))))
8259 (defun gnus-sort-threads (threads)
8261 (if (not gnus-thread-sort-functions)
8263 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8264 (car gnus-thread-sort-functions)
8266 ,(gnus-make-sort-function
8267 (reverse gnus-thread-sort-functions))))))
8268 (gnus-message 7 "Sorting threads...")
8271 (gnus-message 7 "Sorting threads...done")))))
8273 (defun gnus-sort-articles (articles)
8275 (when gnus-article-sort-functions
8276 (let ((func (if (= 1 (length gnus-article-sort-functions))
8277 (car gnus-article-sort-functions)
8279 ,(gnus-make-sort-function
8280 (reverse gnus-article-sort-functions))))))
8281 (gnus-message 7 "Sorting articles...")
8283 (setq gnus-newsgroup-headers (sort articles func))
8284 (gnus-message 7 "Sorting articles...done")))))
8286 (defun gnus-make-sort-function (funs)
8287 "Return a composite sort condition based on the functions in FUNC."
8289 `(or (,(car funs) t1 t2)
8290 (and (not (,(car funs) t2 t1))
8291 ,(gnus-make-sort-function (cdr funs))))
8292 `(,(car funs) t1 t2)))
8294 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8295 (defmacro gnus-thread-header (thread)
8296 ;; Return header of first article in THREAD.
8297 ;; Note that THREAD must never, ever be anything else than a variable -
8298 ;; using some other form will lead to serious barfage.
8299 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8300 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8301 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8304 (defsubst gnus-article-sort-by-number (h1 h2)
8305 "Sort articles by article number."
8306 (< (mail-header-number h1)
8307 (mail-header-number h2)))
8309 (defun gnus-thread-sort-by-number (h1 h2)
8310 "Sort threads by root article number."
8311 (gnus-article-sort-by-number
8312 (gnus-thread-header h1) (gnus-thread-header h2)))
8314 (defsubst gnus-article-sort-by-author (h1 h2)
8315 "Sort articles by root author."
8317 (let ((extract (funcall
8318 gnus-extract-address-components
8319 (mail-header-from h1))))
8320 (or (car extract) (cdr extract)))
8321 (let ((extract (funcall
8322 gnus-extract-address-components
8323 (mail-header-from h2))))
8324 (or (car extract) (cdr extract)))))
8326 (defun gnus-thread-sort-by-author (h1 h2)
8327 "Sort threads by root author."
8328 (gnus-article-sort-by-author
8329 (gnus-thread-header h1) (gnus-thread-header h2)))
8331 (defsubst gnus-article-sort-by-subject (h1 h2)
8332 "Sort articles by root subject."
8334 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8335 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8337 (defun gnus-thread-sort-by-subject (h1 h2)
8338 "Sort threads by root subject."
8339 (gnus-article-sort-by-subject
8340 (gnus-thread-header h1) (gnus-thread-header h2)))
8342 (defsubst gnus-article-sort-by-date (h1 h2)
8343 "Sort articles by root article date."
8345 (inline (gnus-sortable-date (mail-header-date h1)))
8346 (inline (gnus-sortable-date (mail-header-date h2)))))
8348 (defun gnus-thread-sort-by-date (h1 h2)
8349 "Sort threads by root article date."
8350 (gnus-article-sort-by-date
8351 (gnus-thread-header h1) (gnus-thread-header h2)))
8353 (defsubst gnus-article-sort-by-score (h1 h2)
8354 "Sort articles by root article score.
8355 Unscored articles will be counted as having a score of zero."
8356 (> (or (cdr (assq (mail-header-number h1)
8357 gnus-newsgroup-scored))
8358 gnus-summary-default-score 0)
8359 (or (cdr (assq (mail-header-number h2)
8360 gnus-newsgroup-scored))
8361 gnus-summary-default-score 0)))
8363 (defun gnus-thread-sort-by-score (h1 h2)
8364 "Sort threads by root article score."
8365 (gnus-article-sort-by-score
8366 (gnus-thread-header h1) (gnus-thread-header h2)))
8368 (defun gnus-thread-sort-by-total-score (h1 h2)
8369 "Sort threads by the sum of all scores in the thread.
8370 Unscored articles will be counted as having a score of zero."
8371 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8373 (defun gnus-thread-total-score (thread)
8374 ;; This function find the total score of THREAD.
8375 (cond ((null thread)
8378 (if (stringp (car thread))
8379 (apply gnus-thread-score-function 0
8380 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8381 (gnus-thread-total-score-1 thread)))
8383 (gnus-thread-total-score-1 (list thread)))))
8385 (defun gnus-thread-total-score-1 (root)
8386 ;; This function find the total score of the thread below ROOT.
8387 (setq root (car root))
8388 (apply gnus-thread-score-function
8389 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8390 gnus-summary-default-score 0)
8391 (mapcar 'gnus-thread-total-score
8392 (cdr (gnus-gethash (mail-header-id root)
8393 gnus-newsgroup-dependencies)))))
8395 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8396 (defvar gnus-tmp-prev-subject nil)
8397 (defvar gnus-tmp-false-parent nil)
8398 (defvar gnus-tmp-root-expunged nil)
8399 (defvar gnus-tmp-dummy-line nil)
8401 (defun gnus-summary-prepare-threads (threads)
8402 "Prepare summary buffer from THREADS and indentation LEVEL.
8403 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8404 or a straight list of headers."
8405 (gnus-message 7 "Generating summary...")
8407 (setq gnus-newsgroup-threads threads)
8410 (let ((gnus-tmp-level 0)
8411 (default-score (or gnus-summary-default-score 0))
8412 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8413 thread number subject stack state gnus-tmp-gathered beg-match
8414 new-roots gnus-tmp-new-adopts thread-end
8415 gnus-tmp-header gnus-tmp-unread
8416 gnus-tmp-replied gnus-tmp-subject-or-nil
8417 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8418 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8419 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8421 (setq gnus-tmp-prev-subject nil)
8423 (if (vectorp (car threads))
8424 ;; If this is a straight (sic) list of headers, then a
8425 ;; threaded summary display isn't required, so we just create
8426 ;; an unthreaded one.
8427 (gnus-summary-prepare-unthreaded threads)
8429 ;; Do the threaded display.
8431 (while (or threads stack gnus-tmp-new-adopts new-roots)
8433 (if (and (= gnus-tmp-level 0)
8434 (not (setq gnus-tmp-dummy-line nil))
8437 (not gnus-tmp-false-parent)
8438 (or gnus-tmp-new-adopts new-roots))
8439 (if gnus-tmp-new-adopts
8440 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8441 thread (list (car gnus-tmp-new-adopts))
8442 gnus-tmp-header (caar thread)
8443 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8445 (setq thread (list (car new-roots))
8446 gnus-tmp-header (caar thread)
8447 new-roots (cdr new-roots))))
8450 ;; If there are some threads, we do them before the
8451 ;; threads on the stack.
8452 (setq thread threads
8453 gnus-tmp-header (caar thread))
8454 ;; There were no current threads, so we pop something off
8456 (setq state (car stack)
8457 gnus-tmp-level (car state)
8460 gnus-tmp-header (caar thread))))
8462 (setq gnus-tmp-false-parent nil)
8463 (setq gnus-tmp-root-expunged nil)
8464 (setq thread-end nil)
8466 (if (stringp gnus-tmp-header)
8467 ;; The header is a dummy root.
8469 ((eq gnus-summary-make-false-root 'adopt)
8470 ;; We let the first article adopt the rest.
8471 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8473 (setq gnus-tmp-gathered
8475 (lambda (h) (mail-header-number (car h)))
8478 (setq thread (cons (list (caar thread)
8481 (setq gnus-tmp-level -1
8482 gnus-tmp-false-parent t))
8483 ((eq gnus-summary-make-false-root 'empty)
8484 ;; We print adopted articles with empty subject fields.
8485 (setq gnus-tmp-gathered
8487 (lambda (h) (mail-header-number (car h)))
8490 (setq gnus-tmp-level -1))
8491 ((eq gnus-summary-make-false-root 'dummy)
8492 ;; We remember that we probably want to output a dummy
8494 (setq gnus-tmp-dummy-line gnus-tmp-header)
8495 (setq gnus-tmp-prev-subject gnus-tmp-header))
8497 ;; We do not make a root for the gathered
8498 ;; sub-threads at all.
8499 (setq gnus-tmp-level -1)))
8501 (setq number (mail-header-number gnus-tmp-header)
8502 subject (mail-header-subject gnus-tmp-header))
8505 ;; If the thread has changed subject, we might want to make
8506 ;; this subthread into a root.
8507 ((and (null gnus-thread-ignore-subject)
8508 (not (zerop gnus-tmp-level))
8509 gnus-tmp-prev-subject
8511 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8512 (setq new-roots (nconc new-roots (list (car thread)))
8514 gnus-tmp-header nil))
8515 ;; If the article lies outside the current limit,
8516 ;; then we do not display it.
8517 ((and (not (memq number gnus-newsgroup-limit))
8518 (not gnus-tmp-dummy-line))
8519 (setq gnus-tmp-gathered
8521 (lambda (h) (mail-header-number (car h)))
8524 (setq gnus-tmp-new-adopts (if (cdar thread)
8525 (append gnus-tmp-new-adopts
8527 gnus-tmp-new-adopts)
8529 gnus-tmp-header nil)
8530 (when (zerop gnus-tmp-level)
8531 (setq gnus-tmp-root-expunged t)))
8532 ;; Perhaps this article is to be marked as read?
8533 ((and gnus-summary-mark-below
8534 (< (or (cdr (assq number gnus-newsgroup-scored))
8536 gnus-summary-mark-below)
8537 ;; Don't touch sparse articles.
8538 (not (memq number gnus-newsgroup-sparse))
8539 (not (memq number gnus-newsgroup-ancient)))
8540 (setq gnus-newsgroup-unreads
8541 (delq number gnus-newsgroup-unreads))
8542 (if gnus-newsgroup-auto-expire
8543 (push number gnus-newsgroup-expirable)
8544 (push (cons number gnus-low-score-mark)
8545 gnus-newsgroup-reads))))
8547 (when gnus-tmp-header
8548 ;; We may have an old dummy line to output before this
8550 (when gnus-tmp-dummy-line
8551 (gnus-summary-insert-dummy-line
8552 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8553 (setq gnus-tmp-dummy-line nil))
8555 ;; Compute the mark.
8559 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8560 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8561 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8562 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8563 (t (or (cdr (assq number gnus-newsgroup-reads))
8564 gnus-ancient-mark))))
8566 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8567 gnus-tmp-header gnus-tmp-level)
8568 gnus-newsgroup-data)
8570 ;; Actually insert the line.
8572 gnus-tmp-subject-or-nil
8574 ((and gnus-thread-ignore-subject
8575 gnus-tmp-prev-subject
8576 (not (inline (gnus-subject-equal
8577 gnus-tmp-prev-subject subject))))
8579 ((zerop gnus-tmp-level)
8580 (if (and (eq gnus-summary-make-false-root 'empty)
8581 (memq number gnus-tmp-gathered)
8582 gnus-tmp-prev-subject
8583 (inline (gnus-subject-equal
8584 gnus-tmp-prev-subject subject)))
8585 gnus-summary-same-subject
8587 (t gnus-summary-same-subject)))
8588 (if (and (eq gnus-summary-make-false-root 'adopt)
8589 (= gnus-tmp-level 1)
8590 (memq number gnus-tmp-gathered))
8591 (setq gnus-tmp-opening-bracket ?\<
8592 gnus-tmp-closing-bracket ?\>)
8593 (setq gnus-tmp-opening-bracket ?\[
8594 gnus-tmp-closing-bracket ?\]))
8596 gnus-tmp-indentation
8597 (aref gnus-thread-indent-array gnus-tmp-level)
8598 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8599 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8600 gnus-summary-default-score 0)
8602 (if (or (null gnus-summary-default-score)
8603 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8604 gnus-summary-zcore-fuzz)) ?
8605 (if (< gnus-tmp-score gnus-summary-default-score)
8606 gnus-score-below-mark gnus-score-over-mark))
8608 (cond ((memq number gnus-newsgroup-processable)
8610 ((memq number gnus-newsgroup-cached)
8612 ((memq number gnus-newsgroup-replied)
8614 (t gnus-unread-mark))
8615 gnus-tmp-from (mail-header-from gnus-tmp-header)
8618 ((string-match "(.+)" gnus-tmp-from)
8619 (substring gnus-tmp-from
8620 (1+ (match-beginning 0)) (1- (match-end 0))))
8621 ((string-match "<[^>]+> *$" gnus-tmp-from)
8622 (setq beg-match (match-beginning 0))
8623 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8624 (substring gnus-tmp-from (1+ (match-beginning 0))
8625 (1- (match-end 0))))
8626 (substring gnus-tmp-from 0 beg-match)))
8628 (when (string= gnus-tmp-name "")
8629 (setq gnus-tmp-name gnus-tmp-from))
8630 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8631 (gnus-put-text-property
8633 (progn (eval gnus-summary-line-format-spec) (point))
8634 'gnus-number number)
8637 (run-hooks 'gnus-summary-update-hook)
8640 (setq gnus-tmp-prev-subject subject)))
8642 (when (nth 1 thread)
8643 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8644 (incf gnus-tmp-level)
8645 (setq threads (if thread-end nil (cdar thread)))
8647 (setq gnus-tmp-level 0)))))
8648 (gnus-message 7 "Generating summary...done"))
8650 (defun gnus-summary-prepare-unthreaded (headers)
8651 "Generate an unthreaded summary buffer based on HEADERS."
8652 (let (header number mark)
8655 ;; We may have to root out some bad articles...
8656 (when (memq (setq number (mail-header-number
8657 (setq header (pop headers))))
8658 gnus-newsgroup-limit)
8659 ;; Mark article as read when it has a low score.
8660 (when (and gnus-summary-mark-below
8661 (< (or (cdr (assq number gnus-newsgroup-scored))
8662 gnus-summary-default-score 0)
8663 gnus-summary-mark-below)
8664 (not (memq number gnus-newsgroup-ancient)))
8665 (setq gnus-newsgroup-unreads
8666 (delq number gnus-newsgroup-unreads))
8667 (if gnus-newsgroup-auto-expire
8668 (push number gnus-newsgroup-expirable)
8669 (push (cons number gnus-low-score-mark)
8670 gnus-newsgroup-reads)))
8674 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8675 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8676 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8677 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8678 (t (or (cdr (assq number gnus-newsgroup-reads))
8679 gnus-ancient-mark))))
8680 (setq gnus-newsgroup-data
8681 (cons (gnus-data-make number mark (1+ (point)) header 0)
8682 gnus-newsgroup-data))
8683 (gnus-summary-insert-line
8684 header 0 nil mark (memq number gnus-newsgroup-replied)
8685 (memq number gnus-newsgroup-expirable)
8686 (mail-header-subject header) nil
8687 (cdr (assq number gnus-newsgroup-scored))
8688 (memq number gnus-newsgroup-processable))))))
8690 (defun gnus-select-newsgroup (group &optional read-all)
8691 "Select newsgroup GROUP.
8692 If READ-ALL is non-nil, all articles in the group are selected."
8693 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8694 (info (nth 2 entry))
8695 articles fetched-articles cached)
8697 (or (gnus-check-server
8698 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8699 (error "Couldn't open server"))
8701 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8702 (gnus-activate-group group) ; Or we can activate it...
8703 (progn ; Or we bug out.
8704 (when (equal major-mode 'gnus-summary-mode)
8705 (kill-buffer (current-buffer)))
8706 (error "Couldn't request group %s: %s"
8707 group (gnus-status-message group))))
8709 (unless (gnus-request-group group t)
8710 (when (equal major-mode 'gnus-summary-mode)
8711 (kill-buffer (current-buffer)))
8712 (error "Couldn't request group %s: %s"
8713 group (gnus-status-message group)))
8715 (setq gnus-newsgroup-name group)
8716 (setq gnus-newsgroup-unselected nil)
8717 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8719 (and gnus-asynchronous
8720 (gnus-check-backend-function
8721 'request-asynchronous gnus-newsgroup-name)
8722 (setq gnus-newsgroup-async
8723 (gnus-request-asynchronous gnus-newsgroup-name)))
8725 ;; Adjust and set lists of article marks.
8727 (gnus-adjust-marked-articles info))
8729 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8730 (when (gnus-virtual-group-p group)
8731 (setq cached gnus-newsgroup-cached))
8733 (setq gnus-newsgroup-unreads
8734 (gnus-set-difference
8735 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8736 gnus-newsgroup-dormant))
8738 (setq gnus-newsgroup-processable nil)
8740 (setq articles (gnus-articles-to-read group read-all))
8744 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8746 ((eq articles 0) nil)
8748 ;; Init the dependencies hash table.
8749 (setq gnus-newsgroup-dependencies
8750 (gnus-make-hashtable (length articles)))
8751 ;; Retrieve the headers and read them in.
8752 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8753 (setq gnus-newsgroup-headers
8755 (setq gnus-headers-retrieved-by
8756 (gnus-retrieve-headers
8757 articles gnus-newsgroup-name
8758 ;; We might want to fetch old headers, but
8759 ;; not if there is only 1 article.
8760 (and gnus-fetch-old-headers
8762 (not (eq gnus-fetch-old-headers 'some))
8763 (not (numberp gnus-fetch-old-headers)))
8764 (> (length articles) 1))))))
8765 (gnus-get-newsgroup-headers-xover articles)
8766 (gnus-get-newsgroup-headers)))
8767 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8769 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8771 (setq gnus-newsgroup-cached cached))
8773 ;; Set the initial limit.
8774 (setq gnus-newsgroup-limit (copy-sequence articles))
8775 ;; Remove canceled articles from the list of unread articles.
8776 (setq gnus-newsgroup-unreads
8777 (gnus-set-sorted-intersection
8778 gnus-newsgroup-unreads
8779 (setq fetched-articles
8780 (mapcar (lambda (headers) (mail-header-number headers))
8781 gnus-newsgroup-headers))))
8782 ;; Removed marked articles that do not exist.
8783 (gnus-update-missing-marks
8784 (gnus-sorted-complement fetched-articles articles))
8785 ;; We might want to build some more threads first.
8786 (and gnus-fetch-old-headers
8787 (eq gnus-headers-retrieved-by 'nov)
8788 (gnus-build-old-threads))
8789 ;; Check whether auto-expire is to be done in this group.
8790 (setq gnus-newsgroup-auto-expire
8791 (gnus-group-auto-expirable-p group))
8792 ;; Set up the article buffer now, if necessary.
8793 (unless gnus-single-article-buffer
8794 (gnus-article-setup-buffer))
8795 ;; First and last article in this newsgroup.
8796 (when gnus-newsgroup-headers
8797 (setq gnus-newsgroup-begin
8798 (mail-header-number (car gnus-newsgroup-headers))
8801 (gnus-last-element gnus-newsgroup-headers))))
8802 (setq gnus-reffed-article-number -1)
8803 ;; GROUP is successfully selected.
8804 (or gnus-newsgroup-headers t)))))
8806 (defun gnus-articles-to-read (group read-all)
8807 ;; Find out what articles the user wants to read.
8809 ;; Select all articles if `read-all' is non-nil, or if there
8810 ;; are no unread articles.
8812 (and (zerop (length gnus-newsgroup-marked))
8813 (zerop (length gnus-newsgroup-unreads))))
8814 (gnus-uncompress-range (gnus-active group))
8815 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8816 (copy-sequence gnus-newsgroup-unreads))
8818 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8819 (scored (length scored-list))
8820 (number (length articles))
8821 (marked (+ (length gnus-newsgroup-marked)
8822 (length gnus-newsgroup-dormant)))
8830 ((and (or (<= scored marked) (= scored number))
8831 (numberp gnus-large-newsgroup)
8832 (> number gnus-large-newsgroup))
8836 "How many articles from %s (default %d): "
8837 gnus-newsgroup-name number))))
8838 (if (string-match "^[ \t]*$" input) number input)))
8839 ((and (> scored marked) (< scored number))
8842 (format "%s %s (%d scored, %d total): "
8843 "How many articles from"
8844 group scored number))))
8845 (if (string-match "^[ \t]*$" input)
8849 (setq select (if (stringp select) (string-to-number select) select))
8850 (if (or (null select) (zerop select))
8852 (if (and (not (zerop scored)) (<= (abs select) scored))
8854 (setq articles (sort scored-list '<))
8855 (setq number (length articles)))
8856 (setq articles (copy-sequence articles)))
8858 (if (< (abs select) number)
8860 ;; Select the N oldest articles.
8861 (setcdr (nthcdr (1- (abs select)) articles) nil)
8862 ;; Select the N most recent articles.
8863 (setq articles (nthcdr (- number select) articles))))
8864 (setq gnus-newsgroup-unselected
8865 (gnus-sorted-intersection
8866 gnus-newsgroup-unreads
8867 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8870 (defun gnus-killed-articles (killed articles)
8873 (if (inline (gnus-member-of-range (car articles) killed))
8874 (setq out (cons (car articles) out)))
8875 (setq articles (cdr articles)))
8878 (defun gnus-uncompress-marks (marks)
8879 "Uncompress the mark ranges in MARKS."
8880 (let ((uncompressed '(score bookmark))
8883 (if (memq (caar marks) uncompressed)
8884 (push (car marks) out)
8885 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8886 (setq marks (cdr marks)))
8889 (defun gnus-adjust-marked-articles (info)
8890 "Set all article lists and remove all marks that are no longer legal."
8891 (let* ((marked-lists (gnus-info-marks info))
8892 (active (gnus-active (gnus-info-group info)))
8895 (types gnus-article-mark-lists)
8896 (uncompressed '(score bookmark))
8897 marks var articles article mark)
8900 (setq marks (pop marked-lists))
8901 (set (setq var (intern (format "gnus-newsgroup-%s"
8902 (car (rassq (setq mark (car marks))
8904 (if (memq (car marks) uncompressed) (cdr marks)
8905 (gnus-uncompress-range (cdr marks))))
8907 (setq articles (symbol-value var))
8909 ;; All articles have to be subsets of the active articles.
8911 ;; Adjust "simple" lists.
8912 ((memq mark '(tick dormant expirable reply killed save))
8914 (when (or (< (setq article (pop articles)) min) (> article max))
8915 (set var (delq article (symbol-value var))))))
8917 ((memq mark '(score bookmark))
8919 (when (or (< (car (setq article (pop articles))) min)
8920 (> (car article) max))
8921 (set var (delq article (symbol-value var))))))))))
8923 (defun gnus-update-missing-marks (missing)
8924 "Go through the list of MISSING articles and remove them mark lists."
8926 (let ((types gnus-article-mark-lists)
8928 ;; Go through all types.
8930 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8931 (when (symbol-value var)
8932 ;; This list has articles. So we delete all missing articles
8936 (set var (delq (pop m) (symbol-value var)))))))))
8938 (defun gnus-update-marks ()
8939 "Enter the various lists of marked articles into the newsgroup info list."
8940 (let ((types gnus-article-mark-lists)
8941 (info (gnus-get-info gnus-newsgroup-name))
8942 (uncompressed '(score bookmark killed))
8943 type list newmarked symbol)
8945 ;; Add all marks lists that are non-nil to the list of marks lists.
8947 (setq type (pop types))
8948 (when (setq list (symbol-value
8950 (intern (format "gnus-newsgroup-%s"
8952 (push (cons (cdr type)
8953 (if (memq (cdr type) uncompressed) list
8954 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8957 ;; Enter these new marks into the info of the group.
8959 (setcar (nthcdr 3 info) newmarked)
8960 ;; Add the marks lists to the end of the info.
8962 (setcdr (nthcdr 2 info) (list newmarked))))
8964 ;; Cut off the end of the info if there's nothing else there.
8968 (when (nthcdr (decf i) info)
8969 (setcdr (nthcdr i info) nil)))))))
8971 (defun gnus-add-marked-articles (group type articles &optional info force)
8972 ;; Add ARTICLES of TYPE to the info of GROUP.
8973 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8974 ;; add, but replace marked articles of TYPE with ARTICLES.
8975 (let ((info (or info (gnus-get-info group)))
8976 (uncompressed '(score bookmark killed))
8979 (and (not (setq marked (nthcdr 3 info)))
8981 (setcdr (nthcdr 2 info)
8982 (list (list (cons type (gnus-compress-sequence
8984 (and (not (setq m (assq type (car marked))))
8987 (cons (cons type (gnus-compress-sequence articles t) )
8991 (setcar (nthcdr 3 info)
8992 (delq (assq type (car marked)) (car marked)))
8993 (setcdr m (gnus-compress-sequence articles t)))
8994 (setcdr m (gnus-compress-sequence
8995 (sort (nconc (gnus-uncompress-range (cdr m))
8996 (copy-sequence articles)) '<) t))))))
8998 (defun gnus-set-mode-line (where)
8999 "This function sets the mode line of the article or summary buffers.
9000 If WHERE is `summary', the summary mode line format will be used."
9001 ;; Is this mode line one we keep updated?
9002 (when (memq where gnus-updated-mode-lines)
9005 ;; We evaluate this in the summary buffer since these
9006 ;; variables are buffer-local to that buffer.
9007 (set-buffer gnus-summary-buffer)
9008 ;; We bind all these variables that are used in the `eval' form
9010 (let* ((mformat (symbol-value
9012 (format "gnus-%s-mode-line-format-spec" where))))
9013 (gnus-tmp-group-name gnus-newsgroup-name)
9014 (gnus-tmp-article-number (or gnus-current-article 0))
9015 (gnus-tmp-unread gnus-newsgroup-unreads)
9016 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
9017 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
9018 (gnus-tmp-unread-and-unselected
9019 (cond ((and (zerop gnus-tmp-unread-and-unticked)
9020 (zerop gnus-tmp-unselected)) "")
9021 ((zerop gnus-tmp-unselected)
9022 (format "{%d more}" gnus-tmp-unread-and-unticked))
9023 (t (format "{%d(+%d) more}"
9024 gnus-tmp-unread-and-unticked
9025 gnus-tmp-unselected))))
9027 (if (and gnus-current-headers
9028 (vectorp gnus-current-headers))
9029 (gnus-mode-string-quote
9030 (mail-header-subject gnus-current-headers)) ""))
9032 gnus-tmp-header);; passed as argument to any user-format-funcs
9033 (setq mode-string (eval mformat))
9034 (setq max-len (max 4 (if gnus-mode-non-string-length
9036 gnus-mode-non-string-length)
9037 (length mode-string))))
9038 ;; We might have to chop a bit of the string off...
9039 (when (> (length mode-string) max-len)
9041 (concat (gnus-truncate-string mode-string (- max-len 3))
9043 ;; Pad the mode string a bit.
9044 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
9045 ;; Update the mode line.
9046 (setq mode-line-buffer-identification (list mode-string))
9047 (set-buffer-modified-p t))))
9049 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
9050 "Go through the HEADERS list and add all Xrefs to a hash table.
9051 The resulting hash table is returned, or nil if no Xrefs were found."
9052 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
9053 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
9054 (xref-hashtb (make-vector 63 0))
9055 start group entry number xrefs header)
9057 (setq header (pop headers))
9058 (when (and (setq xrefs (mail-header-xref header))
9059 (not (memq (setq number (mail-header-number header))
9062 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
9063 (setq start (match-end 0))
9064 (setq group (if prefix
9065 (concat prefix (substring xrefs (match-beginning 1)
9067 (substring xrefs (match-beginning 1) (match-end 1))))
9069 (string-to-int (substring xrefs (match-beginning 2)
9071 (if (setq entry (gnus-gethash group xref-hashtb))
9072 (setcdr entry (cons number (cdr entry)))
9073 (gnus-sethash group (cons number nil) xref-hashtb)))))
9074 (and start xref-hashtb)))
9076 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
9077 "Look through all the headers and mark the Xrefs as read."
9078 (let ((virtual (gnus-virtual-group-p from-newsgroup))
9079 name entry info xref-hashtb idlist method nth4)
9081 (set-buffer gnus-group-buffer)
9082 (when (setq xref-hashtb
9083 (gnus-create-xref-hashtb from-newsgroup headers unreads))
9086 (unless (string= from-newsgroup (setq name (symbol-name group)))
9087 (setq idlist (symbol-value group))
9088 ;; Dead groups are not updated.
9090 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
9092 (if (stringp (setq nth4 (gnus-info-method info)))
9093 (setq nth4 (gnus-server-to-method nth4))))
9094 ;; Only do the xrefs if the group has the same
9095 ;; select method as the group we have just read.
9096 (or (gnus-methods-equal-p
9097 nth4 (gnus-find-method-for-group from-newsgroup))
9099 (equal nth4 (setq method (gnus-find-method-for-group
9101 (and (equal (car nth4) (car method))
9102 (equal (nth 1 nth4) (nth 1 method))))
9103 gnus-use-cross-reference
9104 (or (not (eq gnus-use-cross-reference t))
9106 ;; Only do cross-references on subscribed
9107 ;; groups, if that is what is wanted.
9108 (<= (gnus-info-level info) gnus-level-subscribed))
9109 (gnus-group-make-articles-read name idlist))))
9112 (defun gnus-group-make-articles-read (group articles)
9114 (entry (gnus-gethash group gnus-newsrc-hashtb))
9115 (info (nth 2 entry))
9116 (active (gnus-active group))
9118 ;; First peel off all illegal article numbers.
9120 (let ((ids articles)
9124 (if (and first (> id (cdr active)))
9126 ;; We'll end up in this situation in one particular
9127 ;; obscure situation. If you re-scan a group and get
9128 ;; a new article that is cross-posted to a different
9129 ;; group that has not been re-scanned, you might get
9130 ;; crossposted article that has a higher number than
9131 ;; Gnus believes possible. So we re-activate this
9132 ;; group as well. This might mean doing the
9133 ;; crossposting thingy will *increase* the number
9134 ;; of articles in some groups. Tsk, tsk.
9135 (setq active (or (gnus-activate-group group) active))))
9136 (if (or (> id (cdr active))
9137 (< id (car active)))
9138 (setq articles (delq id articles)))
9139 (setq ids (cdr ids)))))
9140 ;; If the read list is nil, we init it.
9142 (null (gnus-info-read info))
9144 (gnus-info-set-read info (cons 1 (1- (car active)))))
9145 ;; Then we add the read articles to the range.
9150 (gnus-info-read info) (setq articles (sort articles '<)))))
9151 ;; Then we have to re-compute how many unread
9152 ;; articles there are in this group.
9157 (setq num (- (1+ (cdr active)) (car active))))
9158 ((not (listp (cdr range)))
9159 (setq num (- (cdr active) (- (1+ (cdr range))
9163 (if (numberp (car range))
9165 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
9166 (setq range (cdr range)))
9167 (setq num (- (cdr active) num))))
9168 ;; Update the number of unread articles.
9170 ;; Update the group buffer.
9171 (gnus-group-update-group group t)))))
9173 (defun gnus-methods-equal-p (m1 m2)
9174 (let ((m1 (or m1 gnus-select-method))
9175 (m2 (or m2 gnus-select-method)))
9177 (and (eq (car m1) (car m2))
9178 (or (not (memq 'address (assoc (symbol-name (car m1))
9179 gnus-valid-select-methods)))
9180 (equal (nth 1 m1) (nth 1 m2)))))))
9182 (defsubst gnus-header-value ()
9183 (buffer-substring (match-end 0) (gnus-point-at-eol)))
9185 (defvar gnus-newsgroup-none-id 0)
9187 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
9188 (let ((cur nntp-server-buffer)
9191 (save-excursion (set-buffer gnus-summary-buffer)
9192 gnus-newsgroup-dependencies)))
9193 headers id id-dep ref-dep end ref)
9195 (set-buffer nntp-server-buffer)
9196 (run-hooks 'gnus-parse-headers-hook)
9197 (let ((case-fold-search t)
9198 in-reply-to header p lines)
9199 (goto-char (point-min))
9200 ;; Search to the beginning of the next header. Error messages
9201 ;; do not begin with 2 or 3.
9202 (while (re-search-forward "^[23][0-9]+ " nil t)
9205 ;; This implementation of this function, with nine
9206 ;; search-forwards instead of the one re-search-forward and
9207 ;; a case (which basically was the old function) is actually
9208 ;; about twice as fast, even though it looks messier. You
9209 ;; can't have everything, I guess. Speed and elegance
9210 ;; doesn't always go hand in hand.
9219 (narrow-to-region (point)
9220 (or (and (search-forward "\n.\n" nil t)
9226 (if (search-forward "\nsubject: " nil t)
9227 (gnus-header-value) "(none)"))
9231 (if (search-forward "\nfrom: " nil t)
9232 (gnus-header-value) "(nobody)"))
9236 (if (search-forward "\ndate: " nil t)
9237 (gnus-header-value) ""))
9241 (if (search-forward "\nmessage-id: " nil t)
9242 (setq id (gnus-header-value))
9243 ;; If there was no message-id, we just fake one to make
9244 ;; subsequent routines simpler.
9245 (setq id (concat "none+"
9247 (setq gnus-newsgroup-none-id
9248 (1+ gnus-newsgroup-none-id)))))))
9252 (if (search-forward "\nreferences: " nil t)
9255 (setq end (match-end 0))
9261 (search-backward ">" end t)
9264 (search-backward "<" end t)
9266 ;; Get the references from the in-reply-to header if there
9267 ;; were no references and the in-reply-to header looks
9269 (if (and (search-forward "\nin-reply-to: " nil t)
9270 (setq in-reply-to (gnus-header-value))
9271 (string-match "<[^>]+>" in-reply-to))
9272 (setq ref (substring in-reply-to (match-beginning 0)
9280 (if (search-forward "\nlines: " nil t)
9281 (if (numberp (setq lines (read cur)))
9287 (and (search-forward "\nxref: " nil t)
9288 (gnus-header-value)))))
9289 ;; We do the threading while we read the headers. The
9290 ;; message-id and the last reference are both entered into
9291 ;; the same hash table. Some tippy-toeing around has to be
9292 ;; done in case an article has arrived before the article
9293 ;; which it refers to.
9294 (if (boundp (setq id-dep (intern id dependencies)))
9295 (if (and (car (symbol-value id-dep))
9297 ;; An article with this Message-ID has already
9298 ;; been seen, so we ignore this one, except we add
9299 ;; any additional Xrefs (in case the two articles
9300 ;; came from different servers).
9302 (mail-header-set-xref
9303 (car (symbol-value id-dep))
9304 (concat (or (mail-header-xref
9305 (car (symbol-value id-dep))) "")
9306 (or (mail-header-xref header) "")))
9308 (setcar (symbol-value id-dep) header))
9309 (set id-dep (list header)))
9311 (if (boundp (setq ref-dep (intern ref dependencies)))
9312 (setcdr (symbol-value ref-dep)
9313 (nconc (cdr (symbol-value ref-dep))
9314 (list (symbol-value id-dep))))
9315 (set ref-dep (list nil (symbol-value id-dep))))
9316 (setq headers (cons header headers)))
9317 (goto-char (point-max))
9319 (nreverse headers)))))
9321 ;; The following macros and functions were written by Felix Lee
9322 ;; <flee@cse.psu.edu>.
9324 (defmacro gnus-nov-read-integer ()
9326 (if (= (following-char) ?\t)
9328 (let ((num (condition-case nil (read buffer) (error nil))))
9329 (if (numberp num) num 0)))
9330 (or (eobp) (forward-char 1))))
9332 (defmacro gnus-nov-skip-field ()
9333 '(search-forward "\t" eol 'move))
9335 (defmacro gnus-nov-field ()
9336 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9338 ;; Goes through the xover lines and returns a list of vectors
9339 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9340 force-new dependencies)
9341 "Parse the news overview data in the server buffer, and return a
9342 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9343 ;; Get the Xref when the users reads the articles since most/some
9344 ;; NNTP servers do not include Xrefs when using XOVER.
9345 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9346 (let ((cur nntp-server-buffer)
9347 (dependencies (or dependencies gnus-newsgroup-dependencies))
9348 number headers header)
9350 (set-buffer nntp-server-buffer)
9351 ;; Allow the user to mangle the headers before parsing them.
9352 (run-hooks 'gnus-parse-headers-hook)
9353 (goto-char (point-min))
9354 (while (and sequence (not (eobp)))
9355 (setq number (read cur))
9356 (while (and sequence (< (car sequence) number))
9357 (setq sequence (cdr sequence)))
9359 (eq number (car sequence))
9361 (setq sequence (cdr sequence))
9363 (inline (gnus-nov-parse-line
9364 number dependencies force-new)))
9365 (setq headers (cons header headers)))))
9367 (setq headers (nreverse headers)))
9370 ;; This function has to be called with point after the article number
9371 ;; on the beginning of the line.
9372 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9374 (eol (gnus-point-at-eol))
9375 (buffer (current-buffer))
9376 header ref id id-dep ref-dep)
9378 ;; overview: [num subject from date id refs chars lines misc]
9379 (narrow-to-region (point) eol)
9380 (or (eobp) (forward-char))
9386 (gnus-nov-field) ; subject
9387 (gnus-nov-field) ; from
9388 (gnus-nov-field) ; date
9389 (setq id (or (gnus-nov-field)
9392 (setq none (1+ none)))))) ; id
9395 (let ((beg (point)))
9396 (search-forward "\t" eol)
9397 (if (search-backward ">" beg t)
9401 (search-backward "<" beg t)))
9403 (gnus-nov-field)) ; refs
9404 (gnus-nov-read-integer) ; chars
9405 (gnus-nov-read-integer) ; lines
9406 (if (= (following-char) ?\n)
9408 (gnus-nov-field)) ; misc
9411 (gnus-error 4 "Strange nov line")
9417 ;; We build the thread tree.
9419 (if (boundp (setq id-dep (intern id dependencies)))
9420 (if (and (car (symbol-value id-dep))
9422 ;; An article with this Message-ID has already been seen,
9423 ;; so we ignore this one, except we add any additional
9424 ;; Xrefs (in case the two articles came from different
9427 (mail-header-set-xref
9428 (car (symbol-value id-dep))
9429 (concat (or (mail-header-xref
9430 (car (symbol-value id-dep))) "")
9431 (or (mail-header-xref header) "")))
9433 (setcar (symbol-value id-dep) header))
9434 (set id-dep (list header))))
9436 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9437 (setcdr (symbol-value ref-dep)
9438 (nconc (cdr (symbol-value ref-dep))
9439 (list (symbol-value id-dep))))
9440 (set ref-dep (list nil (symbol-value id-dep)))))
9443 (defun gnus-article-get-xrefs ()
9444 "Fill in the Xref value in `gnus-current-headers', if necessary.
9445 This is meant to be called in `gnus-article-internal-prepare-hook'."
9446 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9447 gnus-current-headers)))
9448 (or (not gnus-use-cross-reference)
9450 (and (mail-header-xref headers)
9451 (not (string= (mail-header-xref headers) "")))
9452 (let ((case-fold-search t)
9455 (nnheader-narrow-to-headers)
9456 (goto-char (point-min))
9457 (if (or (and (eq (downcase (following-char)) ?x)
9458 (looking-at "Xref:"))
9459 (search-forward "\nXref:" nil t))
9461 (goto-char (1+ (match-end 0)))
9462 (setq xref (buffer-substring (point)
9463 (progn (end-of-line) (point))))
9464 (mail-header-set-xref headers xref))))))))
9466 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
9467 "Find article ID and insert the summary line for that article."
9468 (let ((header (if (and old-header use-old-header)
9469 old-header (gnus-read-header id)))
9470 (number (and (numberp id) id))
9473 ;; Rebuild the thread that this article is part of and go to the
9474 ;; article we have fetched.
9475 (when (and (not gnus-show-threads)
9477 (when (setq pos (text-property-any
9478 (point-min) (point-max) 'gnus-number
9479 (mail-header-number old-header)))
9482 (gnus-data-remove (mail-header-number old-header))))
9484 (mail-header-set-number header (mail-header-number old-header)))
9485 (setq gnus-newsgroup-sparse
9486 (delq (setq number (mail-header-number header))
9487 gnus-newsgroup-sparse))
9488 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
9489 (gnus-rebuild-thread (mail-header-id header))
9490 (gnus-summary-goto-subject number nil t))
9491 (when (and (numberp number)
9493 ;; We have to update the boundaries even if we can't fetch the
9494 ;; article if ID is a number -- so that the next `P' or `N'
9495 ;; command will fetch the previous (or next) article even
9496 ;; if the one we tried to fetch this time has been canceled.
9497 (and (> number gnus-newsgroup-end)
9498 (setq gnus-newsgroup-end number))
9499 (and (< number gnus-newsgroup-begin)
9500 (setq gnus-newsgroup-begin number))
9501 (setq gnus-newsgroup-unselected
9502 (delq number gnus-newsgroup-unselected)))
9503 ;; Report back a success?
9504 (and header (mail-header-number header))))
9506 (defun gnus-summary-work-articles (n)
9507 "Return a list of articles to be worked upon. The prefix argument,
9508 the list of process marked articles, and the current article will be
9509 taken into consideration."
9511 ((and n (numberp n))
9512 ;; A numerical prefix has been given.
9513 (let ((backward (< n 0))
9519 (push (setq article (gnus-summary-article-number))
9522 (gnus-summary-find-prev nil article)
9523 (gnus-summary-find-next nil article)))
9525 (nreverse articles)))
9526 ((and (boundp 'transient-mark-mode)
9529 ;; Work on the region between point and mark.
9530 (let ((max (max (point) (mark)))
9533 (goto-char (min (point) (mark)))
9536 (push (setq article (gnus-summary-article-number)) articles)
9537 (gnus-summary-find-next nil article)
9539 (nreverse articles))))
9540 (gnus-newsgroup-processable
9541 ;; There are process-marked articles present.
9542 (reverse gnus-newsgroup-processable))
9544 ;; Just return the current article.
9545 (list (gnus-summary-article-number)))))
9547 (defun gnus-summary-search-group (&optional backward use-level)
9548 "Search for next unread newsgroup.
9549 If optional argument BACKWARD is non-nil, search backward instead."
9551 (set-buffer gnus-group-buffer)
9552 (if (gnus-group-search-forward
9553 backward nil (if use-level (gnus-group-group-level) nil))
9554 (gnus-group-group-name))))
9556 (defun gnus-summary-best-group (&optional exclude-group)
9557 "Find the name of the best unread group.
9558 If EXCLUDE-GROUP, do not go to this group."
9560 (set-buffer gnus-group-buffer)
9562 (gnus-group-best-unread-group exclude-group))))
9564 (defun gnus-summary-find-next (&optional unread article backward)
9565 (if backward (gnus-summary-find-prev)
9566 (let* ((dummy (gnus-summary-article-intangible-p))
9567 (article (or article (gnus-summary-article-number)))
9568 (arts (gnus-data-find-list article))
9570 (when (and (not dummy)
9571 (or (not gnus-summary-check-current)
9573 (not (gnus-data-unread-p (car arts)))))
9574 (setq arts (cdr arts)))
9579 (when (gnus-data-unread-p (car arts))
9580 (setq result (car arts)
9582 (setq arts (cdr arts)))
9585 (goto-char (gnus-data-pos result))
9586 (gnus-data-number result)))))
9588 (defun gnus-summary-find-prev (&optional unread article)
9589 (let* ((eobp (eobp))
9590 (article (or article (gnus-summary-article-number)))
9591 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9593 (when (and (not eobp)
9594 (or (not gnus-summary-check-current)
9596 (not (gnus-data-unread-p (car arts)))))
9597 (setq arts (cdr arts)))
9602 (and (gnus-data-unread-p (car arts))
9603 (setq result (car arts)
9605 (setq arts (cdr arts)))
9609 (goto-char (gnus-data-pos result))
9610 (gnus-data-number result)))))
9612 (defun gnus-summary-find-subject (subject &optional unread backward article)
9613 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9614 (article (or article (gnus-summary-article-number)))
9615 (articles (gnus-data-list backward))
9616 (arts (gnus-data-find-list article articles))
9618 (when (or (not gnus-summary-check-current)
9620 (not (gnus-data-unread-p (car arts))))
9621 (setq arts (cdr arts)))
9623 (and (or (not unread)
9624 (gnus-data-unread-p (car arts)))
9625 (vectorp (gnus-data-header (car arts)))
9627 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9628 (setq result (car arts)
9630 (setq arts (cdr arts)))
9632 (goto-char (gnus-data-pos result))
9633 (gnus-data-number result))))
9635 (defun gnus-summary-search-forward (&optional unread subject backward)
9636 "Search forward for an article.
9637 If UNREAD, look for unread articles. If SUBJECT, look for
9638 articles with that subject. If BACKWARD, search backward instead."
9639 (cond (subject (gnus-summary-find-subject subject unread backward))
9640 (backward (gnus-summary-find-prev unread))
9641 (t (gnus-summary-find-next unread))))
9643 (defun gnus-recenter (&optional n)
9644 "Center point in window and redisplay frame.
9645 Also do horizontal recentering."
9647 (when (and gnus-auto-center-summary
9648 (not (eq gnus-auto-center-summary 'vertical)))
9649 (gnus-horizontal-recenter))
9652 (defun gnus-summary-recenter ()
9653 "Center point in the summary window.
9654 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9655 displayed, no centering will be performed."
9656 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9657 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9658 (let* ((top (cond ((< (window-height) 4) 0)
9659 ((< (window-height) 7) 1)
9661 (height (1- (window-height)))
9662 (bottom (save-excursion (goto-char (point-max))
9663 (forward-line (- height))
9665 (window (get-buffer-window (current-buffer))))
9666 ;; The user has to want it.
9667 (when gnus-auto-center-summary
9668 (when (get-buffer-window gnus-article-buffer)
9669 ;; Only do recentering when the article buffer is displayed,
9670 ;; Set the window start to either `bottom', which is the biggest
9671 ;; possible valid number, or the second line from the top,
9672 ;; whichever is the least.
9674 window (min bottom (save-excursion
9675 (forward-line (- top)) (point)))))
9676 ;; Do horizontal recentering while we're at it.
9677 (when (and (get-buffer-window (current-buffer) t)
9678 (not (eq gnus-auto-center-summary 'vertical)))
9679 (let ((selected (selected-window)))
9680 (select-window (get-buffer-window (current-buffer) t))
9681 (gnus-summary-position-point)
9682 (gnus-horizontal-recenter)
9683 (select-window selected))))))
9685 (defun gnus-horizontal-recenter ()
9686 "Recenter the current buffer horizontally."
9687 (if (< (current-column) (/ (window-width) 2))
9688 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9689 (let* ((orig (point))
9690 (end (window-end (get-buffer-window (current-buffer) t)))
9692 ;; Find the longest line currently displayed in the window.
9693 (goto-char (window-start))
9694 (while (and (not (eobp))
9697 (setq max (max max (current-column)))
9700 ;; Scroll horizontally to center (sort of) the point.
9701 (if (> max (window-width))
9703 (get-buffer-window (current-buffer) t)
9704 (min (- (current-column) (/ (window-width) 3))
9705 (+ 2 (- max (window-width)))))
9706 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9709 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9710 (defun gnus-short-group-name (group &optional levels)
9711 "Collapse GROUP name LEVELS."
9718 (while (string-match "\\." group skip)
9719 (setq skip (match-end 0)
9722 (if (string-match ":" group)
9723 (setq foreign (substring group 0 (match-end 0))
9724 group (substring group (match-end 0))))
9726 (if (and (string-match "\\." group)
9727 (> levels (- gnus-group-uncollapsed-levels 1)))
9728 (setq name (concat name (substring group 0 1))
9729 group (substring group (match-end 0))
9731 name (concat name "."))
9732 (setq name (concat foreign name group)
9736 (defun gnus-summary-jump-to-group (newsgroup)
9737 "Move point to NEWSGROUP in group mode buffer."
9738 ;; Keep update point of group mode buffer if visible.
9739 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9740 (save-window-excursion
9741 ;; Take care of tree window mode.
9742 (if (get-buffer-window gnus-group-buffer)
9743 (pop-to-buffer gnus-group-buffer))
9744 (gnus-group-jump-to-group newsgroup))
9746 ;; Take care of tree window mode.
9747 (if (get-buffer-window gnus-group-buffer)
9748 (pop-to-buffer gnus-group-buffer)
9749 (set-buffer gnus-group-buffer))
9750 (gnus-group-jump-to-group newsgroup))))
9752 ;; This function returns a list of article numbers based on the
9753 ;; difference between the ranges of read articles in this group and
9754 ;; the range of active articles.
9755 (defun gnus-list-of-unread-articles (group)
9756 (let* ((read (gnus-info-read (gnus-get-info group)))
9757 (active (gnus-active group))
9760 ;; If none are read, then all are unread.
9762 (setq first (car active))
9763 ;; If the range of read articles is a single range, then the
9764 ;; first unread article is the article after the last read
9765 ;; article. Sounds logical, doesn't it?
9766 (if (not (listp (cdr read)))
9767 (setq first (1+ (cdr read)))
9768 ;; `read' is a list of ranges.
9769 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9774 (while (< first nlast)
9775 (setq unread (cons first unread))
9776 (setq first (1+ first))))
9777 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9778 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9779 (setq read (cdr read)))))
9780 ;; And add the last unread articles.
9781 (while (<= first last)
9782 (setq unread (cons first unread))
9783 (setq first (1+ first)))
9784 ;; Return the list of unread articles.
9787 (defun gnus-list-of-read-articles (group)
9788 "Return a list of unread, unticked and non-dormant articles."
9789 (let* ((info (gnus-get-info group))
9790 (marked (gnus-info-marks info))
9791 (active (gnus-active group)))
9793 (gnus-set-difference
9794 (gnus-sorted-complement
9795 (gnus-uncompress-range active)
9796 (gnus-list-of-unread-articles group))
9798 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9799 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9801 ;; Various summary commands
9803 (defun gnus-summary-universal-argument (arg)
9804 "Perform any operation on all articles that are process/prefixed."
9806 (gnus-set-global-variables)
9807 (let ((articles (gnus-summary-work-articles arg))
9814 (substitute-command-keys
9815 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9818 (gnus-error 1 "Undefined key")
9821 (gnus-summary-goto-subject (setq article (pop articles)))
9822 (command-execute func)
9823 (gnus-summary-remove-process-mark article)))))
9824 (gnus-summary-position-point))
9826 (defun gnus-summary-toggle-truncation (&optional arg)
9827 "Toggle truncation of summary lines.
9828 With arg, turn line truncation on iff arg is positive."
9830 (setq truncate-lines
9831 (if (null arg) (not truncate-lines)
9832 (> (prefix-numeric-value arg) 0)))
9835 (defun gnus-summary-reselect-current-group (&optional all rescan)
9836 "Exit and then reselect the current newsgroup.
9837 The prefix argument ALL means to select all articles."
9839 (gnus-set-global-variables)
9840 (let ((current-subject (gnus-summary-article-number))
9841 (group gnus-newsgroup-name))
9842 (setq gnus-newsgroup-begin nil)
9844 ;; We have to adjust the point of group mode buffer because the
9845 ;; current point was moved to the next unread newsgroup by
9847 (gnus-summary-jump-to-group group)
9850 (gnus-group-get-new-news-this-group 1)))
9851 (gnus-group-read-group all t)
9852 (gnus-summary-goto-subject current-subject)))
9854 (defun gnus-summary-rescan-group (&optional all)
9855 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9857 (gnus-summary-reselect-current-group all t))
9859 (defun gnus-summary-update-info ()
9860 (let* ((group gnus-newsgroup-name))
9861 (when gnus-newsgroup-kill-headers
9862 (setq gnus-newsgroup-killed
9863 (gnus-compress-sequence
9865 (gnus-set-sorted-intersection
9866 (gnus-uncompress-range gnus-newsgroup-killed)
9867 (setq gnus-newsgroup-unselected
9868 (sort gnus-newsgroup-unselected '<)))
9869 (setq gnus-newsgroup-unreads
9870 (sort gnus-newsgroup-unreads '<))) t)))
9871 (unless (listp (cdr gnus-newsgroup-killed))
9872 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9873 (let ((headers gnus-newsgroup-headers))
9874 (run-hooks 'gnus-exit-group-hook)
9875 (unless gnus-save-score
9876 (setq gnus-newsgroup-scored nil))
9877 ;; Set the new ranges of read articles.
9878 (gnus-update-read-articles
9879 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9880 ;; Set the current article marks.
9882 ;; Do the cross-ref thing.
9883 (when gnus-use-cross-reference
9884 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9885 ;; Do adaptive scoring, and possibly save score files.
9886 (when gnus-newsgroup-adaptive
9887 (gnus-score-adaptive))
9888 (when gnus-use-scoring
9890 ;; Do not switch windows but change the buffer to work.
9891 (set-buffer gnus-group-buffer)
9892 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9893 (gnus-group-update-group group)))))
9895 (defun gnus-summary-exit (&optional temporary)
9896 "Exit reading current newsgroup, and then return to group selection mode.
9897 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9899 (gnus-set-global-variables)
9900 (gnus-kill-save-kill-buffer)
9901 (let* ((group gnus-newsgroup-name)
9902 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9904 (buf (current-buffer)))
9905 (run-hooks 'gnus-summary-prepare-exit-hook)
9906 ;; If we have several article buffers, we kill them at exit.
9907 (unless gnus-single-article-buffer
9908 (gnus-kill-buffer gnus-original-article-buffer)
9909 (setq gnus-article-current nil))
9910 (when gnus-use-cache
9911 (gnus-cache-possibly-remove-articles)
9912 (gnus-cache-save-buffers))
9913 (when gnus-use-trees
9914 (gnus-tree-close group))
9915 ;; Make all changes in this group permanent.
9917 (gnus-summary-update-info))
9918 (gnus-close-group group)
9919 ;; Make sure where I was, and go to next newsgroup.
9920 (set-buffer gnus-group-buffer)
9922 (gnus-group-jump-to-group group))
9923 (run-hooks 'gnus-summary-exit-hook)
9925 (gnus-group-next-unread-group 1))
9928 ;; If we have several article buffers, we kill them at exit.
9929 (unless gnus-single-article-buffer
9930 (gnus-kill-buffer gnus-article-buffer)
9931 (gnus-kill-buffer gnus-original-article-buffer)
9932 (setq gnus-article-current nil))
9934 (if (not gnus-kill-summary-on-exit)
9935 (gnus-deaden-summary)
9936 ;; We set all buffer-local variables to nil. It is unclear why
9937 ;; this is needed, but if we don't, buffer-local variables are
9938 ;; not garbage-collected, it seems. This would the lead to en
9939 ;; ever-growing Emacs.
9940 (gnus-summary-clear-local-variables)
9941 (when (get-buffer gnus-article-buffer)
9942 (bury-buffer gnus-article-buffer))
9943 ;; We clear the global counterparts of the buffer-local
9944 ;; variables as well, just to be on the safe side.
9945 (gnus-configure-windows 'group 'force)
9946 (gnus-summary-clear-local-variables)
9947 ;; Return to group mode buffer.
9948 (if (eq mode 'gnus-summary-mode)
9949 (gnus-kill-buffer buf)))
9950 (setq gnus-current-select-method gnus-select-method)
9951 (pop-to-buffer gnus-group-buffer)
9952 ;; Clear the current group name.
9953 (if (not quit-config)
9955 (gnus-group-jump-to-group group)
9956 (gnus-group-next-unread-group 1)
9957 (gnus-configure-windows 'group 'force))
9958 (if (not (buffer-name (car quit-config)))
9959 (gnus-configure-windows 'group 'force)
9960 (set-buffer (car quit-config))
9961 (and (eq major-mode 'gnus-summary-mode)
9962 (gnus-set-global-variables))
9963 (gnus-configure-windows (cdr quit-config))))
9965 (setq gnus-newsgroup-name nil)))))
9967 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9968 (defun gnus-summary-exit-no-update (&optional no-questions)
9969 "Quit reading current newsgroup without updating read article info."
9971 (gnus-set-global-variables)
9972 (let* ((group gnus-newsgroup-name)
9973 (quit-config (gnus-group-quit-config group)))
9974 (when (or no-questions
9976 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9977 ;; If we have several article buffers, we kill them at exit.
9978 (unless gnus-single-article-buffer
9979 (gnus-kill-buffer gnus-article-buffer)
9980 (gnus-kill-buffer gnus-original-article-buffer)
9981 (setq gnus-article-current nil))
9982 (if (not gnus-kill-summary-on-exit)
9983 (gnus-deaden-summary)
9984 (gnus-close-group group)
9985 (gnus-summary-clear-local-variables)
9986 (set-buffer gnus-group-buffer)
9987 (gnus-summary-clear-local-variables)
9988 (when (get-buffer gnus-summary-buffer)
9989 (kill-buffer gnus-summary-buffer)))
9990 (unless gnus-single-article-buffer
9991 (setq gnus-article-current nil))
9992 (when gnus-use-trees
9993 (gnus-tree-close group))
9994 (when (get-buffer gnus-article-buffer)
9995 (bury-buffer gnus-article-buffer))
9996 ;; Return to the group buffer.
9997 (gnus-configure-windows 'group 'force)
9998 ;; Clear the current group name.
9999 (setq gnus-newsgroup-name nil)
10000 (when (equal (gnus-group-group-name) group)
10001 (gnus-group-next-unread-group 1))
10003 (if (not (buffer-name (car quit-config)))
10004 (gnus-configure-windows 'group 'force)
10005 (set-buffer (car quit-config))
10006 (when (eq major-mode 'gnus-summary-mode)
10007 (gnus-set-global-variables))
10008 (gnus-configure-windows (cdr quit-config)))))))
10010 ;;; Dead summaries.
10012 (defvar gnus-dead-summary-mode-map nil)
10014 (if gnus-dead-summary-mode-map
10016 (setq gnus-dead-summary-mode-map (make-keymap))
10017 (suppress-keymap gnus-dead-summary-mode-map)
10018 (substitute-key-definition
10019 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
10020 (let ((keys '("\C-d" "\r" "\177")))
10022 (define-key gnus-dead-summary-mode-map
10023 (pop keys) 'gnus-summary-wake-up-the-dead))))
10025 (defvar gnus-dead-summary-mode nil
10026 "Minor mode for Gnus summary buffers.")
10028 (defun gnus-dead-summary-mode (&optional arg)
10029 "Minor mode for Gnus summary buffers."
10031 (when (eq major-mode 'gnus-summary-mode)
10032 (make-local-variable 'gnus-dead-summary-mode)
10033 (setq gnus-dead-summary-mode
10034 (if (null arg) (not gnus-dead-summary-mode)
10035 (> (prefix-numeric-value arg) 0)))
10036 (when gnus-dead-summary-mode
10037 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
10038 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
10039 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
10040 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
10041 minor-mode-map-alist)))))
10043 (defun gnus-deaden-summary ()
10044 "Make the current summary buffer into a dead summary buffer."
10045 ;; Kill any previous dead summary buffer.
10046 (when (and gnus-dead-summary
10047 (buffer-name gnus-dead-summary))
10049 (set-buffer gnus-dead-summary)
10050 (when gnus-dead-summary-mode
10051 (kill-buffer (current-buffer)))))
10052 ;; Make this the current dead summary.
10053 (setq gnus-dead-summary (current-buffer))
10054 (gnus-dead-summary-mode 1)
10055 (let ((name (buffer-name)))
10056 (when (string-match "Summary" name)
10058 (concat (substring name 0 (match-beginning 0)) "Dead "
10059 (substring name (match-beginning 0))) t))))
10061 (defun gnus-kill-or-deaden-summary (buffer)
10062 "Kill or deaden the summary BUFFER."
10063 (when (and (buffer-name buffer)
10064 (not gnus-single-article-buffer))
10066 (set-buffer buffer)
10067 (gnus-kill-buffer gnus-article-buffer)
10068 (gnus-kill-buffer gnus-original-article-buffer)))
10069 (cond (gnus-kill-summary-on-exit
10070 (when (and gnus-use-trees
10071 (and (get-buffer buffer)
10072 (buffer-name (get-buffer buffer))))
10074 (set-buffer (get-buffer buffer))
10075 (gnus-tree-close gnus-newsgroup-name)))
10076 (gnus-kill-buffer buffer))
10077 ((and (get-buffer buffer)
10078 (buffer-name (get-buffer buffer)))
10080 (set-buffer buffer)
10081 (gnus-deaden-summary)))))
10083 (defun gnus-summary-wake-up-the-dead (&rest args)
10084 "Wake up the dead summary buffer."
10086 (gnus-dead-summary-mode -1)
10087 (let ((name (buffer-name)))
10088 (when (string-match "Dead " name)
10090 (concat (substring name 0 (match-beginning 0))
10091 (substring name (match-end 0))) t)))
10092 (gnus-message 3 "This dead summary is now alive again"))
10094 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
10095 (defun gnus-summary-fetch-faq (&optional faq-dir)
10096 "Fetch the FAQ for the current group.
10097 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
10101 (if current-prefix-arg
10103 "Faq dir: " (and (listp gnus-group-faq-directory)
10104 gnus-group-faq-directory)))))
10105 (let (gnus-faq-buffer)
10106 (and (setq gnus-faq-buffer
10107 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
10108 (gnus-configure-windows 'summary-faq))))
10110 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10111 (defun gnus-summary-describe-group (&optional force)
10112 "Describe the current newsgroup."
10114 (gnus-group-describe-group force gnus-newsgroup-name))
10116 (defun gnus-summary-describe-briefly ()
10117 "Describe summary mode commands briefly."
10120 (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")))
10122 ;; Walking around group mode buffer from summary mode.
10124 (defun gnus-summary-next-group (&optional no-article target-group backward)
10125 "Exit current newsgroup and then select next unread newsgroup.
10126 If prefix argument NO-ARTICLE is non-nil, no article is selected
10127 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
10128 previous group instead."
10130 (gnus-set-global-variables)
10131 (let ((current-group gnus-newsgroup-name)
10132 (current-buffer (current-buffer))
10134 ;; First we semi-exit this group to update Xrefs and all variables.
10135 ;; We can't do a real exit, because the window conf must remain
10136 ;; the same in case the user is prompted for info, and we don't
10137 ;; want the window conf to change before that...
10138 (gnus-summary-exit t)
10139 (while (not entered)
10140 ;; Then we find what group we are supposed to enter.
10141 (set-buffer gnus-group-buffer)
10142 (gnus-group-jump-to-group current-group)
10145 (if (eq gnus-keep-same-level 'best)
10146 (gnus-summary-best-group gnus-newsgroup-name)
10147 (gnus-summary-search-group backward gnus-keep-same-level))))
10148 (if (not target-group)
10149 ;; There are no further groups, so we return to the group
10152 (gnus-message 5 "Returning to the group buffer")
10154 (set-buffer current-buffer)
10155 (gnus-summary-exit))
10156 ;; We try to enter the target group.
10157 (gnus-group-jump-to-group target-group)
10158 (let ((unreads (gnus-group-group-unread)))
10159 (if (and (or (eq t unreads)
10160 (and unreads (not (zerop unreads))))
10161 (gnus-summary-read-group
10162 target-group nil no-article current-buffer))
10164 (setq current-group target-group
10165 target-group nil)))))))
10167 (defun gnus-summary-prev-group (&optional no-article)
10168 "Exit current newsgroup and then select previous unread newsgroup.
10169 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
10171 (gnus-summary-next-group no-article nil t))
10173 ;; Walking around summary lines.
10175 (defun gnus-summary-first-subject (&optional unread)
10176 "Go to the first unread subject.
10177 If UNREAD is non-nil, go to the first unread article.
10178 Returns the article selected or nil if there are no unread articles."
10183 ((null gnus-newsgroup-data)
10184 (gnus-message 3 "No articles in the group")
10186 ;; Pick the first article.
10188 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
10189 (gnus-data-number (car gnus-newsgroup-data)))
10190 ;; No unread articles.
10191 ((null gnus-newsgroup-unreads)
10192 (gnus-message 3 "No more unread articles")
10194 ;; Find the first unread article.
10196 (let ((data gnus-newsgroup-data))
10198 (not (gnus-data-unread-p (car data))))
10199 (setq data (cdr data)))
10202 (goto-char (gnus-data-pos (car data)))
10203 (gnus-data-number (car data)))))))
10204 (gnus-summary-position-point)))
10206 (defun gnus-summary-next-subject (n &optional unread dont-display)
10207 "Go to next N'th summary line.
10208 If N is negative, go to the previous N'th subject line.
10209 If UNREAD is non-nil, only unread articles are selected.
10210 The difference between N and the actual number of steps taken is
10213 (let ((backward (< n 0))
10215 (while (and (> n 0)
10217 (gnus-summary-find-prev unread)
10218 (gnus-summary-find-next unread)))
10220 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10221 (if unread " unread" "")))
10222 (unless dont-display
10223 (gnus-summary-recenter)
10224 (gnus-summary-position-point))
10227 (defun gnus-summary-next-unread-subject (n)
10228 "Go to next N'th unread summary line."
10230 (gnus-summary-next-subject n t))
10232 (defun gnus-summary-prev-subject (n &optional unread)
10233 "Go to previous N'th summary line.
10234 If optional argument UNREAD is non-nil, only unread article is selected."
10236 (gnus-summary-next-subject (- n) unread))
10238 (defun gnus-summary-prev-unread-subject (n)
10239 "Go to previous N'th unread summary line."
10241 (gnus-summary-next-subject (- n) t))
10243 (defun gnus-summary-goto-subject (article &optional force silent)
10244 "Go the subject line of ARTICLE.
10245 If FORCE, also allow jumping to articles not currently shown."
10247 (data (gnus-data-find article)))
10248 ;; We read in the article if we have to.
10251 (gnus-summary-insert-subject article (and (vectorp force) force) t)
10252 (setq data (gnus-data-find article)))
10257 (gnus-message 3 "Can't find article %d" article))
10259 (goto-char (gnus-data-pos data))
10262 ;; Walking around summary lines with displaying articles.
10264 (defun gnus-summary-expand-window (&optional arg)
10265 "Make the summary buffer take up the entire Emacs frame.
10266 Given a prefix, will force an `article' buffer configuration."
10268 (gnus-set-global-variables)
10270 (gnus-configure-windows 'article 'force)
10271 (gnus-configure-windows 'summary 'force)))
10273 (defun gnus-summary-display-article (article &optional all-header)
10274 "Display ARTICLE in article buffer."
10275 (gnus-set-global-variables)
10279 (if gnus-summary-display-article-function
10280 (funcall gnus-summary-display-article-function article all-header)
10281 (gnus-article-prepare article all-header))
10282 (run-hooks 'gnus-select-article-hook)
10283 (unless (zerop gnus-current-article)
10284 (gnus-summary-goto-subject gnus-current-article))
10285 (gnus-summary-recenter)
10286 (when gnus-use-trees
10287 (gnus-possibly-generate-tree article)
10288 (gnus-highlight-selected-tree article))
10289 ;; Successfully display article.
10290 (gnus-article-set-window-start
10291 (cdr (assq article gnus-newsgroup-bookmarks))))))
10293 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10294 "Select the current article.
10295 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10296 non-nil, the article will be re-fetched even if it already present in
10297 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10299 ;; Make sure we are in the summary buffer to work around bbdb bug.
10300 (unless (eq major-mode 'gnus-summary-mode)
10301 (set-buffer gnus-summary-buffer))
10302 (let ((article (or article (gnus-summary-article-number)))
10303 (all-headers (not (not all-headers))) ;Must be T or NIL.
10304 gnus-summary-display-article-function
10307 (gnus-summary-article-pseudo-p article)
10308 (error "This is a pseudo-article."))
10311 (set-buffer gnus-summary-buffer)
10312 (if (or (and gnus-single-article-buffer
10313 (or (null gnus-current-article)
10314 (null gnus-article-current)
10315 (null (get-buffer gnus-article-buffer))
10316 (not (eq article (cdr gnus-article-current)))
10317 (not (equal (car gnus-article-current)
10318 gnus-newsgroup-name))))
10319 (and (not gnus-single-article-buffer)
10320 (or (null gnus-current-article)
10321 (not (eq gnus-current-article article))))
10323 ;; The requested article is different from the current article.
10325 (gnus-summary-display-article article all-headers)
10326 (setq did article))
10327 (if (or all-headers gnus-show-all-headers)
10328 (gnus-article-show-all-headers))
10331 (gnus-article-set-window-start
10332 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10334 (defun gnus-summary-set-current-mark (&optional current-mark)
10335 "Obsolete function."
10338 (defun gnus-summary-next-article (&optional unread subject backward push)
10339 "Select the next article.
10340 If UNREAD, only unread articles are selected.
10341 If SUBJECT, only articles with SUBJECT are selected.
10342 If BACKWARD, the previous article is selected instead of the next."
10344 (gnus-set-global-variables)
10346 ;; Is there such an article?
10347 ((and (gnus-summary-search-forward unread subject backward)
10348 (or (gnus-summary-display-article (gnus-summary-article-number))
10349 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10350 (gnus-summary-position-point))
10351 ;; If not, we try the first unread, if that is wanted.
10353 gnus-auto-select-same
10354 (or (gnus-summary-first-unread-article)
10355 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10356 (gnus-summary-position-point)
10357 (gnus-message 6 "Wrapped"))
10358 ;; Try to get next/previous article not displayed in this group.
10359 ((and gnus-auto-extend-newsgroup
10360 (not unread) (not subject))
10361 (gnus-summary-goto-article
10362 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10364 ;; Go to next/previous group.
10366 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10367 (gnus-summary-jump-to-group gnus-newsgroup-name))
10368 (let ((cmd last-command-char)
10370 (if (eq gnus-keep-same-level 'best)
10371 (gnus-summary-best-group gnus-newsgroup-name)
10372 (gnus-summary-search-group backward gnus-keep-same-level))))
10373 ;; For some reason, the group window gets selected. We change
10375 (select-window (get-buffer-window (current-buffer)))
10376 ;; Select next unread newsgroup automagically.
10378 ((not gnus-auto-select-next)
10379 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10380 ((or (eq gnus-auto-select-next 'quietly)
10381 (and (eq gnus-auto-select-next 'slightly-quietly)
10383 (and (eq gnus-auto-select-next 'almost-quietly)
10384 (gnus-summary-last-article-p)))
10386 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10387 (gnus-summary-exit)
10388 (gnus-message 7 "No more%s articles (%s)..."
10389 (if unread " unread" "")
10390 (if group (concat "selecting " group)
10392 (gnus-summary-next-group nil group backward)))
10394 (gnus-summary-walk-group-buffer
10395 gnus-newsgroup-name cmd unread backward)))))))
10397 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10398 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10399 (?\C-p (gnus-group-prev-unread-group 1))))
10400 keve key group ended)
10402 (set-buffer gnus-group-buffer)
10403 (gnus-summary-jump-to-group from-group)
10405 (if (eq gnus-keep-same-level 'best)
10406 (gnus-summary-best-group gnus-newsgroup-name)
10407 (gnus-summary-search-group backward gnus-keep-same-level))))
10410 5 "No more%s articles%s" (if unread " unread" "")
10412 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10413 (format " (Type %s for %s [%s])"
10414 (single-key-description cmd) group
10415 (car (gnus-gethash group gnus-newsrc-hashtb)))
10416 (format " (Type %s to exit %s)"
10417 (single-key-description cmd)
10418 gnus-newsgroup-name)))
10419 ;; Confirm auto selection.
10420 (setq key (car (setq keve (gnus-read-event-char))))
10423 ((assq key keystrokes)
10424 (let ((obuf (current-buffer)))
10425 (switch-to-buffer gnus-group-buffer)
10427 (gnus-group-jump-to-group group))
10428 (eval (cadr (assq key keystrokes)))
10429 (setq group (gnus-group-group-name))
10430 (switch-to-buffer obuf))
10433 (if (or (not group)
10434 (gnus-ephemeral-group-p gnus-newsgroup-name))
10435 (gnus-summary-exit)
10436 (gnus-summary-next-group nil group backward)))
10438 (push (cdr keve) unread-command-events))))))
10440 (defun gnus-read-event-char ()
10441 "Get the next event."
10442 (let ((event (read-event)))
10443 (cons (and (numberp event) event) event)))
10445 (defun gnus-summary-next-unread-article ()
10446 "Select unread article after current one."
10448 (gnus-summary-next-article t (and gnus-auto-select-same
10449 (gnus-summary-article-subject))))
10451 (defun gnus-summary-prev-article (&optional unread subject)
10452 "Select the article after the current one.
10453 If UNREAD is non-nil, only unread articles are selected."
10455 (gnus-summary-next-article unread subject t))
10457 (defun gnus-summary-prev-unread-article ()