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 It's probably not a very effective to change this variable once you've
150 run Gnus once. After doing that, you must edit this server from the
153 (defvar gnus-refer-article-method nil
154 "*Preferred method for fetching an article by Message-ID.
155 If you are reading news from the local spool (with nnspool), fetching
156 articles by Message-ID is painfully slow. By setting this method to an
157 nntp method, you might get acceptable results.
159 The value of this variable must be a valid select method as discussed
160 in the documentation of `gnus-select-method'.")
162 (defvar gnus-secondary-select-methods nil
163 "*A list of secondary methods that will be used for reading news.
164 This is a list where each element is a complete select method (see
165 `gnus-select-method').
167 If, for instance, you want to read your mail with the nnml backend,
168 you could set this variable:
170 (setq gnus-secondary-select-methods '((nnml \"\")))")
172 (defvar gnus-secondary-servers nil
173 "*List of NNTP servers that the user can choose between interactively.
174 To make Gnus query you for a server, you have to give `gnus' a
175 non-numeric prefix - `C-u M-x gnus', in short.")
177 (defvar gnus-nntp-server nil
178 "*The name of the host running the NNTP server.
179 This variable is semi-obsolete. Use the `gnus-select-method'
182 (defvar gnus-startup-file "~/.newsrc"
183 "*Your `.newsrc' file.
184 `.newsrc-SERVER' will be used instead if that exists.")
186 (defvar gnus-init-file "~/.gnus"
187 "*Your Gnus elisp startup file.
188 If a file with the .el or .elc suffixes exist, it will be read
191 (defvar gnus-group-faq-directory
192 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
193 "/ftp@sunsite.auc.dk:/pub/usenet/"
194 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
195 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
196 "/ftp@rtfm.mit.edu:/pub/usenet/"
197 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
198 "/ftp@ftp.sunet.se:/pub/usenet/"
199 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
200 "/ftp@hwarang.postech.ac.kr:/pub/usenet/"
201 "/ftp@ftp.hk.super.net:/mirror/faqs/")
202 "*Directory where the group FAQs are stored.
203 This will most commonly be on a remote machine, and the file will be
206 This variable can also be a list of directories. In that case, the
207 first element in the list will be used by default, and the others will
208 be used as backup sites.
210 Note that Gnus uses an aol machine as the default directory. If this
211 feels fundamentally unclean, just think of it as a way to finally get
212 something of value back from them.
214 If the default site is too slow, try one of these:
216 North America: mirrors.aol.com /pub/rtfm/usenet
217 ftp.seas.gwu.edu /pub/rtfm
218 rtfm.mit.edu /pub/usenet
219 Europe: ftp.uni-paderborn.de /pub/FAQ
220 src.doc.ic.ac.uk /usenet/news-FAQS
221 ftp.sunet.se /pub/usenet
222 sunsite.auc.dk /pub/usenet
223 Asia: nctuccca.edu.tw /USENET/FAQ
224 hwarang.postech.ac.kr /pub/usenet
225 ftp.hk.super.net /mirror/faqs")
227 (defvar gnus-group-archive-directory
228 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
229 "*The address of the (ding) archives.")
231 (defvar gnus-group-recent-archive-directory
232 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
233 "*The address of the most recent (ding) articles.")
235 (defvar gnus-default-subscribed-newsgroups nil
236 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
237 It should be a list of strings.
238 If it is `t', Gnus will not do anything special the first time it is
239 started; it'll just use the normal newsgroups subscription methods.")
241 (defvar gnus-use-cross-reference t
242 "*Non-nil means that cross referenced articles will be marked as read.
243 If nil, ignore cross references. If t, mark articles as read in
244 subscribed newsgroups. If neither t nor nil, mark as read in all
247 (defvar gnus-single-article-buffer t
248 "*If non-nil, display all articles in the same buffer.
249 If nil, each group will get its own article buffer.")
251 (defvar gnus-use-dribble-file t
252 "*Non-nil means that Gnus will use a dribble file to store user updates.
253 If Emacs should crash without saving the .newsrc files, complete
254 information can be restored from the dribble file.")
256 (defvar gnus-dribble-directory nil
257 "*The directory where dribble files will be saved.
258 If this variable is nil, the directory where the .newsrc files are
259 saved will be used.")
261 (defvar gnus-asynchronous nil
262 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
264 (defvar gnus-kill-summary-on-exit t
265 "*If non-nil, kill the summary buffer when you exit from it.
266 If nil, the summary will become a \"*Dead Summary*\" buffer, and
267 it will be killed sometime later.")
269 (defvar gnus-large-newsgroup 200
270 "*The number of articles which indicates a large newsgroup.
271 If the number of articles in a newsgroup is greater than this value,
272 confirmation is required for selecting the newsgroup.")
274 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
275 (defvar gnus-no-groups-message "No news is horrible news"
276 "*Message displayed by Gnus when no groups are available.")
278 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
279 "*Non-nil means that the default name of a file to save articles in is the group name.
280 If it's nil, the directory form of the group name is used instead.
282 If this variable is a list, and the list contains the element
283 `not-score', long file names will not be used for score files; if it
284 contains the element `not-save', long file names will not be used for
285 saving; and if it contains the element `not-kill', long file names
286 will not be used for kill files.
288 Note that the default for this variable varies according to what system
289 type you're using. On `usg-unix-v' and `xenix' this variable defaults
290 to nil while on all other systems it defaults to t.")
292 (defvar gnus-article-save-directory gnus-directory
293 "*Name of the directory articles will be saved in (default \"~/News\").")
295 (defvar gnus-kill-files-directory gnus-directory
296 "*Name of the directory where kill files will be stored (default \"~/News\").")
298 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
299 "*A function to save articles in your favorite format.
300 The function must be interactively callable (in other words, it must
301 be an Emacs command).
303 Gnus provides the following functions:
305 * gnus-summary-save-in-rmail (Rmail format)
306 * gnus-summary-save-in-mail (Unix mail format)
307 * gnus-summary-save-in-folder (MH folder)
308 * gnus-summary-save-in-file (article format).
309 * gnus-summary-save-in-vm (use VM's folder format).")
311 (defvar gnus-prompt-before-saving 'always
312 "*This variable says how much prompting is to be done when saving articles.
313 If it is nil, no prompting will be done, and the articles will be
314 saved to the default files. If this variable is `always', each and
315 every article that is saved will be preceded by a prompt, even when
316 saving large batches of articles. If this variable is neither nil not
317 `always', there the user will be prompted once for a file name for
318 each invocation of the saving commands.")
320 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
321 "*A function generating a file name to save articles in Rmail format.
322 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
324 (defvar gnus-mail-save-name (function gnus-plain-save-name)
325 "*A function generating a file name to save articles in Unix mail format.
326 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
328 (defvar gnus-folder-save-name (function gnus-folder-save-name)
329 "*A function generating a file name to save articles in MH folder.
330 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
332 (defvar gnus-file-save-name (function gnus-numeric-save-name)
333 "*A function generating a file name to save articles in article format.
334 The function is called with NEWSGROUP, HEADERS, and optional
337 (defvar gnus-split-methods
338 '((gnus-article-archive-name))
339 "*Variable used to suggest where articles are to be saved.
340 For instance, if you would like to save articles related to Gnus in
341 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
342 you could set this variable to something like:
344 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
345 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
347 This variable is an alist where the where the key is the match and the
348 value is a list of possible files to save in if the match is non-nil.
350 If the match is a string, it is used as a regexp match on the
351 article. If the match is a symbol, that symbol will be funcalled
352 from the buffer of the article to be saved with the newsgroup as the
353 parameter. If it is a list, it will be evaled in the same buffer.
355 If this form or function returns a string, this string will be used as
356 a possible file name; and if it returns a non-nil list, that list will
357 be used as possible file names.")
359 (defvar gnus-move-split-methods nil
360 "*Variable used to suggest where articles are to be moved to.
361 It uses the same syntax as the `gnus-split-methods' variable.")
363 (defvar gnus-save-score nil
364 "*If non-nil, save group scoring info.")
366 (defvar gnus-use-adaptive-scoring nil
367 "*If non-nil, use some adaptive scoring scheme.")
369 (defvar gnus-use-cache 'passive
370 "*If nil, Gnus will ignore the article cache.
371 If `passive', it will allow entering (and reading) articles
372 explicitly entered into the cache. If anything else, use the
373 cache to the full extent of the law.")
375 (defvar gnus-use-trees nil
376 "*If non-nil, display a thread tree buffer.")
378 (defvar gnus-use-grouplens nil
379 "*If non-nil, use GroupLens ratings.")
381 (defvar gnus-keep-backlog nil
382 "*If non-nil, Gnus will keep read articles for later re-retrieval.
383 If it is a number N, then Gnus will only keep the last N articles
384 read. If it is neither nil nor a number, Gnus will keep all read
385 articles. This is not a good idea.")
387 (defvar gnus-use-nocem nil
388 "*If non-nil, Gnus will read NoCeM cancel messages.")
390 (defvar gnus-use-demon nil
391 "If non-nil, Gnus might use some demons.")
393 (defvar gnus-use-scoring t
394 "*If non-nil, enable scoring.")
396 (defvar gnus-use-picons nil
397 "*If non-nil, display picons.")
399 (defvar gnus-fetch-old-headers nil
400 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
401 If an unread article in the group refers to an older, already read (or
402 just marked as read) article, the old article will not normally be
403 displayed in the Summary buffer. If this variable is non-nil, Gnus
404 will attempt to grab the headers to the old articles, and thereby
405 build complete threads. If it has the value `some', only enough
406 headers to connect otherwise loose threads will be displayed.
407 This variable can also be a number. In that case, no more than that
408 number of old headers will be fetched.
410 The server has to support NOV for any of this to work.")
413 ;(defvar gnus-visual t
414 ; "*If non-nil, will do various highlighting.
415 ;If nil, no mouse highlights (or any other highlights) will be
416 ;performed. This might speed up Gnus some when generating large group
417 ;and summary buffers.")
419 (defvar gnus-novice-user t
420 "*Non-nil means that you are a usenet novice.
421 If non-nil, verbose messages may be displayed and confirmations may be
424 (defvar gnus-expert-user nil
425 "*Non-nil means that you will never be asked for confirmation about anything.
426 And that means *anything*.")
428 (defvar gnus-verbose 7
429 "*Integer that says how verbose Gnus should be.
430 The higher the number, the more messages Gnus will flash to say what
431 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
432 display most important messages; and at ten, Gnus will keep on
433 jabbering all the time.")
435 (defvar gnus-keep-same-level nil
436 "*Non-nil means that the next newsgroup after the current will be on the same level.
437 When you type, for instance, `n' after reading the last article in the
438 current newsgroup, you will go to the next newsgroup. If this variable
439 is nil, the next newsgroup will be the next from the group
441 If this variable is non-nil, Gnus will either put you in the
442 next newsgroup with the same level, or, if no such newsgroup is
443 available, the next newsgroup with the lowest possible level higher
444 than the current level.
445 If this variable is `best', Gnus will make the next newsgroup the one
446 with the best level.")
448 (defvar gnus-summary-make-false-root 'adopt
449 "*nil means that Gnus won't gather loose threads.
450 If the root of a thread has expired or been read in a previous
451 session, the information necessary to build a complete thread has been
452 lost. Instead of having many small sub-threads from this original thread
453 scattered all over the summary buffer, Gnus can gather them.
455 If non-nil, Gnus will try to gather all loose sub-threads from an
456 original thread into one large thread.
458 If this variable is non-nil, it should be one of `none', `adopt',
461 If this variable is `none', Gnus will not make a false root, but just
462 present the sub-threads after another.
463 If this variable is `dummy', Gnus will create a dummy root that will
464 have all the sub-threads as children.
465 If this variable is `adopt', Gnus will make one of the \"children\"
466 the parent and mark all the step-children as such.
467 If this variable is `empty', the \"children\" are printed with empty
468 subject fields. (Or rather, they will be printed with a string
469 given by the `gnus-summary-same-subject' variable.)")
471 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
472 "*A regexp to match subjects to be excluded from loose thread gathering.
473 As loose thread gathering is done on subjects only, that means that
474 there can be many false gatherings performed. By rooting out certain
475 common subjects, gathering might become saner.")
477 (defvar gnus-summary-gather-subject-limit nil
478 "*Maximum length of subject comparisons when gathering loose threads.
479 Use nil to compare full subjects. Setting this variable to a low
480 number will help gather threads that have been corrupted by
481 newsreaders chopping off subject lines, but it might also mean that
482 unrelated articles that have subject that happen to begin with the
483 same few characters will be incorrectly gathered.
485 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
486 comparing subjects.")
488 (defvar gnus-simplify-ignored-prefixes nil
489 "*Regexp, matches for which are removed from subject lines when simplifying.")
491 (defvar gnus-build-sparse-threads nil
492 "*If non-nil, fill in the gaps in threads.
493 If `some', only fill in the gaps that are needed to tie loose threads
494 together. If `more', fill in all leaf nodes that Gnus can find. If
495 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
497 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
498 "Function used for gathering loose threads.
499 There are two pre-defined functions: `gnus-gather-threads-by-subject',
500 which only takes Subjects into consideration; and
501 `gnus-gather-threads-by-references', which compared the References
502 headers of the articles to find matches.")
504 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
505 (defvar gnus-summary-same-subject ""
506 "*String indicating that the current article has the same subject as the previous.
507 This variable will only be used if the value of
508 `gnus-summary-make-false-root' is `empty'.")
510 (defvar gnus-summary-goto-unread t
511 "*If non-nil, marking commands will go to the next unread article.
512 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
513 whether it is read or not.")
515 (defvar gnus-group-goto-unread t
516 "*If non-nil, movement commands will go to the next unread and subscribed group.")
518 (defvar gnus-goto-next-group-when-activating t
519 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
521 (defvar gnus-check-new-newsgroups t
522 "*Non-nil means that Gnus will add new newsgroups at startup.
523 If this variable is `ask-server', Gnus will ask the server for new
524 groups since the last time it checked. This means that the killed list
525 is no longer necessary, so you could set `gnus-save-killed-list' to
528 A variant is to have this variable be a list of select methods. Gnus
529 will then use the `ask-server' method on all these select methods to
530 query for new groups from all those servers.
533 (setq gnus-check-new-newsgroups
534 '((nntp \"some.server\") (nntp \"other.server\")))
536 If this variable is nil, then you have to tell Gnus explicitly to
537 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
539 (defvar gnus-check-bogus-newsgroups nil
540 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
541 If this variable is nil, then you have to tell Gnus explicitly to
542 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
544 (defvar gnus-read-active-file t
545 "*Non-nil means that Gnus will read the entire active file at startup.
546 If this variable is nil, Gnus will only know about the groups in your
549 If this variable is `some', Gnus will try to only read the relevant
550 parts of the active file from the server. Not all servers support
551 this, and it might be quite slow with other servers, but this should
552 generally be faster than both the t and nil value.
554 If you set this variable to nil or `some', you probably still want to
555 be told about new newsgroups that arrive. To do that, set
556 `gnus-check-new-newsgroups' to `ask-server'. This may not work
557 properly with all servers.")
559 (defvar gnus-level-subscribed 5
560 "*Groups with levels less than or equal to this variable are subscribed.")
562 (defvar gnus-level-unsubscribed 7
563 "*Groups with levels less than or equal to this variable are unsubscribed.
564 Groups with levels less than `gnus-level-subscribed', which should be
565 less than this variable, are subscribed.")
567 (defvar gnus-level-zombie 8
568 "*Groups with this level are zombie groups.")
570 (defvar gnus-level-killed 9
571 "*Groups with this level are killed.")
573 (defvar gnus-level-default-subscribed 3
574 "*New subscribed groups will be subscribed at this level.")
576 (defvar gnus-level-default-unsubscribed 6
577 "*New unsubscribed groups will be unsubscribed at this level.")
579 (defvar gnus-activate-level (1+ gnus-level-subscribed)
580 "*Groups higher than this level won't be activated on startup.
581 Setting this variable to something log might save lots of time when
582 you have many groups that you aren't interested in.")
584 (defvar gnus-activate-foreign-newsgroups 4
585 "*If nil, Gnus will not check foreign newsgroups at startup.
586 If it is non-nil, it should be a number between one and nine. Foreign
587 newsgroups that have a level lower or equal to this number will be
588 activated on startup. For instance, if you want to active all
589 subscribed newsgroups, but not the rest, you'd set this variable to
590 `gnus-level-subscribed'.
592 If you subscribe to lots of newsgroups from different servers, startup
593 might take a while. By setting this variable to nil, you'll save time,
594 but you won't be told how many unread articles there are in the
597 (defvar gnus-save-newsrc-file t
598 "*Non-nil means that Gnus will save the `.newsrc' file.
599 Gnus always saves its own startup file, which is called
600 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
601 be readily understood by other newsreaders. If you don't plan on
602 using other newsreaders, set this variable to nil to save some time on
605 (defvar gnus-save-killed-list t
606 "*If non-nil, save the list of killed groups to the startup file.
607 If you set this variable to nil, you'll save both time (when starting
608 and quitting) and space (both memory and disk), but it will also mean
609 that Gnus has no record of which groups are new and which are old, so
610 the automatic new newsgroups subscription methods become meaningless.
612 You should always set `gnus-check-new-newsgroups' to `ask-server' or
613 nil if you set this variable to nil.")
615 (defvar gnus-interactive-catchup t
616 "*If non-nil, require your confirmation when catching up a group.")
618 (defvar gnus-interactive-exit t
619 "*If non-nil, require your confirmation when exiting Gnus.")
621 (defvar gnus-kill-killed t
622 "*If non-nil, Gnus will apply kill files to already killed articles.
623 If it is nil, Gnus will never apply kill files to articles that have
624 already been through the scoring process, which might very well save lots
627 (defvar gnus-extract-address-components 'gnus-extract-address-components
628 "*Function for extracting address components from a From header.
629 Two pre-defined function exist: `gnus-extract-address-components',
630 which is the default, quite fast, and too simplistic solution, and
631 `mail-extract-address-components', which works much better, but is
634 (defvar gnus-summary-default-score 0
635 "*Default article score level.
636 If this variable is nil, scoring will be disabled.")
638 (defvar gnus-summary-zcore-fuzz 0
639 "*Fuzziness factor for the zcore in the summary buffer.
640 Articles with scores closer than this to `gnus-summary-default-score'
641 will not be marked.")
643 (defvar gnus-simplify-subject-fuzzy-regexp nil
644 "*Strings to be removed when doing fuzzy matches.
645 This can either be a regular expression or list of regular expressions
646 that will be removed from subject strings if fuzzy subject
647 simplification is selected.")
649 (defvar gnus-permanently-visible-groups nil
650 "*Regexp to match groups that should always be listed in the group buffer.
651 This means that they will still be listed when there are no unread
652 articles in the groups.")
654 (defvar gnus-list-groups-with-ticked-articles t
655 "*If non-nil, list groups that have only ticked articles.
656 If nil, only list groups that have unread articles.")
658 (defvar gnus-group-default-list-level gnus-level-subscribed
659 "*Default listing level.
660 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
662 (defvar gnus-group-use-permanent-levels nil
663 "*If non-nil, once you set a level, Gnus will use this level.")
665 (defvar gnus-group-list-inactive-groups t
666 "*If non-nil, inactive groups will be listed.")
668 (defvar gnus-show-mime nil
669 "*If non-nil, do mime processing of articles.
670 The articles will simply be fed to the function given by
671 `gnus-show-mime-method'.")
673 (defvar gnus-strict-mime t
674 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
676 (defvar gnus-show-mime-method 'metamail-buffer
677 "*Function to process a MIME message.
678 The function is called from the article buffer.")
680 (defvar gnus-decode-encoded-word-method (lambda ())
681 "*Function to decode a MIME encoded-words.
682 The function is called from the article buffer.")
684 (defvar gnus-show-threads t
685 "*If non-nil, display threads in summary mode.")
687 (defvar gnus-thread-hide-subtree nil
688 "*If non-nil, hide all threads initially.
689 If threads are hidden, you have to run the command
690 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
691 to expose hidden threads.")
693 (defvar gnus-thread-hide-killed t
694 "*If non-nil, hide killed threads automatically.")
696 (defvar gnus-thread-ignore-subject nil
697 "*If non-nil, ignore subjects and do all threading based on the Reference header.
698 If nil, which is the default, articles that have different subjects
699 from their parents will start separate threads.")
701 (defvar gnus-thread-operation-ignore-subject t
702 "*If non-nil, subjects will be ignored when doing thread commands.
703 This affects commands like `gnus-summary-kill-thread' and
704 `gnus-summary-lower-thread'.
706 If this variable is nil, articles in the same thread with different
707 subjects will not be included in the operation in question. If this
708 variable is `fuzzy', only articles that have subjects that are fuzzily
709 equal will be included.")
711 (defvar gnus-thread-indent-level 4
712 "*Number that says how much each sub-thread should be indented.")
714 (defvar gnus-ignored-newsgroups
715 (purecopy (mapconcat 'identity
716 '("^to\\." ; not "real" groups
717 "^[0-9. \t]+ " ; all digits in name
718 "[][\"#'()]" ; bogus characters
721 "*A regexp to match uninteresting newsgroups in the active file.
722 Any lines in the active file matching this regular expression are
723 removed from the newsgroup list before anything else is done to it,
724 thus making them effectively non-existent.")
726 (defvar gnus-ignored-headers
727 "^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:"
728 "*All headers that match this regexp will be hidden.
729 This variable can also be a list of regexps of headers to be ignored.
730 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
732 (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-"
733 "*All headers that do not match this regexp will be hidden.
734 This variable can also be a list of regexp of headers to remain visible.
735 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
737 (defvar gnus-sorted-header-list
738 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
739 "^Cc:" "^Date:" "^Organization:")
740 "*This variable is a list of regular expressions.
741 If it is non-nil, headers that match the regular expressions will
742 be placed first in the article buffer in the sequence specified by
745 (defvar gnus-boring-article-headers
746 '(empty followup-to reply-to)
747 "*Headers that are only to be displayed if they have interesting data.
748 Possible values in this list are `empty', `newsgroups', `followup-to',
749 `reply-to', and `date'.")
751 (defvar gnus-show-all-headers nil
752 "*If non-nil, don't hide any headers.")
754 (defvar gnus-save-all-headers t
755 "*If non-nil, don't remove any headers before saving.")
757 (defvar gnus-saved-headers gnus-visible-headers
758 "*Headers to keep if `gnus-save-all-headers' is nil.
759 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
760 If that variable is nil, however, all headers that match this regexp
761 will be kept while the rest will be deleted before saving.")
763 (defvar gnus-inhibit-startup-message nil
764 "*If non-nil, the startup message will not be displayed.")
766 (defvar gnus-signature-separator "^-- *$"
767 "Regexp matching signature separator.")
769 (defvar gnus-signature-limit nil
770 "Provide a limit to what is considered a signature.
771 If it is a number, no signature may not be longer (in characters) than
772 that number. If it is a function, the function will be called without
773 any parameters, and if it returns nil, there is no signature in the
774 buffer. If it is a string, it will be used as a regexp. If it
775 matches, the text in question is not a signature.")
777 (defvar gnus-auto-extend-newsgroup t
778 "*If non-nil, extend newsgroup forward and backward when requested.")
780 (defvar gnus-auto-select-first t
781 "*If nil, don't select the first unread article when entering a group.
782 If this variable is `best', select the highest-scored unread article
783 in the group. If neither nil nor `best', select the first unread
786 If you want to prevent automatic selection of the first unread article
787 in some newsgroups, set the variable to nil in
788 `gnus-select-group-hook'.")
790 (defvar gnus-auto-select-next t
791 "*If non-nil, offer to go to the next group from the end of the previous.
792 If the value is t and the next newsgroup is empty, Gnus will exit
793 summary mode and go back to group mode. If the value is neither nil
794 nor t, Gnus will select the following unread newsgroup. In
795 particular, if the value is the symbol `quietly', the next unread
796 newsgroup will be selected without any confirmation, and if it is
797 `almost-quietly', the next group will be selected without any
798 confirmation if you are located on the last article in the group.
799 Finally, if this variable is `slightly-quietly', the `Z n' command
800 will go to the next group without confirmation.")
802 (defvar gnus-auto-select-same nil
803 "*If non-nil, select the next article with the same subject.")
805 (defvar gnus-summary-check-current nil
806 "*If non-nil, consider the current article when moving.
807 The \"unread\" movement commands will stay on the same line if the
808 current article is unread.")
810 (defvar gnus-auto-center-summary t
811 "*If non-nil, always center the current summary buffer.
812 In particular, if `vertical' do only vertical recentering. If non-nil
813 and non-`vertical', do both horizontal and vertical recentering.")
815 (defvar gnus-break-pages t
816 "*If non-nil, do page breaking on articles.
817 The page delimiter is specified by the `gnus-page-delimiter'
820 (defvar gnus-page-delimiter "^\^L"
821 "*Regexp describing what to use as article page delimiters.
822 The default value is \"^\^L\", which is a form linefeed at the
823 beginning of a line.")
825 (defvar gnus-use-full-window t
826 "*If non-nil, use the entire Emacs screen.")
828 (defvar gnus-window-configuration nil
829 "Obsolete variable. See `gnus-buffer-configuration'.")
831 (defvar gnus-window-min-width 2
832 "*Minimum width of Gnus buffers.")
834 (defvar gnus-window-min-height 1
835 "*Minimum height of Gnus buffers.")
837 (defvar gnus-buffer-configuration
841 (if gnus-carpal '(group-carpal 4))))
845 (if gnus-carpal '(summary-carpal 4))))
852 (if gnus-carpal '(summary-carpal 4))
854 (vertical ((height . 5) (width . 15)
856 (left . -1) (top . 1))
866 (if gnus-carpal '(summary-carpal 4))
867 (if gnus-use-trees '(tree 0.25))
872 (if gnus-carpal '(server-carpal 2))))
876 (if gnus-carpal '(browse-carpal 2))))
879 (message 1.0 point)))
882 (article 1.0 point)))
893 (edit-group 1.0 point)))
897 (edit-server 1.0 point)))
901 (edit-score 1.0 point)))
908 (message 1.0 point)))
911 (message 1.0 point)))
914 (message 1.0 point)))
918 (message 1.0 point)))
925 (if gnus-carpal '(summary-carpal 4))
926 ("*Shell Command Output*" 1.0)))
929 ("*Gnus Help Bug*" 0.5)
930 ("*Gnus Bug*" 1.0 point)))
934 (message 1.0 point))))
935 "Window configuration for all possible Gnus buffers.
936 This variable is a list of lists. Each of these lists has a NAME and
937 a RULE. The NAMEs are commonsense names like `group', which names a
938 rule used when displaying the group buffer; `summary', which names a
939 rule for what happens when you enter a group and do not display an
940 article buffer; and so on. See the value of this variable for a
941 complete list of NAMEs.
943 Each RULE is a list of vectors. The first element in this vector is
944 the name of the buffer to be displayed; the second element is the
945 percentage of the screen this buffer is to occupy (a number in the
946 0.0-0.99 range); the optional third element is `point', which should
947 be present to denote which buffer point is to go to after making this
948 buffer configuration.")
950 (defvar gnus-window-to-buffer
951 '((group . gnus-group-buffer)
952 (summary . gnus-summary-buffer)
953 (article . gnus-article-buffer)
954 (server . gnus-server-buffer)
955 (browse . "*Gnus Browse Server*")
956 (edit-group . gnus-group-edit-buffer)
957 (edit-server . gnus-server-edit-buffer)
958 (group-carpal . gnus-carpal-group-buffer)
959 (summary-carpal . gnus-carpal-summary-buffer)
960 (server-carpal . gnus-carpal-server-buffer)
961 (browse-carpal . gnus-carpal-browse-buffer)
962 (edit-score . gnus-score-edit-buffer)
963 (message . gnus-message-buffer)
964 (mail . gnus-message-buffer)
965 (post-news . gnus-message-buffer)
966 (faq . gnus-faq-buffer)
967 (picons . "*Picons*")
968 (tree . gnus-tree-buffer)
969 (info . gnus-info-buffer)
970 (article-copy . gnus-article-copy)
971 (draft . gnus-draft-buffer))
972 "Mapping from short symbols to buffer names or buffer variables.")
974 (defvar gnus-carpal nil
975 "*If non-nil, display clickable icons.")
977 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
978 "*Function called with a group name when new group is detected.
979 A few pre-made functions are supplied: `gnus-subscribe-randomly'
980 inserts new groups at the beginning of the list of groups;
981 `gnus-subscribe-alphabetically' inserts new groups in strict
982 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
983 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
984 for your decision; `gnus-subscribe-killed' kills all new groups;
985 `gnus-subscribe-zombies' will make all new groups into zombies.")
987 ;; Suggested by a bug report by Hallvard B Furuseth.
988 ;; <h.b.furuseth@usit.uio.no>.
989 (defvar gnus-subscribe-options-newsgroup-method
990 (function gnus-subscribe-alphabetically)
991 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
992 If, for instance, you want to subscribe to all newsgroups in the
993 \"no\" and \"alt\" hierarchies, you'd put the following in your
996 options -n no.all alt.all
998 Gnus will the subscribe all new newsgroups in these hierarchies with
999 the subscription method in this variable.")
1001 (defvar gnus-subscribe-hierarchical-interactive nil
1002 "*If non-nil, Gnus will offer to subscribe hierarchically.
1003 When a new hierarchy appears, Gnus will ask the user:
1005 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
1007 If the user pressed `d', Gnus will descend the hierarchy, `y' will
1008 subscribe to all newsgroups in the hierarchy and `s' will skip this
1009 hierarchy in its entirety.")
1011 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1012 "*Function used for sorting the group buffer.
1013 This function will be called with group info entries as the arguments
1014 for the groups to be sorted. Pre-made functions include
1015 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1016 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1017 `gnus-group-sort-by-rank'.
1019 This variable can also be a list of sorting functions. In that case,
1020 the most significant sort function should be the last function in the
1023 ;; Mark variables suggested by Thomas Michanek
1024 ;; <Thomas.Michanek@telelogic.se>.
1025 (defvar gnus-unread-mark ?
1026 "*Mark used for unread articles.")
1027 (defvar gnus-ticked-mark ?!
1028 "*Mark used for ticked articles.")
1029 (defvar gnus-dormant-mark ??
1030 "*Mark used for dormant articles.")
1031 (defvar gnus-del-mark ?r
1032 "*Mark used for del'd articles.")
1033 (defvar gnus-read-mark ?R
1034 "*Mark used for read articles.")
1035 (defvar gnus-expirable-mark ?E
1036 "*Mark used for expirable articles.")
1037 (defvar gnus-killed-mark ?K
1038 "*Mark used for killed articles.")
1039 (defvar gnus-souped-mark ?F
1040 "*Mark used for killed articles.")
1041 (defvar gnus-kill-file-mark ?X
1042 "*Mark used for articles killed by kill files.")
1043 (defvar gnus-low-score-mark ?Y
1044 "*Mark used for articles with a low score.")
1045 (defvar gnus-catchup-mark ?C
1046 "*Mark used for articles that are caught up.")
1047 (defvar gnus-replied-mark ?A
1048 "*Mark used for articles that have been replied to.")
1049 (defvar gnus-cached-mark ?*
1050 "*Mark used for articles that are in the cache.")
1051 (defvar gnus-saved-mark ?S
1052 "*Mark used for articles that have been saved to.")
1053 (defvar gnus-process-mark ?#
1055 (defvar gnus-ancient-mark ?O
1056 "*Mark used for ancient articles.")
1057 (defvar gnus-sparse-mark ?Q
1058 "*Mark used for sparsely reffed articles.")
1059 (defvar gnus-canceled-mark ?G
1060 "*Mark used for canceled articles.")
1061 (defvar gnus-score-over-mark ?+
1062 "*Score mark used for articles with high scores.")
1063 (defvar gnus-score-below-mark ?-
1064 "*Score mark used for articles with low scores.")
1065 (defvar gnus-empty-thread-mark ?
1066 "*There is no thread under the article.")
1067 (defvar gnus-not-empty-thread-mark ?=
1068 "*There is a thread under the article.")
1070 (defvar gnus-view-pseudo-asynchronously nil
1071 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1073 (defvar gnus-view-pseudos nil
1074 "*If `automatic', pseudo-articles will be viewed automatically.
1075 If `not-confirm', pseudos will be viewed automatically, and the user
1076 will not be asked to confirm the command.")
1078 (defvar gnus-view-pseudos-separately t
1079 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1080 If nil, all files that use the same viewing command will be given as a
1081 list of parameters to that command.")
1083 (defvar gnus-insert-pseudo-articles t
1084 "*If non-nil, insert pseudo-articles when decoding articles.")
1086 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1087 "*Format of group lines.
1088 It works along the same lines as a normal formatting string,
1089 with some simple extensions.
1091 %M Only marked articles (character, \"*\" or \" \")
1092 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1093 %L Level of subscribedness (integer)
1094 %N Number of unread articles (integer)
1095 %I Number of dormant articles (integer)
1096 %i Number of ticked and dormant (integer)
1097 %T Number of ticked articles (integer)
1098 %R Number of read articles (integer)
1099 %t Total number of articles (integer)
1100 %y Number of unread, unticked articles (integer)
1101 %G Group name (string)
1102 %g Qualified group name (string)
1103 %D Group description (string)
1104 %s Select method (string)
1105 %o Moderated group (char, \"m\")
1106 %p Process mark (char)
1107 %O Moderated group (string, \"(m)\" or \"\")
1108 %P Topic indentation (string)
1109 %l Whether there are GroupLens predictions for this group (string)
1110 %n Select from where (string)
1111 %z A string that look like `<%s:%n>' if a foreign select method is used
1112 %u User defined specifier. The next character in the format string should
1113 be a letter. Gnus will call the function gnus-user-format-function-X,
1114 where X is the letter following %u. The function will be passed the
1115 current header as argument. The function should return a string, which
1116 will be inserted into the buffer just like information from any other
1119 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1120 the mouse point move inside the area. There can only be one such area.
1122 Note that this format specification is not always respected. For
1123 reasons of efficiency, when listing killed groups, this specification
1124 is ignored altogether. If the spec is changed considerably, your
1125 output may end up looking strange when listing both alive and killed
1128 If you use %o or %O, reading the active file will be slower and quite
1129 a bit of extra memory will be used. %D will also worsen performance.
1130 Also note that if you change the format specification to include any
1131 of these specs, you must probably re-start Gnus to see them go into
1134 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1135 "*The format specification of the lines in the summary buffer.
1137 It works along the same lines as a normal formatting string,
1138 with some simple extensions.
1140 %N Article number, left padded with spaces (string)
1142 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1143 %n Name of the poster (string)
1144 %a Extracted name of the poster (string)
1145 %A Extracted address of the poster (string)
1146 %F Contents of the From: header (string)
1147 %x Contents of the Xref: header (string)
1148 %D Date of the article (string)
1149 %d Date of the article (string) in DD-MMM format
1150 %M Message-id of the article (string)
1151 %r References of the article (string)
1152 %c Number of characters in the article (integer)
1153 %L Number of lines in the article (integer)
1154 %I Indentation based on thread level (a string of spaces)
1155 %T A string with two possible values: 80 spaces if the article
1156 is on thread level two or larger and 0 spaces on level one
1157 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1158 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1159 %[ Opening bracket (character, \"[\" or \"<\")
1160 %] Closing bracket (character, \"]\" or \">\")
1161 %> Spaces of length thread-level (string)
1162 %< Spaces of length (- 20 thread-level) (string)
1163 %i Article score (number)
1164 %z Article zcore (character)
1165 %t Number of articles under the current thread (number).
1166 %e Whether the thread is empty or not (character).
1167 %l GroupLens score (string).
1168 %u User defined specifier. The next character in the format string should
1169 be a letter. Gnus will call the function gnus-user-format-function-X,
1170 where X is the letter following %u. The function will be passed the
1171 current header as argument. The function should return a string, which
1172 will be inserted into the summary just like information from any other
1175 Text between %( and %) will be highlighted with `gnus-mouse-face'
1176 when the mouse point is placed inside the area. There can only be one
1179 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1180 with care. For reasons of efficiency, Gnus will compute what column
1181 these characters will end up in, and \"hard-code\" that. This means that
1182 it is illegal to have these specs after a variable-length spec. Well,
1183 you might not be arrested, but your summary buffer will look strange,
1184 which is bad enough.
1186 The smart choice is to have these specs as for to the left as
1189 This restriction may disappear in later versions of Gnus.")
1191 (defvar gnus-summary-dummy-line-format
1193 "*The format specification for the dummy roots in the summary buffer.
1194 It works along the same lines as a normal formatting string,
1195 with some simple extensions.
1199 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1200 "*The format specification for the summary mode line.
1201 It works along the same lines as a normal formatting string,
1202 with some simple extensions:
1205 %p Unprefixed group name
1206 %A Current article number
1208 %U Number of unread articles in the group
1209 %e Number of unselected articles in the group
1210 %Z A string with unread/unselected article counts
1211 %g Shortish group name
1212 %S Subject of the current article
1213 %u User-defined spec
1214 %s Current score file name
1215 %d Number of dormant articles
1216 %r Number of articles that have been marked as read in this session
1217 %E Number of articles expunged by the score files")
1219 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1220 "*The format specification for the article mode line.
1221 See `gnus-summary-mode-line-format' for a closer description.")
1223 (defvar gnus-group-mode-line-format "Gnus: %%b {%M%:%S}"
1224 "*The format specification for the group mode line.
1225 It works along the same lines as a normal formatting string,
1226 with some simple extensions:
1228 %S The native news server.
1229 %M The native select method.
1230 %: \":\" if %S isn't \"\".")
1232 (defvar gnus-valid-select-methods
1233 '(("nntp" post address prompt-address)
1234 ("nnspool" post address)
1235 ("nnvirtual" post-mail virtual prompt-address)
1236 ("nnmbox" mail respool address)
1237 ("nnml" mail respool address)
1238 ("nnmh" mail respool address)
1239 ("nndir" post-mail prompt-address address)
1240 ("nneething" none address prompt-address)
1241 ("nndoc" none address prompt-address)
1242 ("nnbabyl" mail address respool)
1243 ("nnkiboze" post address virtual)
1244 ("nnsoup" post-mail address)
1245 ("nndraft" post-mail)
1246 ("nnfolder" mail respool address))
1247 "An alist of valid select methods.
1248 The first element of each list lists should be a string with the name
1249 of the select method. The other elements may be be the category of
1250 this method (ie. `post', `mail', `none' or whatever) or other
1251 properties that this method has (like being respoolable).
1252 If you implement a new select method, all you should have to change is
1253 this variable. I think.")
1255 (defvar gnus-updated-mode-lines '(group article summary tree)
1256 "*List of buffers that should update their mode lines.
1257 The list may contain the symbols `group', `article' and `summary'. If
1258 the corresponding symbol is present, Gnus will keep that mode line
1259 updated with information that may be pertinent.
1260 If this variable is nil, screen refresh may be quicker.")
1262 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1263 (defvar gnus-mode-non-string-length nil
1264 "*Max length of mode-line non-string contents.
1265 If this is nil, Gnus will take space as is needed, leaving the rest
1266 of the modeline intact.")
1269 ;(defvar gnus-mouse-face 'highlight
1270 ; "*Face used for mouse highlighting in Gnus.
1271 ;No mouse highlights will be done if `gnus-visual' is nil.")
1273 (defvar gnus-summary-mark-below 0
1274 "*Mark all articles with a score below this variable as read.
1275 This variable is local to each summary buffer and usually set by the
1278 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1279 "*List of functions used for sorting articles in the summary buffer.
1280 This variable is only used when not using a threaded display.")
1282 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1283 "*List of functions used for sorting threads in the summary buffer.
1284 By default, threads are sorted by article number.
1286 Each function takes two threads and return non-nil if the first thread
1287 should be sorted before the other. If you use more than one function,
1288 the primary sort function should be the last. You should probably
1289 always include `gnus-thread-sort-by-number' in the list of sorting
1290 functions -- preferably first.
1292 Ready-mady functions include `gnus-thread-sort-by-number',
1293 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1294 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1295 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1297 (defvar gnus-thread-score-function '+
1298 "*Function used for calculating the total score of a thread.
1300 The function is called with the scores of the article and each
1301 subthread and should then return the score of the thread.
1303 Some functions you can use are `+', `max', or `min'.")
1305 (defvar gnus-summary-expunge-below nil
1306 "All articles that have a score less than this variable will be expunged.")
1308 (defvar gnus-thread-expunge-below nil
1309 "All threads that have a total score less than this variable will be expunged.
1310 See `gnus-thread-score-function' for en explanation of what a
1311 \"thread score\" is.")
1313 (defvar gnus-auto-subscribed-groups
1314 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1315 "*All new groups that match this regexp will be subscribed automatically.
1316 Note that this variable only deals with new groups. It has no effect
1317 whatsoever on old groups.")
1319 (defvar gnus-options-subscribe nil
1320 "*All new groups matching this regexp will be subscribed unconditionally.
1321 Note that this variable deals only with new newsgroups. This variable
1322 does not affect old newsgroups.")
1324 (defvar gnus-options-not-subscribe nil
1325 "*All new groups matching this regexp will be ignored.
1326 Note that this variable deals only with new newsgroups. This variable
1327 does not affect old (already subscribed) newsgroups.")
1329 (defvar gnus-auto-expirable-newsgroups nil
1330 "*Groups in which to automatically mark read articles as expirable.
1331 If non-nil, this should be a regexp that should match all groups in
1332 which to perform auto-expiry. This only makes sense for mail groups.")
1334 (defvar gnus-total-expirable-newsgroups nil
1335 "*Groups in which to perform expiry of all read articles.
1336 Use with extreme caution. All groups that match this regexp will be
1337 expiring - which means that all read articles will be deleted after
1338 (say) one week. (This only goes for mail groups and the like, of
1341 (defvar gnus-group-uncollapsed-levels 1
1342 "Number of group name elements to leave alone when making a short group name.")
1344 (defvar gnus-hidden-properties '(invisible t intangible t)
1345 "Property list to use for hiding text.")
1347 (defvar gnus-modtime-botch nil
1348 "*Non-nil means .newsrc should be deleted prior to save.
1349 Its use is due to the bogus appearance that .newsrc was modified on
1354 (defvar gnus-group-mode-hook nil
1355 "*A hook for Gnus group mode.")
1357 (defvar gnus-summary-mode-hook nil
1358 "*A hook for Gnus summary mode.
1359 This hook is run before any variables are set in the summary buffer.")
1361 (defvar gnus-article-mode-hook nil
1362 "*A hook for Gnus article mode.")
1364 (defvar gnus-summary-prepare-exit-hook nil
1365 "*A hook called when preparing to exit from the summary buffer.
1366 It calls `gnus-summary-expire-articles' by default.")
1367 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1369 (defvar gnus-summary-exit-hook nil
1370 "*A hook called on exit from the summary buffer.")
1372 (defvar gnus-group-catchup-group-hook nil
1373 "*A hook run when catching up a group from the group buffer.")
1375 (defvar gnus-group-update-group-hook nil
1376 "*A hook called when updating group lines.")
1378 (defvar gnus-open-server-hook nil
1379 "*A hook called just before opening connection to the news server.")
1381 (defvar gnus-load-hook nil
1382 "*A hook run while Gnus is loaded.")
1384 (defvar gnus-startup-hook nil
1385 "*A hook called at startup.
1386 This hook is called after Gnus is connected to the NNTP server.")
1388 (defvar gnus-get-new-news-hook nil
1389 "*A hook run just before Gnus checks for new news.")
1391 (defvar gnus-after-getting-new-news-hook nil
1392 "*A hook run after Gnus checks for new news.")
1394 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1395 "*A function that is called to generate the group buffer.
1396 The function is called with three arguments: The first is a number;
1397 all group with a level less or equal to that number should be listed,
1398 if the second is non-nil, empty groups should also be displayed. If
1399 the third is non-nil, it is a number. No groups with a level lower
1400 than this number should be displayed.
1402 The only current function implemented is `gnus-group-prepare-flat'.")
1404 (defvar gnus-group-prepare-hook nil
1405 "*A hook called after the group buffer has been generated.
1406 If you want to modify the group buffer, you can use this hook.")
1408 (defvar gnus-summary-prepare-hook nil
1409 "*A hook called after the summary buffer has been generated.
1410 If you want to modify the summary buffer, you can use this hook.")
1412 (defvar gnus-summary-generate-hook nil
1413 "*A hook run just before generating the summary buffer.
1414 This hook is commonly used to customize threading variables and the
1417 (defvar gnus-article-prepare-hook nil
1418 "*A hook called after an article has been prepared in the article buffer.
1419 If you want to run a special decoding program like nkf, use this hook.")
1421 ;(defvar gnus-article-display-hook nil
1422 ; "*A hook called after the article is displayed in the article buffer.
1423 ;The hook is designed to change the contents of the article
1424 ;buffer. Typical functions that this hook may contain are
1425 ;`gnus-article-hide-headers' (hide selected headers),
1426 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1427 ;`gnus-article-hide-signature' (hide signature) and
1428 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1429 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1430 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1431 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1433 (defvar gnus-article-x-face-too-ugly nil
1434 "Regexp matching posters whose face shouldn't be shown automatically.")
1436 (defvar gnus-select-group-hook nil
1437 "*A hook called when a newsgroup is selected.
1439 If you'd like to simplify subjects like the
1440 `gnus-summary-next-same-subject' command does, you can use the
1443 (setq gnus-select-group-hook
1446 (mapcar (lambda (header)
1447 (mail-header-set-subject
1449 (gnus-simplify-subject
1450 (mail-header-subject header) 're-only)))
1451 gnus-newsgroup-headers))))")
1453 (defvar gnus-select-article-hook nil
1454 "*A hook called when an article is selected.")
1456 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1457 "*A hook called to apply kill files to a group.
1458 This hook is intended to apply a kill file to the selected newsgroup.
1459 The function `gnus-apply-kill-file' is called by default.
1461 Since a general kill file is too heavy to use only for a few
1462 newsgroups, I recommend you to use a lighter hook function. For
1463 example, if you'd like to apply a kill file to articles which contains
1464 a string `rmgroup' in subject in newsgroup `control', you can use the
1467 (setq gnus-apply-kill-hook
1470 (cond ((string-match \"control\" gnus-newsgroup-name)
1471 (gnus-kill \"Subject\" \"rmgroup\")
1472 (gnus-expunge \"X\"))))))")
1474 (defvar gnus-visual-mark-article-hook
1475 (list 'gnus-highlight-selected-summary)
1476 "*Hook run after selecting an article in the summary buffer.
1477 It is meant to be used for highlighting the article in some way. It
1478 is not run if `gnus-visual' is nil.")
1480 (defvar gnus-parse-headers-hook nil
1481 "*A hook called before parsing the headers.")
1482 (add-hook 'gnus-parse-headers-hook 'gnus-decode-rfc1522)
1484 (defvar gnus-exit-group-hook nil
1485 "*A hook called when exiting (not quitting) summary mode.")
1487 (defvar gnus-suspend-gnus-hook nil
1488 "*A hook called when suspending (not exiting) Gnus.")
1490 (defvar gnus-exit-gnus-hook nil
1491 "*A hook called when exiting Gnus.")
1493 (defvar gnus-after-exiting-gnus-hook nil
1494 "*A hook called after exiting Gnus.")
1496 (defvar gnus-save-newsrc-hook nil
1497 "*A hook called before saving any of the newsrc files.")
1499 (defvar gnus-save-quick-newsrc-hook nil
1500 "*A hook called just before saving the quick newsrc file.
1501 Can be used to turn version control on or off.")
1503 (defvar gnus-save-standard-newsrc-hook nil
1504 "*A hook called just before saving the standard newsrc file.
1505 Can be used to turn version control on or off.")
1507 (defvar gnus-summary-update-hook
1508 (list 'gnus-summary-highlight-line)
1509 "*A hook called when a summary line is changed.
1510 The hook will not be called if `gnus-visual' is nil.
1512 The default function `gnus-summary-highlight-line' will
1513 highlight the line according to the `gnus-summary-highlight'
1516 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1517 "*A hook called when a group line is changed.
1518 The hook will not be called if `gnus-visual' is nil.
1520 The default function `gnus-group-highlight-line' will
1521 highlight the line according to the `gnus-group-highlight'
1524 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1525 "*A hook called when an article is selected for the first time.
1526 The hook is intended to mark an article as read (or unread)
1527 automatically when it is selected.")
1529 (defvar gnus-group-change-level-function nil
1530 "Function run when a group level is changed.
1531 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1533 ;; Remove any hilit infestation.
1534 (add-hook 'gnus-startup-hook
1536 (remove-hook 'gnus-summary-prepare-hook
1537 'hilit-rehighlight-buffer-quietly)
1538 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1539 (setq gnus-mark-article-hook
1540 '(gnus-summary-mark-read-and-unread-as-read))
1541 (remove-hook 'gnus-article-prepare-hook
1542 'hilit-rehighlight-buffer-quietly)))
1545 ;; Internal variables
1547 (defvar gnus-tree-buffer "*Tree*"
1548 "Buffer where Gnus thread trees are displayed.")
1551 (defvar gnus-use-generic-from nil)
1553 (defvar gnus-thread-indent-array nil)
1554 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1556 (defvar gnus-newsrc-file-version nil)
1558 (defvar gnus-method-history nil)
1559 ;; Variable holding the user answers to all method prompts.
1561 (defvar gnus-group-history nil)
1562 ;; Variable holding the user answers to all group prompts.
1564 (defvar gnus-server-alist nil
1565 "List of available servers.")
1567 (defvar gnus-group-indentation-function nil)
1569 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1571 (defvar gnus-goto-missing-group-function nil)
1573 (defvar gnus-override-subscribe-method nil)
1575 (defvar gnus-group-goto-next-group-function nil
1576 "Function to override finding the next group after listing groups.")
1578 (defconst gnus-article-mark-lists
1579 '((marked . tick) (replied . reply)
1580 (expirable . expire) (killed . killed)
1581 (bookmarks . bookmark) (dormant . dormant)
1582 (scored . score) (saved . save)
1586 ;; Avoid highlighting in kill files.
1587 (defvar gnus-summary-inhibit-highlight nil)
1588 (defvar gnus-newsgroup-selected-overlay nil)
1590 (defvar gnus-inhibit-hiding nil)
1591 (defvar gnus-group-indentation "")
1592 (defvar gnus-inhibit-limiting nil)
1593 (defvar gnus-created-frames nil)
1595 (defvar gnus-article-mode-map nil)
1596 (defvar gnus-dribble-buffer nil)
1597 (defvar gnus-headers-retrieved-by nil)
1598 (defvar gnus-article-reply nil)
1599 (defvar gnus-override-method nil)
1600 (defvar gnus-article-check-size nil)
1602 (defvar gnus-current-score-file nil)
1603 (defvar gnus-newsgroup-adaptive-score-file nil)
1604 (defvar gnus-scores-exclude-files nil)
1606 (defvar gnus-opened-servers nil)
1608 (defvar gnus-current-move-group nil)
1609 (defvar gnus-current-copy-group nil)
1610 (defvar gnus-current-crosspost-group nil)
1612 (defvar gnus-newsgroup-dependencies nil)
1613 (defvar gnus-newsgroup-async nil)
1614 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1616 (defvar gnus-newsgroup-adaptive nil)
1618 (defvar gnus-summary-display-table nil)
1619 (defvar gnus-summary-display-article-function nil)
1621 (defvar gnus-summary-highlight-line-function nil
1622 "Function called after highlighting a summary line.")
1624 (defvar gnus-group-line-format-alist
1625 `((?M gnus-tmp-marked-mark ?c)
1626 (?S gnus-tmp-subscribed ?c)
1627 (?L gnus-tmp-level ?d)
1628 (?N (cond ((eq number t) "*" )
1632 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1633 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1635 (?R gnus-tmp-number-of-read ?s)
1636 (?t gnus-tmp-number-total ?d)
1637 (?y gnus-tmp-number-of-unread ?s)
1638 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1639 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1640 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1641 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1642 (?g gnus-tmp-group ?s)
1643 (?G gnus-tmp-qualified-group ?s)
1644 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1645 (?D gnus-tmp-newsgroup-description ?s)
1646 (?o gnus-tmp-moderated ?c)
1647 (?O gnus-tmp-moderated-string ?s)
1648 (?p gnus-tmp-process-marked ?c)
1649 (?s gnus-tmp-news-server ?s)
1650 (?n gnus-tmp-news-method ?s)
1651 (?P gnus-group-indentation ?s)
1652 (?l gnus-tmp-grouplens ?s)
1653 (?z gnus-tmp-news-method-string ?s)
1654 (?u gnus-tmp-user-defined ?s)))
1656 (defvar gnus-summary-line-format-alist
1657 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1658 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1659 (?s gnus-tmp-subject-or-nil ?s)
1660 (?n gnus-tmp-name ?s)
1661 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1663 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1665 (?F gnus-tmp-from ?s)
1666 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1667 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1668 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1669 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1670 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1671 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1672 (?L gnus-tmp-lines ?d)
1673 (?I gnus-tmp-indentation ?s)
1674 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1675 (?R gnus-tmp-replied ?c)
1676 (?\[ gnus-tmp-opening-bracket ?c)
1677 (?\] gnus-tmp-closing-bracket ?c)
1678 (?\> (make-string gnus-tmp-level ? ) ?s)
1679 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1680 (?i gnus-tmp-score ?d)
1681 (?z gnus-tmp-score-char ?c)
1682 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1683 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1684 (?U gnus-tmp-unread ?c)
1685 (?t (gnus-summary-number-of-articles-in-thread
1686 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1688 (?e (gnus-summary-number-of-articles-in-thread
1689 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1691 (?u gnus-tmp-user-defined ?s))
1692 "An alist of format specifications that can appear in summary lines,
1693 and what variables they correspond with, along with the type of the
1694 variable (string, integer, character, etc).")
1696 (defvar gnus-summary-dummy-line-format-alist
1697 `((?S gnus-tmp-subject ?s)
1698 (?N gnus-tmp-number ?d)
1699 (?u gnus-tmp-user-defined ?s)))
1701 (defvar gnus-summary-mode-line-format-alist
1702 `((?G gnus-tmp-group-name ?s)
1703 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1704 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1705 (?A gnus-tmp-article-number ?d)
1706 (?Z gnus-tmp-unread-and-unselected ?s)
1707 (?V gnus-version ?s)
1708 (?U gnus-tmp-unread ?d)
1709 (?S gnus-tmp-subject ?s)
1710 (?e gnus-tmp-unselected ?d)
1711 (?u gnus-tmp-user-defined ?s)
1712 (?d (length gnus-newsgroup-dormant) ?d)
1713 (?t (length gnus-newsgroup-marked) ?d)
1714 (?r (length gnus-newsgroup-reads) ?d)
1715 (?E gnus-newsgroup-expunged-tally ?d)
1716 (?s (gnus-current-score-file-nondirectory) ?s)))
1718 (defvar gnus-article-mode-line-format-alist
1719 gnus-summary-mode-line-format-alist)
1721 (defvar gnus-group-mode-line-format-alist
1722 `((?S gnus-tmp-news-server ?s)
1723 (?M gnus-tmp-news-method ?s)
1724 (?u gnus-tmp-user-defined ?s)
1725 (?: gnus-tmp-colon ?s)))
1727 (defvar gnus-have-read-active-file nil)
1729 (defconst gnus-maintainer
1730 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1731 "The mail address of the Gnus maintainers.")
1733 (defconst gnus-version-number "5.2.19"
1734 "Version number for this version of Gnus.")
1736 (defconst gnus-version (format "Gnus v%s" gnus-version-number)
1737 "Version string for this version of Gnus.")
1739 (defvar gnus-info-nodes
1740 '((gnus-group-mode "(gnus)The Group Buffer")
1741 (gnus-summary-mode "(gnus)The Summary Buffer")
1742 (gnus-article-mode "(gnus)The Article Buffer"))
1743 "Alist of major modes and related Info nodes.")
1745 (defvar gnus-group-buffer "*Group*")
1746 (defvar gnus-summary-buffer "*Summary*")
1747 (defvar gnus-article-buffer "*Article*")
1748 (defvar gnus-server-buffer "*Server*")
1750 (defvar gnus-work-buffer " *gnus work*")
1752 (defvar gnus-original-article-buffer " *Original Article*")
1753 (defvar gnus-original-article nil)
1755 (defvar gnus-buffer-list nil
1756 "Gnus buffers that should be killed on exit.")
1758 (defvar gnus-slave nil
1759 "Whether this Gnus is a slave or not.")
1761 (defvar gnus-variable-list
1762 '(gnus-newsrc-options gnus-newsrc-options-n
1763 gnus-newsrc-last-checked-date
1764 gnus-newsrc-alist gnus-server-alist
1765 gnus-killed-list gnus-zombie-list
1766 gnus-topic-topology gnus-topic-alist
1768 "Gnus variables saved in the quick startup file.")
1770 (defvar gnus-newsrc-options nil
1771 "Options line in the .newsrc file.")
1773 (defvar gnus-newsrc-options-n nil
1774 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1776 (defvar gnus-newsrc-last-checked-date nil
1777 "Date Gnus last asked server for new newsgroups.")
1779 (defvar gnus-topic-topology nil
1780 "The complete topic hierarchy.")
1782 (defvar gnus-topic-alist nil
1783 "The complete topic-group alist.")
1785 (defvar gnus-newsrc-alist nil
1786 "Assoc list of read articles.
1787 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1789 (defvar gnus-newsrc-hashtb nil
1790 "Hashtable of gnus-newsrc-alist.")
1792 (defvar gnus-killed-list nil
1793 "List of killed newsgroups.")
1795 (defvar gnus-killed-hashtb nil
1796 "Hash table equivalent of gnus-killed-list.")
1798 (defvar gnus-zombie-list nil
1799 "List of almost dead newsgroups.")
1801 (defvar gnus-description-hashtb nil
1802 "Descriptions of newsgroups.")
1804 (defvar gnus-list-of-killed-groups nil
1805 "List of newsgroups that have recently been killed by the user.")
1807 (defvar gnus-active-hashtb nil
1808 "Hashtable of active articles.")
1810 (defvar gnus-moderated-list nil
1811 "List of moderated newsgroups.")
1813 (defvar gnus-group-marked nil)
1815 (defvar gnus-current-startup-file nil
1816 "Startup file for the current host.")
1818 (defvar gnus-last-search-regexp nil
1819 "Default regexp for article search command.")
1821 (defvar gnus-last-shell-command nil
1822 "Default shell command on article.")
1824 (defvar gnus-current-select-method nil
1825 "The current method for selecting a newsgroup.")
1827 (defvar gnus-group-list-mode nil)
1829 (defvar gnus-article-internal-prepare-hook nil)
1831 (defvar gnus-newsgroup-name nil)
1832 (defvar gnus-newsgroup-begin nil)
1833 (defvar gnus-newsgroup-end nil)
1834 (defvar gnus-newsgroup-last-rmail nil)
1835 (defvar gnus-newsgroup-last-mail nil)
1836 (defvar gnus-newsgroup-last-folder nil)
1837 (defvar gnus-newsgroup-last-file nil)
1838 (defvar gnus-newsgroup-auto-expire nil)
1839 (defvar gnus-newsgroup-active nil)
1841 (defvar gnus-newsgroup-data nil)
1842 (defvar gnus-newsgroup-data-reverse nil)
1843 (defvar gnus-newsgroup-limit nil)
1844 (defvar gnus-newsgroup-limits nil)
1846 (defvar gnus-newsgroup-unreads nil
1847 "List of unread articles in the current newsgroup.")
1849 (defvar gnus-newsgroup-unselected nil
1850 "List of unselected unread articles in the current newsgroup.")
1852 (defvar gnus-newsgroup-reads nil
1853 "Alist of read articles and article marks in the current newsgroup.")
1855 (defvar gnus-newsgroup-expunged-tally nil)
1857 (defvar gnus-newsgroup-marked nil
1858 "List of ticked articles in the current newsgroup (a subset of unread art).")
1860 (defvar gnus-newsgroup-killed nil
1861 "List of ranges of articles that have been through the scoring process.")
1863 (defvar gnus-newsgroup-cached nil
1864 "List of articles that come from the article cache.")
1866 (defvar gnus-newsgroup-saved nil
1867 "List of articles that have been saved.")
1869 (defvar gnus-newsgroup-kill-headers nil)
1871 (defvar gnus-newsgroup-replied nil
1872 "List of articles that have been replied to in the current newsgroup.")
1874 (defvar gnus-newsgroup-expirable nil
1875 "List of articles in the current newsgroup that can be expired.")
1877 (defvar gnus-newsgroup-processable nil
1878 "List of articles in the current newsgroup that can be processed.")
1880 (defvar gnus-newsgroup-bookmarks nil
1881 "List of articles in the current newsgroup that have bookmarks.")
1883 (defvar gnus-newsgroup-dormant nil
1884 "List of dormant articles in the current newsgroup.")
1886 (defvar gnus-newsgroup-scored nil
1887 "List of scored articles in the current newsgroup.")
1889 (defvar gnus-newsgroup-headers nil
1890 "List of article headers in the current newsgroup.")
1892 (defvar gnus-newsgroup-threads nil)
1894 (defvar gnus-newsgroup-prepared nil
1895 "Whether the current group has been prepared properly.")
1897 (defvar gnus-newsgroup-ancient nil
1898 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1900 (defvar gnus-newsgroup-sparse nil)
1902 (defvar gnus-current-article nil)
1903 (defvar gnus-article-current nil)
1904 (defvar gnus-current-headers nil)
1905 (defvar gnus-have-all-headers nil)
1906 (defvar gnus-last-article nil)
1907 (defvar gnus-newsgroup-history nil)
1908 (defvar gnus-current-kill-article nil)
1910 ;; Save window configuration.
1911 (defvar gnus-prev-winconf nil)
1913 (defvar gnus-summary-mark-positions nil)
1914 (defvar gnus-group-mark-positions nil)
1916 (defvar gnus-reffed-article-number nil)
1918 ;;; Let the byte-compiler know that we know about this variable.
1919 (defvar rmail-default-rmail-file)
1921 (defvar gnus-cache-removable-articles nil)
1923 (defvar gnus-dead-summary nil)
1925 (defconst gnus-summary-local-variables
1926 '(gnus-newsgroup-name
1927 gnus-newsgroup-begin gnus-newsgroup-end
1928 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1929 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1930 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1931 gnus-newsgroup-unselected gnus-newsgroup-marked
1932 gnus-newsgroup-reads gnus-newsgroup-saved
1933 gnus-newsgroup-replied gnus-newsgroup-expirable
1934 gnus-newsgroup-processable gnus-newsgroup-killed
1935 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1936 gnus-newsgroup-headers gnus-newsgroup-threads
1937 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1938 gnus-current-article gnus-current-headers gnus-have-all-headers
1939 gnus-last-article gnus-article-internal-prepare-hook
1940 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1941 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1942 gnus-newsgroup-async gnus-thread-expunge-below
1943 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1944 (gnus-summary-mark-below . global)
1945 gnus-newsgroup-active gnus-scores-exclude-files
1946 gnus-newsgroup-history gnus-newsgroup-ancient
1947 gnus-newsgroup-sparse
1948 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1949 gnus-newsgroup-adaptive-score-file
1950 (gnus-newsgroup-expunged-tally . 0)
1951 gnus-cache-removable-articles gnus-newsgroup-cached
1952 gnus-newsgroup-data gnus-newsgroup-data-reverse
1953 gnus-newsgroup-limit gnus-newsgroup-limits)
1954 "Variables that are buffer-local to the summary buffers.")
1956 (defconst gnus-bug-message
1957 "Sending a bug report to the Gnus Towers.
1958 ========================================
1960 The buffer below is a mail buffer. When you press `C-c C-c', it will
1961 be sent to the Gnus Bug Exterminators.
1963 At the bottom of the buffer you'll see lots of variable settings.
1964 Please do not delete those. They will tell the Bug People what your
1965 environment is, so that it will be easier to locate the bugs.
1967 If you have found a bug that makes Emacs go \"beep\", set
1968 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1969 and include the backtrace in your bug report.
1971 Please describe the bug in annoying, painstaking detail.
1973 Thank you for your help in stamping out bugs.
1976 ;;; End of variables.
1978 ;; Define some autoload functions Gnus might use.
1981 ;; This little mapcar goes through the list below and marks the
1982 ;; symbols in question as autoloaded functions.
1985 (let ((interactive (nth 1 (memq ':interactive package))))
1989 (when (consp function)
1990 (setq keymap (car (memq 'keymap function)))
1991 (setq function (car function)))
1992 (autoload function (car package) nil interactive keymap)))
1993 (if (eq (nth 1 package) ':interactive)
1996 '(("metamail" metamail-buffer)
1997 ("info" Info-goto-node)
1998 ("hexl" hexl-hex-string-to-integer)
1999 ("pp" pp pp-to-string pp-eval-expression)
2000 ("mail-extr" mail-extract-address-components)
2001 ("nnmail" nnmail-split-fancy nnmail-article-group)
2002 ("nnvirtual" nnvirtual-catchup-group)
2003 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
2004 timezone-make-sortable-date timezone-make-time-string)
2005 ("rmailout" rmail-output)
2006 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
2008 ("gnus-soup" :interactive t
2009 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
2010 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
2011 ("nnsoup" nnsoup-pack-replies)
2012 ("gnus-scomo" :interactive t gnus-score-mode)
2013 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
2014 gnus-Folder-save-name gnus-folder-save-name)
2015 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
2016 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2017 gnus-server-make-menu-bar gnus-article-make-menu-bar
2018 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2019 gnus-summary-highlight-line gnus-carpal-setup-buffer
2020 gnus-group-highlight-line
2021 gnus-article-add-button gnus-insert-next-page-button
2022 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2023 ("gnus-vis" :interactive t
2024 gnus-article-push-button gnus-article-press-button
2025 gnus-article-highlight gnus-article-highlight-some
2026 gnus-article-highlight-headers gnus-article-highlight-signature
2027 gnus-article-add-buttons gnus-article-add-buttons-to-head
2028 gnus-article-next-button gnus-article-prev-button)
2029 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2030 gnus-demon-add-disconnection gnus-demon-add-handler
2031 gnus-demon-remove-handler)
2032 ("gnus-demon" :interactive t
2033 gnus-demon-init gnus-demon-cancel)
2034 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2035 gnus-tree-open gnus-tree-close)
2036 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2037 gnus-nocem-unwanted-article-p)
2038 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2039 ("gnus-srvr" gnus-browse-foreign-server)
2040 ("gnus-cite" :interactive t
2041 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2042 gnus-article-hide-citation gnus-article-fill-cited-article
2043 gnus-article-hide-citation-in-followups)
2044 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2045 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2046 gnus-execute gnus-expunge)
2047 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2048 gnus-cache-possibly-remove-articles gnus-cache-request-article
2049 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2050 gnus-cache-enter-remove-article gnus-cached-article-p
2051 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2052 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2053 gnus-cache-remove-article)
2054 ("gnus-score" :interactive t
2055 gnus-summary-increase-score gnus-summary-lower-score
2056 gnus-score-flush-cache gnus-score-close
2057 gnus-score-raise-same-subject-and-select
2058 gnus-score-raise-same-subject gnus-score-default
2059 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2060 gnus-score-lower-same-subject gnus-score-lower-thread
2061 gnus-possibly-score-headers gnus-summary-raise-score
2062 gnus-summary-set-score gnus-summary-current-score)
2064 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2065 gnus-current-score-file-nondirectory gnus-score-adaptive
2066 gnus-score-find-trace gnus-score-file-name)
2067 ("gnus-edit" :interactive t gnus-score-customize)
2068 ("gnus-topic" :interactive t gnus-topic-mode)
2069 ("gnus-topic" gnus-topic-remove-group)
2070 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2071 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2072 ("gnus-uu" :interactive t
2073 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2074 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2075 gnus-uu-mark-by-regexp gnus-uu-mark-all
2076 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2077 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2078 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2079 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2080 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2081 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2082 gnus-uu-decode-binhex-view)
2083 ("gnus-msg" (gnus-summary-send-map keymap)
2084 gnus-mail-yank-original gnus-mail-send-and-exit
2085 gnus-article-mail gnus-new-mail gnus-mail-reply)
2086 ("gnus-msg" :interactive t
2087 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2088 gnus-summary-followup gnus-summary-followup-with-original
2089 gnus-summary-cancel-article gnus-summary-supersede-article
2090 gnus-post-news gnus-inews-news
2091 gnus-summary-reply gnus-summary-reply-with-original
2092 gnus-summary-mail-forward gnus-summary-mail-other-window
2094 ("gnus-picon" :interactive t gnus-article-display-picons
2095 gnus-group-display-picons gnus-picons-article-display-x-face)
2096 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2097 gnus-grouplens-mode)
2098 ("smiley" :interactive t gnus-smiley-display)
2099 ("gnus-vm" gnus-vm-mail-setup)
2100 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2101 gnus-summary-save-article-vm))))
2105 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2106 ;; If you want the cursor to go somewhere else, set these two
2107 ;; functions in some startup hook to whatever you want.
2108 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2109 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2111 ;;; Various macros and substs.
2113 (defun gnus-header-from (header)
2114 (mail-header-from header))
2116 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2117 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2118 (let ((tempvar (make-symbol "GnusStartBufferWindow"))
2119 (w (make-symbol "w"))
2120 (buf (make-symbol "buf")))
2121 `(let* ((,tempvar (selected-window))
2123 (,w (get-buffer-window ,buf 'visible)))
2128 (pop-to-buffer ,buf))
2130 (select-window ,tempvar)))))
2132 (put 'gnus-eval-in-buffer-window 'lisp-indent-function 1)
2133 (put 'gnus-eval-in-buffer-window 'lisp-indent-hook 1)
2134 (put 'gnus-eval-in-buffer-window 'edebug-form-spec '(form body))
2136 (defmacro gnus-gethash (string hashtable)
2137 "Get hash value of STRING in HASHTABLE."
2138 `(symbol-value (intern-soft ,string ,hashtable)))
2140 (defmacro gnus-sethash (string value hashtable)
2141 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2142 `(set (intern ,string ,hashtable) ,value))
2144 (defmacro gnus-intern-safe (string hashtable)
2145 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2146 `(let ((symbol (intern ,string ,hashtable)))
2151 (defmacro gnus-group-unread (group)
2152 "Get the currently computed number of unread articles in GROUP."
2153 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2155 (defmacro gnus-group-entry (group)
2156 "Get the newsrc entry for GROUP."
2157 `(gnus-gethash ,group gnus-newsrc-hashtb))
2159 (defmacro gnus-active (group)
2160 "Get active info on GROUP."
2161 `(gnus-gethash ,group gnus-active-hashtb))
2163 (defmacro gnus-set-active (group active)
2164 "Set GROUP's active info."
2165 `(gnus-sethash ,group ,active gnus-active-hashtb))
2167 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2168 ;; function `substring' might cut on a middle of multi-octet
2170 (defun gnus-truncate-string (str width)
2171 (substring str 0 width))
2173 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2174 ;; to limit the length of a string. This function is necessary since
2175 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2176 (defsubst gnus-limit-string (str width)
2177 (if (> (length str) width)
2178 (substring str 0 width)
2181 (defsubst gnus-simplify-subject-re (subject)
2182 "Remove \"Re:\" from subject lines."
2183 (if (string-match "^[Rr][Ee]: *" subject)
2184 (substring subject (match-end 0))
2187 (defsubst gnus-functionp (form)
2188 "Return non-nil if FORM is funcallable."
2189 (or (and (symbolp form) (fboundp form))
2190 (and (listp form) (eq (car form) 'lambda))))
2192 (defsubst gnus-goto-char (point)
2193 (and point (goto-char point)))
2195 (defmacro gnus-buffer-exists-p (buffer)
2196 `(let ((buffer ,buffer))
2198 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2201 (defmacro gnus-kill-buffer (buffer)
2202 `(let ((buf ,buffer))
2203 (if (gnus-buffer-exists-p buf)
2204 (kill-buffer buf))))
2206 (defsubst gnus-point-at-bol ()
2207 "Return point at the beginning of the line."
2214 (defsubst gnus-point-at-eol ()
2215 "Return point at the end of the line."
2222 (defun gnus-alive-p ()
2223 "Say whether Gnus is running or not."
2224 (and gnus-group-buffer
2225 (get-buffer gnus-group-buffer)))
2227 (defun gnus-delete-first (elt list)
2228 "Delete by side effect the first occurrence of ELT as a member of LIST."
2229 (if (equal (car list) elt)
2232 (while (and (cdr list)
2233 (not (equal (cadr list) elt)))
2234 (setq list (cdr list)))
2236 (setcdr list (cddr list)))
2239 ;; Delete the current line (and the next N lines.);
2240 (defmacro gnus-delete-line (&optional n)
2241 `(delete-region (progn (beginning-of-line) (point))
2242 (progn (forward-line ,(or n 1)) (point))))
2244 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2245 (defvar gnus-init-inhibit nil)
2246 (defun gnus-read-init-file (&optional inhibit-next)
2247 (if gnus-init-inhibit
2248 (setq gnus-init-inhibit nil)
2249 (setq gnus-init-inhibit inhibit-next)
2251 (or (and (file-exists-p gnus-init-file)
2252 ;; Don't try to load a directory.
2253 (not (file-directory-p gnus-init-file)))
2254 (file-exists-p (concat gnus-init-file ".el"))
2255 (file-exists-p (concat gnus-init-file ".elc")))
2257 (load gnus-init-file nil t)
2259 (error "Error in %s: %s" gnus-init-file var))))))
2261 ;; Info access macros.
2263 (defmacro gnus-info-group (info)
2265 (defmacro gnus-info-rank (info)
2267 (defmacro gnus-info-read (info)
2269 (defmacro gnus-info-marks (info)
2271 (defmacro gnus-info-method (info)
2273 (defmacro gnus-info-params (info)
2276 (defmacro gnus-info-level (info)
2277 `(let ((rank (gnus-info-rank ,info)))
2281 (defmacro gnus-info-score (info)
2282 `(let ((rank (gnus-info-rank ,info)))
2283 (or (and (consp rank) (cdr rank)) 0)))
2285 (defmacro gnus-info-set-group (info group)
2286 `(setcar ,info ,group))
2287 (defmacro gnus-info-set-rank (info rank)
2288 `(setcar (nthcdr 1 ,info) ,rank))
2289 (defmacro gnus-info-set-read (info read)
2290 `(setcar (nthcdr 2 ,info) ,read))
2291 (defmacro gnus-info-set-marks (info marks)
2292 `(setcar (nthcdr 3 ,info) ,marks))
2293 (defmacro gnus-info-set-method (info method)
2294 `(setcar (nthcdr 4 ,info) ,method))
2295 (defmacro gnus-info-set-params (info params)
2296 `(setcar (nthcdr 5 ,info) ,params))
2298 (defmacro gnus-info-set-level (info level)
2299 `(let ((rank (cdr ,info)))
2300 (if (consp (car rank))
2301 (setcar (car rank) ,level)
2302 (setcar rank ,level))))
2303 (defmacro gnus-info-set-score (info score)
2304 `(let ((rank (cdr ,info)))
2305 (if (consp (car rank))
2306 (setcdr (car rank) ,score)
2307 (setcar rank (cons (car rank) ,score)))))
2309 (defmacro gnus-get-info (group)
2310 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2312 (defun gnus-byte-code (func)
2313 "Return a form that can be `eval'ed based on FUNC."
2314 (let ((fval (symbol-function func)))
2315 (if (byte-code-function-p fval)
2316 (let ((flist (append fval nil)))
2317 (setcar flist 'byte-code)
2319 (cons 'progn (cddr fval)))))
2321 ;; Find out whether the gnus-visual TYPE is wanted.
2322 (defun gnus-visual-p (&optional type class)
2323 (and gnus-visual ; Has to be non-nil, at least.
2324 (if (not type) ; We don't care about type.
2326 (if (listp gnus-visual) ; It's a list, so we check it.
2327 (or (memq type gnus-visual)
2328 (memq class gnus-visual))
2331 ;;; Load the compatability functions.
2341 (defvar gnus-shutdown-alist nil)
2343 (defun gnus-add-shutdown (function &rest symbols)
2344 "Run FUNCTION whenever one of SYMBOLS is shut down."
2345 (push (cons function symbols) gnus-shutdown-alist))
2347 (defun gnus-shutdown (symbol)
2348 "Shut down everything that waits for SYMBOL."
2349 (let ((alist gnus-shutdown-alist)
2351 (while (setq entry (pop alist))
2352 (when (memq symbol (cdr entry))
2353 (funcall (car entry))))))
2357 ;; Format specs. The chunks below are the machine-generated forms
2358 ;; that are to be evaled as the result of the default format strings.
2359 ;; We write them in here to get them byte-compiled. That way the
2360 ;; default actions will be quite fast, while still retaining the full
2361 ;; flexibility of the user-defined format specs.
2363 ;; First we have lots of dummy defvars to let the compiler know these
2364 ;; are really dynamic variables.
2366 (defvar gnus-tmp-unread)
2367 (defvar gnus-tmp-replied)
2368 (defvar gnus-tmp-score-char)
2369 (defvar gnus-tmp-indentation)
2370 (defvar gnus-tmp-opening-bracket)
2371 (defvar gnus-tmp-lines)
2372 (defvar gnus-tmp-name)
2373 (defvar gnus-tmp-closing-bracket)
2374 (defvar gnus-tmp-subject-or-nil)
2375 (defvar gnus-tmp-subject)
2376 (defvar gnus-tmp-marked)
2377 (defvar gnus-tmp-marked-mark)
2378 (defvar gnus-tmp-subscribed)
2379 (defvar gnus-tmp-process-marked)
2380 (defvar gnus-tmp-number-of-unread)
2381 (defvar gnus-tmp-group-name)
2382 (defvar gnus-tmp-group)
2383 (defvar gnus-tmp-article-number)
2384 (defvar gnus-tmp-unread-and-unselected)
2385 (defvar gnus-tmp-news-method)
2386 (defvar gnus-tmp-news-server)
2387 (defvar gnus-tmp-article-number)
2388 (defvar gnus-mouse-face)
2389 (defvar gnus-mouse-face-prop)
2391 (defun gnus-summary-line-format-spec ()
2392 (insert gnus-tmp-unread gnus-tmp-replied
2393 gnus-tmp-score-char gnus-tmp-indentation)
2394 (gnus-put-text-property
2398 gnus-tmp-opening-bracket
2399 (format "%4d: %-20s"
2401 (if (> (length gnus-tmp-name) 20)
2402 (substring gnus-tmp-name 0 20)
2404 gnus-tmp-closing-bracket)
2406 gnus-mouse-face-prop gnus-mouse-face)
2407 (insert " " gnus-tmp-subject-or-nil "\n"))
2409 (defvar gnus-summary-line-format-spec
2410 (gnus-byte-code 'gnus-summary-line-format-spec))
2412 (defun gnus-summary-dummy-line-format-spec ()
2414 (gnus-put-text-property
2419 gnus-mouse-face-prop gnus-mouse-face)
2420 (insert " " gnus-tmp-subject "\n"))
2422 (defvar gnus-summary-dummy-line-format-spec
2423 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2425 (defun gnus-group-line-format-spec ()
2426 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2427 gnus-tmp-process-marked
2428 gnus-group-indentation
2429 (format "%5s: " gnus-tmp-number-of-unread))
2430 (gnus-put-text-property
2433 (insert gnus-tmp-group "\n")
2435 gnus-mouse-face-prop gnus-mouse-face))
2436 (defvar gnus-group-line-format-spec
2437 (gnus-byte-code 'gnus-group-line-format-spec))
2439 (defvar gnus-format-specs
2440 `((version . ,emacs-version)
2441 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2442 (summary-dummy ,gnus-summary-dummy-line-format
2443 ,gnus-summary-dummy-line-format-spec)
2444 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2446 (defvar gnus-article-mode-line-format-spec nil)
2447 (defvar gnus-summary-mode-line-format-spec nil)
2448 (defvar gnus-group-mode-line-format-spec nil)
2450 ;;; Phew. All that gruft is over, fortunately.
2454 ;;; Gnus Utility Functions
2457 (defun gnus-extract-address-components (from)
2459 ;; First find the address - the thing with the @ in it. This may
2460 ;; not be accurate in mail addresses, but does the trick most of
2461 ;; the time in news messages.
2462 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2463 (setq address (substring from (match-beginning 0) (match-end 0))))
2464 ;; Then we check whether the "name <address>" format is used.
2466 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2467 ;; Linear white space is not required.
2468 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2469 (and (setq name (substring from 0 (match-beginning 0)))
2470 ;; Strip any quotes from the name.
2471 (string-match "\".*\"" name)
2472 (setq name (substring name 1 (1- (match-end 0))))))
2473 ;; If not, then "address (name)" is used.
2475 (and (string-match "(.+)" from)
2476 (setq name (substring from (1+ (match-beginning 0))
2477 (1- (match-end 0)))))
2478 (and (string-match "()" from)
2479 (setq name address))
2480 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2481 ;; XOVER might not support folded From headers.
2482 (and (string-match "(.*" from)
2483 (setq name (substring from (1+ (match-beginning 0))
2485 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2486 (list (or name from) (or address from))))
2488 (defun gnus-fetch-field (field)
2489 "Return the value of the header FIELD of current article."
2492 (let ((case-fold-search t)
2493 (inhibit-point-motion-hooks t))
2494 (nnheader-narrow-to-headers)
2495 (message-fetch-field field)))))
2497 (defun gnus-goto-colon ()
2499 (search-forward ":" (gnus-point-at-eol) t))
2502 (defun gnus-update-format (var)
2503 "Update the format specification near point."
2508 ;; Find the end of the current word.
2509 (re-search-forward "[ \t\n]" nil t)
2511 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2512 (match-string 1)))))
2513 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2514 (match-string 1 var))))
2515 (entry (assq type gnus-format-specs))
2518 (setq gnus-format-specs (delq entry gnus-format-specs)))
2520 (intern (format "%s-spec" var))
2521 (gnus-parse-format (setq value (symbol-value (intern var)))
2522 (symbol-value (intern (format "%s-alist" var)))
2523 (not (string-match "mode" var))))
2524 (setq spec (symbol-value (intern (format "%s-spec" var))))
2525 (push (list type value spec) gnus-format-specs)
2527 (pop-to-buffer "*Gnus Format*")
2529 (lisp-interaction-mode)
2530 (insert (pp-to-string spec))))
2532 (defun gnus-update-format-specifications (&optional force)
2533 "Update all (necessary) format specifications."
2534 ;; Make the indentation array.
2535 (gnus-make-thread-indent-array)
2537 ;; See whether all the stored info needs to be flushed.
2539 (not (equal emacs-version
2540 (cdr (assq 'version gnus-format-specs)))))
2541 (setq gnus-format-specs nil))
2543 ;; Go through all the formats and see whether they need updating.
2544 (let ((types '(summary summary-dummy group
2545 summary-mode group-mode article-mode))
2546 new-format entry type val)
2547 (while (setq type (pop types))
2548 ;; Jump to the proper buffer to find out the value of
2549 ;; the variable, if possible. (It may be buffer-local.)
2551 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2553 (when (and (boundp buffer)
2554 (setq val (symbol-value buffer))
2556 (buffer-name (get-buffer val)))
2557 (set-buffer (get-buffer val)))
2558 (setq new-format (symbol-value
2559 (intern (format "gnus-%s-line-format" type))))))
2560 (setq entry (cdr (assq type gnus-format-specs)))
2562 (equal (car entry) new-format))
2563 ;; Use the old format.
2564 (set (intern (format "gnus-%s-line-format-spec" type))
2566 ;; This is a new format.
2568 (if (not (stringp new-format))
2569 ;; This is a function call or something.
2571 ;; This is a "real" format.
2575 (intern (format "gnus-%s-line-format-alist"
2576 (if (eq type 'article-mode)
2577 'summary-mode type))))
2578 (not (string-match "mode$" (symbol-name type))))))
2579 ;; Enter the new format spec into the list.
2582 (setcar (cdr entry) val)
2583 (setcar entry new-format))
2584 (push (list type new-format val) gnus-format-specs))
2585 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2587 (unless (assq 'version gnus-format-specs)
2588 (push (cons 'version emacs-version) gnus-format-specs))
2590 (gnus-update-group-mark-positions)
2591 (gnus-update-summary-mark-positions))
2593 (defun gnus-update-summary-mark-positions ()
2594 "Compute where the summary marks are to go."
2596 (when (and gnus-summary-buffer
2597 (get-buffer gnus-summary-buffer)
2598 (buffer-name (get-buffer gnus-summary-buffer)))
2599 (set-buffer gnus-summary-buffer))
2600 (let ((gnus-replied-mark 129)
2601 (gnus-score-below-mark 130)
2602 (gnus-score-over-mark 130)
2605 (spec gnus-summary-line-format-spec)
2608 (gnus-set-work-buffer)
2609 (let ((gnus-summary-line-format-spec spec))
2610 (gnus-summary-insert-line
2611 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2612 (goto-char (point-min))
2613 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2615 (goto-char (point-min))
2616 (push (cons 'replied (and (search-forward "\201" nil t)
2619 (goto-char (point-min))
2620 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2622 (setq gnus-summary-mark-positions pos))))
2624 (defun gnus-update-group-mark-positions ()
2626 (let ((gnus-process-mark 128)
2627 (gnus-group-marked '("dummy.group"))
2628 (gnus-active-hashtb (make-vector 10 0)))
2629 (gnus-set-active "dummy.group" '(0 . 0))
2630 (gnus-set-work-buffer)
2631 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2632 (goto-char (point-min))
2633 (setq gnus-group-mark-positions
2634 (list (cons 'process (and (search-forward "\200" nil t)
2635 (- (point) 2))))))))
2637 (defvar gnus-mouse-face-0 'highlight)
2638 (defvar gnus-mouse-face-1 'highlight)
2639 (defvar gnus-mouse-face-2 'highlight)
2640 (defvar gnus-mouse-face-3 'highlight)
2641 (defvar gnus-mouse-face-4 'highlight)
2643 (defun gnus-mouse-face-function (form type)
2644 `(gnus-put-text-property
2645 (point) (progn ,@form (point))
2646 gnus-mouse-face-prop
2649 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2651 (defvar gnus-face-0 'bold)
2652 (defvar gnus-face-1 'italic)
2653 (defvar gnus-face-2 'bold-italic)
2654 (defvar gnus-face-3 'bold)
2655 (defvar gnus-face-4 'bold)
2657 (defun gnus-face-face-function (form type)
2658 `(gnus-put-text-property
2659 (point) (progn ,@form (point))
2660 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2662 (defun gnus-max-width-function (el max-width)
2663 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2665 `(if (> (length ,el) ,max-width)
2666 (substring ,el 0 ,max-width)
2668 `(let ((val (eval ,el)))
2670 (setq val (int-to-string val)))
2671 (if (> (length val) ,max-width)
2672 (substring val 0 ,max-width)
2675 (defun gnus-parse-format (format spec-alist &optional insert)
2676 ;; This function parses the FORMAT string with the help of the
2677 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2678 ;; string. If the FORMAT string contains the specifiers %( and %)
2679 ;; the text between them will have the mouse-face text property.
2681 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2683 (gnus-parse-complex-format format spec-alist)
2684 ;; This is a simple format.
2685 (gnus-parse-simple-format format spec-alist insert)))
2687 (defun gnus-parse-complex-format (format spec-alist)
2689 (gnus-set-work-buffer)
2691 (goto-char (point-min))
2692 (while (re-search-forward "\"" nil t)
2693 (replace-match "\\\"" nil t))
2694 (goto-char (point-min))
2696 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2697 (let ((number (if (match-beginning 1)
2698 (match-string 1) "0"))
2699 (delim (aref (match-string 2) 0)))
2700 (if (or (= delim ?\() (= delim ?\{))
2701 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2703 (replace-match "\")\""))))
2704 (goto-char (point-max))
2706 (goto-char (point-min))
2707 (let ((form (read (current-buffer))))
2708 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2710 (defun gnus-complex-form-to-spec (form spec-alist)
2715 (gnus-parse-simple-format sform spec-alist t)
2716 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2717 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2721 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2722 ;; This function parses the FORMAT string with the help of the
2723 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2726 spec flist fstring newspec elem beg result dontinsert)
2728 (gnus-set-work-buffer)
2730 (goto-char (point-min))
2731 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2733 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2735 beg (1+ (match-beginning 0)))
2736 ;; First check if there are any specs that look anything like
2737 ;; "%12,12A", ie. with a "max width specification". These have
2738 ;; to be treated specially.
2739 (if (setq beg (match-beginning 1))
2743 (1+ (match-beginning 1)) (match-end 1))))
2745 (setq beg (match-beginning 2)))
2746 ;; Find the specification from `spec-alist'.
2747 (unless (setq elem (cdr (assq spec spec-alist)))
2748 (setq elem '("*" ?s)))
2749 ;; Treat user defined format specifiers specially.
2750 (when (eq (car elem) 'gnus-tmp-user-defined)
2753 (list (intern (concat "gnus-user-format-function-"
2755 'gnus-tmp-header) ?s))
2756 (delete-region (match-beginning 3) (match-end 3)))
2757 (if (not (zerop max-width))
2758 (let ((el (car elem)))
2759 (cond ((= (cadr elem) ?c)
2760 (setq el (list 'char-to-string el)))
2762 (setq el (list 'int-to-string el))))
2763 (setq flist (cons (gnus-max-width-function el max-width)
2767 (setq flist (cons (car elem) flist))
2768 (setq newspec (cadr elem)))))
2769 ;; Remove the old specification (and possibly a ",12" string).
2770 (delete-region beg (match-end 2))
2771 ;; Insert the new specification.
2774 (setq fstring (buffer-substring 1 (point-max))))
2775 ;; Do some postprocessing to increase efficiency.
2780 ((string= fstring "")
2782 ;; Not a format string.
2783 ((not (string-match "%" fstring))
2785 ;; A format string with just a single string spec.
2786 ((string= fstring "%s")
2788 ;; A single character.
2789 ((string= fstring "%c")
2792 ((string= fstring "%d")
2795 (list `(princ ,(car flist)))
2796 (list `(int-to-string ,(car flist)))))
2797 ;; Just lots of chars and strings.
2798 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2800 ;; A single string spec at the beginning of the spec.
2801 ((string-match "\\`%[sc][^%]+\\'" fstring)
2802 (list (car flist) (substring fstring 2)))
2803 ;; A single string spec in the middle of the spec.
2804 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2805 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2806 ;; A single string spec in the end of the spec.
2807 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2808 (list (match-string 1 fstring) (car flist)))
2809 ;; A more complex spec.
2811 (list (cons 'format (cons fstring (nreverse flist)))))))
2817 (cons 'insert result)))
2818 (cond ((stringp result)
2821 (cons 'concat result))
2824 (defun gnus-eval-format (format &optional alist props)
2825 "Eval the format variable FORMAT, using ALIST.
2826 If PROPS, insert the result."
2827 (let ((form (gnus-parse-format format alist props)))
2829 (gnus-add-text-properties (point) (progn (eval form) (point)) props)
2832 (defun gnus-remove-text-with-property (prop)
2833 "Delete all text in the current buffer with text property PROP."
2835 (goto-char (point-min))
2837 (while (get-text-property (point) prop)
2839 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2841 (defun gnus-set-work-buffer ()
2842 (if (get-buffer gnus-work-buffer)
2844 (set-buffer gnus-work-buffer)
2846 (set-buffer (get-buffer-create gnus-work-buffer))
2847 (kill-all-local-variables)
2848 (buffer-disable-undo (current-buffer))
2849 (gnus-add-current-to-buffer-list)))
2851 ;; Article file names when saving.
2853 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2854 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2855 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2856 Otherwise, it is like ~/News/news/group/num."
2859 (concat (if (gnus-use-long-file-name 'not-save)
2860 (gnus-capitalize-newsgroup newsgroup)
2861 (gnus-newsgroup-directory-form newsgroup))
2862 "/" (int-to-string (mail-header-number headers)))
2863 gnus-article-save-directory)))
2865 (string-equal (file-name-directory default)
2866 (file-name-directory last-file))
2867 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2869 (or last-file default))))
2871 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2872 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2873 If variable `gnus-use-long-file-name' is non-nil, it is
2874 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2877 (concat (if (gnus-use-long-file-name 'not-save)
2879 (gnus-newsgroup-directory-form newsgroup))
2880 "/" (int-to-string (mail-header-number headers)))
2881 gnus-article-save-directory)))
2883 (string-equal (file-name-directory default)
2884 (file-name-directory last-file))
2885 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2887 (or last-file default))))
2889 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2890 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2891 If variable `gnus-use-long-file-name' is non-nil, it is
2892 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2895 (if (gnus-use-long-file-name 'not-save)
2896 (gnus-capitalize-newsgroup newsgroup)
2897 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2898 gnus-article-save-directory)))
2900 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2901 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2902 If variable `gnus-use-long-file-name' is non-nil, it is
2903 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2906 (if (gnus-use-long-file-name 'not-save)
2908 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2909 gnus-article-save-directory)))
2911 ;; For subscribing new newsgroup
2913 (defun gnus-subscribe-hierarchical-interactive (groups)
2914 (let ((groups (sort groups 'string<))
2915 prefixes prefix start ans group starts)
2917 (setq prefixes (list "^"))
2918 (while (and groups prefixes)
2919 (while (not (string-match (car prefixes) (car groups)))
2920 (setq prefixes (cdr prefixes)))
2921 (setq prefix (car prefixes))
2922 (setq start (1- (length prefix)))
2923 (if (and (string-match "[^\\.]\\." (car groups) start)
2926 (concat "^" (substring (car groups) 0 (match-end 0))))
2927 (string-match prefix (cadr groups)))
2929 (setq prefixes (cons prefix prefixes))
2930 (message "Descend hierarchy %s? ([y]nsq): "
2931 (substring prefix 1 (1- (length prefix))))
2932 (while (not (memq (setq ans (read-char)) '(?y ?\n ?n ?s ?q)))
2934 (message "Descend hierarchy %s? ([y]nsq): "
2935 (substring prefix 1 (1- (length prefix)))))
2938 (string-match prefix
2939 (setq group (car groups))))
2940 (setq gnus-killed-list
2941 (cons group gnus-killed-list))
2942 (gnus-sethash group group gnus-killed-hashtb)
2943 (setq groups (cdr groups)))
2944 (setq starts (cdr starts)))
2947 (string-match prefix
2948 (setq group (car groups))))
2949 (gnus-sethash group group gnus-killed-hashtb)
2950 (gnus-subscribe-alphabetically (car groups))
2951 (setq groups (cdr groups)))
2952 (setq starts (cdr starts)))
2955 (setq group (car groups))
2956 (setq gnus-killed-list (cons group gnus-killed-list))
2957 (gnus-sethash group group gnus-killed-hashtb)
2958 (setq groups (cdr groups))))
2960 (message "Subscribe %s? ([n]yq)" (car groups))
2961 (while (not (memq (setq ans (read-char)) '(?y ?\n ?q ?n)))
2963 (message "Subscribe %s? ([n]yq)" (car groups)))
2964 (setq group (car groups))
2966 (gnus-subscribe-alphabetically (car groups))
2967 (gnus-sethash group group gnus-killed-hashtb))
2970 (setq group (car groups))
2971 (setq gnus-killed-list (cons group gnus-killed-list))
2972 (gnus-sethash group group gnus-killed-hashtb)
2973 (setq groups (cdr groups))))
2975 (setq gnus-killed-list (cons group gnus-killed-list))
2976 (gnus-sethash group group gnus-killed-hashtb)))
2977 (setq groups (cdr groups)))))))
2979 (defun gnus-subscribe-randomly (newsgroup)
2980 "Subscribe new NEWSGROUP by making it the first newsgroup."
2981 (gnus-subscribe-newsgroup newsgroup))
2983 (defun gnus-subscribe-alphabetically (newgroup)
2984 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2985 (let ((groups (cdr gnus-newsrc-alist))
2987 (while (and (not before) groups)
2988 (if (string< newgroup (caar groups))
2989 (setq before (caar groups))
2990 (setq groups (cdr groups))))
2991 (gnus-subscribe-newsgroup newgroup before)))
2993 (defun gnus-subscribe-hierarchically (newgroup)
2994 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2995 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2997 (set-buffer (find-file-noselect gnus-current-startup-file))
2998 (let ((groupkey newgroup)
3000 (while (and (not before) groupkey)
3001 (goto-char (point-min))
3003 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
3004 (while (and (re-search-forward groupkey-re nil t)
3006 (setq before (match-string 1))
3007 (string< before newgroup)))))
3008 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
3010 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
3011 (substring groupkey (match-beginning 1) (match-end 1)))))
3012 (gnus-subscribe-newsgroup newgroup before))))
3014 (defun gnus-subscribe-interactively (group)
3015 "Subscribe the new GROUP interactively.
3016 It is inserted in hierarchical newsgroup order if subscribed. If not,
3018 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
3019 (gnus-subscribe-hierarchically group)
3020 (push group gnus-killed-list)))
3022 (defun gnus-subscribe-zombies (group)
3023 "Make the new GROUP into a zombie group."
3024 (push group gnus-zombie-list))
3026 (defun gnus-subscribe-killed (group)
3027 "Make the new GROUP a killed group."
3028 (push group gnus-killed-list))
3030 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
3031 "Subscribe new NEWSGROUP.
3032 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
3033 the first newsgroup."
3034 ;; We subscribe the group by changing its level to `subscribed'.
3035 (gnus-group-change-level
3036 newsgroup gnus-level-default-subscribed
3037 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
3038 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
3042 (defun gnus-newsgroup-directory-form (newsgroup)
3043 "Make hierarchical directory name from NEWSGROUP name."
3044 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
3045 (len (length newsgroup))
3047 ;; If this is a foreign group, we don't want to translate the
3049 (if (setq idx (string-match ":" newsgroup))
3050 (aset newsgroup idx ?/)
3052 ;; Replace all occurrences of `.' with `/'.
3054 (if (= (aref newsgroup idx) ?.)
3055 (aset newsgroup idx ?/))
3056 (setq idx (1+ idx)))
3059 (defun gnus-newsgroup-savable-name (group)
3060 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
3062 (nnheader-replace-chars-in-string group ?/ ?.))
3064 (defun gnus-make-directory (dir)
3065 "Make DIRECTORY recursively."
3066 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
3067 ;; of the many mysteries of the universe.
3068 (let* ((dir (expand-file-name dir default-directory))
3070 (if (string-match "/$" dir)
3071 (setq dir (substring dir 0 (match-beginning 0))))
3072 ;; First go down the path until we find a directory that exists.
3073 (while (not (file-exists-p dir))
3074 (setq dirs (cons dir dirs))
3075 (string-match "/[^/]+$" dir)
3076 (setq dir (substring dir 0 (match-beginning 0))))
3077 ;; Then create all the subdirs.
3078 (while (and dirs (not err))
3080 (make-directory (car dirs))
3081 (error (setq err t)))
3082 (setq dirs (cdr dirs)))
3083 ;; We return whether we were successful or not.
3086 (defun gnus-capitalize-newsgroup (newsgroup)
3087 "Capitalize NEWSGROUP name."
3088 (and (not (zerop (length newsgroup)))
3089 (concat (char-to-string (upcase (aref newsgroup 0)))
3090 (substring newsgroup 1))))
3092 ;; Various... things.
3094 (defun gnus-simplify-subject (subject &optional re-only)
3095 "Remove `Re:' and words in parentheses.
3096 If RE-ONLY is non-nil, strip leading `Re:'s only."
3097 (let ((case-fold-search t)) ;Ignore case.
3098 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3099 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3100 (setq subject (substring subject (match-end 0))))
3101 ;; Remove uninteresting prefixes.
3102 (if (and (not re-only)
3103 gnus-simplify-ignored-prefixes
3104 (string-match gnus-simplify-ignored-prefixes subject))
3105 (setq subject (substring subject (match-end 0))))
3106 ;; Remove words in parentheses from end.
3108 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3109 (setq subject (substring subject 0 (match-beginning 0)))))
3110 ;; Return subject string.
3113 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3115 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3116 (defun gnus-simplify-buffer-fuzzy ()
3117 (let ((case-fold-search t))
3118 (goto-char (point-min))
3119 (while (search-forward "\t" nil t)
3120 (replace-match " " t t))
3121 (goto-char (point-min))
3122 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3123 (goto-char (match-beginning 0))
3125 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3126 (looking-at "^[[].*: .*[]]$"))
3127 (goto-char (point-min))
3128 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3130 (replace-match "" t t))
3131 (goto-char (point-min))
3132 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3133 (goto-char (match-end 0))
3136 (progn (goto-char (match-beginning 0)))
3137 (re-search-forward ":"))))
3138 (goto-char (point-min))
3139 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3140 (replace-match "" t t))
3141 (goto-char (point-min))
3142 (while (re-search-forward " +" nil t)
3143 (replace-match " " t t))
3144 (goto-char (point-min))
3145 (while (re-search-forward " $" nil t)
3146 (replace-match "" t t))
3147 (goto-char (point-min))
3148 (while (re-search-forward "^ +" nil t)
3149 (replace-match "" t t))
3150 (goto-char (point-min))
3151 (when gnus-simplify-subject-fuzzy-regexp
3152 (if (listp gnus-simplify-subject-fuzzy-regexp)
3153 (let ((list gnus-simplify-subject-fuzzy-regexp))
3155 (goto-char (point-min))
3156 (while (re-search-forward (car list) nil t)
3157 (replace-match "" t t))
3158 (setq list (cdr list))))
3159 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3160 (replace-match "" t t))))))
3162 (defun gnus-simplify-subject-fuzzy (subject)
3163 "Siplify a subject string fuzzily."
3165 (gnus-set-work-buffer)
3166 (let ((case-fold-search t))
3168 (inline (gnus-simplify-buffer-fuzzy))
3171 ;; Add the current buffer to the list of buffers to be killed on exit.
3172 (defun gnus-add-current-to-buffer-list ()
3173 (or (memq (current-buffer) gnus-buffer-list)
3174 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3176 (defun gnus-string> (s1 s2)
3177 (not (or (string< s1 s2)
3180 (defun gnus-read-active-file-p ()
3181 "Say whether the active file has been read from `gnus-select-method'."
3182 (memq gnus-select-method gnus-have-read-active-file))
3184 ;;; General various misc type functions.
3186 (defun gnus-clear-system ()
3187 "Clear all variables and buffers."
3188 ;; Clear Gnus variables.
3189 (let ((variables gnus-variable-list))
3191 (set (car variables) nil)
3192 (setq variables (cdr variables))))
3193 ;; Clear other internal variables.
3194 (setq gnus-list-of-killed-groups nil
3195 gnus-have-read-active-file nil
3196 gnus-newsrc-alist nil
3197 gnus-newsrc-hashtb nil
3198 gnus-killed-list nil
3199 gnus-zombie-list nil
3200 gnus-killed-hashtb nil
3201 gnus-active-hashtb nil
3202 gnus-moderated-list nil
3203 gnus-description-hashtb nil
3204 gnus-current-headers nil
3205 gnus-thread-indent-array nil
3206 gnus-newsgroup-headers nil
3207 gnus-newsgroup-name nil
3208 gnus-server-alist nil
3209 gnus-group-list-mode nil
3210 gnus-opened-servers nil
3211 gnus-current-select-method nil)
3212 (gnus-shutdown 'gnus)
3213 ;; Kill the startup file.
3214 (and gnus-current-startup-file
3215 (get-file-buffer gnus-current-startup-file)
3216 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3217 ;; Clear the dribble buffer.
3218 (gnus-dribble-clear)
3219 ;; Kill global KILL file buffer.
3220 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3221 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3222 (gnus-kill-buffer nntp-server-buffer)
3223 ;; Kill Gnus buffers.
3224 (while gnus-buffer-list
3225 (gnus-kill-buffer (pop gnus-buffer-list)))
3226 ;; Remove Gnus frames.
3227 (while gnus-created-frames
3228 (when (frame-live-p (car gnus-created-frames))
3229 ;; We slap a condition-case around this `delete-frame' to ensure
3230 ;; agains errors if we try do delete the single frame that's left.
3232 (delete-frame (car gnus-created-frames))
3234 (pop gnus-created-frames)))
3236 (defun gnus-windows-old-to-new (setting)
3237 ;; First we take care of the really, really old Gnus 3 actions.
3238 (when (symbolp setting)
3240 ;; Take care of ooold GNUS 3.x values.
3241 (cond ((eq setting 'SelectArticle) 'article)
3242 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3243 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3245 (if (or (listp setting)
3246 (not (and gnus-window-configuration
3247 (memq setting '(group summary article)))))
3249 (let* ((setting (if (eq setting 'group)
3250 (if (assq 'newsgroup gnus-window-configuration)
3252 'newsgroups) setting))
3253 (elem (cadr (assq setting gnus-window-configuration)))
3254 (total (apply '+ elem))
3255 (types '(group summary article))
3256 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3261 (or (not (numberp (nth i elem)))
3262 (zerop (nth i elem))
3264 (setq perc (/ (float (nth 0 elem)) total))
3265 (setq out (cons (if (eq pbuf (nth i types))
3266 (vector (nth i types) perc 'point)
3267 (vector (nth i types) perc))
3270 (list (nreverse out)))))
3273 (defun gnus-add-configuration (conf)
3274 "Add the window configuration CONF to `gnus-buffer-configuration'."
3275 (setq gnus-buffer-configuration
3276 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3277 gnus-buffer-configuration))))
3279 (defvar gnus-frame-list nil)
3281 (defun gnus-configure-frame (split &optional window)
3282 "Split WINDOW according to SPLIT."
3284 (setq window (get-buffer-window (current-buffer))))
3285 (select-window window)
3286 ;; This might be an old-stylee buffer config.
3287 (when (vectorp split)
3288 (setq split (append split nil)))
3289 (when (or (consp (car split))
3290 (vectorp (car split)))
3292 (push 'vertical split))
3293 ;; The SPLIT might be something that is to be evaled to
3294 ;; return a new SPLIT.
3295 (while (and (not (assq (car split) gnus-window-to-buffer))
3296 (gnus-functionp (car split)))
3297 (setq split (eval split)))
3298 (let* ((type (car split))
3300 (len (if (eq type 'horizontal) (window-width) (window-height)))
3302 (window-min-width (or gnus-window-min-width window-min-width))
3303 (window-min-height (or gnus-window-min-height window-min-height))
3304 s result new-win rest comp-subs size sub)
3306 ;; Nothing to do here.
3308 ;; Don't switch buffers.
3310 (and (memq 'point split) window))
3311 ;; This is a buffer to be selected.
3312 ((not (memq type '(frame horizontal vertical)))
3313 (let ((buffer (cond ((stringp type) type)
3314 (t (cdr (assq type gnus-window-to-buffer)))))
3317 (error "Illegal buffer type: %s" type))
3318 (unless (setq buf (get-buffer (if (symbolp buffer)
3319 (symbol-value buffer) buffer)))
3320 (setq buf (get-buffer-create (if (symbolp buffer)
3321 (symbol-value buffer) buffer))))
3322 (switch-to-buffer buf)
3323 ;; We return the window if it has the `point' spec.
3324 (and (memq 'point split) window)))
3325 ;; This is a frame split.
3327 (unless gnus-frame-list
3328 (setq gnus-frame-list (list (window-frame
3329 (get-buffer-window (current-buffer))))))
3331 params frame fresult)
3332 (while (< i (length subs))
3333 ;; Frame parameter is gotten from the sub-split.
3334 (setq params (cadr (elt subs i)))
3335 ;; It should be a list.
3336 (unless (listp params)
3338 ;; Create a new frame?
3339 (unless (setq frame (elt gnus-frame-list i))
3340 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3341 (push frame gnus-created-frames))
3342 ;; Is the old frame still alive?
3343 (unless (frame-live-p frame)
3344 (setcar (nthcdr i gnus-frame-list)
3345 (setq frame (make-frame params))))
3346 ;; Select the frame in question and do more splits there.
3347 (select-frame frame)
3348 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3350 ;; Select the frame that has the selected buffer.
3352 (select-frame (window-frame fresult)))))
3353 ;; This is a normal split.
3355 (when (> (length subs) 0)
3356 ;; First we have to compute the sizes of all new windows.
3358 (setq sub (append (pop subs) nil))
3359 (while (and (not (assq (car sub) gnus-window-to-buffer))
3360 (gnus-functionp (car sub)))
3361 (setq sub (eval sub)))
3363 (push sub comp-subs)
3364 (setq size (cadar comp-subs))
3365 (cond ((equal size 1.0)
3366 (setq rest (car comp-subs))
3369 (setq s (floor (* size len))))
3373 (error "Illegal size: %s" size)))
3374 ;; Try to make sure that we are inside the safe limits.
3376 ((eq type 'horizontal)
3377 (setq s (max s window-min-width)))
3378 ((eq type 'vertical)
3379 (setq s (max s window-min-height))))
3380 (setcar (cdar comp-subs) s)
3382 ;; Take care of the "1.0" spec.
3384 (setcar (cdr rest) (- len total))
3385 (error "No 1.0 specs in %s" split))
3386 ;; The we do the actual splitting in a nice recursive
3388 (setq comp-subs (nreverse comp-subs))
3390 (if (null (cdr comp-subs))
3391 (setq new-win window)
3393 (split-window window (cadar comp-subs)
3394 (eq type 'horizontal))))
3395 (setq result (or (gnus-configure-frame
3396 (car comp-subs) window) result))
3397 (select-window new-win)
3398 (setq window new-win)
3399 (setq comp-subs (cdr comp-subs))))
3400 ;; Return the proper window, if any.
3402 (select-window result))))))
3404 (defvar gnus-frame-split-p nil)
3406 (defun gnus-configure-windows (setting &optional force)
3407 (setq setting (gnus-windows-old-to-new setting))
3408 (let ((split (if (symbolp setting)
3409 (cadr (assq setting gnus-buffer-configuration))
3413 (setq gnus-frame-split-p nil)
3416 (error "No such setting: %s" setting))
3418 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3420 ;; All the windows mentioned are already visible, so we just
3421 ;; put point in the assigned buffer, and do not touch the
3423 (select-window all-visible)
3425 ;; Either remove all windows or just remove all Gnus windows.
3426 (let ((frame (selected-frame)))
3428 (if gnus-use-full-window
3429 ;; We want to remove all other windows.
3430 (if (not gnus-frame-split-p)
3431 ;; This is not a `frame' split, so we ignore the
3433 (delete-other-windows)
3434 ;; This is a `frame' split, so we delete all windows
3438 (unless (eq (cdr (assq 'minibuffer
3439 (frame-parameters frame)))
3441 (select-frame frame)
3442 (delete-other-windows)))
3444 ;; Just remove some windows.
3445 (gnus-remove-some-windows)
3446 (switch-to-buffer nntp-server-buffer))
3447 (select-frame frame)))
3449 (switch-to-buffer nntp-server-buffer)
3450 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3452 (defun gnus-all-windows-visible-p (split)
3453 "Say whether all buffers in SPLIT are currently visible.
3454 In particular, the value returned will be the window that
3456 (let ((stack (list split))
3458 type buffer win buf)
3459 (while (and (setq split (pop stack))
3461 ;; Be backwards compatible.
3462 (when (vectorp split)
3463 (setq split (append split nil)))
3464 (when (or (consp (car split))
3465 (vectorp (car split)))
3467 (push 'vertical split))
3468 ;; The SPLIT might be something that is to be evaled to
3469 ;; return a new SPLIT.
3470 (while (and (not (assq (car split) gnus-window-to-buffer))
3471 (gnus-functionp (car split)))
3472 (setq split (eval split)))
3474 (setq type (elt split 0))
3479 ((not (memq type '(horizontal vertical frame)))
3480 (setq buffer (cond ((stringp type) type)
3481 (t (cdr (assq type gnus-window-to-buffer)))))
3483 (error "Illegal buffer type: %s" type))
3484 (when (setq buf (get-buffer (if (symbolp buffer)
3485 (symbol-value buffer)
3487 (setq win (get-buffer-window buf t)))
3489 (when (memq 'point split)
3490 (setq all-visible win))
3491 (setq all-visible nil)))
3493 (when (eq type 'frame)
3494 (setq gnus-frame-split-p t))
3495 (setq stack (append (cddr split) stack)))))
3496 (unless (eq all-visible t)
3499 (defun gnus-window-top-edge (&optional window)
3500 (nth 1 (window-edges window)))
3502 (defun gnus-remove-some-windows ()
3503 (let ((buffers gnus-window-to-buffer)
3504 buf bufs lowest-buf lowest)
3506 ;; Remove windows on all known Gnus buffers.
3508 (setq buf (cdar buffers))
3510 (setq buf (and (boundp buf) (symbol-value buf))))
3512 (get-buffer-window buf)
3514 (setq bufs (cons buf bufs))
3516 (if (or (not lowest)
3517 (< (gnus-window-top-edge) lowest))
3519 (setq lowest (gnus-window-top-edge))
3520 (setq lowest-buf buf)))))
3521 (setq buffers (cdr buffers)))
3522 ;; Remove windows on *all* summary buffers.
3525 (let ((buf (window-buffer win)))
3526 (if (string-match "^\\*Summary" (buffer-name buf))
3528 (setq bufs (cons buf bufs))
3530 (if (or (not lowest)
3531 (< (gnus-window-top-edge) lowest))
3533 (setq lowest-buf buf)
3534 (setq lowest (gnus-window-top-edge)))))))))
3537 (pop-to-buffer lowest-buf)
3538 (switch-to-buffer nntp-server-buffer)))
3540 (and (not (eq (car bufs) lowest-buf))
3541 (delete-windows-on (car bufs)))
3542 (setq bufs (cdr bufs))))))
3544 (defun gnus-version (&optional arg)
3545 "Version number of this version of Gnus.
3546 If ARG, insert string at point."
3548 (let ((methods gnus-valid-select-methods)
3551 ;; Go through all the legal select methods and add their version
3552 ;; numbers to the total version string. Only the backends that are
3553 ;; currently in use will have their message numbers taken into
3556 (setq meth (intern (concat (caar methods) "-version")))
3558 (stringp (symbol-value meth))
3559 (setq mess (concat mess "; " (symbol-value meth))))
3560 (setq methods (cdr methods)))
3562 (insert (message mess))
3565 (defun gnus-info-find-node ()
3566 "Find Info documentation of Gnus."
3568 ;; Enlarge info window if needed.
3569 (let ((mode major-mode)
3571 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3572 (setq gnus-info-buffer (current-buffer))
3573 (gnus-configure-windows 'info)))
3575 (defun gnus-days-between (date1 date2)
3576 ;; Return the number of days between date1 and date2.
3577 (- (gnus-day-number date1) (gnus-day-number date2)))
3579 (defun gnus-day-number (date)
3580 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3581 (timezone-parse-date date))))
3582 (timezone-absolute-from-gregorian
3583 (nth 1 dat) (nth 2 dat) (car dat))))
3585 (defun gnus-encode-date (date)
3586 "Convert DATE to internal time."
3587 (let* ((parse (timezone-parse-date date))
3588 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3589 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3590 (encode-time (caddr time) (cadr time) (car time)
3591 (caddr date) (cadr date) (car date) (nth 4 date))))
3593 (defun gnus-time-minus (t1 t2)
3594 "Subtract two internal times."
3595 (let ((borrow (< (cadr t1) (cadr t2))))
3596 (list (- (car t1) (car t2) (if borrow 1 0))
3597 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3599 (defun gnus-file-newer-than (file date)
3600 (let ((fdate (nth 5 (file-attributes file))))
3601 (or (> (car fdate) (car date))
3602 (and (= (car fdate) (car date))
3603 (> (nth 1 fdate) (nth 1 date))))))
3605 (defmacro gnus-local-set-keys (&rest plist)
3606 "Set the keys in PLIST in the current keymap."
3607 `(gnus-define-keys-1 (current-local-map) ',plist))
3609 (defmacro gnus-define-keys (keymap &rest plist)
3610 "Define all keys in PLIST in KEYMAP."
3611 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3613 (put 'gnus-define-keys 'lisp-indent-function 1)
3614 (put 'gnus-define-keys 'lisp-indent-hook 1)
3615 (put 'gnus-define-keymap 'lisp-indent-function 1)
3616 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3618 (defmacro gnus-define-keymap (keymap &rest plist)
3619 "Define all keys in PLIST in KEYMAP."
3620 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3622 (defun gnus-define-keys-1 (keymap plist)
3624 (error "Can't set keys in a null keymap"))
3625 (cond ((symbolp keymap)
3626 (setq keymap (symbol-value keymap)))
3629 (set (car keymap) nil)
3630 (define-prefix-command (car keymap))
3631 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3632 (setq keymap (symbol-value (car keymap)))))
3635 (when (symbolp (setq key (pop plist)))
3636 (setq key (symbol-value key)))
3637 (define-key keymap key (pop plist)))))
3639 (defun gnus-group-read-only-p (&optional group)
3640 "Check whether GROUP supports editing or not.
3641 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3642 that that variable is buffer-local to the summary buffers."
3643 (let ((group (or group gnus-newsgroup-name)))
3644 (not (gnus-check-backend-function 'request-replace-article group))))
3646 (defun gnus-group-total-expirable-p (group)
3647 "Check whether GROUP is total-expirable or not."
3648 (let ((params (gnus-info-params (gnus-get-info group))))
3649 (or (memq 'total-expire params)
3650 (cdr (assq 'total-expire params)) ; (total-expire . t)
3651 (and gnus-total-expirable-newsgroups ; Check var.
3652 (string-match gnus-total-expirable-newsgroups group)))))
3654 (defun gnus-group-auto-expirable-p (group)
3655 "Check whether GROUP is total-expirable or not."
3656 (let ((params (gnus-info-params (gnus-get-info group))))
3657 (or (memq 'auto-expire params)
3658 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3659 (and gnus-auto-expirable-newsgroups ; Check var.
3660 (string-match gnus-auto-expirable-newsgroups group)))))
3662 (defun gnus-virtual-group-p (group)
3663 "Say whether GROUP is virtual or not."
3664 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3665 gnus-valid-select-methods)))
3667 (defun gnus-news-group-p (group &optional article)
3668 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3669 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3670 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3671 (eq (gnus-request-type group article) 'news))))
3673 (defsubst gnus-simplify-subject-fully (subject)
3674 "Simplify a subject string according to the user's wishes."
3676 ((null gnus-summary-gather-subject-limit)
3677 (gnus-simplify-subject-re subject))
3678 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3679 (gnus-simplify-subject-fuzzy subject))
3680 ((numberp gnus-summary-gather-subject-limit)
3681 (gnus-limit-string (gnus-simplify-subject-re subject)
3682 gnus-summary-gather-subject-limit))
3686 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3687 "Check whether two subjects are equal. If optional argument
3688 simple-first is t, first argument is already simplified."
3690 ((null simple-first)
3691 (equal (gnus-simplify-subject-fully s1)
3692 (gnus-simplify-subject-fully s2)))
3695 (gnus-simplify-subject-fully s2)))))
3697 ;; Returns a list of writable groups.
3698 (defun gnus-writable-groups ()
3699 (let ((alist gnus-newsrc-alist)
3701 (while (setq group (car (pop alist)))
3702 (unless (gnus-group-read-only-p group)
3703 (push group groups)))
3706 (defun gnus-completing-read (default prompt &rest args)
3707 ;; Like `completing-read', except that DEFAULT is the default argument.
3708 (let* ((prompt (if default
3709 (concat prompt " (default " default ") ")
3710 (concat prompt " ")))
3711 (answer (apply 'completing-read prompt args)))
3712 (if (or (null answer) (zerop (length answer)))
3716 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3718 (defun gnus-y-or-n-p (prompt)
3723 (defun gnus-yes-or-no-p (prompt)
3725 (yes-or-no-p prompt)
3728 ;; Check whether to use long file names.
3729 (defun gnus-use-long-file-name (symbol)
3730 ;; The variable has to be set...
3731 (and gnus-use-long-file-name
3732 ;; If it isn't a list, then we return t.
3733 (or (not (listp gnus-use-long-file-name))
3734 ;; If it is a list, and the list contains `symbol', we
3736 (not (memq symbol gnus-use-long-file-name)))))
3738 ;; I suspect there's a better way, but I haven't taken the time to do
3739 ;; it yet. -erik selberg@cs.washington.edu
3740 (defun gnus-dd-mmm (messy-date)
3741 "Return a string like DD-MMM from a big messy string"
3742 (let ((datevec (condition-case () (timezone-parse-date messy-date)
3748 ;; Make sure leading zeroes are stripped.
3749 (number-to-string (string-to-number (aref datevec 2)))
3753 (nth (1- (string-to-number (aref datevec 1)))
3754 timezone-months-assoc))
3757 (defun gnus-mode-string-quote (string)
3758 "Quote all \"%\" in STRING."
3760 (gnus-set-work-buffer)
3762 (goto-char (point-min))
3763 (while (search-forward "%" nil t)
3767 ;; Make a hash table (default and minimum size is 255).
3768 ;; Optional argument HASHSIZE specifies the table size.
3769 (defun gnus-make-hashtable (&optional hashsize)
3770 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3772 ;; Make a number that is suitable for hashing; bigger than MIN and one
3774 (defun gnus-create-hash-size (min)
3780 ;; Show message if message has a lower level than `gnus-verbose'.
3781 ;; Guideline for numbers:
3782 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3783 ;; for things that take a long time, 7 - not very important messages
3784 ;; on stuff, 9 - messages inside loops.
3785 (defun gnus-message (level &rest args)
3786 (if (<= level gnus-verbose)
3787 (apply 'message args)
3788 ;; We have to do this format thingy here even if the result isn't
3789 ;; shown - the return value has to be the same as the return value
3791 (apply 'format args)))
3793 (defun gnus-error (level &rest args)
3794 "Beep an error if `gnus-verbose' is on LEVEL or less."
3795 (when (<= (floor level) gnus-verbose)
3796 (apply 'message args)
3799 (when (and (floatp level)
3800 (not (zerop (setq duration (* 10 (- level (floor level)))))))
3801 (sit-for duration))))
3804 ;; Generate a unique new group name.
3805 (defun gnus-generate-new-group-name (leaf)
3808 (while (gnus-gethash name gnus-newsrc-hashtb)
3809 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3812 (defsubst gnus-hide-text (b e props)
3813 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
3814 (gnus-add-text-properties b e props)
3815 (when (memq 'intangible props)
3816 (gnus-put-text-property (max (1- b) (point-min))
3817 b 'intangible (cddr (memq 'intangible props)))))
3819 (defsubst gnus-unhide-text (b e)
3820 "Remove hidden text properties from region between B and E."
3821 (remove-text-properties b e gnus-hidden-properties)
3822 (when (memq 'intangible gnus-hidden-properties)
3823 (gnus-put-text-property (max (1- b) (point-min))
3824 b 'intangible nil)))
3826 (defun gnus-hide-text-type (b e type)
3827 "Hide text of TYPE between B and E."
3828 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3830 (defun gnus-parent-headers (headers &optional generation)
3831 "Return the headers of the GENERATIONeth parent of HEADERS."
3833 (setq generation 1))
3834 (let (references parent)
3835 (while (and headers (not (zerop generation)))
3836 (setq references (mail-header-references headers))
3837 (when (and references
3838 (setq parent (gnus-parent-id references))
3839 (setq headers (car (gnus-id-to-thread parent))))
3843 (defun gnus-parent-id (references)
3844 "Return the last Message-ID in REFERENCES."
3845 (when (and references
3846 (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references))
3847 (substring references (match-beginning 1) (match-end 1))))
3849 (defun gnus-split-references (references)
3850 "Return a list of Message-IDs in REFERENCES."
3853 (while (string-match "<[^>]+>" references beg)
3854 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3858 (defun gnus-buffer-live-p (buffer)
3859 "Say whether BUFFER is alive or not."
3862 (buffer-name (get-buffer buffer))))
3864 (defun gnus-ephemeral-group-p (group)
3865 "Say whether GROUP is ephemeral or not."
3866 (gnus-group-get-parameter group 'quit-config))
3868 (defun gnus-group-quit-config (group)
3869 "Return the quit-config of GROUP."
3870 (gnus-group-get-parameter group 'quit-config))
3872 (defun gnus-simplify-mode-line ()
3873 "Make mode lines a bit simpler."
3874 (setq mode-line-modified "-- ")
3875 (when (listp mode-line-format)
3876 (make-local-variable 'mode-line-format)
3877 (setq mode-line-format (copy-sequence mode-line-format))
3878 (when (equal (nth 3 mode-line-format) " ")
3879 (setcar (nthcdr 3 mode-line-format) " "))))
3881 ;;; List and range functions
3883 (defun gnus-last-element (list)
3884 "Return last element of LIST."
3886 (setq list (cdr list)))
3889 (defun gnus-copy-sequence (list)
3890 "Do a complete, total copy of a list."
3891 (if (and (consp list) (not (consp (cdr list))))
3892 (cons (car list) (cdr list))
3893 (mapcar (lambda (elem) (if (consp elem)
3894 (if (consp (cdr elem))
3895 (gnus-copy-sequence elem)
3896 (cons (car elem) (cdr elem)))
3900 (defun gnus-set-difference (list1 list2)
3901 "Return a list of elements of LIST1 that do not appear in LIST2."
3902 (let ((list1 (copy-sequence list1)))
3904 (setq list1 (delq (car list2) list1))
3905 (setq list2 (cdr list2)))
3908 (defun gnus-sorted-complement (list1 list2)
3909 "Return a list of elements of LIST1 that do not appear in LIST2.
3910 Both lists have to be sorted over <."
3912 (if (or (null list1) (null list2))
3914 (while (and list1 list2)
3915 (cond ((= (car list1) (car list2))
3916 (setq list1 (cdr list1)
3918 ((< (car list1) (car list2))
3919 (setq out (cons (car list1) out))
3920 (setq list1 (cdr list1)))
3922 (setq out (cons (car list2) out))
3923 (setq list2 (cdr list2)))))
3924 (nconc (nreverse out) (or list1 list2)))))
3926 (defun gnus-intersection (list1 list2)
3929 (if (memq (car list2) list1)
3930 (setq result (cons (car list2) result)))
3931 (setq list2 (cdr list2)))
3934 (defun gnus-sorted-intersection (list1 list2)
3935 ;; LIST1 and LIST2 have to be sorted over <.
3937 (while (and list1 list2)
3938 (cond ((= (car list1) (car list2))
3939 (setq out (cons (car list1) out)
3942 ((< (car list1) (car list2))
3943 (setq list1 (cdr list1)))
3945 (setq list2 (cdr list2)))))
3948 (defun gnus-set-sorted-intersection (list1 list2)
3949 ;; LIST1 and LIST2 have to be sorted over <.
3950 ;; This function modifies LIST1.
3951 (let* ((top (cons nil list1))
3953 (while (and list1 list2)
3954 (cond ((= (car list1) (car list2))
3958 ((< (car list1) (car list2))
3959 (setcdr prev (cdr list1))
3960 (setq list1 (cdr list1)))
3962 (setq list2 (cdr list2)))))
3966 (defun gnus-compress-sequence (numbers &optional always-list)
3967 "Convert list of numbers to a list of ranges or a single range.
3968 If ALWAYS-LIST is non-nil, this function will always release a list of
3970 (let* ((first (car numbers))
3971 (last (car numbers))
3975 (if (not (listp (cdr numbers)))
3978 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3979 ((= (1+ last) (car numbers)) ;Still in sequence
3980 (setq last (car numbers)))
3981 (t ;End of one sequence
3983 (cons (if (= first last) first
3984 (cons first last)) result))
3985 (setq first (car numbers))
3986 (setq last (car numbers))))
3987 (setq numbers (cdr numbers)))
3988 (if (and (not always-list) (null result))
3989 (if (= first last) (list first) (cons first last))
3990 (nreverse (cons (if (= first last) first (cons first last))
3993 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3994 (defun gnus-uncompress-range (ranges)
3995 "Expand a list of ranges into a list of numbers.
3996 RANGES is either a single range on the form `(num . num)' or a list of
3998 (let (first last result)
4002 ((not (listp (cdr ranges)))
4003 (setq first (car ranges))
4004 (setq last (cdr ranges))
4005 (while (<= first last)
4006 (setq result (cons first result))
4007 (setq first (1+ first)))
4011 (if (atom (car ranges))
4012 (if (numberp (car ranges))
4013 (setq result (cons (car ranges) result)))
4014 (setq first (caar ranges))
4015 (setq last (cdar ranges))
4016 (while (<= first last)
4017 (setq result (cons first result))
4018 (setq first (1+ first))))
4019 (setq ranges (cdr ranges)))
4020 (nreverse result)))))
4022 (defun gnus-add-to-range (ranges list)
4023 "Return a list of ranges that has all articles from both RANGES and LIST.
4024 Note: LIST has to be sorted over `<'."
4026 (gnus-compress-sequence list t)
4027 (setq list (copy-sequence list))
4028 (or (listp (cdr ranges))
4029 (setq ranges (list ranges)))
4031 ilist lowest highest temp)
4032 (while (and ranges list)
4034 (setq lowest (or (and (atom (car ranges)) (car ranges))
4036 (while (and list (cdr list) (< (cadr list) lowest))
4037 (setq list (cdr list)))
4038 (if (< (car ilist) lowest)
4041 (setq list (cdr list))
4043 (setq out (nconc (gnus-compress-sequence ilist t) out))))
4044 (setq highest (or (and (atom (car ranges)) (car ranges))
4046 (while (and list (<= (car list) highest))
4047 (setq list (cdr list)))
4048 (setq ranges (cdr ranges)))
4050 (setq out (nconc (gnus-compress-sequence list t) out)))
4051 (setq out (sort out (lambda (r1 r2)
4052 (< (or (and (atom r1) r1) (car r1))
4053 (or (and (atom r2) r2) (car r2))))))
4056 (if (atom (car ranges))
4058 (if (atom (cadr ranges))
4059 (if (= (1+ (car ranges)) (cadr ranges))
4061 (setcar ranges (cons (car ranges)
4063 (setcdr ranges (cddr ranges))))
4064 (if (= (1+ (car ranges)) (caadr ranges))
4066 (setcar (cadr ranges) (car ranges))
4067 (setcar ranges (cadr ranges))
4068 (setcdr ranges (cddr ranges))))))
4070 (if (atom (cadr ranges))
4071 (if (= (1+ (cdar ranges)) (cadr ranges))
4073 (setcdr (car ranges) (cadr ranges))
4074 (setcdr ranges (cddr ranges))))
4075 (if (= (1+ (cdar ranges)) (caadr ranges))
4077 (setcdr (car ranges) (cdadr ranges))
4078 (setcdr ranges (cddr ranges)))))))
4079 (setq ranges (cdr ranges)))
4082 (defun gnus-remove-from-range (ranges list)
4083 "Return a list of ranges that has all articles from LIST removed from RANGES.
4084 Note: LIST has to be sorted over `<'."
4085 ;; !!! This function shouldn't look like this, but I've got a headache.
4086 (gnus-compress-sequence
4087 (gnus-sorted-complement
4088 (gnus-uncompress-range ranges) list)))
4090 (defun gnus-member-of-range (number ranges)
4091 (if (not (listp (cdr ranges)))
4092 (and (>= number (car ranges))
4093 (<= number (cdr ranges)))
4096 (if (numberp (car ranges))
4097 (>= number (car ranges))
4098 (>= number (caar ranges)))
4100 (if (if (numberp (car ranges))
4101 (= number (car ranges))
4102 (and (>= number (caar ranges))
4103 (<= number (cdar ranges))))
4104 (setq not-stop nil))
4105 (setq ranges (cdr ranges)))
4108 (defun gnus-range-length (range)
4109 "Return the length RANGE would have if uncompressed."
4110 (length (gnus-uncompress-range range)))
4112 (defun gnus-sublist-p (list sublist)
4113 "Test whether all elements in SUBLIST are members of LIST."
4116 (unless (memq (pop sublist) list)
4126 (defvar gnus-group-mode-map nil)
4127 (put 'gnus-group-mode 'mode-class 'special)
4129 (unless gnus-group-mode-map
4130 (setq gnus-group-mode-map (make-keymap))
4131 (suppress-keymap gnus-group-mode-map)
4133 (gnus-define-keys gnus-group-mode-map
4134 " " gnus-group-read-group
4135 "=" gnus-group-select-group
4136 "\r" gnus-group-select-group
4137 "\M-\r" gnus-group-quick-select-group
4138 "j" gnus-group-jump-to-group
4139 "n" gnus-group-next-unread-group
4140 "p" gnus-group-prev-unread-group
4141 "\177" gnus-group-prev-unread-group
4142 [delete] gnus-group-prev-unread-group
4143 "N" gnus-group-next-group
4144 "P" gnus-group-prev-group
4145 "\M-n" gnus-group-next-unread-group-same-level
4146 "\M-p" gnus-group-prev-unread-group-same-level
4147 "," gnus-group-best-unread-group
4148 "." gnus-group-first-unread-group
4149 "u" gnus-group-unsubscribe-current-group
4150 "U" gnus-group-unsubscribe-group
4151 "c" gnus-group-catchup-current
4152 "C" gnus-group-catchup-current-all
4153 "l" gnus-group-list-groups
4154 "L" gnus-group-list-all-groups
4156 "g" gnus-group-get-new-news
4157 "\M-g" gnus-group-get-new-news-this-group
4158 "R" gnus-group-restart
4159 "r" gnus-group-read-init-file
4160 "B" gnus-group-browse-foreign-server
4161 "b" gnus-group-check-bogus-groups
4162 "F" gnus-find-new-newsgroups
4163 "\C-c\C-d" gnus-group-describe-group
4164 "\M-d" gnus-group-describe-all-groups
4165 "\C-c\C-a" gnus-group-apropos
4166 "\C-c\M-\C-a" gnus-group-description-apropos
4167 "a" gnus-group-post-news
4168 "\ek" gnus-group-edit-local-kill
4169 "\eK" gnus-group-edit-global-kill
4170 "\C-k" gnus-group-kill-group
4171 "\C-y" gnus-group-yank-group
4172 "\C-w" gnus-group-kill-region
4173 "\C-x\C-t" gnus-group-transpose-groups
4174 "\C-c\C-l" gnus-group-list-killed
4175 "\C-c\C-x" gnus-group-expire-articles
4176 "\C-c\M-\C-x" gnus-group-expire-all-groups
4178 "s" gnus-group-save-newsrc
4179 "z" gnus-group-suspend
4180 "Z" gnus-group-clear-dribble
4183 "?" gnus-group-describe-briefly
4184 "\C-c\C-i" gnus-info-find-node
4185 "\M-e" gnus-group-edit-group-method
4186 "^" gnus-group-enter-server-mode
4187 gnus-mouse-2 gnus-mouse-pick-group
4188 "<" beginning-of-buffer
4191 "\C-c\C-s" gnus-group-sort-groups
4193 "\C-c\M-g" gnus-activate-all-groups
4194 "\M-&" gnus-group-universal-argument
4195 "#" gnus-group-mark-group
4196 "\M-#" gnus-group-unmark-group)
4198 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4199 "m" gnus-group-mark-group
4200 "u" gnus-group-unmark-group
4201 "w" gnus-group-mark-region
4202 "m" gnus-group-mark-buffer
4203 "r" gnus-group-mark-regexp
4204 "U" gnus-group-unmark-all-groups)
4206 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4207 "d" gnus-group-make-directory-group
4208 "h" gnus-group-make-help-group
4209 "a" gnus-group-make-archive-group
4210 "k" gnus-group-make-kiboze-group
4211 "m" gnus-group-make-group
4212 "E" gnus-group-edit-group
4213 "e" gnus-group-edit-group-method
4214 "p" gnus-group-edit-group-parameters
4215 "v" gnus-group-add-to-virtual
4216 "V" gnus-group-make-empty-virtual
4217 "D" gnus-group-enter-directory
4218 "f" gnus-group-make-doc-group
4219 "r" gnus-group-rename-group
4220 "\177" gnus-group-delete-group
4221 [delete] gnus-group-delete-group)
4223 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4224 "b" gnus-group-brew-soup
4225 "w" gnus-soup-save-areas
4226 "s" gnus-soup-send-replies
4227 "p" gnus-soup-pack-packet
4228 "r" nnsoup-pack-replies)
4230 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4231 "s" gnus-group-sort-groups
4232 "a" gnus-group-sort-groups-by-alphabet
4233 "u" gnus-group-sort-groups-by-unread
4234 "l" gnus-group-sort-groups-by-level
4235 "v" gnus-group-sort-groups-by-score
4236 "r" gnus-group-sort-groups-by-rank
4237 "m" gnus-group-sort-groups-by-method)
4239 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4240 "k" gnus-group-list-killed
4241 "z" gnus-group-list-zombies
4242 "s" gnus-group-list-groups
4243 "u" gnus-group-list-all-groups
4244 "A" gnus-group-list-active
4245 "a" gnus-group-apropos
4246 "d" gnus-group-description-apropos
4247 "m" gnus-group-list-matching
4248 "M" gnus-group-list-all-matching
4249 "l" gnus-group-list-level)
4251 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4252 "f" gnus-score-flush-cache)
4254 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4255 "f" gnus-group-fetch-faq)
4257 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4258 "l" gnus-group-set-current-level
4259 "t" gnus-group-unsubscribe-current-group
4260 "s" gnus-group-unsubscribe-group
4261 "k" gnus-group-kill-group
4262 "y" gnus-group-yank-group
4263 "w" gnus-group-kill-region
4264 "\C-k" gnus-group-kill-level
4265 "z" gnus-group-kill-all-zombies))
4267 (defun gnus-group-mode ()
4268 "Major mode for reading news.
4270 All normal editing commands are switched off.
4271 \\<gnus-group-mode-map>
4272 The group buffer lists (some of) the groups available. For instance,
4273 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4274 lists all zombie groups.
4276 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4277 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4279 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4281 The following commands are available:
4283 \\{gnus-group-mode-map}"
4285 (when (and menu-bar-mode
4286 (gnus-visual-p 'group-menu 'menu))
4287 (gnus-group-make-menu-bar))
4288 (kill-all-local-variables)
4289 (gnus-simplify-mode-line)
4290 (setq major-mode 'gnus-group-mode)
4291 (setq mode-name "Group")
4292 (gnus-group-set-mode-line)
4293 (setq mode-line-process nil)
4294 (use-local-map gnus-group-mode-map)
4295 (buffer-disable-undo (current-buffer))
4296 (setq truncate-lines t)
4297 (setq buffer-read-only t)
4298 (gnus-make-local-hook 'post-command-hook)
4299 (gnus-add-hook 'post-command-hook 'gnus-clear-inboxes-moved nil t)
4300 (run-hooks 'gnus-group-mode-hook))
4302 (defun gnus-clear-inboxes-moved ()
4303 (setq nnmail-moved-inboxes nil))
4305 (defun gnus-mouse-pick-group (e)
4306 "Enter the group under the mouse pointer."
4309 (gnus-group-read-group nil))
4311 ;; Look at LEVEL and find out what the level is really supposed to be.
4312 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4313 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4314 (defun gnus-group-default-level (&optional level number-or-nil)
4316 (gnus-group-use-permanent-levels
4317 (or (setq gnus-group-use-permanent-levels
4318 (or level (if (numberp gnus-group-use-permanent-levels)
4319 gnus-group-use-permanent-levels
4320 (or gnus-group-default-list-level
4321 gnus-level-subscribed))))
4322 gnus-group-default-list-level gnus-level-subscribed))
4326 (or level gnus-group-default-list-level gnus-level-subscribed))))
4329 (defun gnus-slave-no-server (&optional arg)
4330 "Read network news as a slave, without connecting to local server"
4332 (gnus-no-server arg t))
4335 (defun gnus-no-server (&optional arg slave)
4337 If ARG is a positive number, Gnus will use that as the
4338 startup level. If ARG is nil, Gnus will be started at level 2.
4339 If ARG is non-nil and not a positive number, Gnus will
4340 prompt the user for the name of an NNTP server to use.
4341 As opposed to `gnus', this command will not connect to the local server."
4343 (let ((val (or arg (1- gnus-level-default-subscribed))))
4345 (make-local-variable 'gnus-group-use-permanent-levels)
4346 (setq gnus-group-use-permanent-levels val)))
4349 (defun gnus-slave (&optional arg)
4350 "Read news as a slave."
4352 (gnus arg nil 'slave))
4355 (defun gnus-other-frame (&optional arg)
4356 "Pop up a frame to read news."
4358 (if (get-buffer gnus-group-buffer)
4359 (let ((pop-up-frames t))
4361 (select-frame (make-frame))
4365 (defun gnus (&optional arg dont-connect slave)
4367 If ARG is non-nil and a positive number, Gnus will use that as the
4368 startup level. If ARG is non-nil and not a positive number, Gnus will
4369 prompt the user for the name of an NNTP server to use."
4372 (if (get-buffer gnus-group-buffer)
4374 (switch-to-buffer gnus-group-buffer)
4375 (gnus-group-get-new-news))
4378 (nnheader-init-server-buffer)
4379 (gnus-read-init-file)
4380 (setq gnus-slave slave)
4382 (gnus-group-setup-buffer)
4383 (let ((buffer-read-only nil))
4385 (if (not gnus-inhibit-startup-message)
4387 (gnus-group-startup-message)
4390 (let ((level (and (numberp arg) (> arg 0) arg))
4396 (gnus-start-news-server (and arg (not level))))))
4397 (if (and (not dont-connect)
4400 (run-hooks 'gnus-startup-hook)
4401 ;; NNTP server is successfully open.
4403 ;; Find the current startup file name.
4404 (setq gnus-current-startup-file
4405 (gnus-make-newsrc-file gnus-startup-file))
4407 ;; Read the dribble file.
4408 (when (or gnus-slave gnus-use-dribble-file)
4409 (gnus-dribble-read-file))
4411 ;; Allow using GroupLens predictions.
4412 (when gnus-use-grouplens
4414 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4416 (gnus-summary-make-display-table)
4417 ;; Do the actual startup.
4418 (gnus-setup-news nil level dont-connect)
4419 ;; Generate the group buffer.
4420 (gnus-group-list-groups level)
4421 (gnus-group-first-unread-group)
4422 (gnus-configure-windows 'group)
4423 (gnus-group-set-mode-line))))))
4425 (defun gnus-unload ()
4426 "Unload all Gnus features."
4428 (or (boundp 'load-history)
4429 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4430 (let ((history load-history)
4433 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4434 (setq feature (cdr (assq 'provide (car history))))
4435 (unload-feature feature 'force))
4436 (setq history (cdr history)))))
4438 (defun gnus-compile ()
4439 "Byte-compile the user-defined format specs."
4441 (let ((entries gnus-format-specs)
4442 entry gnus-tmp-func)
4444 (gnus-message 7 "Compiling format specs...")
4447 (setq entry (pop entries))
4448 (if (eq (car entry) 'version)
4449 (setq gnus-format-specs (delq entry gnus-format-specs))
4450 (when (and (listp (caddr entry))
4451 (not (eq 'byte-code (caaddr entry))))
4452 (fset 'gnus-tmp-func
4453 `(lambda () ,(caddr entry)))
4454 (byte-compile 'gnus-tmp-func)
4455 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4457 (push (cons 'version emacs-version) gnus-format-specs)
4459 (gnus-message 7 "Compiling user specs...done"))))
4461 (defun gnus-indent-rigidly (start end arg)
4462 "Indent rigidly using only spaces and no tabs."
4465 (narrow-to-region start end)
4466 (indent-rigidly start end arg)
4467 (goto-char (point-min))
4468 (while (search-forward "\t" nil t)
4469 (replace-match " " t t)))))
4471 (defun gnus-group-startup-message (&optional x y)
4472 "Insert startup message in current buffer."
4473 ;; Insert the message.
4478 _ ___ __ ___ __ _ ___
4497 ;; And then hack it.
4498 (gnus-indent-rigidly (point-min) (point-max)
4499 (/ (max (- (window-width) (or x 46)) 0) 2))
4500 (goto-char (point-min))
4502 (let* ((pheight (count-lines (point-min) (point-max)))
4503 (wheight (window-height))
4504 (rest (- wheight pheight)))
4505 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4507 (goto-char (point-min))
4508 (and (search-forward "Praxis" nil t)
4509 (gnus-put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4510 (goto-char (point-min))
4511 (let* ((mode-string (gnus-group-set-mode-line)))
4512 (setq mode-line-buffer-identification
4513 (list (concat gnus-version (substring (car mode-string) 4))))
4514 (set-buffer-modified-p t)))
4516 (defun gnus-group-setup-buffer ()
4517 (or (get-buffer gnus-group-buffer)
4519 (switch-to-buffer gnus-group-buffer)
4520 (gnus-add-current-to-buffer-list)
4522 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4524 (defun gnus-group-list-groups (&optional level unread lowest)
4525 "List newsgroups with level LEVEL or lower that have unread articles.
4526 Default is all subscribed groups.
4527 If argument UNREAD is non-nil, groups with no unread articles are also
4529 (interactive (list (if current-prefix-arg
4530 (prefix-numeric-value current-prefix-arg)
4532 (gnus-group-default-level nil t)
4533 gnus-group-default-list-level
4534 gnus-level-subscribed))))
4536 (setq level (car gnus-group-list-mode)
4537 unread (cdr gnus-group-list-mode)))
4538 (setq level (gnus-group-default-level level))
4539 (gnus-group-setup-buffer) ;May call from out of group buffer
4540 (gnus-update-format-specifications)
4541 (let ((case-fold-search nil)
4542 (props (text-properties-at (gnus-point-at-bol)))
4543 (group (gnus-group-group-name)))
4544 (set-buffer gnus-group-buffer)
4545 (funcall gnus-group-prepare-function level unread lowest)
4546 (if (zerop (buffer-size))
4547 (gnus-message 5 gnus-no-groups-message)
4548 (goto-char (point-max))
4549 (when (or (not gnus-group-goto-next-group-function)
4550 (not (funcall gnus-group-goto-next-group-function
4553 ;; Go to the first group with unread articles.
4554 (gnus-group-search-forward t)
4555 ;; Find the right group to put point on. If the current group
4556 ;; has disappeared in the new listing, try to find the next
4557 ;; one. If no next one can be found, just leave point at the
4558 ;; first newsgroup in the buffer.
4559 (if (not (gnus-goto-char
4561 (point-min) (point-max)
4562 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4563 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4565 (not (gnus-goto-char
4567 (point-min) (point-max) 'gnus-group
4569 (caar newsrc) gnus-active-hashtb)))))
4570 (setq newsrc (cdr newsrc)))
4571 (or newsrc (progn (goto-char (point-max))
4572 (forward-line -1)))))))
4573 ;; Adjust cursor point.
4574 (gnus-group-position-point))))
4576 (defun gnus-group-list-level (level &optional all)
4577 "List groups on LEVEL.
4578 If ALL (the prefix), also list groups that have no unread articles."
4579 (interactive "nList groups on level: \nP")
4580 (gnus-group-list-groups level all level))
4582 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4583 "List all newsgroups with unread articles of level LEVEL or lower.
4584 If ALL is non-nil, list groups that have no unread articles.
4585 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4586 If REGEXP, only list groups matching REGEXP."
4587 (set-buffer gnus-group-buffer)
4588 (let ((buffer-read-only nil)
4589 (newsrc (cdr gnus-newsrc-alist))
4590 (lowest (or lowest 1))
4591 info clevel unread group params)
4593 (if (< lowest gnus-level-zombie)
4594 ;; List living groups.
4596 (setq info (car newsrc)
4597 group (gnus-info-group info)
4598 params (gnus-info-params info)
4600 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4601 (and unread ; This group might be bogus
4603 (string-match regexp group))
4604 (<= (setq clevel (gnus-info-level info)) level)
4606 (or all ; We list all groups?
4607 (if (eq unread t) ; Unactivated?
4608 gnus-group-list-inactive-groups ; We list unactivated
4609 (> unread 0)) ; We list groups with unread articles
4610 (and gnus-list-groups-with-ticked-articles
4611 (cdr (assq 'tick (gnus-info-marks info))))
4612 ; And groups with tickeds
4613 ;; Check for permanent visibility.
4614 (and gnus-permanently-visible-groups
4615 (string-match gnus-permanently-visible-groups
4617 (memq 'visible params)
4618 (cdr (assq 'visible params)))
4619 (gnus-group-insert-group-line
4620 group (gnus-info-level info)
4621 (gnus-info-marks info) unread (gnus-info-method info)))))
4623 ;; List dead groups.
4624 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4625 (gnus-group-prepare-flat-list-dead
4626 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4627 gnus-level-zombie ?Z
4629 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4630 (gnus-group-prepare-flat-list-dead
4631 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4632 gnus-level-killed ?K regexp))
4634 (gnus-group-set-mode-line)
4635 (setq gnus-group-list-mode (cons level all))
4636 (run-hooks 'gnus-group-prepare-hook)))
4638 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4639 ;; List zombies and killed lists somewhat faster, which was
4640 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4641 ;; this by ignoring the group format specification altogether.
4644 ;; This loop is used when listing groups that match some
4647 (setq group (pop groups))
4648 (when (string-match regexp group)
4649 (gnus-add-text-properties
4650 (point) (prog1 (1+ (point))
4651 (insert " " mark " *: " group "\n"))
4652 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4654 'gnus-level level))))
4655 ;; This loop is used when listing all groups.
4657 (gnus-add-text-properties
4658 (point) (prog1 (1+ (point))
4659 (insert " " mark " *: "
4660 (setq group (pop groups)) "\n"))
4661 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4663 'gnus-level level))))))
4665 (defmacro gnus-group-real-name (group)
4666 "Find the real name of a foreign newsgroup."
4667 `(let ((gname ,group))
4668 (if (string-match ":[^:]+$" gname)
4669 (substring gname (1+ (match-beginning 0)))
4672 (defsubst gnus-server-add-address (method)
4673 (let ((method-name (symbol-name (car method))))
4674 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4675 (not (assq (intern (concat method-name "-address")) method)))
4676 (append method (list (list (intern (concat method-name "-address"))
4680 (defsubst gnus-server-get-method (group method)
4681 ;; Input either a server name, and extended server name, or a
4682 ;; select method, and return a select method.
4683 (cond ((stringp method)
4684 (gnus-server-to-method method))
4685 ((equal method gnus-select-method)
4687 ((and (stringp (car method)) group)
4688 (gnus-server-extend-method group method))
4689 ((and method (not group)
4690 (equal (cadr method) ""))
4693 (gnus-server-add-address method))))
4695 (defun gnus-server-to-method (server)
4696 "Map virtual server names to select methods."
4698 ;; Is this a method, perhaps?
4699 (and server (listp server) server)
4700 ;; Perhaps this is the native server?
4701 (and (equal server "native") gnus-select-method)
4702 ;; It should be in the server alist.
4703 (cdr (assoc server gnus-server-alist))
4704 ;; If not, we look through all the opened server
4705 ;; to see whether we can find it there.
4706 (let ((opened gnus-opened-servers))
4708 (not (equal server (format "%s:%s" (caaar opened)
4713 (defmacro gnus-method-equal (ss1 ss2)
4714 "Say whether two servers are equal."
4718 (and (= (length s1) (length s2))
4720 (while (and s1 (member (car s1) s2))
4724 (defun gnus-server-equal (m1 m2)
4725 "Say whether two methods are equal."
4726 (let ((m1 (cond ((null m1) gnus-select-method)
4727 ((stringp m1) (gnus-server-to-method m1))
4729 (m2 (cond ((null m2) gnus-select-method)
4730 ((stringp m2) (gnus-server-to-method m2))
4732 (gnus-method-equal m1 m2)))
4734 (defun gnus-servers-using-backend (backend)
4735 "Return a list of known servers using BACKEND."
4736 (let ((opened gnus-opened-servers)
4739 (when (eq backend (caaar opened))
4740 (push (caar opened) out))
4744 (defun gnus-group-prefixed-name (group method)
4745 "Return the whole name from GROUP and METHOD."
4746 (and (stringp method) (setq method (gnus-server-to-method method)))
4747 (concat (format "%s" (car method))
4749 (or (assoc (format "%s" (car method))
4750 (gnus-methods-using 'address))
4751 (gnus-server-equal method gnus-message-archive-method))
4753 (not (string= (nth 1 method) "")))
4754 (concat "+" (nth 1 method)))
4757 (defun gnus-group-real-prefix (group)
4758 "Return the prefix of the current group name."
4759 (if (string-match "^[^:]+:" group)
4760 (substring group 0 (match-end 0))
4763 (defun gnus-group-method (group)
4764 "Return the server or method used for selecting GROUP."
4765 (let ((prefix (gnus-group-real-prefix group)))
4766 (if (equal prefix "")
4768 (let ((servers gnus-opened-servers)
4770 backend possible found)
4771 (if (string-match "^[^\\+]+\\+" prefix)
4772 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4773 server (substring prefix (match-end 0) (1- (length prefix))))
4774 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4776 (when (eq (caaar servers) backend)
4777 (setq possible (caar servers))
4778 (when (equal (cadaar servers) server)
4779 (setq found (caar servers))))
4781 (or (car (rassoc found gnus-server-alist))
4783 (car (rassoc possible gnus-server-alist))
4785 (list backend server))))))
4787 (defsubst gnus-secondary-method-p (method)
4788 "Return whether METHOD is a secondary select method."
4789 (let ((methods gnus-secondary-select-methods)
4790 (gmethod (gnus-server-get-method nil method)))
4792 (not (equal (gnus-server-get-method nil (car methods))
4794 (setq methods (cdr methods)))
4797 (defun gnus-group-foreign-p (group)
4798 "Say whether a group is foreign or not."
4799 (and (not (gnus-group-native-p group))
4800 (not (gnus-group-secondary-p group))))
4802 (defun gnus-group-native-p (group)
4803 "Say whether the group is native or not."
4804 (not (string-match ":" group)))
4806 (defun gnus-group-secondary-p (group)
4807 "Say whether the group is secondary or not."
4808 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4810 (defun gnus-group-get-parameter (group &optional symbol)
4811 "Returns the group parameters for GROUP.
4812 If SYMBOL, return the value of that symbol in the group parameters."
4813 (let ((params (gnus-info-params (gnus-get-info group))))
4815 (gnus-group-parameter-value params symbol)
4818 (defun gnus-group-parameter-value (params symbol)
4819 "Return the value of SYMBOL in group PARAMS."
4820 (or (car (memq symbol params)) ; It's either a simple symbol
4821 (cdr (assq symbol params)))) ; or a cons.
4823 (defun gnus-group-add-parameter (group param)
4824 "Add parameter PARAM to GROUP."
4825 (let ((info (gnus-get-info group)))
4827 () ; This is a dead group. We just ignore it.
4828 ;; Cons the new param to the old one and update.
4829 (gnus-group-set-info (cons param (gnus-info-params info))
4832 (defun gnus-group-set-parameter (group name value)
4833 "Set parameter NAME to VALUE in GROUP."
4834 (let ((info (gnus-get-info group)))
4836 () ; This is a dead group. We just ignore it.
4837 (let ((old-params (gnus-info-params info))
4838 (new-params (list (cons name value))))
4840 (if (or (not (listp (car old-params)))
4841 (not (eq (caar old-params) name)))
4842 (setq new-params (append new-params (list (car old-params)))))
4843 (setq old-params (cdr old-params)))
4844 (gnus-group-set-info new-params group 'params)))))
4846 (defun gnus-group-add-score (group &optional score)
4847 "Add SCORE to the GROUP score.
4848 If SCORE is nil, add 1 to the score of GROUP."
4849 (let ((info (gnus-get-info group)))
4851 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4853 (defun gnus-summary-bubble-group ()
4854 "Increase the score of the current group.
4855 This is a handy function to add to `gnus-summary-exit-hook' to
4856 increase the score of each group you read."
4857 (gnus-group-add-score gnus-newsgroup-name))
4859 (defun gnus-group-set-info (info &optional method-only-group part)
4860 (let* ((entry (gnus-gethash
4861 (or method-only-group (gnus-info-group info))
4862 gnus-newsrc-hashtb))
4864 (info (if method-only-group (nth 2 entry) info))
4866 (when method-only-group
4868 (error "Trying to change non-existent group %s" method-only-group))
4869 ;; We have received parts of the actual group info - either the
4870 ;; select method or the group parameters. We first check
4871 ;; whether we have to extend the info, and if so, do that.
4872 (let ((len (length info))
4873 (total (if (eq part 'method) 5 6)))
4875 (setcdr (nthcdr (1- len) info)
4876 (make-list (- total len) nil)))
4877 ;; Then we enter the new info.
4878 (setcar (nthcdr (1- total) info) part-info)))
4880 ;; This is a new group, so we just create it.
4882 (set-buffer gnus-group-buffer)
4883 (setq method (gnus-info-method info))
4884 (when (gnus-server-equal method "native")
4887 (set-buffer gnus-group-buffer)
4889 ;; It's a foreign group...
4890 (gnus-group-make-group
4891 (gnus-group-real-name (gnus-info-group info))
4892 (if (stringp method) method
4893 (prin1-to-string (car method)))
4895 (nth 1 (gnus-info-method info))))
4896 ;; It's a native group.
4897 (gnus-group-make-group (gnus-info-group info))))
4898 (gnus-message 6 "Note: New group created")
4900 (gnus-gethash (gnus-group-prefixed-name
4901 (gnus-group-real-name (gnus-info-group info))
4902 (or (gnus-info-method info) gnus-select-method))
4903 gnus-newsrc-hashtb))))
4904 ;; Whether it was a new group or not, we now have the entry, so we
4905 ;; can do the update.
4908 (setcar (nthcdr 2 entry) info)
4909 (when (and (not (eq (car entry) t))
4910 (gnus-active (gnus-info-group info)))
4911 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4912 (error "No such group: %s" (gnus-info-group info)))))
4914 (defun gnus-group-set-method-info (group select-method)
4915 (gnus-group-set-info select-method group 'method))
4917 (defun gnus-group-set-params-info (group params)
4918 (gnus-group-set-info params group 'params))
4920 (defun gnus-group-update-group-line ()
4921 "Update the current line in the group buffer."
4922 (let* ((buffer-read-only nil)
4923 (group (gnus-group-group-name))
4924 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
4925 gnus-group-indentation)
4927 (not (gnus-ephemeral-group-p group))
4929 (concat "(gnus-group-set-info '"
4930 (prin1-to-string (nth 2 entry)) ")")))
4931 (setq gnus-group-indentation (gnus-group-group-indentation))
4933 (gnus-group-insert-group-line-info group)
4935 (gnus-group-position-point)))
4937 (defun gnus-group-insert-group-line-info (group)
4938 "Insert GROUP on the current line."
4939 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4943 ;; (Un)subscribed group.
4944 (setq info (nth 2 entry))
4945 (gnus-group-insert-group-line
4946 group (gnus-info-level info) (gnus-info-marks info)
4947 (or (car entry) t) (gnus-info-method info)))
4948 ;; This group is dead.
4949 (gnus-group-insert-group-line
4951 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4953 (if (setq active (gnus-active group))
4954 (- (1+ (cdr active)) (car active)) 0)
4957 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
4958 gnus-tmp-marked number
4960 "Insert a group line in the group buffer."
4961 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4962 (gnus-tmp-number-total
4964 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4966 (gnus-tmp-number-of-unread
4967 (if (numberp number) (int-to-string (max 0 number))
4969 (gnus-tmp-number-of-read
4970 (if (numberp number)
4971 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4973 (gnus-tmp-subscribed
4974 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4975 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4976 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4978 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4979 (gnus-tmp-newsgroup-description
4980 (if gnus-description-hashtb
4981 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4984 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4985 (gnus-tmp-moderated-string
4986 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4988 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4989 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4990 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4991 (gnus-tmp-news-method-string
4993 (format "(%s:%s)" (car gnus-tmp-method)
4994 (cadr gnus-tmp-method)) ""))
4995 (gnus-tmp-marked-mark
4996 (if (and (numberp number)
4998 (cdr (assq 'tick gnus-tmp-marked)))
5000 (gnus-tmp-process-marked
5001 (if (member gnus-tmp-group gnus-group-marked)
5002 gnus-process-mark ? ))
5004 (or (and gnus-use-grouplens
5005 (bbb-grouplens-group-p gnus-tmp-group))
5007 (buffer-read-only nil)
5008 header gnus-tmp-header) ; passed as parameter to user-funcs.
5010 (gnus-add-text-properties
5014 (eval gnus-group-line-format-spec))
5015 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
5016 gnus-unread ,(if (numberp number)
5017 (string-to-int gnus-tmp-number-of-unread)
5019 gnus-marked ,gnus-tmp-marked-mark
5020 gnus-indentation ,gnus-group-indentation
5021 gnus-level ,gnus-tmp-level))
5022 (when (inline (gnus-visual-p 'group-highlight 'highlight))
5024 (run-hooks 'gnus-group-update-hook)
5026 ;; Allow XEmacs to remove front-sticky text properties.
5027 (gnus-group-remove-excess-properties)))
5029 (defun gnus-group-update-group (group &optional visible-only)
5030 "Update all lines where GROUP appear.
5031 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
5034 (set-buffer gnus-group-buffer)
5035 ;; The buffer may be narrowed.
5038 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
5040 found buffer-read-only)
5041 ;; Enter the current status into the dribble buffer.
5042 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
5043 (if (and entry (not (gnus-ephemeral-group-p group)))
5045 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
5047 ;; Find all group instances. If topics are in use, each group
5048 ;; may be listed in more than once.
5049 (while (setq loc (text-property-any
5050 loc (point-max) 'gnus-group ident))
5053 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5055 (gnus-group-insert-group-line-info group)
5058 (run-hooks 'gnus-group-update-group-hook)))
5059 (setq loc (1+ loc)))
5060 (unless (or found visible-only)
5061 ;; No such line in the buffer, find out where it's supposed to
5062 ;; go, and insert it there (or at the end of the buffer).
5063 (if gnus-goto-missing-group-function
5064 (funcall gnus-goto-missing-group-function group)
5065 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
5066 (while (and entry (car entry)
5070 (point-min) (point-max)
5071 'gnus-group (gnus-intern-safe
5072 (caar entry) gnus-active-hashtb)))))
5073 (setq entry (cdr entry)))
5074 (or entry (goto-char (point-max)))))
5075 ;; Finally insert the line.
5076 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5077 (gnus-group-insert-group-line-info group)
5080 (run-hooks 'gnus-group-update-group-hook))))
5081 (gnus-group-set-mode-line)))))
5083 (defun gnus-group-set-mode-line ()
5084 "Update the mode line in the group buffer."
5085 (when (memq 'group gnus-updated-mode-lines)
5086 ;; Yes, we want to keep this mode line updated.
5088 (set-buffer gnus-group-buffer)
5089 (let* ((gformat (or gnus-group-mode-line-format-spec
5090 (setq gnus-group-mode-line-format-spec
5092 gnus-group-mode-line-format
5093 gnus-group-mode-line-format-alist))))
5094 (gnus-tmp-news-server (cadr gnus-select-method))
5095 (gnus-tmp-news-method (car gnus-select-method))
5096 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
5098 gnus-tmp-header ;Dummy binding for user-defined formats
5099 ;; Get the resulting string.
5100 (mode-string (eval gformat)))
5101 ;; Say whether the dribble buffer has been modified.
5102 (setq mode-line-modified
5103 (if (and gnus-dribble-buffer
5104 (buffer-name gnus-dribble-buffer)
5105 (buffer-modified-p gnus-dribble-buffer)
5107 (set-buffer gnus-dribble-buffer)
5108 (not (zerop (buffer-size)))))
5110 ;; If the line is too long, we chop it off.
5111 (when (> (length mode-string) max-len)
5112 (setq mode-string (substring mode-string 0 (- max-len 4))))
5114 (setq mode-line-buffer-identification
5116 (set-buffer-modified-p t))))))
5118 (defun gnus-group-group-name ()
5119 "Get the name of the newsgroup on the current line."
5120 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
5121 (and group (symbol-name group))))
5123 (defun gnus-group-group-level ()
5124 "Get the level of the newsgroup on the current line."
5125 (get-text-property (gnus-point-at-bol) 'gnus-level))
5127 (defun gnus-group-group-indentation ()
5128 "Get the indentation of the newsgroup on the current line."
5129 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
5130 (and gnus-group-indentation-function
5131 (funcall gnus-group-indentation-function))
5134 (defun gnus-group-group-unread ()
5135 "Get the number of unread articles of the newsgroup on the current line."
5136 (get-text-property (gnus-point-at-bol) 'gnus-unread))
5138 (defun gnus-group-search-forward (&optional backward all level first-too)
5139 "Find the next newsgroup with unread articles.
5140 If BACKWARD is non-nil, find the previous newsgroup instead.
5141 If ALL is non-nil, just find any newsgroup.
5142 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
5144 If FIRST-TOO, the current line is also eligible as a target."
5145 (let ((way (if backward -1 1))
5146 (low gnus-level-killed)
5149 (if (and backward (progn (beginning-of-line)) (bobp))
5151 (or first-too (forward-line way))
5159 (get-text-property (point) 'gnus-unread)))
5160 (and (numberp unread) (> unread 0)))
5161 (setq lev (get-text-property (point)
5163 (<= lev gnus-level-subscribed)))
5165 (and (setq lev (get-text-property (point)
5174 (zerop (forward-line way)))))
5176 (progn (gnus-group-position-point) t)
5177 (goto-char (or pos beg))
5180 ;;; Gnus group mode commands
5184 (defun gnus-group-mark-group (n &optional unmark no-advance)
5185 "Mark the current group."
5187 (let ((buffer-read-only nil)
5191 (when (setq group (gnus-group-group-name))
5195 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5200 (setq gnus-group-marked (delete group gnus-group-marked)))
5202 (setq gnus-group-marked
5203 (cons group (delete group gnus-group-marked)))))
5204 (or no-advance (gnus-group-next-group 1))
5206 (gnus-summary-position-point)
5209 (defun gnus-group-unmark-group (n)
5210 "Remove the mark from the current group."
5212 (gnus-group-mark-group n 'unmark)
5213 (gnus-group-position-point))
5215 (defun gnus-group-unmark-all-groups ()
5216 "Unmark all groups."
5218 (let ((groups gnus-group-marked))
5221 (gnus-group-remove-mark (pop groups)))))
5222 (gnus-group-position-point))
5224 (defun gnus-group-mark-region (unmark beg end)
5225 "Mark all groups between point and mark.
5226 If UNMARK, remove the mark instead."
5227 (interactive "P\nr")
5228 (let ((num (count-lines beg end)))
5231 (- num (gnus-group-mark-group num unmark)))))
5233 (defun gnus-group-mark-buffer (&optional unmark)
5234 "Mark all groups in the buffer.
5235 If UNMARK, remove the mark instead."
5237 (gnus-group-mark-region unmark (point-min) (point-max)))
5239 (defun gnus-group-mark-regexp (regexp)
5240 "Mark all groups that match some regexp."
5241 (interactive "sMark (regexp): ")
5242 (let ((alist (cdr gnus-newsrc-alist))
5245 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5246 (gnus-group-set-mark group))))
5247 (gnus-group-position-point))
5249 (defun gnus-group-remove-mark (group)
5250 "Remove the process mark from GROUP and move point there.
5251 Return nil if the group isn't displayed."
5252 (if (gnus-group-goto-group group)
5254 (gnus-group-mark-group 1 'unmark t)
5256 (setq gnus-group-marked
5257 (delete group gnus-group-marked))
5260 (defun gnus-group-set-mark (group)
5261 "Set the process mark on GROUP."
5262 (if (gnus-group-goto-group group)
5264 (gnus-group-mark-group 1 nil t))
5265 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5267 (defun gnus-group-universal-argument (arg &optional groups func)
5268 "Perform any command on all groups accoring to the process/prefix convention."
5270 (let ((groups (or groups (gnus-group-process-prefix arg)))
5272 (if (eq (setq func (or func
5275 (substitute-command-keys
5276 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5278 (gnus-error 1 "Undefined key")
5280 (gnus-group-remove-mark (setq group (pop groups)))
5281 (command-execute func))))
5282 (gnus-group-position-point))
5284 (defun gnus-group-process-prefix (n)
5285 "Return a list of groups to work on.
5286 Take into consideration N (the prefix) and the list of marked groups."
5289 (setq n (prefix-numeric-value n))
5290 ;; There is a prefix, so we return a list of the N next
5292 (let ((way (if (< n 0) -1 1))
5297 (setq group (gnus-group-group-name)))
5298 (setq groups (cons group groups))
5300 (gnus-group-next-group way)))
5302 ((and (boundp 'transient-mark-mode)
5304 (boundp 'mark-active)
5306 ;; Work on the region between point and mark.
5307 (let ((max (max (point) (mark)))
5310 (goto-char (min (point) (mark)))
5313 (push (gnus-group-group-name) groups)
5314 (zerop (gnus-group-next-group 1))
5316 (nreverse groups))))
5318 ;; No prefix, but a list of marked articles.
5319 (reverse gnus-group-marked))
5321 ;; Neither marked articles or a prefix, so we return the
5323 (let ((group (gnus-group-group-name)))
5324 (and group (list group))))))
5326 ;; Selecting groups.
5328 (defun gnus-group-read-group (&optional all no-article group)
5329 "Read news in this newsgroup.
5330 If the prefix argument ALL is non-nil, already read articles become
5331 readable. IF ALL is a number, fetch this number of articles. If the
5332 optional argument NO-ARTICLE is non-nil, no article will be
5333 auto-selected upon group entry. If GROUP is non-nil, fetch that
5336 (let ((group (or group (gnus-group-group-name)))
5337 number active marked entry)
5338 (or group (error "No group on current line"))
5339 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5340 group gnus-newsrc-hashtb)))))
5341 ;; This group might be a dead group. In that case we have to get
5342 ;; the number of unread articles from `gnus-active-hashtb'.
5344 (cond ((numberp all) all)
5346 ((setq active (gnus-active group))
5347 (- (1+ (cdr active)) (car active)))))
5348 (gnus-summary-read-group
5349 group (or all (and (numberp number)
5350 (zerop (+ number (length (cdr (assq 'tick marked)))
5351 (length (cdr (assq 'dormant marked)))))))
5354 (defun gnus-group-select-group (&optional all)
5355 "Select this newsgroup.
5356 No article is selected automatically.
5357 If ALL is non-nil, already read articles become readable.
5358 If ALL is a number, fetch this number of articles."
5360 (gnus-group-read-group all t))
5362 (defun gnus-group-quick-select-group (&optional all)
5363 "Select the current group \"quickly\".
5364 This means that no highlighting or scoring will be performed."
5367 gnus-score-find-score-files-function
5368 gnus-apply-kill-hook
5369 gnus-summary-expunge-below)
5370 (gnus-group-read-group all t)))
5372 (defun gnus-group-visible-select-group (&optional all)
5373 "Select the current group without hiding any articles."
5375 (let ((gnus-inhibit-limiting t))
5376 (gnus-group-read-group all t)))
5379 (defun gnus-fetch-group (group)
5380 "Start Gnus if necessary and enter GROUP.
5381 Returns whether the fetching was successful or not."
5382 (interactive "sGroup name: ")
5383 (or (get-buffer gnus-group-buffer)
5385 (gnus-group-read-group nil nil group))
5387 ;; Enter a group that is not in the group buffer. Non-nil is returned
5388 ;; if selection was successful.
5389 (defun gnus-group-read-ephemeral-group
5390 (group method &optional activate quit-config)
5391 (let ((group (if (gnus-group-foreign-p group) group
5392 (gnus-group-prefixed-name group method))))
5395 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5396 ((quit-config . ,(if quit-config quit-config
5397 (cons (current-buffer) 'summary))))))
5399 (set-buffer gnus-group-buffer)
5400 (or (gnus-check-server method)
5401 (error "Unable to contact server: %s" (gnus-status-message method)))
5402 (if activate (or (gnus-request-group group)
5403 (error "Couldn't request group")))
5405 (gnus-group-read-group t t group)
5409 (defun gnus-group-jump-to-group (group)
5410 "Jump to newsgroup GROUP."
5412 (list (completing-read
5413 "Group: " gnus-active-hashtb nil
5414 (gnus-read-active-file-p)
5416 'gnus-group-history)))
5418 (when (equal group "")
5419 (error "Empty group name"))
5421 (when (string-match "[\000-\032]" group)
5422 (error "Control characters in group: %s" group))
5424 (let ((b (text-property-any
5425 (point-min) (point-max)
5426 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5427 (unless (gnus-ephemeral-group-p group)
5429 ;; Either go to the line in the group buffer...
5431 ;; ... or insert the line.
5434 (gnus-activate-group group)
5435 (error "%s error: %s" group (gnus-status-message group)))
5437 (gnus-group-update-group group)
5438 (goto-char (text-property-any
5439 (point-min) (point-max)
5440 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5441 ;; Adjust cursor point.
5442 (gnus-group-position-point)))
5444 (defun gnus-group-goto-group (group)
5445 "Goto to newsgroup GROUP."
5447 (let ((b (text-property-any (point-min) (point-max)
5448 'gnus-group (gnus-intern-safe
5449 group gnus-active-hashtb))))
5450 (and b (goto-char b)))))
5452 (defun gnus-group-next-group (n)
5453 "Go to next N'th newsgroup.
5454 If N is negative, search backward instead.
5455 Returns the difference between N and the number of skips actually
5458 (gnus-group-next-unread-group n t))
5460 (defun gnus-group-next-unread-group (n &optional all level)
5461 "Go to next N'th unread newsgroup.
5462 If N is negative, search backward instead.
5463 If ALL is non-nil, choose any newsgroup, unread or not.
5464 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5465 such group can be found, the next group with a level higher than
5467 Returns the difference between N and the number of skips actually
5470 (let ((backward (< n 0))
5473 (gnus-group-search-forward
5474 backward (or (not gnus-group-goto-unread) all) level))
5476 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5477 (if level " on this level or higher" "")))
5480 (defun gnus-group-prev-group (n)
5481 "Go to previous N'th newsgroup.
5482 Returns the difference between N and the number of skips actually
5485 (gnus-group-next-unread-group (- n) t))
5487 (defun gnus-group-prev-unread-group (n)
5488 "Go to previous N'th unread newsgroup.
5489 Returns the difference between N and the number of skips actually
5492 (gnus-group-next-unread-group (- n)))
5494 (defun gnus-group-next-unread-group-same-level (n)
5495 "Go to next N'th unread newsgroup on the same level.
5496 If N is negative, search backward instead.
5497 Returns the difference between N and the number of skips actually
5500 (gnus-group-next-unread-group n t (gnus-group-group-level))
5501 (gnus-group-position-point))
5503 (defun gnus-group-prev-unread-group-same-level (n)
5504 "Go to next N'th unread newsgroup on the same level.
5505 Returns the difference between N and the number of skips actually
5508 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5509 (gnus-group-position-point))
5511 (defun gnus-group-best-unread-group (&optional exclude-group)
5512 "Go to the group with the highest level.
5513 If EXCLUDE-GROUP, do not go to that group."
5515 (goto-char (point-min))
5519 (setq unread (get-text-property (point) 'gnus-unread))
5520 (if (and (numberp unread) (> unread 0))
5522 (if (and (get-text-property (point) 'gnus-level)
5523 (< (get-text-property (point) 'gnus-level) best)
5524 (or (not exclude-group)
5525 (not (equal exclude-group (gnus-group-group-name)))))
5527 (setq best (get-text-property (point) 'gnus-level))
5528 (setq best-point (point))))))
5530 (if best-point (goto-char best-point))
5531 (gnus-summary-position-point)
5532 (and best-point (gnus-group-group-name))))
5534 (defun gnus-group-first-unread-group ()
5535 "Go to the first group with unread articles."
5538 (let ((opoint (point))
5540 (goto-char (point-min))
5541 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5542 (and (numberp unread) ; Not a topic.
5543 (not (zerop unread))) ; Has unread articles.
5544 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5547 nil)) ; Not success.
5548 (gnus-group-position-point)))
5550 (defun gnus-group-enter-server-mode ()
5551 "Jump to the server buffer."
5553 (gnus-enter-server-buffer))
5555 (defun gnus-group-make-group (name &optional method address)
5556 "Add a new newsgroup.
5557 The user will be prompted for a NAME, for a select METHOD, and an
5561 (read-string "Group name: ")
5564 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5565 nil t nil 'gnus-method-history)))
5566 (cond ((assoc method gnus-valid-select-methods)
5568 (if (memq 'prompt-address
5569 (assoc method gnus-valid-select-methods))
5570 (read-string "Address: ")
5572 ((assoc method gnus-server-alist)
5575 (list method ""))))))
5577 (let* ((meth (and method (if address (list (intern method) address)
5579 (nname (if method (gnus-group-prefixed-name name meth) name))
5581 (when (gnus-gethash nname gnus-newsrc-hashtb)
5582 (error "Group %s already exists" nname))
5583 ;; Subscribe to the new group.
5584 (gnus-group-change-level
5585 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5586 gnus-level-default-subscribed gnus-level-killed
5587 (and (gnus-group-group-name)
5588 (gnus-gethash (gnus-group-group-name)
5589 gnus-newsrc-hashtb))
5592 (gnus-set-active nname (cons 1 0))
5593 (or (gnus-ephemeral-group-p name)
5595 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5597 (gnus-group-insert-group-line-info nname)
5599 (gnus-group-position-point)
5601 ;; Load the backend and try to make the backend create
5602 ;; the group as well.
5603 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5605 gnus-valid-select-methods)
5607 (gnus-check-server meth)
5608 (and (gnus-check-backend-function 'request-create-group nname)
5609 (gnus-request-create-group nname))
5612 (defun gnus-group-delete-group (group &optional force)
5613 "Delete the current group.
5614 If FORCE (the prefix) is non-nil, all the articles in the group will
5615 be deleted. This is \"deleted\" as in \"removed forever from the face
5616 of the Earth\". There is no undo."
5618 (list (gnus-group-group-name)
5619 current-prefix-arg))
5620 (or group (error "No group to rename"))
5621 (or (gnus-check-backend-function 'request-delete-group group)
5622 (error "This backend does not support group deletion"))
5624 (if (not (gnus-yes-or-no-p
5626 "Do you really want to delete %s%s? "
5627 group (if force " and all its contents" ""))))
5629 (gnus-message 6 "Deleting group %s..." group)
5630 (if (not (gnus-request-delete-group group force))
5631 (gnus-error 3 "Couldn't delete group %s" group)
5632 (gnus-message 6 "Deleting group %s...done" group)
5633 (gnus-group-goto-group group)
5634 (gnus-group-kill-group 1 t)
5635 (gnus-sethash group nil gnus-active-hashtb)
5637 (gnus-group-position-point)))
5639 (defun gnus-group-rename-group (group new-name)
5642 (gnus-group-group-name)
5644 (or (gnus-check-backend-function
5645 'request-rename-group (gnus-group-group-name))
5646 (error "This backend does not support renaming groups"))
5647 (read-string "New group name: "))))
5649 (or (gnus-check-backend-function 'request-rename-group group)
5650 (error "This backend does not support renaming groups"))
5652 (or group (error "No group to rename"))
5653 (and (string-match "^[ \t]*$" new-name)
5654 (error "Not a valid group name"))
5656 ;; We find the proper prefixed name.
5658 (gnus-group-prefixed-name
5659 (gnus-group-real-name new-name)
5660 (gnus-info-method (gnus-get-info group))))
5662 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5664 (if (not (gnus-request-rename-group group new-name))
5665 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
5666 ;; We rename the group internally by killing it...
5667 (gnus-group-goto-group group)
5668 (gnus-group-kill-group)
5669 ;; ... changing its name ...
5670 (setcar (cdar gnus-list-of-killed-groups) new-name)
5671 ;; ... and then yanking it. Magic!
5672 (gnus-group-yank-group)
5673 (gnus-set-active new-name (gnus-active group))
5674 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5676 (gnus-group-position-point)))
5678 (defun gnus-group-edit-group (group &optional part)
5679 "Edit the group on the current line."
5680 (interactive (list (gnus-group-group-name)))
5681 (let* ((part (or part 'info))
5682 (done-func `(lambda ()
5683 "Exit editing mode and update the information."
5685 (gnus-group-edit-group-done ',part ,group)))
5686 (winconf (current-window-configuration))
5688 (or group (error "No group on current line"))
5689 (or (setq info (gnus-get-info group))
5690 (error "Killed group; can't be edited"))
5691 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5692 (gnus-configure-windows 'edit-group)
5693 (gnus-add-current-to-buffer-list)
5695 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5696 (use-local-map (copy-keymap emacs-lisp-mode-map))
5697 (local-set-key "\C-c\C-c" done-func)
5698 (make-local-variable 'gnus-prev-winconf)
5699 (setq gnus-prev-winconf winconf)
5704 ";; Type `C-c C-c' after editing the select method.\n\n")
5706 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5708 ";; Type `C-c C-c' after editing the group info.\n\n")))
5711 (cond ((eq part 'method)
5712 (or (gnus-info-method info) "native"))
5714 (gnus-info-params info))
5718 (defun gnus-group-edit-group-method (group)
5719 "Edit the select method of GROUP."
5720 (interactive (list (gnus-group-group-name)))
5721 (gnus-group-edit-group group 'method))
5723 (defun gnus-group-edit-group-parameters (group)
5724 "Edit the group parameters of GROUP."
5725 (interactive (list (gnus-group-group-name)))
5726 (gnus-group-edit-group group 'params))
5728 (defun gnus-group-edit-group-done (part group)
5729 "Get info from buffer, update variables and jump to the group buffer."
5730 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5731 (goto-char (point-min))
5732 (let* ((form (read (current-buffer)))
5733 (winconf gnus-prev-winconf)
5734 (method (cond ((eq part 'info) (nth 4 form))
5735 ((eq part 'method) form)
5737 (info (cond ((eq part 'info) form)
5738 ((eq part 'method) (gnus-get-info group))
5741 (if (or (not method)
5743 gnus-select-method method))
5744 (gnus-group-real-name (car info))
5745 (gnus-group-prefixed-name
5746 (gnus-group-real-name (car info)) method))
5748 (when (and new-group
5749 (not (equal new-group group)))
5750 (when (gnus-group-goto-group group)
5751 (gnus-group-kill-group 1))
5752 (gnus-activate-group new-group))
5754 (if (and info new-group)
5756 (setq info (gnus-copy-sequence info))
5757 (setcar info new-group)
5758 (unless (gnus-server-equal method "native")
5759 (unless (nthcdr 3 info)
5760 (nconc info (list nil nil)))
5761 (unless (nthcdr 4 info)
5762 (nconc info (list nil)))
5763 (gnus-info-set-method info method))
5764 (gnus-group-set-info info))
5765 (gnus-group-set-info form (or new-group group) part))
5766 (kill-buffer (current-buffer))
5767 (and winconf (set-window-configuration winconf))
5768 (set-buffer gnus-group-buffer)
5769 (gnus-group-update-group (or new-group group))
5770 (gnus-group-position-point)))
5772 (defun gnus-group-make-help-group ()
5773 "Create the Gnus documentation group."
5775 (let ((path load-path)
5776 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5778 (and (gnus-gethash name gnus-newsrc-hashtb)
5779 (error "Documentation group already exists"))
5781 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5783 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5785 (setq file (concat (file-name-directory
5786 (directory-file-name dir))
5787 "etc/gnus-tut.txt"))))
5790 (gnus-message 1 "Couldn't find doc group")
5791 (gnus-group-make-group
5792 (gnus-group-real-name name)
5793 (list 'nndoc "gnus-help"
5794 (list 'nndoc-address file)
5795 (list 'nndoc-article-type 'mbox)))))
5796 (gnus-group-position-point))
5798 (defun gnus-group-make-doc-group (file type)
5799 "Create a group that uses a single file as the source."
5801 (list (read-file-name "File name: ")
5802 (and current-prefix-arg 'ask)))
5803 (when (eq type 'ask)
5808 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5810 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5811 ((= char ?b) 'babyl)
5812 ((= char ?d) 'digest)
5813 ((= char ?f) 'forward)
5815 (t (setq err (format "%c unknown. " char))
5818 (let* ((file (expand-file-name file))
5819 (name (gnus-generate-new-group-name
5820 (gnus-group-prefixed-name
5821 (file-name-nondirectory file) '(nndoc "")))))
5822 (gnus-group-make-group
5823 (gnus-group-real-name name)
5824 (list 'nndoc (file-name-nondirectory file)
5825 (list 'nndoc-address file)
5826 (list 'nndoc-article-type (or type 'guess))))))
5828 (defun gnus-group-make-archive-group (&optional all)
5829 "Create the (ding) Gnus archive group of the most recent articles.
5830 Given a prefix, create a full group."
5832 (let ((group (gnus-group-prefixed-name
5833 (if all "ding.archives" "ding.recent") '(nndir ""))))
5834 (and (gnus-gethash group gnus-newsrc-hashtb)
5835 (error "Archive group already exists"))
5836 (gnus-group-make-group
5837 (gnus-group-real-name group)
5838 (list 'nndir (if all "hpc" "edu")
5839 (list 'nndir-directory
5840 (if all gnus-group-archive-directory
5841 gnus-group-recent-archive-directory))))))
5843 (defun gnus-group-make-directory-group (dir)
5844 "Create an nndir group.
5845 The user will be prompted for a directory. The contents of this
5846 directory will be used as a newsgroup. The directory should contain
5847 mail messages or news articles in files that have numeric names."
5849 (list (read-file-name "Create group from directory: ")))
5850 (or (file-exists-p dir) (error "No such directory"))
5851 (or (file-directory-p dir) (error "Not a directory"))
5855 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5857 (gnus-group-prefixed-name
5858 (concat (file-name-as-directory (directory-file-name dir))
5861 (setq ext (format "<%d>" (setq i (1+ i)))))
5862 (gnus-group-make-group
5863 (gnus-group-real-name group)
5864 (list 'nndir group (list 'nndir-directory dir)))))
5866 (defun gnus-group-make-kiboze-group (group address scores)
5867 "Create an nnkiboze group.
5868 The user will be prompted for a name, a regexp to match groups, and
5869 score file entries for articles to include in the group."
5872 (read-string "nnkiboze group name: ")
5873 (read-string "Source groups (regexp): ")
5874 (let ((headers (mapcar (lambda (group) (list group))
5875 '("subject" "from" "number" "date" "message-id"
5876 "references" "chars" "lines" "xref"
5877 "followup" "all" "body" "head")))
5878 scores header regexp regexps)
5879 (while (not (equal "" (setq header (completing-read
5880 "Match on header: " headers nil t))))
5882 (while (not (equal "" (setq regexp (read-string
5883 (format "Match on %s (string): "
5885 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5886 (setq scores (cons (cons header regexps) scores)))
5888 (gnus-group-make-group group "nnkiboze" address)
5889 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
5890 (let (emacs-lisp-mode-hook)
5891 (pp scores (current-buffer)))))
5893 (defun gnus-group-add-to-virtual (n vgroup)
5894 "Add the current group to a virtual group."
5896 (list current-prefix-arg
5897 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5899 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5900 (error "%s is not an nnvirtual group" vgroup))
5901 (let* ((groups (gnus-group-process-prefix n))
5902 (method (gnus-info-method (gnus-get-info vgroup))))
5903 (setcar (cdr method)
5905 (nth 1 method) "\\|"
5908 (gnus-group-remove-mark s)
5909 (concat "\\(^" (regexp-quote s) "$\\)"))
5911 (gnus-group-position-point))
5913 (defun gnus-group-make-empty-virtual (group)
5914 "Create a new, fresh, empty virtual group."
5915 (interactive "sCreate new, empty virtual group: ")
5916 (let* ((method (list 'nnvirtual "^$"))
5917 (pgroup (gnus-group-prefixed-name group method)))
5918 ;; Check whether it exists already.
5919 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5920 (error "Group %s already exists." pgroup))
5921 ;; Subscribe the new group after the group on the current line.
5922 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5923 (gnus-group-update-group pgroup)
5925 (gnus-group-position-point)))
5927 (defun gnus-group-enter-directory (dir)
5928 "Enter an ephemeral nneething group."
5929 (interactive "DDirectory to read: ")
5930 (let* ((method (list 'nneething dir))
5931 (leaf (gnus-group-prefixed-name
5932 (file-name-nondirectory (directory-file-name dir))
5934 (name (gnus-generate-new-group-name leaf)))
5935 (let ((nneething-read-only t))
5936 (or (gnus-group-read-ephemeral-group
5938 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5940 (error "Couldn't enter %s" dir)))))
5942 ;; Group sorting commands
5943 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5945 (defun gnus-group-sort-groups (func &optional reverse)
5946 "Sort the group buffer according to FUNC.
5947 If REVERSE, reverse the sorting order."
5948 (interactive (list gnus-group-sort-function
5949 current-prefix-arg))
5951 ((not (listp func)) func)
5953 ((= 1 (length func)) (car func))
5955 ,(gnus-make-sort-function
5956 (reverse func)))))))
5957 ;; We peel off the dummy group from the alist.
5959 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5960 (pop gnus-newsrc-alist))
5962 (setq gnus-newsrc-alist
5963 (sort gnus-newsrc-alist func))
5965 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5966 ;; Regenerate the hash table.
5967 (gnus-make-hashtable-from-newsrc-alist)
5968 (gnus-group-list-groups))))
5970 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5971 "Sort the group buffer alphabetically by group name.
5972 If REVERSE, sort in reverse order."
5974 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5976 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5977 "Sort the group buffer by number of unread articles.
5978 If REVERSE, sort in reverse order."
5980 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5982 (defun gnus-group-sort-groups-by-level (&optional reverse)
5983 "Sort the group buffer by group level.
5984 If REVERSE, sort in reverse order."
5986 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5988 (defun gnus-group-sort-groups-by-score (&optional reverse)
5989 "Sort the group buffer by group score.
5990 If REVERSE, sort in reverse order."
5992 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5994 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5995 "Sort the group buffer by group rank.
5996 If REVERSE, sort in reverse order."
5998 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
6000 (defun gnus-group-sort-groups-by-method (&optional reverse)
6001 "Sort the group buffer alphabetically by backend name.
6002 If REVERSE, sort in reverse order."
6004 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
6006 (defun gnus-group-sort-by-alphabet (info1 info2)
6007 "Sort alphabetically."
6008 (string< (gnus-info-group info1) (gnus-info-group info2)))
6010 (defun gnus-group-sort-by-unread (info1 info2)
6011 "Sort by number of unread articles."
6012 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
6013 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
6014 (< (or (and (numberp n1) n1) 0)
6015 (or (and (numberp n2) n2) 0))))
6017 (defun gnus-group-sort-by-level (info1 info2)
6019 (< (gnus-info-level info1) (gnus-info-level info2)))
6021 (defun gnus-group-sort-by-method (info1 info2)
6022 "Sort alphabetically by backend name."
6023 (string< (symbol-name (car (gnus-find-method-for-group
6024 (gnus-info-group info1) info1)))
6025 (symbol-name (car (gnus-find-method-for-group
6026 (gnus-info-group info2) info2)))))
6028 (defun gnus-group-sort-by-score (info1 info2)
6029 "Sort by group score."
6030 (< (gnus-info-score info1) (gnus-info-score info2)))
6032 (defun gnus-group-sort-by-rank (info1 info2)
6033 "Sort by level and score."
6034 (let ((level1 (gnus-info-level info1))
6035 (level2 (gnus-info-level info2)))
6036 (or (< level1 level2)
6037 (and (= level1 level2)
6038 (> (gnus-info-score info1) (gnus-info-score info2))))))
6040 ;; Group catching up.
6042 (defun gnus-group-clear-data (n)
6043 "Clear all marks and read ranges from the current group."
6045 (let ((groups (gnus-group-process-prefix n))
6047 (while (setq group (pop groups))
6048 (setq info (gnus-get-info group))
6049 (gnus-info-set-read info nil)
6050 (when (gnus-info-marks info)
6051 (gnus-info-set-marks info nil))
6052 (gnus-get-unread-articles-in-group info (gnus-active group) t)
6053 (when (gnus-group-goto-group group)
6054 (gnus-group-remove-mark group)
6055 (gnus-group-update-group-line)))))
6057 (defun gnus-group-catchup-current (&optional n all)
6058 "Mark all articles not marked as unread in current newsgroup as read.
6059 If prefix argument N is numeric, the ARG next newsgroups will be
6060 caught up. If ALL is non-nil, marked articles will also be marked as
6061 read. Cross references (Xref: header) of articles are ignored.
6062 The difference between N and actual number of newsgroups that were
6063 caught up is returned."
6065 (unless (gnus-group-group-name)
6066 (error "No group on the current line"))
6067 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
6071 "Do you really want to mark all articles as read? "
6072 "Mark all unread articles as read? "))))
6074 (let ((groups (gnus-group-process-prefix n))
6077 ;; Virtual groups have to be given special treatment.
6078 (let ((method (gnus-find-method-for-group (car groups))))
6079 (if (eq 'nnvirtual (car method))
6080 (nnvirtual-catchup-group
6081 (gnus-group-real-name (car groups)) (nth 1 method) all)))
6082 (gnus-group-remove-mark (car groups))
6083 (if (>= (gnus-group-group-level) gnus-level-zombie)
6084 (gnus-message 2 "Dead groups can't be caught up")
6086 (gnus-group-goto-group (car groups))
6087 (gnus-group-catchup (car groups) all))
6088 (gnus-group-update-group-line)
6089 (setq ret (1+ ret))))
6090 (setq groups (cdr groups)))
6091 (gnus-group-next-unread-group 1)
6094 (defun gnus-group-catchup-current-all (&optional n)
6095 "Mark all articles in current newsgroup as read.
6096 Cross references (Xref: header) of articles are ignored."
6098 (gnus-group-catchup-current n 'all))
6100 (defun gnus-group-catchup (group &optional all)
6101 "Mark all articles in GROUP as read.
6102 If ALL is non-nil, all articles are marked as read.
6103 The return value is the number of articles that were marked as read,
6104 or nil if no action could be taken."
6105 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6107 ;; Do the updating only if the newsgroup isn't killed.
6108 (if (not (numberp (car entry)))
6109 (gnus-message 1 "Can't catch up; non-active group")
6110 ;; Do auto-expirable marks if that's required.
6111 (when (gnus-group-auto-expirable-p group)
6112 (gnus-add-marked-articles
6113 group 'expire (gnus-list-of-unread-articles group))
6115 (let ((marks (nth 3 (nth 2 entry))))
6116 (gnus-add-marked-articles
6117 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
6118 (gnus-add-marked-articles
6119 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
6121 (gnus-update-read-articles group nil)
6122 ;; Also nix out the lists of marks and dormants.
6124 (gnus-add-marked-articles group 'tick nil nil 'force)
6125 (gnus-add-marked-articles group 'dormant nil nil 'force))
6126 (run-hooks 'gnus-group-catchup-group-hook)
6129 (defun gnus-group-expire-articles (&optional n)
6130 "Expire all expirable articles in the current newsgroup."
6132 (let ((groups (gnus-group-process-prefix n))
6135 (error "No groups to expire"))
6136 (while (setq group (pop groups))
6137 (gnus-group-remove-mark group)
6138 (when (gnus-check-backend-function 'request-expire-articles group)
6139 (gnus-message 6 "Expiring articles in %s..." group)
6140 (let* ((info (gnus-get-info group))
6141 (expirable (if (gnus-group-total-expirable-p group)
6142 (cons nil (gnus-list-of-read-articles group))
6143 (assq 'expire (gnus-info-marks info))))
6144 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
6148 (gnus-compress-sequence
6150 ;; We set the expiry variables to the groupp
6152 (let ((nnmail-expiry-wait-function nil)
6153 (nnmail-expiry-wait expiry-wait))
6154 (gnus-request-expire-articles
6155 (gnus-uncompress-sequence (cdr expirable)) group))
6156 ;; Just expire using the normal expiry values.
6157 (gnus-request-expire-articles
6158 (gnus-uncompress-sequence (cdr expirable)) group)))))
6159 (gnus-message 6 "Expiring articles in %s...done" group)))
6160 (gnus-group-position-point))))
6162 (defun gnus-group-expire-all-groups ()
6163 "Expire all expirable articles in all newsgroups."
6166 (gnus-message 5 "Expiring...")
6167 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6168 (cdr gnus-newsrc-alist))))
6169 (gnus-group-expire-articles nil)))
6170 (gnus-group-position-point)
6171 (gnus-message 5 "Expiring...done"))
6173 (defun gnus-group-set-current-level (n level)
6174 "Set the level of the next N groups to LEVEL."
6179 (let ((s (read-string
6180 (format "Level (default %s): "
6181 (or (gnus-group-group-level)
6182 gnus-level-default-subscribed)))))
6183 (if (string-match "^\\s-*$" s)
6184 (int-to-string (or (gnus-group-group-level)
6185 gnus-level-default-subscribed))
6187 (or (and (>= level 1) (<= level gnus-level-killed))
6188 (error "Illegal level: %d" level))
6189 (let ((groups (gnus-group-process-prefix n))
6191 (while (setq group (pop groups))
6192 (gnus-group-remove-mark group)
6193 (gnus-message 6 "Changed level of %s from %d to %d"
6194 group (or (gnus-group-group-level) gnus-level-killed)
6196 (gnus-group-change-level
6197 group level (or (gnus-group-group-level) gnus-level-killed))
6198 (gnus-group-update-group-line)))
6199 (gnus-group-position-point))
6201 (defun gnus-group-unsubscribe-current-group (&optional n)
6202 "Toggle subscription of the current group.
6203 If given numerical prefix, toggle the N next groups."
6205 (let ((groups (gnus-group-process-prefix n))
6208 (setq group (car groups)
6209 groups (cdr groups))
6210 (gnus-group-remove-mark group)
6211 (gnus-group-unsubscribe-group
6212 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6213 gnus-level-default-unsubscribed
6214 gnus-level-default-subscribed) t)
6215 (gnus-group-update-group-line))
6216 (gnus-group-next-group 1)))
6218 (defun gnus-group-unsubscribe-group (group &optional level silent)
6219 "Toggle subscription to GROUP.
6220 Killed newsgroups are subscribed. If SILENT, don't try to update the
6223 (list (completing-read
6224 "Group: " gnus-active-hashtb nil
6225 (gnus-read-active-file-p)
6227 'gnus-group-history)))
6228 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6230 ((string-match "^[ \t]$" group)
6231 (error "Empty group name"))
6233 ;; Toggle subscription flag.
6234 (gnus-group-change-level
6235 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6236 gnus-level-subscribed)
6237 (1+ gnus-level-subscribed)
6238 gnus-level-default-subscribed)))
6240 (gnus-group-update-group group)))
6241 ((and (stringp group)
6242 (or (not (gnus-read-active-file-p))
6243 (gnus-active group)))
6244 ;; Add new newsgroup.
6245 (gnus-group-change-level
6247 (if level level gnus-level-default-subscribed)
6248 (or (and (member group gnus-zombie-list)
6251 (and (gnus-group-group-name)
6252 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6254 (gnus-group-update-group group)))
6255 (t (error "No such newsgroup: %s" group)))
6256 (gnus-group-position-point)))
6258 (defun gnus-group-transpose-groups (n)
6259 "Move the current newsgroup up N places.
6260 If given a negative prefix, move down instead. The difference between
6261 N and the number of steps taken is returned."
6263 (or (gnus-group-group-name)
6264 (error "No group on current line"))
6265 (gnus-group-kill-group 1)
6267 (forward-line (- n))
6268 (gnus-group-yank-group)
6269 (gnus-group-position-point)))
6271 (defun gnus-group-kill-all-zombies ()
6272 "Kill all zombie newsgroups."
6274 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6275 (setq gnus-zombie-list nil)
6276 (gnus-group-list-groups))
6278 (defun gnus-group-kill-region (begin end)
6279 "Kill newsgroups in current region (excluding current point).
6280 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6295 (beginning-of-line) ;Important when LINES < 1
6296 (gnus-group-kill-group lines)))
6298 (defun gnus-group-kill-group (&optional n discard)
6299 "Kill the next N groups.
6300 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6301 However, only groups that were alive can be yanked; already killed
6302 groups or zombie groups can't be yanked.
6303 The return value is the name of the group that was killed, or a list
6306 (let ((buffer-read-only nil)
6307 (groups (gnus-group-process-prefix n))
6308 group entry level out)
6309 (if (< (length groups) 10)
6310 ;; This is faster when there are few groups.
6312 (push (setq group (pop groups)) out)
6313 (gnus-group-remove-mark group)
6314 (setq level (gnus-group-group-level))
6316 (when (and (not discard)
6317 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6318 (push (cons (car entry) (nth 2 entry))
6319 gnus-list-of-killed-groups))
6320 (gnus-group-change-level
6321 (if entry entry group) gnus-level-killed (if entry nil level)))
6322 ;; If there are lots and lots of groups to be killed, we use
6323 ;; this thing instead.
6325 (setq groups (nreverse groups))
6327 (gnus-group-remove-mark (setq group (pop groups)))
6329 (push group gnus-killed-list)
6330 (setq gnus-newsrc-alist
6331 (delq (assoc group gnus-newsrc-alist)
6333 (when gnus-group-change-level-function
6334 (funcall gnus-group-change-level-function group 9 3))
6336 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6337 (push (cons (car entry) (nth 2 entry))
6338 gnus-list-of-killed-groups)
6339 (setcdr (cdr entry) (cdddr entry)))
6340 ((member group gnus-zombie-list)
6341 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6342 (gnus-make-hashtable-from-newsrc-alist)))
6344 (gnus-group-position-point)
6345 (if (< (length out) 2) (car out) (nreverse out))))
6347 (defun gnus-group-yank-group (&optional arg)
6348 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6349 inserting it before the current newsgroup. The numeric ARG specifies
6350 how many newsgroups are to be yanked. The name of the newsgroup yanked
6351 is returned, or (if several groups are yanked) a list of yanked groups
6354 (setq arg (or arg 1))
6355 (let (info group prev out)
6356 (while (>= (decf arg) 0)
6357 (if (not (setq info (pop gnus-list-of-killed-groups)))
6358 (error "No more newsgroups to yank"))
6359 (push (setq group (nth 1 info)) out)
6360 ;; Find which newsgroup to insert this one before - search
6361 ;; backward until something suitable is found. If there are no
6362 ;; other newsgroups in this buffer, just make this newsgroup the
6364 (setq prev (gnus-group-group-name))
6365 (gnus-group-change-level
6366 info (gnus-info-level (cdr info)) gnus-level-killed
6367 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6369 (gnus-group-insert-group-line-info group))
6371 (gnus-group-position-point)
6372 (if (< (length out) 2) (car out) (nreverse out))))
6374 (defun gnus-group-kill-level (level)
6375 "Kill all groups that is on a certain LEVEL."
6376 (interactive "nKill all groups on level: ")
6378 ((= level gnus-level-zombie)
6379 (setq gnus-killed-list
6380 (nconc gnus-zombie-list gnus-killed-list))
6381 (setq gnus-zombie-list nil))
6382 ((and (< level gnus-level-zombie)
6384 (or gnus-expert-user
6387 "Do you really want to kill all groups on level %d? "
6389 (let* ((prev gnus-newsrc-alist)
6392 (if (= (gnus-info-level level) level)
6393 (setcdr prev (cdr alist))
6395 (setq alist (cdr alist)))
6396 (gnus-make-hashtable-from-newsrc-alist)
6397 (gnus-group-list-groups)))
6399 (error "Can't kill; illegal level: %d" level))))
6401 (defun gnus-group-list-all-groups (&optional arg)
6402 "List all newsgroups with level ARG or lower.
6403 Default is gnus-level-unsubscribed, which lists all subscribed and most
6404 unsubscribed groups."
6406 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6408 ;; Redefine this to list ALL killed groups if prefix arg used.
6409 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6410 (defun gnus-group-list-killed (&optional arg)
6411 "List all killed newsgroups in the group buffer.
6412 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6413 entail asking the server for the groups."
6415 ;; Find all possible killed newsgroups if arg.
6417 (gnus-get-killed-groups))
6418 (if (not gnus-killed-list)
6419 (gnus-message 6 "No killed groups")
6420 (let (gnus-group-list-mode)
6421 (funcall gnus-group-prepare-function
6422 gnus-level-killed t gnus-level-killed))
6423 (goto-char (point-min)))
6424 (gnus-group-position-point))
6426 (defun gnus-group-list-zombies ()
6427 "List all zombie newsgroups in the group buffer."
6429 (if (not gnus-zombie-list)
6430 (gnus-message 6 "No zombie groups")
6431 (let (gnus-group-list-mode)
6432 (funcall gnus-group-prepare-function
6433 gnus-level-zombie t gnus-level-zombie))
6434 (goto-char (point-min)))
6435 (gnus-group-position-point))
6437 (defun gnus-group-list-active ()
6438 "List all groups that are available from the server(s)."
6440 ;; First we make sure that we have really read the active file.
6441 (unless (gnus-read-active-file-p)
6442 (let ((gnus-read-active-file t))
6443 (gnus-read-active-file)))
6444 ;; Find all groups and sort them.
6452 (setq list (cons (symbol-name sym) list))))
6456 (buffer-read-only nil))
6459 (gnus-group-insert-group-line-info (pop groups)))
6460 (goto-char (point-min))))
6462 (defun gnus-activate-all-groups (level)
6463 "Activate absolutely all groups."
6464 (interactive (list 7))
6465 (let ((gnus-activate-level level)
6466 (gnus-activate-foreign-newsgroups level))
6467 (gnus-group-get-new-news)))
6469 (defun gnus-group-get-new-news (&optional arg)
6470 "Get newly arrived articles.
6471 If ARG is a number, it specifies which levels you are interested in
6472 re-scanning. If ARG is non-nil and not a number, this will force
6473 \"hard\" re-reading of the active files from all servers."
6475 (run-hooks 'gnus-get-new-news-hook)
6476 ;; We might read in new NoCeM messages here.
6477 (when (and gnus-use-nocem
6479 (gnus-nocem-scan-groups))
6480 ;; If ARG is not a number, then we read the active file.
6481 (when (and arg (not (numberp arg)))
6482 (let ((gnus-read-active-file t))
6483 (gnus-read-active-file))
6486 (setq arg (gnus-group-default-level arg t))
6487 (if (and gnus-read-active-file (not arg))
6489 (gnus-read-active-file)
6490 (gnus-get-unread-articles arg))
6491 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6492 (gnus-get-unread-articles arg)))
6493 (run-hooks 'gnus-after-getting-new-news-hook)
6494 (gnus-group-list-groups))
6496 (defun gnus-group-get-new-news-this-group (&optional n)
6497 "Check for newly arrived news in the current group (and the N-1 next groups).
6498 The difference between N and the number of newsgroup checked is returned.
6499 If N is negative, this group and the N-1 previous groups will be checked."
6501 (let* ((groups (gnus-group-process-prefix n))
6502 (ret (if (numberp n) (- n (length groups)) 0))
6503 (beg (unless n (point)))
6505 (while (setq group (pop groups))
6506 (gnus-group-remove-mark group)
6507 (if (gnus-activate-group group 'scan)
6509 (gnus-get-unread-articles-in-group
6510 (gnus-get-info group) (gnus-active group) t)
6511 (unless (gnus-virtual-group-p group)
6512 (gnus-close-group group))
6513 (gnus-group-update-group group))
6514 (gnus-error 3 "%s error: %s" group (gnus-status-message group))))
6515 (when beg (goto-char beg))
6516 (when gnus-goto-next-group-when-activating
6517 (gnus-group-next-unread-group 1 t))
6518 (gnus-summary-position-point)
6521 (defun gnus-group-fetch-faq (group &optional faq-dir)
6522 "Fetch the FAQ for the current group."
6525 (and (gnus-group-group-name)
6526 (gnus-group-real-name (gnus-group-group-name)))
6527 (cond (current-prefix-arg
6529 "Faq dir: " (and (listp gnus-group-faq-directory)
6530 (mapcar (lambda (file) (list file))
6531 gnus-group-faq-directory)))))))
6533 (setq faq-dir (if (listp gnus-group-faq-directory)
6534 (car gnus-group-faq-directory)
6535 gnus-group-faq-directory)))
6536 (or group (error "No group name given"))
6537 (let ((file (concat (file-name-as-directory faq-dir)
6538 (gnus-group-real-name group))))
6539 (if (not (file-exists-p file))
6540 (error "No such file: %s" file)
6543 (defun gnus-group-describe-group (force &optional group)
6544 "Display a description of the current newsgroup."
6545 (interactive (list current-prefix-arg (gnus-group-group-name)))
6547 gnus-description-hashtb)
6548 (gnus-sethash group nil gnus-description-hashtb))
6549 (let ((method (gnus-find-method-for-group group))
6551 (or group (error "No group name given"))
6552 (and (or (and gnus-description-hashtb
6553 ;; We check whether this group's method has been
6554 ;; queried for a description file.
6556 (gnus-group-prefixed-name "" method)
6557 gnus-description-hashtb))
6558 (setq desc (gnus-group-get-description group))
6559 (gnus-read-descriptions-file method))
6561 (or desc (gnus-gethash group gnus-description-hashtb)
6562 "No description available")))))
6564 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6565 (defun gnus-group-describe-all-groups (&optional force)
6566 "Pop up a buffer with descriptions of all newsgroups."
6568 (and force (setq gnus-description-hashtb nil))
6569 (if (not (or gnus-description-hashtb
6570 (gnus-read-all-descriptions-files)))
6571 (error "Couldn't request descriptions file"))
6572 (let ((buffer-read-only nil)
6578 (insert (format " *: %-20s %s\n" (symbol-name group)
6579 (symbol-value group)))
6580 (gnus-add-text-properties
6581 b (1+ b) (list 'gnus-group group
6582 'gnus-unread t 'gnus-marked nil
6583 'gnus-level (1+ gnus-level-subscribed))))
6584 gnus-description-hashtb)
6585 (goto-char (point-min))
6586 (gnus-group-position-point)))
6588 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6589 (defun gnus-group-apropos (regexp &optional search-description)
6590 "List all newsgroups that have names that match a regexp."
6591 (interactive "sGnus apropos (regexp): ")
6593 (obuf (current-buffer))
6595 ;; Go through all newsgroups that are known to Gnus.
6598 (and (symbol-name group)
6599 (string-match regexp (symbol-name group))
6600 (setq groups (cons (symbol-name group) groups))))
6602 ;; Also go through all descriptions that are known to Gnus.
6603 (when search-description
6606 (and (string-match regexp (symbol-value group))
6607 (gnus-active (symbol-name group))
6608 (setq groups (cons (symbol-name group) groups))))
6609 gnus-description-hashtb))
6611 (gnus-message 3 "No groups matched \"%s\"." regexp)
6612 ;; Print out all the groups.
6614 (pop-to-buffer "*Gnus Help*")
6615 (buffer-disable-undo (current-buffer))
6617 (setq groups (sort groups 'string<))
6619 ;; Groups may be entered twice into the list of groups.
6620 (if (not (string= (car groups) prev))
6622 (insert (setq prev (car groups)) "\n")
6623 (if (and gnus-description-hashtb
6624 (setq des (gnus-gethash (car groups)
6625 gnus-description-hashtb)))
6626 (insert " " des "\n"))))
6627 (setq groups (cdr groups)))
6628 (goto-char (point-min))))
6629 (pop-to-buffer obuf)))
6631 (defun gnus-group-description-apropos (regexp)
6632 "List all newsgroups that have names or descriptions that match a regexp."
6633 (interactive "sGnus description apropos (regexp): ")
6634 (if (not (or gnus-description-hashtb
6635 (gnus-read-all-descriptions-files)))
6636 (error "Couldn't request descriptions file"))
6637 (gnus-group-apropos regexp t))
6639 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6640 (defun gnus-group-list-matching (level regexp &optional all lowest)
6641 "List all groups with unread articles that match REGEXP.
6642 If the prefix LEVEL is non-nil, it should be a number that says which
6643 level to cut off listing groups.
6644 If ALL, also list groups with no unread articles.
6645 If LOWEST, don't list groups with level lower than LOWEST.
6647 This command may read the active file."
6648 (interactive "P\nsList newsgroups matching: ")
6649 ;; First make sure active file has been read.
6651 (> (prefix-numeric-value level) gnus-level-killed))
6652 (gnus-get-killed-groups))
6653 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6654 all (or lowest 1) regexp)
6655 (goto-char (point-min))
6656 (gnus-group-position-point))
6658 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6659 "List all groups that match REGEXP.
6660 If the prefix LEVEL is non-nil, it should be a number that says which
6661 level to cut off listing groups.
6662 If LOWEST, don't list groups with level lower than LOWEST."
6663 (interactive "P\nsList newsgroups matching: ")
6664 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6666 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6667 (defun gnus-group-save-newsrc (&optional force)
6668 "Save the Gnus startup files.
6669 If FORCE, force saving whether it is necessary or not."
6671 (gnus-save-newsrc-file force))
6673 (defun gnus-group-restart (&optional arg)
6674 "Force Gnus to read the .newsrc file."
6676 (when (gnus-yes-or-no-p
6677 (format "Are you sure you want to read %s? "
6678 gnus-current-startup-file))
6679 (gnus-save-newsrc-file)
6680 (gnus-setup-news 'force)
6681 (gnus-group-list-groups arg)))
6683 (defun gnus-group-read-init-file ()
6684 "Read the Gnus elisp init file."
6686 (gnus-read-init-file))
6688 (defun gnus-group-check-bogus-groups (&optional silent)
6689 "Check bogus newsgroups.
6690 If given a prefix, don't ask for confirmation before removing a bogus
6693 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6694 (gnus-group-list-groups))
6696 (defun gnus-group-edit-global-kill (&optional article group)
6697 "Edit the global kill file.
6698 If GROUP, edit that local kill file instead."
6700 (setq gnus-current-kill-article article)
6701 (gnus-kill-file-edit-file group)
6704 (substitute-command-keys
6705 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6706 (if group "local" "global")))))
6708 (defun gnus-group-edit-local-kill (article group)
6709 "Edit a local kill file."
6710 (interactive (list nil (gnus-group-group-name)))
6711 (gnus-group-edit-global-kill article group))
6713 (defun gnus-group-force-update ()
6714 "Update `.newsrc' file."
6716 (gnus-save-newsrc-file))
6718 (defun gnus-group-suspend ()
6719 "Suspend the current Gnus session.
6720 In fact, cleanup buffers except for group mode buffer.
6721 The hook gnus-suspend-gnus-hook is called before actually suspending."
6723 (run-hooks 'gnus-suspend-gnus-hook)
6724 ;; Kill Gnus buffers except for group mode buffer.
6725 (let ((group-buf (get-buffer gnus-group-buffer)))
6726 ;; Do this on a separate list in case the user does a ^G before we finish
6727 (let ((gnus-buffer-list
6728 (delq group-buf (delq gnus-dribble-buffer
6729 (append gnus-buffer-list nil)))))
6730 (while gnus-buffer-list
6731 (gnus-kill-buffer (car gnus-buffer-list))
6732 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6735 (setq gnus-buffer-list (list group-buf))
6736 (bury-buffer group-buf)
6737 (delete-windows-on group-buf t)))))
6739 (defun gnus-group-clear-dribble ()
6740 "Clear all information from the dribble buffer."
6742 (gnus-dribble-clear)
6743 (gnus-message 7 "Cleared dribble buffer"))
6745 (defun gnus-group-exit ()
6746 "Quit reading news after updating .newsrc.eld and .newsrc.
6747 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6750 (or noninteractive ;For gnus-batch-kill
6751 (not gnus-interactive-exit) ;Without confirmation
6753 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6754 (run-hooks 'gnus-exit-gnus-hook)
6755 ;; Offer to save data from non-quitted summary buffers.
6756 (gnus-offer-save-summaries)
6757 ;; Save the newsrc file(s).
6758 (gnus-save-newsrc-file)
6760 (gnus-close-backends)
6761 ;; Reset everything.
6763 ;; Allow the user to do things after cleaning up.
6764 (run-hooks 'gnus-after-exiting-gnus-hook)))
6766 (defun gnus-close-backends ()
6767 ;; Send a close request to all backends that support such a request.
6768 (let ((methods gnus-valid-select-methods)
6771 (if (fboundp (setq func (intern (concat (caar methods)
6772 "-request-close"))))
6774 (setq methods (cdr methods)))))
6776 (defun gnus-group-quit ()
6777 "Quit reading news without updating .newsrc.eld or .newsrc.
6778 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6780 (when (or noninteractive ;For gnus-batch-kill
6781 (zerop (buffer-size))
6782 (not (gnus-server-opened gnus-select-method))
6784 (not gnus-current-startup-file)
6786 (format "Quit reading news without saving %s? "
6787 (file-name-nondirectory gnus-current-startup-file))))
6788 (run-hooks 'gnus-exit-gnus-hook)
6789 (if gnus-use-full-window
6790 (delete-other-windows)
6791 (gnus-remove-some-windows))
6793 (gnus-close-backends)
6795 ;; Allow the user to do things after cleaning up.
6796 (run-hooks 'gnus-after-exiting-gnus-hook)))
6798 (defun gnus-offer-save-summaries ()
6799 "Offer to save all active summary buffers."
6801 (let ((buflist (buffer-list))
6803 ;; Go through all buffers and find all summaries.
6805 (and (setq bufname (buffer-name (car buflist)))
6806 (string-match "Summary" bufname)
6808 (set-buffer bufname)
6809 ;; We check that this is, indeed, a summary buffer.
6810 (and (eq major-mode 'gnus-summary-mode)
6811 ;; Also make sure this isn't bogus.
6812 gnus-newsgroup-prepared))
6813 (push bufname buffers))
6814 (setq buflist (cdr buflist)))
6815 ;; Go through all these summary buffers and offer to save them.
6818 "Update summary buffer %s? "
6819 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6822 (defun gnus-group-describe-briefly ()
6823 "Give a one line description of the group mode commands."
6825 (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")))
6827 (defun gnus-group-browse-foreign-server (method)
6828 "Browse a foreign news server.
6829 If called interactively, this function will ask for a select method
6830 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6831 If not, METHOD should be a list where the first element is the method
6832 and the second element is the address."
6834 (list (let ((how (completing-read
6836 (append gnus-valid-select-methods gnus-server-alist)
6837 nil t (cons "nntp" 0) 'gnus-method-history)))
6838 ;; We either got a backend name or a virtual server name.
6839 ;; If the first, we also need an address.
6840 (if (assoc how gnus-valid-select-methods)
6842 ;; Suggested by mapjph@bath.ac.uk.
6845 (mapcar (lambda (server) (list server))
6846 gnus-secondary-servers)))
6847 ;; We got a server name, so we find the method.
6848 (gnus-server-to-method how)))))
6849 (gnus-browse-foreign-server method))
6853 ;;; Gnus summary mode
6856 (defvar gnus-summary-mode-map nil)
6858 (put 'gnus-summary-mode 'mode-class 'special)
6860 (unless gnus-summary-mode-map
6861 (setq gnus-summary-mode-map (make-keymap))
6862 (suppress-keymap gnus-summary-mode-map)
6864 ;; Non-orthogonal keys
6866 (gnus-define-keys gnus-summary-mode-map
6867 " " gnus-summary-next-page
6868 "\177" gnus-summary-prev-page
6869 [delete] gnus-summary-prev-page
6870 "\r" gnus-summary-scroll-up
6871 "n" gnus-summary-next-unread-article
6872 "p" gnus-summary-prev-unread-article
6873 "N" gnus-summary-next-article
6874 "P" gnus-summary-prev-article
6875 "\M-\C-n" gnus-summary-next-same-subject
6876 "\M-\C-p" gnus-summary-prev-same-subject
6877 "\M-n" gnus-summary-next-unread-subject
6878 "\M-p" gnus-summary-prev-unread-subject
6879 "." gnus-summary-first-unread-article
6880 "," gnus-summary-best-unread-article
6881 "\M-s" gnus-summary-search-article-forward
6882 "\M-r" gnus-summary-search-article-backward
6883 "<" gnus-summary-beginning-of-article
6884 ">" gnus-summary-end-of-article
6885 "j" gnus-summary-goto-article
6886 "^" gnus-summary-refer-parent-article
6887 "\M-^" gnus-summary-refer-article
6888 "u" gnus-summary-tick-article-forward
6889 "!" gnus-summary-tick-article-forward
6890 "U" gnus-summary-tick-article-backward
6891 "d" gnus-summary-mark-as-read-forward
6892 "D" gnus-summary-mark-as-read-backward
6893 "E" gnus-summary-mark-as-expirable
6894 "\M-u" gnus-summary-clear-mark-forward
6895 "\M-U" gnus-summary-clear-mark-backward
6896 "k" gnus-summary-kill-same-subject-and-select
6897 "\C-k" gnus-summary-kill-same-subject
6898 "\M-\C-k" gnus-summary-kill-thread
6899 "\M-\C-l" gnus-summary-lower-thread
6900 "e" gnus-summary-edit-article
6901 "#" gnus-summary-mark-as-processable
6902 "\M-#" gnus-summary-unmark-as-processable
6903 "\M-\C-t" gnus-summary-toggle-threads
6904 "\M-\C-s" gnus-summary-show-thread
6905 "\M-\C-h" gnus-summary-hide-thread
6906 "\M-\C-f" gnus-summary-next-thread
6907 "\M-\C-b" gnus-summary-prev-thread
6908 "\M-\C-u" gnus-summary-up-thread
6909 "\M-\C-d" gnus-summary-down-thread
6910 "&" gnus-summary-execute-command
6911 "c" gnus-summary-catchup-and-exit
6912 "\C-w" gnus-summary-mark-region-as-read
6913 "\C-t" gnus-summary-toggle-truncation
6914 "?" gnus-summary-mark-as-dormant
6915 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6916 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6917 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6918 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6919 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6920 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6921 "=" gnus-summary-expand-window
6922 "\C-x\C-s" gnus-summary-reselect-current-group
6923 "\M-g" gnus-summary-rescan-group
6924 "w" gnus-summary-stop-page-breaking
6925 "\C-c\C-r" gnus-summary-caesar-message
6926 "\M-t" gnus-summary-toggle-mime
6927 "f" gnus-summary-followup
6928 "F" gnus-summary-followup-with-original
6929 "C" gnus-summary-cancel-article
6930 "r" gnus-summary-reply
6931 "R" gnus-summary-reply-with-original
6932 "\C-c\C-f" gnus-summary-mail-forward
6933 "o" gnus-summary-save-article
6934 "\C-o" gnus-summary-save-article-mail
6935 "|" gnus-summary-pipe-output
6936 "\M-k" gnus-summary-edit-local-kill
6937 "\M-K" gnus-summary-edit-global-kill
6939 "\C-c\C-d" gnus-summary-describe-group
6940 "q" gnus-summary-exit
6941 "Q" gnus-summary-exit-no-update
6942 "\C-c\C-i" gnus-info-find-node
6943 gnus-mouse-2 gnus-mouse-pick-article
6944 "m" gnus-summary-mail-other-window
6945 "a" gnus-summary-post-news
6946 "x" gnus-summary-limit-to-unread
6947 "s" gnus-summary-isearch-article
6948 "t" gnus-article-hide-headers
6949 "g" gnus-summary-show-article
6950 "l" gnus-summary-goto-last-article
6951 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6952 "\C-d" gnus-summary-enter-digest-group
6954 "*" gnus-cache-enter-article
6955 "\M-*" gnus-cache-remove-article
6956 "\M-&" gnus-summary-universal-argument
6957 "\C-l" gnus-recenter
6958 "I" gnus-summary-increase-score
6959 "L" gnus-summary-lower-score
6961 "V" gnus-summary-score-map
6962 "X" gnus-uu-extract-map
6963 "S" gnus-summary-send-map)
6965 ;; Sort of orthogonal keymap
6966 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6967 "t" gnus-summary-tick-article-forward
6968 "!" gnus-summary-tick-article-forward
6969 "d" gnus-summary-mark-as-read-forward
6970 "r" gnus-summary-mark-as-read-forward
6971 "c" gnus-summary-clear-mark-forward
6972 " " gnus-summary-clear-mark-forward
6973 "e" gnus-summary-mark-as-expirable
6974 "x" gnus-summary-mark-as-expirable
6975 "?" gnus-summary-mark-as-dormant
6976 "b" gnus-summary-set-bookmark
6977 "B" gnus-summary-remove-bookmark
6978 "#" gnus-summary-mark-as-processable
6979 "\M-#" gnus-summary-unmark-as-processable
6980 "S" gnus-summary-limit-include-expunged
6981 "C" gnus-summary-catchup
6982 "H" gnus-summary-catchup-to-here
6983 "\C-c" gnus-summary-catchup-all
6984 "k" gnus-summary-kill-same-subject-and-select
6985 "K" gnus-summary-kill-same-subject
6986 "P" gnus-uu-mark-map)
6988 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6989 "c" gnus-summary-clear-above
6990 "u" gnus-summary-tick-above
6991 "m" gnus-summary-mark-above
6992 "k" gnus-summary-kill-below)
6994 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6995 "/" gnus-summary-limit-to-subject
6996 "n" gnus-summary-limit-to-articles
6997 "w" gnus-summary-pop-limit
6998 "s" gnus-summary-limit-to-subject
6999 "a" gnus-summary-limit-to-author
7000 "u" gnus-summary-limit-to-unread
7001 "m" gnus-summary-limit-to-marks
7002 "v" gnus-summary-limit-to-score
7003 "D" gnus-summary-limit-include-dormant
7004 "d" gnus-summary-limit-exclude-dormant
7005 ;; "t" gnus-summary-limit-exclude-thread
7006 "E" gnus-summary-limit-include-expunged
7007 "c" gnus-summary-limit-exclude-childless-dormant
7008 "C" gnus-summary-limit-mark-excluded-as-read)
7010 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
7011 "n" gnus-summary-next-unread-article
7012 "p" gnus-summary-prev-unread-article
7013 "N" gnus-summary-next-article
7014 "P" gnus-summary-prev-article
7015 "\C-n" gnus-summary-next-same-subject
7016 "\C-p" gnus-summary-prev-same-subject
7017 "\M-n" gnus-summary-next-unread-subject
7018 "\M-p" gnus-summary-prev-unread-subject
7019 "f" gnus-summary-first-unread-article
7020 "b" gnus-summary-best-unread-article
7021 "j" gnus-summary-goto-article
7022 "g" gnus-summary-goto-subject
7023 "l" gnus-summary-goto-last-article
7024 "p" gnus-summary-pop-article)
7026 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
7027 "k" gnus-summary-kill-thread
7028 "l" gnus-summary-lower-thread
7029 "i" gnus-summary-raise-thread
7030 "T" gnus-summary-toggle-threads
7031 "t" gnus-summary-rethread-current
7032 "^" gnus-summary-reparent-thread
7033 "s" gnus-summary-show-thread
7034 "S" gnus-summary-show-all-threads
7035 "h" gnus-summary-hide-thread
7036 "H" gnus-summary-hide-all-threads
7037 "n" gnus-summary-next-thread
7038 "p" gnus-summary-prev-thread
7039 "u" gnus-summary-up-thread
7040 "o" gnus-summary-top-thread
7041 "d" gnus-summary-down-thread
7042 "#" gnus-uu-mark-thread
7043 "\M-#" gnus-uu-unmark-thread)
7045 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
7046 "c" gnus-summary-catchup-and-exit
7047 "C" gnus-summary-catchup-all-and-exit
7048 "E" gnus-summary-exit-no-update
7049 "Q" gnus-summary-exit
7050 "Z" gnus-summary-exit
7051 "n" gnus-summary-catchup-and-goto-next-group
7052 "R" gnus-summary-reselect-current-group
7053 "G" gnus-summary-rescan-group
7054 "N" gnus-summary-next-group
7055 "P" gnus-summary-prev-group)
7057 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
7058 " " gnus-summary-next-page
7059 "n" gnus-summary-next-page
7060 "\177" gnus-summary-prev-page
7061 [delete] gnus-summary-prev-page
7062 "p" gnus-summary-prev-page
7063 "\r" gnus-summary-scroll-up
7064 "<" gnus-summary-beginning-of-article
7065 ">" gnus-summary-end-of-article
7066 "b" gnus-summary-beginning-of-article
7067 "e" gnus-summary-end-of-article
7068 "^" gnus-summary-refer-parent-article
7069 "r" gnus-summary-refer-parent-article
7070 "R" gnus-summary-refer-references
7071 "g" gnus-summary-show-article
7072 "s" gnus-summary-isearch-article)
7074 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
7075 "b" gnus-article-add-buttons
7076 "B" gnus-article-add-buttons-to-head
7077 "o" gnus-article-treat-overstrike
7078 ;; "w" gnus-article-word-wrap
7079 "w" gnus-article-fill-cited-article
7080 "c" gnus-article-remove-cr
7081 "L" gnus-article-remove-trailing-blank-lines
7082 "q" gnus-article-de-quoted-unreadable
7083 "f" gnus-article-display-x-face
7084 "l" gnus-summary-stop-page-breaking
7085 "r" gnus-summary-caesar-message
7086 "t" gnus-article-hide-headers
7087 "v" gnus-summary-verbose-headers
7088 "m" gnus-summary-toggle-mime)
7090 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
7091 "a" gnus-article-hide
7092 "h" gnus-article-hide-headers
7093 "b" gnus-article-hide-boring-headers
7094 "s" gnus-article-hide-signature
7095 "c" gnus-article-hide-citation
7096 "p" gnus-article-hide-pgp
7097 "\C-c" gnus-article-hide-citation-maybe)
7099 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
7100 "a" gnus-article-highlight
7101 "h" gnus-article-highlight-headers
7102 "c" gnus-article-highlight-citation
7103 "s" gnus-article-highlight-signature)
7105 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
7106 "z" gnus-article-date-ut
7107 "u" gnus-article-date-ut
7108 "l" gnus-article-date-local
7109 "e" gnus-article-date-lapsed
7110 "o" gnus-article-date-original)
7112 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
7114 "f" gnus-summary-fetch-faq
7115 "d" gnus-summary-describe-group
7116 "h" gnus-summary-describe-briefly
7117 "i" gnus-info-find-node)
7119 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
7120 "e" gnus-summary-expire-articles
7121 "\M-\C-e" gnus-summary-expire-articles-now
7122 "\177" gnus-summary-delete-article
7123 [delete] gnus-summary-delete-article
7124 "m" gnus-summary-move-article
7125 "r" gnus-summary-respool-article
7126 "w" gnus-summary-edit-article
7127 "c" gnus-summary-copy-article
7128 "B" gnus-summary-crosspost-article
7129 "q" gnus-summary-respool-query
7130 "i" gnus-summary-import-article)
7132 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
7133 "o" gnus-summary-save-article
7134 "m" gnus-summary-save-article-mail
7135 "r" gnus-summary-save-article-rmail
7136 "f" gnus-summary-save-article-file
7137 "b" gnus-summary-save-article-body-file
7138 "h" gnus-summary-save-article-folder
7139 "v" gnus-summary-save-article-vm
7140 "p" gnus-summary-pipe-output
7141 "s" gnus-soup-add-article)
7146 (defun gnus-summary-mode (&optional group)
7147 "Major mode for reading articles.
7149 All normal editing commands are switched off.
7150 \\<gnus-summary-mode-map>
7151 Each line in this buffer represents one article. To read an
7152 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
7153 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7156 You can also post articles and send mail from this buffer. To
7157 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7158 of an article, type `\\[gnus-summary-reply]'.
7160 There are approx. one gazillion commands you can execute in this
7161 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7163 The following commands are available:
7165 \\{gnus-summary-mode-map}"
7167 (when (and menu-bar-mode
7168 (gnus-visual-p 'summary-menu 'menu))
7169 (gnus-summary-make-menu-bar))
7170 (kill-all-local-variables)
7171 (gnus-summary-make-local-variables)
7172 (gnus-make-thread-indent-array)
7173 (gnus-simplify-mode-line)
7174 (setq major-mode 'gnus-summary-mode)
7175 (setq mode-name "Summary")
7176 (make-local-variable 'minor-mode-alist)
7177 (use-local-map gnus-summary-mode-map)
7178 (buffer-disable-undo (current-buffer))
7179 (setq buffer-read-only t) ;Disable modification
7180 (setq truncate-lines t)
7181 (setq selective-display t)
7182 (setq selective-display-ellipses t) ;Display `...'
7183 (setq buffer-display-table gnus-summary-display-table)
7184 (setq gnus-newsgroup-name group)
7185 (make-local-variable 'gnus-summary-line-format)
7186 (make-local-variable 'gnus-summary-line-format-spec)
7187 (make-local-variable 'gnus-summary-mark-positions)
7188 (run-hooks 'gnus-summary-mode-hook))
7190 (defun gnus-summary-make-local-variables ()
7191 "Make all the local summary buffer variables."
7192 (let ((locals gnus-summary-local-variables)
7194 (while (setq local (pop locals))
7197 (if (eq (cdr local) 'global)
7198 ;; Copy the global value of the variable.
7199 (setq global (symbol-value (car local)))
7200 ;; Use the value from the list.
7201 (setq global (eval (cdr local))))
7202 (make-local-variable (car local))
7203 (set (car local) global))
7204 ;; Simple nil-valued local variable.
7205 (make-local-variable local)
7208 (defun gnus-summary-make-display-table ()
7209 ;; Change the display table. Odd characters have a tendency to mess
7210 ;; up nicely formatted displays - we make all possible glyphs
7211 ;; display only a single character.
7213 ;; We start from the standard display table, if any.
7214 (setq gnus-summary-display-table
7215 (or (copy-sequence standard-display-table)
7216 (make-display-table)))
7217 ;; Nix out all the control chars...
7219 (while (>= (setq i (1- i)) 0)
7220 (aset gnus-summary-display-table i [??])))
7221 ;; ... but not newline and cr, of course. (cr is necessary for the
7222 ;; selective display).
7223 (aset gnus-summary-display-table ?\n nil)
7224 (aset gnus-summary-display-table ?\r nil)
7225 ;; We nix out any glyphs over 126 that are not set already.
7227 (while (>= (setq i (1- i)) 127)
7228 ;; Only modify if the entry is nil.
7229 (or (aref gnus-summary-display-table i)
7230 (aset gnus-summary-display-table i [??])))))
7232 (defun gnus-summary-clear-local-variables ()
7233 (let ((locals gnus-summary-local-variables))
7235 (if (consp (car locals))
7236 (and (vectorp (caar locals))
7237 (set (caar locals) nil))
7238 (and (vectorp (car locals))
7239 (set (car locals) nil)))
7240 (setq locals (cdr locals)))))
7242 ;; Summary data functions.
7244 (defmacro gnus-data-number (data)
7247 (defmacro gnus-data-set-number (data number)
7248 `(setcar ,data ,number))
7250 (defmacro gnus-data-mark (data)
7253 (defmacro gnus-data-set-mark (data mark)
7254 `(setcar (nthcdr 1 ,data) ,mark))
7256 (defmacro gnus-data-pos (data)
7259 (defmacro gnus-data-set-pos (data pos)
7260 `(setcar (nthcdr 2 ,data) ,pos))
7262 (defmacro gnus-data-header (data)
7265 (defmacro gnus-data-level (data)
7268 (defmacro gnus-data-unread-p (data)
7269 `(= (nth 1 ,data) gnus-unread-mark))
7271 (defmacro gnus-data-pseudo-p (data)
7272 `(consp (nth 3 ,data)))
7274 (defmacro gnus-data-find (number)
7275 `(assq ,number gnus-newsgroup-data))
7277 (defmacro gnus-data-find-list (number &optional data)
7278 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7279 (memq (assq ,number bdata)
7282 (defmacro gnus-data-make (number mark pos header level)
7283 `(list ,number ,mark ,pos ,header ,level))
7285 (defun gnus-data-enter (after-article number mark pos header level offset)
7286 (let ((data (gnus-data-find-list after-article)))
7287 (or data (error "No such article: %d" after-article))
7288 (setcdr data (cons (gnus-data-make number mark pos header level)
7290 (setq gnus-newsgroup-data-reverse nil)
7291 (gnus-data-update-list (cddr data) offset)))
7293 (defun gnus-data-enter-list (after-article list &optional offset)
7295 (let ((data (and after-article (gnus-data-find-list after-article)))
7297 (or data (not after-article) (error "No such article: %d" after-article))
7298 ;; Find the last element in the list to be spliced into the main
7301 (setq list (cdr list)))
7304 (setcdr list gnus-newsgroup-data)
7305 (setq gnus-newsgroup-data ilist)
7306 (and offset (gnus-data-update-list (cdr list) offset)))
7307 (setcdr list (cdr data))
7309 (and offset (gnus-data-update-list (cdr data) offset)))
7310 (setq gnus-newsgroup-data-reverse nil))))
7312 (defun gnus-data-remove (article &optional offset)
7313 (let ((data gnus-newsgroup-data))
7314 (if (= (gnus-data-number (car data)) article)
7315 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7316 gnus-newsgroup-data-reverse nil)
7318 (and (= (gnus-data-number (cadr data)) article)
7320 (setcdr data (cddr data))
7321 (and offset (gnus-data-update-list (cdr data) offset))
7323 gnus-newsgroup-data-reverse nil)))
7324 (setq data (cdr data))))))
7326 (defmacro gnus-data-list (backward)
7328 (or gnus-newsgroup-data-reverse
7329 (setq gnus-newsgroup-data-reverse
7330 (reverse gnus-newsgroup-data)))
7331 gnus-newsgroup-data))
7333 (defun gnus-data-update-list (data offset)
7334 "Add OFFSET to the POS of all data entries in DATA."
7336 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7337 (setq data (cdr data))))
7339 (defun gnus-data-compute-positions ()
7340 "Compute the positions of all articles."
7341 (let ((data gnus-newsgroup-data)
7344 (when (setq pos (text-property-any
7345 (point-min) (point-max)
7346 'gnus-number (gnus-data-number (car data))))
7347 (gnus-data-set-pos (car data) (+ pos 3)))
7348 (setq data (cdr data)))))
7350 (defun gnus-summary-article-pseudo-p (article)
7351 "Say whether this article is a pseudo article or not."
7352 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7354 (defun gnus-article-parent-p (number)
7355 "Say whether this article is a parent or not."
7356 (let ((data (gnus-data-find-list number)))
7357 (and (cdr data) ; There has to be an article after...
7358 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7359 (gnus-data-level (nth 1 data))))))
7361 (defun gnus-article-children (number)
7362 "Return a list of all children to NUMBER."
7363 (let* ((data (gnus-data-find-list number))
7364 (level (gnus-data-level (car data)))
7366 (setq data (cdr data))
7368 (= (gnus-data-level (car data)) (1+ level)))
7369 (push (gnus-data-number (car data)) children)
7370 (setq data (cdr data)))
7373 (defmacro gnus-summary-skip-intangible ()
7374 "If the current article is intangible, then jump to a different article."
7375 '(let ((to (get-text-property (point) 'gnus-intangible)))
7376 (and to (gnus-summary-goto-subject to))))
7378 (defmacro gnus-summary-article-intangible-p ()
7379 "Say whether this article is intangible or not."
7380 '(get-text-property (point) 'gnus-intangible))
7382 ;; Some summary mode macros.
7384 (defmacro gnus-summary-article-number ()
7385 "The article number of the article on the current line.
7386 If there isn's an article number here, then we return the current
7389 (gnus-summary-skip-intangible)
7390 (or (get-text-property (point) 'gnus-number)
7391 (gnus-summary-last-subject))))
7393 (defmacro gnus-summary-article-header (&optional number)
7394 `(gnus-data-header (gnus-data-find
7395 ,(or number '(gnus-summary-article-number)))))
7397 (defmacro gnus-summary-thread-level (&optional number)
7398 `(if (and (eq gnus-summary-make-false-root 'dummy)
7399 (get-text-property (point) 'gnus-intangible))
7401 (gnus-data-level (gnus-data-find
7402 ,(or number '(gnus-summary-article-number))))))
7404 (defmacro gnus-summary-article-mark (&optional number)
7405 `(gnus-data-mark (gnus-data-find
7406 ,(or number '(gnus-summary-article-number)))))
7408 (defmacro gnus-summary-article-pos (&optional number)
7409 `(gnus-data-pos (gnus-data-find
7410 ,(or number '(gnus-summary-article-number)))))
7412 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7413 (defmacro gnus-summary-article-subject (&optional number)
7414 "Return current subject string or nil if nothing."
7417 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7418 '(gnus-data-header (assq (gnus-summary-article-number)
7419 gnus-newsgroup-data)))))
7422 (mail-header-subject headers))))
7424 (defmacro gnus-summary-article-score (&optional number)
7425 "Return current article score."
7426 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7427 gnus-newsgroup-scored))
7428 gnus-summary-default-score 0))
7430 (defun gnus-summary-article-children (&optional number)
7431 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7432 (level (gnus-data-level (car data)))
7434 (while (and (setq data (cdr data))
7435 (> (setq l (gnus-data-level (car data))) level))
7436 (and (= (1+ level) l)
7437 (setq children (cons (gnus-data-number (car data))
7439 (nreverse children)))
7441 (defun gnus-summary-article-parent (&optional number)
7442 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7443 (gnus-data-list t)))
7444 (level (gnus-data-level (car data))))
7446 () ; This is a root.
7447 ;; We search until we find an article with a level less than
7448 ;; this one. That function has to be the parent.
7449 (while (and (setq data (cdr data))
7450 (not (< (gnus-data-level (car data)) level))))
7451 (and data (gnus-data-number (car data))))))
7453 (defun gnus-unread-mark-p (mark)
7454 "Say whether MARK is the unread mark."
7455 (= mark gnus-unread-mark))
7457 (defun gnus-read-mark-p (mark)
7458 "Say whether MARK is one of the marks that mark as read.
7459 This is all marks except unread, ticked, dormant, and expirable."
7460 (not (or (= mark gnus-unread-mark)
7461 (= mark gnus-ticked-mark)
7462 (= mark gnus-dormant-mark)
7463 (= mark gnus-expirable-mark))))
7465 ;; Saving hidden threads.
7467 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
7468 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
7469 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
7471 (defmacro gnus-save-hidden-threads (&rest forms)
7472 "Save hidden threads, eval FORMS, and restore the hidden threads."
7473 (let ((config (make-symbol "config")))
7474 `(let ((,config (gnus-hidden-threads-configuration)))
7478 (gnus-restore-hidden-threads-configuration ,config)))))
7480 (defun gnus-hidden-threads-configuration ()
7481 "Return the current hidden threads configuration."
7484 (goto-char (point-min))
7485 (while (search-forward "\r" nil t)
7486 (push (1- (point)) config))
7489 (defun gnus-restore-hidden-threads-configuration (config)
7490 "Restore hidden threads configuration from CONFIG."
7491 (let (point buffer-read-only)
7492 (while (setq point (pop config))
7493 (when (and (< point (point-max))
7495 (= (following-char) ?\n))
7496 (subst-char-in-region point (1+ point) ?\n ?\r)))))
7498 ;; Various summary mode internalish functions.
7500 (defun gnus-mouse-pick-article (e)
7503 (gnus-summary-next-page nil t))
7505 (defun gnus-summary-setup-buffer (group)
7506 "Initialize summary buffer."
7507 (let ((buffer (concat "*Summary " group "*")))
7508 (if (get-buffer buffer)
7511 (setq gnus-summary-buffer (current-buffer))
7512 (not gnus-newsgroup-prepared))
7513 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7514 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7515 (gnus-add-current-to-buffer-list)
7516 (gnus-summary-mode group)
7518 (gnus-carpal-setup-buffer 'summary))
7519 (unless gnus-single-article-buffer
7520 (make-local-variable 'gnus-article-buffer)
7521 (make-local-variable 'gnus-article-current)
7522 (make-local-variable 'gnus-original-article-buffer))
7523 (setq gnus-newsgroup-name group)
7526 (defun gnus-set-global-variables ()
7527 ;; Set the global equivalents of the summary buffer-local variables
7528 ;; to the latest values they had. These reflect the summary buffer
7529 ;; that was in action when the last article was fetched.
7530 (when (eq major-mode 'gnus-summary-mode)
7531 (setq gnus-summary-buffer (current-buffer))
7532 (let ((name gnus-newsgroup-name)
7533 (marked gnus-newsgroup-marked)
7534 (unread gnus-newsgroup-unreads)
7535 (headers gnus-current-headers)
7536 (data gnus-newsgroup-data)
7537 (summary gnus-summary-buffer)
7538 (article-buffer gnus-article-buffer)
7539 (original gnus-original-article-buffer)
7540 (gac gnus-article-current)
7541 (score-file gnus-current-score-file))
7543 (set-buffer gnus-group-buffer)
7544 (setq gnus-newsgroup-name name)
7545 (setq gnus-newsgroup-marked marked)
7546 (setq gnus-newsgroup-unreads unread)
7547 (setq gnus-current-headers headers)
7548 (setq gnus-newsgroup-data data)
7549 (setq gnus-article-current gac)
7550 (setq gnus-summary-buffer summary)
7551 (setq gnus-article-buffer article-buffer)
7552 (setq gnus-original-article-buffer original)
7553 (setq gnus-current-score-file score-file)))))
7555 (defun gnus-summary-last-article-p (&optional article)
7556 "Return whether ARTICLE is the last article in the buffer."
7557 (if (not (setq article (or article (gnus-summary-article-number))))
7558 t ; All non-existant numbers are the last article. :-)
7559 (not (cdr (gnus-data-find-list article)))))
7561 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7562 "Insert a dummy root in the summary buffer."
7564 (gnus-add-text-properties
7565 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7566 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7568 (defun gnus-make-thread-indent-array ()
7570 (unless (and gnus-thread-indent-array
7571 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7572 (setq gnus-thread-indent-array (make-vector 201 "")
7573 gnus-thread-indent-array-level gnus-thread-indent-level)
7575 (aset gnus-thread-indent-array n
7576 (make-string (* n gnus-thread-indent-level) ? ))
7579 (defun gnus-summary-insert-line
7580 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7581 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7582 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7583 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7584 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7585 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7586 (gnus-tmp-score-char
7587 (if (or (null gnus-summary-default-score)
7588 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7589 gnus-summary-zcore-fuzz)) ?
7590 (if (< gnus-tmp-score gnus-summary-default-score)
7591 gnus-score-below-mark gnus-score-over-mark)))
7592 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7593 ((memq gnus-tmp-current gnus-newsgroup-cached)
7595 (gnus-tmp-replied gnus-replied-mark)
7596 ((memq gnus-tmp-current gnus-newsgroup-saved)
7598 (t gnus-unread-mark)))
7599 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7602 ((string-match "(.+)" gnus-tmp-from)
7603 (substring gnus-tmp-from
7604 (1+ (match-beginning 0)) (1- (match-end 0))))
7605 ((string-match "<[^>]+> *$" gnus-tmp-from)
7606 (let ((beg (match-beginning 0)))
7607 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7608 (substring gnus-tmp-from (1+ (match-beginning 0))
7609 (1- (match-end 0))))
7610 (substring gnus-tmp-from 0 beg))))
7612 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7613 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7614 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7615 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7616 (buffer-read-only nil))
7617 (when (string= gnus-tmp-name "")
7618 (setq gnus-tmp-name gnus-tmp-from))
7619 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7620 (gnus-put-text-property
7622 (progn (eval gnus-summary-line-format-spec) (point))
7623 'gnus-number gnus-tmp-number)
7624 (when (gnus-visual-p 'summary-highlight 'highlight)
7626 (run-hooks 'gnus-summary-update-hook)
7629 (defun gnus-summary-update-line (&optional dont-update)
7630 ;; Update summary line after change.
7631 (when (and gnus-summary-default-score
7632 (not gnus-summary-inhibit-highlight))
7633 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7634 (article (gnus-summary-article-number))
7635 (score (gnus-summary-article-score article)))
7637 (if (and gnus-summary-mark-below
7638 (< (gnus-summary-article-score)
7639 gnus-summary-mark-below))
7640 ;; This article has a low score, so we mark it as read.
7641 (when (memq article gnus-newsgroup-unreads)
7642 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7643 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7644 ;; This article was previously marked as read on account
7645 ;; of a low score, but now it has risen, so we mark it as
7647 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7648 (gnus-summary-update-mark
7649 (if (or (null gnus-summary-default-score)
7650 (<= (abs (- score gnus-summary-default-score))
7651 gnus-summary-zcore-fuzz)) ?
7652 (if (< score gnus-summary-default-score)
7653 gnus-score-below-mark gnus-score-over-mark)) 'score))
7654 ;; Do visual highlighting.
7655 (when (gnus-visual-p 'summary-highlight 'highlight)
7656 (run-hooks 'gnus-summary-update-hook)))))
7658 (defvar gnus-tmp-new-adopts nil)
7660 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7661 ;; Sum up all elements (and sub-elements) in a list.
7663 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7665 ((and (consp thread) (cdr thread))
7668 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7671 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7674 (when (and level (zerop level) gnus-tmp-new-adopts)
7677 'gnus-summary-number-of-articles-in-thread
7678 gnus-tmp-new-adopts))))
7680 (if (> number 1) gnus-not-empty-thread-mark
7681 gnus-empty-thread-mark)
7684 (defun gnus-summary-set-local-parameters (group)
7685 "Go through the local params of GROUP and set all variable specs in that list."
7686 (let ((params (gnus-info-params (gnus-get-info group)))
7689 (setq elem (car params)
7690 params (cdr params))
7691 (and (consp elem) ; Has to be a cons.
7692 (consp (cdr elem)) ; The cdr has to be a list.
7693 (symbolp (car elem)) ; Has to be a symbol in there.
7694 (not (memq (car elem)
7695 '(quit-config to-address to-list to-group)))
7696 (progn ; So we set it.
7697 (make-local-variable (car elem))
7698 (set (car elem) (eval (nth 1 elem))))))))
7700 (defun gnus-summary-read-group (group &optional show-all no-article
7701 kill-buffer no-display)
7702 "Start reading news in newsgroup GROUP.
7703 If SHOW-ALL is non-nil, already read articles are also listed.
7704 If NO-ARTICLE is non-nil, no article is selected initially.
7705 If NO-DISPLAY, don't generate a summary buffer."
7706 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7707 (let* ((new-group (gnus-summary-setup-buffer group))
7708 (quit-config (gnus-group-quit-config group))
7709 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7711 ;; This summary buffer exists already, so we just select it.
7713 (gnus-set-global-variables)
7715 (gnus-kill-or-deaden-summary kill-buffer))
7716 (gnus-configure-windows 'summary 'force)
7717 (gnus-set-mode-line 'summary)
7718 (gnus-summary-position-point)
7721 ;; We couldn't select this group.
7723 (when (and (eq major-mode 'gnus-summary-mode)
7724 (not (equal (current-buffer) kill-buffer)))
7725 (kill-buffer (current-buffer))
7726 (if (not quit-config)
7728 (set-buffer gnus-group-buffer)
7729 (gnus-group-jump-to-group group)
7730 (gnus-group-next-unread-group 1))
7731 (if (not (buffer-name (car quit-config)))
7732 (gnus-configure-windows 'group 'force)
7733 (set-buffer (car quit-config))
7734 (and (eq major-mode 'gnus-summary-mode)
7735 (gnus-set-global-variables))
7736 (gnus-configure-windows (cdr quit-config)))))
7737 (gnus-message 3 "Can't select group")
7739 ;; The user did a `C-g' while prompting for number of articles,
7740 ;; so we exit this group.
7741 ((eq did-select 'quit)
7742 (and (eq major-mode 'gnus-summary-mode)
7743 (not (equal (current-buffer) kill-buffer))
7744 (kill-buffer (current-buffer)))
7746 (gnus-kill-or-deaden-summary kill-buffer))
7747 (if (not quit-config)
7749 (set-buffer gnus-group-buffer)
7750 (gnus-group-jump-to-group group)
7751 (gnus-group-next-unread-group 1)
7752 (gnus-configure-windows 'group 'force))
7753 (if (not (buffer-name (car quit-config)))
7754 (gnus-configure-windows 'group 'force)
7755 (set-buffer (car quit-config))
7756 (and (eq major-mode 'gnus-summary-mode)
7757 (gnus-set-global-variables))
7758 (gnus-configure-windows (cdr quit-config))))
7759 ;; Finally signal the quit.
7761 ;; The group was successfully selected.
7763 (gnus-set-global-variables)
7764 ;; Save the active value in effect when the group was entered.
7765 (setq gnus-newsgroup-active
7767 (gnus-active gnus-newsgroup-name)))
7768 ;; You can change the summary buffer in some way with this hook.
7769 (run-hooks 'gnus-select-group-hook)
7770 ;; Set any local variables in the group parameters.
7771 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7772 (gnus-update-format-specifications)
7773 ;; Do score processing.
7774 (when gnus-use-scoring
7775 (gnus-possibly-score-headers))
7776 ;; Check whether to fill in the gaps in the threads.
7777 (when gnus-build-sparse-threads
7778 (gnus-build-sparse-threads))
7779 ;; Find the initial limit.
7780 (if gnus-show-threads
7782 (let ((gnus-newsgroup-dormant nil))
7783 (gnus-summary-initial-limit show-all))
7784 (gnus-summary-initial-limit show-all))
7785 (setq gnus-newsgroup-limit
7787 (lambda (header) (mail-header-number header))
7788 gnus-newsgroup-headers)))
7789 ;; Generate the summary buffer.
7791 (gnus-summary-prepare))
7792 (when gnus-use-trees
7793 (gnus-tree-open group)
7794 (setq gnus-summary-highlight-line-function
7795 'gnus-tree-highlight-article))
7796 ;; If the summary buffer is empty, but there are some low-scored
7797 ;; articles or some excluded dormants, we include these in the
7799 (when (and (zerop (buffer-size))
7801 (cond (gnus-newsgroup-dormant
7802 (gnus-summary-limit-include-dormant))
7803 ((and gnus-newsgroup-scored show-all)
7804 (gnus-summary-limit-include-expunged))))
7805 ;; Function `gnus-apply-kill-file' must be called in this hook.
7806 (run-hooks 'gnus-apply-kill-hook)
7807 (if (and (zerop (buffer-size))
7810 ;; This newsgroup is empty.
7811 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7812 (gnus-message 6 "No unread news")
7814 (gnus-kill-or-deaden-summary kill-buffer))
7815 ;; Return nil from this function.
7817 ;; Hide conversation thread subtrees. We cannot do this in
7818 ;; gnus-summary-prepare-hook since kill processing may not
7819 ;; work with hidden articles.
7820 (and gnus-show-threads
7821 gnus-thread-hide-subtree
7822 (gnus-summary-hide-all-threads))
7823 ;; Show first unread article if requested.
7824 (if (and (not no-article)
7826 gnus-newsgroup-unreads
7827 gnus-auto-select-first)
7828 (unless (if (eq gnus-auto-select-first 'best)
7829 (gnus-summary-best-unread-article)
7830 (gnus-summary-first-unread-article))
7831 (gnus-configure-windows 'summary))
7832 ;; Don't select any articles, just move point to the first
7833 ;; article in the group.
7834 (goto-char (point-min))
7835 (gnus-summary-position-point)
7836 (gnus-set-mode-line 'summary)
7837 (gnus-configure-windows 'summary 'force))
7838 ;; If we are in async mode, we send some info to the backend.
7839 (when gnus-newsgroup-async
7840 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7842 (gnus-kill-or-deaden-summary kill-buffer))
7843 (when (get-buffer-window gnus-group-buffer t)
7844 ;; Gotta use windows, because recenter does wierd stuff if
7845 ;; the current buffer ain't the displayed window.
7846 (let ((owin (selected-window)))
7847 (select-window (get-buffer-window gnus-group-buffer t))
7848 (when (gnus-group-goto-group group)
7850 (select-window owin))))
7851 ;; Mark this buffer as "prepared".
7852 (setq gnus-newsgroup-prepared t)
7855 (defun gnus-summary-prepare ()
7856 "Generate the summary buffer."
7857 (let ((buffer-read-only nil))
7859 (setq gnus-newsgroup-data nil
7860 gnus-newsgroup-data-reverse nil)
7861 (run-hooks 'gnus-summary-generate-hook)
7862 ;; Generate the buffer, either with threads or without.
7863 (when gnus-newsgroup-headers
7864 (gnus-summary-prepare-threads
7865 (if gnus-show-threads
7866 (gnus-sort-gathered-threads
7867 (funcall gnus-summary-thread-gathering-function
7869 (gnus-cut-threads (gnus-make-threads)))))
7870 ;; Unthreaded display.
7871 (gnus-sort-articles gnus-newsgroup-headers))))
7872 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7873 ;; Call hooks for modifying summary buffer.
7874 (goto-char (point-min))
7875 (run-hooks 'gnus-summary-prepare-hook)))
7877 (defun gnus-gather-threads-by-subject (threads)
7878 "Gather threads by looking at Subject headers."
7879 (if (not gnus-summary-make-false-root)
7881 (let ((hashtb (gnus-make-hashtable 1023))
7884 subject hthread whole-subject)
7886 (setq whole-subject (mail-header-subject (caar threads)))
7889 ;; Truncate the subject.
7890 ((numberp gnus-summary-gather-subject-limit)
7891 (setq subject (gnus-simplify-subject-re whole-subject))
7892 (if (> (length subject) gnus-summary-gather-subject-limit)
7893 (substring subject 0 gnus-summary-gather-subject-limit)
7895 ;; Fuzzily simplify it.
7896 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7897 (gnus-simplify-subject-fuzzy whole-subject))
7898 ;; Just remove the leading "Re:".
7900 (gnus-simplify-subject-re whole-subject))))
7902 (if (and gnus-summary-gather-exclude-subject
7903 (string-match gnus-summary-gather-exclude-subject
7905 () ; We don't want to do anything with this article.
7906 ;; We simplify the subject before looking it up in the
7909 (if (setq hthread (gnus-gethash subject hashtb))
7911 ;; We enter a dummy root into the thread, if we
7912 ;; haven't done that already.
7913 (unless (stringp (caar hthread))
7914 (setcar hthread (list whole-subject (car hthread))))
7915 ;; We add this new gathered thread to this gathered
7917 (setcdr (car hthread)
7918 (nconc (cdar hthread) (list (car threads))))
7919 ;; Remove it from the list of threads.
7920 (setcdr prev (cdr threads))
7921 (setq threads prev))
7922 ;; Enter this thread into the hash table.
7923 (gnus-sethash subject threads hashtb)))
7925 (setq threads (cdr threads)))
7928 (defun gnus-gather-threads-by-references (threads)
7929 "Gather threads by looking at References headers."
7930 (let ((idhashtb (gnus-make-hashtable 1023))
7931 (thhashtb (gnus-make-hashtable 1023))
7934 ids references id gthread gid entered)
7936 (when (setq references (mail-header-references (caar threads)))
7937 (setq id (mail-header-id (caar threads)))
7938 (setq ids (gnus-split-references references))
7941 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7943 (gnus-sethash (car ids) id idhashtb)
7944 (gnus-sethash id threads thhashtb))
7945 (setq gthread (gnus-gethash gid thhashtb))
7947 ;; We enter a dummy root into the thread, if we
7948 ;; haven't done that already.
7949 (unless (stringp (caar gthread))
7950 (setcar gthread (list (mail-header-subject (caar gthread))
7952 ;; We add this new gathered thread to this gathered
7954 (setcdr (car gthread)
7955 (nconc (cdar gthread) (list (car threads)))))
7956 ;; Add it into the thread hash table.
7957 (gnus-sethash id gthread thhashtb)
7959 ;; Remove it from the list of threads.
7960 (setcdr prev (cdr threads))
7961 (setq threads prev))
7962 (setq ids (cdr ids))))
7964 (setq threads (cdr threads)))
7967 (defun gnus-sort-gathered-threads (threads)
7968 "Sort subtreads inside each gathered thread by article number."
7969 (let ((result threads))
7971 (when (stringp (caar threads))
7972 (setcdr (car threads)
7973 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7974 (setq threads (cdr threads)))
7977 (defun gnus-make-threads ()
7978 "Go through the dependency hashtb and find the roots. Return all threads."
7982 (unless (car (symbol-value refs))
7983 ;; These threads do not refer back to any other articles,
7984 ;; so they're roots.
7985 (setq threads (append (cdr (symbol-value refs)) threads))))
7986 gnus-newsgroup-dependencies)
7989 (defun gnus-build-sparse-threads ()
7990 (let ((headers gnus-newsgroup-headers)
7991 (deps gnus-newsgroup-dependencies)
7992 header references generation relations
7993 cthread subject child end pthread relation)
7994 ;; First we create an alist of generations/relations, where
7995 ;; generations is how much we trust the ralation, and the relation
7997 (gnus-message 7 "Making sparse threads...")
7999 (nnheader-set-temp-buffer " *gnus sparse threads*")
8000 (while (setq header (pop headers))
8001 (when (and (setq references (mail-header-references header))
8002 (not (string= references "")))
8004 (setq child (mail-header-id header)
8005 subject (mail-header-subject header))
8007 (while (search-backward ">" nil t)
8008 (setq end (1+ (point)))
8009 (when (search-backward "<" nil t)
8010 (push (list (incf generation)
8011 child (setq child (buffer-substring (point) end))
8014 (push (list (1+ generation) child nil subject) relations)
8016 (kill-buffer (current-buffer)))
8017 ;; Sort over trustworthiness.
8018 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
8019 (while (setq relation (pop relations))
8020 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
8021 (unless (car (symbol-value cthread))
8022 ;; Make this article the parent of these threads.
8023 (setcar (symbol-value cthread)
8024 (vector gnus-reffed-article-number
8028 (or (caddr relation) "") 0 0 "")))
8029 (set cthread (list (vector gnus-reffed-article-number
8031 "" "" (cadr relation)
8032 (or (caddr relation) "") 0 0 ""))))
8033 (push gnus-reffed-article-number gnus-newsgroup-limit)
8034 (push gnus-reffed-article-number gnus-newsgroup-sparse)
8035 (push (cons gnus-reffed-article-number gnus-sparse-mark)
8036 gnus-newsgroup-reads)
8037 (decf gnus-reffed-article-number)
8038 ;; Make this new thread the child of its parent.
8039 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
8040 (setcdr (symbol-value pthread)
8041 (nconc (cdr (symbol-value pthread))
8042 (list (symbol-value cthread))))
8043 (set pthread (list nil (symbol-value cthread))))))
8044 (gnus-message 7 "Making sparse threads...done")))
8046 (defun gnus-build-old-threads ()
8047 ;; Look at all the articles that refer back to old articles, and
8048 ;; fetch the headers for the articles that aren't there. This will
8049 ;; build complete threads - if the roots haven't been expired by the
8054 (when (not (car (symbol-value refs)))
8055 (setq heads (cdr (symbol-value refs)))
8057 (if (memq (mail-header-number (caar heads))
8058 gnus-newsgroup-dormant)
8059 (setq heads (cdr heads))
8060 (setq id (symbol-name refs))
8061 (while (and (setq id (gnus-build-get-header id))
8062 (not (car (gnus-gethash
8063 id gnus-newsgroup-dependencies)))))
8064 (setq heads nil)))))
8065 gnus-newsgroup-dependencies)))
8067 (defun gnus-build-get-header (id)
8068 ;; Look through the buffer of NOV lines and find the header to
8069 ;; ID. Enter this line into the dependencies hash table, and return
8070 ;; the id of the parent article (if any).
8071 (let ((deps gnus-newsgroup-dependencies)
8075 (set-buffer nntp-server-buffer)
8076 (goto-char (point-min))
8077 (while (and (not found) (search-forward id nil t))
8079 (setq found (looking-at
8080 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
8081 (regexp-quote id))))
8082 (or found (beginning-of-line 2)))
8086 (setq header (gnus-nov-parse-line
8087 (read (current-buffer)) deps))
8088 (gnus-parent-id (mail-header-references header)))))
8090 (let ((number (mail-header-number header)))
8091 (push number gnus-newsgroup-limit)
8092 (push header gnus-newsgroup-headers)
8093 (if (memq number gnus-newsgroup-unselected)
8095 (push number gnus-newsgroup-unreads)
8096 (setq gnus-newsgroup-unselected
8097 (delq number gnus-newsgroup-unselected)))
8098 (push number gnus-newsgroup-ancient)))))))
8100 (defun gnus-summary-update-article (article &optional iheader)
8101 "Update ARTICLE in the summary buffer."
8102 (set-buffer gnus-summary-buffer)
8103 (let* ((header (or iheader (gnus-summary-article-header article)))
8104 (id (mail-header-id header))
8105 (data (gnus-data-find article))
8106 (thread (gnus-id-to-thread id))
8107 (references (mail-header-references header))
8112 (not (equal "" references)))
8115 (buffer-read-only nil)
8117 (number (mail-header-number header))
8120 ;; !!! Should this be in or not?
8122 (setcar thread nil))
8124 (delq thread parent))
8125 (if (gnus-summary-insert-subject id header iheader)
8126 ;; Set the (possibly) new article number in the data structure.
8127 (gnus-data-set-number data (gnus-id-to-article id))
8131 (defun gnus-rebuild-thread (id)
8132 "Rebuild the thread containing ID."
8133 (let ((buffer-read-only nil)
8134 current thread data)
8135 (if (not gnus-show-threads)
8136 (setq thread (list (car (gnus-id-to-thread id))))
8137 ;; Get the thread this article is part of.
8138 (setq thread (gnus-remove-thread id)))
8139 (setq current (save-excursion
8140 (and (zerop (forward-line -1))
8141 (gnus-summary-article-number))))
8142 ;; If this is a gathered thread, we have to go some re-gathering.
8143 (when (stringp (car thread))
8144 (let ((subject (car thread))
8146 (setq thread (cdr thread))
8148 (unless (memq (setq thr (gnus-id-to-thread
8150 (mail-header-id (caar thread)))))
8153 (setq thread (cdr thread)))
8154 ;; We now have all (unique) roots.
8155 (if (= (length roots) 1)
8156 ;; All the loose roots are now one solid root.
8157 (setq thread (car roots))
8158 (setq thread (cons subject (gnus-sort-threads roots))))))
8160 ;; We then insert this thread into the summary buffer.
8161 (let (gnus-newsgroup-data gnus-newsgroup-threads)
8162 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
8163 (setq data (nreverse gnus-newsgroup-data))
8164 (setq threads gnus-newsgroup-threads))
8165 ;; We splice the new data into the data structure.
8166 (gnus-data-enter-list current data)
8167 (gnus-data-compute-positions)
8168 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
8170 (defun gnus-number-to-header (number)
8171 "Return the header for article NUMBER."
8172 (let ((headers gnus-newsgroup-headers))
8174 (not (= number (mail-header-number (car headers)))))
8179 (defun gnus-id-to-thread (id)
8180 "Return the (sub-)thread where ID appears."
8181 (gnus-gethash id gnus-newsgroup-dependencies))
8183 (defun gnus-id-to-article (id)
8184 "Return the article number of ID."
8185 (let ((thread (gnus-id-to-thread id)))
8188 (mail-header-number (car thread)))))
8190 (defun gnus-id-to-header (id)
8191 "Return the article headers of ID."
8192 (car (gnus-id-to-thread id)))
8194 (defun gnus-article-displayed-root-p (article)
8195 "Say whether ARTICLE is a root(ish) article."
8196 (let ((level (gnus-summary-thread-level article))
8197 (refs (mail-header-references (gnus-summary-article-header article)))
8203 ((null (gnus-parent-id refs)) t)
8205 (null (setq particle (gnus-id-to-article
8206 (gnus-parent-id refs))))
8207 (null (gnus-summary-thread-level particle)))))))
8209 (defun gnus-root-id (id)
8210 "Return the id of the root of the thread where ID appears."
8212 (while (and id (setq prev (car (gnus-gethash
8213 id gnus-newsgroup-dependencies))))
8215 id (gnus-parent-id (mail-header-references prev))))
8218 (defun gnus-remove-thread (id &optional dont-remove)
8219 "Remove the thread that has ID in it."
8220 (let ((dep gnus-newsgroup-dependencies)
8221 headers thread last-id)
8222 ;; First go up in this thread until we find the root.
8223 (setq last-id (gnus-root-id id))
8224 (setq headers (list (car (gnus-id-to-thread last-id))
8225 (caadr (gnus-id-to-thread last-id))))
8226 ;; We have now found the real root of this thread. It might have
8227 ;; been gathered into some loose thread, so we have to search
8228 ;; through the threads to find the thread we wanted.
8229 (let ((threads gnus-newsgroup-threads)
8232 (setq sub (car threads))
8233 (if (stringp (car sub))
8234 ;; This is a gathered threads, so we look at the roots
8235 ;; below it to find whether this article in in this
8238 (setq sub (cdr sub))
8240 (when (member (caar sub) headers)
8241 (setq thread (car threads)
8244 (setq sub (cdr sub))))
8245 ;; It's an ordinary thread, so we check it.
8246 (when (eq (car sub) (car headers))
8249 (setq threads (cdr threads)))
8250 ;; If this article is in no thread, then it's a root.
8253 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8254 (setq thread (gnus-gethash last-id dep)))
8257 thread ; We return this thread.
8259 (if (stringp (car thread))
8261 ;; If we use dummy roots, then we have to remove the
8262 ;; dummy root as well.
8263 (when (eq gnus-summary-make-false-root 'dummy)
8266 (setq thread (cdr thread))
8268 (gnus-remove-thread-1 (car thread))
8269 (setq thread (cdr thread))))
8270 (gnus-remove-thread-1 thread))))))))
8272 (defun gnus-remove-thread-1 (thread)
8273 "Remove the thread THREAD recursively."
8274 (let ((number (mail-header-number (car thread)))
8276 (when (setq pos (text-property-any
8277 (point-min) (point-max) 'gnus-number number))
8280 (gnus-data-remove number))
8281 (setq thread (cdr thread))
8283 (gnus-remove-thread-1 (pop thread)))))
8285 (defun gnus-sort-threads (threads)
8287 (if (not gnus-thread-sort-functions)
8289 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8290 (car gnus-thread-sort-functions)
8292 ,(gnus-make-sort-function
8293 (reverse gnus-thread-sort-functions))))))
8294 (gnus-message 7 "Sorting threads...")
8297 (gnus-message 7 "Sorting threads...done")))))
8299 (defun gnus-sort-articles (articles)
8301 (when gnus-article-sort-functions
8302 (let ((func (if (= 1 (length gnus-article-sort-functions))
8303 (car gnus-article-sort-functions)
8305 ,(gnus-make-sort-function
8306 (reverse gnus-article-sort-functions))))))
8307 (gnus-message 7 "Sorting articles...")
8309 (setq gnus-newsgroup-headers (sort articles func))
8310 (gnus-message 7 "Sorting articles...done")))))
8312 (defun gnus-make-sort-function (funs)
8313 "Return a composite sort condition based on the functions in FUNC."
8315 `(or (,(car funs) t1 t2)
8316 (and (not (,(car funs) t2 t1))
8317 ,(gnus-make-sort-function (cdr funs))))
8318 `(,(car funs) t1 t2)))
8320 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8321 (defmacro gnus-thread-header (thread)
8322 ;; Return header of first article in THREAD.
8323 ;; Note that THREAD must never, ever be anything else than a variable -
8324 ;; using some other form will lead to serious barfage.
8325 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8326 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8327 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8330 (defsubst gnus-article-sort-by-number (h1 h2)
8331 "Sort articles by article number."
8332 (< (mail-header-number h1)
8333 (mail-header-number h2)))
8335 (defun gnus-thread-sort-by-number (h1 h2)
8336 "Sort threads by root article number."
8337 (gnus-article-sort-by-number
8338 (gnus-thread-header h1) (gnus-thread-header h2)))
8340 (defsubst gnus-article-sort-by-author (h1 h2)
8341 "Sort articles by root author."
8343 (let ((extract (funcall
8344 gnus-extract-address-components
8345 (mail-header-from h1))))
8346 (or (car extract) (cdr extract)))
8347 (let ((extract (funcall
8348 gnus-extract-address-components
8349 (mail-header-from h2))))
8350 (or (car extract) (cdr extract)))))
8352 (defun gnus-thread-sort-by-author (h1 h2)
8353 "Sort threads by root author."
8354 (gnus-article-sort-by-author
8355 (gnus-thread-header h1) (gnus-thread-header h2)))
8357 (defsubst gnus-article-sort-by-subject (h1 h2)
8358 "Sort articles by root subject."
8360 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8361 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8363 (defun gnus-thread-sort-by-subject (h1 h2)
8364 "Sort threads by root subject."
8365 (gnus-article-sort-by-subject
8366 (gnus-thread-header h1) (gnus-thread-header h2)))
8368 (defsubst gnus-article-sort-by-date (h1 h2)
8369 "Sort articles by root article date."
8371 (inline (gnus-sortable-date (mail-header-date h1)))
8372 (inline (gnus-sortable-date (mail-header-date h2)))))
8374 (defun gnus-thread-sort-by-date (h1 h2)
8375 "Sort threads by root article date."
8376 (gnus-article-sort-by-date
8377 (gnus-thread-header h1) (gnus-thread-header h2)))
8379 (defsubst gnus-article-sort-by-score (h1 h2)
8380 "Sort articles by root article score.
8381 Unscored articles will be counted as having a score of zero."
8382 (> (or (cdr (assq (mail-header-number h1)
8383 gnus-newsgroup-scored))
8384 gnus-summary-default-score 0)
8385 (or (cdr (assq (mail-header-number h2)
8386 gnus-newsgroup-scored))
8387 gnus-summary-default-score 0)))
8389 (defun gnus-thread-sort-by-score (h1 h2)
8390 "Sort threads by root article score."
8391 (gnus-article-sort-by-score
8392 (gnus-thread-header h1) (gnus-thread-header h2)))
8394 (defun gnus-thread-sort-by-total-score (h1 h2)
8395 "Sort threads by the sum of all scores in the thread.
8396 Unscored articles will be counted as having a score of zero."
8397 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8399 (defun gnus-thread-total-score (thread)
8400 ;; This function find the total score of THREAD.
8401 (cond ((null thread)
8404 (if (stringp (car thread))
8405 (apply gnus-thread-score-function 0
8406 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8407 (gnus-thread-total-score-1 thread)))
8409 (gnus-thread-total-score-1 (list thread)))))
8411 (defun gnus-thread-total-score-1 (root)
8412 ;; This function find the total score of the thread below ROOT.
8413 (setq root (car root))
8414 (apply gnus-thread-score-function
8415 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8416 gnus-summary-default-score 0)
8417 (mapcar 'gnus-thread-total-score
8418 (cdr (gnus-gethash (mail-header-id root)
8419 gnus-newsgroup-dependencies)))))
8421 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8422 (defvar gnus-tmp-prev-subject nil)
8423 (defvar gnus-tmp-false-parent nil)
8424 (defvar gnus-tmp-root-expunged nil)
8425 (defvar gnus-tmp-dummy-line nil)
8427 (defun gnus-summary-prepare-threads (threads)
8428 "Prepare summary buffer from THREADS and indentation LEVEL.
8429 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8430 or a straight list of headers."
8431 (gnus-message 7 "Generating summary...")
8433 (setq gnus-newsgroup-threads threads)
8436 (let ((gnus-tmp-level 0)
8437 (default-score (or gnus-summary-default-score 0))
8438 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8439 thread number subject stack state gnus-tmp-gathered beg-match
8440 new-roots gnus-tmp-new-adopts thread-end
8441 gnus-tmp-header gnus-tmp-unread
8442 gnus-tmp-replied gnus-tmp-subject-or-nil
8443 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8444 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8445 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8447 (setq gnus-tmp-prev-subject nil)
8449 (if (vectorp (car threads))
8450 ;; If this is a straight (sic) list of headers, then a
8451 ;; threaded summary display isn't required, so we just create
8452 ;; an unthreaded one.
8453 (gnus-summary-prepare-unthreaded threads)
8455 ;; Do the threaded display.
8457 (while (or threads stack gnus-tmp-new-adopts new-roots)
8459 (if (and (= gnus-tmp-level 0)
8460 (not (setq gnus-tmp-dummy-line nil))
8463 (not gnus-tmp-false-parent)
8464 (or gnus-tmp-new-adopts new-roots))
8465 (if gnus-tmp-new-adopts
8466 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8467 thread (list (car gnus-tmp-new-adopts))
8468 gnus-tmp-header (caar thread)
8469 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8471 (setq thread (list (car new-roots))
8472 gnus-tmp-header (caar thread)
8473 new-roots (cdr new-roots))))
8476 ;; If there are some threads, we do them before the
8477 ;; threads on the stack.
8478 (setq thread threads
8479 gnus-tmp-header (caar thread))
8480 ;; There were no current threads, so we pop something off
8482 (setq state (car stack)
8483 gnus-tmp-level (car state)
8486 gnus-tmp-header (caar thread))))
8488 (setq gnus-tmp-false-parent nil)
8489 (setq gnus-tmp-root-expunged nil)
8490 (setq thread-end nil)
8492 (if (stringp gnus-tmp-header)
8493 ;; The header is a dummy root.
8495 ((eq gnus-summary-make-false-root 'adopt)
8496 ;; We let the first article adopt the rest.
8497 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8499 (setq gnus-tmp-gathered
8501 (lambda (h) (mail-header-number (car h)))
8504 (setq thread (cons (list (caar thread)
8507 (setq gnus-tmp-level -1
8508 gnus-tmp-false-parent t))
8509 ((eq gnus-summary-make-false-root 'empty)
8510 ;; We print adopted articles with empty subject fields.
8511 (setq gnus-tmp-gathered
8513 (lambda (h) (mail-header-number (car h)))
8516 (setq gnus-tmp-level -1))
8517 ((eq gnus-summary-make-false-root 'dummy)
8518 ;; We remember that we probably want to output a dummy
8520 (setq gnus-tmp-dummy-line gnus-tmp-header)
8521 (setq gnus-tmp-prev-subject gnus-tmp-header))
8523 ;; We do not make a root for the gathered
8524 ;; sub-threads at all.
8525 (setq gnus-tmp-level -1)))
8527 (setq number (mail-header-number gnus-tmp-header)
8528 subject (mail-header-subject gnus-tmp-header))
8531 ;; If the thread has changed subject, we might want to make
8532 ;; this subthread into a root.
8533 ((and (null gnus-thread-ignore-subject)
8534 (not (zerop gnus-tmp-level))
8535 gnus-tmp-prev-subject
8537 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8538 (setq new-roots (nconc new-roots (list (car thread)))
8540 gnus-tmp-header nil))
8541 ;; If the article lies outside the current limit,
8542 ;; then we do not display it.
8543 ((and (not (memq number gnus-newsgroup-limit))
8544 (not gnus-tmp-dummy-line))
8545 (setq gnus-tmp-gathered
8547 (lambda (h) (mail-header-number (car h)))
8550 (setq gnus-tmp-new-adopts (if (cdar thread)
8551 (append gnus-tmp-new-adopts
8553 gnus-tmp-new-adopts)
8555 gnus-tmp-header nil)
8556 (when (zerop gnus-tmp-level)
8557 (setq gnus-tmp-root-expunged t)))
8558 ;; Perhaps this article is to be marked as read?
8559 ((and gnus-summary-mark-below
8560 (< (or (cdr (assq number gnus-newsgroup-scored))
8562 gnus-summary-mark-below)
8563 ;; Don't touch sparse articles.
8564 (not (memq number gnus-newsgroup-sparse))
8565 (not (memq number gnus-newsgroup-ancient)))
8566 (setq gnus-newsgroup-unreads
8567 (delq number gnus-newsgroup-unreads))
8568 (if gnus-newsgroup-auto-expire
8569 (push number gnus-newsgroup-expirable)
8570 (push (cons number gnus-low-score-mark)
8571 gnus-newsgroup-reads))))
8573 (when gnus-tmp-header
8574 ;; We may have an old dummy line to output before this
8576 (when gnus-tmp-dummy-line
8577 (gnus-summary-insert-dummy-line
8578 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8579 (setq gnus-tmp-dummy-line nil))
8581 ;; Compute the mark.
8585 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8586 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8587 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8588 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8589 (t (or (cdr (assq number gnus-newsgroup-reads))
8590 gnus-ancient-mark))))
8592 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8593 gnus-tmp-header gnus-tmp-level)
8594 gnus-newsgroup-data)
8596 ;; Actually insert the line.
8598 gnus-tmp-subject-or-nil
8600 ((and gnus-thread-ignore-subject
8601 gnus-tmp-prev-subject
8602 (not (inline (gnus-subject-equal
8603 gnus-tmp-prev-subject subject))))
8605 ((zerop gnus-tmp-level)
8606 (if (and (eq gnus-summary-make-false-root 'empty)
8607 (memq number gnus-tmp-gathered)
8608 gnus-tmp-prev-subject
8609 (inline (gnus-subject-equal
8610 gnus-tmp-prev-subject subject)))
8611 gnus-summary-same-subject
8613 (t gnus-summary-same-subject)))
8614 (if (and (eq gnus-summary-make-false-root 'adopt)
8615 (= gnus-tmp-level 1)
8616 (memq number gnus-tmp-gathered))
8617 (setq gnus-tmp-opening-bracket ?\<
8618 gnus-tmp-closing-bracket ?\>)
8619 (setq gnus-tmp-opening-bracket ?\[
8620 gnus-tmp-closing-bracket ?\]))
8622 gnus-tmp-indentation
8623 (aref gnus-thread-indent-array gnus-tmp-level)
8624 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8625 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8626 gnus-summary-default-score 0)
8628 (if (or (null gnus-summary-default-score)
8629 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8630 gnus-summary-zcore-fuzz)) ?
8631 (if (< gnus-tmp-score gnus-summary-default-score)
8632 gnus-score-below-mark gnus-score-over-mark))
8634 (cond ((memq number gnus-newsgroup-processable)
8636 ((memq number gnus-newsgroup-cached)
8638 ((memq number gnus-newsgroup-replied)
8640 (t gnus-unread-mark))
8641 gnus-tmp-from (mail-header-from gnus-tmp-header)
8644 ((string-match "(.+)" gnus-tmp-from)
8645 (substring gnus-tmp-from
8646 (1+ (match-beginning 0)) (1- (match-end 0))))
8647 ((string-match "<[^>]+> *$" gnus-tmp-from)
8648 (setq beg-match (match-beginning 0))
8649 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8650 (substring gnus-tmp-from (1+ (match-beginning 0))
8651 (1- (match-end 0))))
8652 (substring gnus-tmp-from 0 beg-match)))
8654 (when (string= gnus-tmp-name "")
8655 (setq gnus-tmp-name gnus-tmp-from))
8656 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8657 (gnus-put-text-property
8659 (progn (eval gnus-summary-line-format-spec) (point))
8660 'gnus-number number)
8663 (run-hooks 'gnus-summary-update-hook)
8666 (setq gnus-tmp-prev-subject subject)))
8668 (when (nth 1 thread)
8669 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8670 (incf gnus-tmp-level)
8671 (setq threads (if thread-end nil (cdar thread)))
8673 (setq gnus-tmp-level 0)))))
8674 (gnus-message 7 "Generating summary...done"))
8676 (defun gnus-summary-prepare-unthreaded (headers)
8677 "Generate an unthreaded summary buffer based on HEADERS."
8678 (let (header number mark)
8681 ;; We may have to root out some bad articles...
8682 (when (memq (setq number (mail-header-number
8683 (setq header (pop headers))))
8684 gnus-newsgroup-limit)
8685 ;; Mark article as read when it has a low score.
8686 (when (and gnus-summary-mark-below
8687 (< (or (cdr (assq number gnus-newsgroup-scored))
8688 gnus-summary-default-score 0)
8689 gnus-summary-mark-below)
8690 (not (memq number gnus-newsgroup-ancient)))
8691 (setq gnus-newsgroup-unreads
8692 (delq number gnus-newsgroup-unreads))
8693 (if gnus-newsgroup-auto-expire
8694 (push number gnus-newsgroup-expirable)
8695 (push (cons number gnus-low-score-mark)
8696 gnus-newsgroup-reads)))
8700 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8701 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8702 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8703 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8704 (t (or (cdr (assq number gnus-newsgroup-reads))
8705 gnus-ancient-mark))))
8706 (setq gnus-newsgroup-data
8707 (cons (gnus-data-make number mark (1+ (point)) header 0)
8708 gnus-newsgroup-data))
8709 (gnus-summary-insert-line
8710 header 0 nil mark (memq number gnus-newsgroup-replied)
8711 (memq number gnus-newsgroup-expirable)
8712 (mail-header-subject header) nil
8713 (cdr (assq number gnus-newsgroup-scored))
8714 (memq number gnus-newsgroup-processable))))))
8716 (defun gnus-select-newsgroup (group &optional read-all)
8717 "Select newsgroup GROUP.
8718 If READ-ALL is non-nil, all articles in the group are selected."
8719 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8720 (info (nth 2 entry))
8721 articles fetched-articles cached)
8723 (or (gnus-check-server
8724 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8725 (error "Couldn't open server"))
8727 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8728 (gnus-activate-group group) ; Or we can activate it...
8729 (progn ; Or we bug out.
8730 (when (equal major-mode 'gnus-summary-mode)
8731 (kill-buffer (current-buffer)))
8732 (error "Couldn't request group %s: %s"
8733 group (gnus-status-message group))))
8735 (unless (gnus-request-group group t)
8736 (when (equal major-mode 'gnus-summary-mode)
8737 (kill-buffer (current-buffer)))
8738 (error "Couldn't request group %s: %s"
8739 group (gnus-status-message group)))
8741 (setq gnus-newsgroup-name group)
8742 (setq gnus-newsgroup-unselected nil)
8743 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8745 (and gnus-asynchronous
8746 (gnus-check-backend-function
8747 'request-asynchronous gnus-newsgroup-name)
8748 (setq gnus-newsgroup-async
8749 (gnus-request-asynchronous gnus-newsgroup-name)))
8751 ;; Adjust and set lists of article marks.
8753 (gnus-adjust-marked-articles info))
8755 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8756 (when (gnus-virtual-group-p group)
8757 (setq cached gnus-newsgroup-cached))
8759 (setq gnus-newsgroup-unreads
8760 (gnus-set-difference
8761 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8762 gnus-newsgroup-dormant))
8764 (setq gnus-newsgroup-processable nil)
8766 (setq articles (gnus-articles-to-read group read-all))
8770 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8772 ((eq articles 0) nil)
8774 ;; Init the dependencies hash table.
8775 (setq gnus-newsgroup-dependencies
8776 (gnus-make-hashtable (length articles)))
8777 ;; Retrieve the headers and read them in.
8778 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8779 (setq gnus-newsgroup-headers
8781 (setq gnus-headers-retrieved-by
8782 (gnus-retrieve-headers
8783 articles gnus-newsgroup-name
8784 ;; We might want to fetch old headers, but
8785 ;; not if there is only 1 article.
8786 (and gnus-fetch-old-headers
8788 (not (eq gnus-fetch-old-headers 'some))
8789 (not (numberp gnus-fetch-old-headers)))
8790 (> (length articles) 1))))))
8791 (gnus-get-newsgroup-headers-xover articles)
8792 (gnus-get-newsgroup-headers)))
8793 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8795 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8797 (setq gnus-newsgroup-cached cached))
8799 ;; Set the initial limit.
8800 (setq gnus-newsgroup-limit (copy-sequence articles))
8801 ;; Remove canceled articles from the list of unread articles.
8802 (setq gnus-newsgroup-unreads
8803 (gnus-set-sorted-intersection
8804 gnus-newsgroup-unreads
8805 (setq fetched-articles
8806 (mapcar (lambda (headers) (mail-header-number headers))
8807 gnus-newsgroup-headers))))
8808 ;; Removed marked articles that do not exist.
8809 (gnus-update-missing-marks
8810 (gnus-sorted-complement fetched-articles articles))
8811 ;; We might want to build some more threads first.
8812 (and gnus-fetch-old-headers
8813 (eq gnus-headers-retrieved-by 'nov)
8814 (gnus-build-old-threads))
8815 ;; Check whether auto-expire is to be done in this group.
8816 (setq gnus-newsgroup-auto-expire
8817 (gnus-group-auto-expirable-p group))
8818 ;; Set up the article buffer now, if necessary.
8819 (unless gnus-single-article-buffer
8820 (gnus-article-setup-buffer))
8821 ;; First and last article in this newsgroup.
8822 (when gnus-newsgroup-headers
8823 (setq gnus-newsgroup-begin
8824 (mail-header-number (car gnus-newsgroup-headers))
8827 (gnus-last-element gnus-newsgroup-headers))))
8828 (setq gnus-reffed-article-number -1)
8829 ;; GROUP is successfully selected.
8830 (or gnus-newsgroup-headers t)))))
8832 (defun gnus-articles-to-read (group read-all)
8833 ;; Find out what articles the user wants to read.
8835 ;; Select all articles if `read-all' is non-nil, or if there
8836 ;; are no unread articles.
8838 (and (zerop (length gnus-newsgroup-marked))
8839 (zerop (length gnus-newsgroup-unreads))))
8840 (gnus-uncompress-range (gnus-active group))
8841 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8842 (copy-sequence gnus-newsgroup-unreads))
8844 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8845 (scored (length scored-list))
8846 (number (length articles))
8847 (marked (+ (length gnus-newsgroup-marked)
8848 (length gnus-newsgroup-dormant)))
8856 ((and (or (<= scored marked) (= scored number))
8857 (numberp gnus-large-newsgroup)
8858 (> number gnus-large-newsgroup))
8862 "How many articles from %s (default %d): "
8863 gnus-newsgroup-name number))))
8864 (if (string-match "^[ \t]*$" input) number input)))
8865 ((and (> scored marked) (< scored number)
8866 (> (- scored number) 20))
8869 (format "%s %s (%d scored, %d total): "
8870 "How many articles from"
8871 group scored number))))
8872 (if (string-match "^[ \t]*$" input)
8876 (setq select (if (stringp select) (string-to-number select) select))
8877 (if (or (null select) (zerop select))
8879 (if (and (not (zerop scored)) (<= (abs select) scored))
8881 (setq articles (sort scored-list '<))
8882 (setq number (length articles)))
8883 (setq articles (copy-sequence articles)))
8885 (if (< (abs select) number)
8887 ;; Select the N oldest articles.
8888 (setcdr (nthcdr (1- (abs select)) articles) nil)
8889 ;; Select the N most recent articles.
8890 (setq articles (nthcdr (- number select) articles))))
8891 (setq gnus-newsgroup-unselected
8892 (gnus-sorted-intersection
8893 gnus-newsgroup-unreads
8894 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8897 (defun gnus-killed-articles (killed articles)
8900 (if (inline (gnus-member-of-range (car articles) killed))
8901 (setq out (cons (car articles) out)))
8902 (setq articles (cdr articles)))
8905 (defun gnus-uncompress-marks (marks)
8906 "Uncompress the mark ranges in MARKS."
8907 (let ((uncompressed '(score bookmark))
8910 (if (memq (caar marks) uncompressed)
8911 (push (car marks) out)
8912 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8913 (setq marks (cdr marks)))
8916 (defun gnus-adjust-marked-articles (info)
8917 "Set all article lists and remove all marks that are no longer legal."
8918 (let* ((marked-lists (gnus-info-marks info))
8919 (active (gnus-active (gnus-info-group info)))
8922 (types gnus-article-mark-lists)
8923 (uncompressed '(score bookmark))
8924 marks var articles article mark)
8927 (setq marks (pop marked-lists))
8928 (set (setq var (intern (format "gnus-newsgroup-%s"
8929 (car (rassq (setq mark (car marks))
8931 (if (memq (car marks) uncompressed) (cdr marks)
8932 (gnus-uncompress-range (cdr marks))))
8934 (setq articles (symbol-value var))
8936 ;; All articles have to be subsets of the active articles.
8938 ;; Adjust "simple" lists.
8939 ((memq mark '(tick dormant expirable reply killed save))
8941 (when (or (< (setq article (pop articles)) min) (> article max))
8942 (set var (delq article (symbol-value var))))))
8944 ((memq mark '(score bookmark))
8946 (when (or (< (car (setq article (pop articles))) min)
8947 (> (car article) max))
8948 (set var (delq article (symbol-value var))))))))))
8950 (defun gnus-update-missing-marks (missing)
8951 "Go through the list of MISSING articles and remove them mark lists."
8953 (let ((types gnus-article-mark-lists)
8955 ;; Go through all types.
8957 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8958 (when (symbol-value var)
8959 ;; This list has articles. So we delete all missing articles
8963 (set var (delq (pop m) (symbol-value var)))))))))
8965 (defun gnus-update-marks ()
8966 "Enter the various lists of marked articles into the newsgroup info list."
8967 (let ((types gnus-article-mark-lists)
8968 (info (gnus-get-info gnus-newsgroup-name))
8969 (uncompressed '(score bookmark killed))
8970 type list newmarked symbol)
8972 ;; Add all marks lists that are non-nil to the list of marks lists.
8974 (setq type (pop types))
8975 (when (setq list (symbol-value
8977 (intern (format "gnus-newsgroup-%s"
8979 (push (cons (cdr type)
8980 (if (memq (cdr type) uncompressed) list
8981 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8984 ;; Enter these new marks into the info of the group.
8986 (setcar (nthcdr 3 info) newmarked)
8987 ;; Add the marks lists to the end of the info.
8989 (setcdr (nthcdr 2 info) (list newmarked))))
8991 ;; Cut off the end of the info if there's nothing else there.
8995 (when (nthcdr (decf i) info)
8996 (setcdr (nthcdr i info) nil)))))))
8998 (defun gnus-add-marked-articles (group type articles &optional info force)
8999 ;; Add ARTICLES of TYPE to the info of GROUP.
9000 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
9001 ;; add, but replace marked articles of TYPE with ARTICLES.
9002 (let ((info (or info (gnus-get-info group)))
9003 (uncompressed '(score bookmark killed))
9006 (and (not (setq marked (nthcdr 3 info)))
9008 (setcdr (nthcdr 2 info)
9009 (list (list (cons type (gnus-compress-sequence
9011 (and (not (setq m (assq type (car marked))))
9014 (cons (cons type (gnus-compress-sequence articles t) )
9018 (setcar (nthcdr 3 info)
9019 (delq (assq type (car marked)) (car marked)))
9020 (setcdr m (gnus-compress-sequence articles t)))
9021 (setcdr m (gnus-compress-sequence
9022 (sort (nconc (gnus-uncompress-range (cdr m))
9023 (copy-sequence articles)) '<) t))))))
9025 (defun gnus-set-mode-line (where)
9026 "This function sets the mode line of the article or summary buffers.
9027 If WHERE is `summary', the summary mode line format will be used."
9028 ;; Is this mode line one we keep updated?
9029 (when (memq where gnus-updated-mode-lines)
9032 ;; We evaluate this in the summary buffer since these
9033 ;; variables are buffer-local to that buffer.
9034 (set-buffer gnus-summary-buffer)
9035 ;; We bind all these variables that are used in the `eval' form
9037 (let* ((mformat (symbol-value
9039 (format "gnus-%s-mode-line-format-spec" where))))
9040 (gnus-tmp-group-name gnus-newsgroup-name)
9041 (gnus-tmp-article-number (or gnus-current-article 0))
9042 (gnus-tmp-unread gnus-newsgroup-unreads)
9043 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
9044 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
9045 (gnus-tmp-unread-and-unselected
9046 (cond ((and (zerop gnus-tmp-unread-and-unticked)
9047 (zerop gnus-tmp-unselected)) "")
9048 ((zerop gnus-tmp-unselected)
9049 (format "{%d more}" gnus-tmp-unread-and-unticked))
9050 (t (format "{%d(+%d) more}"
9051 gnus-tmp-unread-and-unticked
9052 gnus-tmp-unselected))))
9054 (if (and gnus-current-headers
9055 (vectorp gnus-current-headers))
9056 (gnus-mode-string-quote
9057 (mail-header-subject gnus-current-headers)) ""))
9059 gnus-tmp-header);; passed as argument to any user-format-funcs
9060 (setq mode-string (eval mformat))
9061 (setq max-len (max 4 (if gnus-mode-non-string-length
9063 gnus-mode-non-string-length)
9064 (length mode-string))))
9065 ;; We might have to chop a bit of the string off...
9066 (when (> (length mode-string) max-len)
9068 (concat (gnus-truncate-string mode-string (- max-len 3))
9070 ;; Pad the mode string a bit.
9071 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
9072 ;; Update the mode line.
9073 (setq mode-line-buffer-identification (list mode-string))
9074 (set-buffer-modified-p t))))
9076 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
9077 "Go through the HEADERS list and add all Xrefs to a hash table.
9078 The resulting hash table is returned, or nil if no Xrefs were found."
9079 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
9080 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
9081 (xref-hashtb (make-vector 63 0))
9082 start group entry number xrefs header)
9084 (setq header (pop headers))
9085 (when (and (setq xrefs (mail-header-xref header))
9086 (not (memq (setq number (mail-header-number header))
9089 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
9090 (setq start (match-end 0))
9091 (setq group (if prefix
9092 (concat prefix (substring xrefs (match-beginning 1)
9094 (substring xrefs (match-beginning 1) (match-end 1))))
9096 (string-to-int (substring xrefs (match-beginning 2)
9098 (if (setq entry (gnus-gethash group xref-hashtb))
9099 (setcdr entry (cons number (cdr entry)))
9100 (gnus-sethash group (cons number nil) xref-hashtb)))))
9101 (and start xref-hashtb)))
9103 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
9104 "Look through all the headers and mark the Xrefs as read."
9105 (let ((virtual (gnus-virtual-group-p from-newsgroup))
9106 name entry info xref-hashtb idlist method nth4)
9108 (set-buffer gnus-group-buffer)
9109 (when (setq xref-hashtb
9110 (gnus-create-xref-hashtb from-newsgroup headers unreads))
9113 (unless (string= from-newsgroup (setq name (symbol-name group)))
9114 (setq idlist (symbol-value group))
9115 ;; Dead groups are not updated.
9117 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
9119 (if (stringp (setq nth4 (gnus-info-method info)))
9120 (setq nth4 (gnus-server-to-method nth4))))
9121 ;; Only do the xrefs if the group has the same
9122 ;; select method as the group we have just read.
9123 (or (gnus-methods-equal-p
9124 nth4 (gnus-find-method-for-group from-newsgroup))
9126 (equal nth4 (setq method (gnus-find-method-for-group
9128 (and (equal (car nth4) (car method))
9129 (equal (nth 1 nth4) (nth 1 method))))
9130 gnus-use-cross-reference
9131 (or (not (eq gnus-use-cross-reference t))
9133 ;; Only do cross-references on subscribed
9134 ;; groups, if that is what is wanted.
9135 (<= (gnus-info-level info) gnus-level-subscribed))
9136 (gnus-group-make-articles-read name idlist))))
9139 (defun gnus-group-make-articles-read (group articles)
9141 (entry (gnus-gethash group gnus-newsrc-hashtb))
9142 (info (nth 2 entry))
9143 (active (gnus-active group))
9145 ;; First peel off all illegal article numbers.
9147 (let ((ids articles)
9151 (if (and first (> id (cdr active)))
9153 ;; We'll end up in this situation in one particular
9154 ;; obscure situation. If you re-scan a group and get
9155 ;; a new article that is cross-posted to a different
9156 ;; group that has not been re-scanned, you might get
9157 ;; crossposted article that has a higher number than
9158 ;; Gnus believes possible. So we re-activate this
9159 ;; group as well. This might mean doing the
9160 ;; crossposting thingy will *increase* the number
9161 ;; of articles in some groups. Tsk, tsk.
9162 (setq active (or (gnus-activate-group group) active))))
9163 (if (or (> id (cdr active))
9164 (< id (car active)))
9165 (setq articles (delq id articles)))
9166 (setq ids (cdr ids)))))
9167 ;; If the read list is nil, we init it.
9169 (null (gnus-info-read info))
9171 (gnus-info-set-read info (cons 1 (1- (car active)))))
9172 ;; Then we add the read articles to the range.
9177 (gnus-info-read info) (setq articles (sort articles '<)))))
9178 ;; Then we have to re-compute how many unread
9179 ;; articles there are in this group.
9184 (setq num (- (1+ (cdr active)) (car active))))
9185 ((not (listp (cdr range)))
9186 (setq num (- (cdr active) (- (1+ (cdr range))
9190 (if (numberp (car range))
9192 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
9193 (setq range (cdr range)))
9194 (setq num (- (cdr active) num))))
9195 ;; Update the number of unread articles.
9197 ;; Update the group buffer.
9198 (gnus-group-update-group group t)))))
9200 (defun gnus-methods-equal-p (m1 m2)
9201 (let ((m1 (or m1 gnus-select-method))
9202 (m2 (or m2 gnus-select-method)))
9204 (and (eq (car m1) (car m2))
9205 (or (not (memq 'address (assoc (symbol-name (car m1))
9206 gnus-valid-select-methods)))
9207 (equal (nth 1 m1) (nth 1 m2)))))))
9209 (defsubst gnus-header-value ()
9212 (if (re-search-forward "^[^ \t]" nil t)
9216 (gnus-point-at-eol))))
9218 (defvar gnus-newsgroup-none-id 0)
9220 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
9221 (let ((cur nntp-server-buffer)
9224 (save-excursion (set-buffer gnus-summary-buffer)
9225 gnus-newsgroup-dependencies)))
9226 headers id id-dep ref-dep end ref)
9228 (set-buffer nntp-server-buffer)
9229 (run-hooks 'gnus-parse-headers-hook)
9230 (let ((case-fold-search t)
9231 in-reply-to header p lines)
9232 (goto-char (point-min))
9233 ;; Search to the beginning of the next header. Error messages
9234 ;; do not begin with 2 or 3.
9235 (while (re-search-forward "^[23][0-9]+ " nil t)
9238 ;; This implementation of this function, with nine
9239 ;; search-forwards instead of the one re-search-forward and
9240 ;; a case (which basically was the old function) is actually
9241 ;; about twice as fast, even though it looks messier. You
9242 ;; can't have everything, I guess. Speed and elegance
9243 ;; doesn't always go hand in hand.
9252 (narrow-to-region (point)
9253 (or (and (search-forward "\n.\n" nil t)
9259 (if (search-forward "\nsubject: " nil t)
9260 (gnus-header-value) "(none)"))
9264 (if (search-forward "\nfrom: " nil t)
9265 (gnus-header-value) "(nobody)"))
9269 (if (search-forward "\ndate: " nil t)
9270 (gnus-header-value) ""))
9274 (if (search-forward "\nmessage-id: " nil t)
9275 (setq id (gnus-header-value))
9276 ;; If there was no message-id, we just fake one to make
9277 ;; subsequent routines simpler.
9278 (setq id (concat "none+"
9280 (setq gnus-newsgroup-none-id
9281 (1+ gnus-newsgroup-none-id)))))))
9285 (if (search-forward "\nreferences: " nil t)
9294 (search-backward ">" end t)
9297 (search-backward "<" end t)
9299 ;; Get the references from the in-reply-to header if there
9300 ;; were no references and the in-reply-to header looks
9302 (if (and (search-forward "\nin-reply-to: " nil t)
9303 (setq in-reply-to (gnus-header-value))
9304 (string-match "<[^>]+>" in-reply-to))
9305 (setq ref (substring in-reply-to (match-beginning 0)
9313 (if (search-forward "\nlines: " nil t)
9314 (if (numberp (setq lines (read cur)))
9320 (and (search-forward "\nxref: " nil t)
9321 (gnus-header-value)))))
9322 ;; We do the threading while we read the headers. The
9323 ;; message-id and the last reference are both entered into
9324 ;; the same hash table. Some tippy-toeing around has to be
9325 ;; done in case an article has arrived before the article
9326 ;; which it refers to.
9327 (if (boundp (setq id-dep (intern id dependencies)))
9328 (if (and (car (symbol-value id-dep))
9330 ;; An article with this Message-ID has already
9331 ;; been seen, so we ignore this one, except we add
9332 ;; any additional Xrefs (in case the two articles
9333 ;; came from different servers).
9335 (mail-header-set-xref
9336 (car (symbol-value id-dep))
9337 (concat (or (mail-header-xref
9338 (car (symbol-value id-dep))) "")
9339 (or (mail-header-xref header) "")))
9341 (setcar (symbol-value id-dep) header))
9342 (set id-dep (list header)))
9344 (if (boundp (setq ref-dep (intern ref dependencies)))
9345 (setcdr (symbol-value ref-dep)
9346 (nconc (cdr (symbol-value ref-dep))
9347 (list (symbol-value id-dep))))
9348 (set ref-dep (list nil (symbol-value id-dep))))
9349 (setq headers (cons header headers)))
9350 (goto-char (point-max))
9352 (nreverse headers)))))
9354 ;; The following macros and functions were written by Felix Lee
9355 ;; <flee@cse.psu.edu>.
9357 (defmacro gnus-nov-read-integer ()
9359 (if (= (following-char) ?\t)
9361 (let ((num (condition-case nil (read buffer) (error nil))))
9362 (if (numberp num) num 0)))
9363 (or (eobp) (forward-char 1))))
9365 (defmacro gnus-nov-skip-field ()
9366 '(search-forward "\t" eol 'move))
9368 (defmacro gnus-nov-field ()
9369 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9371 ;; Goes through the xover lines and returns a list of vectors
9372 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9373 force-new dependencies)
9374 "Parse the news overview data in the server buffer, and return a
9375 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9376 ;; Get the Xref when the users reads the articles since most/some
9377 ;; NNTP servers do not include Xrefs when using XOVER.
9378 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9379 (let ((cur nntp-server-buffer)
9380 (dependencies (or dependencies gnus-newsgroup-dependencies))
9381 number headers header)
9383 (set-buffer nntp-server-buffer)
9384 ;; Allow the user to mangle the headers before parsing them.
9385 (run-hooks 'gnus-parse-headers-hook)
9386 (goto-char (point-min))
9387 (while (and sequence (not (eobp)))
9388 (setq number (read cur))
9389 (while (and sequence (< (car sequence) number))
9390 (setq sequence (cdr sequence)))
9392 (eq number (car sequence))
9394 (setq sequence (cdr sequence))
9396 (inline (gnus-nov-parse-line
9397 number dependencies force-new)))
9398 (setq headers (cons header headers)))))
9400 (setq headers (nreverse headers)))
9403 ;; This function has to be called with point after the article number
9404 ;; on the beginning of the line.
9405 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9407 (eol (gnus-point-at-eol))
9408 (buffer (current-buffer))
9409 header ref id id-dep ref-dep)
9411 ;; overview: [num subject from date id refs chars lines misc]
9412 (narrow-to-region (point) eol)
9413 (or (eobp) (forward-char))
9419 (gnus-nov-field) ; subject
9420 (gnus-nov-field) ; from
9421 (gnus-nov-field) ; date
9422 (setq id (or (gnus-nov-field)
9425 (setq none (1+ none)))))) ; id
9428 (let ((beg (point)))
9429 (search-forward "\t" eol)
9430 (if (search-backward ">" beg t)
9434 (search-backward "<" beg t)))
9436 (gnus-nov-field)) ; refs
9437 (gnus-nov-read-integer) ; chars
9438 (gnus-nov-read-integer) ; lines
9439 (if (= (following-char) ?\n)
9441 (gnus-nov-field)) ; misc
9444 (gnus-error 4 "Strange nov line")
9450 ;; We build the thread tree.
9452 (if (boundp (setq id-dep (intern id dependencies)))
9453 (if (and (car (symbol-value id-dep))
9455 ;; An article with this Message-ID has already been seen,
9456 ;; so we ignore this one, except we add any additional
9457 ;; Xrefs (in case the two articles came from different
9460 (mail-header-set-xref
9461 (car (symbol-value id-dep))
9462 (concat (or (mail-header-xref
9463 (car (symbol-value id-dep))) "")
9464 (or (mail-header-xref header) "")))
9466 (setcar (symbol-value id-dep) header))
9467 (set id-dep (list header))))
9469 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9470 (setcdr (symbol-value ref-dep)
9471 (nconc (cdr (symbol-value ref-dep))
9472 (list (symbol-value id-dep))))
9473 (set ref-dep (list nil (symbol-value id-dep)))))
9476 (defun gnus-article-get-xrefs ()
9477 "Fill in the Xref value in `gnus-current-headers', if necessary.
9478 This is meant to be called in `gnus-article-internal-prepare-hook'."
9479 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9480 gnus-current-headers)))
9481 (or (not gnus-use-cross-reference)
9483 (and (mail-header-xref headers)
9484 (not (string= (mail-header-xref headers) "")))
9485 (let ((case-fold-search t)
9488 (nnheader-narrow-to-headers)
9489 (goto-char (point-min))
9490 (if (or (and (eq (downcase (following-char)) ?x)
9491 (looking-at "Xref:"))
9492 (search-forward "\nXref:" nil t))
9494 (goto-char (1+ (match-end 0)))
9495 (setq xref (buffer-substring (point)
9496 (progn (end-of-line) (point))))
9497 (mail-header-set-xref headers xref))))))))
9499 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
9500 "Find article ID and insert the summary line for that article."
9501 (let ((header (if (and old-header use-old-header)
9502 old-header (gnus-read-header id)))
9503 (number (and (numberp id) id))
9506 ;; Rebuild the thread that this article is part of and go to the
9507 ;; article we have fetched.
9508 (when (and (not gnus-show-threads)
9510 (when (setq pos (text-property-any
9511 (point-min) (point-max) 'gnus-number
9512 (mail-header-number old-header)))
9515 (gnus-data-remove (mail-header-number old-header))))
9517 (mail-header-set-number header (mail-header-number old-header)))
9518 (setq gnus-newsgroup-sparse
9519 (delq (setq number (mail-header-number header))
9520 gnus-newsgroup-sparse))
9521 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
9522 (gnus-rebuild-thread (mail-header-id header))
9523 (gnus-summary-goto-subject number nil t))
9524 (when (and (numberp number)
9526 ;; We have to update the boundaries even if we can't fetch the
9527 ;; article if ID is a number -- so that the next `P' or `N'
9528 ;; command will fetch the previous (or next) article even
9529 ;; if the one we tried to fetch this time has been canceled.
9530 (and (> number gnus-newsgroup-end)
9531 (setq gnus-newsgroup-end number))
9532 (and (< number gnus-newsgroup-begin)
9533 (setq gnus-newsgroup-begin number))
9534 (setq gnus-newsgroup-unselected
9535 (delq number gnus-newsgroup-unselected)))
9536 ;; Report back a success?
9537 (and header (mail-header-number header))))
9539 (defun gnus-summary-work-articles (n)
9540 "Return a list of articles to be worked upon. The prefix argument,
9541 the list of process marked articles, and the current article will be
9542 taken into consideration."
9544 ((and n (numberp n))
9545 ;; A numerical prefix has been given.
9546 (let ((backward (< n 0))
9552 (push (setq article (gnus-summary-article-number))
9555 (gnus-summary-find-prev nil article)
9556 (gnus-summary-find-next nil article)))
9558 (nreverse articles)))
9559 ((and (boundp 'transient-mark-mode)
9562 ;; Work on the region between point and mark.
9563 (let ((max (max (point) (mark)))
9566 (goto-char (min (point) (mark)))
9569 (push (setq article (gnus-summary-article-number)) articles)
9570 (gnus-summary-find-next nil article)
9572 (nreverse articles))))
9573 (gnus-newsgroup-processable
9574 ;; There are process-marked articles present.
9575 (reverse gnus-newsgroup-processable))
9577 ;; Just return the current article.
9578 (list (gnus-summary-article-number)))))
9580 (defun gnus-summary-search-group (&optional backward use-level)
9581 "Search for next unread newsgroup.
9582 If optional argument BACKWARD is non-nil, search backward instead."
9584 (set-buffer gnus-group-buffer)
9585 (if (gnus-group-search-forward
9586 backward nil (if use-level (gnus-group-group-level) nil))
9587 (gnus-group-group-name))))
9589 (defun gnus-summary-best-group (&optional exclude-group)
9590 "Find the name of the best unread group.
9591 If EXCLUDE-GROUP, do not go to this group."
9593 (set-buffer gnus-group-buffer)
9595 (gnus-group-best-unread-group exclude-group))))
9597 (defun gnus-summary-find-next (&optional unread article backward)
9598 (if backward (gnus-summary-find-prev)
9599 (let* ((dummy (gnus-summary-article-intangible-p))
9600 (article (or article (gnus-summary-article-number)))
9601 (arts (gnus-data-find-list article))
9603 (when (and (not dummy)
9604 (or (not gnus-summary-check-current)
9606 (not (gnus-data-unread-p (car arts)))))
9607 (setq arts (cdr arts)))
9612 (when (gnus-data-unread-p (car arts))
9613 (setq result (car arts)
9615 (setq arts (cdr arts)))
9618 (goto-char (gnus-data-pos result))
9619 (gnus-data-number result)))))
9621 (defun gnus-summary-find-prev (&optional unread article)
9622 (let* ((eobp (eobp))
9623 (article (or article (gnus-summary-article-number)))
9624 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9626 (when (and (not eobp)
9627 (or (not gnus-summary-check-current)
9629 (not (gnus-data-unread-p (car arts)))))
9630 (setq arts (cdr arts)))
9635 (and (gnus-data-unread-p (car arts))
9636 (setq result (car arts)
9638 (setq arts (cdr arts)))
9642 (goto-char (gnus-data-pos result))
9643 (gnus-data-number result)))))
9645 (defun gnus-summary-find-subject (subject &optional unread backward article)
9646 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9647 (article (or article (gnus-summary-article-number)))
9648 (articles (gnus-data-list backward))
9649 (arts (gnus-data-find-list article articles))
9651 (when (or (not gnus-summary-check-current)
9653 (not (gnus-data-unread-p (car arts))))
9654 (setq arts (cdr arts)))
9656 (and (or (not unread)
9657 (gnus-data-unread-p (car arts)))
9658 (vectorp (gnus-data-header (car arts)))
9660 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9661 (setq result (car arts)
9663 (setq arts (cdr arts)))
9665 (goto-char (gnus-data-pos result))
9666 (gnus-data-number result))))
9668 (defun gnus-summary-search-forward (&optional unread subject backward)
9669 "Search forward for an article.
9670 If UNREAD, look for unread articles. If SUBJECT, look for
9671 articles with that subject. If BACKWARD, search backward instead."
9672 (cond (subject (gnus-summary-find-subject subject unread backward))
9673 (backward (gnus-summary-find-prev unread))
9674 (t (gnus-summary-find-next unread))))
9676 (defun gnus-recenter (&optional n)
9677 "Center point in window and redisplay frame.
9678 Also do horizontal recentering."
9680 (when (and gnus-auto-center-summary
9681 (not (eq gnus-auto-center-summary 'vertical)))
9682 (gnus-horizontal-recenter))
9685 (defun gnus-summary-recenter ()
9686 "Center point in the summary window.
9687 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9688 displayed, no centering will be performed."
9689 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9690 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9691 (let* ((top (cond ((< (window-height) 4) 0)
9692 ((< (window-height) 7) 1)
9694 (height (1- (window-height)))
9695 (bottom (save-excursion (goto-char (point-max))
9696 (forward-line (- height))
9698 (window (get-buffer-window (current-buffer))))
9699 ;; The user has to want it.
9700 (when gnus-auto-center-summary
9701 (when (get-buffer-window gnus-article-buffer)
9702 ;; Only do recentering when the article buffer is displayed,
9703 ;; Set the window start to either `bottom', which is the biggest
9704 ;; possible valid number, or the second line from the top,
9705 ;; whichever is the least.
9707 window (min bottom (save-excursion
9708 (forward-line (- top)) (point)))))
9709 ;; Do horizontal recentering while we're at it.
9710 (when (and (get-buffer-window (current-buffer) t)
9711 (not (eq gnus-auto-center-summary 'vertical)))
9712 (let ((selected (selected-window)))
9713 (select-window (get-buffer-window (current-buffer) t))
9714 (gnus-summary-position-point)
9715 (gnus-horizontal-recenter)
9716 (select-window selected))))))
9718 (defun gnus-horizontal-recenter ()
9719 "Recenter the current buffer horizontally."
9720 (if (< (current-column) (/ (window-width) 2))
9721 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9722 (let* ((orig (point))
9723 (end (window-end (get-buffer-window (current-buffer) t)))
9725 ;; Find the longest line currently displayed in the window.
9726 (goto-char (window-start))
9727 (while (and (not (eobp))
9730 (setq max (max max (current-column)))
9733 ;; Scroll horizontally to center (sort of) the point.
9734 (if (> max (window-width))
9736 (get-buffer-window (current-buffer) t)
9737 (min (- (current-column) (/ (window-width) 3))
9738 (+ 2 (- max (window-width)))))
9739 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9742 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9743 (defun gnus-short-group-name (group &optional levels)
9744 "Collapse GROUP name LEVELS."
9751 (while (string-match "\\." group skip)
9752 (setq skip (match-end 0)
9755 (if (string-match ":" group)
9756 (setq foreign (substring group 0 (match-end 0))
9757 group (substring group (match-end 0))))
9759 (if (and (string-match "\\." group)
9760 (> levels (- gnus-group-uncollapsed-levels 1)))
9761 (setq name (concat name (substring group 0 1))
9762 group (substring group (match-end 0))
9764 name (concat name "."))
9765 (setq name (concat foreign name group)
9769 (defun gnus-summary-jump-to-group (newsgroup)
9770 "Move point to NEWSGROUP in group mode buffer."
9771 ;; Keep update point of group mode buffer if visible.
9772 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9773 (save-window-excursion
9774 ;; Take care of tree window mode.
9775 (if (get-buffer-window gnus-group-buffer)
9776 (pop-to-buffer gnus-group-buffer))
9777 (gnus-group-jump-to-group newsgroup))
9779 ;; Take care of tree window mode.
9780 (if (get-buffer-window gnus-group-buffer)
9781 (pop-to-buffer gnus-group-buffer)
9782 (set-buffer gnus-group-buffer))
9783 (gnus-group-jump-to-group newsgroup))))
9785 ;; This function returns a list of article numbers based on the
9786 ;; difference between the ranges of read articles in this group and
9787 ;; the range of active articles.
9788 (defun gnus-list-of-unread-articles (group)
9789 (let* ((read (gnus-info-read (gnus-get-info group)))
9790 (active (gnus-active group))
9793 ;; If none are read, then all are unread.
9795 (setq first (car active))
9796 ;; If the range of read articles is a single range, then the
9797 ;; first unread article is the article after the last read
9798 ;; article. Sounds logical, doesn't it?
9799 (if (not (listp (cdr read)))
9800 (setq first (1+ (cdr read)))
9801 ;; `read' is a list of ranges.
9802 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9807 (while (< first nlast)
9808 (setq unread (cons first unread))
9809 (setq first (1+ first))))
9810 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9811 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9812 (setq read (cdr read)))))
9813 ;; And add the last unread articles.
9814 (while (<= first last)
9815 (setq unread (cons first unread))
9816 (setq first (1+ first)))
9817 ;; Return the list of unread articles.
9820 (defun gnus-list-of-read-articles (group)
9821 "Return a list of unread, unticked and non-dormant articles."
9822 (let* ((info (gnus-get-info group))
9823 (marked (gnus-info-marks info))
9824 (active (gnus-active group)))
9826 (gnus-set-difference
9827 (gnus-sorted-complement
9828 (gnus-uncompress-range active)
9829 (gnus-list-of-unread-articles group))
9831 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9832 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9834 ;; Various summary commands
9836 (defun gnus-summary-universal-argument (arg)
9837 "Perform any operation on all articles that are process/prefixed."
9839 (gnus-set-global-variables)
9840 (let ((articles (gnus-summary-work-articles arg))
9847 (substitute-command-keys
9848 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9851 (gnus-error 1 "Undefined key")
9854 (gnus-summary-goto-subject (setq article (pop articles)))
9855 (command-execute func)
9856 (gnus-summary-remove-process-mark article)))))
9857 (gnus-summary-position-point))
9859 (defun gnus-summary-toggle-truncation (&optional arg)
9860 "Toggle truncation of summary lines.
9861 With arg, turn line truncation on iff arg is positive."
9863 (setq truncate-lines
9864 (if (null arg) (not truncate-lines)
9865 (> (prefix-numeric-value arg) 0)))
9868 (defun gnus-summary-reselect-current-group (&optional all rescan)
9869 "Exit and then reselect the current newsgroup.
9870 The prefix argument ALL means to select all articles."
9872 (gnus-set-global-variables)
9873 (let ((current-subject (gnus-summary-article-number))
9874 (group gnus-newsgroup-name))
9875 (setq gnus-newsgroup-begin nil)
9877 ;; We have to adjust the point of group mode buffer because the
9878 ;; current point was moved to the next unread newsgroup by
9880 (gnus-summary-jump-to-group group)
9883 (gnus-group-get-new-news-this-group 1)))
9884 (gnus-group-read-group all t)
9885 (gnus-summary-goto-subject current-subject)))
9887 (defun gnus-summary-rescan-group (&optional all)
9888 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9890 (gnus-summary-reselect-current-group all t))
9892 (defun gnus-summary-update-info ()
9893 (let* ((group gnus-newsgroup-name))
9894 (when gnus-newsgroup-kill-headers
9895 (setq gnus-newsgroup-killed
9896 (gnus-compress-sequence
9898 (gnus-set-sorted-intersection
9899 (gnus-uncompress-range gnus-newsgroup-killed)
9900 (setq gnus-newsgroup-unselected
9901 (sort gnus-newsgroup-unselected '<)))
9902 (setq gnus-newsgroup-unreads
9903 (sort gnus-newsgroup-unreads '<))) t)))
9904 (unless (listp (cdr gnus-newsgroup-killed))
9905 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9906 (let ((headers gnus-newsgroup-headers))
9907 (run-hooks 'gnus-exit-group-hook)
9908 (unless gnus-save-score
9909 (setq gnus-newsgroup-scored nil))
9910 ;; Set the new ranges of read articles.
9911 (gnus-update-read-articles
9912 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9913 ;; Set the current article marks.
9915 ;; Do the cross-ref thing.
9916 (when gnus-use-cross-reference
9917 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9918 ;; Do adaptive scoring, and possibly save score files.
9919 (when gnus-newsgroup-adaptive
9920 (gnus-score-adaptive))
9921 (when gnus-use-scoring
9923 ;; Do not switch windows but change the buffer to work.
9924 (set-buffer gnus-group-buffer)
9925 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9926 (gnus-group-update-group group)))))
9928 (defun gnus-summary-exit (&optional temporary)
9929 "Exit reading current newsgroup, and then return to group selection mode.
9930 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9932 (gnus-set-global-variables)
9933 (gnus-kill-save-kill-buffer)
9934 (let* ((group gnus-newsgroup-name)
9935 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9937 (buf (current-buffer)))
9938 (run-hooks 'gnus-summary-prepare-exit-hook)
9939 ;; If we have several article buffers, we kill them at exit.
9940 (unless gnus-single-article-buffer
9941 (gnus-kill-buffer gnus-original-article-buffer)
9942 (setq gnus-article-current nil))
9943 (when gnus-use-cache
9944 (gnus-cache-possibly-remove-articles)
9945 (gnus-cache-save-buffers))
9946 (when gnus-use-trees
9947 (gnus-tree-close group))
9948 ;; Make all changes in this group permanent.
9950 (gnus-summary-update-info))
9951 (gnus-close-group group)
9952 ;; Make sure where I was, and go to next newsgroup.
9953 (set-buffer gnus-group-buffer)
9955 (gnus-group-jump-to-group group))
9956 (run-hooks 'gnus-summary-exit-hook)
9958 (gnus-group-next-unread-group 1))
9961 ;; If we have several article buffers, we kill them at exit.
9962 (unless gnus-single-article-buffer
9963 (gnus-kill-buffer gnus-article-buffer)
9964 (gnus-kill-buffer gnus-original-article-buffer)
9965 (setq gnus-article-current nil))
9967 (if (not gnus-kill-summary-on-exit)
9968 (gnus-deaden-summary)
9969 ;; We set all buffer-local variables to nil. It is unclear why
9970 ;; this is needed, but if we don't, buffer-local variables are
9971 ;; not garbage-collected, it seems. This would the lead to en
9972 ;; ever-growing Emacs.
9973 (gnus-summary-clear-local-variables)
9974 (when (get-buffer gnus-article-buffer)
9975 (bury-buffer gnus-article-buffer))
9976 ;; We clear the global counterparts of the buffer-local
9977 ;; variables as well, just to be on the safe side.
9978 (gnus-configure-windows 'group 'force)
9979 (gnus-summary-clear-local-variables)
9980 ;; Return to group mode buffer.
9981 (if (eq mode 'gnus-summary-mode)
9982 (gnus-kill-buffer buf)))
9983 (setq gnus-current-select-method gnus-select-method)
9984 (pop-to-buffer gnus-group-buffer)
9985 ;; Clear the current group name.
9986 (if (not quit-config)
9988 (gnus-group-jump-to-group group)
9989 (gnus-group-next-unread-group 1)
9990 (gnus-configure-windows 'group 'force))
9991 (if (not (buffer-name (car quit-config)))
9992 (gnus-configure-windows 'group 'force)
9993 (set-buffer (car quit-config))
9994 (and (eq major-mode 'gnus-summary-mode)
9995 (gnus-set-global-variables))
9996 (gnus-configure-windows (cdr quit-config))))
9998 (setq gnus-newsgroup-name nil)))))
10000 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
10001 (defun gnus-summary-exit-no-update (&optional no-questions)
10002 "Quit reading current newsgroup without updating read article info."
10004 (gnus-set-global-variables)
10005 (let* ((group gnus-newsgroup-name)
10006 (quit-config (gnus-group-quit-config group)))
10007 (when (or no-questions
10009 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
10010 ;; If we have several article buffers, we kill them at exit.
10011 (unless gnus-single-article-buffer
10012 (gnus-kill-buffer gnus-article-buffer)
10013 (gnus-kill-buffer gnus-original-article-buffer)
10014 (setq gnus-article-current nil))
10015 (if (not gnus-kill-summary-on-exit)
10016 (gnus-deaden-summary)
10017 (gnus-close-group group)
10018 (gnus-summary-clear-local-variables)
10019 (set-buffer gnus-group-buffer)
10020 (gnus-summary-clear-local-variables)
10021 (when (get-buffer gnus-summary-buffer)
10022 (kill-buffer gnus-summary-buffer)))
10023 (unless gnus-single-article-buffer
10024 (setq gnus-article-current nil))
10025 (when gnus-use-trees
10026 (gnus-tree-close group))
10027 (when (get-buffer gnus-article-buffer)
10028 (bury-buffer gnus-article-buffer))
10029 ;; Return to the group buffer.
10030 (gnus-configure-windows 'group 'force)
10031 ;; Clear the current group name.
10032 (setq gnus-newsgroup-name nil)
10033 (when (equal (gnus-group-group-name) group)
10034 (gnus-group-next-unread-group 1))
10036 (if (not (buffer-name (car quit-config)))
10037 (gnus-configure-windows 'group 'force)
10038 (set-buffer (car quit-config))
10039 (when (eq major-mode 'gnus-summary-mode)
10040 (gnus-set-global-variables))
10041 (gnus-configure-windows (cdr quit-config)))))))
10043 ;;; Dead summaries.
10045 (defvar gnus-dead-summary-mode-map nil)
10047 (if gnus-dead-summary-mode-map
10049 (setq gnus-dead-summary-mode-map (make-keymap))
10050 (suppress-keymap gnus-dead-summary-mode-map)
10051 (substitute-key-definition
10052 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
10053 (let ((keys '("\C-d" "\r" "\177")))
10055 (define-key gnus-dead-summary-mode-map
10056 (pop keys) 'gnus-summary-wake-up-the-dead))))
10058 (defvar gnus-dead-summary-mode nil
10059 "Minor mode for Gnus summary buffers.")
10061 (defun gnus-dead-summary-mode (&optional arg)
10062 "Minor mode for Gnus summary buffers."
10064 (when (eq major-mode 'gnus-summary-mode)
10065 (make-local-variable 'gnus-dead-summary-mode)
10066 (setq gnus-dead-summary-mode
10067 (if (null arg) (not gnus-dead-summary-mode)
10068 (> (prefix-numeric-value arg) 0)))
10069 (when gnus-dead-summary-mode
10070 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
10071 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
10072 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
10073 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
10074 minor-mode-map-alist)))))
10076 (defun gnus-deaden-summary ()
10077 "Make the current summary buffer into a dead summary buffer."
10078 ;; Kill any previous dead summary buffer.
10079 (when (and gnus-dead-summary
10080 (buffer-name gnus-dead-summary))
10082 (set-buffer gnus-dead-summary)
10083 (when gnus-dead-summary-mode
10084 (kill-buffer (current-buffer)))))
10085 ;; Make this the current dead summary.
10086 (setq gnus-dead-summary (current-buffer))
10087 (gnus-dead-summary-mode 1)
10088 (let ((name (buffer-name)))
10089 (when (string-match "Summary" name)
10091 (concat (substring name 0 (match-beginning 0)) "Dead "
10092 (substring name (match-beginning 0))) t))))
10094 (defun gnus-kill-or-deaden-summary (buffer)
10095 "Kill or deaden the summary BUFFER."
10096 (when (and (buffer-name buffer)
10097 (not gnus-single-article-buffer))
10099 (set-buffer buffer)
10100 (gnus-kill-buffer gnus-article-buffer)
10101 (gnus-kill-buffer gnus-original-article-buffer)))
10102 (cond (gnus-kill-summary-on-exit
10103 (when (and gnus-use-trees
10104 (and (get-buffer buffer)
10105 (buffer-name (get-buffer buffer))))
10107 (set-buffer (get-buffer buffer))
10108 (gnus-tree-close gnus-newsgroup-name)))
10109 (gnus-kill-buffer buffer))
10110 ((and (get-buffer buffer)
10111 (buffer-name (get-buffer buffer)))
10113 (set-buffer buffer)
10114 (gnus-deaden-summary)))))
10116 (defun gnus-summary-wake-up-the-dead (&rest args)
10117 "Wake up the dead summary buffer."
10119 (gnus-dead-summary-mode -1)
10120 (let ((name (buffer-name)))
10121 (when (string-match "Dead " name)
10123 (concat (substring name 0 (match-beginning 0))
10124 (substring name (match-end 0))) t)))
10125 (gnus-message 3 "This dead summary is now alive again"))
10127 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
10128 (defun gnus-summary-fetch-faq (&optional faq-dir)
10129 "Fetch the FAQ for the current group.
10130 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
10134 (if current-prefix-arg
10136 "Faq dir: " (and (listp gnus-group-faq-directory)
10137 gnus-group-faq-directory)))))
10138 (let (gnus-faq-buffer)
10139 (and (setq gnus-faq-buffer
10140 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
10141 (gnus-configure-windows 'summary-faq))))
10143 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10144 (defun gnus-summary-describe-group (&optional force)
10145 "Describe the current newsgroup."
10147 (gnus-group-describe-group force gnus-newsgroup-name))
10149 (defun gnus-summary-describe-briefly ()
10150 "Describe summary mode commands briefly."
10153 (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")))
10155 ;; Walking around group mode buffer from summary mode.
10157 (defun gnus-summary-next-group (&optional no-article target-group backward)
10158 "Exit current newsgroup and then select next unread newsgroup.
10159 If prefix argument NO-ARTICLE is non-nil, no article is selected
10160 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
10161 previous group instead."
10163 (gnus-set-global-variables)
10164 (let ((current-group gnus-newsgroup-name)
10165 (current-buffer (current-buffer))
10167 ;; First we semi-exit this group to update Xrefs and all variables.
10168 ;; We can't do a real exit, because the window conf must remain
10169 ;; the same in case the user is prompted for info, and we don't
10170 ;; want the window conf to change before that...
10171 (gnus-summary-exit t)
10172 (while (not entered)
10173 ;; Then we find what group we are supposed to enter.
10174 (set-buffer gnus-group-buffer)
10175 (gnus-group-jump-to-group current-group)
10178 (if (eq gnus-keep-same-level 'best)
10179 (gnus-summary-best-group gnus-newsgroup-name)
10180 (gnus-summary-search-group backward gnus-keep-same-level))))
10181 (if (not target-group)
10182 ;; There are no further groups, so we return to the group
10185 (gnus-message 5 "Returning to the group buffer")
10187 (set-buffer current-buffer)
10188 (gnus-summary-exit))
10189 ;; We try to enter the target group.
10190 (gnus-group-jump-to-group target-group)
10191 (let ((unreads (gnus-group-group-unread)))
10192 (if (and (or (eq t unreads)
10193 (and unreads (not (zerop unreads))))
10194 (gnus-summary-read-group
10195 target-group nil no-article current-buffer))
10197 (setq current-group target-group
10198 target-group nil)))))))
10200 (defun gnus-summary-prev-group (&optional no-article)
10201 "Exit current newsgroup and then select previous unread newsgroup.
10202 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
10204 (gnus-summary-next-group no-article nil t))
10206 ;; Walking around summary lines.
10208 (defun gnus-summary-first-subject (&optional unread)
10209 "Go to the first unread subject.
10210 If UNREAD is non-nil, go to the first unread article.
10211 Returns the article selected or nil if there are no unread articles."
10216 ((null gnus-newsgroup-data)
10217 (gnus-message 3 "No articles in the group")
10219 ;; Pick the first article.
10221 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
10222 (gnus-data-number (car gnus-newsgroup-data)))
10223 ;; No unread articles.
10224 ((null gnus-newsgroup-unreads)
10225 (gnus-message 3 "No more unread articles")
10227 ;; Find the first unread article.
10229 (let ((data gnus-newsgroup-data))
10231 (not (gnus-data-unread-p (car data))))
10232 (setq data (cdr data)))
10235 (goto-char (gnus-data-pos (car data)))
10236 (gnus-data-number (car data)))))))
10237 (gnus-summary-position-point)))
10239 (defun gnus-summary-next-subject (n &optional unread dont-display)
10240 "Go to next N'th summary line.
10241 If N is negative, go to the previous N'th subject line.
10242 If UNREAD is non-nil, only unread articles are selected.
10243 The difference between N and the actual number of steps taken is
10246 (let ((backward (< n 0))
10248 (while (and (> n 0)
10250 (gnus-summary-find-prev unread)
10251 (gnus-summary-find-next unread)))
10253 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10254 (if unread " unread" "")))
10255 (unless dont-display
10256 (gnus-summary-recenter)
10257 (gnus-summary-position-point))
10260 (defun gnus-summary-next-unread-subject (n)
10261 "Go to next N'th unread summary line."
10263 (gnus-summary-next-subject n t))
10265 (defun gnus-summary-prev-subject (n &optional unread)
10266 "Go to previous N'th summary line.
10267 If optional argument UNREAD is non-nil, only unread article is selected."
10269 (gnus-summary-next-subject (- n) unread))
10271 (defun gnus-summary-prev-unread-subject (n)
10272 "Go to previous N'th unread summary line."
10274 (gnus-summary-next-subject (- n) t))
10276 (defun gnus-summary-goto-subject (article &optional force silent)
10277 "Go the subject line of ARTICLE.
10278 If FORCE, also allow jumping to articles not currently shown."
10280 (data (gnus-data-find article)))
10281 ;; We read in the article if we have to.
10284 (gnus-summary-insert-subject article (and (vectorp force) force) t)
10285 (setq data (gnus-data-find article)))
10290 (gnus-message 3 "Can't find article %d" article))
10292 (goto-char (gnus-data-pos data))
10295 ;; Walking around summary lines with displaying articles.
10297 (defun gnus-summary-expand-window (&optional arg)
10298 "Make the summary buffer take up the entire Emacs frame.
10299 Given a prefix, will force an `article' buffer configuration."
10301 (gnus-set-global-variables)
10303 (gnus-configure-windows 'article 'force)
10304 (gnus-configure-windows 'summary 'force)))
10306 (defun gnus-summary-display-article (article &optional all-header)
10307 "Display ARTICLE in article buffer."
10308 (gnus-set-global-variables)
10312 (if gnus-summary-display-article-function
10313 (funcall gnus-summary-display-article-function article all-header)
10314 (gnus-article-prepare article all-header))
10315 (run-hooks 'gnus-select-article-hook)
10316 (unless (zerop gnus-current-article)
10317 (gnus-summary-goto-subject gnus-current-article))
10318 (gnus-summary-recenter)
10319 (when gnus-use-trees
10320 (gnus-possibly-generate-tree article)
10321 (gnus-highlight-selected-tree article))
10322 ;; Successfully display article.
10323 (gnus-article-set-window-start
10324 (cdr (assq article gnus-newsgroup-bookmarks))))))
10326 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10327 "Select the current article.
10328 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10329 non-nil, the article will be re-fetched even if it already present in
10330 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10332 ;; Make sure we are in the summary buffer to work around bbdb bug.
10333 (unless (eq major-mode 'gnus-summary-mode)
10334 (set-buffer gnus-summary-buffer))
10335 (let ((article (or article (gnus-summary-article-number)))
10336 (all-headers (not (not all-headers))) ;Must be T or NIL.
10337 gnus-summary-display-article-function
10340 (gnus-summary-article-pseudo-p article)
10341 (error "This is a pseudo-article."))
10344 (set-buffer gnus-summary-buffer)
10345 (if (or (and gnus-single-article-buffer
10346 (or (null gnus-current-article)
10347 (null gnus-article-current)
10348 (null (get-buffer gnus-article-buffer))
10349 (not (eq article (cdr gnus-article-current)))
10350 (not (equal (car gnus-article-current)
10351 gnus-newsgroup-name))))
10352 (and (not gnus-single-article-buffer)
10353 (or (null gnus-current-article)
10354 (not (eq gnus-current-article article))))
10356 ;; The requested article is different from the current article.
10358 (gnus-summary-display-article article all-headers)
10359 (setq did article))
10360 (if (or all-headers gnus-show-all-headers)
10361 (gnus-article-show-all-headers))
10364 (gnus-article-set-window-start
10365 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10367 (defun gnus-summary-set-current-mark (&optional current-mark)
10368 "Obsolete function."
10371 (defun gnus-summary-next-article (&optional unread subject backward push)
10372 "Select the next article.
10373 If UNREAD, only unread articles are selected.
10374 If SUBJECT, only articles with SUBJECT are selected.
10375 If BACKWARD, the previous article is selected instead of the next."
10377 (gnus-set-global-variables)
10379 ;; Is there such an article?
10380 ((and (gnus-summary-search-forward unread subject backward)
10381 (or (gnus-summary-display-article (gnus-summary-article-number))
10382 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10383 (gnus-summary-position-point))
10384 ;; If not, we try the first unread, if that is wanted.
10386 gnus-auto-select-same
10387 (or (gnus-summary-first-unread-article)
10388 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10389 (gnus-summary-position-point)
10390 (gnus-message 6 "Wrapped"))
10391 ;; Try to get next/previous article not displayed in this group.
10392 ((and gnus-auto-extend-newsgroup
10393 (not unread) (not subject))
10394 (gnus-summary-goto-article
10395 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10397 ;; Go to next/previous group.
10399 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10400 (gnus-summary-jump-to-group gnus-newsgroup-name))
10401 (let ((cmd last-command-char)
10403 (if (eq gnus-keep-same-level 'best)
10404 (gnus-summary-best-group gnus-newsgroup-name)
10405 (gnus-summary-search-group backward gnus-keep-same-level))))
10406 ;; For some reason, the group window gets selected. We change
10408 (select-window (get-buffer-window (current-buffer)))
10409 ;; Select next unread newsgroup automagically.
10411 ((or (not gnus-auto-select-next)
10413 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10414 ((or (eq gnus-auto-select-next 'quietly)
10415 (and (eq gnus-auto-select-next 'slightly-quietly)
10417 (and (eq gnus-auto-select-next 'almost-quietly)
10418 (gnus-summary-last-article-p)))
10420 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10421 (gnus-summary-exit)
10422 (gnus-message 7 "No more%s articles (%s)..."
10423 (if unread " unread" "")
10424 (if group (concat "selecting " group)
10426 (gnus-summary-next-group nil group backward)))
10428 (gnus-summary-walk-group-buffer
10429 gnus-newsgroup-name cmd unread backward)))))))
10431 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10432 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10433 (?\C-p (gnus-group-prev-unread-group 1))))
10434 keve key group ended)
10436 (set-buffer gnus-group-buffer)
10437 (gnus-summary-jump-to-group from-group)
10439 (if (eq gnus-keep-same-level 'best)
10440 (gnus-summary-best-group gnus-newsgroup-name)
10441 (gnus-summary-search-group backward gnus-keep-same-level))))
10444 5 "No more%s articles%s" (if unread " unread" "")
10446 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10447 (format " (Type %s for %s [%s])"
10448 (single-key-description cmd) group
10449 (car (gnus-gethash group gnus-newsrc-hashtb)))
10450 (format " (Type %s to exit %s)"
10451 (single-key-description cmd)
10452 gnus-newsgroup-name)))
10453 ;; Confirm auto selection.
10454 (setq key (car (setq keve (gnus-read-event-char))))
10457 ((assq key keystrokes)
10458 (let ((obuf (current-buffer)))
10459 (switch-to-buffer gnus-group-buffer)
10461 (gnus-group-jump-to-group group))
10462 (eval (cadr (assq key keystrokes)))
10463 (setq group (gnus-group-group-name))
10464 (switch-to-buffer obuf))
10467 (if (or (not group)
10468 (gnus-ephemeral-group-p gnus-newsgroup-name))
10469 (gnus-summary-exit)
10470 (gnus-summary-next-group nil group backward)))
10472 (push (cdr keve) unread-command-events))))))
10474 (defun gnus-read-event-char ()
10475 "Get the next event."
10476 (let ((event (read-event)))
10477 (cons (and (numberp event) event) event)))
10479 (defun gnus-summary-next-unread-article ()
10480 "Select unread article after current one."
10482 (gnus-summary-next-article t (and gnus-auto-select-same
10483 (gnus-summary-article-subject))))
10485 (defun gnus-summary-prev-article (&optional unread subject)
10486 "Select the article after the current one.
10487 If UNREAD is non-nil, only unread articles are selected."
10489 (gnus-summary-next-article unread subject t))
10491 (defun gnus-summary-prev-unread-article ()
10492 "Select unred article before current one."
10494 (gnus-summary-prev-article t (and gnus-auto-select-same
10495 (gnus-summary-article-subject))))
10497 (defun gnus-summary-next-page (&optional lines circular)
10498 "Show next page of the selected article.
10499 If at the end of the current article, select the next article.
10500 LINES says how many lines should be scrolled up.
10502 If CIRCULAR is non-nil, go to the start of the article instead of
10503 selecting the next article when reaching the end of the current
10506 (setq gnus-summary-buffer (current-buffer))
10507 (gnus-set-global-variables)
10508 (let ((article (gnus-summary-article-number))
10510 (gnus-configure-windows 'article)
10511 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
10512 (if (and (eq gnus-summary-goto-unread 'never)
10513 (not (gnus-summary-last-article-p article)))
10514 (gnus-summary-next-article)
10515 (gnus-summary-next-unread-article))
10516 (if (or (null gnus-current-article)
10517 (null gnus-article-current)
10518 (/= article (cdr gnus-article-current))
10519 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10520 ;; Selected subject is different from current article's.
10521 (gnus-summary-display-article article)
10522 (gnus-eval-in-buffer-window gnus-article-buffer
10523 (setq endp (gnus-article-next-page lines)))
10526 (gnus-summary-beginning-of-article))
10528 (gnus-message 3 "End of message"))
10530 (if (and (eq gnus-summary-goto-unread 'never)
10531 (not (gnus-summary-last-article-p article)))
10532 (gnus-summary-next-article)
10533 (gnus-summary-next-unread-article)))))))
10534 (gnus-summary-recenter)
10535 (gnus-summary-position-point)))
10537 (defun gnus-summary-prev-page (&optional lines)
10538 "Show previous page of selected article.
10539 Argument LINES specifies lines to be scrolled down."
10541 (gnus-set-global-variables)
10542 (let ((article (gnus-summary-article-number)))
10543 (gnus-configure-windows 'article)
10544 (if (or (null gnus-current-article)
10545 (null gnus-article-current)
10546 (/= article (cdr gnus-article-current))
10547 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10548 ;; Selected subject is different from current article's.
10549 (gnus-summary-display-article article)
10550 (gnus-summary-recenter)
10551 (gnus-eval-in-buffer-window gnus-article-buffer
10552 (gnus-article-prev-page lines))))
10553 (gnus-summary-position-point))
10555 (defun gnus-summary-scroll-up (lines)
10556 "Scroll up (or down) one line current article.
10557 Argument LINES specifies lines to be scrolled up (or down if negative)."
10559 (gnus-set-global-variables)
10560 (gnus-configure-windows 'article)
10561 (gnus-summary-show-thread)
10562 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10563 (gnus-eval-in-buffer-window gnus-article-buffer
10565 (if (gnus-article-next-page lines)
10566 (gnus-message 3 "End of message")))
10568 (gnus-article-prev-page (- lines))))))
10569 (gnus-summary-recenter)
10570 (gnus-summary-position-point))
10572 (defun gnus-summary-next-same-subject ()
10573 "Select next article which has the same subject as current one."
10575 (gnus-set-global-variables)
10576 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10578 (defun gnus-summary-prev-same-subject ()
10579 "Select previous article which has the same subject as current one."
10581 (gnus-set-global-variables)
10582 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10584 (defun gnus-summary-next-unread-same-subject ()
10585 "Select next unread article which has the same subject as current one."
10587 (gnus-set-global-variables)
10588 (gnus-summary-next-article t (gnus-summary-article-subject)))
10590 (defun gnus-summary-prev-unread-same-subject ()
10591 "Select previous unread article which has the same subject as current one."
10593 (gnus-set-global-variables)
10594 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10596 (defun gnus-summary-first-unread-article ()
10597 "Select the first unread article.
10598 Return nil if there are no unread articles."
10600 (gnus-set-global-variables)
10602 (if (gnus-summary-first-subject t)
10604 (gnus-summary-show-thread)
10605 (gnus-summary-first-subject t)
10606 (gnus-summary-display-article (gnus-summary-article-number))))
10607 (gnus-summary-position-point)))
10609 (defun gnus-summary-best-unread-article ()
10610 "Select the unread article with the highest score."
10612 (gnus-set-global-variables)
10613 (let ((best -1000000)
10614 (data gnus-newsgroup-data)
10617 (and (gnus-data-unread-p (car data))
10619 (gnus-summary-article-score (gnus-data-number (car data))))
10622 article (gnus-data-number (car data))))
10623 (setq data (cdr data)))
10626 (gnus-summary-goto-article article)
10627 (error "No unread articles"))
10628 (gnus-summary-position-point))))
10630 (defun gnus-summary-last-subject ()
10631 "Go to the last displayed subject line in the group."
10632 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10634 (gnus-summary-goto-subject article))))
10636 (defun gnus-summary-goto-article (article &optional all-headers force)
10637 "Fetch ARTICLE and display it if it exists.
10638 If ALL-HEADERS is non-nil, no header lines are hidden."
10644 (mapcar (lambda (number) (list (int-to-string number)))
10645 gnus-newsgroup-limit)))
10649 (if (gnus-summary-goto-subject article force)
10650 (gnus-summary-display-article article all-headers)
10651 (gnus-message 4 "Couldn't go to article %s" article) nil)
10652 (gnus-summary-position-point)))
10654 (defun gnus-summary-goto-last-article ()
10655 "Go to the previously read article."
10658 (and gnus-last-article
10659 (gnus-summary-goto-article gnus-last-article))
10660 (gnus-summary-position-point)))
10662 (defun gnus-summary-pop-article (number)
10663 "Pop one article off the history and go to the previous.
10664 NUMBER articles will be popped off."
10667 (setq gnus-newsgroup-history
10668 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10670 (gnus-summary-goto-article (car to))
10671 (error "Article history empty")))
10672 (gnus-summary-position-point))
10674 ;; Summary commands and functions for limiting the summary buffer.
10676 (defun gnus-summary-limit-to-articles (n)
10677 "Limit the summary buffer to the next N articles.
10678 If not given a prefix, use the process marked articles instead."
10680 (gnus-set-global-variables)
10682 (let ((articles (gnus-summary-work-articles n)))
10683 (setq gnus-newsgroup-processable nil)
10684 (gnus-summary-limit articles))
10685 (gnus-summary-position-point)))
10687 (defun gnus-summary-pop-limit (&optional total)
10688 "Restore the previous limit.
10689 If given a prefix, remove all limits."
10691 (gnus-set-global-variables)
10693 (setq gnus-newsgroup-limits
10694 (list (mapcar (lambda (h) (mail-header-number h))
10695 gnus-newsgroup-headers))))
10696 (unless gnus-newsgroup-limits
10697 (error "No limit to pop"))
10699 (gnus-summary-limit nil 'pop)
10700 (gnus-summary-position-point)))
10702 (defun gnus-summary-limit-to-subject (subject &optional header)
10703 "Limit the summary buffer to articles that have subjects that match a regexp."
10704 (interactive "sRegexp: ")
10706 (setq header "subject"))
10707 (when (not (equal "" subject))
10709 (let ((articles (gnus-summary-find-matching
10710 (or header "subject") subject 'all)))
10711 (or articles (error "Found no matches for \"%s\"" subject))
10712 (gnus-summary-limit articles))
10713 (gnus-summary-position-point))))
10715 (defun gnus-summary-limit-to-author (from)
10716 "Limit the summary buffer to articles that have authors that match a regexp."
10717 (interactive "sRegexp: ")
10718 (gnus-summary-limit-to-subject from "from"))
10720 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10722 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10724 (defun gnus-summary-limit-to-unread (&optional all)
10725 "Limit the summary buffer to articles that are not marked as read.
10726 If ALL is non-nil, limit strictly to unread articles."
10729 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10730 (gnus-summary-limit-to-marks
10731 ;; Concat all the marks that say that an article is read and have
10733 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10734 gnus-killed-mark gnus-kill-file-mark
10735 gnus-low-score-mark gnus-expirable-mark
10736 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10739 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10740 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10742 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10743 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10744 If REVERSE, limit the summary buffer to articles that are not marked
10745 with MARKS. MARKS can either be a string of marks or a list of marks.
10746 Returns how many articles were removed."
10747 (interactive "sMarks: ")
10748 (gnus-set-global-variables)
10750 (let ((data gnus-newsgroup-data)
10751 (marks (if (listp marks) marks
10752 (append marks nil))) ; Transform to list.
10755 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10756 (memq (gnus-data-mark (car data)) marks))
10757 (setq articles (cons (gnus-data-number (car data)) articles)))
10758 (setq data (cdr data)))
10759 (gnus-summary-limit articles))
10760 (gnus-summary-position-point)))
10762 (defun gnus-summary-limit-to-score (&optional score)
10763 "Limit to articles with score at or above SCORE."
10765 (gnus-set-global-variables)
10766 (setq score (if score
10767 (prefix-numeric-value score)
10768 (or gnus-summary-default-score 0)))
10769 (let ((data gnus-newsgroup-data)
10772 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10774 (push (gnus-data-number (car data)) articles))
10775 (setq data (cdr data)))
10777 (gnus-summary-limit articles)
10778 (gnus-summary-position-point))))
10780 (defun gnus-summary-limit-include-dormant ()
10781 "Display all the hidden articles that are marked as dormant."
10783 (gnus-set-global-variables)
10784 (or gnus-newsgroup-dormant
10785 (error "There are no dormant articles in this group"))
10787 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10788 (gnus-summary-position-point)))
10790 (defun gnus-summary-limit-exclude-dormant ()
10791 "Hide all dormant articles."
10793 (gnus-set-global-variables)
10795 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10796 (gnus-summary-position-point)))
10798 (defun gnus-summary-limit-exclude-childless-dormant ()
10799 "Hide all dormant articles that have no children."
10801 (gnus-set-global-variables)
10802 (let ((data (gnus-data-list t))
10803 articles d children)
10804 ;; Find all articles that are either not dormant or have
10806 (while (setq d (pop data))
10807 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10808 (and (setq children
10809 (gnus-article-children (gnus-data-number d)))
10812 (when (memq (car children) articles)
10817 (push (gnus-data-number d) articles)))
10818 ;; Do the limiting.
10820 (gnus-summary-limit articles)
10821 (gnus-summary-position-point))))
10823 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10824 "Mark all unread excluded articles as read.
10825 If ALL, mark even excluded ticked and dormants as read."
10827 (let ((articles (gnus-sorted-complement
10829 (mapcar (lambda (h) (mail-header-number h))
10830 gnus-newsgroup-headers)
10832 (sort gnus-newsgroup-limit '<)))
10834 (setq gnus-newsgroup-unreads nil)
10836 (setq gnus-newsgroup-dormant nil
10837 gnus-newsgroup-marked nil
10838 gnus-newsgroup-reads
10840 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10841 gnus-newsgroup-reads))
10842 (while (setq article (pop articles))
10843 (unless (or (memq article gnus-newsgroup-dormant)
10844 (memq article gnus-newsgroup-marked))
10845 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10847 (defun gnus-summary-limit (articles &optional pop)
10849 ;; We pop the previous limit off the stack and use that.
10850 (setq articles (car gnus-newsgroup-limits)
10851 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10852 ;; We use the new limit, so we push the old limit on the stack.
10853 (setq gnus-newsgroup-limits
10854 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10856 (setq gnus-newsgroup-limit articles)
10857 (let ((total (length gnus-newsgroup-data))
10858 (data (gnus-data-find-list (gnus-summary-article-number)))
10860 ;; This will do all the work of generating the new summary buffer
10861 ;; according to the new limit.
10862 (gnus-summary-prepare)
10863 ;; Hide any threads, possibly.
10864 (and gnus-show-threads
10865 gnus-thread-hide-subtree
10866 (gnus-summary-hide-all-threads))
10867 ;; Try to return to the article you were at, or one in the
10870 ;; We try to find some article after the current one.
10872 (and (gnus-summary-goto-subject
10873 (gnus-data-number (car data)) nil t)
10876 (setq data (cdr data))))
10878 ;; If there is no data, that means that we were after the last
10879 ;; article. The same goes when we can't find any articles
10880 ;; after the current one.
10882 (goto-char (point-max))
10883 (gnus-summary-find-prev)))
10884 ;; We return how many articles were removed from the summary
10885 ;; buffer as a result of the new limit.
10886 (- total (length gnus-newsgroup-data))))
10888 (defsubst gnus-invisible-cut-children (threads)
10891 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
10896 (defsubst gnus-cut-thread (thread)
10897 "Go forwards in the thread until we find an article that we want to display."
10898 (when (or (eq gnus-fetch-old-headers 'some)
10899 (eq gnus-build-sparse-threads 'some)
10900 (eq gnus-build-sparse-threads 'more))
10901 ;; Deal with old-fetched headers and sparse threads.
10905 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10906 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
10907 (or (<= (length (cdr thread)) 1)
10908 (gnus-invisible-cut-children (cdr thread))))
10909 (setq thread (cadr thread))))
10912 (defun gnus-cut-threads (threads)
10913 "Cut off all uninteresting articles from the beginning of threads."
10914 (when (or (eq gnus-fetch-old-headers 'some)
10915 (eq gnus-build-sparse-threads 'some)
10916 (eq gnus-build-sparse-threads 'more))
10917 (let ((th threads))
10919 (setcar th (gnus-cut-thread (car th)))
10920 (setq th (cdr th)))))
10921 ;; Remove nixed out threads.
10922 (delq nil threads))
10924 (defun gnus-summary-initial-limit (&optional show-if-empty)
10925 "Figure out what the initial limit is supposed to be on group entry.
10926 This entails weeding out unwanted dormants, low-scored articles,
10927 fetch-old-headers verbiage, and so on."
10928 ;; Most groups have nothing to remove.
10929 (if (or gnus-inhibit-limiting
10930 (and (null gnus-newsgroup-dormant)
10931 (not (eq gnus-fetch-old-headers 'some))
10932 (null gnus-summary-expunge-below)
10933 (not (eq gnus-build-sparse-threads 'some))
10934 (not (eq gnus-build-sparse-threads 'more))
10935 (null gnus-thread-expunge-below)
10936 (not gnus-use-nocem)))
10938 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10939 (setq gnus-newsgroup-limit nil)
10942 (unless (car (symbol-value node))
10943 ;; These threads have no parents -- they are roots.
10944 (let ((nodes (cdr (symbol-value node)))
10947 (if (and gnus-thread-expunge-below
10948 (< (gnus-thread-total-score (car nodes))
10949 gnus-thread-expunge-below))
10950 (gnus-expunge-thread (pop nodes))
10951 (setq thread (pop nodes))
10952 (gnus-summary-limit-children thread))))))
10953 gnus-newsgroup-dependencies)
10954 ;; If this limitation resulted in an empty group, we might
10955 ;; pop the previous limit and use it instead.
10956 (when (and (not gnus-newsgroup-limit)
10958 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10959 gnus-newsgroup-limit))
10961 (defun gnus-summary-limit-children (thread)
10962 "Return 1 if this subthread is visible and 0 if it is not."
10963 ;; First we get the number of visible children to this thread. This
10964 ;; is done by recursing down the thread using this function, so this
10965 ;; will really go down to a leaf article first, before slowly
10966 ;; working its way up towards the root.
10970 (apply '+ (mapcar 'gnus-summary-limit-children
10973 (number (mail-header-number (car thread)))
10976 ;; If this article is dormant and has absolutely no visible
10977 ;; children, then this article isn't visible.
10978 (and (memq number gnus-newsgroup-dormant)
10980 ;; If this is "fetch-old-headered" and there is only one
10981 ;; visible child (or less), then we don't want this article.
10982 (and (eq gnus-fetch-old-headers 'some)
10983 (memq number gnus-newsgroup-ancient)
10985 ;; If this is a sparsely inserted article with no children,
10986 ;; we don't want it.
10987 (and (eq gnus-build-sparse-threads 'some)
10988 (memq number gnus-newsgroup-sparse)
10990 ;; If we use expunging, and this article is really
10991 ;; low-scored, then we don't want this article.
10992 (when (and gnus-summary-expunge-below
10994 (or (cdr (assq number gnus-newsgroup-scored))
10995 gnus-summary-default-score))
10996 gnus-summary-expunge-below))
10997 ;; We increase the expunge-tally here, but that has
10998 ;; nothing to do with the limits, really.
10999 (incf gnus-newsgroup-expunged-tally)
11000 ;; We also mark as read here, if that's wanted.
11001 (when (and gnus-summary-mark-below
11002 (< score gnus-summary-mark-below))
11003 (setq gnus-newsgroup-unreads
11004 (delq number gnus-newsgroup-unreads))
11005 (if gnus-newsgroup-auto-expire
11006 (push number gnus-newsgroup-expirable)
11007 (push (cons number gnus-low-score-mark)
11008 gnus-newsgroup-reads)))
11010 (and gnus-use-nocem
11011 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
11012 ;; Nope, invisible article.
11014 ;; Ok, this article is to be visible, so we add it to the limit
11016 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
11019 (defun gnus-expunge-thread (thread)
11020 "Mark all articles in THREAD as read."
11021 (let* ((number (mail-header-number (car thread))))
11022 (incf gnus-newsgroup-expunged-tally)
11023 ;; We also mark as read here, if that's wanted.
11024 (setq gnus-newsgroup-unreads
11025 (delq number gnus-newsgroup-unreads))
11026 (if gnus-newsgroup-auto-expire
11027 (push number gnus-newsgroup-expirable)
11028 (push (cons number gnus-low-score-mark)
11029 gnus-newsgroup-reads)))
11030 ;; Go recursively through all subthreads.
11031 (mapcar 'gnus-expunge-thread (cdr thread)))
11033 ;; Summary article oriented commands
11035 (defun gnus-summary-refer-parent-article (n)
11036 "Refer parent article N times.
11037 The difference between N and the number of articles fetched is returned."
11039 (gnus-set-global-variables)
11043 (let* ((header (gnus-summary-article-header))
11045 ;; If we try to find the parent of the currently
11046 ;; displayed article, then we take a look at the actual
11047 ;; References header, since this is slightly more
11048 ;; reliable than the References field we got from the
11050 (if (and (eq (mail-header-number header)
11051 (cdr gnus-article-current))
11052 (equal gnus-newsgroup-name
11053 (car gnus-article-current)))
11055 (set-buffer gnus-original-article-buffer)
11056 (nnheader-narrow-to-headers)
11058 (message-fetch-field "references")
11060 ;; It's not the current article, so we take a bet on
11061 ;; the value we got from the server.
11062 (mail-header-references header))))
11063 (if (setq ref (or ref (mail-header-references header)))
11064 (or (gnus-summary-refer-article (gnus-parent-id ref))
11065 (gnus-message 1 "Couldn't find parent"))
11066 (gnus-message 1 "No references in article %d"
11067 (gnus-summary-article-number))
11070 (gnus-summary-position-point)
11073 (defun gnus-summary-refer-references ()
11074 "Fetch all articles mentioned in the References header.
11075 Return how many articles were fetched."
11077 (gnus-set-global-variables)
11078 (let ((ref (mail-header-references (gnus-summary-article-header)))
11079 (current (gnus-summary-article-number))
11081 ;; For each Message-ID in the References header...
11082 (while (string-match "<[^>]*>" ref)
11084 ;; ... fetch that article.
11085 (gnus-summary-refer-article
11086 (prog1 (match-string 0 ref)
11087 (setq ref (substring ref (match-end 0))))))
11088 (gnus-summary-goto-subject current)
11089 (gnus-summary-position-point)
11092 (defun gnus-summary-refer-article (message-id)
11093 "Fetch an article specified by MESSAGE-ID."
11094 (interactive "sMessage-ID: ")
11095 (when (and (stringp message-id)
11096 (not (zerop (length message-id))))
11097 ;; Construct the correct Message-ID if necessary.
11098 ;; Suggested by tale@pawl.rpi.edu.
11099 (unless (string-match "^<" message-id)
11100 (setq message-id (concat "<" message-id)))
11101 (unless (string-match ">$" message-id)
11102 (setq message-id (concat message-id ">")))
11103 (let* ((header (gnus-id-to-header message-id))
11104 (sparse (and header
11105 (memq (mail-header-number header)
11106 gnus-newsgroup-sparse))))
11109 ;; The article is present in the buffer, to we just go to it.
11110 (gnus-summary-goto-article
11111 (mail-header-number header) nil header)
11113 (gnus-summary-update-article (mail-header-number header))))
11114 ;; We fetch the article
11115 (let ((gnus-override-method
11116 (and (gnus-news-group-p gnus-newsgroup-name)
11117 gnus-refer-article-method))
11119 ;; Start the special refer-article method, if necessary.
11120 (when (and gnus-refer-article-method
11121 (gnus-news-group-p gnus-newsgroup-name))
11122 (gnus-check-server gnus-refer-article-method))
11123 ;; Fetch the header, and display the article.
11124 (if (setq number (gnus-summary-insert-subject message-id))
11125 (gnus-summary-select-article nil nil nil number)
11126 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
11128 (defun gnus-summary-enter-digest-group (&optional force)
11129 "Enter a digest group based on the current article."
11131 (gnus-set-global-variables)
11132 (gnus-summary-select-article)
11133 (let ((name (format "%s-%d"
11134 (gnus-group-prefixed-name
11135 gnus-newsgroup-name (list 'nndoc ""))
11136 gnus-current-article))
11137 (ogroup gnus-newsgroup-name)
11138 (case-fold-search t)
11139 (buf (current-buffer))
11142 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
11143 (insert-buffer-substring gnus-original-article-buffer)
11145 (goto-char (point-min))
11146 (or (search-forward "\n\n" nil t) (point)))
11147 (goto-char (point-min))
11148 (delete-matching-lines "^\\(Path\\):\\|^From ")
11151 (if (gnus-group-read-ephemeral-group
11152 name `(nndoc ,name (nndoc-address
11154 (nndoc-article-type ,(if force 'digest 'guess))) t)
11155 ;; Make all postings to this group go to the parent group.
11156 (nconc (gnus-info-params (gnus-get-info name))
11157 (list (cons 'to-group ogroup)))
11158 ;; Couldn't select this doc group.
11159 (switch-to-buffer buf)
11160 (gnus-set-global-variables)
11161 (gnus-configure-windows 'summary)
11162 (gnus-message 3 "Article couldn't be entered?"))
11163 (kill-buffer dig))))
11165 (defun gnus-summary-isearch-article (&optional regexp-p)
11166 "Do incremental search forward on the current article.
11167 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
11169 (gnus-set-global-variables)
11170 (gnus-summary-select-article)
11171 (gnus-configure-windows 'article)
11172 (gnus-eval-in-buffer-window gnus-article-buffer
11173 (goto-char (point-min))
11174 (isearch-forward regexp-p)))
11176 (defun gnus-summary-search-article-forward (regexp &optional backward)
11177 "Search for an article containing REGEXP forward.
11178 If BACKWARD, search backward instead."
11181 (format "Search article %s (regexp%s): "
11182 (if current-prefix-arg "backward" "forward")
11183 (if gnus-last-search-regexp
11184 (concat ", default " gnus-last-search-regexp)
11186 current-prefix-arg))
11187 (gnus-set-global-variables)
11188 (if (string-equal regexp "")
11189 (setq regexp (or gnus-last-search-regexp ""))
11190 (setq gnus-last-search-regexp regexp))
11191 (unless (gnus-summary-search-article regexp backward)
11192 (error "Search failed: \"%s\"" regexp)))
11194 (defun gnus-summary-search-article-backward (regexp)
11195 "Search for an article containing REGEXP backward."
11198 (format "Search article backward (regexp%s): "
11199 (if gnus-last-search-regexp
11200 (concat ", default " gnus-last-search-regexp)
11202 (gnus-summary-search-article-forward regexp 'backward))
11204 (defun gnus-summary-search-article (regexp &optional backward)
11205 "Search for an article containing REGEXP.
11206 Optional argument BACKWARD means do search for backward.
11207 `gnus-select-article-hook' is not called during the search."
11208 (let ((gnus-select-article-hook nil) ;Disable hook.
11209 (gnus-article-display-hook nil)
11210 (gnus-mark-article-hook nil) ;Inhibit marking as read.
11213 're-search-backward 're-search-forward))
11214 (sum (current-buffer))
11216 (gnus-save-hidden-threads
11217 (gnus-summary-select-article)
11218 (set-buffer gnus-article-buffer)
11222 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
11224 (re-search-backward regexp nil t)
11225 (re-search-forward regexp nil t))
11226 ;; We found the regexp.
11228 (setq found 'found)
11229 (beginning-of-line)
11231 (get-buffer-window (current-buffer))
11235 ;; We didn't find it, so we go to the next article.
11237 (if (not (if backward (gnus-summary-find-prev)
11238 (gnus-summary-find-next)))
11239 ;; No more articles.
11241 ;; Select the next article and adjust point.
11242 (gnus-summary-select-article)
11243 (set-buffer gnus-article-buffer)
11245 (goto-char (if backward (point-max) (point-min))))))
11246 (gnus-message 7 ""))
11247 ;; Return whether we found the regexp.
11248 (when (eq found 'found)
11249 (gnus-summary-show-thread)
11250 (gnus-summary-goto-subject gnus-current-article)
11251 (gnus-summary-position-point)
11254 (defun gnus-summary-find-matching (header regexp &optional backward unread
11256 "Return a list of all articles that match REGEXP on HEADER.
11257 The search stars on the current article and goes forwards unless
11258 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
11259 If UNREAD is non-nil, only unread articles will
11260 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
11261 in the comparisons."
11262 (let ((data (if (eq backward 'all) gnus-newsgroup-data
11263 (gnus-data-find-list
11264 (gnus-summary-article-number) (gnus-data-list backward))))
11265 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
11266 (case-fold-search (not not-case-fold))
11268 (or (fboundp (intern (concat "mail-header-" header)))
11269 (error "%s is not a valid header" header))
11271 (setq d (car data))
11272 (and (or (not unread) ; We want all articles...
11273 (gnus-data-unread-p d)) ; Or just unreads.
11274 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11275 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11276 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11277 (setq data (cdr data)))
11278 (nreverse articles)))
11280 (defun gnus-summary-execute-command (header regexp command &optional backward)
11281 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11282 If HEADER is an empty string (or nil), the match is done on the entire
11283 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11285 (list (let ((completion-ignore-case t))
11288 (mapcar (lambda (string) (list string))
11289 '("Number" "Subject" "From" "Lines" "Date"
11290 "Message-ID" "Xref" "References" "Body"))
11291 nil 'require-match))
11292 (read-string "Regexp: ")
11293 (read-key-sequence "Command: ")
11294 current-prefix-arg))
11295 (when (equal header "Body")
11297 (gnus-set-global-variables)
11298 ;; Hidden thread subtrees must be searched as well.
11299 (gnus-summary-show-all-threads)
11300 ;; We don't want to change current point nor window configuration.
11302 (save-window-excursion
11303 (gnus-message 6 "Executing %s..." (key-description command))
11304 ;; We'd like to execute COMMAND interactively so as to give arguments.
11305 (gnus-execute header regexp
11306 `(lambda () (call-interactively ',(key-binding command)))
11308 (gnus-message 6 "Executing %s...done" (key-description command)))))
11310 (defun gnus-summary-beginning-of-article ()
11311 "Scroll the article back to the beginning."
11313 (gnus-set-global-variables)
11314 (gnus-summary-select-article)
11315 (gnus-configure-windows 'article)
11316 (gnus-eval-in-buffer-window gnus-article-buffer
11318 (goto-char (point-min))
11319 (and gnus-break-pages (gnus-narrow-to-page))))
11321 (defun gnus-summary-end-of-article ()
11322 "Scroll to the end of the article."
11324 (gnus-set-global-variables)
11325 (gnus-summary-select-article)
11326 (gnus-configure-windows 'article)
11327 (gnus-eval-in-buffer-window gnus-article-buffer
11329 (goto-char (point-max))
11331 (and gnus-break-pages (gnus-narrow-to-page))))
11333 (defun gnus-summary-show-article (&optional arg)
11334 "Force re-fetching of the current article.
11335 If ARG (the prefix) is non-nil, show the raw article without any
11336 article massaging functions being run."
11338 (gnus-set-global-variables)
11340 ;; Select the article the normal way.
11341 (gnus-summary-select-article nil 'force)
11342 ;; Bind the article treatment functions to nil.
11343 (let ((gnus-have-all-headers t)
11344 gnus-article-display-hook
11345 gnus-article-prepare-hook
11348 (gnus-summary-select-article nil 'force)))
11349 (gnus-summary-goto-subject gnus-current-article)
11350 ; (gnus-configure-windows 'article)
11351 (gnus-summary-position-point))
11353 (defun gnus-summary-verbose-headers (&optional arg)
11354 "Toggle permanent full header display.
11355 If ARG is a positive number, turn header display on.
11356 If ARG is a negative number, turn header display off."
11358 (gnus-set-global-variables)
11359 (gnus-summary-toggle-header arg)
11360 (setq gnus-show-all-headers
11361 (cond ((or (not (numberp arg))
11363 (not gnus-show-all-headers))
11367 (defun gnus-summary-toggle-header (&optional arg)
11368 "Show the headers if they are hidden, or hide them if they are shown.
11369 If ARG is a positive number, show the entire header.
11370 If ARG is a negative number, hide the unwanted header lines."
11372 (gnus-set-global-variables)
11374 (set-buffer gnus-article-buffer)
11375 (let* ((buffer-read-only nil)
11376 (inhibit-point-motion-hooks t)
11377 (hidden (text-property-any
11378 (goto-char (point-min)) (search-forward "\n\n")
11381 (goto-char (point-min))
11382 (when (search-forward "\n\n" nil t)
11383 (delete-region (point-min) (1- (point))))
11384 (goto-char (point-min))
11386 (set-buffer gnus-original-article-buffer)
11387 (goto-char (point-min))
11388 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11389 (insert-buffer-substring gnus-original-article-buffer 1 e)
11390 (let ((gnus-inhibit-hiding t))
11391 (run-hooks 'gnus-article-display-hook))
11392 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11393 (gnus-article-hide-headers)))))
11395 (defun gnus-summary-show-all-headers ()
11396 "Make all header lines visible."
11398 (gnus-set-global-variables)
11399 (gnus-article-show-all-headers))
11401 (defun gnus-summary-toggle-mime (&optional arg)
11402 "Toggle MIME processing.
11403 If ARG is a positive number, turn MIME processing on."
11405 (gnus-set-global-variables)
11406 (setq gnus-show-mime
11407 (if (null arg) (not gnus-show-mime)
11408 (> (prefix-numeric-value arg) 0)))
11409 (gnus-summary-select-article t 'force))
11411 (defun gnus-summary-caesar-message (&optional arg)
11412 "Caesar rotate the current article by 13.
11413 The numerical prefix specifies how manu places to rotate each letter
11416 (gnus-set-global-variables)
11417 (gnus-summary-select-article)
11418 (let ((mail-header-separator ""))
11419 (gnus-eval-in-buffer-window gnus-article-buffer
11422 (let ((start (window-start))
11424 (message-caesar-buffer-body arg)
11425 (set-window-start (get-buffer-window (current-buffer)) start))))))
11427 (defun gnus-summary-stop-page-breaking ()
11428 "Stop page breaking in the current article."
11430 (gnus-set-global-variables)
11431 (gnus-summary-select-article)
11432 (gnus-eval-in-buffer-window gnus-article-buffer
11435 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11436 "Move the current article to a different newsgroup.
11437 If N is a positive number, move the N next articles.
11438 If N is a negative number, move the N previous articles.
11439 If N is nil and any articles have been marked with the process mark,
11440 move those articles instead.
11441 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11442 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11443 re-spool using this method.
11445 For this function to work, both the current newsgroup and the
11446 newsgroup that you want to move to have to support the `request-move'
11447 and `request-accept' functions."
11449 (unless action (setq action 'move))
11450 (gnus-set-global-variables)
11451 ;; Check whether the source group supports the required functions.
11452 (cond ((and (eq action 'move)
11453 (not (gnus-check-backend-function
11454 'request-move-article gnus-newsgroup-name)))
11455 (error "The current group does not support article moving"))
11456 ((and (eq action 'crosspost)
11457 (not (gnus-check-backend-function
11458 'request-replace-article gnus-newsgroup-name)))
11459 (error "The current group does not support article editing")))
11460 (let ((articles (gnus-summary-work-articles n))
11461 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11462 (names '((move "Move" "Moving")
11463 (copy "Copy" "Copying")
11464 (crosspost "Crosspost" "Crossposting")))
11465 (copy-buf (save-excursion
11466 (nnheader-set-temp-buffer " *copy article*")))
11467 art-group to-method new-xref article to-groups)
11468 (unless (assq action names)
11469 (error "Unknown action %s" action))
11470 ;; Read the newsgroup name.
11471 (when (and (not to-newsgroup)
11472 (not select-method))
11474 (gnus-read-move-group-name
11475 (cadr (assq action names))
11476 (symbol-value (intern (format "gnus-current-%s-group" action)))
11478 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11479 (setq to-method (or select-method
11480 (gnus-find-method-for-group to-newsgroup)))
11481 ;; Check the method we are to move this article to...
11482 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11483 (error "%s does not support article copying" (car to-method)))
11484 (or (gnus-check-server to-method)
11485 (error "Can't open server %s" (car to-method)))
11486 (gnus-message 6 "%s to %s: %s..."
11487 (caddr (assq action names))
11488 (or (car select-method) to-newsgroup) articles)
11490 (setq article (pop articles))
11494 ;; Move the article.
11496 (gnus-request-move-article
11497 article ; Article to move
11498 gnus-newsgroup-name ; From newsgrouo
11499 (nth 1 (gnus-find-method-for-group
11500 gnus-newsgroup-name)) ; Server
11501 (list 'gnus-request-accept-article
11502 to-newsgroup (list 'quote select-method)
11503 (not articles)) ; Accept form
11504 (not articles))) ; Only save nov last time
11505 ;; Copy the article.
11508 (set-buffer copy-buf)
11509 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11510 (gnus-request-accept-article
11511 to-newsgroup select-method (not articles))))
11512 ;; Crosspost the article.
11513 ((eq action 'crosspost)
11514 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11515 (setq new-xref (concat gnus-newsgroup-name ":" article))
11516 (if (and xref (not (string= xref "")))
11518 (when (string-match "^Xref: " xref)
11519 (setq xref (substring xref (match-end 0))))
11520 (setq new-xref (concat xref " " new-xref)))
11521 (setq new-xref (concat (system-name) " " new-xref)))
11523 (set-buffer copy-buf)
11524 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11525 (nnheader-replace-header "xref" new-xref)
11526 (gnus-request-accept-article
11527 to-newsgroup select-method (not articles)))))))
11528 (if (not art-group)
11529 (gnus-message 1 "Couldn't %s article %s"
11530 (cadr (assq action names)) article)
11533 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11535 (gnus-group-prefixed-name
11538 (gnus-find-method-for-group to-newsgroup)))
11539 gnus-newsrc-hashtb)))
11540 (info (nth 2 entry))
11541 (to-group (gnus-info-group info)))
11542 ;; Update the group that has been moved to.
11544 (memq action '(move copy)))
11545 (unless (member to-group to-groups)
11546 (push to-group to-groups))
11548 (unless (memq article gnus-newsgroup-unreads)
11549 (gnus-info-set-read
11550 info (gnus-add-to-range (gnus-info-read info)
11551 (list (cdr art-group)))))
11553 ;; Copy any marks over to the new group.
11554 (let ((marks gnus-article-mark-lists)
11555 (to-article (cdr art-group)))
11557 ;; See whether the article is to be put in the cache.
11558 (when gnus-use-cache
11559 (gnus-cache-possibly-enter-article
11560 to-group to-article
11561 (let ((header (copy-sequence
11562 (gnus-summary-article-header article))))
11563 (mail-header-set-number header to-article)
11565 (memq article gnus-newsgroup-marked)
11566 (memq article gnus-newsgroup-dormant)
11567 (memq article gnus-newsgroup-unreads)))
11570 (when (memq article (symbol-value
11571 (intern (format "gnus-newsgroup-%s"
11573 ;; If the other group is the same as this group,
11574 ;; then we have to add the mark to the list.
11575 (when (equal to-group gnus-newsgroup-name)
11576 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11579 (intern (format "gnus-newsgroup-%s"
11581 ;; Copy mark to other group.
11582 (gnus-add-marked-articles
11583 to-group (cdar marks) (list to-article) info))
11584 (setq marks (cdr marks)))))
11586 ;; Update the Xref header in this article to point to
11587 ;; the new crossposted article we have just created.
11588 (when (eq action 'crosspost)
11590 (set-buffer copy-buf)
11591 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11592 (nnheader-replace-header
11593 "xref" (concat new-xref " " (gnus-group-prefixed-name
11594 (car art-group) to-method)
11595 ":" (cdr art-group)))
11596 (gnus-request-replace-article
11597 article gnus-newsgroup-name (current-buffer)))))
11599 (gnus-summary-goto-subject article)
11600 (when (eq action 'move)
11601 (gnus-summary-mark-article article gnus-canceled-mark)))
11602 (gnus-summary-remove-process-mark article))
11603 ;; Re-activate all groups that have been moved to.
11605 (gnus-activate-group (pop to-groups)))
11607 (gnus-kill-buffer copy-buf)
11608 (gnus-summary-position-point)
11609 (gnus-set-mode-line 'summary)))
11611 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11612 "Move the current article to a different newsgroup.
11613 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11614 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11615 re-spool using this method."
11617 (gnus-summary-move-article n nil select-method 'copy))
11619 (defun gnus-summary-crosspost-article (&optional n)
11620 "Crosspost the current article to some other group."
11622 (gnus-summary-move-article n nil nil 'crosspost))
11624 (defvar gnus-summary-respool-default-method nil
11625 "Default method for respooling an article.
11626 If nil, use to the current newsgroup method.")
11628 (defun gnus-summary-respool-article (&optional n method)
11629 "Respool the current article.
11630 The article will be squeezed through the mail spooling process again,
11631 which means that it will be put in some mail newsgroup or other
11632 depending on `nnmail-split-methods'.
11633 If N is a positive number, respool the N next articles.
11634 If N is a negative number, respool the N previous articles.
11635 If N is nil and any articles have been marked with the process mark,
11636 respool those articles instead.
11638 Respooling can be done both from mail groups and \"real\" newsgroups.
11639 In the former case, the articles in question will be moved from the
11640 current group into whatever groups they are destined to. In the
11641 latter case, they will be copied into the relevant groups."
11643 (list current-prefix-arg
11644 (let* ((methods (gnus-methods-using 'respool))
11646 (symbol-name (or gnus-summary-respool-default-method
11647 (car (gnus-find-method-for-group
11648 gnus-newsgroup-name)))))
11650 (gnus-completing-read
11651 methname "What backend do you want to use when? "
11652 methods nil t nil 'gnus-method-history))
11655 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11656 (list (intern method) ""))
11660 (cdr (completing-read
11662 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11663 (gnus-set-global-variables)
11665 (error "No method given for respooling"))
11666 (if (assoc (symbol-name
11667 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11668 (gnus-methods-using 'respool))
11669 (gnus-summary-move-article n nil method)
11670 (gnus-summary-copy-article n nil method)))
11672 (defun gnus-summary-import-article (file)
11673 "Import a random file into a mail newsgroup."
11674 (interactive "fImport file: ")
11675 (gnus-set-global-variables)
11676 (let ((group gnus-newsgroup-name)
11677 (now (current-time))
11679 (or (gnus-check-backend-function 'request-accept-article group)
11680 (error "%s does not support article importing" group))
11681 (or (file-readable-p file)
11682 (not (file-regular-p file))
11683 (error "Can't read %s" file))
11685 (set-buffer (get-buffer-create " *import file*"))
11686 (buffer-disable-undo (current-buffer))
11688 (insert-file-contents file)
11689 (goto-char (point-min))
11690 (unless (nnheader-article-p)
11691 ;; This doesn't look like an article, so we fudge some headers.
11692 (setq atts (file-attributes file)
11693 lines (count-lines (point-min) (point-max)))
11694 (insert "From: " (read-string "From: ") "\n"
11695 "Subject: " (read-string "Subject: ") "\n"
11696 "Date: " (timezone-make-date-arpa-standard
11697 (current-time-string (nth 5 atts))
11698 (current-time-zone now)
11699 (current-time-zone now)) "\n"
11700 "Message-ID: " (message-make-message-id) "\n"
11701 "Lines: " (int-to-string lines) "\n"
11702 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11703 (gnus-request-accept-article group nil t)
11704 (kill-buffer (current-buffer)))))
11706 (defun gnus-summary-expire-articles (&optional now)
11707 "Expire all articles that are marked as expirable in the current group."
11709 (gnus-set-global-variables)
11710 (when (gnus-check-backend-function
11711 'request-expire-articles gnus-newsgroup-name)
11712 ;; This backend supports expiry.
11713 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11714 (expirable (if total
11715 (gnus-list-of-read-articles gnus-newsgroup-name)
11716 (setq gnus-newsgroup-expirable
11717 (sort gnus-newsgroup-expirable '<))))
11718 (expiry-wait (if now 'immediate
11719 (gnus-group-get-parameter
11720 gnus-newsgroup-name 'expiry-wait)))
11723 ;; There are expirable articles in this group, so we run them
11724 ;; through the expiry process.
11725 (gnus-message 6 "Expiring articles...")
11726 ;; The list of articles that weren't expired is returned.
11728 (let ((nnmail-expiry-wait-function nil)
11729 (nnmail-expiry-wait expiry-wait))
11730 (setq es (gnus-request-expire-articles
11731 expirable gnus-newsgroup-name)))
11732 (setq es (gnus-request-expire-articles
11733 expirable gnus-newsgroup-name)))
11734 (or total (setq gnus-newsgroup-expirable es))
11735 ;; We go through the old list of expirable, and mark all
11736 ;; really expired articles as nonexistent.
11737 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11738 (let ((gnus-use-cache nil))
11740 (unless (memq (car expirable) es)
11741 (when (gnus-data-find (car expirable))
11742 (gnus-summary-mark-article
11743 (car expirable) gnus-canceled-mark)))
11744 (setq expirable (cdr expirable)))))
11745 (gnus-message 6 "Expiring articles...done")))))
11747 (defun gnus-summary-expire-articles-now ()
11748 "Expunge all expirable articles in the current group.
11749 This means that *all* articles that are marked as expirable will be
11750 deleted forever, right now."
11752 (gnus-set-global-variables)
11753 (or gnus-expert-user
11755 "Are you really, really, really sure you want to delete all these messages? ")
11757 (gnus-summary-expire-articles t))
11759 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11760 (defun gnus-summary-delete-article (&optional n)
11761 "Delete the N next (mail) articles.
11762 This command actually deletes articles. This is not a marking
11763 command. The article will disappear forever from your life, never to
11765 If N is negative, delete backwards.
11766 If N is nil and articles have been marked with the process mark,
11767 delete these instead."
11769 (gnus-set-global-variables)
11770 (or (gnus-check-backend-function 'request-expire-articles
11771 gnus-newsgroup-name)
11772 (error "The current newsgroup does not support article deletion."))
11773 ;; Compute the list of articles to delete.
11774 (let ((articles (gnus-summary-work-articles n))
11776 (if (and gnus-novice-user
11777 (not (gnus-y-or-n-p
11778 (format "Do you really want to delete %s forever? "
11779 (if (> (length articles) 1)
11780 (format "these %s articles" (length articles))
11781 "this article")))))
11783 ;; Delete the articles.
11784 (setq not-deleted (gnus-request-expire-articles
11785 articles gnus-newsgroup-name 'force))
11787 (gnus-summary-remove-process-mark (car articles))
11788 ;; The backend might not have been able to delete the article
11790 (or (memq (car articles) not-deleted)
11791 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11792 (setq articles (cdr articles))))
11793 (gnus-summary-position-point)
11794 (gnus-set-mode-line 'summary)
11797 (defun gnus-summary-edit-article (&optional force)
11798 "Enter into a buffer and edit the current article.
11799 This will have permanent effect only in mail groups.
11800 If FORCE is non-nil, allow editing of articles even in read-only
11804 (set-buffer gnus-summary-buffer)
11805 (gnus-set-global-variables)
11806 (when (and (not force)
11807 (gnus-group-read-only-p))
11808 (error "The current newsgroup does not support article editing."))
11809 (gnus-summary-select-article t nil t)
11810 (gnus-configure-windows 'article)
11811 (select-window (get-buffer-window gnus-article-buffer))
11812 (gnus-message 6 "C-c C-c to end edits")
11813 (setq buffer-read-only nil)
11815 (use-local-map (copy-keymap (current-local-map)))
11816 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11817 (buffer-enable-undo)
11819 (goto-char (point-min))
11820 (search-forward "\n\n" nil t)))
11822 (defun gnus-summary-edit-article-done ()
11823 "Make edits to the current article permanent."
11825 (if (gnus-group-read-only-p)
11827 (gnus-summary-edit-article-postpone)
11829 1 "The current newsgroup does not support article editing."))
11830 (let ((buf (format "%s" (buffer-string))))
11833 (if (not (gnus-request-replace-article
11834 (cdr gnus-article-current) (car gnus-article-current)
11836 (error "Couldn't replace article.")
11837 (gnus-article-mode)
11838 (use-local-map gnus-article-mode-map)
11839 (setq buffer-read-only t)
11840 (buffer-disable-undo (current-buffer))
11841 (gnus-configure-windows 'summary)
11842 (gnus-summary-update-article (cdr gnus-article-current))
11843 (when gnus-use-cache
11844 (gnus-cache-update-article
11845 (car gnus-article-current) (cdr gnus-article-current)))
11846 (when gnus-keep-backlog
11847 (gnus-backlog-remove-article
11848 (car gnus-article-current) (cdr gnus-article-current))))
11850 (when (get-buffer gnus-original-article-buffer)
11851 (set-buffer gnus-original-article-buffer)
11852 (setq gnus-original-article nil)))
11853 (setq gnus-article-current nil
11854 gnus-current-article nil)
11855 (run-hooks 'gnus-article-display-hook)
11856 (and (gnus-visual-p 'summary-highlight 'highlight)
11857 (run-hooks 'gnus-visual-mark-article-hook)))))
11859 (defun gnus-summary-edit-article-postpone ()
11860 "Postpone changes to the current article."
11862 (gnus-article-mode)
11863 (use-local-map gnus-article-mode-map)
11864 (setq buffer-read-only t)
11865 (buffer-disable-undo (current-buffer))
11866 (gnus-configure-windows 'summary)
11867 (and (gnus-visual-p 'summary-highlight 'highlight)
11868 (run-hooks 'gnus-visual-mark-article-hook)))
11870 (defun gnus-summary-respool-query ()
11871 "Query where the respool algorithm would put this article."
11873 (gnus-set-global-variables)
11874 (gnus-summary-select-article)
11876 (set-buffer gnus-article-buffer)
11878 (goto-char (point-min))
11879 (search-forward "\n\n")
11880 (narrow-to-region (point-min) (point))
11881 (pp-eval-expression
11882 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11884 ;; Summary marking commands.
11886 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11887 "Mark articles which has the same subject as read, and then select the next.
11888 If UNMARK is positive, remove any kind of mark.
11889 If UNMARK is negative, tick articles."
11891 (gnus-set-global-variables)
11893 (setq unmark (prefix-numeric-value unmark)))
11895 (gnus-summary-mark-same-subject
11896 (gnus-summary-article-subject) unmark)))
11897 ;; Select next unread article. If auto-select-same mode, should
11898 ;; select the first unread article.
11899 (gnus-summary-next-article t (and gnus-auto-select-same
11900 (gnus-summary-article-subject)))
11901 (gnus-message 7 "%d article%s marked as %s"
11902 count (if (= count 1) " is" "s are")
11903 (if unmark "unread" "read"))))
11905 (defun gnus-summary-kill-same-subject (&optional unmark)
11906 "Mark articles which has the same subject as read.
11907 If UNMARK is positive, remove any kind of mark.
11908 If UNMARK is negative, tick articles."
11910 (gnus-set-global-variables)
11912 (setq unmark (prefix-numeric-value unmark)))
11914 (gnus-summary-mark-same-subject
11915 (gnus-summary-article-subject) unmark)))
11916 ;; If marked as read, go to next unread subject.
11918 ;; Go to next unread subject.
11919 (gnus-summary-next-subject 1 t))
11920 (gnus-message 7 "%d articles are marked as %s"
11921 count (if unmark "unread" "read"))))
11923 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11924 "Mark articles with same SUBJECT as read, and return marked number.
11925 If optional argument UNMARK is positive, remove any kinds of marks.
11926 If optional argument UNMARK is negative, mark articles as unread instead."
11930 ((null unmark) ; Mark as read.
11933 (gnus-summary-mark-article-as-read gnus-killed-mark)
11934 (gnus-summary-show-thread) t)
11935 (gnus-summary-find-subject subject))
11936 (setq count (1+ count))))
11937 ((> unmark 0) ; Tick.
11940 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11941 (gnus-summary-show-thread) t)
11942 (gnus-summary-find-subject subject))
11943 (setq count (1+ count))))
11944 (t ; Mark as unread.
11947 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11948 (gnus-summary-show-thread) t)
11949 (gnus-summary-find-subject subject))
11950 (setq count (1+ count)))))
11951 (gnus-set-mode-line 'summary)
11952 ;; Return the number of marked articles.
11955 (defun gnus-summary-mark-as-processable (n &optional unmark)
11956 "Set the process mark on the next N articles.
11957 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11958 the process mark instead. The difference between N and the actual
11959 number of articles marked is returned."
11961 (gnus-set-global-variables)
11962 (let ((backward (< n 0))
11967 (gnus-summary-remove-process-mark
11968 (gnus-summary-article-number))
11969 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11970 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11972 (if (/= 0 n) (gnus-message 7 "No more articles"))
11973 (gnus-summary-recenter)
11974 (gnus-summary-position-point)
11977 (defun gnus-summary-unmark-as-processable (n)
11978 "Remove the process mark from the next N articles.
11979 If N is negative, mark backward instead. The difference between N and
11980 the actual number of articles marked is returned."
11982 (gnus-set-global-variables)
11983 (gnus-summary-mark-as-processable n t))
11985 (defun gnus-summary-unmark-all-processable ()
11986 "Remove the process mark from all articles."
11988 (gnus-set-global-variables)
11990 (while gnus-newsgroup-processable
11991 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11992 (gnus-summary-position-point))
11994 (defun gnus-summary-mark-as-expirable (n)
11995 "Mark N articles forward as expirable.
11996 If N is negative, mark backward instead. The difference between N and
11997 the actual number of articles marked is returned."
11999 (gnus-set-global-variables)
12000 (gnus-summary-mark-forward n gnus-expirable-mark))
12002 (defun gnus-summary-mark-article-as-replied (article)
12003 "Mark ARTICLE replied and update the summary line."
12004 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
12005 (let ((buffer-read-only nil))
12006 (when (gnus-summary-goto-subject article)
12007 (gnus-summary-update-secondary-mark article))))
12009 (defun gnus-summary-set-bookmark (article)
12010 "Set a bookmark in current article."
12011 (interactive (list (gnus-summary-article-number)))
12012 (gnus-set-global-variables)
12013 (if (or (not (get-buffer gnus-article-buffer))
12014 (not gnus-current-article)
12015 (not gnus-article-current)
12016 (not (equal gnus-newsgroup-name (car gnus-article-current))))
12017 (error "No current article selected"))
12018 ;; Remove old bookmark, if one exists.
12019 (let ((old (assq article gnus-newsgroup-bookmarks)))
12020 (if old (setq gnus-newsgroup-bookmarks
12021 (delq old gnus-newsgroup-bookmarks))))
12022 ;; Set the new bookmark, which is on the form
12023 ;; (article-number . line-number-in-body).
12024 (setq gnus-newsgroup-bookmarks
12028 (set-buffer gnus-article-buffer)
12032 (goto-char (point-min))
12033 (search-forward "\n\n" nil t)
12036 gnus-newsgroup-bookmarks))
12037 (gnus-message 6 "A bookmark has been added to the current article."))
12039 (defun gnus-summary-remove-bookmark (article)
12040 "Remove the bookmark from the current article."
12041 (interactive (list (gnus-summary-article-number)))
12042 (gnus-set-global-variables)
12043 ;; Remove old bookmark, if one exists.
12044 (let ((old (assq article gnus-newsgroup-bookmarks)))
12047 (setq gnus-newsgroup-bookmarks
12048 (delq old gnus-newsgroup-bookmarks))
12049 (gnus-message 6 "Removed bookmark."))
12050 (gnus-message 6 "No bookmark in current article."))))
12052 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12053 (defun gnus-summary-mark-as-dormant (n)
12054 "Mark N articles forward as dormant.
12055 If N is negative, mark backward instead. The difference between N and
12056 the actual number of articles marked is returned."
12058 (gnus-set-global-variables)
12059 (gnus-summary-mark-forward n gnus-dormant-mark))
12061 (defun gnus-summary-set-process-mark (article)
12062 "Set the process mark on ARTICLE and update the summary line."
12063 (setq gnus-newsgroup-processable
12065 (delq article gnus-newsgroup-processable)))
12066 (when (gnus-summary-goto-subject article)
12067 (gnus-summary-show-thread)
12068 (gnus-summary-update-secondary-mark article)))
12070 (defun gnus-summary-remove-process-mark (article)
12071 "Remove the process mark from ARTICLE and update the summary line."
12072 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
12073 (when (gnus-summary-goto-subject article)
12074 (gnus-summary-show-thread)
12075 (gnus-summary-update-secondary-mark article)))
12077 (defun gnus-summary-set-saved-mark (article)
12078 "Set the process mark on ARTICLE and update the summary line."
12079 (push article gnus-newsgroup-saved)
12080 (when (gnus-summary-goto-subject article)
12081 (gnus-summary-update-secondary-mark article)))
12083 (defun gnus-summary-mark-forward (n &optional mark no-expire)
12084 "Mark N articles as read forwards.
12085 If N is negative, mark backwards instead.
12086 Mark with MARK. If MARK is ? , ?! or ??, articles will be
12088 The difference between N and the actual number of articles marked is
12091 (gnus-set-global-variables)
12092 (let ((backward (< n 0))
12093 (gnus-summary-goto-unread
12094 (and gnus-summary-goto-unread
12095 (not (eq gnus-summary-goto-unread 'never))
12096 (not (memq mark (list gnus-unread-mark
12097 gnus-ticked-mark gnus-dormant-mark)))))
12099 (mark (or mark gnus-del-mark)))
12100 (while (and (> n 0)
12101 (gnus-summary-mark-article nil mark no-expire)
12102 (zerop (gnus-summary-next-subject
12104 (and gnus-summary-goto-unread
12105 (not (eq gnus-summary-goto-unread 'never)))
12108 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12109 (gnus-summary-recenter)
12110 (gnus-summary-position-point)
12111 (gnus-set-mode-line 'summary)
12114 (defun gnus-summary-mark-article-as-read (mark)
12115 "Mark the current article quickly as read with MARK."
12116 (let ((article (gnus-summary-article-number)))
12117 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12118 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12119 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12120 (setq gnus-newsgroup-reads
12121 (cons (cons article mark) gnus-newsgroup-reads))
12122 ;; Possibly remove from cache, if that is used.
12123 (and gnus-use-cache (gnus-cache-enter-remove-article article))
12124 ;; Allow the backend to change the mark.
12125 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
12126 ;; Check for auto-expiry.
12127 (when (and gnus-newsgroup-auto-expire
12128 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12129 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12130 (= mark gnus-ancient-mark)
12131 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
12132 (setq mark gnus-expirable-mark)
12133 (push article gnus-newsgroup-expirable))
12134 ;; Set the mark in the buffer.
12135 (gnus-summary-update-mark mark 'unread)
12138 (defun gnus-summary-mark-article-as-unread (mark)
12139 "Mark the current article quickly as unread with MARK."
12140 (let ((article (gnus-summary-article-number)))
12141 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12142 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12143 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12144 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
12145 (cond ((= mark gnus-ticked-mark)
12146 (push article gnus-newsgroup-marked))
12147 ((= mark gnus-dormant-mark)
12148 (push article gnus-newsgroup-dormant))
12150 (push article gnus-newsgroup-unreads)))
12151 (setq gnus-newsgroup-reads
12152 (delq (assq article gnus-newsgroup-reads)
12153 gnus-newsgroup-reads))
12155 ;; See whether the article is to be put in the cache.
12156 (and gnus-use-cache
12157 (vectorp (gnus-summary-article-header article))
12159 (gnus-cache-possibly-enter-article
12160 gnus-newsgroup-name article
12161 (gnus-summary-article-header article)
12162 (= mark gnus-ticked-mark)
12163 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12166 (gnus-summary-update-mark mark 'unread)
12169 (defun gnus-summary-mark-article (&optional article mark no-expire)
12170 "Mark ARTICLE with MARK. MARK can be any character.
12171 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
12172 `??' (dormant) and `?E' (expirable).
12173 If MARK is nil, then the default character `?D' is used.
12174 If ARTICLE is nil, then the article on the current line will be
12176 ;; The mark might be a string.
12177 (and (stringp mark)
12178 (setq mark (aref mark 0)))
12179 ;; If no mark is given, then we check auto-expiring.
12180 (and (not no-expire)
12181 gnus-newsgroup-auto-expire
12183 (and (numberp mark)
12184 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12185 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12186 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
12187 (setq mark gnus-expirable-mark))
12188 (let* ((mark (or mark gnus-del-mark))
12189 (article (or article (gnus-summary-article-number))))
12190 (or article (error "No article on current line"))
12191 (if (or (= mark gnus-unread-mark)
12192 (= mark gnus-ticked-mark)
12193 (= mark gnus-dormant-mark))
12194 (gnus-mark-article-as-unread article mark)
12195 (gnus-mark-article-as-read article mark))
12197 ;; See whether the article is to be put in the cache.
12198 (and gnus-use-cache
12199 (not (= mark gnus-canceled-mark))
12200 (vectorp (gnus-summary-article-header article))
12202 (gnus-cache-possibly-enter-article
12203 gnus-newsgroup-name article
12204 (gnus-summary-article-header article)
12205 (= mark gnus-ticked-mark)
12206 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12208 (if (gnus-summary-goto-subject article nil t)
12209 (let ((buffer-read-only nil))
12210 (gnus-summary-show-thread)
12212 (gnus-summary-update-mark mark 'unread)
12215 (defun gnus-summary-update-secondary-mark (article)
12216 "Update the secondary (read, process, cache) mark."
12217 (gnus-summary-update-mark
12218 (cond ((memq article gnus-newsgroup-processable)
12220 ((memq article gnus-newsgroup-cached)
12222 ((memq article gnus-newsgroup-replied)
12224 ((memq article gnus-newsgroup-saved)
12226 (t gnus-unread-mark))
12228 (when (gnus-visual-p 'summary-highlight 'highlight)
12229 (run-hooks 'gnus-summary-update-hook))
12232 (defun gnus-summary-update-mark (mark type)
12233 (beginning-of-line)
12234 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
12235 (buffer-read-only nil))
12237 (<= (+ forward (point)) (point-max)))
12238 ;; Go to the right position on the line.
12239 (goto-char (+ forward (point)))
12240 ;; Replace the old mark with the new mark.
12241 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
12242 ;; Optionally update the marks by some user rule.
12243 (when (eq type 'unread)
12244 (gnus-data-set-mark
12245 (gnus-data-find (gnus-summary-article-number)) mark)
12246 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
12248 (defun gnus-mark-article-as-read (article &optional mark)
12249 "Enter ARTICLE in the pertinent lists and remove it from others."
12250 ;; Make the article expirable.
12251 (let ((mark (or mark gnus-del-mark)))
12252 (if (= mark gnus-expirable-mark)
12253 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
12254 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
12255 ;; Remove from unread and marked lists.
12256 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12257 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12258 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12259 (push (cons article mark) gnus-newsgroup-reads)
12260 ;; Possibly remove from cache, if that is used.
12261 (when gnus-use-cache
12262 (gnus-cache-enter-remove-article article))))
12264 (defun gnus-mark-article-as-unread (article &optional mark)
12265 "Enter ARTICLE in the pertinent lists and remove it from others."
12266 (let ((mark (or mark gnus-ticked-mark)))
12267 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12268 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12269 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12270 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12271 (cond ((= mark gnus-ticked-mark)
12272 (push article gnus-newsgroup-marked))
12273 ((= mark gnus-dormant-mark)
12274 (push article gnus-newsgroup-dormant))
12276 (push article gnus-newsgroup-unreads)))
12277 (setq gnus-newsgroup-reads
12278 (delq (assq article gnus-newsgroup-reads)
12279 gnus-newsgroup-reads))))
12281 (defalias 'gnus-summary-mark-as-unread-forward
12282 'gnus-summary-tick-article-forward)
12283 (make-obsolete 'gnus-summary-mark-as-unread-forward
12284 'gnus-summary-tick-article-forward)
12285 (defun gnus-summary-tick-article-forward (n)
12286 "Tick N articles forwards.
12287 If N is negative, tick backwards instead.
12288 The difference between N and the number of articles ticked is returned."
12290 (gnus-summary-mark-forward n gnus-ticked-mark))
12292 (defalias 'gnus-summary-mark-as-unread-backward
12293 'gnus-summary-tick-article-backward)
12294 (make-obsolete 'gnus-summary-mark-as-unread-backward
12295 'gnus-summary-tick-article-backward)
12296 (defun gnus-summary-tick-article-backward (n)
12297 "Tick N articles backwards.
12298 The difference between N and the number of articles ticked is returned."
12300 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12302 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12303 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12304 (defun gnus-summary-tick-article (&optional article clear-mark)
12305 "Mark current article as unread.
12306 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12307 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12309 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12310 gnus-ticked-mark)))
12312 (defun gnus-summary-mark-as-read-forward (n)
12313 "Mark N articles as read forwards.
12314 If N is negative, mark backwards instead.
12315 The difference between N and the actual number of articles marked is
12318 (gnus-summary-mark-forward n gnus-del-mark t))
12320 (defun gnus-summary-mark-as-read-backward (n)
12321 "Mark the N articles as read backwards.
12322 The difference between N and the actual number of articles marked is
12325 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12327 (defun gnus-summary-mark-as-read (&optional article mark)
12328 "Mark current article as read.
12329 ARTICLE specifies the article to be marked as read.
12330 MARK specifies a string to be inserted at the beginning of the line."
12331 (gnus-summary-mark-article article mark))
12333 (defun gnus-summary-clear-mark-forward (n)
12334 "Clear marks from N articles forward.
12335 If N is negative, clear backward instead.
12336 The difference between N and the number of marks cleared is returned."
12338 (gnus-summary-mark-forward n gnus-unread-mark))
12340 (defun gnus-summary-clear-mark-backward (n)
12341 "Clear marks from N articles backward.
12342 The difference between N and the number of marks cleared is returned."
12344 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12346 (defun gnus-summary-mark-unread-as-read ()
12347 "Intended to be used by `gnus-summary-mark-article-hook'."
12348 (when (memq gnus-current-article gnus-newsgroup-unreads)
12349 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12351 (defun gnus-summary-mark-read-and-unread-as-read ()
12352 "Intended to be used by `gnus-summary-mark-article-hook'."
12353 (let ((mark (gnus-summary-article-mark)))
12354 (when (or (gnus-unread-mark-p mark)
12355 (gnus-read-mark-p mark))
12356 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12358 (defun gnus-summary-mark-region-as-read (point mark all)
12359 "Mark all unread articles between point and mark as read.
12360 If given a prefix, mark all articles between point and mark as read,
12361 even ticked and dormant ones."
12362 (interactive "r\nP")
12366 (beginning-of-line)
12371 (memq (setq article (gnus-summary-article-number))
12372 gnus-newsgroup-unreads))
12373 (gnus-summary-mark-article article gnus-del-mark))
12375 (gnus-summary-find-next))))))
12377 (defun gnus-summary-mark-below (score mark)
12378 "Mark articles with score less than SCORE with MARK."
12379 (interactive "P\ncMark: ")
12380 (gnus-set-global-variables)
12381 (setq score (if score
12382 (prefix-numeric-value score)
12383 (or gnus-summary-default-score 0)))
12385 (set-buffer gnus-summary-buffer)
12386 (goto-char (point-min))
12389 (and (< (gnus-summary-article-score) score)
12390 (gnus-summary-mark-article nil mark))
12391 (gnus-summary-find-next)))))
12393 (defun gnus-summary-kill-below (&optional score)
12394 "Mark articles with score below SCORE as read."
12396 (gnus-set-global-variables)
12397 (gnus-summary-mark-below score gnus-killed-mark))
12399 (defun gnus-summary-clear-above (&optional score)
12400 "Clear all marks from articles with score above SCORE."
12402 (gnus-set-global-variables)
12403 (gnus-summary-mark-above score gnus-unread-mark))
12405 (defun gnus-summary-tick-above (&optional score)
12406 "Tick all articles with score above SCORE."
12408 (gnus-set-global-variables)
12409 (gnus-summary-mark-above score gnus-ticked-mark))
12411 (defun gnus-summary-mark-above (score mark)
12412 "Mark articles with score over SCORE with MARK."
12413 (interactive "P\ncMark: ")
12414 (gnus-set-global-variables)
12415 (setq score (if score
12416 (prefix-numeric-value score)
12417 (or gnus-summary-default-score 0)))
12419 (set-buffer gnus-summary-buffer)
12420 (goto-char (point-min))
12422 (if (> (gnus-summary-article-score) score)
12423 (gnus-summary-mark-article nil mark))
12425 (gnus-summary-find-next)))))
12427 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12428 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12429 (defun gnus-summary-limit-include-expunged ()
12430 "Display all the hidden articles that were expunged for low scores."
12432 (gnus-set-global-variables)
12433 (let ((buffer-read-only nil))
12434 (let ((scored gnus-newsgroup-scored)
12437 (or (gnus-summary-goto-subject (caar scored))
12438 (and (setq h (gnus-summary-article-header (caar scored)))
12439 (< (cdar scored) gnus-summary-expunge-below)
12440 (setq headers (cons h headers))))
12441 (setq scored (cdr scored)))
12442 (or headers (error "No expunged articles hidden."))
12443 (goto-char (point-min))
12444 (gnus-summary-prepare-unthreaded (nreverse headers)))
12445 (goto-char (point-min))
12446 (gnus-summary-position-point)))
12448 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12449 "Mark all articles not marked as unread in this newsgroup as read.
12450 If prefix argument ALL is non-nil, all articles are marked as read.
12451 If QUIETLY is non-nil, no questions will be asked.
12452 If TO-HERE is non-nil, it should be a point in the buffer. All
12453 articles before this point will be marked as read.
12454 The number of articles marked as read is returned."
12456 (gnus-set-global-variables)
12459 (not gnus-interactive-catchup) ;Without confirmation?
12463 "Mark absolutely all articles as read? "
12464 "Mark all unread articles as read? ")))
12466 (not gnus-newsgroup-adaptive)
12467 (not gnus-newsgroup-auto-expire))
12470 (setq gnus-newsgroup-marked nil
12471 gnus-newsgroup-dormant nil))
12472 (setq gnus-newsgroup-unreads nil))
12473 ;; We actually mark all articles as canceled, which we
12474 ;; have to do when using auto-expiry or adaptive scoring.
12475 (gnus-summary-show-all-threads)
12476 (if (gnus-summary-first-subject (not all))
12478 (if to-here (< (point) to-here) t)
12479 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12480 (gnus-summary-find-next (not all)))))
12482 (setq gnus-newsgroup-unreads nil))
12483 (gnus-set-mode-line 'summary)))
12484 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12485 (if (and (not to-here) (eq 'nnvirtual (car method)))
12486 (nnvirtual-catchup-group
12487 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12488 (gnus-summary-position-point)))
12490 (defun gnus-summary-catchup-to-here (&optional all)
12491 "Mark all unticked articles before the current one as read.
12492 If ALL is non-nil, also mark ticked and dormant articles as read."
12494 (gnus-set-global-variables)
12496 (gnus-save-hidden-threads
12497 (let ((beg (point)))
12498 ;; We check that there are unread articles.
12499 (when (or all (gnus-summary-find-prev))
12500 (gnus-summary-catchup all t beg)))))
12501 (gnus-summary-position-point))
12503 (defun gnus-summary-catchup-all (&optional quietly)
12504 "Mark all articles in this newsgroup as read."
12506 (gnus-set-global-variables)
12507 (gnus-summary-catchup t quietly))
12509 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12510 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12511 If prefix argument ALL is non-nil, all articles are marked as read."
12513 (gnus-set-global-variables)
12514 (gnus-summary-catchup all quietly nil 'fast)
12515 ;; Select next newsgroup or exit.
12516 (if (eq gnus-auto-select-next 'quietly)
12517 (gnus-summary-next-group nil)
12518 (gnus-summary-exit)))
12520 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12521 "Mark all articles in this newsgroup as read, and then exit."
12523 (gnus-set-global-variables)
12524 (gnus-summary-catchup-and-exit t quietly))
12526 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12527 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12528 "Mark all articles in this group as read and select the next group.
12529 If given a prefix, mark all articles, unread as well as ticked, as
12532 (gnus-set-global-variables)
12534 (gnus-summary-catchup all))
12535 (gnus-summary-next-article t nil nil t))
12537 ;; Thread-based commands.
12539 (defun gnus-summary-articles-in-thread (&optional article)
12540 "Return a list of all articles in the current thread.
12541 If ARTICLE is non-nil, return all articles in the thread that starts
12542 with that article."
12543 (let* ((article (or article (gnus-summary-article-number)))
12544 (data (gnus-data-find-list article))
12545 (top-level (gnus-data-level (car data)))
12547 (cond ((null gnus-thread-operation-ignore-subject)
12548 (gnus-simplify-subject-re
12549 (mail-header-subject (gnus-data-header (car data)))))
12550 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12551 (gnus-simplify-subject-fuzzy
12552 (mail-header-subject (gnus-data-header (car data)))))
12554 (end-point (save-excursion
12555 (if (gnus-summary-go-to-next-thread)
12556 (point) (point-max))))
12559 (< (gnus-data-pos (car data)) end-point))
12560 (when (or (not top-subject)
12561 (string= top-subject
12562 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12563 (gnus-simplify-subject-fuzzy
12564 (mail-header-subject
12565 (gnus-data-header (car data))))
12566 (gnus-simplify-subject-re
12567 (mail-header-subject
12568 (gnus-data-header (car data)))))))
12569 (push (gnus-data-number (car data)) articles))
12570 (unless (and (setq data (cdr data))
12571 (> (gnus-data-level (car data)) top-level))
12573 ;; Return the list of articles.
12574 (nreverse articles)))
12576 (defun gnus-summary-rethread-current ()
12577 "Rethread the thread the current article is part of."
12579 (gnus-set-global-variables)
12580 (let* ((gnus-show-threads t)
12581 (article (gnus-summary-article-number))
12582 (id (mail-header-id (gnus-summary-article-header)))
12583 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12585 (error "No article on the current line"))
12586 (gnus-rebuild-thread id)
12587 (gnus-summary-goto-subject article)))
12589 (defun gnus-summary-reparent-thread ()
12590 "Make current article child of the marked (or previous) article.
12592 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12593 is non-nil or the Subject: of both articles are the same."
12595 (or (not (gnus-group-read-only-p))
12596 (error "The current newsgroup does not support article editing."))
12597 (or (<= (length gnus-newsgroup-processable) 1)
12598 (error "No more than one article may be marked."))
12599 (save-window-excursion
12600 (let ((gnus-article-buffer " *reparent*")
12601 (current-article (gnus-summary-article-number))
12602 ; first grab the marked article, otherwise one line up.
12603 (parent-article (if (not (null gnus-newsgroup-processable))
12604 (car gnus-newsgroup-processable)
12606 (if (eq (forward-line -1) 0)
12607 (gnus-summary-article-number)
12608 (error "Beginning of summary buffer."))))))
12609 (or (not (eq current-article parent-article))
12610 (error "An article may not be self-referential."))
12611 (let ((message-id (mail-header-id
12612 (gnus-summary-article-header parent-article))))
12613 (or (and message-id (not (equal message-id "")))
12614 (error "No message-id in desired parent."))
12615 (gnus-summary-select-article t t nil current-article)
12616 (set-buffer gnus-article-buffer)
12617 (setq buffer-read-only nil)
12618 (let ((buf (format "%s" (buffer-string))))
12621 (goto-char (point-min))
12622 (if (search-forward-regexp "^References: " nil t)
12623 (insert message-id " " )
12624 (insert "References: " message-id "\n"))
12625 (or (gnus-request-replace-article current-article
12626 (car gnus-article-current)
12627 gnus-article-buffer)
12628 (error "Couldn't replace article."))
12629 (set-buffer gnus-summary-buffer)
12630 (gnus-summary-unmark-all-processable)
12631 (gnus-summary-rethread-current)
12632 (gnus-message 3 "Article %d is now the child of article %d."
12633 current-article parent-article)))))
12635 (defun gnus-summary-toggle-threads (&optional arg)
12636 "Toggle showing conversation threads.
12637 If ARG is positive number, turn showing conversation threads on."
12639 (gnus-set-global-variables)
12640 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12641 (setq gnus-show-threads
12642 (if (null arg) (not gnus-show-threads)
12643 (> (prefix-numeric-value arg) 0)))
12644 (gnus-summary-prepare)
12645 (gnus-summary-goto-subject current)
12646 (gnus-summary-position-point)))
12648 (defun gnus-summary-show-all-threads ()
12649 "Show all threads."
12651 (gnus-set-global-variables)
12653 (let ((buffer-read-only nil))
12654 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12655 (gnus-summary-position-point))
12657 (defun gnus-summary-show-thread ()
12658 "Show thread subtrees.
12659 Returns nil if no thread was there to be shown."
12661 (gnus-set-global-variables)
12662 (let ((buffer-read-only nil)
12664 ;; first goto end then to beg, to have point at beg after let
12665 (end (progn (end-of-line) (point)))
12666 (beg (progn (beginning-of-line) (point))))
12668 ;; Any hidden lines here?
12669 (search-forward "\r" end t)
12670 (subst-char-in-region beg end ?\^M ?\n t)
12672 (gnus-summary-position-point))))
12674 (defun gnus-summary-hide-all-threads ()
12675 "Hide all thread subtrees."
12677 (gnus-set-global-variables)
12679 (goto-char (point-min))
12680 (gnus-summary-hide-thread)
12681 (while (zerop (gnus-summary-next-thread 1 t))
12682 (gnus-summary-hide-thread)))
12683 (gnus-summary-position-point))
12685 (defun gnus-summary-hide-thread ()
12686 "Hide thread subtrees.
12687 Returns nil if no threads were there to be hidden."
12689 (gnus-set-global-variables)
12690 (let ((buffer-read-only nil)
12692 (article (gnus-summary-article-number)))
12694 ;; Go forward until either the buffer ends or the subthread
12696 (when (and (not (eobp))
12697 (or (zerop (gnus-summary-next-thread 1 t))
12698 (goto-char (point-max))))
12700 (if (and (> (point) start)
12701 (search-backward "\n" start t))
12703 (subst-char-in-region start (point) ?\n ?\^M)
12704 (gnus-summary-goto-subject article))
12707 ;;(gnus-summary-position-point)
12710 (defun gnus-summary-go-to-next-thread (&optional previous)
12711 "Go to the same level (or less) next thread.
12712 If PREVIOUS is non-nil, go to previous thread instead.
12713 Return the article number moved to, or nil if moving was impossible."
12714 (let ((level (gnus-summary-thread-level))
12715 (way (if previous -1 1))
12718 (while (and (not (eobp))
12719 (< level (gnus-summary-thread-level)))
12720 (forward-line way))
12727 (gnus-summary-article-number)
12728 (goto-char beg)))))
12730 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12731 "Go to the same level (or less) next thread.
12732 If PREVIOUS is non-nil, go to previous thread instead.
12733 Return the article number moved to, or nil if moving was impossible."
12734 (if (and (eq gnus-summary-make-false-root 'dummy)
12735 (gnus-summary-article-intangible-p))
12736 (let ((beg (point)))
12737 (while (and (zerop (forward-line 1))
12738 (not (gnus-summary-article-intangible-p))
12739 (not (zerop (save-excursion
12740 (gnus-summary-thread-level))))))
12746 (let* ((level (gnus-summary-thread-level))
12747 (article (gnus-summary-article-number))
12748 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12751 (if (<= (gnus-data-level (car data)) level)
12752 (setq oart (gnus-data-number (car data))
12754 (setq data (cdr data))))
12756 (gnus-summary-goto-subject oart)))))
12758 (defun gnus-summary-next-thread (n &optional silent)
12759 "Go to the same level next N'th thread.
12760 If N is negative, search backward instead.
12761 Returns the difference between N and the number of skips actually
12764 If SILENT, don't output messages."
12766 (gnus-set-global-variables)
12767 (let ((backward (< n 0))
12770 (while (and (> n 0)
12771 (gnus-summary-go-to-next-thread backward))
12774 (gnus-summary-position-point))
12775 (when (and (not silent) (/= 0 n))
12776 (gnus-message 7 "No more threads"))
12779 (defun gnus-summary-prev-thread (n)
12780 "Go to the same level previous N'th thread.
12781 Returns the difference between N and the number of skips actually
12784 (gnus-set-global-variables)
12785 (gnus-summary-next-thread (- n)))
12787 (defun gnus-summary-go-down-thread ()
12788 "Go down one level in the current thread."
12789 (let ((children (gnus-summary-article-children)))
12791 (gnus-summary-goto-subject (car children)))))
12793 (defun gnus-summary-go-up-thread ()
12794 "Go up one level in the current thread."
12795 (let ((parent (gnus-summary-article-parent)))
12797 (gnus-summary-goto-subject parent))))
12799 (defun gnus-summary-down-thread (n)
12800 "Go down thread N steps.
12801 If N is negative, go up instead.
12802 Returns the difference between N and how many steps down that were
12805 (gnus-set-global-variables)
12808 (while (and (> n 0)
12809 (if up (gnus-summary-go-up-thread)
12810 (gnus-summary-go-down-thread)))
12812 (gnus-summary-position-point)
12813 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12816 (defun gnus-summary-up-thread (n)
12817 "Go up thread N steps.
12818 If N is negative, go up instead.
12819 Returns the difference between N and how many steps down that were
12822 (gnus-set-global-variables)
12823 (gnus-summary-down-thread (- n)))
12825 (defun gnus-summary-top-thread ()
12826 "Go to the top of the thread."
12828 (gnus-set-global-variables)
12829 (while (gnus-summary-go-up-thread))
12830 (gnus-summary-article-number))
12832 (defun gnus-summary-kill-thread (&optional unmark)
12833 "Mark articles under current thread as read.
12834 If the prefix argument is positive, remove any kinds of marks.
12835 If the prefix argument is negative, tick articles instead."
12837 (gnus-set-global-variables)
12839 (setq unmark (prefix-numeric-value unmark)))
12840 (let ((articles (gnus-summary-articles-in-thread)))
12842 ;; Expand the thread.
12843 (gnus-summary-show-thread)
12844 ;; Mark all the articles.
12846 (gnus-summary-goto-subject (car articles))
12847 (cond ((null unmark)
12848 (gnus-summary-mark-article-as-read gnus-killed-mark))
12850 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12852 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12853 (setq articles (cdr articles))))
12854 ;; Hide killed subtrees.
12856 gnus-thread-hide-killed
12857 (gnus-summary-hide-thread))
12858 ;; If marked as read, go to next unread subject.
12860 ;; Go to next unread subject.
12861 (gnus-summary-next-subject 1 t)))
12862 (gnus-set-mode-line 'summary))
12864 ;; Summary sorting commands
12866 (defun gnus-summary-sort-by-number (&optional reverse)
12867 "Sort summary buffer by article number.
12868 Argument REVERSE means reverse order."
12870 (gnus-summary-sort 'number reverse))
12872 (defun gnus-summary-sort-by-author (&optional reverse)
12873 "Sort summary buffer by author name alphabetically.
12874 If case-fold-search is non-nil, case of letters is ignored.
12875 Argument REVERSE means reverse order."
12877 (gnus-summary-sort 'author reverse))
12879 (defun gnus-summary-sort-by-subject (&optional reverse)
12880 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12881 If case-fold-search is non-nil, case of letters is ignored.
12882 Argument REVERSE means reverse order."
12884 (gnus-summary-sort 'subject reverse))
12886 (defun gnus-summary-sort-by-date (&optional reverse)
12887 "Sort summary buffer by date.
12888 Argument REVERSE means reverse order."
12890 (gnus-summary-sort 'date reverse))
12892 (defun gnus-summary-sort-by-score (&optional reverse)
12893 "Sort summary buffer by score.
12894 Argument REVERSE means reverse order."
12896 (gnus-summary-sort 'score reverse))
12898 (defun gnus-summary-sort (predicate reverse)
12899 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12900 (gnus-set-global-variables)
12901 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12902 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12903 (gnus-thread-sort-functions
12908 (,thread t2 t1)))))
12909 (gnus-article-sort-functions
12914 (,article t2 t1)))))
12916 (gnus-summary-prepare-hook nil))
12917 ;; We do the sorting by regenerating the threads.
12918 (gnus-summary-prepare)
12919 ;; Hide subthreads if needed.
12920 (when (and gnus-show-threads gnus-thread-hide-subtree)
12921 (gnus-summary-hide-all-threads)))
12922 ;; If in async mode, we send some info to the backend.
12923 (when gnus-newsgroup-async
12924 (gnus-request-asynchronous
12925 gnus-newsgroup-name gnus-newsgroup-data)))
12927 (defun gnus-sortable-date (date)
12928 "Make sortable string by string-lessp from DATE.
12929 Timezone package is used."
12932 (setq date (inline (timezone-fix-time
12934 (aref (inline (timezone-parse-date date)) 4))))
12936 (timezone-make-sortable-date
12937 (aref date 0) (aref date 1) (aref date 2)
12939 (timezone-make-time-string
12940 (aref date 3) (aref date 4) (aref date 5))))))
12943 ;; Summary saving commands.
12945 (defun gnus-summary-save-article (&optional n not-saved)
12946 "Save the current article using the default saver function.
12947 If N is a positive number, save the N next articles.
12948 If N is a negative number, save the N previous articles.
12949 If N is nil and any articles have been marked with the process mark,
12950 save those articles instead.
12951 The variable `gnus-default-article-saver' specifies the saver function."
12953 (gnus-set-global-variables)
12954 (let ((articles (gnus-summary-work-articles n))
12955 (save-buffer (save-excursion
12956 (nnheader-set-temp-buffer " *Gnus Save*")))
12957 file header article)
12959 (setq header (gnus-summary-article-header
12960 (setq article (pop articles))))
12961 (if (not (vectorp header))
12962 ;; This is a pseudo-article.
12963 (if (assq 'name header)
12964 (gnus-copy-file (cdr (assq 'name header)))
12965 (gnus-message 1 "Article %d is unsaveable" article))
12966 ;; This is a real article.
12967 (save-window-excursion
12968 (gnus-summary-select-article t nil nil article))
12970 (set-buffer save-buffer)
12972 (insert-buffer-substring gnus-original-article-buffer))
12973 (unless gnus-save-all-headers
12974 ;; Remove headers accoring to `gnus-saved-headers'.
12975 (let ((gnus-visible-headers
12976 (or gnus-saved-headers gnus-visible-headers))
12977 (gnus-article-buffer save-buffer))
12978 (gnus-article-hide-headers 1 t)))
12979 (save-window-excursion
12980 (if (not gnus-default-article-saver)
12981 (error "No default saver is defined.")
12982 ;; !!! Magic! The saving functions all save
12983 ;; `gnus-original-article-buffer' (or so they think),
12984 ;; but we bind that variable to our save-buffer.
12985 (set-buffer gnus-article-buffer)
12986 (let ((gnus-original-article-buffer save-buffer))
12987 (set-buffer gnus-summary-buffer)
12988 (setq file (funcall
12989 gnus-default-article-saver
12991 ((not gnus-prompt-before-saving)
12993 ((eq gnus-prompt-before-saving 'always)
12996 (gnus-summary-remove-process-mark article)
12998 (gnus-summary-set-saved-mark article))))
12999 (gnus-kill-buffer save-buffer)
13000 (gnus-summary-position-point)
13003 (defun gnus-summary-pipe-output (&optional arg)
13004 "Pipe the current article to a subprocess.
13005 If N is a positive number, pipe the N next articles.
13006 If N is a negative number, pipe the N previous articles.
13007 If N is nil and any articles have been marked with the process mark,
13008 pipe those articles instead."
13010 (gnus-set-global-variables)
13011 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
13012 (gnus-summary-save-article arg t))
13013 (gnus-configure-windows 'pipe))
13015 (defun gnus-summary-save-article-mail (&optional arg)
13016 "Append the current article to an mail file.
13017 If N is a positive number, save the N next articles.
13018 If N is a negative number, save the N previous articles.
13019 If N is nil and any articles have been marked with the process mark,
13020 save those articles instead."
13022 (gnus-set-global-variables)
13023 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
13024 (gnus-summary-save-article arg)))
13026 (defun gnus-summary-save-article-rmail (&optional arg)
13027 "Append the current article to an rmail file.
13028 If N is a positive number, save the N next articles.
13029 If N is a negative number, save the N previous articles.
13030 If N is nil and any articles have been marked with the process mark,
13031 save those articles instead."
13033 (gnus-set-global-variables)
13034 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
13035 (gnus-summary-save-article arg)))
13037 (defun gnus-summary-save-article-file (&optional arg)
13038 "Append the current article to a file.
13039 If N is a positive number, save the N next articles.
13040 If N is a negative number, save the N previous articles.
13041 If N is nil and any articles have been marked with the process mark,
13042 save those articles instead."
13044 (gnus-set-global-variables)
13045 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
13046 (gnus-summary-save-article arg)))
13048 (defun gnus-summary-save-article-body-file (&optional arg)
13049 "Append the current article body to a file.
13050 If N is a positive number, save the N next articles.
13051 If N is a negative number, save the N previous articles.
13052 If N is nil and any articles have been marked with the process mark,
13053 save those articles instead."
13055 (gnus-set-global-variables)
13056 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
13057 (gnus-summary-save-article arg)))
13059 (defun gnus-get-split-value (methods)
13060 "Return a value based on the split METHODS."
13061 (let (split-name method result match)
13064 (set-buffer gnus-original-article-buffer)
13066 (nnheader-narrow-to-headers)
13068 (goto-char (point-min))
13069 (setq method (pop methods))
13070 (setq match (car method))
13073 ;; Regular expression.
13075 (re-search-forward match nil t)
13077 ((gnus-functionp match)
13081 (setq result (funcall match gnus-newsgroup-name))))
13086 (setq result (eval match)))))
13087 (setq split-name (append (cdr method) split-name))
13088 (cond ((stringp result)
13089 (push result split-name))
13091 (setq split-name (append result split-name)))))))))
13094 (defun gnus-read-move-group-name (prompt default articles prefix)
13095 "Read a group name."
13096 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
13097 (minibuffer-confirm-incomplete nil) ; XEmacs
13104 (assoc (symbol-name
13105 (car (gnus-find-method-for-group
13107 gnus-valid-select-methods))
13108 (push (list (symbol-name g)) group-map)))
13109 gnus-active-hashtb))
13111 (format "%s %s to:"
13113 (if (> (length articles) 1)
13114 (format "these %d articles" (length articles))
13119 (gnus-completing-read default prom
13120 group-map nil nil prefix
13121 'gnus-group-history))
13122 ((= 1 (length split-name))
13123 (gnus-completing-read (car split-name) prom group-map
13125 'gnus-group-history))
13127 (gnus-completing-read nil prom
13128 (mapcar (lambda (el) (list el))
13129 (nreverse split-name))
13131 'gnus-group-history)))))
13133 (if (or (string= to-newsgroup "")
13134 (string= to-newsgroup prefix))
13135 (setq to-newsgroup (or default "")))
13136 (or (gnus-active to-newsgroup)
13137 (gnus-activate-group to-newsgroup)
13138 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
13140 (or (gnus-request-create-group to-newsgroup)
13141 (error "Couldn't create group %s" to-newsgroup)))
13142 (error "No such group: %s" to-newsgroup)))
13145 (defun gnus-read-save-file-name (prompt default-name)
13146 (let* ((split-name (gnus-get-split-value gnus-split-methods))
13148 ;; Let the split methods have their say.
13150 ;; No split name was found.
13153 (concat prompt " (default "
13154 (file-name-nondirectory default-name) ") ")
13155 (file-name-directory default-name)
13157 ;; A single split name was found
13158 ((= 1 (length split-name))
13160 (concat prompt " (default " (car split-name) ") ")
13161 gnus-article-save-directory
13162 (concat gnus-article-save-directory (car split-name))))
13163 ;; A list of splits was found.
13165 (setq split-name (nreverse split-name))
13167 (let ((file-name-history (nconc split-name file-name-history)))
13170 (concat prompt " (`M-p' for defaults) ")
13171 gnus-article-save-directory
13172 (car split-name))))
13173 (car (push result file-name-history)))))))
13174 ;; If we have read a directory, we append the default file name.
13175 (when (file-directory-p file)
13176 (setq file (concat (file-name-as-directory file)
13177 (file-name-nondirectory default-name))))
13178 ;; Possibly translate some charaters.
13179 (nnheader-translate-file-chars file)))
13181 (defun gnus-article-archive-name (group)
13182 "Return the first instance of an \"Archive-name\" in the current buffer."
13183 (let ((case-fold-search t))
13184 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
13185 (match-string 1))))
13187 (defun gnus-summary-save-in-rmail (&optional filename)
13188 "Append this article to Rmail file.
13189 Optional argument FILENAME specifies file name.
13190 Directory to save to is default to `gnus-article-save-directory'."
13192 (gnus-set-global-variables)
13193 (let ((default-name
13194 (funcall gnus-rmail-save-name gnus-newsgroup-name
13195 gnus-current-headers gnus-newsgroup-last-rmail)))
13197 (cond ((eq filename 'default)
13199 (filename filename)
13200 (t (gnus-read-save-file-name
13201 "Save in rmail file:" default-name))))
13202 (gnus-make-directory (file-name-directory filename))
13203 (gnus-eval-in-buffer-window gnus-original-article-buffer
13207 (gnus-output-to-rmail filename))))
13208 ;; Remember the directory name to save articles
13209 (setq gnus-newsgroup-last-rmail filename)))
13211 (defun gnus-summary-save-in-mail (&optional filename)
13212 "Append this article to Unix mail file.
13213 Optional argument FILENAME specifies file name.
13214 Directory to save to is default to `gnus-article-save-directory'."
13216 (gnus-set-global-variables)
13217 (let ((default-name
13218 (funcall gnus-mail-save-name gnus-newsgroup-name
13219 gnus-current-headers gnus-newsgroup-last-mail)))
13221 (cond ((eq filename 'default)
13223 (filename filename)
13224 (t (gnus-read-save-file-name
13225 "Save in Unix mail file:" default-name))))
13227 (expand-file-name filename
13229 (file-name-directory default-name))))
13230 (gnus-make-directory (file-name-directory filename))
13231 (gnus-eval-in-buffer-window gnus-original-article-buffer
13235 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
13236 (gnus-output-to-rmail filename)
13237 (let ((mail-use-rfc822 t))
13238 (rmail-output filename 1 t t))))))
13239 ;; Remember the directory name to save articles.
13240 (setq gnus-newsgroup-last-mail filename)))
13242 (defun gnus-summary-save-in-file (&optional filename)
13243 "Append this article to file.
13244 Optional argument FILENAME specifies file name.
13245 Directory to save to is default to `gnus-article-save-directory'."
13247 (gnus-set-global-variables)
13248 (let ((default-name
13249 (funcall gnus-file-save-name gnus-newsgroup-name
13250 gnus-current-headers gnus-newsgroup-last-file)))
13252 (cond ((eq filename 'default)
13254 (filename filename)
13255 (t (gnus-read-save-file-name
13256 "Save in file:" default-name))))
13257 (gnus-make-directory (file-name-directory filename))
13258 (gnus-eval-in-buffer-window gnus-original-article-buffer
13262 (gnus-output-to-file filename))))
13263 ;; Remember the directory name to save articles.
13264 (setq gnus-newsgroup-last-file filename)))
13266 (defun gnus-summary-save-body-in-file (&optional filename)
13267 "Append this article body to a file.
13268 Optional argument FILENAME specifies file name.
13269 The directory to save in defaults to `gnus-article-save-directory'."
13271 (gnus-set-global-variables)
13272 (let ((default-name
13273 (funcall gnus-file-save-name gnus-newsgroup-name
13274 gnus-current-headers gnus-newsgroup-last-file)))
13276 (cond ((eq filename 'default)
13278 (filename filename)
13279 (t (gnus-read-save-file-name
13280 "Save body in file:" default-name))))
13281 (gnus-make-directory (file-name-directory filename))
13282 (gnus-eval-in-buffer-window gnus-article-buffer
13286 (goto-char (point-min))
13287 (and (search-forward "\n\n" nil t)
13288 (narrow-to-region (point) (point-max)))
13289 (gnus-output-to-file filename))))
13290 ;; Remember the directory name to save articles.
13291 (setq gnus-newsgroup-last-file filename)))
13293 (defun gnus-summary-save-in-pipe (&optional command)
13294 "Pipe this article to subprocess."
13296 (gnus-set-global-variables)
13298 (cond ((eq command 'default)
13299 gnus-last-shell-command)
13301 (t (read-string "Shell command on article: "
13302 gnus-last-shell-command))))
13303 (if (string-equal command "")
13304 (setq command gnus-last-shell-command))
13305 (gnus-eval-in-buffer-window gnus-article-buffer
13308 (shell-command-on-region (point-min) (point-max) command nil)))
13309 (setq gnus-last-shell-command command))
13311 ;; Summary extract commands
13313 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13314 (let ((buffer-read-only nil)
13315 (article (gnus-summary-article-number))
13317 (or (gnus-summary-goto-subject article)
13318 (error (format "No such article: %d" article)))
13319 (gnus-summary-position-point)
13320 ;; If all commands are to be bunched up on one line, we collect
13322 (if gnus-view-pseudos-separately
13324 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13327 (setq action (cdr (assq 'action (car ps))))
13328 (setq files (list (cdr (assq 'name (car ps)))))
13329 (while (and ps (cdr ps)
13330 (string= (or action "1")
13331 (or (cdr (assq 'action (cadr ps))) "2")))
13332 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13333 (setcdr ps (cddr ps)))
13336 (if (not (string-match "%s" action))
13337 (setq files (cons " " files)))
13338 (setq files (cons " " files))
13339 (and (assq 'execute (car ps))
13340 (setcdr (assq 'execute (car ps))
13341 (funcall (if (string-match "%s" action)
13344 (mapconcat (lambda (f) f) files " ")))))
13345 (setq ps (cdr ps)))))
13346 (if (and gnus-view-pseudos (not not-view))
13348 (and (assq 'execute (car pslist))
13349 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13350 (eq gnus-view-pseudos 'not-confirm)))
13351 (setq pslist (cdr pslist)))
13354 (setq after-article (or (cdr (assq 'article (car pslist)))
13355 (gnus-summary-article-number)))
13356 (gnus-summary-goto-subject after-article)
13359 (insert " " (file-name-nondirectory
13360 (cdr (assq 'name (car pslist))))
13361 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13363 (forward-line -1) ; back to `b'
13364 (gnus-add-text-properties
13365 b (1- e) (list 'gnus-number gnus-reffed-article-number
13366 gnus-mouse-face-prop gnus-mouse-face))
13368 after-article gnus-reffed-article-number
13369 gnus-unread-mark b (car pslist) 0 (- e b))
13370 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13371 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13372 (setq pslist (cdr pslist)))))))
13374 (defun gnus-pseudos< (p1 p2)
13375 (let ((c1 (cdr (assq 'action p1)))
13376 (c2 (cdr (assq 'action p2))))
13377 (and c1 c2 (string< c1 c2))))
13379 (defun gnus-request-pseudo-article (props)
13380 (cond ((assq 'execute props)
13381 (gnus-execute-command (cdr (assq 'execute props)))))
13382 (let ((gnus-current-article (gnus-summary-article-number)))
13383 (run-hooks 'gnus-mark-article-hook)))
13385 (defun gnus-execute-command (command &optional automatic)
13387 (gnus-article-setup-buffer)
13388 (set-buffer gnus-article-buffer)
13389 (setq buffer-read-only nil)
13390 (let ((command (if automatic command (read-string "Command: " command)))
13391 ;; Just binding this here doesn't help, because there might
13392 ;; be output from the process after exiting the scope of
13394 ;; (buffer-read-only nil)
13397 (insert "$ " command "\n\n")
13398 (if gnus-view-pseudo-asynchronously
13399 (start-process "gnus-execute" nil "sh" "-c" command)
13400 (call-process "sh" nil t nil "-c" command)))))
13402 (defun gnus-copy-file (file &optional to)
13405 (list (read-file-name "Copy file: " default-directory)
13406 (read-file-name "Copy file to: " default-directory)))
13407 (gnus-set-global-variables)
13408 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13409 (and (file-directory-p to)
13410 (setq to (concat (file-name-as-directory to)
13411 (file-name-nondirectory file))))
13412 (copy-file file to))
13414 ;; Summary kill commands.
13416 (defun gnus-summary-edit-global-kill (article)
13417 "Edit the \"global\" kill file."
13418 (interactive (list (gnus-summary-article-number)))
13419 (gnus-set-global-variables)
13420 (gnus-group-edit-global-kill article))
13422 (defun gnus-summary-edit-local-kill ()
13423 "Edit a local kill file applied to the current newsgroup."
13425 (gnus-set-global-variables)
13426 (setq gnus-current-headers (gnus-summary-article-header))
13427 (gnus-set-global-variables)
13428 (gnus-group-edit-local-kill
13429 (gnus-summary-article-number) gnus-newsgroup-name))
13433 ;;; Gnus article mode
13436 (put 'gnus-article-mode 'mode-class 'special)
13438 (if gnus-article-mode-map
13440 (setq gnus-article-mode-map (make-keymap))
13441 (suppress-keymap gnus-article-mode-map)
13443 (gnus-define-keys gnus-article-mode-map
13444 " " gnus-article-goto-next-page
13445 "\177" gnus-article-goto-prev-page
13446 [delete] gnus-article-goto-prev-page
13447 "\C-c^" gnus-article-refer-article
13448 "h" gnus-article-show-summary
13449 "s" gnus-article-show-summary
13450 "\C-c\C-m" gnus-article-mail
13451 "?" gnus-article-describe-briefly
13452 gnus-mouse-2 gnus-article-push-button
13453 "\r" gnus-article-press-button
13454 "\t" gnus-article-next-button
13455 "\M-\t" gnus-article-prev-button
13456 "\C-c\C-b" gnus-bug)
13458 (substitute-key-definition
13459 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13461 (defun gnus-article-mode ()
13462 "Major mode for displaying an article.
13464 All normal editing commands are switched off.
13466 The following commands are available:
13468 \\<gnus-article-mode-map>
13469 \\[gnus-article-next-page]\t Scroll the article one page forwards
13470 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13471 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13472 \\[gnus-article-show-summary]\t Display the summary buffer
13473 \\[gnus-article-mail]\t Send a reply to the address near point
13474 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13475 \\[gnus-info-find-node]\t Go to the Gnus info node"
13477 (when (and menu-bar-mode
13478 (gnus-visual-p 'article-menu 'menu))
13479 (gnus-article-make-menu-bar))
13480 (kill-all-local-variables)
13481 (gnus-simplify-mode-line)
13482 (setq mode-name "Article")
13483 (setq major-mode 'gnus-article-mode)
13484 (make-local-variable 'minor-mode-alist)
13485 (or (assq 'gnus-show-mime minor-mode-alist)
13486 (setq minor-mode-alist
13487 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13488 (use-local-map gnus-article-mode-map)
13489 (make-local-variable 'page-delimiter)
13490 (setq page-delimiter gnus-page-delimiter)
13491 (buffer-disable-undo (current-buffer))
13492 (setq buffer-read-only t) ;Disable modification
13493 (run-hooks 'gnus-article-mode-hook))
13495 (defun gnus-article-setup-buffer ()
13496 "Initialize the article buffer."
13497 (let* ((name (if gnus-single-article-buffer "*Article*"
13498 (concat "*Article " gnus-newsgroup-name "*")))
13500 (progn (string-match "\\*Article" name)
13501 (concat " *Original Article"
13502 (substring name (match-end 0))))))
13503 (setq gnus-article-buffer name)
13504 (setq gnus-original-article-buffer original)
13505 ;; This might be a variable local to the summary buffer.
13506 (unless gnus-single-article-buffer
13508 (set-buffer gnus-summary-buffer)
13509 (setq gnus-article-buffer name)
13510 (setq gnus-original-article-buffer original)
13511 (gnus-set-global-variables))
13512 (make-local-variable 'gnus-summary-buffer))
13513 ;; Init original article buffer.
13515 (set-buffer (get-buffer-create gnus-original-article-buffer))
13516 (buffer-disable-undo (current-buffer))
13517 (setq major-mode 'gnus-original-article-mode)
13518 (make-local-variable 'gnus-original-article))
13519 (if (get-buffer name)
13522 (buffer-disable-undo (current-buffer))
13523 (setq buffer-read-only t)
13524 (gnus-add-current-to-buffer-list)
13525 (or (eq major-mode 'gnus-article-mode)
13526 (gnus-article-mode))
13529 (set-buffer (get-buffer-create name))
13530 (gnus-add-current-to-buffer-list)
13531 (gnus-article-mode)
13532 (current-buffer)))))
13534 ;; Set article window start at LINE, where LINE is the number of lines
13535 ;; from the head of the article.
13536 (defun gnus-article-set-window-start (&optional line)
13538 (get-buffer-window gnus-article-buffer t)
13540 (set-buffer gnus-article-buffer)
13541 (goto-char (point-min))
13544 (gnus-message 6 "Moved to bookmark")
13545 (search-forward "\n\n" nil t)
13546 (forward-line line)
13549 (defun gnus-kill-all-overlays ()
13550 "Delete all overlays in the current buffer."
13551 (when (fboundp 'overlay-lists)
13552 (let* ((overlayss (overlay-lists))
13553 (buffer-read-only nil)
13554 (overlays (nconc (car overlayss) (cdr overlayss))))
13556 (delete-overlay (pop overlays))))))
13558 (defun gnus-request-article-this-buffer (article group)
13559 "Get an article and insert it into this buffer."
13560 (let (do-update-line)
13564 (gnus-kill-all-overlays)
13565 (setq group (or group gnus-newsgroup-name))
13567 ;; Open server if it has closed.
13568 (gnus-check-server (gnus-find-method-for-group group))
13570 ;; Using `gnus-request-article' directly will insert the article into
13571 ;; `nntp-server-buffer' - so we'll save some time by not having to
13572 ;; copy it from the server buffer into the article buffer.
13574 ;; We only request an article by message-id when we do not have the
13575 ;; headers for it, so we'll have to get those.
13576 (when (stringp article)
13577 (let ((gnus-override-method gnus-refer-article-method))
13578 (gnus-read-header article)))
13580 ;; If the article number is negative, that means that this article
13581 ;; doesn't belong in this newsgroup (possibly), so we find its
13582 ;; message-id and request it by id instead of number.
13583 (when (and (numberp article)
13584 gnus-summary-buffer
13585 (get-buffer gnus-summary-buffer)
13586 (buffer-name (get-buffer gnus-summary-buffer)))
13588 (set-buffer gnus-summary-buffer)
13589 (let ((header (gnus-summary-article-header article)))
13592 ((memq article gnus-newsgroup-sparse)
13593 ;; This is a sparse gap article.
13594 (setq do-update-line article)
13595 (setq article (mail-header-id header))
13596 (let ((gnus-override-method gnus-refer-article-method))
13597 (gnus-read-header article))
13598 (setq gnus-newsgroup-sparse
13599 (delq article gnus-newsgroup-sparse)))
13601 ;; It's a real article.
13602 (setq article (mail-header-id header)))
13604 ;; It is an extracted pseudo-article.
13605 (setq article 'pseudo)
13606 (gnus-request-pseudo-article header))))
13608 (let ((method (gnus-find-method-for-group
13609 gnus-newsgroup-name)))
13610 (if (not (eq (car method) 'nneething))
13612 (let ((dir (concat (file-name-as-directory (nth 1 method))
13613 (mail-header-subject header))))
13614 (if (file-directory-p dir)
13616 (setq article 'nneething)
13617 (gnus-group-enter-directory dir)))))))))
13620 ;; Refuse to select canceled articles.
13621 ((and (numberp article)
13622 gnus-summary-buffer
13623 (get-buffer gnus-summary-buffer)
13624 (buffer-name (get-buffer gnus-summary-buffer))
13625 (eq (cdr (save-excursion
13626 (set-buffer gnus-summary-buffer)
13627 (assq article gnus-newsgroup-reads)))
13628 gnus-canceled-mark))
13630 ;; We first check `gnus-original-article-buffer'.
13631 ((and (get-buffer gnus-original-article-buffer)
13634 (set-buffer gnus-original-article-buffer)
13635 (and (equal (car gnus-original-article) group)
13636 (eq (cdr gnus-original-article) article))))
13637 (insert-buffer-substring gnus-original-article-buffer)
13639 ;; Check the backlog.
13640 ((and gnus-keep-backlog
13641 (gnus-backlog-request-article group article (current-buffer)))
13643 ;; Check the cache.
13644 ((and gnus-use-cache
13646 (gnus-cache-request-article article group))
13648 ;; Get the article and put into the article buffer.
13649 ((or (stringp article) (numberp article))
13650 (let ((gnus-override-method
13651 (and (stringp article) gnus-refer-article-method))
13652 (buffer-read-only nil))
13654 (gnus-kill-all-overlays)
13655 (if (gnus-request-article article group (current-buffer))
13657 (and gnus-keep-backlog
13659 (gnus-backlog-enter-article
13660 group article (current-buffer)))
13662 ;; It was a pseudo.
13665 ;; Take the article from the original article buffer
13666 ;; and place it in the buffer it's supposed to be in.
13667 (when (and (get-buffer gnus-article-buffer)
13668 ;;(numberp article)
13669 (equal (buffer-name (current-buffer))
13670 (buffer-name (get-buffer gnus-article-buffer))))
13672 (if (get-buffer gnus-original-article-buffer)
13673 (set-buffer (get-buffer gnus-original-article-buffer))
13674 (set-buffer (get-buffer-create gnus-original-article-buffer))
13675 (buffer-disable-undo (current-buffer))
13676 (setq major-mode 'gnus-original-article-mode)
13677 (setq buffer-read-only t)
13678 (gnus-add-current-to-buffer-list))
13679 (let (buffer-read-only)
13681 (insert-buffer-substring gnus-article-buffer))
13682 (setq gnus-original-article (cons group article))))
13684 ;; Update sparse articles.
13685 (when (and do-update-line
13686 (or (numberp article)
13687 (stringp article)))
13688 (let ((buf (current-buffer)))
13689 (set-buffer gnus-summary-buffer)
13690 (gnus-summary-update-article do-update-line)
13691 (gnus-summary-goto-subject do-update-line nil t)
13692 (set-window-point (get-buffer-window (current-buffer) t)
13694 (set-buffer buf))))))
13696 (defun gnus-read-header (id &optional header)
13697 "Read the headers of article ID and enter them into the Gnus system."
13698 (let ((group gnus-newsgroup-name)
13699 (gnus-override-method
13700 (and (gnus-news-group-p gnus-newsgroup-name)
13701 gnus-refer-article-method))
13703 ;; First we check to see whether the header in question is already
13706 ;; This is a Message-ID.
13707 (setq header (or header (gnus-id-to-header id)))
13708 ;; This is an article number.
13709 (setq header (or header (gnus-summary-article-header id))))
13711 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13712 ;; We have found the header.
13714 ;; We have to really fetch the header to this article.
13716 (if (gnus-check-backend-function 'request-head group)
13717 (gnus-request-head id group)
13718 (gnus-request-article id group)))
13720 (set-buffer nntp-server-buffer)
13721 (and (search-forward "\n\n" nil t)
13722 (delete-region (1- (point)) (point-max)))
13723 (goto-char (point-max))
13725 (goto-char (point-min))
13729 ((cdr where) (cdr where))
13730 (header (mail-header-number header))
13731 (t gnus-reffed-article-number))
13733 (insert " Article retrieved.\n"))
13735 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13736 ; (setcar (gnus-id-to-thread id) nil))
13737 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13738 () ; Malformed head.
13739 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13740 (if (and (stringp id)
13741 (not (string= (gnus-group-real-name group)
13743 ;; If we fetched by Message-ID and the article came
13744 ;; from a different group, we fudge some bogus article
13745 ;; numbers for this article.
13746 (mail-header-set-number header gnus-reffed-article-number))
13747 (decf gnus-reffed-article-number)
13748 (gnus-remove-header (mail-header-number header))
13749 (push header gnus-newsgroup-headers)
13750 (setq gnus-current-headers header)
13751 (push (mail-header-number header) gnus-newsgroup-limit))
13754 (defun gnus-remove-header (number)
13755 "Remove header NUMBER from `gnus-newsgroup-headers'."
13756 (if (and gnus-newsgroup-headers
13757 (= number (mail-header-number (car gnus-newsgroup-headers))))
13758 (pop gnus-newsgroup-headers)
13759 (let ((headers gnus-newsgroup-headers))
13760 (while (and (cdr headers)
13761 (not (= number (mail-header-number (cadr headers)))))
13763 (when (cdr headers)
13764 (setcdr headers (cddr headers))))))
13766 (defun gnus-article-prepare (article &optional all-headers header)
13767 "Prepare ARTICLE in article mode buffer.
13768 ARTICLE should either be an article number or a Message-ID.
13769 If ARTICLE is an id, HEADER should be the article headers.
13770 If ALL-HEADERS is non-nil, no headers are hidden."
13772 ;; Make sure we start in a summary buffer.
13773 (unless (eq major-mode 'gnus-summary-mode)
13774 (set-buffer gnus-summary-buffer))
13775 (setq gnus-summary-buffer (current-buffer))
13776 ;; Make sure the connection to the server is alive.
13777 (unless (gnus-server-opened
13778 (gnus-find-method-for-group gnus-newsgroup-name))
13779 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13780 (gnus-request-group gnus-newsgroup-name t))
13781 (let* ((article (if header (mail-header-number header) article))
13782 (summary-buffer (current-buffer))
13783 (internal-hook gnus-article-internal-prepare-hook)
13784 (group gnus-newsgroup-name)
13787 (gnus-article-setup-buffer)
13788 (set-buffer gnus-article-buffer)
13789 ;; Deactivate active regions.
13790 (when (and (boundp 'transient-mark-mode)
13791 transient-mark-mode)
13792 (setq mark-active nil))
13793 (if (not (setq result (let ((buffer-read-only nil))
13794 (gnus-request-article-this-buffer
13796 ;; There is no such article.
13798 (when (and (numberp article)
13799 (not (memq article gnus-newsgroup-sparse)))
13800 (setq gnus-article-current
13801 (cons gnus-newsgroup-name article))
13802 (set-buffer gnus-summary-buffer)
13803 (setq gnus-current-article article)
13804 (gnus-summary-mark-article article gnus-canceled-mark))
13805 (unless (memq article gnus-newsgroup-sparse)
13807 1 "No such article (may have expired or been canceled)")))
13808 (if (or (eq result 'pseudo) (eq result 'nneething))
13811 (set-buffer summary-buffer)
13812 (setq gnus-last-article gnus-current-article
13813 gnus-newsgroup-history (cons gnus-current-article
13814 gnus-newsgroup-history)
13815 gnus-current-article 0
13816 gnus-current-headers nil
13817 gnus-article-current nil)
13818 (if (eq result 'nneething)
13819 (gnus-configure-windows 'summary)
13820 (gnus-configure-windows 'article))
13821 (gnus-set-global-variables))
13822 (gnus-set-mode-line 'article))
13823 ;; The result from the `request' was an actual article -
13824 ;; or at least some text that is now displayed in the
13826 (if (and (numberp article)
13827 (not (eq article gnus-current-article)))
13828 ;; Seems like a new article has been selected.
13829 ;; `gnus-current-article' must be an article number.
13831 (set-buffer summary-buffer)
13832 (setq gnus-last-article gnus-current-article
13833 gnus-newsgroup-history (cons gnus-current-article
13834 gnus-newsgroup-history)
13835 gnus-current-article article
13836 gnus-current-headers
13837 (gnus-summary-article-header gnus-current-article)
13838 gnus-article-current
13839 (cons gnus-newsgroup-name gnus-current-article))
13840 (unless (vectorp gnus-current-headers)
13841 (setq gnus-current-headers nil))
13842 (gnus-summary-show-thread)
13843 (run-hooks 'gnus-mark-article-hook)
13844 (gnus-set-mode-line 'summary)
13845 (and (gnus-visual-p 'article-highlight 'highlight)
13846 (run-hooks 'gnus-visual-mark-article-hook))
13847 ;; Set the global newsgroup variables here.
13848 ;; Suggested by Jim Sisolak
13849 ;; <sisolak@trans4.neep.wisc.edu>.
13850 (gnus-set-global-variables)
13851 (setq gnus-have-all-headers
13852 (or all-headers gnus-show-all-headers))
13853 (and gnus-use-cache
13854 (vectorp (gnus-summary-article-header article))
13855 (gnus-cache-possibly-enter-article
13857 (gnus-summary-article-header article)
13858 (memq article gnus-newsgroup-marked)
13859 (memq article gnus-newsgroup-dormant)
13860 (memq article gnus-newsgroup-unreads)))))
13861 (when (or (numberp article)
13863 ;; Hooks for getting information from the article.
13864 ;; This hook must be called before being narrowed.
13865 (let (buffer-read-only)
13866 (run-hooks 'internal-hook)
13867 (run-hooks 'gnus-article-prepare-hook)
13868 ;; Decode MIME message.
13870 (if (or (not gnus-strict-mime)
13871 (gnus-fetch-field "Mime-Version"))
13872 (funcall gnus-show-mime-method)
13873 (funcall gnus-decode-encoded-word-method)))
13874 ;; Perform the article display hooks.
13875 (run-hooks 'gnus-article-display-hook))
13877 (goto-char (point-min))
13878 (and gnus-break-pages (gnus-narrow-to-page)))
13879 (gnus-set-mode-line 'article)
13880 (gnus-configure-windows 'article)
13881 (goto-char (point-min))
13884 (defun gnus-article-show-all-headers ()
13885 "Show all article headers in article mode buffer."
13887 (gnus-article-setup-buffer)
13888 (set-buffer gnus-article-buffer)
13889 (let ((buffer-read-only nil))
13890 (gnus-unhide-text (point-min) (point-max)))))
13892 (defun gnus-article-hide-headers-if-wanted ()
13893 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13894 Provided for backwards compatibility."
13895 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13896 gnus-inhibit-hiding
13897 (gnus-article-hide-headers)))
13899 (defsubst gnus-article-header-rank ()
13900 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13901 (let ((list gnus-sorted-header-list)
13904 (when (looking-at (car list))
13906 (setq list (cdr list))
13910 (defun gnus-article-hide-headers (&optional arg delete)
13911 "Toggle whether to hide unwanted headers and possibly sort them as well.
13912 If given a negative prefix, always show; if given a positive prefix,
13914 (interactive (gnus-hidden-arg))
13915 (if (gnus-article-check-hidden-text 'headers arg)
13916 ;; Show boring headers as well.
13917 (gnus-article-show-hidden-text 'boring-headers)
13918 ;; This function might be inhibited.
13919 (unless gnus-inhibit-hiding
13921 (set-buffer gnus-article-buffer)
13923 (let ((buffer-read-only nil)
13924 (props (nconc (list 'gnus-type 'headers)
13925 gnus-hidden-properties))
13926 (max (1+ (length gnus-sorted-header-list)))
13927 (ignored (when (not (stringp gnus-visible-headers))
13928 (cond ((stringp gnus-ignored-headers)
13929 gnus-ignored-headers)
13930 ((listp gnus-ignored-headers)
13931 (mapconcat 'identity gnus-ignored-headers
13934 (cond ((stringp gnus-visible-headers)
13935 gnus-visible-headers)
13936 ((and gnus-visible-headers
13937 (listp gnus-visible-headers))
13938 (mapconcat 'identity gnus-visible-headers "\\|"))))
13939 (inhibit-point-motion-hooks t)
13941 ;; First we narrow to just the headers.
13943 (goto-char (point-min))
13944 ;; Hide any "From " lines at the beginning of (mail) articles.
13945 (while (looking-at "From ")
13949 (delete-region (point-min) (point))
13950 (gnus-hide-text (point-min) (point) props)))
13951 ;; Then treat the rest of the header lines.
13954 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13955 ;; Then we use the two regular expressions
13956 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13957 ;; select which header lines is to remain visible in the
13959 (goto-char (point-min))
13960 (while (re-search-forward "^[^ \t]*:" nil t)
13961 (beginning-of-line)
13962 ;; We add the headers we want to keep to a list and delete
13963 ;; them from the buffer.
13964 (gnus-put-text-property
13965 (point) (1+ (point)) 'message-rank
13966 (if (or (and visible (looking-at visible))
13968 (not (looking-at ignored))))
13969 (gnus-article-header-rank)
13972 (message-sort-headers-1)
13973 (when (setq beg (text-property-any
13974 (point-min) (point-max) 'message-rank (+ 2 max)))
13975 ;; We make the unwanted headers invisible.
13977 (delete-region beg (point-max))
13978 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13979 (gnus-hide-text-type beg (point-max) 'headers))
13980 ;; Work around XEmacs lossage.
13981 (gnus-put-text-property (point-min) beg 'invisible nil))))))))
13983 (defun gnus-article-hide-boring-headers (&optional arg)
13984 "Toggle hiding of headers that aren't very interesting.
13985 If given a negative prefix, always show; if given a positive prefix,
13987 (interactive (gnus-hidden-arg))
13988 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13990 (set-buffer gnus-article-buffer)
13992 (let ((buffer-read-only nil)
13993 (list gnus-boring-article-headers)
13994 (inhibit-point-motion-hooks t)
13996 (nnheader-narrow-to-headers)
13998 (setq elem (pop list))
13999 (goto-char (point-min))
14001 ;; Hide empty headers.
14003 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
14005 (gnus-hide-text-type
14006 (progn (beginning-of-line) (point))
14009 (if (re-search-forward "^[^ \t]" nil t)
14010 (match-beginning 0)
14013 ;; Hide boring Newsgroups header.
14014 ((eq elem 'newsgroups)
14015 (when (equal (message-fetch-field "newsgroups")
14016 (gnus-group-real-name gnus-newsgroup-name))
14017 (gnus-article-hide-header "newsgroups")))
14018 ((eq elem 'followup-to)
14019 (when (equal (message-fetch-field "followup-to")
14020 (message-fetch-field "newsgroups"))
14021 (gnus-article-hide-header "followup-to")))
14022 ((eq elem 'reply-to)
14023 (let ((from (message-fetch-field "from"))
14024 (reply-to (message-fetch-field "reply-to")))
14028 (nth 1 (funcall gnus-extract-address-components from))
14029 (nth 1 (funcall gnus-extract-address-components
14031 (gnus-article-hide-header "reply-to"))))
14033 (let ((date (message-fetch-field "date")))
14035 (< (gnus-days-between date (current-time-string))
14037 (gnus-article-hide-header "date")))))))))))
14039 (defun gnus-article-hide-header (header)
14041 (goto-char (point-min))
14042 (when (re-search-forward (concat "^" header ":") nil t)
14043 (gnus-hide-text-type
14044 (progn (beginning-of-line) (point))
14047 (if (re-search-forward "^[^ \t]" nil t)
14048 (match-beginning 0)
14050 'boring-headers))))
14052 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
14053 (defun gnus-article-treat-overstrike ()
14054 "Translate overstrikes into bold text."
14057 (set-buffer gnus-article-buffer)
14058 (let ((buffer-read-only nil))
14059 (while (search-forward "\b" nil t)
14060 (let ((next (following-char))
14061 (previous (char-after (- (point) 2))))
14063 ((eq next previous)
14064 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14065 (gnus-put-text-property (point) (1+ (point)) 'face 'bold))
14067 (gnus-put-text-property (1- (point)) (1+ (point)) 'invisible t)
14068 (gnus-put-text-property
14069 (- (point) 2) (1- (point)) 'face 'underline))
14071 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
14072 (gnus-put-text-property
14073 (point) (1+ (point)) 'face 'underline))))))))
14075 (defun gnus-article-word-wrap ()
14076 "Format too long lines."
14079 (set-buffer gnus-article-buffer)
14080 (let ((buffer-read-only nil))
14082 (goto-char (point-min))
14083 (search-forward "\n\n" nil t)
14085 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
14086 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
14087 (adaptive-fill-mode t))
14088 (while (not (eobp))
14089 (and (>= (current-column) (min fill-column (window-width)))
14090 (/= (preceding-char) ?:)
14091 (fill-paragraph nil))
14092 (end-of-line 2))))))
14094 (defun gnus-article-remove-cr ()
14095 "Remove carriage returns from an article."
14098 (set-buffer gnus-article-buffer)
14099 (let ((buffer-read-only nil))
14100 (goto-char (point-min))
14101 (while (search-forward "\r" nil t)
14102 (replace-match "" t t)))))
14104 (defun gnus-article-remove-trailing-blank-lines ()
14105 "Remove all trailing blank lines from the article."
14108 (set-buffer gnus-article-buffer)
14109 (let ((buffer-read-only nil))
14110 (goto-char (point-max))
14114 (while (looking-at "^[ \t]*$")
14119 (defun gnus-article-display-x-face (&optional force)
14120 "Look for an X-Face header and display it if present."
14121 (interactive (list 'force))
14123 (set-buffer gnus-article-buffer)
14124 ;; Delete the old process, if any.
14125 (when (process-status "gnus-x-face")
14126 (delete-process "gnus-x-face"))
14127 (let ((inhibit-point-motion-hooks t)
14128 (case-fold-search nil)
14131 (nnheader-narrow-to-headers)
14132 (setq from (message-fetch-field "from"))
14133 (goto-char (point-min))
14134 (when (and gnus-article-x-face-command
14136 ;; Check whether this face is censored.
14137 (not gnus-article-x-face-too-ugly)
14138 (and gnus-article-x-face-too-ugly from
14139 (not (string-match gnus-article-x-face-too-ugly
14141 ;; Has to be present.
14142 (re-search-forward "^X-Face: " nil t))
14143 ;; We now have the area of the buffer where the X-Face is stored.
14144 (let ((beg (point))
14145 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
14146 ;; We display the face.
14147 (if (symbolp gnus-article-x-face-command)
14148 ;; The command is a lisp function, so we call it.
14149 (if (gnus-functionp gnus-article-x-face-command)
14150 (funcall gnus-article-x-face-command beg end)
14151 (error "%s is not a function" gnus-article-x-face-command))
14152 ;; The command is a string, so we interpret the command
14153 ;; as a, well, command, and fork it off.
14154 (let ((process-connection-type nil))
14155 (process-kill-without-query
14157 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
14158 (process-send-region "gnus-x-face" beg end)
14159 (process-send-eof "gnus-x-face")))))))))
14161 (defalias 'gnus-headers-decode-quoted-printable 'gnus-decode-rfc1522)
14162 (defun gnus-decode-rfc1522 ()
14163 "Hack to remove QP encoding from headers."
14164 (let ((case-fold-search t)
14165 (inhibit-point-motion-hooks t)
14166 (buffer-read-only nil)
14170 (goto-char (point-min))
14171 (or (search-forward "\n\n" nil t) (point-max)))
14173 (while (re-search-forward
14174 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
14175 (setq string (match-string 1))
14176 (narrow-to-region (match-beginning 0) (match-end 0))
14177 (delete-region (point-min) (point-max))
14179 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
14180 (subst-char-in-region (point-min) (point-max) ?_ ? )
14182 (goto-char (point-min))))))
14184 (defun gnus-article-de-quoted-unreadable (&optional force)
14185 "Do a naive translation of a quoted-printable-encoded article.
14186 This is in no way, shape or form meant as a replacement for real MIME
14187 processing, but is simply a stop-gap measure until MIME support is
14189 If FORCE, decode the article whether it is marked as quoted-printable
14191 (interactive (list 'force))
14193 (set-buffer gnus-article-buffer)
14194 (let ((case-fold-search t)
14195 (buffer-read-only nil)
14196 (type (gnus-fetch-field "content-transfer-encoding")))
14197 (gnus-decode-rfc1522)
14199 (and type (string-match "quoted-printable" (downcase type))))
14200 (goto-char (point-min))
14201 (search-forward "\n\n" nil 'move)
14202 (gnus-mime-decode-quoted-printable (point) (point-max))))))
14204 (defun gnus-mime-decode-quoted-printable (from to)
14205 "Decode Quoted-Printable in the region between FROM and TO."
14208 (while (search-forward "=" to t)
14209 (cond ((eq (following-char) ?\n)
14212 ((looking-at "[0-9A-F][0-9A-F]")
14213 (subst-char-in-region
14214 (1- (point)) (point) ?=
14215 (hexl-hex-string-to-integer
14216 (buffer-substring (point) (+ 2 (point)))))
14220 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
14222 (defun gnus-article-hide-pgp (&optional arg)
14223 "Toggle hiding of any PGP headers and signatures in the current article.
14224 If given a negative prefix, always show; if given a positive prefix,
14226 (interactive (gnus-hidden-arg))
14227 (unless (gnus-article-check-hidden-text 'pgp arg)
14229 (set-buffer gnus-article-buffer)
14230 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
14231 buffer-read-only beg end)
14233 (goto-char (point-min))
14234 ;; Hide the "header".
14235 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
14236 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14238 ;; Hide the actual signature.
14239 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
14240 (setq end (1+ (match-beginning 0)))
14243 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
14245 ;; Perhaps we shouldn't hide to the end of the buffer
14246 ;; if there is no end to the signature?
14249 ;; Hide "- " PGP quotation markers.
14250 (when (and beg end)
14251 (narrow-to-region beg end)
14252 (goto-char (point-min))
14253 (while (re-search-forward "^- " nil t)
14254 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14257 (defun gnus-article-hide-signature (&optional arg)
14258 "Hide the signature in the current article.
14259 If given a negative prefix, always show; if given a positive prefix,
14261 (interactive (gnus-hidden-arg))
14262 (unless (gnus-article-check-hidden-text 'signature arg)
14264 (set-buffer gnus-article-buffer)
14266 (let ((buffer-read-only nil))
14267 (when (gnus-narrow-to-signature)
14268 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
14270 (defun gnus-article-strip-leading-blank-lines ()
14271 "Remove all blank lines from the beginning of the article."
14274 (set-buffer gnus-article-buffer)
14275 (let (buffer-read-only)
14276 (goto-char (point-min))
14277 (when (search-forward "\n\n" nil t)
14278 (while (looking-at "[ \t]$")
14279 (gnus-delete-line))))))
14281 (defvar mime::preview/content-list)
14282 (defvar mime::preview-content-info/point-min)
14283 (defun gnus-narrow-to-signature ()
14284 "Narrow to the signature."
14286 (if (and (boundp 'mime::preview/content-list)
14287 mime::preview/content-list)
14288 (let ((pcinfo (car (last mime::preview/content-list))))
14291 (funcall (intern "mime::preview-content-info/point-min") pcinfo)
14294 (goto-char (point-max))
14295 (when (re-search-backward gnus-signature-separator nil t)
14297 (when (or (null gnus-signature-limit)
14298 (and (numberp gnus-signature-limit)
14299 (< (- (point-max) (point)) gnus-signature-limit))
14300 (and (gnus-functionp gnus-signature-limit)
14301 (funcall gnus-signature-limit))
14302 (and (stringp gnus-signature-limit)
14303 (not (re-search-forward gnus-signature-limit nil t))))
14304 (narrow-to-region (point) (point-max))
14307 (defun gnus-hidden-arg ()
14308 "Return the current prefix arg as a number, or 0 if no prefix."
14309 (list (if current-prefix-arg
14310 (prefix-numeric-value current-prefix-arg)
14313 (defun gnus-article-check-hidden-text (type arg)
14314 "Return nil if hiding is necessary.
14315 Arg can be nil or a number. Nil and positive means hide, negative
14316 means show, 0 means toggle."
14318 (set-buffer gnus-article-buffer)
14319 (let ((hide (gnus-article-hidden-text-p type)))
14325 (gnus-article-show-hidden-text type))
14327 (if (eq hide 'hidden)
14328 (gnus-article-show-hidden-text type)
14331 (defun gnus-article-hidden-text-p (type)
14332 "Say whether the current buffer contains hidden text of type TYPE."
14333 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
14335 (if (get-text-property pos 'invisible)
14339 (defun gnus-article-hide (&optional arg force)
14340 "Hide all the gruft in the current article.
14341 This means that PGP stuff, signatures, cited text and (some)
14342 headers will be hidden.
14343 If given a prefix, show the hidden text instead."
14344 (interactive (list current-prefix-arg 'force))
14345 (gnus-article-hide-headers arg)
14346 (gnus-article-hide-pgp arg)
14347 (gnus-article-hide-citation-maybe arg force)
14348 (gnus-article-hide-signature arg))
14350 (defun gnus-article-show-hidden-text (type &optional hide)
14351 "Show all hidden text of type TYPE.
14352 If HIDE, hide the text instead."
14354 (set-buffer gnus-article-buffer)
14355 (let ((buffer-read-only nil)
14356 (inhibit-point-motion-hooks t)
14358 (while (gnus-goto-char (text-property-any
14359 beg (point-max) 'gnus-type type))
14363 (gnus-hide-text beg (point) gnus-hidden-properties)
14364 (gnus-unhide-text beg (point)))
14365 (setq beg (point)))
14368 (defvar gnus-article-time-units
14369 `((year . ,(* 365.25 24 60 60))
14370 (week . ,(* 7 24 60 60))
14371 (day . ,(* 24 60 60))
14372 (hour . ,(* 60 60))
14375 "Mapping from time units to seconds.")
14377 (defun gnus-article-date-ut (&optional type highlight)
14378 "Convert DATE date to universal time in the current article.
14379 If TYPE is `local', convert to local time; if it is `lapsed', output
14380 how much time has lapsed since DATE."
14381 (interactive (list 'ut t))
14382 (let* ((header (or gnus-current-headers
14383 (gnus-summary-article-header) ""))
14384 (date (and (vectorp header) (mail-header-date header)))
14385 (date-regexp "^Date: \\|^X-Sent: ")
14386 (now (current-time))
14387 (inhibit-point-motion-hooks t)
14389 (when (and date (not (string= date "")))
14391 (set-buffer gnus-article-buffer)
14393 (nnheader-narrow-to-headers)
14394 (let ((buffer-read-only nil))
14395 ;; Delete any old Date headers.
14396 (if (re-search-forward date-regexp nil t)
14398 (setq bface (get-text-property (gnus-point-at-bol) 'face)
14399 eface (get-text-property (1- (gnus-point-at-eol))
14401 (message-remove-header date-regexp t)
14402 (beginning-of-line))
14403 (goto-char (point-max)))
14404 (insert (gnus-make-date-line date type))
14405 ;; Do highlighting.
14407 (when (and (gnus-visual-p 'article-highlight 'highlight)
14408 (looking-at "\\([^:]+\\): *\\(.*\\)$"))
14409 (gnus-put-text-property (match-beginning 1) (match-end 1)
14411 (gnus-put-text-property (match-beginning 2) (match-end 2)
14412 'face eface))))))))
14414 (defun gnus-make-date-line (date type)
14415 "Return a DATE line of TYPE."
14417 ;; Convert to the local timezone. We have to slap a
14418 ;; `condition-case' round the calls to the timezone
14419 ;; functions since they aren't particularly resistant to
14422 (concat "Date: " (condition-case ()
14423 (timezone-make-date-arpa-standard date)
14426 ;; Convert to Universal Time.
14430 (timezone-make-date-arpa-standard date nil "UT")
14433 ;; Get the original date from the article.
14434 ((eq type 'original)
14435 (concat "Date: " date "\n"))
14436 ;; Do an X-Sent lapsed format.
14438 ;; If the date is seriously mangled, the timezone
14439 ;; functions are liable to bug out, so we condition-case
14440 ;; the entire thing.
14441 (let* ((now (current-time))
14446 (timezone-make-date-arpa-standard
14447 (current-time-string now)
14448 (current-time-zone now) "UT"))
14450 (timezone-make-date-arpa-standard
14453 (real-sec (+ (* (float (car real-time)) 65536)
14455 (sec (abs real-sec))
14458 ((equal real-time '(0 0))
14459 "X-Sent: Unknown\n")
14465 ;; This is a bit convoluted, but basically we go
14466 ;; through the time units for years, weeks, etc,
14467 ;; and divide things to see whether that results
14468 ;; in positive answers.
14471 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14472 ;; The (remaining) seconds are too few to
14473 ;; be divided into this time unit.
14475 ;; It's big enough, so we output it.
14476 (setq sec (- sec (* num (cdr unit))))
14478 (concat (if prev ", " "") (int-to-string
14480 " " (symbol-name (car unit))
14481 (if (> num 1) "s" ""))
14483 gnus-article-time-units "")
14484 ;; If dates are odd, then it might appear like the
14485 ;; article was sent in the future.
14488 " in the future\n"))))))
14490 (error "Unknown conversion type: %s" type))))
14492 (defun gnus-article-date-local (&optional highlight)
14493 "Convert the current article date to the local timezone."
14494 (interactive (list t))
14495 (gnus-article-date-ut 'local highlight))
14497 (defun gnus-article-date-original (&optional highlight)
14498 "Convert the current article date to what it was originally.
14499 This is only useful if you have used some other date conversion
14500 function and want to see what the date was before converting."
14501 (interactive (list t))
14502 (gnus-article-date-ut 'original highlight))
14504 (defun gnus-article-date-lapsed (&optional highlight)
14505 "Convert the current article date to time lapsed since it was sent."
14506 (interactive (list t))
14507 (gnus-article-date-ut 'lapsed highlight))
14509 (defun gnus-article-maybe-highlight ()
14510 "Do some article highlighting if `gnus-visual' is non-nil."
14511 (if (gnus-visual-p 'article-highlight 'highlight)
14512 (gnus-article-highlight-some)))
14514 ;;; Article savers.
14516 (defun gnus-output-to-rmail (file-name)
14517 "Append the current article to an Rmail file named FILE-NAME."
14519 ;; Most of these codes are borrowed from rmailout.el.
14520 (setq file-name (expand-file-name file-name))
14521 (setq rmail-default-rmail-file file-name)
14522 (let ((artbuf (current-buffer))
14523 (tmpbuf (get-buffer-create " *Gnus-output*")))
14525 (or (get-file-buffer file-name)
14526 (file-exists-p file-name)
14527 (if (gnus-yes-or-no-p
14528 (concat "\"" file-name "\" does not exist, create it? "))
14529 (let ((file-buffer (create-file-buffer file-name)))
14531 (set-buffer file-buffer)
14532 (rmail-insert-rmail-file-header)
14533 (let ((require-final-newline nil))
14534 (write-region (point-min) (point-max) file-name t 1)))
14535 (kill-buffer file-buffer))
14536 (error "Output file does not exist")))
14537 (set-buffer tmpbuf)
14538 (buffer-disable-undo (current-buffer))
14540 (insert-buffer-substring artbuf)
14541 (gnus-convert-article-to-rmail)
14542 ;; Decide whether to append to a file or to an Emacs buffer.
14543 (let ((outbuf (get-file-buffer file-name)))
14545 (append-to-file (point-min) (point-max) file-name)
14546 ;; File has been visited, in buffer OUTBUF.
14547 (set-buffer outbuf)
14548 (let ((buffer-read-only nil)
14549 (msg (and (boundp 'rmail-current-message)
14550 (symbol-value 'rmail-current-message))))
14551 ;; If MSG is non-nil, buffer is in RMAIL mode.
14554 (narrow-to-region (point-max) (point-max))))
14555 (insert-buffer-substring tmpbuf)
14558 (goto-char (point-min))
14560 (search-backward "\^_")
14561 (narrow-to-region (point) (point-max))
14562 (goto-char (1+ (point-min)))
14563 (rmail-count-new-messages t)
14564 (rmail-show-message msg)))))))
14565 (kill-buffer tmpbuf)))
14567 (defun gnus-output-to-file (file-name)
14568 "Append the current article to a file named FILE-NAME."
14569 (let ((artbuf (current-buffer)))
14570 (nnheader-temp-write nil
14571 (insert-buffer-substring artbuf)
14572 ;; Append newline at end of the buffer as separator, and then
14573 ;; save it to file.
14574 (goto-char (point-max))
14576 (append-to-file (point-min) (point-max) file-name))))
14578 (defun gnus-convert-article-to-rmail ()
14579 "Convert article in current buffer to Rmail message format."
14580 (let ((buffer-read-only nil))
14581 ;; Convert article directly into Babyl format.
14582 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14583 (goto-char (point-min))
14584 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14585 (while (search-forward "\n\^_" nil t) ;single char
14586 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14587 (goto-char (point-max))
14590 (defun gnus-narrow-to-page (&optional arg)
14591 "Narrow the article buffer to a page.
14592 If given a numerical ARG, move forward ARG pages."
14594 (setq arg (if arg (prefix-numeric-value arg) 0))
14596 (set-buffer gnus-article-buffer)
14597 (goto-char (point-min))
14599 (when (gnus-visual-p 'page-marker)
14600 (let ((buffer-read-only nil))
14601 (gnus-remove-text-with-property 'gnus-prev)
14602 (gnus-remove-text-with-property 'gnus-next)))
14605 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14607 (re-search-forward page-delimiter nil 'move arg)))
14608 (goto-char (match-end 0)))
14611 (if (re-search-forward page-delimiter nil 'move)
14612 (match-beginning 0)
14614 (when (and (gnus-visual-p 'page-marker)
14615 (not (= (point-min) 1)))
14617 (goto-char (point-min))
14618 (gnus-insert-prev-page-button)))
14619 (when (and (gnus-visual-p 'page-marker)
14620 (not (= (1- (point-max)) (buffer-size))))
14622 (goto-char (point-max))
14623 (gnus-insert-next-page-button)))))
14625 ;; Article mode commands
14627 (defun gnus-article-goto-next-page ()
14628 "Show the next page of the article."
14630 (when (gnus-article-next-page)
14631 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
14633 (defun gnus-article-goto-prev-page ()
14634 "Show the next page of the article."
14636 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))
14637 (gnus-article-prev-page nil)))
14639 (defun gnus-article-next-page (&optional lines)
14640 "Show the next page of the current article.
14641 If end of article, return non-nil. Otherwise return nil.
14642 Argument LINES specifies lines to be scrolled up."
14644 (move-to-window-line -1)
14645 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14646 (if (save-excursion
14648 (and (pos-visible-in-window-p) ;Not continuation line.
14650 ;; Nothing in this page.
14651 (if (or (not gnus-break-pages)
14654 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14656 (gnus-narrow-to-page 1) ;Go to next page.
14658 ;; More in this page.
14662 ;; Long lines may cause an end-of-buffer error.
14663 (goto-char (point-max))))
14664 (move-to-window-line 0)
14667 (defun gnus-article-prev-page (&optional lines)
14668 "Show previous page of current article.
14669 Argument LINES specifies lines to be scrolled down."
14671 (move-to-window-line 0)
14672 (if (and gnus-break-pages
14674 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14676 (gnus-narrow-to-page -1) ;Go to previous page.
14677 (goto-char (point-max))
14681 (scroll-down lines)
14683 (move-to-window-line 0))))
14685 (defun gnus-article-refer-article ()
14686 "Read article specified by message-id around point."
14688 (let ((point (point)))
14689 (search-forward ">" nil t) ;Move point to end of "<....>".
14690 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14691 (let ((message-id (match-string 1)))
14693 (set-buffer gnus-summary-buffer)
14694 (gnus-summary-refer-article message-id))
14695 (goto-char (point))
14696 (error "No references around point"))))
14698 (defun gnus-article-show-summary ()
14699 "Reconfigure windows to show summary buffer."
14701 (gnus-configure-windows 'article)
14702 (gnus-summary-goto-subject gnus-current-article))
14704 (defun gnus-article-describe-briefly ()
14705 "Describe article mode commands briefly."
14708 (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-next-page]:Next page \\[gnus-article-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help")))
14710 (defun gnus-article-summary-command ()
14711 "Execute the last keystroke in the summary buffer."
14713 (let ((obuf (current-buffer))
14714 (owin (current-window-configuration))
14716 (switch-to-buffer gnus-summary-buffer 'norecord)
14717 (setq func (lookup-key (current-local-map) (this-command-keys)))
14718 (call-interactively func)
14720 (set-window-configuration owin)
14721 (set-window-point (get-buffer-window (current-buffer)) (point))))
14723 (defun gnus-article-summary-command-nosave ()
14724 "Execute the last keystroke in the summary buffer."
14727 (pop-to-buffer gnus-summary-buffer 'norecord)
14728 (setq func (lookup-key (current-local-map) (this-command-keys)))
14729 (call-interactively func)))
14731 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14732 "Read a summary buffer key sequence and execute it from the article buffer."
14735 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14736 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14737 "=" "^" "\M-^" "|"))
14740 (set-buffer gnus-summary-buffer)
14741 (push (or key last-command-event) unread-command-events)
14742 (setq keys (read-key-sequence nil)))
14745 (if (member keys nosaves)
14747 (pop-to-buffer gnus-summary-buffer 'norecord)
14748 (if (setq func (lookup-key (current-local-map) keys))
14749 (call-interactively func)
14751 (let ((obuf (current-buffer))
14752 (owin (current-window-configuration))
14755 (if not-restore-window
14756 (pop-to-buffer gnus-summary-buffer 'norecord)
14757 (switch-to-buffer gnus-summary-buffer 'norecord))
14758 (setq in-buffer (current-buffer))
14759 (if (setq func (lookup-key (current-local-map) keys))
14760 (call-interactively func)
14762 (when (eq in-buffer (current-buffer))
14764 (unless not-restore-window
14765 (set-window-configuration owin))
14766 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14770 ;;; Kill file handling.
14774 (defalias 'gnus-batch-kill 'gnus-batch-score)
14776 (defun gnus-batch-score ()
14777 "Run batched scoring.
14778 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14779 Newsgroups is a list of strings in Bnews format. If you want to score
14780 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14781 score the alt hierarchy, you'd say \"!alt.all\"."
14784 (gnus-newsrc-parse-options
14785 (apply (function concat)
14786 (mapcar (lambda (g) (concat g " "))
14787 command-line-args-left))))
14788 (gnus-expert-user t)
14789 (nnmail-spool-file nil)
14790 (gnus-use-dribble-file nil)
14791 (yes (car yes-and-no))
14792 (no (cdr yes-and-no))
14794 ;; Disable verbose message.
14795 gnus-novice-user gnus-large-newsgroup)
14796 ;; Eat all arguments.
14797 (setq command-line-args-left nil)
14800 ;; Apply kills to specified newsgroups in command line arguments.
14801 (setq newsrc (cdr gnus-newsrc-alist))
14803 (setq group (caar newsrc))
14804 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14805 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14807 (or (eq (car entry) t)
14808 (not (zerop (car entry)))))
14809 (if yes (string-match yes group) t)
14810 (or (null no) (not (string-match no group))))
14812 (gnus-summary-read-group group nil t nil t)
14813 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14814 (gnus-summary-exit))))
14815 (setq newsrc (cdr newsrc)))
14817 (switch-to-buffer gnus-group-buffer)
14818 (gnus-group-save-newsrc)))
14820 (defun gnus-apply-kill-file ()
14821 "Apply a kill file to the current newsgroup.
14822 Returns the number of articles marked as read."
14823 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14824 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14825 (gnus-apply-kill-file-internal)
14828 (defun gnus-kill-save-kill-buffer ()
14829 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14830 (when (get-file-buffer file)
14832 (set-buffer (get-file-buffer file))
14833 (and (buffer-modified-p) (save-buffer))
14834 (kill-buffer (current-buffer))))))
14836 (defvar gnus-kill-file-name "KILL"
14837 "Suffix of the kill files.")
14839 (defun gnus-newsgroup-kill-file (newsgroup)
14840 "Return the name of a kill file name for NEWSGROUP.
14841 If NEWSGROUP is nil, return the global kill file name instead."
14843 ;; The global KILL file is placed at top of the directory.
14844 ((or (null newsgroup)
14845 (string-equal newsgroup ""))
14846 (expand-file-name gnus-kill-file-name
14847 gnus-kill-files-directory))
14848 ;; Append ".KILL" to newsgroup name.
14849 ((gnus-use-long-file-name 'not-kill)
14850 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14851 "." gnus-kill-file-name)
14852 gnus-kill-files-directory))
14853 ;; Place "KILL" under the hierarchical directory.
14855 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14856 "/" gnus-kill-file-name)
14857 gnus-kill-files-directory))))
14864 (defvar gnus-dribble-ignore nil)
14865 (defvar gnus-dribble-eval-file nil)
14867 (defun gnus-dribble-file-name ()
14868 "Return the dribble file for the current .newsrc."
14870 (if gnus-dribble-directory
14871 (concat (file-name-as-directory gnus-dribble-directory)
14872 (file-name-nondirectory gnus-current-startup-file))
14873 gnus-current-startup-file)
14876 (defun gnus-dribble-enter (string)
14877 "Enter STRING into the dribble buffer."
14878 (if (and (not gnus-dribble-ignore)
14879 gnus-dribble-buffer
14880 (buffer-name gnus-dribble-buffer))
14881 (let ((obuf (current-buffer)))
14882 (set-buffer gnus-dribble-buffer)
14883 (insert string "\n")
14884 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14885 (set-buffer obuf))))
14887 (defun gnus-dribble-read-file ()
14888 "Read the dribble file from disk."
14889 (let ((dribble-file (gnus-dribble-file-name)))
14891 (set-buffer (setq gnus-dribble-buffer
14893 (file-name-nondirectory dribble-file))))
14894 (gnus-add-current-to-buffer-list)
14896 (setq buffer-file-name dribble-file)
14898 (buffer-disable-undo (current-buffer))
14899 (bury-buffer (current-buffer))
14900 (set-buffer-modified-p nil)
14901 (let ((auto (make-auto-save-file-name))
14902 (gnus-dribble-ignore t)
14904 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14905 ;; Load whichever file is newest -- the auto save file
14906 ;; or the "real" file.
14907 (if (file-newer-than-file-p auto dribble-file)
14908 (insert-file-contents auto)
14909 (insert-file-contents dribble-file))
14910 (unless (zerop (buffer-size))
14911 (set-buffer-modified-p t))
14912 ;; Set the file modes to reflect the .newsrc file modes.
14914 (when (and (file-exists-p gnus-current-startup-file)
14915 (setq modes (file-modes gnus-current-startup-file)))
14916 (set-file-modes dribble-file modes))
14917 ;; Possibly eval the file later.
14918 (when (gnus-y-or-n-p
14919 "Auto-save file exists. Do you want to read it? ")
14920 (setq gnus-dribble-eval-file t)))))))
14922 (defun gnus-dribble-eval-file ()
14923 (when gnus-dribble-eval-file
14924 (setq gnus-dribble-eval-file nil)
14926 (let ((gnus-dribble-ignore t))
14927 (set-buffer gnus-dribble-buffer)
14928 (eval-buffer (current-buffer))))))
14930 (defun gnus-dribble-delete-file ()
14931 (when (file-exists-p (gnus-dribble-file-name))
14932 (delete-file (gnus-dribble-file-name)))
14933 (when gnus-dribble-buffer
14935 (set-buffer gnus-dribble-buffer)
14936 (let ((auto (make-auto-save-file-name)))
14937 (if (file-exists-p auto)
14938 (delete-file auto))
14940 (set-buffer-modified-p nil)))))
14942 (defun gnus-dribble-save ()
14943 (when (and gnus-dribble-buffer
14944 (buffer-name gnus-dribble-buffer))
14946 (set-buffer gnus-dribble-buffer)
14949 (defun gnus-dribble-clear ()
14950 (when (gnus-buffer-exists-p gnus-dribble-buffer)
14952 (set-buffer gnus-dribble-buffer)
14954 (set-buffer-modified-p nil)
14955 (setq buffer-saved-size (buffer-size)))))
14959 ;;; Server Communication
14962 (defun gnus-start-news-server (&optional confirm)
14963 "Open a method for getting news.
14964 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14966 (if gnus-current-select-method
14967 ;; Stream is already opened.
14969 ;; Open NNTP server.
14970 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14973 ;; Read server name with completion.
14974 (setq gnus-nntp-server
14975 (completing-read "NNTP server: "
14976 (mapcar (lambda (server) (list server))
14977 (cons (list gnus-nntp-server)
14978 gnus-secondary-servers))
14979 nil nil gnus-nntp-server))))
14981 (if (and gnus-nntp-server
14982 (stringp gnus-nntp-server)
14983 (not (string= gnus-nntp-server "")))
14984 (setq gnus-select-method
14985 (cond ((or (string= gnus-nntp-server "")
14986 (string= gnus-nntp-server "::"))
14987 (list 'nnspool (system-name)))
14988 ((string-match "^:" gnus-nntp-server)
14989 (list 'nnmh gnus-nntp-server
14990 (list 'nnmh-directory
14991 (file-name-as-directory
14993 (concat "~/" (substring
14994 gnus-nntp-server 1)))))
14995 (list 'nnmh-get-new-mail nil)))
14997 (list 'nntp gnus-nntp-server)))))
14999 (setq how (car gnus-select-method))
15000 (cond ((eq how 'nnspool)
15002 (gnus-message 5 "Looking up local news spool..."))
15005 (gnus-message 5 "Looking up mh spool..."))
15008 (setq gnus-current-select-method gnus-select-method)
15009 (run-hooks 'gnus-open-server-hook)
15011 ;; gnus-open-server-hook might have opened it
15012 (gnus-server-opened gnus-select-method)
15013 (gnus-open-server gnus-select-method)
15016 "%s (%s) open error: '%s'. Continue? "
15017 (car gnus-select-method) (cadr gnus-select-method)
15018 (gnus-status-message gnus-select-method)))
15019 (gnus-error 1 "Couldn't open server on %s"
15020 (nth 1 gnus-select-method))))))
15022 (defun gnus-check-group (group)
15023 "Try to make sure that the server where GROUP exists is alive."
15024 (let ((method (gnus-find-method-for-group group)))
15025 (or (gnus-server-opened method)
15026 (gnus-open-server method))))
15028 (defun gnus-check-server (&optional method silent)
15029 "Check whether the connection to METHOD is down.
15030 If METHOD is nil, use `gnus-select-method'.
15031 If it is down, start it up (again)."
15032 (let ((method (or method gnus-select-method)))
15033 ;; Transform virtual server names into select methods.
15034 (when (stringp method)
15035 (setq method (gnus-server-to-method method)))
15036 (if (gnus-server-opened method)
15037 ;; The stream is already opened.
15039 ;; Open the server.
15041 (gnus-message 5 "Opening %s server%s..." (car method)
15042 (if (equal (nth 1 method) "") ""
15043 (format " on %s" (nth 1 method)))))
15044 (run-hooks 'gnus-open-server-hook)
15046 (gnus-open-server method)
15050 (defun gnus-get-function (method function)
15051 "Return a function symbol based on METHOD and FUNCTION."
15052 ;; Translate server names into methods.
15054 (error "Attempted use of a nil select method"))
15055 (when (stringp method)
15056 (setq method (gnus-server-to-method method)))
15057 (let ((func (intern (format "%s-%s" (car method) function))))
15058 ;; If the functions isn't bound, we require the backend in
15060 (unless (fboundp func)
15061 (require (car method))
15062 (unless (fboundp func)
15063 ;; This backend doesn't implement this function.
15064 (error "No such function: %s" func)))
15069 ;;; Interface functions to the backends.
15072 (defun gnus-open-server (method)
15073 "Open a connection to METHOD."
15074 (when (stringp method)
15075 (setq method (gnus-server-to-method method)))
15076 (let ((elem (assoc method gnus-opened-servers)))
15077 ;; If this method was previously denied, we just return nil.
15078 (if (eq (nth 1 elem) 'denied)
15080 (gnus-message 1 "Denied server")
15082 ;; Open the server.
15084 (funcall (gnus-get-function method 'open-server)
15085 (nth 1 method) (nthcdr 2 method))))
15086 ;; If this hasn't been opened before, we add it to the list.
15088 (setq elem (list method nil)
15089 gnus-opened-servers (cons elem gnus-opened-servers)))
15090 ;; Set the status of this server.
15091 (setcar (cdr elem) (if result 'ok 'denied))
15092 ;; Return the result from the "open" call.
15095 (defun gnus-close-server (method)
15096 "Close the connection to METHOD."
15097 (when (stringp method)
15098 (setq method (gnus-server-to-method method)))
15099 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
15101 (defun gnus-request-list (method)
15102 "Request the active file from METHOD."
15103 (when (stringp method)
15104 (setq method (gnus-server-to-method method)))
15105 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
15107 (defun gnus-request-list-newsgroups (method)
15108 "Request the newsgroups file from METHOD."
15109 (when (stringp method)
15110 (setq method (gnus-server-to-method method)))
15111 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
15113 (defun gnus-request-newgroups (date method)
15114 "Request all new groups since DATE from METHOD."
15115 (when (stringp method)
15116 (setq method (gnus-server-to-method method)))
15117 (funcall (gnus-get-function method 'request-newgroups)
15118 date (nth 1 method)))
15120 (defun gnus-server-opened (method)
15121 "Check whether a connection to METHOD has been opened."
15122 (when (stringp method)
15123 (setq method (gnus-server-to-method method)))
15124 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
15126 (defun gnus-status-message (method)
15127 "Return the status message from METHOD.
15128 If METHOD is a string, it is interpreted as a group name. The method
15129 this group uses will be queried."
15130 (let ((method (if (stringp method) (gnus-find-method-for-group method)
15132 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
15134 (defun gnus-request-group (group &optional dont-check method)
15135 "Request GROUP. If DONT-CHECK, no information is required."
15136 (let ((method (or method (gnus-find-method-for-group group))))
15137 (when (stringp method)
15138 (setq method (gnus-server-to-method method)))
15139 (funcall (gnus-get-function method 'request-group)
15140 (gnus-group-real-name group) (nth 1 method) dont-check)))
15142 (defun gnus-request-asynchronous (group &optional articles)
15143 "Request that GROUP behave asynchronously.
15144 ARTICLES is the `data' of the group."
15145 (let ((method (gnus-find-method-for-group group)))
15146 (funcall (gnus-get-function method 'request-asynchronous)
15147 (gnus-group-real-name group) (nth 1 method) articles)))
15149 (defun gnus-list-active-group (group)
15150 "Request active information on GROUP."
15151 (let ((method (gnus-find-method-for-group group))
15152 (func 'list-active-group))
15153 (when (gnus-check-backend-function func group)
15154 (funcall (gnus-get-function method func)
15155 (gnus-group-real-name group) (nth 1 method)))))
15157 (defun gnus-request-group-description (group)
15158 "Request a description of GROUP."
15159 (let ((method (gnus-find-method-for-group group))
15160 (func 'request-group-description))
15161 (when (gnus-check-backend-function func group)
15162 (funcall (gnus-get-function method func)
15163 (gnus-group-real-name group) (nth 1 method)))))
15165 (defun gnus-close-group (group)
15166 "Request the GROUP be closed."
15167 (let ((method (gnus-find-method-for-group group)))
15168 (funcall (gnus-get-function method 'close-group)
15169 (gnus-group-real-name group) (nth 1 method))))
15171 (defun gnus-retrieve-headers (articles group &optional fetch-old)
15172 "Request headers for ARTICLES in GROUP.
15173 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
15174 (let ((method (gnus-find-method-for-group group)))
15175 (if (and gnus-use-cache (numberp (car articles)))
15176 (gnus-cache-retrieve-headers articles group fetch-old)
15177 (funcall (gnus-get-function method 'retrieve-headers)
15178 articles (gnus-group-real-name group) (nth 1 method)
15181 (defun gnus-retrieve-groups (groups method)
15182 "Request active information on GROUPS from METHOD."
15183 (when (stringp method)
15184 (setq method (gnus-server-to-method method)))
15185 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
15187 (defun gnus-request-type (group &optional article)
15188 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15189 (let ((method (gnus-find-method-for-group group)))
15190 (if (not (gnus-check-backend-function 'request-type (car method)))
15192 (funcall (gnus-get-function method 'request-type)
15193 (gnus-group-real-name group) article))))
15195 (defun gnus-request-update-mark (group article mark)
15196 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15197 (let ((method (gnus-find-method-for-group group)))
15198 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
15200 (funcall (gnus-get-function method 'request-update-mark)
15201 (gnus-group-real-name group) article mark))))
15203 (defun gnus-request-article (article group &optional buffer)
15204 "Request the ARTICLE in GROUP.
15205 ARTICLE can either be an article number or an article Message-ID.
15206 If BUFFER, insert the article in that group."
15207 (let ((method (gnus-find-method-for-group group)))
15208 (funcall (gnus-get-function method 'request-article)
15209 article (gnus-group-real-name group) (nth 1 method) buffer)))
15211 (defun gnus-request-head (article group)
15212 "Request the head of ARTICLE in GROUP."
15213 (let ((method (gnus-find-method-for-group group)))
15214 (funcall (gnus-get-function method 'request-head)
15215 article (gnus-group-real-name group) (nth 1 method))))
15217 (defun gnus-request-body (article group)
15218 "Request the body of ARTICLE in GROUP."
15219 (let ((method (gnus-find-method-for-group group)))
15220 (funcall (gnus-get-function method 'request-body)
15221 article (gnus-group-real-name group) (nth 1 method))))
15223 (defun gnus-request-post (method)
15224 "Post the current buffer using METHOD."
15225 (when (stringp method)
15226 (setq method (gnus-server-to-method method)))
15227 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
15229 (defun gnus-request-scan (group method)
15230 "Request a SCAN being performed in GROUP from METHOD.
15231 If GROUP is nil, all groups on METHOD are scanned."
15232 (let ((method (if group (gnus-find-method-for-group group) method)))
15233 (funcall (gnus-get-function method 'request-scan)
15234 (and group (gnus-group-real-name group)) (nth 1 method))))
15236 (defsubst gnus-request-update-info (info method)
15237 "Request that METHOD update INFO."
15238 (when (stringp method)
15239 (setq method (gnus-server-to-method method)))
15240 (when (gnus-check-backend-function 'request-update-info (car method))
15241 (funcall (gnus-get-function method 'request-update-info)
15242 (gnus-group-real-name (gnus-info-group info))
15243 info (nth 1 method))))
15245 (defun gnus-request-expire-articles (articles group &optional force)
15246 (let ((method (gnus-find-method-for-group group)))
15247 (funcall (gnus-get-function method 'request-expire-articles)
15248 articles (gnus-group-real-name group) (nth 1 method)
15251 (defun gnus-request-move-article
15252 (article group server accept-function &optional last)
15253 (let ((method (gnus-find-method-for-group group)))
15254 (funcall (gnus-get-function method 'request-move-article)
15255 article (gnus-group-real-name group)
15256 (nth 1 method) accept-function last)))
15258 (defun gnus-request-accept-article (group method &optional last)
15259 ;; Make sure there's a newline at the end of the article.
15260 (when (stringp method)
15261 (setq method (gnus-server-to-method method)))
15262 (when (and (not method)
15264 (setq method (gnus-find-method-for-group group)))
15265 (goto-char (point-max))
15268 (let ((func (car (or method (gnus-find-method-for-group group)))))
15269 (funcall (intern (format "%s-request-accept-article" func))
15270 (if (stringp group) (gnus-group-real-name group) group)
15274 (defun gnus-request-replace-article (article group buffer)
15275 (let ((func (car (gnus-find-method-for-group group))))
15276 (funcall (intern (format "%s-request-replace-article" func))
15277 article (gnus-group-real-name group) buffer)))
15279 (defun gnus-request-associate-buffer (group)
15280 (let ((method (gnus-find-method-for-group group)))
15281 (funcall (gnus-get-function method 'request-associate-buffer)
15282 (gnus-group-real-name group))))
15284 (defun gnus-request-restore-buffer (article group)
15285 "Request a new buffer restored to the state of ARTICLE."
15286 (let ((method (gnus-find-method-for-group group)))
15287 (funcall (gnus-get-function method 'request-restore-buffer)
15288 article (gnus-group-real-name group) (nth 1 method))))
15290 (defun gnus-request-create-group (group &optional method)
15291 (when (stringp method)
15292 (setq method (gnus-server-to-method method)))
15293 (let ((method (or method (gnus-find-method-for-group group))))
15294 (funcall (gnus-get-function method 'request-create-group)
15295 (gnus-group-real-name group) (nth 1 method))))
15297 (defun gnus-request-delete-group (group &optional force)
15298 (let ((method (gnus-find-method-for-group group)))
15299 (funcall (gnus-get-function method 'request-delete-group)
15300 (gnus-group-real-name group) force (nth 1 method))))
15302 (defun gnus-request-rename-group (group new-name)
15303 (let ((method (gnus-find-method-for-group group)))
15304 (funcall (gnus-get-function method 'request-rename-group)
15305 (gnus-group-real-name group)
15306 (gnus-group-real-name new-name) (nth 1 method))))
15308 (defun gnus-member-of-valid (symbol group)
15309 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
15310 (memq symbol (assoc
15311 (symbol-name (car (gnus-find-method-for-group group)))
15312 gnus-valid-select-methods)))
15314 (defun gnus-method-option-p (method option)
15315 "Return non-nil if select METHOD has OPTION as a parameter."
15316 (when (stringp method)
15317 (setq method (gnus-server-to-method method)))
15318 (memq option (assoc (format "%s" (car method))
15319 gnus-valid-select-methods)))
15321 (defun gnus-server-extend-method (group method)
15322 ;; This function "extends" a virtual server. If the server is
15323 ;; "hello", and the select method is ("hello" (my-var "something"))
15324 ;; in the group "alt.alt", this will result in a new virtual server
15325 ;; called "hello+alt.alt".
15327 (gnus-copy-sequence
15328 (if (equal (car method) "native") gnus-select-method
15329 (cdr (assoc (car method) gnus-server-alist))))))
15330 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
15331 (nconc entry (cdr method))))
15333 (defun gnus-find-method-for-group (group &optional info)
15334 "Find the select method that GROUP uses."
15335 (or gnus-override-method
15337 gnus-select-method)
15338 (let ((info (or info (gnus-get-info group)))
15341 (not (setq method (gnus-info-method info)))
15342 (equal method "native"))
15345 (cond ((stringp method)
15346 (gnus-server-to-method method))
15347 ((stringp (car method))
15348 (gnus-server-extend-method group method))
15351 (cond ((equal (cadr method) "")
15353 ((null (cadr method))
15354 (list (car method) ""))
15356 (gnus-server-add-address method)))))))
15358 (defun gnus-check-backend-function (func group)
15359 "Check whether GROUP supports function FUNC."
15360 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
15362 (fboundp (intern (format "%s-%s" method func)))))
15364 (defun gnus-methods-using (feature)
15365 "Find all methods that have FEATURE."
15366 (let ((valids gnus-valid-select-methods)
15369 (if (memq feature (car valids))
15370 (setq outs (cons (car valids) outs)))
15371 (setq valids (cdr valids)))
15376 ;;; Active & Newsrc File Handling
15379 (defun gnus-setup-news (&optional rawfile level dont-connect)
15380 "Setup news information.
15381 If RAWFILE is non-nil, the .newsrc file will also be read.
15382 If LEVEL is non-nil, the news will be set up at level LEVEL."
15383 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
15386 ;; Clear some variables to re-initialize news information.
15387 (setq gnus-newsrc-alist nil
15388 gnus-active-hashtb nil)
15389 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15390 (gnus-read-newsrc-file rawfile))
15392 (when (and (not (assoc "archive" gnus-server-alist))
15393 gnus-message-archive-method)
15394 (push (cons "archive" gnus-message-archive-method)
15395 gnus-server-alist))
15397 ;; If we don't read the complete active file, we fill in the
15399 (if (or (null gnus-read-active-file)
15400 (eq gnus-read-active-file 'some))
15401 (gnus-update-active-hashtb-from-killed))
15403 ;; Read the active file and create `gnus-active-hashtb'.
15404 ;; If `gnus-read-active-file' is nil, then we just create an empty
15405 ;; hash table. The partial filling out of the hash table will be
15406 ;; done in `gnus-get-unread-articles'.
15407 (and gnus-read-active-file
15409 (gnus-read-active-file))
15411 (or gnus-active-hashtb
15412 (setq gnus-active-hashtb (make-vector 4095 0)))
15414 ;; Initialize the cache.
15415 (when gnus-use-cache
15418 ;; Possibly eval the dribble file.
15419 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15421 ;; Slave Gnusii should then clear the dribble buffer.
15422 (when (and init gnus-slave)
15423 (gnus-dribble-clear))
15425 (gnus-update-format-specifications)
15427 ;; See whether we need to read the description file.
15428 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15429 (not gnus-description-hashtb)
15431 gnus-read-active-file)
15432 (gnus-read-all-descriptions-files))
15434 ;; Find new newsgroups and treat them.
15435 (if (and init gnus-check-new-newsgroups (not level)
15436 (gnus-check-server gnus-select-method))
15437 (gnus-find-new-newsgroups))
15439 ;; We might read in new NoCeM messages here.
15440 (when (and gnus-use-nocem
15442 (not dont-connect))
15443 (gnus-nocem-scan-groups))
15445 ;; Find the number of unread articles in each non-dead group.
15446 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15447 (gnus-get-unread-articles level))
15449 (if (and init gnus-check-bogus-newsgroups
15450 gnus-read-active-file (not level)
15451 (gnus-server-opened gnus-select-method))
15452 (gnus-check-bogus-newsgroups))))
15454 (defun gnus-find-new-newsgroups (&optional arg)
15455 "Search for new newsgroups and add them.
15456 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15457 The `-n' option line from .newsrc is respected.
15458 If ARG (the prefix), use the `ask-server' method to query
15459 the server for new groups."
15461 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15462 (null gnus-read-active-file)
15463 (eq gnus-read-active-file 'some))
15464 'ask-server gnus-check-new-newsgroups)))
15465 (unless (gnus-check-first-time-used)
15466 (if (or (consp check)
15467 (eq check 'ask-server))
15468 ;; Ask the server for new groups.
15469 (gnus-ask-server-for-new-groups)
15470 ;; Go through the active hashtb and look for new groups.
15472 group new-newsgroups)
15473 (gnus-message 5 "Looking for new newsgroups...")
15474 (unless gnus-have-read-active-file
15475 (gnus-read-active-file))
15476 (setq gnus-newsrc-last-checked-date (current-time-string))
15477 (unless gnus-killed-hashtb
15478 (gnus-make-hashtable-from-killed))
15479 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15480 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15483 (if (or (null (setq group (symbol-name sym)))
15485 (null (symbol-value sym))
15486 (gnus-gethash group gnus-killed-hashtb)
15487 (gnus-gethash group gnus-newsrc-hashtb))
15489 (let ((do-sub (gnus-matches-options-n group)))
15491 ((eq do-sub 'subscribe)
15492 (setq groups (1+ groups))
15493 (gnus-sethash group group gnus-killed-hashtb)
15494 (funcall gnus-subscribe-options-newsgroup-method group))
15495 ((eq do-sub 'ignore)
15498 (setq groups (1+ groups))
15499 (gnus-sethash group group gnus-killed-hashtb)
15500 (if gnus-subscribe-hierarchical-interactive
15501 (setq new-newsgroups (cons group new-newsgroups))
15502 (funcall gnus-subscribe-newsgroup-method group)))))))
15503 gnus-active-hashtb)
15504 (when new-newsgroups
15505 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15506 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15508 (gnus-message 6 "%d new newsgroup%s arrived."
15509 groups (if (> groups 1) "s have" " has"))
15510 (gnus-message 6 "No new newsgroups.")))))))
15512 (defun gnus-matches-options-n (group)
15513 ;; Returns `subscribe' if the group is to be unconditionally
15514 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15515 ;; no match for the group.
15517 ;; First we check the two user variables.
15519 ((and gnus-options-subscribe
15520 (string-match gnus-options-subscribe group))
15522 ((and gnus-auto-subscribed-groups
15523 (string-match gnus-auto-subscribed-groups group))
15525 ((and gnus-options-not-subscribe
15526 (string-match gnus-options-not-subscribe group))
15528 ;; Then we go through the list that was retrieved from the .newsrc
15529 ;; file. This list has elements on the form
15530 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15531 ;; is in the reverse order of the options line) is returned.
15533 (let ((regs gnus-newsrc-options-n))
15535 (not (string-match (caar regs) group)))
15536 (setq regs (cdr regs)))
15537 (and regs (cdar regs))))))
15539 (defun gnus-ask-server-for-new-groups ()
15540 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15541 (methods (cons gnus-select-method
15543 (when gnus-message-archive-method
15546 (and (consp gnus-check-new-newsgroups)
15547 gnus-check-new-newsgroups)
15548 gnus-secondary-select-methods))))
15550 (new-date (current-time-string))
15551 group new-newsgroups got-new method hashtb
15552 gnus-override-subscribe-method)
15553 ;; Go through both primary and secondary select methods and
15554 ;; request new newsgroups.
15555 (while (setq method (gnus-server-get-method nil (pop methods)))
15556 (setq new-newsgroups nil)
15557 (setq gnus-override-subscribe-method method)
15558 (when (and (gnus-check-server method)
15559 (gnus-request-newgroups date method))
15562 (setq hashtb (gnus-make-hashtable 100))
15563 (set-buffer nntp-server-buffer)
15564 ;; Enter all the new groups into a hashtable.
15565 (gnus-active-to-gnus-format method hashtb 'ignore))
15566 ;; Now all new groups from `method' are in `hashtb'.
15568 (lambda (group-sym)
15569 (if (or (null (setq group (symbol-name group-sym)))
15570 (not (boundp group-sym))
15571 (null (symbol-value group-sym))
15572 (gnus-gethash group gnus-newsrc-hashtb)
15573 (member group gnus-zombie-list)
15574 (member group gnus-killed-list))
15575 ;; The group is already known.
15577 ;; Make this group active.
15578 (when (symbol-value group-sym)
15579 (gnus-set-active group (symbol-value group-sym)))
15580 ;; Check whether we want it or not.
15581 (let ((do-sub (gnus-matches-options-n group)))
15583 ((eq do-sub 'subscribe)
15585 (gnus-sethash group group gnus-killed-hashtb)
15586 (funcall gnus-subscribe-options-newsgroup-method group))
15587 ((eq do-sub 'ignore)
15591 (gnus-sethash group group gnus-killed-hashtb)
15592 (if gnus-subscribe-hierarchical-interactive
15593 (push group new-newsgroups)
15594 (funcall gnus-subscribe-newsgroup-method group)))))))
15596 (when new-newsgroups
15597 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15598 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15600 (gnus-message 6 "%d new newsgroup%s arrived."
15601 groups (if (> groups 1) "s have" " has")))
15602 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15605 (defun gnus-check-first-time-used ()
15606 (if (or (> (length gnus-newsrc-alist) 1)
15607 (file-exists-p gnus-startup-file)
15608 (file-exists-p (concat gnus-startup-file ".el"))
15609 (file-exists-p (concat gnus-startup-file ".eld")))
15611 (gnus-message 6 "First time user; subscribing you to default groups")
15612 (unless (gnus-read-active-file-p)
15613 (gnus-read-active-file))
15614 (setq gnus-newsrc-last-checked-date (current-time-string))
15615 (let ((groups gnus-default-subscribed-newsgroups)
15619 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15622 (if (null (setq group (symbol-name sym)))
15624 (let ((do-sub (gnus-matches-options-n group)))
15626 ((eq do-sub 'subscribe)
15627 (gnus-sethash group group gnus-killed-hashtb)
15628 (funcall gnus-subscribe-options-newsgroup-method group))
15629 ((eq do-sub 'ignore)
15632 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15633 gnus-active-hashtb)
15635 (if (gnus-active (car groups))
15636 (gnus-group-change-level
15637 (car groups) gnus-level-default-subscribed gnus-level-killed))
15638 (setq groups (cdr groups)))
15639 (gnus-group-make-help-group)
15640 (and gnus-novice-user
15641 (gnus-message 7 "`A k' to list killed groups"))))))
15643 (defun gnus-subscribe-group (group previous &optional method)
15644 (gnus-group-change-level
15646 (list t group gnus-level-default-subscribed nil nil method)
15648 gnus-level-default-subscribed gnus-level-killed previous t))
15650 ;; `gnus-group-change-level' is the fundamental function for changing
15651 ;; subscription levels of newsgroups. This might mean just changing
15652 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15653 ;; again, which subscribes/unsubscribes a group, which is equally
15654 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15655 ;; from 8-9 to 1-7 means that you remove the group from the list of
15656 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15657 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15658 ;; which is trivial.
15659 ;; ENTRY can either be a string (newsgroup name) or a list (if
15660 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15661 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15663 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15664 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15666 (defun gnus-group-change-level (entry level &optional oldlevel
15667 previous fromkilled)
15668 (let (group info active num)
15669 ;; Glean what info we can from the arguments
15671 (if fromkilled (setq group (nth 1 entry))
15672 (setq group (car (nth 2 entry))))
15673 (setq group entry))
15674 (if (and (stringp entry)
15676 (< oldlevel gnus-level-zombie))
15677 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15678 (if (and (not oldlevel)
15680 (setq oldlevel (gnus-info-level (nth 2 entry)))
15681 (setq oldlevel (or oldlevel 9)))
15682 (if (stringp previous)
15683 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15685 (if (and (>= oldlevel gnus-level-zombie)
15686 (gnus-gethash group gnus-newsrc-hashtb))
15687 ;; We are trying to subscribe a group that is already
15691 (or (gnus-ephemeral-group-p group)
15692 (gnus-dribble-enter
15693 (format "(gnus-group-change-level %S %S %S %S %S)"
15694 group level oldlevel (car (nth 2 previous)) fromkilled)))
15696 ;; Then we remove the newgroup from any old structures, if needed.
15697 ;; If the group was killed, we remove it from the killed or zombie
15698 ;; list. If not, and it is in fact going to be killed, we remove
15699 ;; it from the newsrc hash table and assoc.
15701 ((>= oldlevel gnus-level-zombie)
15702 (if (= oldlevel gnus-level-zombie)
15703 (setq gnus-zombie-list (delete group gnus-zombie-list))
15704 (setq gnus-killed-list (delete group gnus-killed-list))))
15706 (if (and (>= level gnus-level-zombie)
15709 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15711 (setcdr (gnus-gethash (car (nth 3 entry))
15712 gnus-newsrc-hashtb)
15714 (setcdr (cdr entry) (cdddr entry))))))
15716 ;; Finally we enter (if needed) the list where it is supposed to
15717 ;; go, and change the subscription level. If it is to be killed,
15718 ;; we enter it into the killed or zombie list.
15720 ((>= level gnus-level-zombie)
15721 ;; Remove from the hash table.
15722 (gnus-sethash group nil gnus-newsrc-hashtb)
15723 ;; We do not enter foreign groups into the list of dead
15725 (unless (gnus-group-foreign-p group)
15726 (if (= level gnus-level-zombie)
15727 (setq gnus-zombie-list (cons group gnus-zombie-list))
15728 (setq gnus-killed-list (cons group gnus-killed-list)))))
15730 ;; If the list is to be entered into the newsrc assoc, and
15731 ;; it was killed, we have to create an entry in the newsrc
15732 ;; hashtb format and fix the pointers in the newsrc assoc.
15733 (if (< oldlevel gnus-level-zombie)
15734 ;; It was alive, and it is going to stay alive, so we
15735 ;; just change the level and don't change any pointers or
15736 ;; hash table entries.
15737 (setcar (cdaddr entry) level)
15739 (setq info (cdr entry)
15741 (setq active (gnus-active group))
15743 (if active (- (1+ (cdr active)) (car active)) t))
15744 ;; Check whether the group is foreign. If so, the
15745 ;; foreign select method has to be entered into the
15747 (let ((method (or gnus-override-subscribe-method
15748 (gnus-group-method group))))
15749 (if (eq method gnus-select-method)
15750 (setq info (list group level nil))
15751 (setq info (list group level nil nil method)))))
15754 (let ((p gnus-newsrc-alist))
15758 (setq entry (cons info (cddr previous)))
15761 (setcdr (cdr previous) entry)
15762 (gnus-sethash group (cons num (cdr previous))
15763 gnus-newsrc-hashtb))
15764 (setcdr previous entry)
15765 (gnus-sethash group (cons num previous)
15766 gnus-newsrc-hashtb))
15768 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15769 (when gnus-group-change-level-function
15770 (funcall gnus-group-change-level-function group level oldlevel)))))
15772 (defun gnus-kill-newsgroup (newsgroup)
15773 "Obsolete function. Kills a newsgroup."
15774 (gnus-group-change-level
15775 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15777 (defun gnus-check-bogus-newsgroups (&optional confirm)
15778 "Remove bogus newsgroups.
15779 If CONFIRM is non-nil, the user has to confirm the deletion of every
15781 (let ((newsrc (cdr gnus-newsrc-alist))
15782 bogus group entry info)
15783 (gnus-message 5 "Checking bogus newsgroups...")
15784 (unless (gnus-read-active-file-p)
15785 (gnus-read-active-file))
15786 (when (gnus-read-active-file-p)
15787 ;; Find all bogus newsgroup that are subscribed.
15789 (setq info (pop newsrc)
15790 group (gnus-info-group info))
15791 (unless (or (gnus-active group) ; Active
15792 (gnus-info-method info) ; Foreign
15794 (not (gnus-y-or-n-p
15795 (format "Remove bogus newsgroup: %s " group)))))
15796 ;; Found a bogus newsgroup.
15797 (push group bogus)))
15798 ;; Remove all bogus subscribed groups by first killing them, and
15799 ;; then removing them from the list of killed groups.
15801 (when (setq entry (gnus-gethash (setq group (pop bogus))
15802 gnus-newsrc-hashtb))
15803 (gnus-group-change-level entry gnus-level-killed)
15804 (setq gnus-killed-list (delete group gnus-killed-list))))
15805 ;; Then we remove all bogus groups from the list of killed and
15806 ;; zombie groups. They are are removed without confirmation.
15807 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15810 (setq killed (symbol-value (car dead-lists)))
15812 (unless (gnus-active (setq group (pop killed)))
15813 ;; The group is bogus.
15814 ;; !!!Slow as hell.
15815 (set (car dead-lists)
15816 (delete group (symbol-value (car dead-lists))))))
15817 (setq dead-lists (cdr dead-lists))))
15818 (gnus-message 5 "Checking bogus newsgroups...done"))))
15820 (defun gnus-check-duplicate-killed-groups ()
15821 "Remove duplicates from the list of killed groups."
15823 (let ((killed gnus-killed-list))
15825 (gnus-message 9 "%d" (length killed))
15826 (setcdr killed (delete (car killed) (cdr killed)))
15827 (setq killed (cdr killed)))))
15829 ;; We want to inline a function from gnus-cache, so we cheat here:
15832 (require 'gnus-cache))
15834 (defun gnus-get-unread-articles-in-group (info active &optional update)
15836 ;; Allow the backend to update the info in the group.
15838 (gnus-request-update-info
15839 info (gnus-find-method-for-group (gnus-info-group info))))
15840 (gnus-activate-group (gnus-info-group info) nil t))
15841 (let* ((range (gnus-info-read info))
15843 ;; If a cache is present, we may have to alter the active info.
15844 (when (and gnus-use-cache info)
15845 (inline (gnus-cache-possibly-alter-active
15846 (gnus-info-group info) active)))
15847 ;; Modify the list of read articles according to what articles
15848 ;; are available; then tally the unread articles and add the
15849 ;; number to the group hash table entry.
15851 ((zerop (cdr active))
15854 (setq num (- (1+ (cdr active)) (car active))))
15855 ((not (listp (cdr range)))
15856 ;; Fix a single (num . num) range according to the
15857 ;; active hash table.
15858 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15859 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15860 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15861 ;; Compute number of unread articles.
15862 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15864 ;; The read list is a list of ranges. Fix them according to
15865 ;; the active hash table.
15866 ;; First peel off any elements that are below the lower
15868 (while (and (cdr range)
15870 (or (and (atom (cadr range)) (cadr range))
15872 (if (numberp (car range))
15875 (or (and (numberp (cadr range))
15878 (setcdr (car range)
15879 (or (and (numberp (nth 1 range)) (nth 1 range))
15881 (setcdr range (cddr range)))
15882 ;; Adjust the first element to be the same as the lower limit.
15883 (if (and (not (atom (car range)))
15884 (< (cdar range) (car active)))
15885 (setcdr (car range) (1- (car active))))
15886 ;; Then we want to peel off any elements that are higher
15887 ;; than the upper active limit.
15888 (let ((srange range))
15889 ;; Go past all legal elements.
15890 (while (and (cdr srange)
15891 (<= (or (and (atom (cadr srange))
15893 (caadr srange)) (cdr active)))
15894 (setq srange (cdr srange)))
15896 ;; Nuke all remaining illegal elements.
15897 (setcdr srange nil))
15899 ;; Adjust the final element.
15900 (if (and (not (atom (car srange)))
15901 (> (cdar srange) (cdr active)))
15902 (setcdr (car srange) (cdr active))))
15903 ;; Compute the number of unread articles.
15905 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15907 (or (and (atom (car range)) (car range))
15909 (setq range (cdr range)))
15910 (setq num (max 0 (- (cdr active) num)))))
15911 ;; Set the number of unread articles.
15913 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
15916 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15917 ;; and compute how many unread articles there are in each group.
15918 (defun gnus-get-unread-articles (&optional level)
15919 (let* ((newsrc (cdr gnus-newsrc-alist))
15920 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15923 (cond ((and gnus-activate-foreign-newsgroups
15924 (not (numberp gnus-activate-foreign-newsgroups)))
15925 (1+ gnus-level-subscribed))
15926 ((numberp gnus-activate-foreign-newsgroups)
15927 gnus-activate-foreign-newsgroups)
15930 info group active method)
15931 (gnus-message 5 "Checking new news...")
15934 (setq active (gnus-active (setq group (gnus-info-group
15935 (setq info (pop newsrc))))))
15937 ;; Check newsgroups. If the user doesn't want to check them, or
15938 ;; they can't be checked (for instance, if the news server can't
15939 ;; be reached) we just set the number of unread articles in this
15940 ;; newsgroup to t. This means that Gnus thinks that there are
15941 ;; unread articles, but it has no idea how many.
15942 (if (and (setq method (gnus-info-method info))
15943 (not (gnus-server-equal
15945 (setq method (gnus-server-get-method nil method))))
15946 (not (gnus-secondary-method-p method)))
15947 ;; These groups are foreign. Check the level.
15948 (when (<= (gnus-info-level info) foreign-level)
15949 (setq active (gnus-activate-group group 'scan))
15950 (unless (inline (gnus-virtual-group-p group))
15951 (inline (gnus-close-group group)))
15952 (when (fboundp (intern (concat (symbol-name (car method))
15953 "-request-update-info")))
15954 (inline (gnus-request-update-info info method))))
15955 ;; These groups are native or secondary.
15956 (when (and (<= (gnus-info-level info) level)
15957 (not gnus-read-active-file))
15958 (setq active (gnus-activate-group group 'scan))
15959 (inline (gnus-close-group group))))
15961 ;; Get the number of unread articles in the group.
15963 (inline (gnus-get-unread-articles-in-group info active))
15964 ;; The group couldn't be reached, so we nix out the number of
15965 ;; unread articles and stuff.
15966 (gnus-set-active group nil)
15967 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
15969 (gnus-message 5 "Checking new news...done")))
15971 ;; Create a hash table out of the newsrc alist. The `car's of the
15972 ;; alist elements are used as keys.
15973 (defun gnus-make-hashtable-from-newsrc-alist ()
15974 (let ((alist gnus-newsrc-alist)
15975 (ohashtb gnus-newsrc-hashtb)
15977 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15979 (setq prev (setq gnus-newsrc-alist
15980 (if (equal (caar gnus-newsrc-alist)
15983 (cons (list "dummy.group" 0 nil) alist)))))
15987 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
15989 gnus-newsrc-hashtb)
15991 alist (cdr alist)))))
15993 (defun gnus-make-hashtable-from-killed ()
15994 "Create a hash table from the killed and zombie lists."
15995 (let ((lists '(gnus-killed-list gnus-zombie-list))
15997 (setq gnus-killed-hashtb
15998 (gnus-make-hashtable
15999 (+ (length gnus-killed-list) (length gnus-zombie-list))))
16000 (while (setq list (pop lists))
16001 (setq list (symbol-value list))
16003 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
16005 (defun gnus-activate-group (group &optional scan dont-check)
16006 ;; Check whether a group has been activated or not.
16007 ;; If SCAN, request a scan of that group as well.
16008 (let ((method (gnus-find-method-for-group group))
16010 (and (gnus-check-server method)
16011 ;; We escape all bugs and quit here to make it possible to
16012 ;; continue if a group is so out-there that it reports bugs
16016 (gnus-check-backend-function 'request-scan (car method))
16017 (gnus-request-scan group method))
16020 (gnus-request-group group dont-check)
16024 (set-buffer nntp-server-buffer)
16025 (goto-char (point-min))
16026 ;; Parse the result we got from `gnus-request-group'.
16027 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
16029 (goto-char (match-beginning 1))
16031 group (setq active (cons (read (current-buffer))
16032 (read (current-buffer)))))
16033 ;; Return the new active info.
16036 (defun gnus-update-read-articles (group unread)
16037 "Update the list of read and ticked articles in GROUP using the
16038 UNREAD and TICKED lists.
16039 Note: UNSELECTED has to be sorted over `<'.
16040 Returns whether the updating was successful."
16041 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
16042 (entry (gnus-gethash group gnus-newsrc-hashtb))
16043 (info (nth 2 entry))
16045 (unread (sort (copy-sequence unread) '<))
16047 (if (or (not info) (not active))
16048 ;; There is no info on this group if it was, in fact,
16049 ;; killed. Gnus stores no information on killed groups, so
16050 ;; there's nothing to be done.
16051 ;; One could store the information somewhere temporarily,
16052 ;; perhaps... Hmmm...
16054 ;; Remove any negative articles numbers.
16055 (while (and unread (< (car unread) 0))
16056 (setq unread (cdr unread)))
16057 ;; Remove any expired article numbers
16058 (while (and unread (< (car unread) (car active)))
16059 (setq unread (cdr unread)))
16060 ;; Compute the ranges of read articles by looking at the list of
16061 ;; unread articles.
16063 (if (/= (car unread) prev)
16064 (setq read (cons (if (= prev (1- (car unread))) prev
16065 (cons prev (1- (car unread)))) read)))
16066 (setq prev (1+ (car unread)))
16067 (setq unread (cdr unread)))
16068 (when (<= prev (cdr active))
16069 (setq read (cons (cons prev (cdr active)) read)))
16070 ;; Enter this list into the group info.
16071 (gnus-info-set-read
16072 info (if (> (length read) 1) (nreverse read) read))
16073 ;; Set the number of unread articles in gnus-newsrc-hashtb.
16074 (gnus-get-unread-articles-in-group info (gnus-active group))
16077 (defun gnus-make-articles-unread (group articles)
16078 "Mark ARTICLES in GROUP as unread."
16079 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
16080 (gnus-gethash (gnus-group-real-name group)
16081 gnus-newsrc-hashtb))))
16082 (ranges (gnus-info-read info))
16085 (when (gnus-member-of-range
16086 (setq article (pop articles)) ranges)
16087 (setq news (cons article news))))
16089 (gnus-info-set-read
16090 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
16091 (gnus-group-update-group group t))))
16093 ;; Enter all dead groups into the hashtb.
16094 (defun gnus-update-active-hashtb-from-killed ()
16095 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
16096 (lists (list gnus-killed-list gnus-zombie-list))
16099 (setq killed (car lists))
16101 (gnus-sethash (car killed) nil hashtb)
16102 (setq killed (cdr killed)))
16103 (setq lists (cdr lists)))))
16105 (defun gnus-get-killed-groups ()
16106 "Go through the active hashtb and all all unknown groups as killed."
16107 ;; First make sure active file has been read.
16108 (unless (gnus-read-active-file-p)
16109 (let ((gnus-read-active-file t))
16110 (gnus-read-active-file)))
16111 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
16112 ;; Go through all newsgroups that are known to Gnus - enlarge kill list.
16116 (group (symbol-name sym)))
16117 (if (or (null group)
16118 (gnus-gethash group gnus-killed-hashtb)
16119 (gnus-gethash group gnus-newsrc-hashtb))
16121 (let ((do-sub (gnus-matches-options-n group)))
16122 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
16124 (setq groups (1+ groups))
16125 (setq gnus-killed-list
16126 (cons group gnus-killed-list))
16127 (gnus-sethash group group gnus-killed-hashtb))))))
16128 gnus-active-hashtb))
16130 ;; Get the active file(s) from the backend(s).
16131 (defun gnus-read-active-file ()
16132 (gnus-group-set-mode-line)
16135 (if (gnus-check-server gnus-select-method)
16136 ;; The native server is available.
16137 (cons gnus-select-method gnus-secondary-select-methods)
16138 ;; The native server is down, so we just do the
16140 gnus-secondary-select-methods)
16141 ;; Also read from the archive server.
16142 (when gnus-message-archive-method
16143 (list "archive"))))
16145 (setq gnus-have-read-active-file nil)
16147 (set-buffer nntp-server-buffer)
16149 (let* ((method (if (stringp (car methods))
16150 (gnus-server-get-method nil (car methods))
16152 (where (nth 1 method))
16153 (mesg (format "Reading active file%s via %s..."
16154 (if (and where (not (zerop (length where))))
16155 (concat " from " where) "")
16157 (gnus-message 5 mesg)
16158 (when (gnus-check-server method)
16159 ;; Request that the backend scan its incoming messages.
16160 (and (gnus-check-backend-function 'request-scan (car method))
16161 (gnus-request-scan nil method))
16163 ((and (eq gnus-read-active-file 'some)
16164 (gnus-check-backend-function 'retrieve-groups (car method)))
16165 (let ((newsrc (cdr gnus-newsrc-alist))
16166 (gmethod (gnus-server-get-method nil method))
16168 (while (setq info (pop newsrc))
16169 (when (gnus-server-equal
16170 (gnus-find-method-for-group
16171 (gnus-info-group info) info)
16173 (push (gnus-group-real-name (gnus-info-group info))
16176 (gnus-check-server method)
16177 (setq list-type (gnus-retrieve-groups groups method))
16181 1.2 "Cannot read partial active file from %s server."
16183 ((eq list-type 'active)
16184 (gnus-active-to-gnus-format method gnus-active-hashtb))
16186 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
16188 (if (not (gnus-request-list method))
16189 (unless (equal method gnus-message-archive-method)
16190 (gnus-error 1 "Cannot read active file from %s server."
16192 (gnus-message 5 mesg)
16193 (gnus-active-to-gnus-format method gnus-active-hashtb)
16194 ;; We mark this active file as read.
16195 (push method gnus-have-read-active-file)
16196 (gnus-message 5 "%sdone" mesg))))))
16197 (setq methods (cdr methods))))))
16199 ;; Read an active file and place the results in `gnus-active-hashtb'.
16200 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
16202 (setq method gnus-select-method))
16203 (let ((cur (current-buffer))
16205 (if (and gnus-active-hashtb
16206 (not (equal method gnus-select-method)))
16208 (setq gnus-active-hashtb
16209 (if (equal method gnus-select-method)
16210 (gnus-make-hashtable
16211 (count-lines (point-min) (point-max)))
16212 (gnus-make-hashtable 4096)))))))
16213 ;; Delete unnecessary lines.
16214 (goto-char (point-min))
16215 (while (search-forward "\nto." nil t)
16216 (delete-region (1+ (match-beginning 0))
16217 (progn (forward-line 1) (point))))
16218 (or (string= gnus-ignored-newsgroups "")
16220 (goto-char (point-min))
16221 (delete-matching-lines gnus-ignored-newsgroups)))
16222 ;; Make the group names readable as a lisp expression even if they
16223 ;; contain special characters.
16224 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
16225 (goto-char (point-max))
16226 (while (re-search-backward "[][';?()#]" nil t)
16228 ;; If these are groups from a foreign select method, we insert the
16229 ;; group prefix in front of the group names.
16230 (and method (not (gnus-server-equal
16231 (gnus-server-get-method nil method)
16232 (gnus-server-get-method nil gnus-select-method)))
16233 (let ((prefix (gnus-group-prefixed-name "" method)))
16234 (goto-char (point-min))
16235 (while (and (not (eobp))
16236 (progn (insert prefix)
16237 (zerop (forward-line 1)))))))
16238 ;; Store the active file in a hash table.
16239 (goto-char (point-min))
16240 (if (string-match "%[oO]" gnus-group-line-format)
16241 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
16242 ;; If we want information on moderated groups, we use this
16244 (let* ((mod-hashtb (make-vector 7 0))
16245 (m (intern "m" mod-hashtb))
16247 (while (not (eobp))
16248 (condition-case nil
16250 (narrow-to-region (point) (gnus-point-at-eol))
16251 (setq group (let ((obarray hashtb)) (read cur)))
16252 (if (and (numberp (setq max (read cur)))
16253 (numberp (setq min (read cur)))
16255 (skip-chars-forward " \t")
16257 (or (= (following-char) ?=)
16258 (= (following-char) ?x)
16259 (= (following-char) ?j)))))
16260 (set group (cons min max))
16262 ;; Enter moderated groups into a list.
16263 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
16264 (setq gnus-moderated-list
16265 (cons (symbol-name group) gnus-moderated-list))))
16272 ;; And if we do not care about moderation, we use this loop,
16273 ;; which is faster.
16274 (let (group max min)
16275 (while (not (eobp))
16278 (narrow-to-region (point) (gnus-point-at-eol))
16279 ;; group gets set to a symbol interned in the hash table
16280 ;; (what a hack!!) - jwz
16281 (setq group (let ((obarray hashtb)) (read cur)))
16282 (if (and (numberp (setq max (read cur)))
16283 (numberp (setq min (read cur)))
16285 (skip-chars-forward " \t")
16287 (or (= (following-char) ?=)
16288 (= (following-char) ?x)
16289 (= (following-char) ?j)))))
16290 (set group (cons min max))
16298 (gnus-message 3 "Warning - illegal active: %s"
16300 (gnus-point-at-bol) (gnus-point-at-eol)))))))
16302 (forward-line 1))))))
16304 (defun gnus-groups-to-gnus-format (method &optional hashtb)
16305 ;; Parse a "groups" active file.
16306 (let ((cur (current-buffer))
16308 (if (and method gnus-active-hashtb)
16310 (setq gnus-active-hashtb
16311 (gnus-make-hashtable
16312 (count-lines (point-min) (point-max)))))))
16313 (prefix (and method
16314 (not (gnus-server-equal
16315 (gnus-server-get-method nil method)
16316 (gnus-server-get-method nil gnus-select-method)))
16317 (gnus-group-prefixed-name "" method))))
16319 (goto-char (point-min))
16320 ;; We split this into to separate loops, one with the prefix
16321 ;; and one without to speed the reading up somewhat.
16323 (let (min max opoint group)
16324 (while (not (eobp))
16327 (read cur) (read cur)
16328 (setq min (read cur)
16331 (skip-chars-forward " \t")
16334 (set (let ((obarray hashtb)) (read cur))
16336 (error (and group (symbolp group) (set group nil))))
16338 (let (min max group)
16339 (while (not (eobp))
16341 (if (= (following-char) ?2)
16343 (read cur) (read cur)
16344 (setq min (read cur)
16346 (set (setq group (let ((obarray hashtb)) (read cur)))
16348 (error (and group (symbolp group) (set group nil))))
16349 (forward-line 1))))))
16351 (defun gnus-read-newsrc-file (&optional force)
16352 "Read startup file.
16353 If FORCE is non-nil, the .newsrc file is read."
16354 ;; Reset variables that might be defined in the .newsrc.eld file.
16355 (let ((variables gnus-variable-list))
16357 (set (car variables) nil)
16358 (setq variables (cdr variables))))
16359 (let* ((newsrc-file gnus-current-startup-file)
16360 (quick-file (concat newsrc-file ".el")))
16362 ;; We always load the .newsrc.eld file. If always contains
16363 ;; much information that can not be gotten from the .newsrc
16364 ;; file (ticked articles, killed groups, foreign methods, etc.)
16365 (gnus-read-newsrc-el-file quick-file)
16367 (if (and (file-exists-p gnus-current-startup-file)
16369 (and (file-newer-than-file-p newsrc-file quick-file)
16370 (file-newer-than-file-p newsrc-file
16371 (concat quick-file "d")))
16372 (not gnus-newsrc-alist)))
16373 ;; We read the .newsrc file. Note that if there if a
16374 ;; .newsrc.eld file exists, it has already been read, and
16375 ;; the `gnus-newsrc-hashtb' has been created. While reading
16376 ;; the .newsrc file, Gnus will only use the information it
16377 ;; can find there for changing the data already read -
16378 ;; ie. reading the .newsrc file will not trash the data
16379 ;; already read (except for read articles).
16381 (gnus-message 5 "Reading %s..." newsrc-file)
16382 (set-buffer (find-file-noselect newsrc-file))
16383 (buffer-disable-undo (current-buffer))
16384 (gnus-newsrc-to-gnus-format)
16385 (kill-buffer (current-buffer))
16386 (gnus-message 5 "Reading %s...done" newsrc-file)))
16388 ;; Read any slave files.
16390 (gnus-master-read-slave-newsrc))
16392 ;; Convert old to new.
16393 (gnus-convert-old-newsrc))))
16395 (defun gnus-continuum-version (version)
16396 "Return VERSION as a floating point number."
16397 (when (or (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version)
16398 (string-match "^\\(.?\\)gnus-\\([0-9.]+\\)$" version))
16399 (let* ((alpha (and (match-beginning 1) (match-string 1 version)))
16400 (number (match-string 2 version))
16402 (string-match "\\([0-9]\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?" number)
16403 (setq major (string-to-number (match-string 1 number)))
16404 (setq minor (string-to-number (match-string 2 number)))
16405 (setq least (if (match-beginning 3)
16406 (string-to-number (match-string 3 number))
16410 (format "%s00%02d%02d"
16412 ((member alpha '("(ding)" "d")) "4.99")
16413 ((member alpha '("September" "s")) "5.01")
16414 ((member alpha '("Red" "r")) "5.03"))
16416 (format "%d.%02d%02d" major minor least))))))
16418 (defun gnus-convert-old-newsrc ()
16419 "Convert old newsrc into the new format, if needed."
16420 (let ((fcv (and gnus-newsrc-file-version
16421 (gnus-continuum-version gnus-newsrc-file-version))))
16423 ;; No .newsrc.eld file was loaded.
16425 ;; Gnus 5 .newsrc.eld was loaded.
16426 ((< fcv (gnus-continuum-version "September Gnus v0.1"))
16427 (gnus-convert-old-ticks)))))
16429 (defun gnus-convert-old-ticks ()
16430 (let ((newsrc (cdr gnus-newsrc-alist))
16431 marks info dormant ticked)
16432 (while (setq info (pop newsrc))
16433 (when (setq marks (gnus-info-marks info))
16434 (setq dormant (cdr (assq 'dormant marks))
16435 ticked (cdr (assq 'tick marks)))
16436 (when (or dormant ticked)
16437 (gnus-info-set-read
16440 (gnus-info-read info)
16441 (nconc (gnus-uncompress-range dormant)
16442 (gnus-uncompress-range ticked)))))))))
16444 (defun gnus-read-newsrc-el-file (file)
16445 (let ((ding-file (concat file "d")))
16446 ;; We always, always read the .eld file.
16447 (gnus-message 5 "Reading %s..." ding-file)
16448 (let (gnus-newsrc-assoc)
16449 (condition-case nil
16450 (load ding-file t t t)
16452 (gnus-error 1 "Error in %s" ding-file)))
16453 (when gnus-newsrc-assoc
16454 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
16455 (gnus-make-hashtable-from-newsrc-alist)
16456 (when (file-newer-than-file-p file ding-file)
16457 ;; Old format quick file
16458 (gnus-message 5 "Reading %s..." file)
16459 ;; The .el file is newer than the .eld file, so we read that one
16461 (gnus-read-old-newsrc-el-file file))))
16463 ;; Parse the old-style quick startup file
16464 (defun gnus-read-old-newsrc-el-file (file)
16465 (let (newsrc killed marked group m info)
16467 (let ((gnus-killed-assoc nil)
16468 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
16470 (condition-case nil
16473 (setq newsrc gnus-newsrc-assoc
16474 killed gnus-killed-assoc
16475 marked gnus-marked-assoc)))
16476 (setq gnus-newsrc-alist nil)
16477 (while (setq group (pop newsrc))
16478 (if (setq info (gnus-get-info (car group)))
16480 (gnus-info-set-read info (cddr group))
16481 (gnus-info-set-level
16482 info (if (nth 1 group) gnus-level-default-subscribed
16483 gnus-level-default-unsubscribed))
16484 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16487 (if (nth 1 group) gnus-level-default-subscribed
16488 gnus-level-default-unsubscribed)
16490 gnus-newsrc-alist))
16491 ;; Copy marks into info.
16492 (when (setq m (assoc (car group) marked))
16493 (unless (nthcdr 3 info)
16494 (nconc info (list nil)))
16495 (gnus-info-set-marks
16496 info (list (cons 'tick (gnus-compress-sequence
16497 (sort (cdr m) '<) t))))))
16498 (setq newsrc killed)
16500 (setcar newsrc (caar newsrc))
16501 (setq newsrc (cdr newsrc)))
16502 (setq gnus-killed-list killed))
16503 ;; The .el file version of this variable does not begin with
16504 ;; "options", while the .eld version does, so we just add it if it
16507 gnus-newsrc-options
16509 (and (not (string-match "^ *options" gnus-newsrc-options))
16510 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16511 (and (not (string-match "\n$" gnus-newsrc-options))
16512 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16513 ;; Finally, if we read some options lines, we parse them.
16514 (or (string= gnus-newsrc-options "")
16515 (gnus-newsrc-parse-options gnus-newsrc-options))))
16517 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16518 (gnus-make-hashtable-from-newsrc-alist)))
16520 (defun gnus-make-newsrc-file (file)
16521 "Make server dependent file name by catenating FILE and server host name."
16522 (let* ((file (expand-file-name file nil))
16523 (real-file (concat file "-" (nth 1 gnus-select-method))))
16524 (if (or (file-exists-p real-file)
16525 (file-exists-p (concat real-file ".el"))
16526 (file-exists-p (concat real-file ".eld")))
16529 (defun gnus-newsrc-to-gnus-format ()
16530 (setq gnus-newsrc-options "")
16531 (setq gnus-newsrc-options-n nil)
16533 (or gnus-active-hashtb
16534 (setq gnus-active-hashtb (make-vector 4095 0)))
16535 (let ((buf (current-buffer))
16536 (already-read (> (length gnus-newsrc-alist) 1))
16537 group subscribed options-symbol newsrc Options-symbol
16539 (goto-char (point-min))
16540 ;; We intern the symbol `options' in the active hashtb so that we
16541 ;; can `eq' against it later.
16542 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16543 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16545 (while (not (eobp))
16546 ;; We first read the first word on the line by narrowing and
16547 ;; then reading into `gnus-active-hashtb'. Most groups will
16548 ;; already exist in that hashtb, so this will save some string
16552 (progn (skip-chars-forward "^ \t!:\n") (point)))
16553 (goto-char (point-min))
16555 (and (/= (point-min) (point-max))
16556 (let ((obarray gnus-active-hashtb)) (read buf))))
16558 ;; Now, the symbol we have read is either `options' or a group
16559 ;; name. If it is an options line, we just add it to a string.
16561 ((or (eq symbol options-symbol)
16562 (eq symbol Options-symbol))
16563 (setq gnus-newsrc-options
16564 ;; This concating is quite inefficient, but since our
16565 ;; thorough studies show that approx 99.37% of all
16566 ;; .newsrc files only contain a single options line, we
16567 ;; don't give a damn, frankly, my dear.
16568 (concat gnus-newsrc-options
16570 (gnus-point-at-bol)
16571 ;; Options may continue on the next line.
16572 (or (and (re-search-forward "^[^ \t]" nil 'move)
16573 (progn (beginning-of-line) (point)))
16577 ;; Group names can be just numbers.
16578 (when (numberp symbol)
16579 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16580 (or (boundp symbol) (set symbol nil))
16581 ;; It was a group name.
16582 (setq subscribed (= (following-char) ?:)
16583 group (symbol-name symbol)
16586 ;; If the line ends here, this is clearly a buggy line, so
16587 ;; we put point a the beginning of line and let the cond
16588 ;; below do the error handling.
16589 (beginning-of-line)
16590 ;; We skip to the beginning of the ranges.
16591 (skip-chars-forward "!: \t"))
16592 ;; We are now at the beginning of the list of read articles.
16593 ;; We read them range by range.
16596 ((looking-at "[0-9]+")
16597 ;; We narrow and read a number instead of buffer-substring/
16598 ;; string-to-int because it's faster. narrow/widen is
16599 ;; faster than save-restriction/narrow, and save-restriction
16600 ;; produces a garbage object.
16602 (narrow-to-region (match-beginning 0) (match-end 0))
16605 ;; If the next character is a dash, then this is a range.
16606 (if (= (following-char) ?-)
16608 ;; We read the upper bound of the range.
16610 (if (not (looking-at "[0-9]+"))
16611 ;; This is a buggy line, by we pretend that
16612 ;; it's kinda OK. Perhaps the user should be
16614 (setq reads (cons num1 reads))
16619 (narrow-to-region (match-beginning 0)
16624 ;; It was just a simple number, so we add it to the
16626 (setq reads (cons num1 reads)))
16627 ;; If the next char in ?\n, then we have reached the end
16628 ;; of the line and return nil.
16629 (/= (following-char) ?\n))
16630 ((= (following-char) ?\n)
16631 ;; End of line, so we end.
16634 ;; Not numbers and not eol, so this might be a buggy
16637 ;; If it was eob instead of ?\n, we allow it.
16639 ;; The line was buggy.
16641 (gnus-error 3.1 "Mangled line: %s"
16642 (buffer-substring (gnus-point-at-bol)
16643 (gnus-point-at-eol)))))
16645 ;; Skip past ", ". Spaces are illegal in these ranges, but
16646 ;; we allow them, because it's a common mistake to put a
16647 ;; space after the comma.
16648 (skip-chars-forward ", "))
16650 ;; We have already read .newsrc.eld, so we gently update the
16651 ;; data in the hash table with the information we have just
16654 (let ((info (gnus-get-info group))
16657 ;; There is an entry for this file in the alist.
16659 (gnus-info-set-read info (nreverse reads))
16660 ;; We update the level very gently. In fact, we
16661 ;; only change it if there's been a status change
16662 ;; from subscribed to unsubscribed, or vice versa.
16663 (setq level (gnus-info-level info))
16664 (cond ((and (<= level gnus-level-subscribed)
16666 (setq level (if reads
16667 gnus-level-default-unsubscribed
16668 (1+ gnus-level-default-unsubscribed))))
16669 ((and (> level gnus-level-subscribed) subscribed)
16670 (setq level gnus-level-default-subscribed)))
16671 (gnus-info-set-level info level))
16672 ;; This is a new group.
16673 (setq info (list group
16675 gnus-level-default-subscribed
16677 (1+ gnus-level-subscribed)
16678 gnus-level-default-unsubscribed))
16679 (nreverse reads))))
16680 (setq newsrc (cons info newsrc))))))
16683 (setq newsrc (nreverse newsrc))
16685 (if (not already-read)
16687 ;; We now have two newsrc lists - `newsrc', which is what we
16688 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16689 ;; what we've read from .newsrc.eld. We have to merge these
16690 ;; lists. We do this by "attaching" any (foreign) groups in the
16691 ;; gnus-newsrc-alist to the (native) group that precedes them.
16692 (let ((rc (cdr gnus-newsrc-alist))
16693 (prev gnus-newsrc-alist)
16696 (or (null (nth 4 (car rc))) ; It's a native group.
16697 (assoc (caar rc) newsrc) ; It's already in the alist.
16698 (if (setq entry (assoc (caar prev) newsrc))
16699 (setcdr (setq mentry (memq entry newsrc))
16700 (cons (car rc) (cdr mentry)))
16701 (setq newsrc (cons (car rc) newsrc))))
16705 (setq gnus-newsrc-alist newsrc)
16706 ;; We make the newsrc hashtb.
16707 (gnus-make-hashtable-from-newsrc-alist)
16709 ;; Finally, if we read some options lines, we parse them.
16710 (or (string= gnus-newsrc-options "")
16711 (gnus-newsrc-parse-options gnus-newsrc-options))))
16713 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16714 ;; The return value will be a list on the form
16715 ;; ((regexp1 . ignore)
16716 ;; (regexp2 . subscribe)...)
16717 ;; When handling new newsgroups, groups that match a `ignore' regexp
16718 ;; will be ignored, and groups that match a `subscribe' regexp will be
16719 ;; subscribed. A line like
16720 ;; options -n !all rec.all
16721 ;; will lead to a list that looks like
16722 ;; (("^rec\\..+" . subscribe)
16723 ;; ("^.+" . ignore))
16724 ;; So all "rec.*" groups will be subscribed, while all the other
16725 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16726 ;; different from "options -n rec.all !all".
16727 (defun gnus-newsrc-parse-options (options)
16730 (gnus-set-work-buffer)
16731 (insert (regexp-quote options))
16732 ;; First we treat all continuation lines.
16733 (goto-char (point-min))
16734 (while (re-search-forward "\n[ \t]+" nil t)
16735 (replace-match " " t t))
16736 ;; Then we transform all "all"s into ".+"s.
16737 (goto-char (point-min))
16738 (while (re-search-forward "\\ball\\b" nil t)
16739 (replace-match ".+" t t))
16740 (goto-char (point-min))
16741 ;; We remove all other options than the "-n" ones.
16742 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16743 (replace-match " ")
16745 (goto-char (point-min))
16747 ;; We are only interested in "options -n" lines - we
16748 ;; ignore the other option lines.
16749 (while (re-search-forward "[ \t]-n" nil t)
16751 (or (save-excursion
16752 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16754 (gnus-point-at-eol)))
16755 ;; Search for all "words"...
16756 (while (re-search-forward "[^ \t,\n]+" eol t)
16757 (if (= (char-after (match-beginning 0)) ?!)
16758 ;; If the word begins with a bang (!), this is a "not"
16759 ;; spec. We put this spec (minus the bang) and the
16760 ;; symbol `ignore' into the list.
16761 (setq out (cons (cons (concat
16762 "^" (buffer-substring
16763 (1+ (match-beginning 0))
16766 ;; There was no bang, so this is a "yes" spec.
16767 (setq out (cons (cons (concat "^" (match-string 0))
16768 'subscribe) out)))))
16770 (setq gnus-newsrc-options-n out))))
16772 (defun gnus-save-newsrc-file (&optional force)
16773 "Save .newsrc file."
16774 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16775 ;; from the variable gnus-newsrc-alist.
16776 (when (and (or gnus-newsrc-alist gnus-killed-list)
16777 gnus-current-startup-file)
16779 (if (and (or gnus-use-dribble-file gnus-slave)
16781 (or (not gnus-dribble-buffer)
16782 (not (buffer-name gnus-dribble-buffer))
16783 (zerop (save-excursion
16784 (set-buffer gnus-dribble-buffer)
16786 (gnus-message 4 "(No changes need to be saved)")
16787 (run-hooks 'gnus-save-newsrc-hook)
16789 (gnus-slave-save-newsrc)
16791 (when gnus-save-newsrc-file
16792 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16793 (gnus-gnus-to-newsrc-format)
16794 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16795 ;; Save .newsrc.eld.
16796 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16797 (make-local-variable 'version-control)
16798 (setq version-control 'never)
16799 (setq buffer-file-name
16800 (concat gnus-current-startup-file ".eld"))
16801 (setq default-directory (file-name-directory buffer-file-name))
16802 (gnus-add-current-to-buffer-list)
16803 (buffer-disable-undo (current-buffer))
16805 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16806 (gnus-gnus-to-quick-newsrc-format)
16807 (run-hooks 'gnus-save-quick-newsrc-hook)
16809 (kill-buffer (current-buffer))
16811 5 "Saving %s.eld...done" gnus-current-startup-file))
16812 (gnus-dribble-delete-file)
16813 (gnus-group-set-mode-line)))))
16815 (defun gnus-gnus-to-quick-newsrc-format ()
16816 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16817 (insert ";; Gnus startup file.\n")
16818 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16819 (insert ";; to read .newsrc.\n")
16820 (insert "(setq gnus-newsrc-file-version "
16821 (prin1-to-string gnus-version) ")\n")
16823 (if gnus-save-killed-list gnus-variable-list
16824 ;; Remove the `gnus-killed-list' from the list of variables
16825 ;; to be saved, if required.
16826 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16827 ;; Peel off the "dummy" group.
16828 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16830 ;; Insert the variables into the file.
16832 (when (and (boundp (setq variable (pop variables)))
16833 (symbol-value variable))
16834 (insert "(setq " (symbol-name variable) " '")
16835 (prin1 (symbol-value variable) (current-buffer))
16838 (defun gnus-gnus-to-newsrc-format ()
16839 ;; Generate and save the .newsrc file.
16841 (set-buffer (create-file-buffer gnus-current-startup-file))
16842 (let ((newsrc (cdr gnus-newsrc-alist))
16843 (standard-output (current-buffer))
16844 info ranges range method)
16845 (setq buffer-file-name gnus-current-startup-file)
16846 (setq default-directory (file-name-directory buffer-file-name))
16847 (buffer-disable-undo (current-buffer))
16850 (if gnus-newsrc-options (insert gnus-newsrc-options))
16851 ;; Write subscribed and unsubscribed.
16852 (while (setq info (pop newsrc))
16853 ;; Don't write foreign groups to .newsrc.
16854 (when (or (null (setq method (gnus-info-method info)))
16855 (equal method "native")
16856 (gnus-server-equal method gnus-select-method))
16857 (insert (gnus-info-group info)
16858 (if (> (gnus-info-level info) gnus-level-subscribed)
16860 (when (setq ranges (gnus-info-read info))
16862 (if (not (listp (cdr ranges)))
16863 (if (= (car ranges) (cdr ranges))
16864 (princ (car ranges))
16865 (princ (car ranges))
16867 (princ (cdr ranges)))
16868 (while (setq range (pop ranges))
16869 (if (or (atom range) (= (car range) (cdr range)))
16870 (princ (or (and (atom range) range) (car range)))
16871 (princ (car range))
16873 (princ (cdr range)))
16874 (if ranges (insert ",")))))
16876 (make-local-variable 'version-control)
16877 (setq version-control 'never)
16878 ;; It has been reported that sometime the modtime on the .newsrc
16879 ;; file seems to be off. We really do want to overwrite it, so
16880 ;; we clear the modtime here before saving. It's a bit odd,
16882 ;; sometimes the modtime clear isn't sufficient. most brute force:
16883 ;; delete the silly thing entirely first. but this fails to provide
16884 ;; such niceties as .newsrc~ creation.
16885 (if gnus-modtime-botch
16886 (delete-file gnus-startup-file)
16887 (clear-visited-file-modtime))
16888 (run-hooks 'gnus-save-standard-newsrc-hook)
16890 (kill-buffer (current-buffer)))))
16894 ;;; Slave functions.
16897 (defun gnus-slave-save-newsrc ()
16899 (set-buffer gnus-dribble-buffer)
16901 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16902 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16904 (defun gnus-master-read-slave-newsrc ()
16907 (file-name-directory gnus-current-startup-file)
16911 (file-name-nondirectory gnus-current-startup-file)
16915 (if (not slave-files)
16916 () ; There are no slave files to read.
16917 (gnus-message 7 "Reading slave newsrcs...")
16919 (set-buffer (get-buffer-create " *gnus slave*"))
16920 (buffer-disable-undo (current-buffer))
16922 (sort (mapcar (lambda (file)
16923 (list (nth 5 (file-attributes file)) file))
16926 (or (< (caar f1) (caar f2))
16927 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16930 (setq file (nth 1 (car slave-files)))
16931 (insert-file-contents file)
16932 (if (condition-case ()
16934 (eval-buffer (current-buffer))
16937 (gnus-error 3.2 "Possible error in %s" file)
16939 (or gnus-slave ; Slaves shouldn't delete these files.
16943 (setq slave-files (cdr slave-files))))
16944 (gnus-message 7 "Reading slave newsrcs...done"))))
16948 ;;; Group description.
16951 (defun gnus-read-all-descriptions-files ()
16952 (let ((methods (cons gnus-select-method
16954 (when gnus-message-archive-method
16956 gnus-secondary-select-methods))))
16958 (gnus-read-descriptions-file (car methods))
16959 (setq methods (cdr methods)))
16962 (defun gnus-read-descriptions-file (&optional method)
16963 (let ((method (or method gnus-select-method))
16965 (when (stringp method)
16966 (setq method (gnus-server-to-method method)))
16967 ;; We create the hashtable whether we manage to read the desc file
16968 ;; to avoid trying to re-read after a failed read.
16969 (or gnus-description-hashtb
16970 (setq gnus-description-hashtb
16971 (gnus-make-hashtable (length gnus-active-hashtb))))
16972 ;; Mark this method's desc file as read.
16973 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16974 gnus-description-hashtb)
16976 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16978 ((not (gnus-check-server method))
16979 (gnus-message 1 "Couldn't open server")
16981 ((not (gnus-request-list-newsgroups method))
16982 (gnus-message 1 "Couldn't read newsgroups descriptions")
16987 (set-buffer nntp-server-buffer)
16988 (goto-char (point-min))
16989 (when (or (search-forward "\n.\n" nil t)
16990 (goto-char (point-max)))
16991 (beginning-of-line)
16992 (narrow-to-region (point-min) (point)))
16993 ;; If these are groups from a foreign select method, we insert the
16994 ;; group prefix in front of the group names.
16995 (and method (not (gnus-server-equal
16996 (gnus-server-get-method nil method)
16997 (gnus-server-get-method nil gnus-select-method)))
16998 (let ((prefix (gnus-group-prefixed-name "" method)))
16999 (goto-char (point-min))
17000 (while (and (not (eobp))
17001 (progn (insert prefix)
17002 (zerop (forward-line 1)))))))
17003 (goto-char (point-min))
17004 (while (not (eobp))
17005 ;; If we get an error, we set group to 0, which is not a
17009 (let ((obarray gnus-description-hashtb))
17010 ;; Group is set to a symbol interned in this
17012 (read nntp-server-buffer))
17014 (skip-chars-forward " \t")
17015 ;; ... which leads to this line being effectively ignored.
17016 (and (symbolp group)
17017 (set group (buffer-substring
17018 (point) (progn (end-of-line) (point)))))
17019 (forward-line 1))))
17020 (gnus-message 5 "Reading descriptions file...done")
17023 (defun gnus-group-get-description (group)
17024 "Get the description of a group by sending XGTITLE to the server."
17025 (when (gnus-request-group-description group)
17027 (set-buffer nntp-server-buffer)
17028 (goto-char (point-min))
17029 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
17030 (match-string 1)))))
17034 ;;; Buffering of read articles.
17037 (defvar gnus-backlog-buffer " *Gnus Backlog*")
17038 (defvar gnus-backlog-articles nil)
17039 (defvar gnus-backlog-hashtb nil)
17041 (defun gnus-backlog-buffer ()
17042 "Return the backlog buffer."
17043 (or (get-buffer gnus-backlog-buffer)
17045 (set-buffer (get-buffer-create gnus-backlog-buffer))
17046 (buffer-disable-undo (current-buffer))
17047 (setq buffer-read-only t)
17048 (gnus-add-current-to-buffer-list)
17049 (get-buffer gnus-backlog-buffer))))
17051 (defun gnus-backlog-setup ()
17052 "Initialize backlog variables."
17053 (unless gnus-backlog-hashtb
17054 (setq gnus-backlog-hashtb (make-vector 1023 0))))
17056 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
17058 (defun gnus-backlog-shutdown ()
17059 "Clear all backlog variables and buffers."
17060 (when (get-buffer gnus-backlog-buffer)
17061 (kill-buffer gnus-backlog-buffer))
17062 (setq gnus-backlog-hashtb nil
17063 gnus-backlog-articles nil))
17065 (defun gnus-backlog-enter-article (group number buffer)
17066 (gnus-backlog-setup)
17067 (let ((ident (intern (concat group ":" (int-to-string number))
17068 gnus-backlog-hashtb))
17070 (if (memq ident gnus-backlog-articles)
17071 () ; It's already kept.
17072 ;; Remove the oldest article, if necessary.
17073 (and (numberp gnus-keep-backlog)
17074 (>= (length gnus-backlog-articles) gnus-keep-backlog)
17075 (gnus-backlog-remove-oldest-article))
17076 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
17077 ;; Insert the new article.
17079 (set-buffer (gnus-backlog-buffer))
17080 (let (buffer-read-only)
17081 (goto-char (point-max))
17082 (or (bolp) (insert "\n"))
17084 (insert-buffer-substring buffer)
17085 ;; Tag the beginning of the article with the ident.
17086 (gnus-put-text-property b (1+ b) 'gnus-backlog ident))))))
17088 (defun gnus-backlog-remove-oldest-article ()
17090 (set-buffer (gnus-backlog-buffer))
17091 (goto-char (point-min))
17092 (if (zerop (buffer-size))
17093 () ; The buffer is empty.
17094 (let ((ident (get-text-property (point) 'gnus-backlog))
17096 ;; Remove the ident from the list of articles.
17098 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17099 ;; Delete the article itself.
17101 (point) (next-single-property-change
17102 (1+ (point)) 'gnus-backlog nil (point-max)))))))
17104 (defun gnus-backlog-remove-article (group number)
17105 "Remove article NUMBER in GROUP from the backlog."
17106 (when (numberp number)
17107 (gnus-backlog-setup)
17108 (let ((ident (intern (concat group ":" (int-to-string number))
17109 gnus-backlog-hashtb))
17111 (when (memq ident gnus-backlog-articles)
17112 ;; It was in the backlog.
17114 (set-buffer (gnus-backlog-buffer))
17115 (let (buffer-read-only)
17116 (when (setq beg (text-property-any
17117 (point-min) (point-max) 'gnus-backlog
17119 ;; Find the end (i. e., the beginning of the next article).
17121 (next-single-property-change
17122 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))
17123 (delete-region beg end)
17127 (defun gnus-backlog-request-article (group number buffer)
17128 (when (numberp number)
17129 (gnus-backlog-setup)
17130 (let ((ident (intern (concat group ":" (int-to-string number))
17131 gnus-backlog-hashtb))
17133 (when (memq ident gnus-backlog-articles)
17134 ;; It was in the backlog.
17136 (set-buffer (gnus-backlog-buffer))
17137 (if (not (setq beg (text-property-any
17138 (point-min) (point-max) 'gnus-backlog
17140 ;; It wasn't in the backlog after all.
17142 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17143 ;; Find the end (i. e., the beginning of the next article).
17145 (next-single-property-change
17146 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
17147 (let ((buffer-read-only nil))
17149 (insert-buffer-substring gnus-backlog-buffer beg end)
17152 ;; Allow redefinition of Gnus functions.
17154 (gnus-ems-redefine)
17158 ;;; gnus.el ends here