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))
37 (eval-when-compile (require 'cl))
39 (defvar gnus-directory (or (getenv "SAVEDIR") "~/News/")
40 "*Directory variable from which all other Gnus file variables are derived.")
42 ;; Site dependent variables. These variables should be defined in
45 (defvar gnus-default-nntp-server nil
46 "Specify a default NNTP server.
47 This variable should be defined in paths.el, and should never be set
49 If you want to change servers, you should use `gnus-select-method'.
50 See the documentation to that variable.")
52 (defvar gnus-backup-default-subscribed-newsgroups
53 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
54 "Default default new newsgroups the first time Gnus is run.
55 Should be set in paths.el, and shouldn't be touched by the user.")
57 (defvar gnus-local-domain nil
58 "Local domain name without a host name.
59 The DOMAINNAME environment variable is used instead if it is defined.
60 If the `system-name' function returns the full Internet name, there is
61 no need to set this variable.")
63 (defvar gnus-local-organization nil
64 "String with a description of what organization (if any) the user belongs to.
65 The ORGANIZATION environment variable is used instead if it is defined.
66 If this variable contains a function, this function will be called
67 with the current newsgroup name as the argument. The function should
70 In any case, if the string (either in the variable, in the environment
71 variable, or returned by the function) is a file name, the contents of
72 this file will be used as the organization.")
74 ;; Customization variables
76 ;; Don't touch this variable.
77 (defvar gnus-nntp-service "nntp"
78 "*NNTP service name (\"nntp\" or 119).
79 This is an obsolete variable, which is scarcely used. If you use an
80 nntp server for your newsgroup and want to change the port number
81 used to 899, you would say something along these lines:
83 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
85 (defvar gnus-nntpserver-file "/etc/nntpserver"
86 "*A file with only the name of the nntp server in it.")
88 ;; This function is used to check both the environment variable
89 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
90 ;; an nntp server name default.
91 (defun gnus-getenv-nntpserver ()
92 (or (getenv "NNTPSERVER")
93 (and (file-readable-p gnus-nntpserver-file)
95 (set-buffer (get-buffer-create " *gnus nntp*"))
96 (buffer-disable-undo (current-buffer))
97 (insert-file-contents gnus-nntpserver-file)
98 (let ((name (buffer-string)))
100 (if (string-match "^[ \t\n]*$" name)
103 (kill-buffer (current-buffer))))))))
105 (defvar gnus-select-method
107 (list 'nntp (or (condition-case ()
108 (gnus-getenv-nntpserver)
110 (if (and gnus-default-nntp-server
111 (not (string= gnus-default-nntp-server "")))
112 gnus-default-nntp-server)
114 (if (or (null gnus-nntp-service)
115 (equal gnus-nntp-service "nntp"))
117 (list gnus-nntp-service)))
118 "*Default method for selecting a newsgroup.
119 This variable should be a list, where the first element is how the
120 news is to be fetched, the second is the address.
122 For instance, if you want to get your news via NNTP from
123 \"flab.flab.edu\", you could say:
125 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
127 If you want to use your local spool, say:
129 (setq gnus-select-method (list 'nnspool (system-name)))
131 If you use this variable, you must set `gnus-nntp-server' to nil.
133 There is a lot more to know about select methods and virtual servers -
134 see the manual for details.")
136 (defvar gnus-message-archive-method
139 (nnfolder-directory ,(nnheader-concat message-directory "archive"))
140 (nnfolder-active-file
141 ,(nnheader-concat message-directory "archive/active"))
142 (nnfolder-get-new-mail nil)
143 (nnfolder-inhibit-expiry t))
144 "*Method used for archiving messages you've sent.
145 This should be a mail method.")
147 (defvar gnus-refer-article-method nil
148 "*Preferred method for fetching an article by Message-ID.
149 If you are reading news from the local spool (with nnspool), fetching
150 articles by Message-ID is painfully slow. By setting this method to an
151 nntp method, you might get acceptable results.
153 The value of this variable must be a valid select method as discussed
154 in the documentation of `gnus-select-method'.")
156 (defvar gnus-secondary-select-methods nil
157 "*A list of secondary methods that will be used for reading news.
158 This is a list where each element is a complete select method (see
159 `gnus-select-method').
161 If, for instance, you want to read your mail with the nnml backend,
162 you could set this variable:
164 (setq gnus-secondary-select-methods '((nnml \"\")))")
166 (defvar gnus-secondary-servers nil
167 "*List of NNTP servers that the user can choose between interactively.
168 To make Gnus query you for a server, you have to give `gnus' a
169 non-numeric prefix - `C-u M-x gnus', in short.")
171 (defvar gnus-nntp-server nil
172 "*The name of the host running the NNTP server.
173 This variable is semi-obsolete. Use the `gnus-select-method'
176 (defvar gnus-startup-file "~/.newsrc"
177 "*Your `.newsrc' file.
178 `.newsrc-SERVER' will be used instead if that exists.")
180 (defvar gnus-init-file "~/.gnus"
181 "*Your Gnus elisp startup file.
182 If a file with the .el or .elc suffixes exist, it will be read
185 (defvar gnus-group-faq-directory
186 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
187 "/ftp@sunsite.auc.dk:/pub/usenet/"
188 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
189 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
190 "/ftp@rtfm.mit.edu:/pub/usenet/"
191 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
192 "/ftp@ftp.sunet.se:/pub/usenet/"
193 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
194 "/ftp@hwarang.postech.ac.kr:/pub/usenet/"
195 "/ftp@ftp.hk.super.net:/mirror/faqs/")
196 "*Directory where the group FAQs are stored.
197 This will most commonly be on a remote machine, and the file will be
200 This variable can also be a list of directories. In that case, the
201 first element in the list will be used by default, and the others will
202 be used as backup sites.
204 Note that Gnus uses an aol machine as the default directory. If this
205 feels fundamentally unclean, just think of it as a way to finally get
206 something of value back from them.
208 If the default site is too slow, try one of these:
210 North America: mirrors.aol.com /pub/rtfm/usenet
211 ftp.seas.gwu.edu /pub/rtfm
212 rtfm.mit.edu /pub/usenet
213 Europe: ftp.uni-paderborn.de /pub/FAQ
214 src.doc.ic.ac.uk /usenet/news-FAQS
215 ftp.sunet.se /pub/usenet
216 sunsite.auc.dk /pub/usenet
217 Asia: nctuccca.edu.tw /USENET/FAQ
218 hwarang.postech.ac.kr /pub/usenet
219 ftp.hk.super.net /mirror/faqs")
221 (defvar gnus-group-archive-directory
222 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list/"
223 "*The address of the (ding) archives.")
225 (defvar gnus-group-recent-archive-directory
226 "/ftp@ftp.hpc.uh.edu:/pub/emacs/ding-list-recent/"
227 "*The address of the most recent (ding) articles.")
229 (defvar gnus-default-subscribed-newsgroups nil
230 "*This variable lists what newsgroups should be subscribed the first time Gnus is used.
231 It should be a list of strings.
232 If it is `t', Gnus will not do anything special the first time it is
233 started; it'll just use the normal newsgroups subscription methods.")
235 (defvar gnus-use-cross-reference t
236 "*Non-nil means that cross referenced articles will be marked as read.
237 If nil, ignore cross references. If t, mark articles as read in
238 subscribed newsgroups. If neither t nor nil, mark as read in all
241 (defvar gnus-single-article-buffer t
242 "*If non-nil, display all articles in the same buffer.
243 If nil, each group will get its own article buffer.")
245 (defvar gnus-use-dribble-file t
246 "*Non-nil means that Gnus will use a dribble file to store user updates.
247 If Emacs should crash without saving the .newsrc files, complete
248 information can be restored from the dribble file.")
250 (defvar gnus-dribble-directory nil
251 "*The directory where dribble files will be saved.
252 If this variable is nil, the directory where the .newsrc files are
253 saved will be used.")
255 (defvar gnus-asynchronous nil
256 "*If non-nil, Gnus will supply backends with data needed for async article fetching.")
258 (defvar gnus-kill-summary-on-exit t
259 "*If non-nil, kill the summary buffer when you exit from it.
260 If nil, the summary will become a \"*Dead Summary*\" buffer, and
261 it will be killed sometime later.")
263 (defvar gnus-large-newsgroup 200
264 "*The number of articles which indicates a large newsgroup.
265 If the number of articles in a newsgroup is greater than this value,
266 confirmation is required for selecting the newsgroup.")
268 ;; Suggested by Andrew Eskilsson <pi92ae@lelle.pt.hk-r.se>.
269 (defvar gnus-no-groups-message "No news is horrible news"
270 "*Message displayed by Gnus when no groups are available.")
272 (defvar gnus-use-long-file-name (not (memq system-type '(usg-unix-v xenix)))
273 "*Non-nil means that the default name of a file to save articles in is the group name.
274 If it's nil, the directory form of the group name is used instead.
276 If this variable is a list, and the list contains the element
277 `not-score', long file names will not be used for score files; if it
278 contains the element `not-save', long file names will not be used for
279 saving; and if it contains the element `not-kill', long file names
280 will not be used for kill files.")
282 (defvar gnus-article-save-directory gnus-directory
283 "*Name of the directory articles will be saved in (default \"~/News\").")
285 (defvar gnus-kill-files-directory gnus-directory
286 "*Name of the directory where kill files will be stored (default \"~/News\").")
288 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
289 "*A function to save articles in your favorite format.
290 The function must be interactively callable (in other words, it must
291 be an Emacs command).
293 Gnus provides the following functions:
295 * gnus-summary-save-in-rmail (Rmail format)
296 * gnus-summary-save-in-mail (Unix mail format)
297 * gnus-summary-save-in-folder (MH folder)
298 * gnus-summary-save-in-file (article format).
299 * gnus-summary-save-in-vm (use VM's folder format).")
301 (defvar gnus-prompt-before-saving 'always
302 "*This variable says how much prompting is to be done when saving articles.
303 If it is nil, no prompting will be done, and the articles will be
304 saved to the default files. If this variable is `always', each and
305 every article that is saved will be preceded by a prompt, even when
306 saving large batches of articles. If this variable is neither nil not
307 `always', there the user will be prompted once for a file name for
308 each invocation of the saving commands.")
310 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
311 "*A function generating a file name to save articles in Rmail format.
312 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
314 (defvar gnus-mail-save-name (function gnus-plain-save-name)
315 "*A function generating a file name to save articles in Unix mail format.
316 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
318 (defvar gnus-folder-save-name (function gnus-folder-save-name)
319 "*A function generating a file name to save articles in MH folder.
320 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
322 (defvar gnus-file-save-name (function gnus-numeric-save-name)
323 "*A function generating a file name to save articles in article format.
324 The function is called with NEWSGROUP, HEADERS, and optional
327 (defvar gnus-split-methods
328 '((gnus-article-archive-name))
329 "*Variable used to suggest where articles are to be saved.
330 For instance, if you would like to save articles related to Gnus in
331 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
332 you could set this variable to something like:
334 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
335 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
337 This variable is an alist where the where the key is the match and the
338 value is a list of possible files to save in if the match is non-nil.
340 If the match is a string, it is used as a regexp match on the
341 article. If the match is a symbol, that symbol will be funcalled
342 from the buffer of the article to be saved with the newsgroup as the
343 parameter. If it is a list, it will be evaled in the same buffer.
345 If this form or function returns a string, this string will be used as
346 a possible file name; and if it returns a non-nil list, that list will
347 be used as possible file names.")
349 (defvar gnus-move-split-methods nil
350 "*Variable used to suggest where articles are to be moved to.
351 It uses the same syntax as the `gnus-split-methods' variable.")
353 (defvar gnus-save-score nil
354 "*If non-nil, save group scoring info.")
356 (defvar gnus-use-adaptive-scoring nil
357 "*If non-nil, use some adaptive scoring scheme.")
359 (defvar gnus-use-cache 'passive
360 "*If nil, Gnus will ignore the article cache.
361 If `passive', it will allow entering (and reading) articles
362 explicitly entered into the cache. If anything else, use the
363 cache to the full extent of the law.")
365 (defvar gnus-use-trees nil
366 "*If non-nil, display a thread tree buffer.")
368 (defvar gnus-use-grouplens nil
369 "*If non-nil, use GroupLens ratings.")
371 (defvar gnus-keep-backlog nil
372 "*If non-nil, Gnus will keep read articles for later re-retrieval.
373 If it is a number N, then Gnus will only keep the last N articles
374 read. If it is neither nil nor a number, Gnus will keep all read
375 articles. This is not a good idea.")
377 (defvar gnus-use-nocem nil
378 "*If non-nil, Gnus will read NoCeM cancel messages.")
380 (defvar gnus-use-demon nil
381 "If non-nil, Gnus might use some demons.")
383 (defvar gnus-use-scoring t
384 "*If non-nil, enable scoring.")
386 (defvar gnus-use-picons nil
387 "*If non-nil, display picons.")
389 (defvar gnus-fetch-old-headers nil
390 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
391 If an unread article in the group refers to an older, already read (or
392 just marked as read) article, the old article will not normally be
393 displayed in the Summary buffer. If this variable is non-nil, Gnus
394 will attempt to grab the headers to the old articles, and thereby
395 build complete threads. If it has the value `some', only enough
396 headers to connect otherwise loose threads will be displayed.
397 This variable can also be a number. In that case, no more than that
398 number of old headers will be fetched.
400 The server has to support NOV for any of this to work.")
403 ;(defvar gnus-visual t
404 ; "*If non-nil, will do various highlighting.
405 ;If nil, no mouse highlights (or any other highlights) will be
406 ;performed. This might speed up Gnus some when generating large group
407 ;and summary buffers.")
409 (defvar gnus-novice-user t
410 "*Non-nil means that you are a usenet novice.
411 If non-nil, verbose messages may be displayed and confirmations may be
414 (defvar gnus-expert-user nil
415 "*Non-nil means that you will never be asked for confirmation about anything.
416 And that means *anything*.")
418 (defvar gnus-verbose 7
419 "*Integer that says how verbose Gnus should be.
420 The higher the number, the more messages Gnus will flash to say what
421 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
422 display most important messages; and at ten, Gnus will keep on
423 jabbering all the time.")
425 (defvar gnus-keep-same-level nil
426 "*Non-nil means that the next newsgroup after the current will be on the same level.
427 When you type, for instance, `n' after reading the last article in the
428 current newsgroup, you will go to the next newsgroup. If this variable
429 is nil, the next newsgroup will be the next from the group
431 If this variable is non-nil, Gnus will either put you in the
432 next newsgroup with the same level, or, if no such newsgroup is
433 available, the next newsgroup with the lowest possible level higher
434 than the current level.
435 If this variable is `best', Gnus will make the next newsgroup the one
436 with the best level.")
438 (defvar gnus-summary-make-false-root 'adopt
439 "*nil means that Gnus won't gather loose threads.
440 If the root of a thread has expired or been read in a previous
441 session, the information necessary to build a complete thread has been
442 lost. Instead of having many small sub-threads from this original thread
443 scattered all over the summary buffer, Gnus can gather them.
445 If non-nil, Gnus will try to gather all loose sub-threads from an
446 original thread into one large thread.
448 If this variable is non-nil, it should be one of `none', `adopt',
451 If this variable is `none', Gnus will not make a false root, but just
452 present the sub-threads after another.
453 If this variable is `dummy', Gnus will create a dummy root that will
454 have all the sub-threads as children.
455 If this variable is `adopt', Gnus will make one of the \"children\"
456 the parent and mark all the step-children as such.
457 If this variable is `empty', the \"children\" are printed with empty
458 subject fields. (Or rather, they will be printed with a string
459 given by the `gnus-summary-same-subject' variable.)")
461 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
462 "*A regexp to match subjects to be excluded from loose thread gathering.
463 As loose thread gathering is done on subjects only, that means that
464 there can be many false gatherings performed. By rooting out certain
465 common subjects, gathering might become saner.")
467 (defvar gnus-summary-gather-subject-limit nil
468 "*Maximum length of subject comparisons when gathering loose threads.
469 Use nil to compare full subjects. Setting this variable to a low
470 number will help gather threads that have been corrupted by
471 newsreaders chopping off subject lines, but it might also mean that
472 unrelated articles that have subject that happen to begin with the
473 same few characters will be incorrectly gathered.
475 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
476 comparing subjects.")
478 (defvar gnus-simplify-ignored-prefixes nil
479 "*Regexp, matches for which are removed from subject lines when simplifying.")
481 (defvar gnus-build-sparse-threads nil
482 "*If non-nil, fill in the gaps in threads.
483 If `some', only fill in the gaps that are needed to tie loose threads
484 together. If `more', fill in all leaf nodes that Gnus can find. If
485 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
487 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
488 "Function used for gathering loose threads.
489 There are two pre-defined functions: `gnus-gather-threads-by-subject',
490 which only takes Subjects into consideration; and
491 `gnus-gather-threads-by-references', which compared the References
492 headers of the articles to find matches.")
494 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
495 (defvar gnus-summary-same-subject ""
496 "*String indicating that the current article has the same subject as the previous.
497 This variable will only be used if the value of
498 `gnus-summary-make-false-root' is `empty'.")
500 (defvar gnus-summary-goto-unread t
501 "*If non-nil, marking commands will go to the next unread article.
502 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
503 whether it is read or not.")
505 (defvar gnus-group-goto-unread t
506 "*If non-nil, movement commands will go to the next unread and subscribed group.")
508 (defvar gnus-goto-next-group-when-activating t
509 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
511 (defvar gnus-check-new-newsgroups t
512 "*Non-nil means that Gnus will add new newsgroups at startup.
513 If this variable is `ask-server', Gnus will ask the server for new
514 groups since the last time it checked. This means that the killed list
515 is no longer necessary, so you could set `gnus-save-killed-list' to
518 A variant is to have this variable be a list of select methods. Gnus
519 will then use the `ask-server' method on all these select methods to
520 query for new groups from all those servers.
523 (setq gnus-check-new-newsgroups
524 '((nntp \"some.server\") (nntp \"other.server\")))
526 If this variable is nil, then you have to tell Gnus explicitly to
527 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
529 (defvar gnus-check-bogus-newsgroups nil
530 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
531 If this variable is nil, then you have to tell Gnus explicitly to
532 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
534 (defvar gnus-read-active-file t
535 "*Non-nil means that Gnus will read the entire active file at startup.
536 If this variable is nil, Gnus will only know about the groups in your
539 If this variable is `some', Gnus will try to only read the relevant
540 parts of the active file from the server. Not all servers support
541 this, and it might be quite slow with other servers, but this should
542 generally be faster than both the t and nil value.
544 If you set this variable to nil or `some', you probably still want to
545 be told about new newsgroups that arrive. To do that, set
546 `gnus-check-new-newsgroups' to `ask-server'. This may not work
547 properly with all servers.")
549 (defvar gnus-level-subscribed 5
550 "*Groups with levels less than or equal to this variable are subscribed.")
552 (defvar gnus-level-unsubscribed 7
553 "*Groups with levels less than or equal to this variable are unsubscribed.
554 Groups with levels less than `gnus-level-subscribed', which should be
555 less than this variable, are subscribed.")
557 (defvar gnus-level-zombie 8
558 "*Groups with this level are zombie groups.")
560 (defvar gnus-level-killed 9
561 "*Groups with this level are killed.")
563 (defvar gnus-level-default-subscribed 3
564 "*New subscribed groups will be subscribed at this level.")
566 (defvar gnus-level-default-unsubscribed 6
567 "*New unsubscribed groups will be unsubscribed at this level.")
569 (defvar gnus-activate-level (1+ gnus-level-subscribed)
570 "*Groups higher than this level won't be activated on startup.
571 Setting this variable to something log might save lots of time when
572 you have many groups that you aren't interested in.")
574 (defvar gnus-activate-foreign-newsgroups 4
575 "*If nil, Gnus will not check foreign newsgroups at startup.
576 If it is non-nil, it should be a number between one and nine. Foreign
577 newsgroups that have a level lower or equal to this number will be
578 activated on startup. For instance, if you want to active all
579 subscribed newsgroups, but not the rest, you'd set this variable to
580 `gnus-level-subscribed'.
582 If you subscribe to lots of newsgroups from different servers, startup
583 might take a while. By setting this variable to nil, you'll save time,
584 but you won't be told how many unread articles there are in the
587 (defvar gnus-save-newsrc-file t
588 "*Non-nil means that Gnus will save the `.newsrc' file.
589 Gnus always saves its own startup file, which is called
590 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
591 be readily understood by other newsreaders. If you don't plan on
592 using other newsreaders, set this variable to nil to save some time on
595 (defvar gnus-save-killed-list t
596 "*If non-nil, save the list of killed groups to the startup file.
597 If you set this variable to nil, you'll save both time (when starting
598 and quitting) and space (both memory and disk), but it will also mean
599 that Gnus has no record of which groups are new and which are old, so
600 the automatic new newsgroups subscription methods become meaningless.
602 You should always set `gnus-check-new-newsgroups' to `ask-server' or
603 nil if you set this variable to nil.")
605 (defvar gnus-interactive-catchup t
606 "*If non-nil, require your confirmation when catching up a group.")
608 (defvar gnus-interactive-exit t
609 "*If non-nil, require your confirmation when exiting Gnus.")
611 (defvar gnus-kill-killed t
612 "*If non-nil, Gnus will apply kill files to already killed articles.
613 If it is nil, Gnus will never apply kill files to articles that have
614 already been through the scoring process, which might very well save lots
617 (defvar gnus-extract-address-components 'gnus-extract-address-components
618 "*Function for extracting address components from a From header.
619 Two pre-defined function exist: `gnus-extract-address-components',
620 which is the default, quite fast, and too simplistic solution, and
621 `mail-extract-address-components', which works much better, but is
624 (defvar gnus-summary-default-score 0
625 "*Default article score level.
626 If this variable is nil, scoring will be disabled.")
628 (defvar gnus-summary-zcore-fuzz 0
629 "*Fuzziness factor for the zcore in the summary buffer.
630 Articles with scores closer than this to `gnus-summary-default-score'
631 will not be marked.")
633 (defvar gnus-simplify-subject-fuzzy-regexp nil
634 "*Strings to be removed when doing fuzzy matches.
635 This can either be a regular expression or list of regular expressions
636 that will be removed from subject strings if fuzzy subject
637 simplification is selected.")
639 (defvar gnus-permanently-visible-groups nil
640 "*Regexp to match groups that should always be listed in the group buffer.
641 This means that they will still be listed when there are no unread
642 articles in the groups.")
644 (defvar gnus-list-groups-with-ticked-articles t
645 "*If non-nil, list groups that have only ticked articles.
646 If nil, only list groups that have unread articles.")
648 (defvar gnus-group-default-list-level gnus-level-subscribed
649 "*Default listing level.
650 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
652 (defvar gnus-group-use-permanent-levels nil
653 "*If non-nil, once you set a level, Gnus will use this level.")
655 (defvar gnus-group-list-inactive-groups t
656 "*If non-nil, inactive groups will be listed.")
658 (defvar gnus-show-mime nil
659 "*If non-nil, do mime processing of articles.
660 The articles will simply be fed to the function given by
661 `gnus-show-mime-method'.")
663 (defvar gnus-strict-mime t
664 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
666 (defvar gnus-show-mime-method 'metamail-buffer
667 "*Function to process a MIME message.
668 The function is called from the article buffer.")
670 (defvar gnus-decode-encoded-word-method (lambda ())
671 "*Function to decode a MIME encoded-words.
672 The function is called from the article buffer.")
674 (defvar gnus-show-threads t
675 "*If non-nil, display threads in summary mode.")
677 (defvar gnus-thread-hide-subtree nil
678 "*If non-nil, hide all threads initially.
679 If threads are hidden, you have to run the command
680 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
681 to expose hidden threads.")
683 (defvar gnus-thread-hide-killed t
684 "*If non-nil, hide killed threads automatically.")
686 (defvar gnus-thread-ignore-subject nil
687 "*If non-nil, ignore subjects and do all threading based on the Reference header.
688 If nil, which is the default, articles that have different subjects
689 from their parents will start separate threads.")
691 (defvar gnus-thread-operation-ignore-subject t
692 "*If non-nil, subjects will be ignored when doing thread commands.
693 This affects commands like `gnus-summary-kill-thread' and
694 `gnus-summary-lower-thread'.
696 If this variable is nil, articles in the same thread with different
697 subjects will not be included in the operation in question. If this
698 variable is `fuzzy', only articles that have subjects that are fuzzily
699 equal will be included.")
701 (defvar gnus-thread-indent-level 4
702 "*Number that says how much each sub-thread should be indented.")
704 (defvar gnus-ignored-newsgroups
705 (purecopy (mapconcat 'identity
706 '("^to\\." ; not "real" groups
707 "^[0-9. \t]+ " ; all digits in name
708 "[][\"#'()]" ; bogus characters
711 "*A regexp to match uninteresting newsgroups in the active file.
712 Any lines in the active file matching this regular expression are
713 removed from the newsgroup list before anything else is done to it,
714 thus making them effectively non-existent.")
716 (defvar gnus-ignored-headers
717 "^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:"
718 "*All headers that match this regexp will be hidden.
719 This variable can also be a list of regexps of headers to be ignored.
720 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
722 (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-"
723 "*All headers that do not match this regexp will be hidden.
724 This variable can also be a list of regexp of headers to remain visible.
725 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
727 (defvar gnus-sorted-header-list
728 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
729 "^Cc:" "^Date:" "^Organization:")
730 "*This variable is a list of regular expressions.
731 If it is non-nil, headers that match the regular expressions will
732 be placed first in the article buffer in the sequence specified by
735 (defvar gnus-boring-article-headers
736 '(empty followup-to reply-to)
737 "*Headers that are only to be displayed if they have interesting data.
738 Possible values in this list are `empty', `newsgroups', `followup-to',
739 `reply-to', and `date'.")
741 (defvar gnus-show-all-headers nil
742 "*If non-nil, don't hide any headers.")
744 (defvar gnus-save-all-headers t
745 "*If non-nil, don't remove any headers before saving.")
747 (defvar gnus-saved-headers gnus-visible-headers
748 "*Headers to keep if `gnus-save-all-headers' is nil.
749 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
750 If that variable is nil, however, all headers that match this regexp
751 will be kept while the rest will be deleted before saving.")
753 (defvar gnus-inhibit-startup-message nil
754 "*If non-nil, the startup message will not be displayed.")
756 (defvar gnus-signature-separator "^-- *$"
757 "Regexp matching signature separator.")
759 (defvar gnus-signature-limit nil
760 "Provide a limit to what is considered a signature.
761 If it is a number, no signature may not be longer (in characters) than
762 that number. If it is a function, the function will be called without
763 any parameters, and if it returns nil, there is no signature in the
764 buffer. If it is a string, it will be used as a regexp. If it
765 matches, the text in question is not a signature.")
767 (defvar gnus-auto-extend-newsgroup t
768 "*If non-nil, extend newsgroup forward and backward when requested.")
770 (defvar gnus-auto-select-first t
771 "*If nil, don't select the first unread article when entering a group.
772 If this variable is `best', select the highest-scored unread article
773 in the group. If neither nil nor `best', select the first unread
776 If you want to prevent automatic selection of the first unread article
777 in some newsgroups, set the variable to nil in
778 `gnus-select-group-hook'.")
780 (defvar gnus-auto-select-next t
781 "*If non-nil, offer to go to the next group from the end of the previous.
782 If the value is t and the next newsgroup is empty, Gnus will exit
783 summary mode and go back to group mode. If the value is neither nil
784 nor t, Gnus will select the following unread newsgroup. In
785 particular, if the value is the symbol `quietly', the next unread
786 newsgroup will be selected without any confirmation, and if it is
787 `almost-quietly', the next group will be selected without any
788 confirmation if you are located on the last article in the group.
789 Finally, if this variable is `slightly-quietly', the `Z n' command
790 will go to the next group without confirmation.")
792 (defvar gnus-auto-select-same nil
793 "*If non-nil, select the next article with the same subject.")
795 (defvar gnus-summary-check-current nil
796 "*If non-nil, consider the current article when moving.
797 The \"unread\" movement commands will stay on the same line if the
798 current article is unread.")
800 (defvar gnus-auto-center-summary t
801 "*If non-nil, always center the current summary buffer.
802 In particular, if `vertical' do only vertical recentering. If non-nil
803 and non-`vertical', do both horizontal and vertical recentering.")
805 (defvar gnus-break-pages t
806 "*If non-nil, do page breaking on articles.
807 The page delimiter is specified by the `gnus-page-delimiter'
810 (defvar gnus-page-delimiter "^\^L"
811 "*Regexp describing what to use as article page delimiters.
812 The default value is \"^\^L\", which is a form linefeed at the
813 beginning of a line.")
815 (defvar gnus-use-full-window t
816 "*If non-nil, use the entire Emacs screen.")
818 (defvar gnus-window-configuration nil
819 "Obsolete variable. See `gnus-buffer-configuration'.")
821 (defvar gnus-window-min-width 2
822 "*Minimum width of Gnus buffers.")
824 (defvar gnus-window-min-height 1
825 "*Minimum height of Gnus buffers.")
827 (defvar gnus-buffer-configuration
831 (if gnus-carpal '(group-carpal 4))))
835 (if gnus-carpal '(summary-carpal 4))))
842 (if gnus-carpal '(summary-carpal 4))
844 (vertical ((height . 5) (width . 15)
846 (left . -1) (top . 1))
856 (if gnus-carpal '(summary-carpal 4))
857 (if gnus-use-trees '(tree 0.25))
862 (if gnus-carpal '(server-carpal 2))))
866 (if gnus-carpal '(browse-carpal 2))))
869 (message 1.0 point)))
872 (article 1.0 point)))
883 (edit-group 1.0 point)))
887 (edit-server 1.0 point)))
891 (edit-score 1.0 point)))
898 (message 1.0 point)))
901 (message 1.0 point)))
904 (message 1.0 point)))
908 (message 1.0 point)))
915 (if gnus-carpal '(summary-carpal 4))
916 ("*Shell Command Output*" 1.0)))
919 ("*Gnus Help Bug*" 0.5)
920 ("*Gnus Bug*" 1.0 point)))
924 (message 1.0 point))))
925 "Window configuration for all possible Gnus buffers.
926 This variable is a list of lists. Each of these lists has a NAME and
927 a RULE. The NAMEs are commonsense names like `group', which names a
928 rule used when displaying the group buffer; `summary', which names a
929 rule for what happens when you enter a group and do not display an
930 article buffer; and so on. See the value of this variable for a
931 complete list of NAMEs.
933 Each RULE is a list of vectors. The first element in this vector is
934 the name of the buffer to be displayed; the second element is the
935 percentage of the screen this buffer is to occupy (a number in the
936 0.0-0.99 range); the optional third element is `point', which should
937 be present to denote which buffer point is to go to after making this
938 buffer configuration.")
940 (defvar gnus-window-to-buffer
941 '((group . gnus-group-buffer)
942 (summary . gnus-summary-buffer)
943 (article . gnus-article-buffer)
944 (server . gnus-server-buffer)
945 (browse . "*Gnus Browse Server*")
946 (edit-group . gnus-group-edit-buffer)
947 (edit-server . gnus-server-edit-buffer)
948 (group-carpal . gnus-carpal-group-buffer)
949 (summary-carpal . gnus-carpal-summary-buffer)
950 (server-carpal . gnus-carpal-server-buffer)
951 (browse-carpal . gnus-carpal-browse-buffer)
952 (edit-score . gnus-score-edit-buffer)
953 (message . gnus-message-buffer)
954 (mail . gnus-message-buffer)
955 (post-news . gnus-message-buffer)
956 (faq . gnus-faq-buffer)
957 (picons . "*Picons*")
958 (tree . gnus-tree-buffer)
959 (info . gnus-info-buffer)
960 (article-copy . gnus-article-copy)
961 (draft . gnus-draft-buffer))
962 "Mapping from short symbols to buffer names or buffer variables.")
964 (defvar gnus-carpal nil
965 "*If non-nil, display clickable icons.")
967 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
968 "*Function called with a group name when new group is detected.
969 A few pre-made functions are supplied: `gnus-subscribe-randomly'
970 inserts new groups at the beginning of the list of groups;
971 `gnus-subscribe-alphabetically' inserts new groups in strict
972 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
973 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
974 for your decision; `gnus-subscribe-killed' kills all new groups;
975 `gnus-subscribe-zombies' will make all new groups into zombies.")
977 ;; Suggested by a bug report by Hallvard B Furuseth.
978 ;; <h.b.furuseth@usit.uio.no>.
979 (defvar gnus-subscribe-options-newsgroup-method
980 (function gnus-subscribe-alphabetically)
981 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
982 If, for instance, you want to subscribe to all newsgroups in the
983 \"no\" and \"alt\" hierarchies, you'd put the following in your
986 options -n no.all alt.all
988 Gnus will the subscribe all new newsgroups in these hierarchies with
989 the subscription method in this variable.")
991 (defvar gnus-subscribe-hierarchical-interactive nil
992 "*If non-nil, Gnus will offer to subscribe hierarchically.
993 When a new hierarchy appears, Gnus will ask the user:
995 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
997 If the user pressed `d', Gnus will descend the hierarchy, `y' will
998 subscribe to all newsgroups in the hierarchy and `s' will skip this
999 hierarchy in its entirety.")
1001 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1002 "*Function used for sorting the group buffer.
1003 This function will be called with group info entries as the arguments
1004 for the groups to be sorted. Pre-made functions include
1005 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1006 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1007 `gnus-group-sort-by-rank'.
1009 This variable can also be a list of sorting functions. In that case,
1010 the most significant sort function should be the last function in the
1013 ;; Mark variables suggested by Thomas Michanek
1014 ;; <Thomas.Michanek@telelogic.se>.
1015 (defvar gnus-unread-mark ?
1016 "*Mark used for unread articles.")
1017 (defvar gnus-ticked-mark ?!
1018 "*Mark used for ticked articles.")
1019 (defvar gnus-dormant-mark ??
1020 "*Mark used for dormant articles.")
1021 (defvar gnus-del-mark ?r
1022 "*Mark used for del'd articles.")
1023 (defvar gnus-read-mark ?R
1024 "*Mark used for read articles.")
1025 (defvar gnus-expirable-mark ?E
1026 "*Mark used for expirable articles.")
1027 (defvar gnus-killed-mark ?K
1028 "*Mark used for killed articles.")
1029 (defvar gnus-souped-mark ?F
1030 "*Mark used for killed articles.")
1031 (defvar gnus-kill-file-mark ?X
1032 "*Mark used for articles killed by kill files.")
1033 (defvar gnus-low-score-mark ?Y
1034 "*Mark used for articles with a low score.")
1035 (defvar gnus-catchup-mark ?C
1036 "*Mark used for articles that are caught up.")
1037 (defvar gnus-replied-mark ?A
1038 "*Mark used for articles that have been replied to.")
1039 (defvar gnus-cached-mark ?*
1040 "*Mark used for articles that are in the cache.")
1041 (defvar gnus-saved-mark ?S
1042 "*Mark used for articles that have been saved to.")
1043 (defvar gnus-process-mark ?#
1045 (defvar gnus-ancient-mark ?O
1046 "*Mark used for ancient articles.")
1047 (defvar gnus-sparse-mark ?Q
1048 "*Mark used for sparsely reffed articles.")
1049 (defvar gnus-canceled-mark ?G
1050 "*Mark used for canceled articles.")
1051 (defvar gnus-score-over-mark ?+
1052 "*Score mark used for articles with high scores.")
1053 (defvar gnus-score-below-mark ?-
1054 "*Score mark used for articles with low scores.")
1055 (defvar gnus-empty-thread-mark ?
1056 "*There is no thread under the article.")
1057 (defvar gnus-not-empty-thread-mark ?=
1058 "*There is a thread under the article.")
1060 (defvar gnus-view-pseudo-asynchronously nil
1061 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1063 (defvar gnus-view-pseudos nil
1064 "*If `automatic', pseudo-articles will be viewed automatically.
1065 If `not-confirm', pseudos will be viewed automatically, and the user
1066 will not be asked to confirm the command.")
1068 (defvar gnus-view-pseudos-separately t
1069 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1070 If nil, all files that use the same viewing command will be given as a
1071 list of parameters to that command.")
1073 (defvar gnus-insert-pseudo-articles t
1074 "*If non-nil, insert pseudo-articles when decoding articles.")
1076 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1077 "*Format of group lines.
1078 It works along the same lines as a normal formatting string,
1079 with some simple extensions.
1081 %M Only marked articles (character, \"*\" or \" \")
1082 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1083 %L Level of subscribedness (integer)
1084 %N Number of unread articles (integer)
1085 %I Number of dormant articles (integer)
1086 %i Number of ticked and dormant (integer)
1087 %T Number of ticked articles (integer)
1088 %R Number of read articles (integer)
1089 %t Total number of articles (integer)
1090 %y Number of unread, unticked articles (integer)
1091 %G Group name (string)
1092 %g Qualified group name (string)
1093 %D Group description (string)
1094 %s Select method (string)
1095 %o Moderated group (char, \"m\")
1096 %p Process mark (char)
1097 %O Moderated group (string, \"(m)\" or \"\")
1098 %P Topic indentation (string)
1099 %l Whether there are GroupLens predictions for this group (string)
1100 %n Select from where (string)
1101 %z A string that look like `<%s:%n>' if a foreign select method is used
1102 %u User defined specifier. The next character in the format string should
1103 be a letter. Gnus will call the function gnus-user-format-function-X,
1104 where X is the letter following %u. The function will be passed the
1105 current header as argument. The function should return a string, which
1106 will be inserted into the buffer just like information from any other
1109 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1110 the mouse point move inside the area. There can only be one such area.
1112 Note that this format specification is not always respected. For
1113 reasons of efficiency, when listing killed groups, this specification
1114 is ignored altogether. If the spec is changed considerably, your
1115 output may end up looking strange when listing both alive and killed
1118 If you use %o or %O, reading the active file will be slower and quite
1119 a bit of extra memory will be used. %D will also worsen performance.
1120 Also note that if you change the format specification to include any
1121 of these specs, you must probably re-start Gnus to see them go into
1124 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1125 "*The format specification of the lines in the summary buffer.
1127 It works along the same lines as a normal formatting string,
1128 with some simple extensions.
1130 %N Article number, left padded with spaces (string)
1132 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1133 %n Name of the poster (string)
1134 %a Extracted name of the poster (string)
1135 %A Extracted address of the poster (string)
1136 %F Contents of the From: header (string)
1137 %x Contents of the Xref: header (string)
1138 %D Date of the article (string)
1139 %d Date of the article (string) in DD-MMM format
1140 %M Message-id of the article (string)
1141 %r References of the article (string)
1142 %c Number of characters in the article (integer)
1143 %L Number of lines in the article (integer)
1144 %I Indentation based on thread level (a string of spaces)
1145 %T A string with two possible values: 80 spaces if the article
1146 is on thread level two or larger and 0 spaces on level one
1147 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1148 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1149 %[ Opening bracket (character, \"[\" or \"<\")
1150 %] Closing bracket (character, \"]\" or \">\")
1151 %> Spaces of length thread-level (string)
1152 %< Spaces of length (- 20 thread-level) (string)
1153 %i Article score (number)
1154 %z Article zcore (character)
1155 %t Number of articles under the current thread (number).
1156 %e Whether the thread is empty or not (character).
1157 %l GroupLens score (string).
1158 %u User defined specifier. The next character in the format string should
1159 be a letter. Gnus will call the function gnus-user-format-function-X,
1160 where X is the letter following %u. The function will be passed the
1161 current header as argument. The function should return a string, which
1162 will be inserted into the summary just like information from any other
1165 Text between %( and %) will be highlighted with `gnus-mouse-face'
1166 when the mouse point is placed inside the area. There can only be one
1169 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1170 with care. For reasons of efficiency, Gnus will compute what column
1171 these characters will end up in, and \"hard-code\" that. This means that
1172 it is illegal to have these specs after a variable-length spec. Well,
1173 you might not be arrested, but your summary buffer will look strange,
1174 which is bad enough.
1176 The smart choice is to have these specs as for to the left as
1179 This restriction may disappear in later versions of Gnus.")
1181 (defvar gnus-summary-dummy-line-format
1183 "*The format specification for the dummy roots in the summary buffer.
1184 It works along the same lines as a normal formatting string,
1185 with some simple extensions.
1189 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1190 "*The format specification for the summary mode line.
1191 It works along the same lines as a normal formatting string,
1192 with some simple extensions:
1195 %p Unprefixed group name
1196 %A Current article number
1198 %U Number of unread articles in the group
1199 %e Number of unselected articles in the group
1200 %Z A string with unread/unselected article counts
1201 %g Shortish group name
1202 %S Subject of the current article
1203 %u User-defined spec
1204 %s Current score file name
1205 %d Number of dormant articles
1206 %r Number of articles that have been marked as read in this session
1207 %E Number of articles expunged by the score files")
1209 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1210 "*The format specification for the article mode line.
1211 See `gnus-summary-mode-line-format' for a closer description.")
1213 (defvar gnus-group-mode-line-format "Gnus: %%b {%M%:%S}"
1214 "*The format specification for the group mode line.
1215 It works along the same lines as a normal formatting string,
1216 with some simple extensions:
1218 %S The native news server.
1219 %M The native select method.
1220 %: \":\" if %S isn't \"\".")
1222 (defvar gnus-valid-select-methods
1223 '(("nntp" post address prompt-address)
1224 ("nnspool" post address)
1225 ("nnvirtual" post-mail virtual prompt-address)
1226 ("nnmbox" mail respool address)
1227 ("nnml" mail respool address)
1228 ("nnmh" mail respool address)
1229 ("nndir" post-mail prompt-address address)
1230 ("nneething" none address prompt-address)
1231 ("nndoc" none address prompt-address)
1232 ("nnbabyl" mail address respool)
1233 ("nnkiboze" post address virtual)
1234 ("nnsoup" post-mail address)
1235 ("nndraft" post-mail)
1236 ("nnfolder" mail respool address))
1237 "An alist of valid select methods.
1238 The first element of each list lists should be a string with the name
1239 of the select method. The other elements may be be the category of
1240 this method (ie. `post', `mail', `none' or whatever) or other
1241 properties that this method has (like being respoolable).
1242 If you implement a new select method, all you should have to change is
1243 this variable. I think.")
1245 (defvar gnus-updated-mode-lines '(group article summary tree)
1246 "*List of buffers that should update their mode lines.
1247 The list may contain the symbols `group', `article' and `summary'. If
1248 the corresponding symbol is present, Gnus will keep that mode line
1249 updated with information that may be pertinent.
1250 If this variable is nil, screen refresh may be quicker.")
1252 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1253 (defvar gnus-mode-non-string-length nil
1254 "*Max length of mode-line non-string contents.
1255 If this is nil, Gnus will take space as is needed, leaving the rest
1256 of the modeline intact.")
1259 ;(defvar gnus-mouse-face 'highlight
1260 ; "*Face used for mouse highlighting in Gnus.
1261 ;No mouse highlights will be done if `gnus-visual' is nil.")
1263 (defvar gnus-summary-mark-below 0
1264 "*Mark all articles with a score below this variable as read.
1265 This variable is local to each summary buffer and usually set by the
1268 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1269 "*List of functions used for sorting articles in the summary buffer.
1270 This variable is only used when not using a threaded display.")
1272 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1273 "*List of functions used for sorting threads in the summary buffer.
1274 By default, threads are sorted by article number.
1276 Each function takes two threads and return non-nil if the first thread
1277 should be sorted before the other. If you use more than one function,
1278 the primary sort function should be the last. You should probably
1279 always include `gnus-thread-sort-by-number' in the list of sorting
1280 functions -- preferably first.
1282 Ready-mady functions include `gnus-thread-sort-by-number',
1283 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1284 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1285 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1287 (defvar gnus-thread-score-function '+
1288 "*Function used for calculating the total score of a thread.
1290 The function is called with the scores of the article and each
1291 subthread and should then return the score of the thread.
1293 Some functions you can use are `+', `max', or `min'.")
1295 (defvar gnus-summary-expunge-below nil
1296 "All articles that have a score less than this variable will be expunged.")
1298 (defvar gnus-thread-expunge-below nil
1299 "All threads that have a total score less than this variable will be expunged.
1300 See `gnus-thread-score-function' for en explanation of what a
1301 \"thread score\" is.")
1303 (defvar gnus-auto-subscribed-groups
1304 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1305 "*All new groups that match this regexp will be subscribed automatically.
1306 Note that this variable only deals with new groups. It has no effect
1307 whatsoever on old groups.")
1309 (defvar gnus-options-subscribe nil
1310 "*All new groups matching this regexp will be subscribed unconditionally.
1311 Note that this variable deals only with new newsgroups. This variable
1312 does not affect old newsgroups.")
1314 (defvar gnus-options-not-subscribe nil
1315 "*All new groups matching this regexp will be ignored.
1316 Note that this variable deals only with new newsgroups. This variable
1317 does not affect old (already subscribed) newsgroups.")
1319 (defvar gnus-auto-expirable-newsgroups nil
1320 "*Groups in which to automatically mark read articles as expirable.
1321 If non-nil, this should be a regexp that should match all groups in
1322 which to perform auto-expiry. This only makes sense for mail groups.")
1324 (defvar gnus-total-expirable-newsgroups nil
1325 "*Groups in which to perform expiry of all read articles.
1326 Use with extreme caution. All groups that match this regexp will be
1327 expiring - which means that all read articles will be deleted after
1328 (say) one week. (This only goes for mail groups and the like, of
1331 (defvar gnus-group-uncollapsed-levels 1
1332 "Number of group name elements to leave alone when making a short group name.")
1334 (defvar gnus-hidden-properties '(invisible t intangible t)
1335 "Property list to use for hiding text.")
1337 (defvar gnus-modtime-botch nil
1338 "*Non-nil means .newsrc should be deleted prior to save.
1339 Its use is due to the bogus appearance that .newsrc was modified on
1344 (defvar gnus-group-mode-hook nil
1345 "*A hook for Gnus group mode.")
1347 (defvar gnus-summary-mode-hook nil
1348 "*A hook for Gnus summary mode.
1349 This hook is run before any variables are set in the summary buffer.")
1351 (defvar gnus-article-mode-hook nil
1352 "*A hook for Gnus article mode.")
1354 (defvar gnus-summary-prepare-exit-hook nil
1355 "*A hook called when preparing to exit from the summary buffer.
1356 It calls `gnus-summary-expire-articles' by default.")
1357 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1359 (defvar gnus-summary-exit-hook nil
1360 "*A hook called on exit from the summary buffer.")
1362 (defvar gnus-group-catchup-group-hook nil
1363 "*A hook run when catching up a group from the group buffer.")
1365 (defvar gnus-open-server-hook nil
1366 "*A hook called just before opening connection to the news server.")
1368 (defvar gnus-load-hook nil
1369 "*A hook run while Gnus is loaded.")
1371 (defvar gnus-startup-hook nil
1372 "*A hook called at startup.
1373 This hook is called after Gnus is connected to the NNTP server.")
1375 (defvar gnus-get-new-news-hook nil
1376 "*A hook run just before Gnus checks for new news.")
1378 (defvar gnus-after-getting-new-news-hook nil
1379 "*A hook run after Gnus checks for new news.")
1381 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1382 "*A function that is called to generate the group buffer.
1383 The function is called with three arguments: The first is a number;
1384 all group with a level less or equal to that number should be listed,
1385 if the second is non-nil, empty groups should also be displayed. If
1386 the third is non-nil, it is a number. No groups with a level lower
1387 than this number should be displayed.
1389 The only current function implemented is `gnus-group-prepare-flat'.")
1391 (defvar gnus-group-prepare-hook nil
1392 "*A hook called after the group buffer has been generated.
1393 If you want to modify the group buffer, you can use this hook.")
1395 (defvar gnus-summary-prepare-hook nil
1396 "*A hook called after the summary buffer has been generated.
1397 If you want to modify the summary buffer, you can use this hook.")
1399 (defvar gnus-summary-generate-hook nil
1400 "*A hook run just before generating the summary buffer.
1401 This hook is commonly used to customize threading variables and the
1404 (defvar gnus-article-prepare-hook nil
1405 "*A hook called after an article has been prepared in the article buffer.
1406 If you want to run a special decoding program like nkf, use this hook.")
1408 ;(defvar gnus-article-display-hook nil
1409 ; "*A hook called after the article is displayed in the article buffer.
1410 ;The hook is designed to change the contents of the article
1411 ;buffer. Typical functions that this hook may contain are
1412 ;`gnus-article-hide-headers' (hide selected headers),
1413 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1414 ;`gnus-article-hide-signature' (hide signature) and
1415 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1416 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1417 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1418 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1420 (defvar gnus-article-x-face-command
1421 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1422 "String or function to be executed to display an X-Face header.
1423 If it is a string, the command will be executed in a sub-shell
1424 asynchronously. The compressed face will be piped to this command.")
1426 (defvar gnus-article-x-face-too-ugly nil
1427 "Regexp matching posters whose face shouldn't be shown automatically.")
1429 (defvar gnus-select-group-hook nil
1430 "*A hook called when a newsgroup is selected.
1432 If you'd like to simplify subjects like the
1433 `gnus-summary-next-same-subject' command does, you can use the
1436 (setq gnus-select-group-hook
1439 (mapcar (lambda (header)
1440 (mail-header-set-subject
1442 (gnus-simplify-subject
1443 (mail-header-subject header) 're-only)))
1444 gnus-newsgroup-headers))))")
1446 (defvar gnus-select-article-hook nil
1447 "*A hook called when an article is selected.")
1449 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1450 "*A hook called to apply kill files to a group.
1451 This hook is intended to apply a kill file to the selected newsgroup.
1452 The function `gnus-apply-kill-file' is called by default.
1454 Since a general kill file is too heavy to use only for a few
1455 newsgroups, I recommend you to use a lighter hook function. For
1456 example, if you'd like to apply a kill file to articles which contains
1457 a string `rmgroup' in subject in newsgroup `control', you can use the
1460 (setq gnus-apply-kill-hook
1463 (cond ((string-match \"control\" gnus-newsgroup-name)
1464 (gnus-kill \"Subject\" \"rmgroup\")
1465 (gnus-expunge \"X\"))))))")
1467 (defvar gnus-visual-mark-article-hook
1468 (list 'gnus-highlight-selected-summary)
1469 "*Hook run after selecting an article in the summary buffer.
1470 It is meant to be used for highlighting the article in some way. It
1471 is not run if `gnus-visual' is nil.")
1473 (defvar gnus-parse-headers-hook nil
1474 "*A hook called before parsing the headers.")
1475 (add-hook 'gnus-parse-headers-hook 'gnus-decode-rfc1522)
1477 (defvar gnus-exit-group-hook nil
1478 "*A hook called when exiting (not quitting) summary mode.")
1480 (defvar gnus-suspend-gnus-hook nil
1481 "*A hook called when suspending (not exiting) Gnus.")
1483 (defvar gnus-exit-gnus-hook nil
1484 "*A hook called when exiting Gnus.")
1486 (defvar gnus-after-exiting-gnus-hook nil
1487 "*A hook called after exiting Gnus.")
1489 (defvar gnus-save-newsrc-hook nil
1490 "*A hook called before saving any of the newsrc files.")
1492 (defvar gnus-save-quick-newsrc-hook nil
1493 "*A hook called just before saving the quick newsrc file.
1494 Can be used to turn version control on or off.")
1496 (defvar gnus-save-standard-newsrc-hook nil
1497 "*A hook called just before saving the standard newsrc file.
1498 Can be used to turn version control on or off.")
1500 (defvar gnus-summary-update-hook
1501 (list 'gnus-summary-highlight-line)
1502 "*A hook called when a summary line is changed.
1503 The hook will not be called if `gnus-visual' is nil.
1505 The default function `gnus-summary-highlight-line' will
1506 highlight the line according to the `gnus-summary-highlight'
1509 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1510 "*A hook called when a group line is changed.
1511 The hook will not be called if `gnus-visual' is nil.
1513 The default function `gnus-group-highlight-line' will
1514 highlight the line according to the `gnus-group-highlight'
1517 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1518 "*A hook called when an article is selected for the first time.
1519 The hook is intended to mark an article as read (or unread)
1520 automatically when it is selected.")
1522 (defvar gnus-group-change-level-function nil
1523 "Function run when a group level is changed.
1524 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1526 ;; Remove any hilit infestation.
1527 (add-hook 'gnus-startup-hook
1529 (remove-hook 'gnus-summary-prepare-hook
1530 'hilit-rehighlight-buffer-quietly)
1531 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1532 (setq gnus-mark-article-hook
1533 '(gnus-summary-mark-read-and-unread-as-read))
1534 (remove-hook 'gnus-article-prepare-hook
1535 'hilit-rehighlight-buffer-quietly)))
1538 ;; Internal variables
1540 (defvar gnus-tree-buffer "*Tree*"
1541 "Buffer where Gnus thread trees are displayed.")
1544 (defvar gnus-use-generic-from nil)
1546 (defvar gnus-thread-indent-array nil)
1547 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1549 (defvar gnus-newsrc-file-version nil)
1551 (defvar gnus-method-history nil)
1552 ;; Variable holding the user answers to all method prompts.
1554 (defvar gnus-group-history nil)
1555 ;; Variable holding the user answers to all group prompts.
1557 (defvar gnus-server-alist nil
1558 "List of available servers.")
1560 (defvar gnus-group-indentation-function nil)
1562 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1564 (defvar gnus-goto-missing-group-function nil)
1566 (defvar gnus-override-subscribe-method nil)
1568 (defvar gnus-group-goto-next-group-function nil
1569 "Function to override finding the next group after listing groups.")
1571 (defconst gnus-article-mark-lists
1572 '((marked . tick) (replied . reply)
1573 (expirable . expire) (killed . killed)
1574 (bookmarks . bookmark) (dormant . dormant)
1575 (scored . score) (saved . save)
1579 ;; Avoid highlighting in kill files.
1580 (defvar gnus-summary-inhibit-highlight nil)
1581 (defvar gnus-newsgroup-selected-overlay nil)
1583 (defvar gnus-inhibit-hiding nil)
1584 (defvar gnus-group-indentation "")
1585 (defvar gnus-inhibit-limiting nil)
1586 (defvar gnus-created-frames nil)
1588 (defvar gnus-article-mode-map nil)
1589 (defvar gnus-dribble-buffer nil)
1590 (defvar gnus-headers-retrieved-by nil)
1591 (defvar gnus-article-reply nil)
1592 (defvar gnus-override-method nil)
1593 (defvar gnus-article-check-size nil)
1595 (defvar gnus-current-score-file nil)
1596 (defvar gnus-newsgroup-adaptive-score-file nil)
1597 (defvar gnus-scores-exclude-files nil)
1599 (defvar gnus-opened-servers nil)
1601 (defvar gnus-current-move-group nil)
1602 (defvar gnus-current-copy-group nil)
1603 (defvar gnus-current-crosspost-group nil)
1605 (defvar gnus-newsgroup-dependencies nil)
1606 (defvar gnus-newsgroup-async nil)
1607 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1609 (defvar gnus-newsgroup-adaptive nil)
1611 (defvar gnus-summary-display-table nil)
1612 (defvar gnus-summary-display-article-function nil)
1614 (defvar gnus-summary-highlight-line-function nil
1615 "Function called after highlighting a summary line.")
1617 (defvar gnus-group-line-format-alist
1618 `((?M gnus-tmp-marked-mark ?c)
1619 (?S gnus-tmp-subscribed ?c)
1620 (?L gnus-tmp-level ?d)
1621 (?N (cond ((eq number t) "*" )
1625 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1626 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1628 (?R gnus-tmp-number-of-read ?s)
1629 (?t gnus-tmp-number-total ?d)
1630 (?y gnus-tmp-number-of-unread ?s)
1631 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1632 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1633 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1634 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1635 (?g gnus-tmp-group ?s)
1636 (?G gnus-tmp-qualified-group ?s)
1637 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1638 (?D gnus-tmp-newsgroup-description ?s)
1639 (?o gnus-tmp-moderated ?c)
1640 (?O gnus-tmp-moderated-string ?s)
1641 (?p gnus-tmp-process-marked ?c)
1642 (?s gnus-tmp-news-server ?s)
1643 (?n gnus-tmp-news-method ?s)
1644 (?P gnus-group-indentation ?s)
1645 (?l gnus-tmp-grouplens ?s)
1646 (?z gnus-tmp-news-method-string ?s)
1647 (?u gnus-tmp-user-defined ?s)))
1649 (defvar gnus-summary-line-format-alist
1650 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1651 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1652 (?s gnus-tmp-subject-or-nil ?s)
1653 (?n gnus-tmp-name ?s)
1654 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1656 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1658 (?F gnus-tmp-from ?s)
1659 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1660 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1661 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1662 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1663 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1664 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1665 (?L gnus-tmp-lines ?d)
1666 (?I gnus-tmp-indentation ?s)
1667 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1668 (?R gnus-tmp-replied ?c)
1669 (?\[ gnus-tmp-opening-bracket ?c)
1670 (?\] gnus-tmp-closing-bracket ?c)
1671 (?\> (make-string gnus-tmp-level ? ) ?s)
1672 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1673 (?i gnus-tmp-score ?d)
1674 (?z gnus-tmp-score-char ?c)
1675 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1676 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1677 (?U gnus-tmp-unread ?c)
1678 (?t (gnus-summary-number-of-articles-in-thread
1679 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1681 (?e (gnus-summary-number-of-articles-in-thread
1682 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1684 (?u gnus-tmp-user-defined ?s))
1685 "An alist of format specifications that can appear in summary lines,
1686 and what variables they correspond with, along with the type of the
1687 variable (string, integer, character, etc).")
1689 (defvar gnus-summary-dummy-line-format-alist
1690 `((?S gnus-tmp-subject ?s)
1691 (?N gnus-tmp-number ?d)
1692 (?u gnus-tmp-user-defined ?s)))
1694 (defvar gnus-summary-mode-line-format-alist
1695 `((?G gnus-tmp-group-name ?s)
1696 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1697 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1698 (?A gnus-tmp-article-number ?d)
1699 (?Z gnus-tmp-unread-and-unselected ?s)
1700 (?V gnus-version ?s)
1701 (?U gnus-tmp-unread ?d)
1702 (?S gnus-tmp-subject ?s)
1703 (?e gnus-tmp-unselected ?d)
1704 (?u gnus-tmp-user-defined ?s)
1705 (?d (length gnus-newsgroup-dormant) ?d)
1706 (?t (length gnus-newsgroup-marked) ?d)
1707 (?r (length gnus-newsgroup-reads) ?d)
1708 (?E gnus-newsgroup-expunged-tally ?d)
1709 (?s (gnus-current-score-file-nondirectory) ?s)))
1711 (defvar gnus-article-mode-line-format-alist
1712 gnus-summary-mode-line-format-alist)
1714 (defvar gnus-group-mode-line-format-alist
1715 `((?S gnus-tmp-news-server ?s)
1716 (?M gnus-tmp-news-method ?s)
1717 (?u gnus-tmp-user-defined ?s)
1718 (?: gnus-tmp-colon ?s)))
1720 (defvar gnus-have-read-active-file nil)
1722 (defconst gnus-maintainer
1723 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1724 "The mail address of the Gnus maintainers.")
1726 (defconst gnus-version "September Gnus v0.97"
1727 "Version number for this version of Gnus.")
1729 (defvar gnus-info-nodes
1730 '((gnus-group-mode "(gnus)The Group Buffer")
1731 (gnus-summary-mode "(gnus)The Summary Buffer")
1732 (gnus-article-mode "(gnus)The Article Buffer"))
1733 "Assoc list of major modes and related Info nodes.")
1735 (defvar gnus-group-buffer "*Group*")
1736 (defvar gnus-summary-buffer "*Summary*")
1737 (defvar gnus-article-buffer "*Article*")
1738 (defvar gnus-server-buffer "*Server*")
1740 (defvar gnus-work-buffer " *gnus work*")
1742 (defvar gnus-original-article-buffer " *Original Article*")
1743 (defvar gnus-original-article nil)
1745 (defvar gnus-buffer-list nil
1746 "Gnus buffers that should be killed on exit.")
1748 (defvar gnus-slave nil
1749 "Whether this Gnus is a slave or not.")
1751 (defvar gnus-variable-list
1752 '(gnus-newsrc-options gnus-newsrc-options-n
1753 gnus-newsrc-last-checked-date
1754 gnus-newsrc-alist gnus-server-alist
1755 gnus-killed-list gnus-zombie-list
1756 gnus-topic-topology gnus-topic-alist
1758 "Gnus variables saved in the quick startup file.")
1760 (defvar gnus-newsrc-options nil
1761 "Options line in the .newsrc file.")
1763 (defvar gnus-newsrc-options-n nil
1764 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1766 (defvar gnus-newsrc-last-checked-date nil
1767 "Date Gnus last asked server for new newsgroups.")
1769 (defvar gnus-topic-topology nil
1770 "The complete topic hierarchy.")
1772 (defvar gnus-topic-alist nil
1773 "The complete topic-group alist.")
1775 (defvar gnus-newsrc-alist nil
1776 "Assoc list of read articles.
1777 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1779 (defvar gnus-newsrc-hashtb nil
1780 "Hashtable of gnus-newsrc-alist.")
1782 (defvar gnus-killed-list nil
1783 "List of killed newsgroups.")
1785 (defvar gnus-killed-hashtb nil
1786 "Hash table equivalent of gnus-killed-list.")
1788 (defvar gnus-zombie-list nil
1789 "List of almost dead newsgroups.")
1791 (defvar gnus-description-hashtb nil
1792 "Descriptions of newsgroups.")
1794 (defvar gnus-list-of-killed-groups nil
1795 "List of newsgroups that have recently been killed by the user.")
1797 (defvar gnus-active-hashtb nil
1798 "Hashtable of active articles.")
1800 (defvar gnus-moderated-list nil
1801 "List of moderated newsgroups.")
1803 (defvar gnus-group-marked nil)
1805 (defvar gnus-current-startup-file nil
1806 "Startup file for the current host.")
1808 (defvar gnus-last-search-regexp nil
1809 "Default regexp for article search command.")
1811 (defvar gnus-last-shell-command nil
1812 "Default shell command on article.")
1814 (defvar gnus-current-select-method nil
1815 "The current method for selecting a newsgroup.")
1817 (defvar gnus-group-list-mode nil)
1819 (defvar gnus-article-internal-prepare-hook nil)
1821 (defvar gnus-newsgroup-name nil)
1822 (defvar gnus-newsgroup-begin nil)
1823 (defvar gnus-newsgroup-end nil)
1824 (defvar gnus-newsgroup-last-rmail nil)
1825 (defvar gnus-newsgroup-last-mail nil)
1826 (defvar gnus-newsgroup-last-folder nil)
1827 (defvar gnus-newsgroup-last-file nil)
1828 (defvar gnus-newsgroup-auto-expire nil)
1829 (defvar gnus-newsgroup-active nil)
1831 (defvar gnus-newsgroup-data nil)
1832 (defvar gnus-newsgroup-data-reverse nil)
1833 (defvar gnus-newsgroup-limit nil)
1834 (defvar gnus-newsgroup-limits nil)
1836 (defvar gnus-newsgroup-unreads nil
1837 "List of unread articles in the current newsgroup.")
1839 (defvar gnus-newsgroup-unselected nil
1840 "List of unselected unread articles in the current newsgroup.")
1842 (defvar gnus-newsgroup-reads nil
1843 "Alist of read articles and article marks in the current newsgroup.")
1845 (defvar gnus-newsgroup-expunged-tally nil)
1847 (defvar gnus-newsgroup-marked nil
1848 "List of ticked articles in the current newsgroup (a subset of unread art).")
1850 (defvar gnus-newsgroup-killed nil
1851 "List of ranges of articles that have been through the scoring process.")
1853 (defvar gnus-newsgroup-cached nil
1854 "List of articles that come from the article cache.")
1856 (defvar gnus-newsgroup-saved nil
1857 "List of articles that have been saved.")
1859 (defvar gnus-newsgroup-kill-headers nil)
1861 (defvar gnus-newsgroup-replied nil
1862 "List of articles that have been replied to in the current newsgroup.")
1864 (defvar gnus-newsgroup-expirable nil
1865 "List of articles in the current newsgroup that can be expired.")
1867 (defvar gnus-newsgroup-processable nil
1868 "List of articles in the current newsgroup that can be processed.")
1870 (defvar gnus-newsgroup-bookmarks nil
1871 "List of articles in the current newsgroup that have bookmarks.")
1873 (defvar gnus-newsgroup-dormant nil
1874 "List of dormant articles in the current newsgroup.")
1876 (defvar gnus-newsgroup-scored nil
1877 "List of scored articles in the current newsgroup.")
1879 (defvar gnus-newsgroup-headers nil
1880 "List of article headers in the current newsgroup.")
1882 (defvar gnus-newsgroup-threads nil)
1884 (defvar gnus-newsgroup-prepared nil
1885 "Whether the current group has been prepared properly.")
1887 (defvar gnus-newsgroup-ancient nil
1888 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1890 (defvar gnus-newsgroup-sparse nil)
1892 (defvar gnus-current-article nil)
1893 (defvar gnus-article-current nil)
1894 (defvar gnus-current-headers nil)
1895 (defvar gnus-have-all-headers nil)
1896 (defvar gnus-last-article nil)
1897 (defvar gnus-newsgroup-history nil)
1898 (defvar gnus-current-kill-article nil)
1900 ;; Save window configuration.
1901 (defvar gnus-prev-winconf nil)
1903 (defvar gnus-summary-mark-positions nil)
1904 (defvar gnus-group-mark-positions nil)
1906 (defvar gnus-reffed-article-number nil)
1908 ;;; Let the byte-compiler know that we know about this variable.
1909 (defvar rmail-default-rmail-file)
1911 (defvar gnus-cache-removable-articles nil)
1913 (defvar gnus-dead-summary nil)
1915 (defconst gnus-summary-local-variables
1916 '(gnus-newsgroup-name
1917 gnus-newsgroup-begin gnus-newsgroup-end
1918 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1919 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1920 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1921 gnus-newsgroup-unselected gnus-newsgroup-marked
1922 gnus-newsgroup-reads gnus-newsgroup-saved
1923 gnus-newsgroup-replied gnus-newsgroup-expirable
1924 gnus-newsgroup-processable gnus-newsgroup-killed
1925 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1926 gnus-newsgroup-headers gnus-newsgroup-threads
1927 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1928 gnus-current-article gnus-current-headers gnus-have-all-headers
1929 gnus-last-article gnus-article-internal-prepare-hook
1930 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1931 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1932 gnus-newsgroup-async gnus-thread-expunge-below
1933 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1934 (gnus-summary-mark-below . 0)
1935 gnus-newsgroup-active gnus-scores-exclude-files
1936 gnus-newsgroup-history gnus-newsgroup-ancient
1937 gnus-newsgroup-sparse
1938 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1939 gnus-newsgroup-adaptive-score-file
1940 (gnus-newsgroup-expunged-tally . 0)
1941 gnus-cache-removable-articles gnus-newsgroup-cached
1942 gnus-newsgroup-data gnus-newsgroup-data-reverse
1943 gnus-newsgroup-limit gnus-newsgroup-limits)
1944 "Variables that are buffer-local to the summary buffers.")
1946 (defconst gnus-bug-message
1947 "Sending a bug report to the Gnus Towers.
1948 ========================================
1950 The buffer below is a mail buffer. When you press `C-c C-c', it will
1951 be sent to the Gnus Bug Exterminators.
1953 At the bottom of the buffer you'll see lots of variable settings.
1954 Please do not delete those. They will tell the Bug People what your
1955 environment is, so that it will be easier to locate the bugs.
1957 If you have found a bug that makes Emacs go \"beep\", set
1958 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1959 and include the backtrace in your bug report.
1961 Please describe the bug in annoying, painstaking detail.
1963 Thank you for your help in stamping out bugs.
1966 ;;; End of variables.
1968 ;; Define some autoload functions Gnus might use.
1971 ;; This little mapcar goes through the list below and marks the
1972 ;; symbols in question as autoloaded functions.
1975 (let ((interactive (nth 1 (memq ':interactive package))))
1979 (when (consp function)
1980 (setq keymap (car (memq 'keymap function)))
1981 (setq function (car function)))
1982 (autoload function (car package) nil interactive keymap)))
1983 (if (eq (nth 1 package) ':interactive)
1986 '(("metamail" metamail-buffer)
1987 ("info" Info-goto-node)
1988 ("hexl" hexl-hex-string-to-integer)
1989 ("pp" pp pp-to-string pp-eval-expression)
1990 ("mail-extr" mail-extract-address-components)
1991 ("nnmail" nnmail-split-fancy nnmail-article-group)
1992 ("nnvirtual" nnvirtual-catchup-group)
1993 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
1994 timezone-make-sortable-date timezone-make-time-string)
1995 ("sendmail" mail-position-on-field mail-setup)
1996 ("rmailout" rmail-output)
1997 ("rnewspost" news-mail-other-window news-reply-yank-original
1998 news-caesar-buffer-body)
1999 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
2001 ("gnus-soup" :interactive t
2002 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
2003 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
2004 ("nnsoup" nnsoup-pack-replies)
2005 ("gnus-scomo" :interactive t gnus-score-mode)
2006 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
2007 gnus-Folder-save-name gnus-folder-save-name)
2008 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
2009 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2010 gnus-server-make-menu-bar gnus-article-make-menu-bar
2011 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2012 gnus-summary-highlight-line gnus-carpal-setup-buffer
2013 gnus-group-highlight-line
2014 gnus-article-add-button gnus-insert-next-page-button
2015 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2016 ("gnus-vis" :interactive t
2017 gnus-article-push-button gnus-article-press-button
2018 gnus-article-highlight gnus-article-highlight-some
2019 gnus-article-highlight-headers gnus-article-highlight-signature
2020 gnus-article-add-buttons gnus-article-add-buttons-to-head
2021 gnus-article-next-button gnus-article-prev-button)
2022 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2023 gnus-demon-add-disconnection gnus-demon-add-handler
2024 gnus-demon-remove-handler)
2025 ("gnus-demon" :interactive t
2026 gnus-demon-init gnus-demon-cancel)
2027 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2028 gnus-tree-open gnus-tree-close)
2029 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2030 gnus-nocem-unwanted-article-p)
2031 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2032 ("gnus-srvr" gnus-browse-foreign-server)
2033 ("gnus-cite" :interactive t
2034 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2035 gnus-article-hide-citation gnus-article-fill-cited-article
2036 gnus-article-hide-citation-in-followups)
2037 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2038 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2039 gnus-execute gnus-expunge)
2040 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2041 gnus-cache-possibly-remove-articles gnus-cache-request-article
2042 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2043 gnus-cache-enter-remove-article gnus-cached-article-p
2044 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2045 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2046 gnus-cache-remove-article)
2047 ("gnus-score" :interactive t
2048 gnus-summary-increase-score gnus-summary-lower-score
2049 gnus-score-flush-cache gnus-score-close
2050 gnus-score-raise-same-subject-and-select
2051 gnus-score-raise-same-subject gnus-score-default
2052 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2053 gnus-score-lower-same-subject gnus-score-lower-thread
2054 gnus-possibly-score-headers gnus-summary-raise-score
2055 gnus-summary-set-score gnus-summary-current-score)
2057 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2058 gnus-current-score-file-nondirectory gnus-score-adaptive
2059 gnus-score-find-trace gnus-score-file-name)
2060 ("gnus-edit" :interactive t gnus-score-customize)
2061 ("gnus-topic" :interactive t gnus-topic-mode)
2062 ("gnus-topic" gnus-topic-remove-group)
2063 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2064 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2065 ("gnus-uu" :interactive t
2066 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2067 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2068 gnus-uu-mark-by-regexp gnus-uu-mark-all
2069 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2070 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2071 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2072 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2073 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2074 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2075 gnus-uu-decode-binhex-view)
2076 ("gnus-msg" (gnus-summary-send-map keymap)
2077 gnus-mail-yank-original gnus-mail-send-and-exit
2078 gnus-sendmail-setup-mail gnus-article-mail
2079 gnus-inews-message-id gnus-new-mail gnus-mail-reply)
2080 ("gnus-msg" :interactive t
2081 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2082 gnus-summary-followup gnus-summary-followup-with-original
2083 gnus-summary-followup-and-reply
2084 gnus-summary-followup-and-reply-with-original
2085 gnus-summary-cancel-article gnus-summary-supersede-article
2086 gnus-post-news gnus-inews-news gnus-cancel-news
2087 gnus-summary-reply gnus-summary-reply-with-original
2088 gnus-summary-mail-forward gnus-summary-mail-other-window
2090 ("gnus-picon" :interactive t gnus-article-display-picons
2091 gnus-group-display-picons gnus-picons-article-display-x-face)
2092 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2093 gnus-grouplens-mode)
2094 ("gnus-vm" gnus-vm-mail-setup)
2095 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2096 gnus-summary-save-article-vm gnus-yank-article))))
2100 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2101 ;; If you want the cursor to go somewhere else, set these two
2102 ;; functions in some startup hook to whatever you want.
2103 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2104 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2106 ;;; Various macros and substs.
2108 (defun gnus-header-from (header)
2109 (mail-header-from header))
2111 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2112 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2113 (let ((tempvar (make-symbol "GnusStartBufferWindow"))
2114 (w (make-symbol "w"))
2115 (buf (make-symbol "buf")))
2116 `(let* ((,tempvar (selected-window))
2118 (,w (get-buffer-window ,buf 'visible)))
2123 (pop-to-buffer ,buf))
2125 (select-window ,tempvar)))))
2127 (defmacro gnus-gethash (string hashtable)
2128 "Get hash value of STRING in HASHTABLE."
2129 `(symbol-value (intern-soft ,string ,hashtable)))
2131 (defmacro gnus-sethash (string value hashtable)
2132 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2133 `(set (intern ,string ,hashtable) ,value))
2135 (defmacro gnus-intern-safe (string hashtable)
2136 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2137 `(let ((symbol (intern ,string ,hashtable)))
2142 (defmacro gnus-group-unread (group)
2143 "Get the currently computed number of unread articles in GROUP."
2144 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2146 (defmacro gnus-group-entry (group)
2147 "Get the newsrc entry for GROUP."
2148 `(gnus-gethash ,group gnus-newsrc-hashtb))
2150 (defmacro gnus-active (group)
2151 "Get active info on GROUP."
2152 `(gnus-gethash ,group gnus-active-hashtb))
2154 (defmacro gnus-set-active (group active)
2155 "Set GROUP's active info."
2156 `(gnus-sethash ,group ,active gnus-active-hashtb))
2158 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2159 ;; function `substring' might cut on a middle of multi-octet
2161 (defun gnus-truncate-string (str width)
2162 (substring str 0 width))
2164 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2165 ;; to limit the length of a string. This function is necessary since
2166 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2167 (defsubst gnus-limit-string (str width)
2168 (if (> (length str) width)
2169 (substring str 0 width)
2172 (defsubst gnus-simplify-subject-re (subject)
2173 "Remove \"Re:\" from subject lines."
2174 (if (string-match "^[Rr][Ee]: *" subject)
2175 (substring subject (match-end 0))
2178 (defsubst gnus-functionp (form)
2179 "Return non-nil if FORM is funcallable."
2180 (or (and (symbolp form) (fboundp form))
2181 (and (listp form) (eq (car form) 'lambda))))
2183 (defsubst gnus-goto-char (point)
2184 (and point (goto-char point)))
2186 (defmacro gnus-buffer-exists-p (buffer)
2187 `(let ((buffer ,buffer))
2189 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2192 (defmacro gnus-kill-buffer (buffer)
2193 `(let ((buf ,buffer))
2194 (if (gnus-buffer-exists-p buf)
2195 (kill-buffer buf))))
2197 (defsubst gnus-point-at-bol ()
2198 "Return point at the beginning of the line."
2205 (defsubst gnus-point-at-eol ()
2206 "Return point at the end of the line."
2213 (defun gnus-alive-p ()
2214 "Say whether Gnus is running or not."
2215 (and gnus-group-buffer
2216 (get-buffer gnus-group-buffer)))
2218 ;; Delete the current line (and the next N lines.);
2219 (defmacro gnus-delete-line (&optional n)
2220 `(delete-region (progn (beginning-of-line) (point))
2221 (progn (forward-line ,(or n 1)) (point))))
2223 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2224 (defvar gnus-init-inhibit nil)
2225 (defun gnus-read-init-file (&optional inhibit-next)
2226 (if gnus-init-inhibit
2227 (setq gnus-init-inhibit nil)
2228 (setq gnus-init-inhibit inhibit-next)
2230 (or (and (file-exists-p gnus-init-file)
2231 ;; Don't try to load a directory.
2232 (not (file-directory-p gnus-init-file)))
2233 (file-exists-p (concat gnus-init-file ".el"))
2234 (file-exists-p (concat gnus-init-file ".elc")))
2236 (load gnus-init-file nil t)
2238 (error "Error in %s: %s" gnus-init-file var))))))
2240 ;; Info access macros.
2242 (defmacro gnus-info-group (info)
2244 (defmacro gnus-info-rank (info)
2246 (defmacro gnus-info-read (info)
2248 (defmacro gnus-info-marks (info)
2250 (defmacro gnus-info-method (info)
2252 (defmacro gnus-info-params (info)
2255 (defmacro gnus-info-level (info)
2256 `(let ((rank (gnus-info-rank ,info)))
2260 (defmacro gnus-info-score (info)
2261 `(let ((rank (gnus-info-rank ,info)))
2262 (or (and (consp rank) (cdr rank)) 0)))
2264 (defmacro gnus-info-set-group (info group)
2265 `(setcar ,info ,group))
2266 (defmacro gnus-info-set-rank (info rank)
2267 `(setcar (nthcdr 1 ,info) ,rank))
2268 (defmacro gnus-info-set-read (info read)
2269 `(setcar (nthcdr 2 ,info) ,read))
2270 (defmacro gnus-info-set-marks (info marks)
2271 `(setcar (nthcdr 3 ,info) ,marks))
2272 (defmacro gnus-info-set-method (info method)
2273 `(setcar (nthcdr 4 ,info) ,method))
2274 (defmacro gnus-info-set-params (info params)
2275 `(setcar (nthcdr 5 ,info) ,params))
2277 (defmacro gnus-info-set-level (info level)
2278 `(let ((rank (cdr ,info)))
2279 (if (consp (car rank))
2280 (setcar (car rank) ,level)
2281 (setcar rank ,level))))
2282 (defmacro gnus-info-set-score (info score)
2283 `(let ((rank (cdr ,info)))
2284 (if (consp (car rank))
2285 (setcdr (car rank) ,score)
2286 (setcar rank (cons (car rank) ,score)))))
2288 (defmacro gnus-get-info (group)
2289 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2291 (defun gnus-byte-code (func)
2292 "Return a form that can be `eval'ed based on FUNC."
2293 (let ((fval (symbol-function func)))
2294 (if (byte-code-function-p fval)
2295 (let ((flist (append fval nil)))
2296 (setcar flist 'byte-code)
2298 (cons 'progn (cddr fval)))))
2300 ;;; Load the compatability functions.
2310 (defvar gnus-shutdown-alist nil)
2312 (defun gnus-add-shutdown (function &rest symbols)
2313 "Run FUNCTION whenever one of SYMBOLS is shut down."
2314 (push (cons function symbols) gnus-shutdown-alist))
2316 (defun gnus-shutdown (symbol)
2317 "Shut down everything that waits for SYMBOL."
2318 (let ((alist gnus-shutdown-alist)
2320 (while (setq entry (pop alist))
2321 (when (memq symbol (cdr entry))
2322 (funcall (car entry))))))
2326 ;; Format specs. The chunks below are the machine-generated forms
2327 ;; that are to be evaled as the result of the default format strings.
2328 ;; We write them in here to get them byte-compiled. That way the
2329 ;; default actions will be quite fast, while still retaining the full
2330 ;; flexibility of the user-defined format specs.
2332 ;; First we have lots of dummy defvars to let the compiler know these
2333 ;; are really dynamic variables.
2335 (defvar gnus-tmp-unread)
2336 (defvar gnus-tmp-replied)
2337 (defvar gnus-tmp-score-char)
2338 (defvar gnus-tmp-indentation)
2339 (defvar gnus-tmp-opening-bracket)
2340 (defvar gnus-tmp-lines)
2341 (defvar gnus-tmp-name)
2342 (defvar gnus-tmp-closing-bracket)
2343 (defvar gnus-tmp-subject-or-nil)
2344 (defvar gnus-tmp-subject)
2345 (defvar gnus-tmp-marked)
2346 (defvar gnus-tmp-marked-mark)
2347 (defvar gnus-tmp-subscribed)
2348 (defvar gnus-tmp-process-marked)
2349 (defvar gnus-tmp-number-of-unread)
2350 (defvar gnus-tmp-group-name)
2351 (defvar gnus-tmp-group)
2352 (defvar gnus-tmp-article-number)
2353 (defvar gnus-tmp-unread-and-unselected)
2354 (defvar gnus-tmp-news-method)
2355 (defvar gnus-tmp-news-server)
2356 (defvar gnus-tmp-article-number)
2357 (defvar gnus-mouse-face)
2358 (defvar gnus-mouse-face-prop)
2360 (defun gnus-summary-line-format-spec ()
2361 (insert gnus-tmp-unread gnus-tmp-replied
2362 gnus-tmp-score-char gnus-tmp-indentation)
2363 (gnus-put-text-property
2367 gnus-tmp-opening-bracket
2368 (format "%4d: %-20s"
2370 (if (> (length gnus-tmp-name) 20)
2371 (substring gnus-tmp-name 0 20)
2373 gnus-tmp-closing-bracket)
2375 gnus-mouse-face-prop gnus-mouse-face)
2376 (insert " " gnus-tmp-subject-or-nil "\n"))
2378 (defvar gnus-summary-line-format-spec
2379 (gnus-byte-code 'gnus-summary-line-format-spec))
2381 (defun gnus-summary-dummy-line-format-spec ()
2383 (gnus-put-text-property
2388 gnus-mouse-face-prop gnus-mouse-face)
2389 (insert " " gnus-tmp-subject "\n"))
2391 (defvar gnus-summary-dummy-line-format-spec
2392 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2394 (defun gnus-group-line-format-spec ()
2395 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2396 gnus-tmp-process-marked
2397 gnus-group-indentation
2398 (format "%5s: " gnus-tmp-number-of-unread))
2399 (gnus-put-text-property
2402 (insert gnus-tmp-group "\n")
2404 gnus-mouse-face-prop gnus-mouse-face))
2405 (defvar gnus-group-line-format-spec
2406 (gnus-byte-code 'gnus-group-line-format-spec))
2408 (defvar gnus-format-specs
2409 `((version . ,emacs-version)
2410 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2411 (summary-dummy ,gnus-summary-dummy-line-format
2412 ,gnus-summary-dummy-line-format-spec)
2413 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2415 (defvar gnus-article-mode-line-format-spec nil)
2416 (defvar gnus-summary-mode-line-format-spec nil)
2417 (defvar gnus-group-mode-line-format-spec nil)
2419 ;;; Phew. All that gruft is over, fortunately.
2423 ;;; Gnus Utility Functions
2426 (defun gnus-extract-address-components (from)
2428 ;; First find the address - the thing with the @ in it. This may
2429 ;; not be accurate in mail addresses, but does the trick most of
2430 ;; the time in news messages.
2431 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2432 (setq address (substring from (match-beginning 0) (match-end 0))))
2433 ;; Then we check whether the "name <address>" format is used.
2435 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2436 ;; Linear white space is not required.
2437 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2438 (and (setq name (substring from 0 (match-beginning 0)))
2439 ;; Strip any quotes from the name.
2440 (string-match "\".*\"" name)
2441 (setq name (substring name 1 (1- (match-end 0))))))
2442 ;; If not, then "address (name)" is used.
2444 (and (string-match "(.+)" from)
2445 (setq name (substring from (1+ (match-beginning 0))
2446 (1- (match-end 0)))))
2447 (and (string-match "()" from)
2448 (setq name address))
2449 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2450 ;; XOVER might not support folded From headers.
2451 (and (string-match "(.*" from)
2452 (setq name (substring from (1+ (match-beginning 0))
2454 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2455 (list (or name from) (or address from))))
2457 (defun gnus-fetch-field (field)
2458 "Return the value of the header FIELD of current article."
2461 (let ((case-fold-search t)
2462 (inhibit-point-motion-hooks t))
2463 (nnheader-narrow-to-headers)
2464 (message-fetch-field field)))))
2466 (defun gnus-goto-colon ()
2468 (search-forward ":" (gnus-point-at-eol) t))
2471 (defun gnus-update-format (var)
2472 "Update the format specification near point."
2477 ;; Find the end of the current word.
2478 (re-search-forward "[ \t\n]" nil t)
2480 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2481 (match-string 1)))))
2482 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2483 (match-string 1 var))))
2484 (entry (assq type gnus-format-specs))
2487 (setq gnus-format-specs (delq entry gnus-format-specs)))
2489 (intern (format "%s-spec" var))
2490 (gnus-parse-format (setq value (symbol-value (intern var)))
2491 (symbol-value (intern (format "%s-alist" var)))
2492 (not (string-match "mode" var))))
2493 (setq spec (symbol-value (intern (format "%s-spec" var))))
2494 (push (list type value spec) gnus-format-specs)
2496 (pop-to-buffer "*Gnus Format*")
2498 (lisp-interaction-mode)
2499 (insert (pp-to-string spec))))
2501 (defun gnus-update-format-specifications (&optional force)
2502 "Update all (necessary) format specifications."
2503 ;; Make the indentation array.
2504 (gnus-make-thread-indent-array)
2506 ;; See whether all the stored info needs to be flushed.
2508 (not (equal emacs-version
2509 (cdr (assq 'version gnus-format-specs)))))
2510 (setq gnus-format-specs nil))
2512 ;; Go through all the formats and see whether they need updating.
2513 (let ((types '(summary summary-dummy group
2514 summary-mode group-mode article-mode))
2515 new-format entry type val)
2516 (while (setq type (pop types))
2517 ;; Jump to the proper buffer to find out the value of
2518 ;; the variable, if possible. (It may be buffer-local.)
2520 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2522 (when (and (boundp buffer)
2523 (setq val (symbol-value buffer))
2525 (buffer-name (get-buffer val)))
2526 (set-buffer (get-buffer val)))
2527 (setq new-format (symbol-value
2528 (intern (format "gnus-%s-line-format" type))))))
2529 (setq entry (cdr (assq type gnus-format-specs)))
2531 (equal (car entry) new-format))
2532 ;; Use the old format.
2533 (set (intern (format "gnus-%s-line-format-spec" type))
2535 ;; This is a new format.
2537 (if (not (stringp new-format))
2538 ;; This is a function call or something.
2540 ;; This is a "real" format.
2544 (intern (format "gnus-%s-line-format-alist"
2545 (if (eq type 'article-mode)
2546 'summary-mode type))))
2547 (not (string-match "mode$" (symbol-name type))))))
2548 ;; Enter the new format spec into the list.
2551 (setcar (cdr entry) val)
2552 (setcar entry new-format))
2553 (push (list type new-format val) gnus-format-specs))
2554 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2556 (unless (assq 'version gnus-format-specs)
2557 (push (cons 'version emacs-version) gnus-format-specs))
2559 (gnus-update-group-mark-positions)
2560 (gnus-update-summary-mark-positions))
2562 (defun gnus-update-summary-mark-positions ()
2563 "Compute where the summary marks are to go."
2565 (when (and gnus-summary-buffer
2566 (get-buffer gnus-summary-buffer)
2567 (buffer-name (get-buffer gnus-summary-buffer)))
2568 (set-buffer gnus-summary-buffer))
2569 (let ((gnus-replied-mark 129)
2570 (gnus-score-below-mark 130)
2571 (gnus-score-over-mark 130)
2574 (spec gnus-summary-line-format-spec)
2577 (gnus-set-work-buffer)
2578 (let ((gnus-summary-line-format-spec spec))
2579 (gnus-summary-insert-line
2580 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2581 (goto-char (point-min))
2582 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2584 (goto-char (point-min))
2585 (push (cons 'replied (and (search-forward "\201" nil t)
2588 (goto-char (point-min))
2589 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2591 (setq gnus-summary-mark-positions pos))))
2593 (defun gnus-update-group-mark-positions ()
2595 (let ((gnus-process-mark 128)
2596 (gnus-group-marked '("dummy.group"))
2597 (gnus-active-hashtb (make-vector 10 0)))
2598 (gnus-set-active "dummy.group" '(0 . 0))
2599 (gnus-set-work-buffer)
2600 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2601 (goto-char (point-min))
2602 (setq gnus-group-mark-positions
2603 (list (cons 'process (and (search-forward "\200" nil t)
2604 (- (point) 2))))))))
2606 (defvar gnus-mouse-face-0 'highlight)
2607 (defvar gnus-mouse-face-1 'highlight)
2608 (defvar gnus-mouse-face-2 'highlight)
2609 (defvar gnus-mouse-face-3 'highlight)
2610 (defvar gnus-mouse-face-4 'highlight)
2612 (defun gnus-mouse-face-function (form type)
2613 `(gnus-put-text-property
2614 (point) (progn ,@form (point))
2615 gnus-mouse-face-prop
2618 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2620 (defvar gnus-face-0 'bold)
2621 (defvar gnus-face-1 'italic)
2622 (defvar gnus-face-2 'bold-italic)
2623 (defvar gnus-face-3 'bold)
2624 (defvar gnus-face-4 'bold)
2626 (defun gnus-face-face-function (form type)
2627 `(gnus-put-text-property
2628 (point) (progn ,@form (point))
2629 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2631 (defun gnus-max-width-function (el max-width)
2632 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2634 `(if (> (length ,el) ,max-width)
2635 (substring ,el 0 ,max-width)
2637 `(let ((val (eval ,el)))
2639 (setq val (int-to-string val)))
2640 (if (> (length val) ,max-width)
2641 (substring val 0 ,max-width)
2644 (defun gnus-parse-format (format spec-alist &optional insert)
2645 ;; This function parses the FORMAT string with the help of the
2646 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2647 ;; string. If the FORMAT string contains the specifiers %( and %)
2648 ;; the text between them will have the mouse-face text property.
2650 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2652 (gnus-parse-complex-format format spec-alist)
2653 ;; This is a simple format.
2654 (gnus-parse-simple-format format spec-alist insert)))
2656 (defun gnus-parse-complex-format (format spec-alist)
2658 (gnus-set-work-buffer)
2660 (goto-char (point-min))
2661 (while (re-search-forward "\"" nil t)
2662 (replace-match "\\\"" nil t))
2663 (goto-char (point-min))
2665 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2666 (let ((number (if (match-beginning 1)
2667 (match-string 1) "0"))
2668 (delim (aref (match-string 2) 0)))
2669 (if (or (= delim ?\() (= delim ?\{))
2670 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2672 (replace-match "\")\""))))
2673 (goto-char (point-max))
2675 (goto-char (point-min))
2676 (let ((form (read (current-buffer))))
2677 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2679 (defun gnus-complex-form-to-spec (form spec-alist)
2684 (gnus-parse-simple-format sform spec-alist t)
2685 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2686 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2690 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2691 ;; This function parses the FORMAT string with the help of the
2692 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2695 spec flist fstring newspec elem beg result dontinsert)
2697 (gnus-set-work-buffer)
2699 (goto-char (point-min))
2700 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2702 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2704 beg (1+ (match-beginning 0)))
2705 ;; First check if there are any specs that look anything like
2706 ;; "%12,12A", ie. with a "max width specification". These have
2707 ;; to be treated specially.
2708 (if (setq beg (match-beginning 1))
2712 (1+ (match-beginning 1)) (match-end 1))))
2714 (setq beg (match-beginning 2)))
2715 ;; Find the specification from `spec-alist'.
2716 (unless (setq elem (cdr (assq spec spec-alist)))
2717 (setq elem '("*" ?s)))
2718 ;; Treat user defined format specifiers specially.
2719 (when (eq (car elem) 'gnus-tmp-user-defined)
2722 (list (intern (concat "gnus-user-format-function-"
2724 'gnus-tmp-header) ?s))
2725 (delete-region (match-beginning 3) (match-end 3)))
2726 (if (not (zerop max-width))
2727 (let ((el (car elem)))
2728 (cond ((= (cadr elem) ?c)
2729 (setq el (list 'char-to-string el)))
2731 (setq el (list 'int-to-string el))))
2732 (setq flist (cons (gnus-max-width-function el max-width)
2736 (setq flist (cons (car elem) flist))
2737 (setq newspec (cadr elem)))))
2738 ;; Remove the old specification (and possibly a ",12" string).
2739 (delete-region beg (match-end 2))
2740 ;; Insert the new specification.
2743 (setq fstring (buffer-substring 1 (point-max))))
2744 ;; Do some postprocessing to increase efficiency.
2749 ((string= fstring "")
2751 ;; Not a format string.
2752 ((not (string-match "%" fstring))
2754 ;; A format string with just a single string spec.
2755 ((string= fstring "%s")
2757 ;; A single character.
2758 ((string= fstring "%c")
2761 ((string= fstring "%d")
2764 (list `(princ ,(car flist)))
2765 (list `(int-to-string ,(car flist)))))
2766 ;; Just lots of chars and strings.
2767 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2769 ;; A single string spec at the beginning of the spec.
2770 ((string-match "\\`%[sc][^%]+\\'" fstring)
2771 (list (car flist) (substring fstring 2)))
2772 ;; A single string spec in the middle of the spec.
2773 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2774 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2775 ;; A single string spec in the end of the spec.
2776 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2777 (list (match-string 1 fstring) (car flist)))
2778 ;; A more complex spec.
2780 (list (cons 'format (cons fstring (nreverse flist)))))))
2786 (cons 'insert result)))
2787 (cond ((stringp result)
2790 (cons 'concat result))
2793 (defun gnus-eval-format (format &optional alist props)
2794 "Eval the format variable FORMAT, using ALIST.
2795 If PROPS, insert the result."
2796 (let ((form (gnus-parse-format format alist props)))
2798 (gnus-add-text-properties (point) (progn (eval form) (point)) props)
2801 (defun gnus-remove-text-with-property (prop)
2802 "Delete all text in the current buffer with text property PROP."
2804 (goto-char (point-min))
2806 (while (get-text-property (point) prop)
2808 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2810 (defun gnus-set-work-buffer ()
2811 (if (get-buffer gnus-work-buffer)
2813 (set-buffer gnus-work-buffer)
2815 (set-buffer (get-buffer-create gnus-work-buffer))
2816 (kill-all-local-variables)
2817 (buffer-disable-undo (current-buffer))
2818 (gnus-add-current-to-buffer-list)))
2820 ;; Article file names when saving.
2822 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2823 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2824 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2825 Otherwise, it is like ~/News/news/group/num."
2828 (concat (if (gnus-use-long-file-name 'not-save)
2829 (gnus-capitalize-newsgroup newsgroup)
2830 (gnus-newsgroup-directory-form newsgroup))
2831 "/" (int-to-string (mail-header-number headers)))
2832 gnus-article-save-directory)))
2834 (string-equal (file-name-directory default)
2835 (file-name-directory last-file))
2836 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2838 (or last-file default))))
2840 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2841 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2842 If variable `gnus-use-long-file-name' is non-nil, it is
2843 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2846 (concat (if (gnus-use-long-file-name 'not-save)
2848 (gnus-newsgroup-directory-form newsgroup))
2849 "/" (int-to-string (mail-header-number headers)))
2850 gnus-article-save-directory)))
2852 (string-equal (file-name-directory default)
2853 (file-name-directory last-file))
2854 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2856 (or last-file default))))
2858 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2859 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2860 If variable `gnus-use-long-file-name' is non-nil, it is
2861 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2864 (if (gnus-use-long-file-name 'not-save)
2865 (gnus-capitalize-newsgroup newsgroup)
2866 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2867 gnus-article-save-directory)))
2869 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2870 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2871 If variable `gnus-use-long-file-name' is non-nil, it is
2872 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2875 (if (gnus-use-long-file-name 'not-save)
2877 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2878 gnus-article-save-directory)))
2880 ;; For subscribing new newsgroup
2882 (defun gnus-subscribe-hierarchical-interactive (groups)
2883 (let ((groups (sort groups 'string<))
2884 prefixes prefix start ans group starts)
2886 (setq prefixes (list "^"))
2887 (while (and groups prefixes)
2888 (while (not (string-match (car prefixes) (car groups)))
2889 (setq prefixes (cdr prefixes)))
2890 (setq prefix (car prefixes))
2891 (setq start (1- (length prefix)))
2892 (if (and (string-match "[^\\.]\\." (car groups) start)
2895 (concat "^" (substring (car groups) 0 (match-end 0))))
2896 (string-match prefix (cadr groups)))
2898 (setq prefixes (cons prefix prefixes))
2899 (message "Descend hierarchy %s? ([y]nsq): "
2900 (substring prefix 1 (1- (length prefix))))
2901 (setq ans (read-char))
2904 (string-match prefix
2905 (setq group (car groups))))
2906 (setq gnus-killed-list
2907 (cons group gnus-killed-list))
2908 (gnus-sethash group group gnus-killed-hashtb)
2909 (setq groups (cdr groups)))
2910 (setq starts (cdr starts)))
2913 (string-match prefix
2914 (setq group (car groups))))
2915 (gnus-sethash group group gnus-killed-hashtb)
2916 (gnus-subscribe-alphabetically (car groups))
2917 (setq groups (cdr groups)))
2918 (setq starts (cdr starts)))
2921 (setq group (car groups))
2922 (setq gnus-killed-list (cons group gnus-killed-list))
2923 (gnus-sethash group group gnus-killed-hashtb)
2924 (setq groups (cdr groups))))
2926 (message "Subscribe %s? ([n]yq)" (car groups))
2927 (setq ans (read-char))
2928 (setq group (car groups))
2930 (gnus-subscribe-alphabetically (car groups))
2931 (gnus-sethash group group gnus-killed-hashtb))
2934 (setq group (car groups))
2935 (setq gnus-killed-list (cons group gnus-killed-list))
2936 (gnus-sethash group group gnus-killed-hashtb)
2937 (setq groups (cdr groups))))
2939 (setq gnus-killed-list (cons group gnus-killed-list))
2940 (gnus-sethash group group gnus-killed-hashtb)))
2941 (setq groups (cdr groups)))))))
2943 (defun gnus-subscribe-randomly (newsgroup)
2944 "Subscribe new NEWSGROUP by making it the first newsgroup."
2945 (gnus-subscribe-newsgroup newsgroup))
2947 (defun gnus-subscribe-alphabetically (newgroup)
2948 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2949 (let ((groups (cdr gnus-newsrc-alist))
2951 (while (and (not before) groups)
2952 (if (string< newgroup (caar groups))
2953 (setq before (caar groups))
2954 (setq groups (cdr groups))))
2955 (gnus-subscribe-newsgroup newgroup before)))
2957 (defun gnus-subscribe-hierarchically (newgroup)
2958 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2959 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2961 (set-buffer (find-file-noselect gnus-current-startup-file))
2962 (let ((groupkey newgroup)
2964 (while (and (not before) groupkey)
2965 (goto-char (point-min))
2967 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2968 (while (and (re-search-forward groupkey-re nil t)
2970 (setq before (match-string 1))
2971 (string< before newgroup)))))
2972 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2974 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2975 (substring groupkey (match-beginning 1) (match-end 1)))))
2976 (gnus-subscribe-newsgroup newgroup before))))
2978 (defun gnus-subscribe-interactively (group)
2979 "Subscribe the new GROUP interactively.
2980 It is inserted in hierarchical newsgroup order if subscribed. If not,
2982 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
2983 (gnus-subscribe-hierarchically group)
2984 (push group gnus-killed-list)))
2986 (defun gnus-subscribe-zombies (group)
2987 "Make the new GROUP into a zombie group."
2988 (push group gnus-zombie-list))
2990 (defun gnus-subscribe-killed (group)
2991 "Make the new GROUP a killed group."
2992 (push group gnus-killed-list))
2994 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2995 "Subscribe new NEWSGROUP.
2996 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2997 the first newsgroup."
2998 ;; We subscribe the group by changing its level to `subscribed'.
2999 (gnus-group-change-level
3000 newsgroup gnus-level-default-subscribed
3001 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
3002 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
3006 (defun gnus-newsgroup-directory-form (newsgroup)
3007 "Make hierarchical directory name from NEWSGROUP name."
3008 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
3009 (len (length newsgroup))
3011 ;; If this is a foreign group, we don't want to translate the
3013 (if (setq idx (string-match ":" newsgroup))
3014 (aset newsgroup idx ?/)
3016 ;; Replace all occurrences of `.' with `/'.
3018 (if (= (aref newsgroup idx) ?.)
3019 (aset newsgroup idx ?/))
3020 (setq idx (1+ idx)))
3023 (defun gnus-newsgroup-savable-name (group)
3024 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
3026 (nnheader-replace-chars-in-string group ?/ ?.))
3028 (defun gnus-make-directory (dir)
3029 "Make DIRECTORY recursively."
3030 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
3031 ;; of the many mysteries of the universe.
3032 (let* ((dir (expand-file-name dir default-directory))
3034 (if (string-match "/$" dir)
3035 (setq dir (substring dir 0 (match-beginning 0))))
3036 ;; First go down the path until we find a directory that exists.
3037 (while (not (file-exists-p dir))
3038 (setq dirs (cons dir dirs))
3039 (string-match "/[^/]+$" dir)
3040 (setq dir (substring dir 0 (match-beginning 0))))
3041 ;; Then create all the subdirs.
3042 (while (and dirs (not err))
3044 (make-directory (car dirs))
3045 (error (setq err t)))
3046 (setq dirs (cdr dirs)))
3047 ;; We return whether we were successful or not.
3050 (defun gnus-capitalize-newsgroup (newsgroup)
3051 "Capitalize NEWSGROUP name."
3052 (and (not (zerop (length newsgroup)))
3053 (concat (char-to-string (upcase (aref newsgroup 0)))
3054 (substring newsgroup 1))))
3056 ;; Various... things.
3058 (defun gnus-simplify-subject (subject &optional re-only)
3059 "Remove `Re:' and words in parentheses.
3060 If RE-ONLY is non-nil, strip leading `Re:'s only."
3061 (let ((case-fold-search t)) ;Ignore case.
3062 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3063 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3064 (setq subject (substring subject (match-end 0))))
3065 ;; Remove uninteresting prefixes.
3066 (if (and (not re-only)
3067 gnus-simplify-ignored-prefixes
3068 (string-match gnus-simplify-ignored-prefixes subject))
3069 (setq subject (substring subject (match-end 0))))
3070 ;; Remove words in parentheses from end.
3072 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3073 (setq subject (substring subject 0 (match-beginning 0)))))
3074 ;; Return subject string.
3077 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3079 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3080 (defun gnus-simplify-buffer-fuzzy ()
3081 (goto-char (point-min))
3082 (while (search-forward "\t" nil t)
3083 (replace-match " " t t))
3084 (goto-char (point-min))
3085 (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *" nil t)
3086 (goto-char (match-beginning 0))
3088 (looking-at "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
3089 (looking-at "^[[].*: .*[]]$"))
3090 (goto-char (point-min))
3091 (while (re-search-forward "^ *\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;] *"
3093 (replace-match "" t t))
3094 (goto-char (point-min))
3095 (while (re-search-forward "^[[].*: .*[]]$" nil t)
3096 (goto-char (match-end 0))
3099 (progn (goto-char (match-beginning 0)))
3100 (re-search-forward ":"))))
3101 (goto-char (point-min))
3102 (while (re-search-forward " *[[{(][^()\n]*[]})] *$" nil t)
3103 (replace-match "" t t))
3104 (goto-char (point-min))
3105 (while (re-search-forward " +" nil t)
3106 (replace-match " " t t))
3107 (goto-char (point-min))
3108 (while (re-search-forward " $" nil t)
3109 (replace-match "" t t))
3110 (goto-char (point-min))
3111 (while (re-search-forward "^ +" nil t)
3112 (replace-match "" t t))
3113 (goto-char (point-min))
3114 (when gnus-simplify-subject-fuzzy-regexp
3115 (if (listp gnus-simplify-subject-fuzzy-regexp)
3116 (let ((list gnus-simplify-subject-fuzzy-regexp))
3118 (goto-char (point-min))
3119 (while (re-search-forward (car list) nil t)
3120 (replace-match "" t t))
3121 (setq list (cdr list))))
3122 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3123 (replace-match "" t t)))))
3125 (defun gnus-simplify-subject-fuzzy (subject)
3126 "Siplify a subject string fuzzily."
3128 (gnus-set-work-buffer)
3129 (let ((case-fold-search t))
3131 (inline (gnus-simplify-buffer-fuzzy))
3134 ;; Add the current buffer to the list of buffers to be killed on exit.
3135 (defun gnus-add-current-to-buffer-list ()
3136 (or (memq (current-buffer) gnus-buffer-list)
3137 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3139 (defun gnus-string> (s1 s2)
3140 (not (or (string< s1 s2)
3143 (defun gnus-read-active-file-p ()
3144 "Say whether the active file has been read from `gnus-select-method'."
3145 (memq gnus-select-method gnus-have-read-active-file))
3147 ;;; General various misc type functions.
3149 (defun gnus-clear-system ()
3150 "Clear all variables and buffers."
3151 ;; Clear Gnus variables.
3152 (let ((variables gnus-variable-list))
3154 (set (car variables) nil)
3155 (setq variables (cdr variables))))
3156 ;; Clear other internal variables.
3157 (setq gnus-list-of-killed-groups nil
3158 gnus-have-read-active-file nil
3159 gnus-newsrc-alist nil
3160 gnus-newsrc-hashtb nil
3161 gnus-killed-list nil
3162 gnus-zombie-list nil
3163 gnus-killed-hashtb nil
3164 gnus-active-hashtb nil
3165 gnus-moderated-list nil
3166 gnus-description-hashtb nil
3167 gnus-current-headers nil
3168 gnus-thread-indent-array nil
3169 gnus-newsgroup-headers nil
3170 gnus-newsgroup-name nil
3171 gnus-server-alist nil
3172 gnus-group-list-mode nil
3173 gnus-opened-servers nil
3174 gnus-current-select-method nil)
3175 (gnus-shutdown 'gnus)
3176 ;; Kill the startup file.
3177 (and gnus-current-startup-file
3178 (get-file-buffer gnus-current-startup-file)
3179 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3180 ;; Clear the dribble buffer.
3181 (gnus-dribble-clear)
3182 ;; Kill global KILL file buffer.
3183 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3184 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3185 (gnus-kill-buffer nntp-server-buffer)
3186 ;; Kill Gnus buffers.
3187 (while gnus-buffer-list
3188 (gnus-kill-buffer (pop gnus-buffer-list)))
3189 ;; Remove Gnus frames.
3190 (while gnus-created-frames
3191 (when (frame-live-p (car gnus-created-frames))
3192 ;; We slap a condition-case around this `delete-frame' to ensure
3193 ;; agains errors if we try do delete the single frame that's left.
3195 (delete-frame (car gnus-created-frames))
3197 (pop gnus-created-frames)))
3199 (defun gnus-windows-old-to-new (setting)
3200 ;; First we take care of the really, really old Gnus 3 actions.
3201 (when (symbolp setting)
3203 ;; Take care of ooold GNUS 3.x values.
3204 (cond ((eq setting 'SelectArticle) 'article)
3205 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3206 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3208 (if (or (listp setting)
3209 (not (and gnus-window-configuration
3210 (memq setting '(group summary article)))))
3212 (let* ((setting (if (eq setting 'group)
3213 (if (assq 'newsgroup gnus-window-configuration)
3215 'newsgroups) setting))
3216 (elem (cadr (assq setting gnus-window-configuration)))
3217 (total (apply '+ elem))
3218 (types '(group summary article))
3219 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3224 (or (not (numberp (nth i elem)))
3225 (zerop (nth i elem))
3227 (setq perc (/ (float (nth 0 elem)) total))
3228 (setq out (cons (if (eq pbuf (nth i types))
3229 (vector (nth i types) perc 'point)
3230 (vector (nth i types) perc))
3233 (list (nreverse out)))))
3236 (defun gnus-add-configuration (conf)
3237 "Add the window configuration CONF to `gnus-buffer-configuration'."
3238 (setq gnus-buffer-configuration
3239 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3240 gnus-buffer-configuration))))
3242 (defvar gnus-frame-list nil)
3244 (defun gnus-configure-frame (split &optional window)
3245 "Split WINDOW according to SPLIT."
3247 (setq window (get-buffer-window (current-buffer))))
3248 (select-window window)
3249 ;; This might be an old-stylee buffer config.
3250 (when (vectorp split)
3251 (setq split (append split nil)))
3252 (when (or (consp (car split))
3253 (vectorp (car split)))
3255 (push 'vertical split))
3256 ;; The SPLIT might be something that is to be evaled to
3257 ;; return a new SPLIT.
3258 (while (and (not (assq (car split) gnus-window-to-buffer))
3259 (gnus-functionp (car split)))
3260 (setq split (eval split)))
3261 (let* ((type (car split))
3263 (len (if (eq type 'horizontal) (window-width) (window-height)))
3265 (window-min-width (or gnus-window-min-width window-min-width))
3266 (window-min-height (or gnus-window-min-height window-min-height))
3267 s result new-win rest comp-subs size sub)
3269 ;; Nothing to do here.
3271 ;; Don't switch buffers.
3273 (and (memq 'point split) window))
3274 ;; This is a buffer to be selected.
3275 ((not (memq type '(frame horizontal vertical)))
3276 (let ((buffer (cond ((stringp type) type)
3277 (t (cdr (assq type gnus-window-to-buffer)))))
3280 (error "Illegal buffer type: %s" type))
3281 (unless (setq buf (get-buffer (if (symbolp buffer)
3282 (symbol-value buffer) buffer)))
3283 (setq buf (get-buffer-create (if (symbolp buffer)
3284 (symbol-value buffer) buffer))))
3285 (switch-to-buffer buf)
3286 ;; We return the window if it has the `point' spec.
3287 (and (memq 'point split) window)))
3288 ;; This is a frame split.
3290 (unless gnus-frame-list
3291 (setq gnus-frame-list (list (window-frame
3292 (get-buffer-window (current-buffer))))))
3294 params frame fresult)
3295 (while (< i (length subs))
3296 ;; Frame parameter is gotten from the sub-split.
3297 (setq params (cadr (elt subs i)))
3298 ;; It should be a list.
3299 (unless (listp params)
3301 ;; Create a new frame?
3302 (unless (setq frame (elt gnus-frame-list i))
3303 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3304 (push frame gnus-created-frames))
3305 ;; Is the old frame still alive?
3306 (unless (frame-live-p frame)
3307 (setcar (nthcdr i gnus-frame-list)
3308 (setq frame (make-frame params))))
3309 ;; Select the frame in question and do more splits there.
3310 (select-frame frame)
3311 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3313 ;; Select the frame that has the selected buffer.
3315 (select-frame (window-frame fresult)))))
3316 ;; This is a normal split.
3318 (when (> (length subs) 0)
3319 ;; First we have to compute the sizes of all new windows.
3321 (setq sub (append (pop subs) nil))
3322 (while (and (not (assq (car sub) gnus-window-to-buffer))
3323 (gnus-functionp (car sub)))
3324 (setq sub (eval sub)))
3326 (push sub comp-subs)
3327 (setq size (cadar comp-subs))
3328 (cond ((equal size 1.0)
3329 (setq rest (car comp-subs))
3332 (setq s (floor (* size len))))
3336 (error "Illegal size: %s" size)))
3337 ;; Try to make sure that we are inside the safe limits.
3339 ((eq type 'horizontal)
3340 (setq s (max s window-min-width)))
3341 ((eq type 'vertical)
3342 (setq s (max s window-min-height))))
3343 (setcar (cdar comp-subs) s)
3345 ;; Take care of the "1.0" spec.
3347 (setcar (cdr rest) (- len total))
3348 (error "No 1.0 specs in %s" split))
3349 ;; The we do the actual splitting in a nice recursive
3351 (setq comp-subs (nreverse comp-subs))
3353 (if (null (cdr comp-subs))
3354 (setq new-win window)
3356 (split-window window (cadar comp-subs)
3357 (eq type 'horizontal))))
3358 (setq result (or (gnus-configure-frame
3359 (car comp-subs) window) result))
3360 (select-window new-win)
3361 (setq window new-win)
3362 (setq comp-subs (cdr comp-subs))))
3363 ;; Return the proper window, if any.
3365 (select-window result))))))
3367 (defvar gnus-frame-split-p nil)
3369 (defun gnus-configure-windows (setting &optional force)
3370 (setq setting (gnus-windows-old-to-new setting))
3371 (let ((split (if (symbolp setting)
3372 (cadr (assq setting gnus-buffer-configuration))
3376 (setq gnus-frame-split-p nil)
3379 (error "No such setting: %s" setting))
3381 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3383 ;; All the windows mentioned are already visible, so we just
3384 ;; put point in the assigned buffer, and do not touch the
3386 (select-window all-visible)
3388 ;; Either remove all windows or just remove all Gnus windows.
3389 (let ((frame (selected-frame)))
3391 (if gnus-use-full-window
3392 ;; We want to remove all other windows.
3393 (if (not gnus-frame-split-p)
3394 ;; This is not a `frame' split, so we ignore the
3396 (delete-other-windows)
3397 ;; This is a `frame' split, so we delete all windows
3401 (unless (eq (cdr (assq 'minibuffer
3402 (frame-parameters frame)))
3404 (select-frame frame)
3405 (delete-other-windows)))
3407 ;; Just remove some windows.
3408 (gnus-remove-some-windows)
3409 (switch-to-buffer nntp-server-buffer))
3410 (select-frame frame)))
3412 (switch-to-buffer nntp-server-buffer)
3413 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3415 (defun gnus-all-windows-visible-p (split)
3416 "Say whether all buffers in SPLIT are currently visible.
3417 In particular, the value returned will be the window that
3419 (let ((stack (list split))
3421 type buffer win buf)
3422 (while (and (setq split (pop stack))
3424 ;; Be backwards compatible.
3425 (when (vectorp split)
3426 (setq split (append split nil)))
3427 (when (or (consp (car split))
3428 (vectorp (car split)))
3430 (push 'vertical split))
3431 ;; The SPLIT might be something that is to be evaled to
3432 ;; return a new SPLIT.
3433 (while (and (not (assq (car split) gnus-window-to-buffer))
3434 (gnus-functionp (car split)))
3435 (setq split (eval split)))
3437 (setq type (elt split 0))
3442 ((not (memq type '(horizontal vertical frame)))
3443 (setq buffer (cond ((stringp type) type)
3444 (t (cdr (assq type gnus-window-to-buffer)))))
3446 (error "Illegal buffer type: %s" type))
3447 (when (setq buf (get-buffer (if (symbolp buffer)
3448 (symbol-value buffer)
3450 (setq win (get-buffer-window buf t)))
3452 (when (memq 'point split)
3453 (setq all-visible win))
3454 (setq all-visible nil)))
3456 (when (eq type 'frame)
3457 (setq gnus-frame-split-p t))
3458 (setq stack (append (cddr split) stack)))))
3459 (unless (eq all-visible t)
3462 (defun gnus-window-top-edge (&optional window)
3463 (nth 1 (window-edges window)))
3465 (defun gnus-remove-some-windows ()
3466 (let ((buffers gnus-window-to-buffer)
3467 buf bufs lowest-buf lowest)
3469 ;; Remove windows on all known Gnus buffers.
3471 (setq buf (cdar buffers))
3473 (setq buf (and (boundp buf) (symbol-value buf))))
3475 (get-buffer-window buf)
3477 (setq bufs (cons buf bufs))
3479 (if (or (not lowest)
3480 (< (gnus-window-top-edge) lowest))
3482 (setq lowest (gnus-window-top-edge))
3483 (setq lowest-buf buf)))))
3484 (setq buffers (cdr buffers)))
3485 ;; Remove windows on *all* summary buffers.
3488 (let ((buf (window-buffer win)))
3489 (if (string-match "^\\*Summary" (buffer-name buf))
3491 (setq bufs (cons buf bufs))
3493 (if (or (not lowest)
3494 (< (gnus-window-top-edge) lowest))
3496 (setq lowest-buf buf)
3497 (setq lowest (gnus-window-top-edge)))))))))
3500 (pop-to-buffer lowest-buf)
3501 (switch-to-buffer nntp-server-buffer)))
3503 (and (not (eq (car bufs) lowest-buf))
3504 (delete-windows-on (car bufs)))
3505 (setq bufs (cdr bufs))))))
3507 (defun gnus-version ()
3508 "Version numbers of this version of Gnus."
3510 (let ((methods gnus-valid-select-methods)
3513 ;; Go through all the legal select methods and add their version
3514 ;; numbers to the total version string. Only the backends that are
3515 ;; currently in use will have their message numbers taken into
3518 (setq meth (intern (concat (caar methods) "-version")))
3520 (stringp (symbol-value meth))
3521 (setq mess (concat mess "; " (symbol-value meth))))
3522 (setq methods (cdr methods)))
3523 (gnus-message 2 mess)))
3525 (defun gnus-info-find-node ()
3526 "Find Info documentation of Gnus."
3528 ;; Enlarge info window if needed.
3529 (let ((mode major-mode)
3531 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3532 (setq gnus-info-buffer (current-buffer))
3533 (gnus-configure-windows 'info)))
3535 (defun gnus-days-between (date1 date2)
3536 ;; Return the number of days between date1 and date2.
3537 (- (gnus-day-number date1) (gnus-day-number date2)))
3539 (defun gnus-day-number (date)
3540 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3541 (timezone-parse-date date))))
3542 (timezone-absolute-from-gregorian
3543 (nth 1 dat) (nth 2 dat) (car dat))))
3545 (defun gnus-encode-date (date)
3546 "Convert DATE to internal time."
3547 (let* ((parse (timezone-parse-date date))
3548 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3549 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3550 (encode-time (caddr time) (cadr time) (car time)
3551 (caddr date) (cadr date) (car date) (nth 4 date))))
3553 (defun gnus-time-minus (t1 t2)
3554 "Subtract two internal times."
3555 (let ((borrow (< (cadr t1) (cadr t2))))
3556 (list (- (car t1) (car t2) (if borrow 1 0))
3557 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3559 (defun gnus-file-newer-than (file date)
3560 (let ((fdate (nth 5 (file-attributes file))))
3561 (or (> (car fdate) (car date))
3562 (and (= (car fdate) (car date))
3563 (> (nth 1 fdate) (nth 1 date))))))
3565 (defmacro gnus-local-set-keys (&rest plist)
3566 "Set the keys in PLIST in the current keymap."
3567 `(gnus-define-keys-1 (current-local-map) ',plist))
3569 (defmacro gnus-define-keys (keymap &rest plist)
3570 "Define all keys in PLIST in KEYMAP."
3571 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3573 (put 'gnus-define-keys 'lisp-indent-function 1)
3574 (put 'gnus-define-keys 'lisp-indent-hook 1)
3575 (put 'gnus-define-keymap 'lisp-indent-function 1)
3576 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3578 (defmacro gnus-define-keymap (keymap &rest plist)
3579 "Define all keys in PLIST in KEYMAP."
3580 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3582 (defun gnus-define-keys-1 (keymap plist)
3584 (error "Can't set keys in a null keymap"))
3585 (cond ((symbolp keymap)
3586 (setq keymap (symbol-value keymap)))
3589 (set (car keymap) nil)
3590 (define-prefix-command (car keymap))
3591 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3592 (setq keymap (symbol-value (car keymap)))))
3595 (when (symbolp (setq key (pop plist)))
3596 (setq key (symbol-value key)))
3597 (define-key keymap key (pop plist)))))
3599 (defun gnus-group-read-only-p (&optional group)
3600 "Check whether GROUP supports editing or not.
3601 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3602 that that variable is buffer-local to the summary buffers."
3603 (let ((group (or group gnus-newsgroup-name)))
3604 (not (gnus-check-backend-function 'request-replace-article group))))
3606 (defun gnus-group-total-expirable-p (group)
3607 "Check whether GROUP is total-expirable or not."
3608 (let ((params (gnus-info-params (gnus-get-info group))))
3609 (or (memq 'total-expire params)
3610 (cdr (assq 'total-expire params)) ; (total-expire . t)
3611 (and gnus-total-expirable-newsgroups ; Check var.
3612 (string-match gnus-total-expirable-newsgroups group)))))
3614 (defun gnus-group-auto-expirable-p (group)
3615 "Check whether GROUP is total-expirable or not."
3616 (let ((params (gnus-info-params (gnus-get-info group))))
3617 (or (memq 'auto-expire params)
3618 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3619 (and gnus-auto-expirable-newsgroups ; Check var.
3620 (string-match gnus-auto-expirable-newsgroups group)))))
3622 (defun gnus-virtual-group-p (group)
3623 "Say whether GROUP is virtual or not."
3624 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3625 gnus-valid-select-methods)))
3627 (defun gnus-news-group-p (group &optional article)
3628 "Return non-nil if GROUP (and ARTICLE) come from a news server."
3629 (or (gnus-member-of-valid 'post group) ; Ordinary news group.
3630 (and (gnus-member-of-valid 'post-mail group) ; Combined group.
3631 (eq (gnus-request-type group article) 'news))))
3633 (defsubst gnus-simplify-subject-fully (subject)
3634 "Simplify a subject string according to the user's wishes."
3636 ((null gnus-summary-gather-subject-limit)
3637 (gnus-simplify-subject-re subject))
3638 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3639 (gnus-simplify-subject-fuzzy subject))
3640 ((numberp gnus-summary-gather-subject-limit)
3641 (gnus-limit-string (gnus-simplify-subject-re subject)
3642 gnus-summary-gather-subject-limit))
3646 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3647 "Check whether two subjects are equal. If optional argument
3648 simple-first is t, first argument is already simplified."
3650 ((null simple-first)
3651 (equal (gnus-simplify-subject-fully s1)
3652 (gnus-simplify-subject-fully s2)))
3655 (gnus-simplify-subject-fully s2)))))
3657 ;; Returns a list of writable groups.
3658 (defun gnus-writable-groups ()
3659 (let ((alist gnus-newsrc-alist)
3661 (while (setq group (car (pop alist)))
3662 (unless (gnus-group-read-only-p group)
3663 (push group groups)))
3666 (defun gnus-completing-read (default prompt &rest args)
3667 ;; Like `completing-read', except that DEFAULT is the default argument.
3668 (let* ((prompt (if default
3669 (concat prompt " (default " default ") ")
3670 (concat prompt " ")))
3671 (answer (apply 'completing-read prompt args)))
3672 (if (or (null answer) (zerop (length answer)))
3676 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3678 (defun gnus-y-or-n-p (prompt)
3683 (defun gnus-yes-or-no-p (prompt)
3685 (yes-or-no-p prompt)
3688 ;; Check whether to use long file names.
3689 (defun gnus-use-long-file-name (symbol)
3690 ;; The variable has to be set...
3691 (and gnus-use-long-file-name
3692 ;; If it isn't a list, then we return t.
3693 (or (not (listp gnus-use-long-file-name))
3694 ;; If it is a list, and the list contains `symbol', we
3696 (not (memq symbol gnus-use-long-file-name)))))
3698 ;; I suspect there's a better way, but I haven't taken the time to do
3699 ;; it yet. -erik selberg@cs.washington.edu
3700 (defun gnus-dd-mmm (messy-date)
3701 "Return a string like DD-MMM from a big messy string"
3702 (let ((datevec (condition-case () (timezone-parse-date messy-date)
3708 ;; Make sure leading zeroes are stripped.
3709 (number-to-string (string-to-number (aref datevec 2)))
3713 (nth (1- (string-to-number (aref datevec 1)))
3714 timezone-months-assoc))
3717 (defun gnus-mode-string-quote (string)
3718 "Quote all \"%\" in STRING."
3720 (gnus-set-work-buffer)
3722 (goto-char (point-min))
3723 (while (search-forward "%" nil t)
3727 ;; Make a hash table (default and minimum size is 255).
3728 ;; Optional argument HASHSIZE specifies the table size.
3729 (defun gnus-make-hashtable (&optional hashsize)
3730 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3732 ;; Make a number that is suitable for hashing; bigger than MIN and one
3734 (defun gnus-create-hash-size (min)
3740 ;; Show message if message has a lower level than `gnus-verbose'.
3741 ;; Guideline for numbers:
3742 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3743 ;; for things that take a long time, 7 - not very important messages
3744 ;; on stuff, 9 - messages inside loops.
3745 (defun gnus-message (level &rest args)
3746 (if (<= level gnus-verbose)
3747 (apply 'message args)
3748 ;; We have to do this format thingy here even if the result isn't
3749 ;; shown - the return value has to be the same as the return value
3751 (apply 'format args)))
3753 (defun gnus-error (level &rest args)
3754 "Beep an error if `gnus-verbose' is on LEVEL or less."
3755 (when (<= (floor level) gnus-verbose)
3756 (apply 'message args)
3759 (when (and (floatp level)
3760 (not (zerop (setq duration (* 10 (- level (floor level)))))))
3761 (sit-for duration))))
3764 ;; Generate a unique new group name.
3765 (defun gnus-generate-new-group-name (leaf)
3768 (while (gnus-gethash name gnus-newsrc-hashtb)
3769 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3772 (defsubst gnus-hide-text (b e props)
3773 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
3774 (gnus-add-text-properties b e props)
3775 (when (memq 'intangible props)
3776 (gnus-put-text-property (max (1- b) (point-min))
3777 b 'intangible (cddr (memq 'intangible props)))))
3779 (defsubst gnus-unhide-text (b e)
3780 "Remove hidden text properties from region between B and E."
3781 (remove-text-properties b e gnus-hidden-properties)
3782 (when (memq 'intangible gnus-hidden-properties)
3783 (gnus-put-text-property (max (1- b) (point-min))
3784 b 'intangible nil)))
3786 (defun gnus-hide-text-type (b e type)
3787 "Hide text of TYPE between B and E."
3788 (gnus-hide-text b e (cons 'gnus-type (cons type gnus-hidden-properties))))
3790 ;; Find out whether the gnus-visual TYPE is wanted.
3791 (defun gnus-visual-p (&optional type class)
3792 (and gnus-visual ; Has to be non-nil, at least.
3793 (if (not type) ; We don't care about type.
3795 (if (listp gnus-visual) ; It's a list, so we check it.
3796 (or (memq type gnus-visual)
3797 (memq class gnus-visual))
3800 (defun gnus-parent-headers (headers &optional generation)
3801 "Return the headers of the GENERATIONeth parent of HEADERS."
3803 (setq generation 1))
3804 (let (references parent)
3805 (while (and headers (not (zerop generation)))
3806 (setq references (mail-header-references headers))
3807 (when (and references
3808 (setq parent (gnus-parent-id references))
3809 (setq headers (car (gnus-id-to-thread parent))))
3813 (defun gnus-parent-id (references)
3814 "Return the last Message-ID in REFERENCES."
3815 (when (and references
3816 (string-match "\\(<[^\n<>]+>\\)[ \t\n]*\\'" references))
3817 (substring references (match-beginning 1) (match-end 1))))
3819 (defun gnus-split-references (references)
3820 "Return a list of Message-IDs in REFERENCES."
3823 (while (string-match "<[^>]+>" references beg)
3824 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3828 (defun gnus-buffer-live-p (buffer)
3829 "Say whether BUFFER is alive or not."
3832 (buffer-name (get-buffer buffer))))
3834 (defun gnus-ephemeral-group-p (group)
3835 "Say whether GROUP is ephemeral or not."
3836 (gnus-group-get-parameter group 'quit-config))
3838 (defun gnus-group-quit-config (group)
3839 "Return the quit-config of GROUP."
3840 (gnus-group-get-parameter group 'quit-config))
3842 (defun gnus-simplify-mode-line ()
3843 "Make mode lines a bit simpler."
3844 (setq mode-line-modified "-- ")
3845 (when (listp mode-line-format)
3846 (make-local-variable 'mode-line-format)
3847 (setq mode-line-format (copy-sequence mode-line-format))
3848 (when (equal (nth 3 mode-line-format) " ")
3849 (setcar (nthcdr 3 mode-line-format) " "))))
3851 ;;; List and range functions
3853 (defun gnus-last-element (list)
3854 "Return last element of LIST."
3856 (setq list (cdr list)))
3859 (defun gnus-copy-sequence (list)
3860 "Do a complete, total copy of a list."
3861 (if (and (consp list) (not (consp (cdr list))))
3862 (cons (car list) (cdr list))
3863 (mapcar (lambda (elem) (if (consp elem)
3864 (if (consp (cdr elem))
3865 (gnus-copy-sequence elem)
3866 (cons (car elem) (cdr elem)))
3870 (defun gnus-set-difference (list1 list2)
3871 "Return a list of elements of LIST1 that do not appear in LIST2."
3872 (let ((list1 (copy-sequence list1)))
3874 (setq list1 (delq (car list2) list1))
3875 (setq list2 (cdr list2)))
3878 (defun gnus-sorted-complement (list1 list2)
3879 "Return a list of elements of LIST1 that do not appear in LIST2.
3880 Both lists have to be sorted over <."
3882 (if (or (null list1) (null list2))
3884 (while (and list1 list2)
3885 (cond ((= (car list1) (car list2))
3886 (setq list1 (cdr list1)
3888 ((< (car list1) (car list2))
3889 (setq out (cons (car list1) out))
3890 (setq list1 (cdr list1)))
3892 (setq out (cons (car list2) out))
3893 (setq list2 (cdr list2)))))
3894 (nconc (nreverse out) (or list1 list2)))))
3896 (defun gnus-intersection (list1 list2)
3899 (if (memq (car list2) list1)
3900 (setq result (cons (car list2) result)))
3901 (setq list2 (cdr list2)))
3904 (defun gnus-sorted-intersection (list1 list2)
3905 ;; LIST1 and LIST2 have to be sorted over <.
3907 (while (and list1 list2)
3908 (cond ((= (car list1) (car list2))
3909 (setq out (cons (car list1) out)
3912 ((< (car list1) (car list2))
3913 (setq list1 (cdr list1)))
3915 (setq list2 (cdr list2)))))
3918 (defun gnus-set-sorted-intersection (list1 list2)
3919 ;; LIST1 and LIST2 have to be sorted over <.
3920 ;; This function modifies LIST1.
3921 (let* ((top (cons nil list1))
3923 (while (and list1 list2)
3924 (cond ((= (car list1) (car list2))
3928 ((< (car list1) (car list2))
3929 (setcdr prev (cdr list1))
3930 (setq list1 (cdr list1)))
3932 (setq list2 (cdr list2)))))
3936 (defun gnus-compress-sequence (numbers &optional always-list)
3937 "Convert list of numbers to a list of ranges or a single range.
3938 If ALWAYS-LIST is non-nil, this function will always release a list of
3940 (let* ((first (car numbers))
3941 (last (car numbers))
3945 (if (not (listp (cdr numbers)))
3948 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3949 ((= (1+ last) (car numbers)) ;Still in sequence
3950 (setq last (car numbers)))
3951 (t ;End of one sequence
3953 (cons (if (= first last) first
3954 (cons first last)) result))
3955 (setq first (car numbers))
3956 (setq last (car numbers))))
3957 (setq numbers (cdr numbers)))
3958 (if (and (not always-list) (null result))
3959 (if (= first last) (list first) (cons first last))
3960 (nreverse (cons (if (= first last) first (cons first last))
3963 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3964 (defun gnus-uncompress-range (ranges)
3965 "Expand a list of ranges into a list of numbers.
3966 RANGES is either a single range on the form `(num . num)' or a list of
3968 (let (first last result)
3972 ((not (listp (cdr ranges)))
3973 (setq first (car ranges))
3974 (setq last (cdr ranges))
3975 (while (<= first last)
3976 (setq result (cons first result))
3977 (setq first (1+ first)))
3981 (if (atom (car ranges))
3982 (if (numberp (car ranges))
3983 (setq result (cons (car ranges) result)))
3984 (setq first (caar ranges))
3985 (setq last (cdar ranges))
3986 (while (<= first last)
3987 (setq result (cons first result))
3988 (setq first (1+ first))))
3989 (setq ranges (cdr ranges)))
3990 (nreverse result)))))
3992 (defun gnus-add-to-range (ranges list)
3993 "Return a list of ranges that has all articles from both RANGES and LIST.
3994 Note: LIST has to be sorted over `<'."
3996 (gnus-compress-sequence list t)
3997 (setq list (copy-sequence list))
3998 (or (listp (cdr ranges))
3999 (setq ranges (list ranges)))
4001 ilist lowest highest temp)
4002 (while (and ranges list)
4004 (setq lowest (or (and (atom (car ranges)) (car ranges))
4006 (while (and list (cdr list) (< (cadr list) lowest))
4007 (setq list (cdr list)))
4008 (if (< (car ilist) lowest)
4011 (setq list (cdr list))
4013 (setq out (nconc (gnus-compress-sequence ilist t) out))))
4014 (setq highest (or (and (atom (car ranges)) (car ranges))
4016 (while (and list (<= (car list) highest))
4017 (setq list (cdr list)))
4018 (setq ranges (cdr ranges)))
4020 (setq out (nconc (gnus-compress-sequence list t) out)))
4021 (setq out (sort out (lambda (r1 r2)
4022 (< (or (and (atom r1) r1) (car r1))
4023 (or (and (atom r2) r2) (car r2))))))
4026 (if (atom (car ranges))
4028 (if (atom (cadr ranges))
4029 (if (= (1+ (car ranges)) (cadr ranges))
4031 (setcar ranges (cons (car ranges)
4033 (setcdr ranges (cddr ranges))))
4034 (if (= (1+ (car ranges)) (caadr ranges))
4036 (setcar (cadr ranges) (car ranges))
4037 (setcar ranges (cadr ranges))
4038 (setcdr ranges (cddr ranges))))))
4040 (if (atom (cadr ranges))
4041 (if (= (1+ (cdar ranges)) (cadr ranges))
4043 (setcdr (car ranges) (cadr ranges))
4044 (setcdr ranges (cddr ranges))))
4045 (if (= (1+ (cdar ranges)) (caadr ranges))
4047 (setcdr (car ranges) (cdadr ranges))
4048 (setcdr ranges (cddr ranges)))))))
4049 (setq ranges (cdr ranges)))
4052 (defun gnus-remove-from-range (ranges list)
4053 "Return a list of ranges that has all articles from LIST removed from RANGES.
4054 Note: LIST has to be sorted over `<'."
4055 ;; !!! This function shouldn't look like this, but I've got a headache.
4056 (gnus-compress-sequence
4057 (gnus-sorted-complement
4058 (gnus-uncompress-range ranges) list)))
4060 (defun gnus-member-of-range (number ranges)
4061 (if (not (listp (cdr ranges)))
4062 (and (>= number (car ranges))
4063 (<= number (cdr ranges)))
4066 (if (numberp (car ranges))
4067 (>= number (car ranges))
4068 (>= number (caar ranges)))
4070 (if (if (numberp (car ranges))
4071 (= number (car ranges))
4072 (and (>= number (caar ranges))
4073 (<= number (cdar ranges))))
4074 (setq not-stop nil))
4075 (setq ranges (cdr ranges)))
4078 (defun gnus-range-length (range)
4079 "Return the length RANGE would have if uncompressed."
4080 (length (gnus-uncompress-range range)))
4082 (defun gnus-sublist-p (list sublist)
4083 "Test whether all elements in SUBLIST are members of LIST."
4086 (unless (memq (pop sublist) list)
4096 (defvar gnus-group-mode-map nil)
4097 (put 'gnus-group-mode 'mode-class 'special)
4099 (unless gnus-group-mode-map
4100 (setq gnus-group-mode-map (make-keymap))
4101 (suppress-keymap gnus-group-mode-map)
4103 (gnus-define-keys gnus-group-mode-map
4104 " " gnus-group-read-group
4105 "=" gnus-group-select-group
4106 "\r" gnus-group-select-group
4107 "\M-\r" gnus-group-quick-select-group
4108 "j" gnus-group-jump-to-group
4109 "n" gnus-group-next-unread-group
4110 "p" gnus-group-prev-unread-group
4111 "\177" gnus-group-prev-unread-group
4112 [delete] gnus-group-prev-unread-group
4113 "N" gnus-group-next-group
4114 "P" gnus-group-prev-group
4115 "\M-n" gnus-group-next-unread-group-same-level
4116 "\M-p" gnus-group-prev-unread-group-same-level
4117 "," gnus-group-best-unread-group
4118 "." gnus-group-first-unread-group
4119 "u" gnus-group-unsubscribe-current-group
4120 "U" gnus-group-unsubscribe-group
4121 "c" gnus-group-catchup-current
4122 "C" gnus-group-catchup-current-all
4123 "l" gnus-group-list-groups
4124 "L" gnus-group-list-all-groups
4126 "g" gnus-group-get-new-news
4127 "\M-g" gnus-group-get-new-news-this-group
4128 "R" gnus-group-restart
4129 "r" gnus-group-read-init-file
4130 "B" gnus-group-browse-foreign-server
4131 "b" gnus-group-check-bogus-groups
4132 "F" gnus-find-new-newsgroups
4133 "\C-c\C-d" gnus-group-describe-group
4134 "\M-d" gnus-group-describe-all-groups
4135 "\C-c\C-a" gnus-group-apropos
4136 "\C-c\M-\C-a" gnus-group-description-apropos
4137 "a" gnus-group-post-news
4138 "\ek" gnus-group-edit-local-kill
4139 "\eK" gnus-group-edit-global-kill
4140 "\C-k" gnus-group-kill-group
4141 "\C-y" gnus-group-yank-group
4142 "\C-w" gnus-group-kill-region
4143 "\C-x\C-t" gnus-group-transpose-groups
4144 "\C-c\C-l" gnus-group-list-killed
4145 "\C-c\C-x" gnus-group-expire-articles
4146 "\C-c\M-\C-x" gnus-group-expire-all-groups
4148 "s" gnus-group-save-newsrc
4149 "z" gnus-group-suspend
4150 "Z" gnus-group-clear-dribble
4153 "?" gnus-group-describe-briefly
4154 "\C-c\C-i" gnus-info-find-node
4155 "\M-e" gnus-group-edit-group-method
4156 "^" gnus-group-enter-server-mode
4157 gnus-mouse-2 gnus-mouse-pick-group
4158 "<" beginning-of-buffer
4161 "\C-c\C-s" gnus-group-sort-groups
4163 "\C-c\M-g" gnus-activate-all-groups
4164 "\M-&" gnus-group-universal-argument
4165 "#" gnus-group-mark-group
4166 "\M-#" gnus-group-unmark-group)
4168 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4169 "m" gnus-group-mark-group
4170 "u" gnus-group-unmark-group
4171 "w" gnus-group-mark-region
4172 "m" gnus-group-mark-buffer
4173 "r" gnus-group-mark-regexp
4174 "U" gnus-group-unmark-all-groups)
4176 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4177 "d" gnus-group-make-directory-group
4178 "h" gnus-group-make-help-group
4179 "a" gnus-group-make-archive-group
4180 "k" gnus-group-make-kiboze-group
4181 "m" gnus-group-make-group
4182 "E" gnus-group-edit-group
4183 "e" gnus-group-edit-group-method
4184 "p" gnus-group-edit-group-parameters
4185 "v" gnus-group-add-to-virtual
4186 "V" gnus-group-make-empty-virtual
4187 "D" gnus-group-enter-directory
4188 "f" gnus-group-make-doc-group
4189 "r" gnus-group-rename-group
4190 "\177" gnus-group-delete-group
4191 [delete] gnus-group-delete-group)
4193 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4194 "b" gnus-group-brew-soup
4195 "w" gnus-soup-save-areas
4196 "s" gnus-soup-send-replies
4197 "p" gnus-soup-pack-packet
4198 "r" nnsoup-pack-replies)
4200 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4201 "s" gnus-group-sort-groups
4202 "a" gnus-group-sort-groups-by-alphabet
4203 "u" gnus-group-sort-groups-by-unread
4204 "l" gnus-group-sort-groups-by-level
4205 "v" gnus-group-sort-groups-by-score
4206 "r" gnus-group-sort-groups-by-rank
4207 "m" gnus-group-sort-groups-by-method)
4209 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4210 "k" gnus-group-list-killed
4211 "z" gnus-group-list-zombies
4212 "s" gnus-group-list-groups
4213 "u" gnus-group-list-all-groups
4214 "A" gnus-group-list-active
4215 "a" gnus-group-apropos
4216 "d" gnus-group-description-apropos
4217 "m" gnus-group-list-matching
4218 "M" gnus-group-list-all-matching
4219 "l" gnus-group-list-level)
4221 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4222 "f" gnus-score-flush-cache)
4224 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4225 "f" gnus-group-fetch-faq)
4227 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4228 "l" gnus-group-set-current-level
4229 "t" gnus-group-unsubscribe-current-group
4230 "s" gnus-group-unsubscribe-group
4231 "k" gnus-group-kill-group
4232 "y" gnus-group-yank-group
4233 "w" gnus-group-kill-region
4234 "\C-k" gnus-group-kill-level
4235 "z" gnus-group-kill-all-zombies))
4237 (defun gnus-group-mode ()
4238 "Major mode for reading news.
4240 All normal editing commands are switched off.
4241 \\<gnus-group-mode-map>
4242 The group buffer lists (some of) the groups available. For instance,
4243 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4244 lists all zombie groups.
4246 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4247 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4249 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4251 The following commands are available:
4253 \\{gnus-group-mode-map}"
4255 (when (and menu-bar-mode
4256 (gnus-visual-p 'group-menu 'menu))
4257 (gnus-group-make-menu-bar))
4258 (kill-all-local-variables)
4259 (gnus-simplify-mode-line)
4260 (setq major-mode 'gnus-group-mode)
4261 (setq mode-name "Group")
4262 (gnus-group-set-mode-line)
4263 (setq mode-line-process nil)
4264 (use-local-map gnus-group-mode-map)
4265 (buffer-disable-undo (current-buffer))
4266 (setq truncate-lines t)
4267 (setq buffer-read-only t)
4268 (gnus-make-local-hook 'post-command-hook)
4269 (add-hook 'post-command-hook 'gnus-clear-inboxes-moved)
4270 (run-hooks 'gnus-group-mode-hook))
4272 (defun gnus-clear-inboxes-moved ()
4273 (setq nnmail-moved-inboxes nil))
4275 (defun gnus-mouse-pick-group (e)
4276 "Enter the group under the mouse pointer."
4279 (gnus-group-read-group nil))
4281 ;; Look at LEVEL and find out what the level is really supposed to be.
4282 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4283 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4284 (defun gnus-group-default-level (&optional level number-or-nil)
4286 (gnus-group-use-permanent-levels
4287 (or (setq gnus-group-use-permanent-levels
4288 (or level (if (numberp gnus-group-use-permanent-levels)
4289 gnus-group-use-permanent-levels
4290 (or gnus-group-default-list-level
4291 gnus-level-subscribed))))
4292 gnus-group-default-list-level gnus-level-subscribed))
4296 (or level gnus-group-default-list-level gnus-level-subscribed))))
4299 (defun gnus-slave-no-server (&optional arg)
4300 "Read network news as a slave, without connecting to local server"
4302 (gnus-no-server arg t))
4305 (defun gnus-no-server (&optional arg slave)
4307 If ARG is a positive number, Gnus will use that as the
4308 startup level. If ARG is nil, Gnus will be started at level 2.
4309 If ARG is non-nil and not a positive number, Gnus will
4310 prompt the user for the name of an NNTP server to use.
4311 As opposed to `gnus', this command will not connect to the local server."
4313 (let ((val (or arg (1- gnus-level-default-subscribed))))
4315 (make-local-variable 'gnus-group-use-permanent-levels)
4316 (setq gnus-group-use-permanent-levels val)))
4319 (defun gnus-slave (&optional arg)
4320 "Read news as a slave."
4322 (gnus arg nil 'slave))
4325 (defun gnus-other-frame (&optional arg)
4326 "Pop up a frame to read news."
4328 (if (get-buffer gnus-group-buffer)
4329 (let ((pop-up-frames t))
4331 (select-frame (make-frame))
4335 (defun gnus (&optional arg dont-connect slave)
4337 If ARG is non-nil and a positive number, Gnus will use that as the
4338 startup level. If ARG is non-nil and not a positive number, Gnus will
4339 prompt the user for the name of an NNTP server to use."
4342 (if (get-buffer gnus-group-buffer)
4344 (switch-to-buffer gnus-group-buffer)
4345 (gnus-group-get-new-news))
4348 (nnheader-init-server-buffer)
4349 (gnus-read-init-file)
4350 (setq gnus-slave slave)
4352 (gnus-group-setup-buffer)
4353 (let ((buffer-read-only nil))
4355 (if (not gnus-inhibit-startup-message)
4357 (gnus-group-startup-message)
4360 (let ((level (and (numberp arg) (> arg 0) arg))
4366 (gnus-start-news-server (and arg (not level))))))
4367 (if (and (not dont-connect)
4370 (run-hooks 'gnus-startup-hook)
4371 ;; NNTP server is successfully open.
4373 ;; Find the current startup file name.
4374 (setq gnus-current-startup-file
4375 (gnus-make-newsrc-file gnus-startup-file))
4377 ;; Read the dribble file.
4378 (when (or gnus-slave gnus-use-dribble-file)
4379 (gnus-dribble-read-file))
4381 ;; Allow using GroupLens predictions.
4382 (when gnus-use-grouplens
4384 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4386 (gnus-summary-make-display-table)
4387 ;; Do the actual startup.
4388 (gnus-setup-news nil level dont-connect)
4389 ;; Generate the group buffer.
4390 (gnus-group-list-groups level)
4391 (gnus-group-first-unread-group)
4392 (gnus-configure-windows 'group)
4393 (gnus-group-set-mode-line))))))
4395 (defun gnus-unload ()
4396 "Unload all Gnus features."
4398 (or (boundp 'load-history)
4399 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4400 (let ((history load-history)
4403 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4404 (setq feature (cdr (assq 'provide (car history))))
4405 (unload-feature feature 'force))
4406 (setq history (cdr history)))))
4408 (defun gnus-compile ()
4409 "Byte-compile the user-defined format specs."
4411 (let ((entries gnus-format-specs)
4412 entry gnus-tmp-func)
4414 (gnus-message 7 "Compiling format specs...")
4417 (setq entry (pop entries))
4418 (if (eq (car entry) 'version)
4419 (setq gnus-format-specs (delq entry gnus-format-specs))
4420 (when (and (listp (caddr entry))
4421 (not (eq 'byte-code (caaddr entry))))
4422 (fset 'gnus-tmp-func
4423 `(lambda () ,(caddr entry)))
4424 (byte-compile 'gnus-tmp-func)
4425 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4427 (push (cons 'version emacs-version) gnus-format-specs)
4429 (gnus-message 7 "Compiling user specs...done"))))
4431 (defun gnus-indent-rigidly (start end arg)
4432 "Indent rigidly using only spaces and no tabs."
4435 (narrow-to-region start end)
4436 (indent-rigidly start end arg)
4437 (goto-char (point-min))
4438 (while (search-forward "\t" nil t)
4439 (replace-match " " t t)))))
4441 (defun gnus-group-startup-message (&optional x y)
4442 "Insert startup message in current buffer."
4443 ;; Insert the message.
4448 _ ___ __ ___ __ _ ___
4467 ;; And then hack it.
4468 (gnus-indent-rigidly (point-min) (point-max)
4469 (/ (max (- (window-width) (or x 46)) 0) 2))
4470 (goto-char (point-min))
4472 (let* ((pheight (count-lines (point-min) (point-max)))
4473 (wheight (window-height))
4474 (rest (- wheight pheight)))
4475 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4477 (goto-char (point-min))
4478 (and (search-forward "Praxis" nil t)
4479 (gnus-put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4480 (goto-char (point-min))
4481 (let* ((mode-string (gnus-group-set-mode-line)))
4482 (setq mode-line-buffer-identification
4483 (list (concat gnus-version (substring (car mode-string) 4))))
4484 (set-buffer-modified-p t)))
4486 (defun gnus-group-setup-buffer ()
4487 (or (get-buffer gnus-group-buffer)
4489 (switch-to-buffer gnus-group-buffer)
4490 (gnus-add-current-to-buffer-list)
4492 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4494 (defun gnus-group-list-groups (&optional level unread lowest)
4495 "List newsgroups with level LEVEL or lower that have unread articles.
4496 Default is all subscribed groups.
4497 If argument UNREAD is non-nil, groups with no unread articles are also
4499 (interactive (list (if current-prefix-arg
4500 (prefix-numeric-value current-prefix-arg)
4502 (gnus-group-default-level nil t)
4503 gnus-group-default-list-level
4504 gnus-level-subscribed))))
4506 (setq level (car gnus-group-list-mode)
4507 unread (cdr gnus-group-list-mode)))
4508 (setq level (gnus-group-default-level level))
4509 (gnus-group-setup-buffer) ;May call from out of group buffer
4510 (gnus-update-format-specifications)
4511 (let ((case-fold-search nil)
4512 (props (text-properties-at (gnus-point-at-bol)))
4513 (group (gnus-group-group-name)))
4514 (set-buffer gnus-group-buffer)
4515 (funcall gnus-group-prepare-function level unread lowest)
4516 (if (zerop (buffer-size))
4517 (gnus-message 5 gnus-no-groups-message)
4518 (goto-char (point-max))
4519 (when (or (not gnus-group-goto-next-group-function)
4520 (not (funcall gnus-group-goto-next-group-function
4523 ;; Go to the first group with unread articles.
4524 (gnus-group-search-forward t)
4525 ;; Find the right group to put point on. If the current group
4526 ;; has disappeared in the new listing, try to find the next
4527 ;; one. If no next one can be found, just leave point at the
4528 ;; first newsgroup in the buffer.
4529 (if (not (gnus-goto-char
4531 (point-min) (point-max)
4532 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4533 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4535 (not (gnus-goto-char
4537 (point-min) (point-max) 'gnus-group
4539 (caar newsrc) gnus-active-hashtb)))))
4540 (setq newsrc (cdr newsrc)))
4541 (or newsrc (progn (goto-char (point-max))
4542 (forward-line -1)))))))
4543 ;; Adjust cursor point.
4544 (gnus-group-position-point))))
4546 (defun gnus-group-list-level (level &optional all)
4547 "List groups on LEVEL.
4548 If ALL (the prefix), also list groups that have no unread articles."
4549 (interactive "nList groups on level: \nP")
4550 (gnus-group-list-groups level all level))
4552 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4553 "List all newsgroups with unread articles of level LEVEL or lower.
4554 If ALL is non-nil, list groups that have no unread articles.
4555 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4556 If REGEXP, only list groups matching REGEXP."
4557 (set-buffer gnus-group-buffer)
4558 (let ((buffer-read-only nil)
4559 (newsrc (cdr gnus-newsrc-alist))
4560 (lowest (or lowest 1))
4561 info clevel unread group params)
4563 (if (< lowest gnus-level-zombie)
4564 ;; List living groups.
4566 (setq info (car newsrc)
4567 group (gnus-info-group info)
4568 params (gnus-info-params info)
4570 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4571 (and unread ; This group might be bogus
4573 (string-match regexp group))
4574 (<= (setq clevel (gnus-info-level info)) level)
4576 (or all ; We list all groups?
4577 (if (eq unread t) ; Unactivated?
4578 gnus-group-list-inactive-groups ; We list unactivated
4579 (> unread 0)) ; We list groups with unread articles
4580 (and gnus-list-groups-with-ticked-articles
4581 (cdr (assq 'tick (gnus-info-marks info))))
4582 ; And groups with tickeds
4583 ;; Check for permanent visibility.
4584 (and gnus-permanently-visible-groups
4585 (string-match gnus-permanently-visible-groups
4587 (memq 'visible params)
4588 (cdr (assq 'visible params)))
4589 (gnus-group-insert-group-line
4590 group (gnus-info-level info)
4591 (gnus-info-marks info) unread (gnus-info-method info)))))
4593 ;; List dead groups.
4594 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4595 (gnus-group-prepare-flat-list-dead
4596 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4597 gnus-level-zombie ?Z
4599 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4600 (gnus-group-prepare-flat-list-dead
4601 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4602 gnus-level-killed ?K regexp))
4604 (gnus-group-set-mode-line)
4605 (setq gnus-group-list-mode (cons level all))
4606 (run-hooks 'gnus-group-prepare-hook)))
4608 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4609 ;; List zombies and killed lists somewhat faster, which was
4610 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4611 ;; this by ignoring the group format specification altogether.
4614 ;; This loop is used when listing groups that match some
4617 (setq group (pop groups))
4618 (when (string-match regexp group)
4619 (gnus-add-text-properties
4620 (point) (prog1 (1+ (point))
4621 (insert " " mark " *: " group "\n"))
4622 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4624 'gnus-level level))))
4625 ;; This loop is used when listing all groups.
4627 (gnus-add-text-properties
4628 (point) (prog1 (1+ (point))
4629 (insert " " mark " *: "
4630 (setq group (pop groups)) "\n"))
4631 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4633 'gnus-level level))))))
4635 (defmacro gnus-group-real-name (group)
4636 "Find the real name of a foreign newsgroup."
4637 `(let ((gname ,group))
4638 (if (string-match ":[^:]+$" gname)
4639 (substring gname (1+ (match-beginning 0)))
4642 (defsubst gnus-server-add-address (method)
4643 (let ((method-name (symbol-name (car method))))
4644 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4645 (not (assq (intern (concat method-name "-address")) method)))
4646 (append method (list (list (intern (concat method-name "-address"))
4650 (defsubst gnus-server-get-method (group method)
4651 ;; Input either a server name, and extended server name, or a
4652 ;; select method, and return a select method.
4653 (cond ((stringp method)
4654 (gnus-server-to-method method))
4655 ((equal method gnus-select-method)
4657 ((and (stringp (car method)) group)
4658 (gnus-server-extend-method group method))
4659 ((and method (not group)
4660 (equal (cadr method) ""))
4663 (gnus-server-add-address method))))
4665 (defun gnus-server-to-method (server)
4666 "Map virtual server names to select methods."
4668 ;; Is this a method, perhaps?
4669 (and server (listp server) server)
4670 ;; Perhaps this is the native server?
4671 (and (equal server "native") gnus-select-method)
4672 ;; It should be in the server alist.
4673 (cdr (assoc server gnus-server-alist))
4674 ;; If not, we look through all the opened server
4675 ;; to see whether we can find it there.
4676 (let ((opened gnus-opened-servers))
4678 (not (equal server (format "%s:%s" (caaar opened)
4683 (defmacro gnus-method-equal (ss1 ss2)
4684 "Say whether two servers are equal."
4688 (and (= (length s1) (length s2))
4690 (while (and s1 (member (car s1) s2))
4694 (defun gnus-server-equal (m1 m2)
4695 "Say whether two methods are equal."
4696 (let ((m1 (cond ((null m1) gnus-select-method)
4697 ((stringp m1) (gnus-server-to-method m1))
4699 (m2 (cond ((null m2) gnus-select-method)
4700 ((stringp m2) (gnus-server-to-method m2))
4702 (gnus-method-equal m1 m2)))
4704 (defun gnus-servers-using-backend (backend)
4705 "Return a list of known servers using BACKEND."
4706 (let ((opened gnus-opened-servers)
4709 (when (eq backend (caaar opened))
4710 (push (caar opened) out))
4714 (defun gnus-group-prefixed-name (group method)
4715 "Return the whole name from GROUP and METHOD."
4716 (and (stringp method) (setq method (gnus-server-to-method method)))
4717 (concat (format "%s" (car method))
4719 (or (assoc (format "%s" (car method))
4720 (gnus-methods-using 'address))
4721 (gnus-server-equal method gnus-message-archive-method))
4723 (not (string= (nth 1 method) "")))
4724 (concat "+" (nth 1 method)))
4727 (defun gnus-group-real-prefix (group)
4728 "Return the prefix of the current group name."
4729 (if (string-match "^[^:]+:" group)
4730 (substring group 0 (match-end 0))
4733 (defun gnus-group-method (group)
4734 "Return the server or method used for selecting GROUP."
4735 (let ((prefix (gnus-group-real-prefix group)))
4736 (if (equal prefix "")
4738 (let ((servers gnus-opened-servers)
4740 backend possible found)
4741 (if (string-match "^[^\\+]+\\+" prefix)
4742 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4743 server (substring prefix (match-end 0) (1- (length prefix))))
4744 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4746 (when (eq (caaar servers) backend)
4747 (setq possible (caar servers))
4748 (when (equal (cadaar servers) server)
4749 (setq found (caar servers))))
4751 (or (car (rassoc found gnus-server-alist))
4753 (car (rassoc possible gnus-server-alist))
4755 (list backend server))))))
4757 (defsubst gnus-secondary-method-p (method)
4758 "Return whether METHOD is a secondary select method."
4759 (let ((methods gnus-secondary-select-methods)
4760 (gmethod (gnus-server-get-method nil method)))
4762 (not (equal (gnus-server-get-method nil (car methods))
4764 (setq methods (cdr methods)))
4767 (defun gnus-group-foreign-p (group)
4768 "Say whether a group is foreign or not."
4769 (and (not (gnus-group-native-p group))
4770 (not (gnus-group-secondary-p group))))
4772 (defun gnus-group-native-p (group)
4773 "Say whether the group is native or not."
4774 (not (string-match ":" group)))
4776 (defun gnus-group-secondary-p (group)
4777 "Say whether the group is secondary or not."
4778 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4780 (defun gnus-group-get-parameter (group &optional symbol)
4781 "Returns the group parameters for GROUP.
4782 If SYMBOL, return the value of that symbol in the group parameters."
4783 (let ((params (gnus-info-params (gnus-get-info group))))
4785 (gnus-group-parameter-value params symbol)
4788 (defun gnus-group-parameter-value (params symbol)
4789 "Return the value of SYMBOL in group PARAMS."
4790 (or (car (memq symbol params)) ; It's either a simple symbol
4791 (cdr (assq symbol params)))) ; or a cons.
4793 (defun gnus-group-add-parameter (group param)
4794 "Add parameter PARAM to GROUP."
4795 (let ((info (gnus-get-info group)))
4797 () ; This is a dead group. We just ignore it.
4798 ;; Cons the new param to the old one and update.
4799 (gnus-group-set-info (cons param (gnus-info-params info))
4802 (defun gnus-group-set-parameter (group name value)
4803 "Set parameter NAME to VALUE in GROUP."
4804 (let ((info (gnus-get-info group)))
4806 () ; This is a dead group. We just ignore it.
4807 (let ((old-params (gnus-info-params info))
4808 (new-params (list (cons name value))))
4810 (if (or (not (listp (car old-params)))
4811 (not (eq (caar old-params) name)))
4812 (setq new-params (append new-params (list (car old-params)))))
4813 (setq old-params (cdr old-params)))
4814 (gnus-group-set-info new-params group 'params)))))
4816 (defun gnus-group-add-score (group &optional score)
4817 "Add SCORE to the GROUP score.
4818 If SCORE is nil, add 1 to the score of GROUP."
4819 (let ((info (gnus-get-info group)))
4821 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1))))))
4823 (defun gnus-summary-bubble-group ()
4824 "Increase the score of the current group.
4825 This is a handy function to add to `gnus-summary-exit-hook' to
4826 increase the score of each group you read."
4827 (gnus-group-add-score gnus-newsgroup-name))
4829 (defun gnus-group-set-info (info &optional method-only-group part)
4830 (let* ((entry (gnus-gethash
4831 (or method-only-group (gnus-info-group info))
4832 gnus-newsrc-hashtb))
4834 (info (if method-only-group (nth 2 entry) info))
4836 (when method-only-group
4838 (error "Trying to change non-existent group %s" method-only-group))
4839 ;; We have received parts of the actual group info - either the
4840 ;; select method or the group parameters. We first check
4841 ;; whether we have to extend the info, and if so, do that.
4842 (let ((len (length info))
4843 (total (if (eq part 'method) 5 6)))
4845 (setcdr (nthcdr (1- len) info)
4846 (make-list (- total len) nil)))
4847 ;; Then we enter the new info.
4848 (setcar (nthcdr (1- total) info) part-info)))
4850 ;; This is a new group, so we just create it.
4852 (set-buffer gnus-group-buffer)
4853 (setq method (gnus-info-method info))
4854 (when (gnus-server-equal method "native")
4857 (set-buffer gnus-group-buffer)
4859 ;; It's a foreign group...
4860 (gnus-group-make-group
4861 (gnus-group-real-name (gnus-info-group info))
4862 (if (stringp method) method
4863 (prin1-to-string (car method)))
4865 (nth 1 (gnus-info-method info))))
4866 ;; It's a native group.
4867 (gnus-group-make-group (gnus-info-group info))))
4868 (gnus-message 6 "Note: New group created")
4870 (gnus-gethash (gnus-group-prefixed-name
4871 (gnus-group-real-name (gnus-info-group info))
4872 (or (gnus-info-method info) gnus-select-method))
4873 gnus-newsrc-hashtb))))
4874 ;; Whether it was a new group or not, we now have the entry, so we
4875 ;; can do the update.
4878 (setcar (nthcdr 2 entry) info)
4879 (when (and (not (eq (car entry) t))
4880 (gnus-active (gnus-info-group info)))
4881 (setcar entry (length (gnus-list-of-unread-articles (car info))))))
4882 (error "No such group: %s" (gnus-info-group info)))))
4884 (defun gnus-group-set-method-info (group select-method)
4885 (gnus-group-set-info select-method group 'method))
4887 (defun gnus-group-set-params-info (group params)
4888 (gnus-group-set-info params group 'params))
4890 (defun gnus-group-update-group-line ()
4891 "Update the current line in the group buffer."
4892 (let* ((buffer-read-only nil)
4893 (group (gnus-group-group-name))
4894 (entry (and group (gnus-gethash group gnus-newsrc-hashtb)))
4895 gnus-group-indentation)
4897 (not (gnus-ephemeral-group-p group))
4899 (concat "(gnus-group-set-info '"
4900 (prin1-to-string (nth 2 entry)) ")")))
4901 (setq gnus-group-indentation (gnus-group-group-indentation))
4903 (gnus-group-insert-group-line-info group)
4905 (gnus-group-position-point)))
4907 (defun gnus-group-insert-group-line-info (group)
4908 "Insert GROUP on the current line."
4909 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4913 ;; (Un)subscribed group.
4914 (setq info (nth 2 entry))
4915 (gnus-group-insert-group-line
4916 group (gnus-info-level info) (gnus-info-marks info)
4917 (or (car entry) t) (gnus-info-method info)))
4918 ;; This group is dead.
4919 (gnus-group-insert-group-line
4921 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4923 (if (setq active (gnus-active group))
4924 (- (1+ (cdr active)) (car active)) 0)
4927 (defun gnus-group-insert-group-line (gnus-tmp-group gnus-tmp-level
4928 gnus-tmp-marked number
4930 "Insert a group line in the group buffer."
4931 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4932 (gnus-tmp-number-total
4934 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4936 (gnus-tmp-number-of-unread
4937 (if (numberp number) (int-to-string (max 0 number))
4939 (gnus-tmp-number-of-read
4940 (if (numberp number)
4941 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4943 (gnus-tmp-subscribed
4944 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4945 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4946 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4948 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4949 (gnus-tmp-newsgroup-description
4950 (if gnus-description-hashtb
4951 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4954 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4955 (gnus-tmp-moderated-string
4956 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4958 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4959 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4960 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4961 (gnus-tmp-news-method-string
4963 (format "(%s:%s)" (car gnus-tmp-method)
4964 (cadr gnus-tmp-method)) ""))
4965 (gnus-tmp-marked-mark
4966 (if (and (numberp number)
4968 (cdr (assq 'tick gnus-tmp-marked)))
4970 (gnus-tmp-process-marked
4971 (if (member gnus-tmp-group gnus-group-marked)
4972 gnus-process-mark ? ))
4974 (or (and gnus-use-grouplens
4975 (bbb-grouplens-group-p gnus-tmp-group))
4977 (buffer-read-only nil)
4978 header gnus-tmp-header) ; passed as parameter to user-funcs.
4980 (gnus-add-text-properties
4984 (eval gnus-group-line-format-spec))
4985 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
4986 gnus-unread ,(if (numberp number)
4987 (string-to-int gnus-tmp-number-of-unread)
4989 gnus-marked ,gnus-tmp-marked-mark
4990 gnus-indentation ,gnus-group-indentation
4991 gnus-level ,gnus-tmp-level))
4992 (when (inline (gnus-visual-p 'group-highlight 'highlight))
4994 (run-hooks 'gnus-group-update-hook)
4996 ;; Allow XEmacs to remove front-sticky text properties.
4997 (gnus-group-remove-excess-properties)))
4999 (defun gnus-group-update-group (group &optional visible-only)
5000 "Update all lines where GROUP appear.
5001 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
5004 (set-buffer gnus-group-buffer)
5005 ;; The buffer may be narrowed.
5008 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
5010 found buffer-read-only)
5011 ;; Enter the current status into the dribble buffer.
5012 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
5013 (if (and entry (not (gnus-ephemeral-group-p group)))
5015 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
5017 ;; Find all group instances. If topics are in use, each group
5018 ;; may be listed in more than once.
5019 (while (setq loc (text-property-any
5020 loc (point-max) 'gnus-group ident))
5023 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5025 (gnus-group-insert-group-line-info group))
5026 (setq loc (1+ loc)))
5027 (unless (or found visible-only)
5028 ;; No such line in the buffer, find out where it's supposed to
5029 ;; go, and insert it there (or at the end of the buffer).
5030 (if gnus-goto-missing-group-function
5031 (funcall gnus-goto-missing-group-function group)
5032 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
5033 (while (and entry (car entry)
5037 (point-min) (point-max)
5038 'gnus-group (gnus-intern-safe
5039 (caar entry) gnus-active-hashtb)))))
5040 (setq entry (cdr entry)))
5041 (or entry (goto-char (point-max)))))
5042 ;; Finally insert the line.
5043 (let ((gnus-group-indentation (gnus-group-group-indentation)))
5044 (gnus-group-insert-group-line-info group)))
5045 (gnus-group-set-mode-line)))))
5047 (defun gnus-group-set-mode-line ()
5048 "Update the mode line in the group buffer."
5049 (when (memq 'group gnus-updated-mode-lines)
5050 ;; Yes, we want to keep this mode line updated.
5052 (set-buffer gnus-group-buffer)
5053 (let* ((gformat (or gnus-group-mode-line-format-spec
5054 (setq gnus-group-mode-line-format-spec
5056 gnus-group-mode-line-format
5057 gnus-group-mode-line-format-alist))))
5058 (gnus-tmp-news-server (cadr gnus-select-method))
5059 (gnus-tmp-news-method (car gnus-select-method))
5060 (gnus-tmp-colon (if (equal gnus-tmp-news-server "") "" ":"))
5062 gnus-tmp-header ;Dummy binding for user-defined formats
5063 ;; Get the resulting string.
5064 (mode-string (eval gformat)))
5065 ;; Say whether the dribble buffer has been modified.
5066 (setq mode-line-modified
5067 (if (and gnus-dribble-buffer
5068 (buffer-name gnus-dribble-buffer)
5069 (buffer-modified-p gnus-dribble-buffer)
5071 (set-buffer gnus-dribble-buffer)
5072 (not (zerop (buffer-size)))))
5074 ;; If the line is too long, we chop it off.
5075 (when (> (length mode-string) max-len)
5076 (setq mode-string (substring mode-string 0 (- max-len 4))))
5078 (setq mode-line-buffer-identification
5080 (set-buffer-modified-p t))))))
5082 (defun gnus-group-group-name ()
5083 "Get the name of the newsgroup on the current line."
5084 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
5085 (and group (symbol-name group))))
5087 (defun gnus-group-group-level ()
5088 "Get the level of the newsgroup on the current line."
5089 (get-text-property (gnus-point-at-bol) 'gnus-level))
5091 (defun gnus-group-group-indentation ()
5092 "Get the indentation of the newsgroup on the current line."
5093 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation)
5094 (and gnus-group-indentation-function
5095 (funcall gnus-group-indentation-function))
5098 (defun gnus-group-group-unread ()
5099 "Get the number of unread articles of the newsgroup on the current line."
5100 (get-text-property (gnus-point-at-bol) 'gnus-unread))
5102 (defun gnus-group-search-forward (&optional backward all level first-too)
5103 "Find the next newsgroup with unread articles.
5104 If BACKWARD is non-nil, find the previous newsgroup instead.
5105 If ALL is non-nil, just find any newsgroup.
5106 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
5108 If FIRST-TOO, the current line is also eligible as a target."
5109 (let ((way (if backward -1 1))
5110 (low gnus-level-killed)
5113 (if (and backward (progn (beginning-of-line)) (bobp))
5115 (or first-too (forward-line way))
5123 (get-text-property (point) 'gnus-unread)))
5124 (and (numberp unread) (> unread 0)))
5125 (setq lev (get-text-property (point)
5127 (<= lev gnus-level-subscribed)))
5129 (and (setq lev (get-text-property (point)
5138 (zerop (forward-line way)))))
5140 (progn (gnus-group-position-point) t)
5141 (goto-char (or pos beg))
5144 ;;; Gnus group mode commands
5148 (defun gnus-group-mark-group (n &optional unmark no-advance)
5149 "Mark the current group."
5151 (let ((buffer-read-only nil)
5155 (when (setq group (gnus-group-group-name))
5159 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
5164 (setq gnus-group-marked (delete group gnus-group-marked)))
5166 (setq gnus-group-marked
5167 (cons group (delete group gnus-group-marked)))))
5168 (or no-advance (gnus-group-next-group 1))
5170 (gnus-summary-position-point)
5173 (defun gnus-group-unmark-group (n)
5174 "Remove the mark from the current group."
5176 (gnus-group-mark-group n 'unmark)
5177 (gnus-group-position-point))
5179 (defun gnus-group-unmark-all-groups ()
5180 "Unmark all groups."
5182 (let ((groups gnus-group-marked))
5185 (gnus-group-remove-mark (pop groups)))))
5186 (gnus-group-position-point))
5188 (defun gnus-group-mark-region (unmark beg end)
5189 "Mark all groups between point and mark.
5190 If UNMARK, remove the mark instead."
5191 (interactive "P\nr")
5192 (let ((num (count-lines beg end)))
5195 (- num (gnus-group-mark-group num unmark)))))
5197 (defun gnus-group-mark-buffer (&optional unmark)
5198 "Mark all groups in the buffer.
5199 If UNMARK, remove the mark instead."
5201 (gnus-group-mark-region unmark (point-min) (point-max)))
5203 (defun gnus-group-mark-regexp (regexp)
5204 "Mark all groups that match some regexp."
5205 (interactive "sMark (regexp): ")
5206 (let ((alist (cdr gnus-newsrc-alist))
5209 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5210 (gnus-group-set-mark group))))
5211 (gnus-group-position-point))
5213 (defun gnus-group-remove-mark (group)
5214 "Remove the process mark from GROUP and move point there.
5215 Return nil if the group isn't displayed."
5216 (if (gnus-group-goto-group group)
5218 (gnus-group-mark-group 1 'unmark t)
5220 (setq gnus-group-marked
5221 (delete group gnus-group-marked))
5224 (defun gnus-group-set-mark (group)
5225 "Set the process mark on GROUP."
5226 (if (gnus-group-goto-group group)
5228 (gnus-group-mark-group 1 nil t))
5229 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5231 (defun gnus-group-universal-argument (arg &optional groups func)
5232 "Perform any command on all groups accoring to the process/prefix convention."
5234 (let ((groups (or groups (gnus-group-process-prefix arg)))
5236 (if (eq (setq func (or func
5239 (substitute-command-keys
5240 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5242 (gnus-error 1 "Undefined key")
5244 (gnus-group-remove-mark (setq group (pop groups)))
5245 (command-execute func))))
5246 (gnus-group-position-point))
5248 (defun gnus-group-process-prefix (n)
5249 "Return a list of groups to work on.
5250 Take into consideration N (the prefix) and the list of marked groups."
5253 (setq n (prefix-numeric-value n))
5254 ;; There is a prefix, so we return a list of the N next
5256 (let ((way (if (< n 0) -1 1))
5261 (setq group (gnus-group-group-name)))
5262 (setq groups (cons group groups))
5264 (gnus-group-next-group way)))
5266 ((and (boundp 'transient-mark-mode)
5268 (boundp 'mark-active)
5270 ;; Work on the region between point and mark.
5271 (let ((max (max (point) (mark)))
5274 (goto-char (min (point) (mark)))
5277 (push (gnus-group-group-name) groups)
5278 (zerop (gnus-group-next-group 1))
5280 (nreverse groups))))
5282 ;; No prefix, but a list of marked articles.
5283 (reverse gnus-group-marked))
5285 ;; Neither marked articles or a prefix, so we return the
5287 (let ((group (gnus-group-group-name)))
5288 (and group (list group))))))
5290 ;; Selecting groups.
5292 (defun gnus-group-read-group (&optional all no-article group)
5293 "Read news in this newsgroup.
5294 If the prefix argument ALL is non-nil, already read articles become
5295 readable. IF ALL is a number, fetch this number of articles. If the
5296 optional argument NO-ARTICLE is non-nil, no article will be
5297 auto-selected upon group entry. If GROUP is non-nil, fetch that
5300 (let ((group (or group (gnus-group-group-name)))
5301 number active marked entry)
5302 (or group (error "No group on current line"))
5303 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5304 group gnus-newsrc-hashtb)))))
5305 ;; This group might be a dead group. In that case we have to get
5306 ;; the number of unread articles from `gnus-active-hashtb'.
5308 (cond ((numberp all) all)
5310 ((setq active (gnus-active group))
5311 (- (1+ (cdr active)) (car active)))))
5312 (gnus-summary-read-group
5313 group (or all (and (numberp number)
5314 (zerop (+ number (length (cdr (assq 'tick marked)))
5315 (length (cdr (assq 'dormant marked)))))))
5318 (defun gnus-group-select-group (&optional all)
5319 "Select this newsgroup.
5320 No article is selected automatically.
5321 If ALL is non-nil, already read articles become readable.
5322 If ALL is a number, fetch this number of articles."
5324 (gnus-group-read-group all t))
5326 (defun gnus-group-quick-select-group (&optional all)
5327 "Select the current group \"quickly\".
5328 This means that no highlighting or scoring will be performed."
5331 gnus-score-find-score-files-function
5332 gnus-apply-kill-hook
5333 gnus-summary-expunge-below)
5334 (gnus-group-read-group all t)))
5336 (defun gnus-group-visible-select-group (&optional all)
5337 "Select the current group without hiding any articles."
5339 (let ((gnus-inhibit-limiting t))
5340 (gnus-group-read-group all t)))
5343 (defun gnus-fetch-group (group)
5344 "Start Gnus if necessary and enter GROUP.
5345 Returns whether the fetching was successful or not."
5346 (interactive "sGroup name: ")
5347 (or (get-buffer gnus-group-buffer)
5349 (gnus-group-read-group nil nil group))
5351 ;; Enter a group that is not in the group buffer. Non-nil is returned
5352 ;; if selection was successful.
5353 (defun gnus-group-read-ephemeral-group
5354 (group method &optional activate quit-config)
5355 (let ((group (if (gnus-group-foreign-p group) group
5356 (gnus-group-prefixed-name group method))))
5359 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5360 ((quit-config . ,(if quit-config quit-config
5361 (cons (current-buffer) 'summary))))))
5363 (set-buffer gnus-group-buffer)
5364 (or (gnus-check-server method)
5365 (error "Unable to contact server: %s" (gnus-status-message method)))
5366 (if activate (or (gnus-request-group group)
5367 (error "Couldn't request group")))
5369 (gnus-group-read-group t t group)
5373 (defun gnus-group-jump-to-group (group)
5374 "Jump to newsgroup GROUP."
5376 (list (completing-read
5377 "Group: " gnus-active-hashtb nil
5378 (gnus-read-active-file-p)
5380 'gnus-group-history)))
5382 (when (equal group "")
5383 (error "Empty group name"))
5385 (when (string-match "[\000-\032]" group)
5386 (error "Control characters in group: %s" group))
5388 (let ((b (text-property-any
5389 (point-min) (point-max)
5390 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5391 (unless (gnus-ephemeral-group-p group)
5393 ;; Either go to the line in the group buffer...
5395 ;; ... or insert the line.
5398 (gnus-activate-group group)
5399 (error "%s error: %s" group (gnus-status-message group)))
5401 (gnus-group-update-group group)
5402 (goto-char (text-property-any
5403 (point-min) (point-max)
5404 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5405 ;; Adjust cursor point.
5406 (gnus-group-position-point)))
5408 (defun gnus-group-goto-group (group)
5409 "Goto to newsgroup GROUP."
5411 (let ((b (text-property-any (point-min) (point-max)
5412 'gnus-group (gnus-intern-safe
5413 group gnus-active-hashtb))))
5414 (and b (goto-char b)))))
5416 (defun gnus-group-next-group (n)
5417 "Go to next N'th newsgroup.
5418 If N is negative, search backward instead.
5419 Returns the difference between N and the number of skips actually
5422 (gnus-group-next-unread-group n t))
5424 (defun gnus-group-next-unread-group (n &optional all level)
5425 "Go to next N'th unread newsgroup.
5426 If N is negative, search backward instead.
5427 If ALL is non-nil, choose any newsgroup, unread or not.
5428 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5429 such group can be found, the next group with a level higher than
5431 Returns the difference between N and the number of skips actually
5434 (let ((backward (< n 0))
5437 (gnus-group-search-forward
5438 backward (or (not gnus-group-goto-unread) all) level))
5440 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5441 (if level " on this level or higher" "")))
5444 (defun gnus-group-prev-group (n)
5445 "Go to previous N'th newsgroup.
5446 Returns the difference between N and the number of skips actually
5449 (gnus-group-next-unread-group (- n) t))
5451 (defun gnus-group-prev-unread-group (n)
5452 "Go to previous N'th unread newsgroup.
5453 Returns the difference between N and the number of skips actually
5456 (gnus-group-next-unread-group (- n)))
5458 (defun gnus-group-next-unread-group-same-level (n)
5459 "Go to next N'th unread newsgroup on the same level.
5460 If N is negative, search backward instead.
5461 Returns the difference between N and the number of skips actually
5464 (gnus-group-next-unread-group n t (gnus-group-group-level))
5465 (gnus-group-position-point))
5467 (defun gnus-group-prev-unread-group-same-level (n)
5468 "Go to next N'th unread newsgroup on the same level.
5469 Returns the difference between N and the number of skips actually
5472 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5473 (gnus-group-position-point))
5475 (defun gnus-group-best-unread-group (&optional exclude-group)
5476 "Go to the group with the highest level.
5477 If EXCLUDE-GROUP, do not go to that group."
5479 (goto-char (point-min))
5483 (setq unread (get-text-property (point) 'gnus-unread))
5484 (if (and (numberp unread) (> unread 0))
5486 (if (and (get-text-property (point) 'gnus-level)
5487 (< (get-text-property (point) 'gnus-level) best)
5488 (or (not exclude-group)
5489 (not (equal exclude-group (gnus-group-group-name)))))
5491 (setq best (get-text-property (point) 'gnus-level))
5492 (setq best-point (point))))))
5494 (if best-point (goto-char best-point))
5495 (gnus-summary-position-point)
5496 (and best-point (gnus-group-group-name))))
5498 (defun gnus-group-first-unread-group ()
5499 "Go to the first group with unread articles."
5502 (let ((opoint (point))
5504 (goto-char (point-min))
5505 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5506 (and (numberp unread) ; Not a topic.
5507 (not (zerop unread))) ; Has unread articles.
5508 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5511 nil)) ; Not success.
5512 (gnus-group-position-point)))
5514 (defun gnus-group-enter-server-mode ()
5515 "Jump to the server buffer."
5517 (gnus-enter-server-buffer))
5519 (defun gnus-group-make-group (name &optional method address)
5520 "Add a new newsgroup.
5521 The user will be prompted for a NAME, for a select METHOD, and an
5525 (read-string "Group name: ")
5528 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5529 nil t nil 'gnus-method-history)))
5530 (cond ((assoc method gnus-valid-select-methods)
5532 (if (memq 'prompt-address
5533 (assoc method gnus-valid-select-methods))
5534 (read-string "Address: ")
5536 ((assoc method gnus-server-alist)
5539 (list method ""))))))
5541 (let* ((meth (and method (if address (list (intern method) address)
5543 (nname (if method (gnus-group-prefixed-name name meth) name))
5545 (when (gnus-gethash nname gnus-newsrc-hashtb)
5546 (error "Group %s already exists" nname))
5547 ;; Subscribe to the new group.
5548 (gnus-group-change-level
5549 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5550 gnus-level-default-subscribed gnus-level-killed
5551 (and (gnus-group-group-name)
5552 (gnus-gethash (gnus-group-group-name)
5553 gnus-newsrc-hashtb))
5556 (gnus-set-active nname (cons 1 0))
5557 (or (gnus-ephemeral-group-p name)
5559 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5561 (gnus-group-insert-group-line-info nname)
5563 (gnus-group-position-point)
5565 ;; Load the backend and try to make the backend create
5566 ;; the group as well.
5567 (when (assoc (symbol-name (setq backend (car (gnus-server-get-method
5569 gnus-valid-select-methods)
5571 (gnus-check-server meth)
5572 (and (gnus-check-backend-function 'request-create-group nname)
5573 (gnus-request-create-group nname))
5576 (defun gnus-group-delete-group (group &optional force)
5577 "Delete the current group.
5578 If FORCE (the prefix) is non-nil, all the articles in the group will
5579 be deleted. This is \"deleted\" as in \"removed forever from the face
5580 of the Earth\". There is no undo."
5582 (list (gnus-group-group-name)
5583 current-prefix-arg))
5584 (or group (error "No group to rename"))
5585 (or (gnus-check-backend-function 'request-delete-group group)
5586 (error "This backend does not support group deletion"))
5588 (if (not (gnus-yes-or-no-p
5590 "Do you really want to delete %s%s? "
5591 group (if force " and all its contents" ""))))
5593 (gnus-message 6 "Deleting group %s..." group)
5594 (if (not (gnus-request-delete-group group force))
5595 (gnus-error 3 "Couldn't delete group %s" group)
5596 (gnus-message 6 "Deleting group %s...done" group)
5597 (gnus-group-goto-group group)
5598 (gnus-group-kill-group 1 t)
5599 (gnus-sethash group nil gnus-active-hashtb)
5601 (gnus-group-position-point)))
5603 (defun gnus-group-rename-group (group new-name)
5606 (gnus-group-group-name)
5608 (or (gnus-check-backend-function
5609 'request-rename-group (gnus-group-group-name))
5610 (error "This backend does not support renaming groups"))
5611 (read-string "New group name: "))))
5613 (or (gnus-check-backend-function 'request-rename-group group)
5614 (error "This backend does not support renaming groups"))
5616 (or group (error "No group to rename"))
5617 (and (string-match "^[ \t]*$" new-name)
5618 (error "Not a valid group name"))
5620 ;; We find the proper prefixed name.
5622 (gnus-group-prefixed-name
5623 (gnus-group-real-name new-name)
5624 (gnus-info-method (gnus-get-info group))))
5626 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5628 (if (not (gnus-request-rename-group group new-name))
5629 (gnus-error 3 "Couldn't rename group %s to %s" group new-name)
5630 ;; We rename the group internally by killing it...
5631 (gnus-group-goto-group group)
5632 (gnus-group-kill-group)
5633 ;; ... changing its name ...
5634 (setcar (cdar gnus-list-of-killed-groups) new-name)
5635 ;; ... and then yanking it. Magic!
5636 (gnus-group-yank-group)
5637 (gnus-set-active new-name (gnus-active group))
5638 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5640 (gnus-group-position-point)))
5642 (defun gnus-group-edit-group (group &optional part)
5643 "Edit the group on the current line."
5644 (interactive (list (gnus-group-group-name)))
5645 (let* ((part (or part 'info))
5646 (done-func `(lambda ()
5647 "Exit editing mode and update the information."
5649 (gnus-group-edit-group-done ',part ,group)))
5650 (winconf (current-window-configuration))
5652 (or group (error "No group on current line"))
5653 (or (setq info (gnus-get-info group))
5654 (error "Killed group; can't be edited"))
5655 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5656 (gnus-configure-windows 'edit-group)
5657 (gnus-add-current-to-buffer-list)
5659 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5660 (use-local-map (copy-keymap emacs-lisp-mode-map))
5661 (local-set-key "\C-c\C-c" done-func)
5662 (make-local-variable 'gnus-prev-winconf)
5663 (setq gnus-prev-winconf winconf)
5668 ";; Type `C-c C-c' after editing the select method.\n\n")
5670 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5672 ";; Type `C-c C-c' after editing the group info.\n\n")))
5675 (cond ((eq part 'method)
5676 (or (gnus-info-method info) "native"))
5678 (gnus-info-params info))
5682 (defun gnus-group-edit-group-method (group)
5683 "Edit the select method of GROUP."
5684 (interactive (list (gnus-group-group-name)))
5685 (gnus-group-edit-group group 'method))
5687 (defun gnus-group-edit-group-parameters (group)
5688 "Edit the group parameters of GROUP."
5689 (interactive (list (gnus-group-group-name)))
5690 (gnus-group-edit-group group 'params))
5692 (defun gnus-group-edit-group-done (part group)
5693 "Get info from buffer, update variables and jump to the group buffer."
5694 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5695 (goto-char (point-min))
5696 (let* ((form (read (current-buffer)))
5697 (winconf gnus-prev-winconf)
5698 (method (cond ((eq part 'info) (nth 4 form))
5699 ((eq part 'method) form)
5701 (info (cond ((eq part 'info) form)
5702 ((eq part 'method) (gnus-get-info group))
5705 (if (or (not method)
5707 gnus-select-method method))
5708 (gnus-group-real-name (car info))
5709 (gnus-group-prefixed-name
5710 (gnus-group-real-name (car info)) method))
5712 (when (and new-group
5713 (not (equal new-group group)))
5714 (when (gnus-group-goto-group group)
5715 (gnus-group-kill-group 1))
5716 (gnus-activate-group new-group))
5718 (if (and info new-group)
5720 (setq info (gnus-copy-sequence info))
5721 (setcar info new-group)
5722 (unless (gnus-server-equal method "native")
5723 (unless (nthcdr 3 info)
5724 (nconc info (list nil nil)))
5725 (unless (nthcdr 4 info)
5726 (nconc info (list nil)))
5727 (gnus-info-set-method info method))
5728 (gnus-group-set-info info))
5729 (gnus-group-set-info form (or new-group group) part))
5730 (kill-buffer (current-buffer))
5731 (and winconf (set-window-configuration winconf))
5732 (set-buffer gnus-group-buffer)
5733 (gnus-group-update-group (or new-group group))
5734 (gnus-group-position-point)))
5736 (defun gnus-group-make-help-group ()
5737 "Create the Gnus documentation group."
5739 (let ((path load-path)
5740 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5742 (and (gnus-gethash name gnus-newsrc-hashtb)
5743 (error "Documentation group already exists"))
5745 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5747 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5749 (setq file (concat (file-name-directory
5750 (directory-file-name dir))
5751 "etc/gnus-tut.txt"))))
5754 (gnus-message 1 "Couldn't find doc group")
5755 (gnus-group-make-group
5756 (gnus-group-real-name name)
5757 (list 'nndoc "gnus-help"
5758 (list 'nndoc-address file)
5759 (list 'nndoc-article-type 'mbox)))))
5760 (gnus-group-position-point))
5762 (defun gnus-group-make-doc-group (file type)
5763 "Create a group that uses a single file as the source."
5765 (list (read-file-name "File name: ")
5766 (and current-prefix-arg 'ask)))
5767 (when (eq type 'ask)
5772 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5774 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5775 ((= char ?b) 'babyl)
5776 ((= char ?d) 'digest)
5777 ((= char ?f) 'forward)
5779 (t (setq err (format "%c unknown. " char))
5782 (let* ((file (expand-file-name file))
5783 (name (gnus-generate-new-group-name
5784 (gnus-group-prefixed-name
5785 (file-name-nondirectory file) '(nndoc "")))))
5786 (gnus-group-make-group
5787 (gnus-group-real-name name)
5788 (list 'nndoc (file-name-nondirectory file)
5789 (list 'nndoc-address file)
5790 (list 'nndoc-article-type (or type 'guess))))))
5792 (defun gnus-group-make-archive-group (&optional all)
5793 "Create the (ding) Gnus archive group of the most recent articles.
5794 Given a prefix, create a full group."
5796 (let ((group (gnus-group-prefixed-name
5797 (if all "ding.archives" "ding.recent") '(nndir ""))))
5798 (and (gnus-gethash group gnus-newsrc-hashtb)
5799 (error "Archive group already exists"))
5800 (gnus-group-make-group
5801 (gnus-group-real-name group)
5802 (list 'nndir (if all "hpc" "edu")
5803 (list 'nndir-directory
5804 (if all gnus-group-archive-directory
5805 gnus-group-recent-archive-directory))))))
5807 (defun gnus-group-make-directory-group (dir)
5808 "Create an nndir group.
5809 The user will be prompted for a directory. The contents of this
5810 directory will be used as a newsgroup. The directory should contain
5811 mail messages or news articles in files that have numeric names."
5813 (list (read-file-name "Create group from directory: ")))
5814 (or (file-exists-p dir) (error "No such directory"))
5815 (or (file-directory-p dir) (error "Not a directory"))
5819 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5821 (gnus-group-prefixed-name
5822 (concat (file-name-as-directory (directory-file-name dir))
5825 (setq ext (format "<%d>" (setq i (1+ i)))))
5826 (gnus-group-make-group
5827 (gnus-group-real-name group)
5828 (list 'nndir group (list 'nndir-directory dir)))))
5830 (defun gnus-group-make-kiboze-group (group address scores)
5831 "Create an nnkiboze group.
5832 The user will be prompted for a name, a regexp to match groups, and
5833 score file entries for articles to include in the group."
5836 (read-string "nnkiboze group name: ")
5837 (read-string "Source groups (regexp): ")
5838 (let ((headers (mapcar (lambda (group) (list group))
5839 '("subject" "from" "number" "date" "message-id"
5840 "references" "chars" "lines" "xref"
5841 "followup" "all" "body" "head")))
5842 scores header regexp regexps)
5843 (while (not (equal "" (setq header (completing-read
5844 "Match on header: " headers nil t))))
5846 (while (not (equal "" (setq regexp (read-string
5847 (format "Match on %s (string): "
5849 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5850 (setq scores (cons (cons header regexps) scores)))
5852 (gnus-group-make-group group "nnkiboze" address)
5853 (nnheader-temp-write (gnus-score-file-name (concat "nnkiboze:" group))
5854 (let (emacs-lisp-mode-hook)
5855 (pp scores (current-buffer)))))
5857 (defun gnus-group-add-to-virtual (n vgroup)
5858 "Add the current group to a virtual group."
5860 (list current-prefix-arg
5861 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5863 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5864 (error "%s is not an nnvirtual group" vgroup))
5865 (let* ((groups (gnus-group-process-prefix n))
5866 (method (gnus-info-method (gnus-get-info vgroup))))
5867 (setcar (cdr method)
5869 (nth 1 method) "\\|"
5872 (gnus-group-remove-mark s)
5873 (concat "\\(^" (regexp-quote s) "$\\)"))
5875 (gnus-group-position-point))
5877 (defun gnus-group-make-empty-virtual (group)
5878 "Create a new, fresh, empty virtual group."
5879 (interactive "sCreate new, empty virtual group: ")
5880 (let* ((method (list 'nnvirtual "^$"))
5881 (pgroup (gnus-group-prefixed-name group method)))
5882 ;; Check whether it exists already.
5883 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5884 (error "Group %s already exists." pgroup))
5885 ;; Subscribe the new group after the group on the current line.
5886 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5887 (gnus-group-update-group pgroup)
5889 (gnus-group-position-point)))
5891 (defun gnus-group-enter-directory (dir)
5892 "Enter an ephemeral nneething group."
5893 (interactive "DDirectory to read: ")
5894 (let* ((method (list 'nneething dir))
5895 (leaf (gnus-group-prefixed-name
5896 (file-name-nondirectory (directory-file-name dir))
5898 (name (gnus-generate-new-group-name leaf)))
5899 (let ((nneething-read-only t))
5900 (or (gnus-group-read-ephemeral-group
5902 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5904 (error "Couldn't enter %s" dir)))))
5906 ;; Group sorting commands
5907 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5909 (defun gnus-group-sort-groups (func &optional reverse)
5910 "Sort the group buffer according to FUNC.
5911 If REVERSE, reverse the sorting order."
5912 (interactive (list gnus-group-sort-function
5913 current-prefix-arg))
5915 ((not (listp func)) func)
5917 ((= 1 (length func)) (car func))
5919 ,(gnus-make-sort-function
5920 (reverse func)))))))
5921 ;; We peel off the dummy group from the alist.
5923 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5924 (pop gnus-newsrc-alist))
5926 (setq gnus-newsrc-alist
5927 (sort gnus-newsrc-alist func))
5929 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5930 ;; Regenerate the hash table.
5931 (gnus-make-hashtable-from-newsrc-alist)
5932 (gnus-group-list-groups))))
5934 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5935 "Sort the group buffer alphabetically by group name.
5936 If REVERSE, sort in reverse order."
5938 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5940 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5941 "Sort the group buffer by number of unread articles.
5942 If REVERSE, sort in reverse order."
5944 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5946 (defun gnus-group-sort-groups-by-level (&optional reverse)
5947 "Sort the group buffer by group level.
5948 If REVERSE, sort in reverse order."
5950 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5952 (defun gnus-group-sort-groups-by-score (&optional reverse)
5953 "Sort the group buffer by group score.
5954 If REVERSE, sort in reverse order."
5956 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5958 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5959 "Sort the group buffer by group rank.
5960 If REVERSE, sort in reverse order."
5962 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5964 (defun gnus-group-sort-groups-by-method (&optional reverse)
5965 "Sort the group buffer alphabetically by backend name.
5966 If REVERSE, sort in reverse order."
5968 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
5970 (defun gnus-group-sort-by-alphabet (info1 info2)
5971 "Sort alphabetically."
5972 (string< (gnus-info-group info1) (gnus-info-group info2)))
5974 (defun gnus-group-sort-by-unread (info1 info2)
5975 "Sort by number of unread articles."
5976 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
5977 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
5978 (< (or (and (numberp n1) n1) 0)
5979 (or (and (numberp n2) n2) 0))))
5981 (defun gnus-group-sort-by-level (info1 info2)
5983 (< (gnus-info-level info1) (gnus-info-level info2)))
5985 (defun gnus-group-sort-by-method (info1 info2)
5986 "Sort alphabetically by backend name."
5987 (string< (symbol-name (car (gnus-find-method-for-group
5988 (gnus-info-group info1) info1)))
5989 (symbol-name (car (gnus-find-method-for-group
5990 (gnus-info-group info2) info2)))))
5992 (defun gnus-group-sort-by-score (info1 info2)
5993 "Sort by group score."
5994 (< (gnus-info-score info1) (gnus-info-score info2)))
5996 (defun gnus-group-sort-by-rank (info1 info2)
5997 "Sort by level and score."
5998 (let ((level1 (gnus-info-level info1))
5999 (level2 (gnus-info-level info2)))
6000 (or (< level1 level2)
6001 (and (= level1 level2)
6002 (> (gnus-info-score info1) (gnus-info-score info2))))))
6004 ;; Group catching up.
6006 (defun gnus-group-clear-data (n)
6007 "Clear all marks and read ranges from the current group."
6009 (let ((groups (gnus-group-process-prefix n))
6011 (while (setq group (pop groups))
6012 (setq info (gnus-get-info group))
6013 (gnus-info-set-read info nil)
6014 (when (gnus-info-marks info)
6015 (gnus-info-set-marks info nil))
6016 (gnus-get-unread-articles-in-group info (gnus-active group) t)
6017 (when (gnus-group-goto-group group)
6018 (gnus-group-remove-mark group)
6019 (gnus-group-update-group-line)))))
6021 (defun gnus-group-catchup-current (&optional n all)
6022 "Mark all articles not marked as unread in current newsgroup as read.
6023 If prefix argument N is numeric, the ARG next newsgroups will be
6024 caught up. If ALL is non-nil, marked articles will also be marked as
6025 read. Cross references (Xref: header) of articles are ignored.
6026 The difference between N and actual number of newsgroups that were
6027 caught up is returned."
6029 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
6033 "Do you really want to mark all articles as read? "
6034 "Mark all unread articles as read? "))))
6036 (let ((groups (gnus-group-process-prefix n))
6039 ;; Virtual groups have to be given special treatment.
6040 (let ((method (gnus-find-method-for-group (car groups))))
6041 (if (eq 'nnvirtual (car method))
6042 (nnvirtual-catchup-group
6043 (gnus-group-real-name (car groups)) (nth 1 method) all)))
6044 (gnus-group-remove-mark (car groups))
6045 (if (>= (gnus-group-group-level) gnus-level-zombie)
6046 (gnus-message 2 "Dead groups can't be caught up")
6048 (gnus-group-goto-group (car groups))
6049 (gnus-group-catchup (car groups) all))
6050 (gnus-group-update-group-line)
6051 (setq ret (1+ ret))))
6052 (setq groups (cdr groups)))
6053 (gnus-group-next-unread-group 1)
6056 (defun gnus-group-catchup-current-all (&optional n)
6057 "Mark all articles in current newsgroup as read.
6058 Cross references (Xref: header) of articles are ignored."
6060 (gnus-group-catchup-current n 'all))
6062 (defun gnus-group-catchup (group &optional all)
6063 "Mark all articles in GROUP as read.
6064 If ALL is non-nil, all articles are marked as read.
6065 The return value is the number of articles that were marked as read,
6066 or nil if no action could be taken."
6067 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
6069 ;; Do the updating only if the newsgroup isn't killed.
6070 (if (not (numberp (car entry)))
6071 (gnus-message 1 "Can't catch up; non-active group")
6072 ;; Do auto-expirable marks if that's required.
6073 (when (gnus-group-auto-expirable-p group)
6074 (gnus-add-marked-articles
6075 group 'expire (gnus-list-of-unread-articles group))
6077 (let ((marks (nth 3 (nth 2 entry))))
6078 (gnus-add-marked-articles
6079 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
6080 (gnus-add-marked-articles
6081 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
6083 (gnus-update-read-articles group nil)
6084 ;; Also nix out the lists of marks and dormants.
6086 (gnus-add-marked-articles group 'tick nil nil 'force)
6087 (gnus-add-marked-articles group 'dormant nil nil 'force))
6088 (run-hooks 'gnus-group-catchup-group-hook)
6091 (defun gnus-group-expire-articles (&optional n)
6092 "Expire all expirable articles in the current newsgroup."
6094 (let ((groups (gnus-group-process-prefix n))
6097 (error "No groups to expire"))
6098 (while (setq group (pop groups))
6099 (gnus-group-remove-mark group)
6100 (when (gnus-check-backend-function 'request-expire-articles group)
6101 (gnus-message 6 "Expiring articles in %s..." group)
6102 (let* ((info (gnus-get-info group))
6103 (expirable (if (gnus-group-total-expirable-p group)
6104 (cons nil (gnus-list-of-read-articles group))
6105 (assq 'expire (gnus-info-marks info))))
6106 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
6110 (gnus-compress-sequence
6112 ;; We set the expiry variables to the groupp
6114 (let ((nnmail-expiry-wait-function nil)
6115 (nnmail-expiry-wait expiry-wait))
6116 (gnus-request-expire-articles
6117 (gnus-uncompress-sequence (cdr expirable)) group))
6118 ;; Just expire using the normal expiry values.
6119 (gnus-request-expire-articles
6120 (gnus-uncompress-sequence (cdr expirable)) group)))))
6121 (gnus-message 6 "Expiring articles in %s...done" group)))
6122 (gnus-group-position-point))))
6124 (defun gnus-group-expire-all-groups ()
6125 "Expire all expirable articles in all newsgroups."
6128 (gnus-message 5 "Expiring...")
6129 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
6130 (cdr gnus-newsrc-alist))))
6131 (gnus-group-expire-articles nil)))
6132 (gnus-group-position-point)
6133 (gnus-message 5 "Expiring...done"))
6135 (defun gnus-group-set-current-level (n level)
6136 "Set the level of the next N groups to LEVEL."
6141 (let ((s (read-string
6142 (format "Level (default %s): "
6143 (or (gnus-group-group-level)
6144 gnus-level-default-subscribed)))))
6145 (if (string-match "^\\s-*$" s)
6146 (int-to-string (or (gnus-group-group-level)
6147 gnus-level-default-subscribed))
6149 (or (and (>= level 1) (<= level gnus-level-killed))
6150 (error "Illegal level: %d" level))
6151 (let ((groups (gnus-group-process-prefix n))
6153 (while (setq group (pop groups))
6154 (gnus-group-remove-mark group)
6155 (gnus-message 6 "Changed level of %s from %d to %d"
6156 group (or (gnus-group-group-level) gnus-level-killed)
6158 (gnus-group-change-level
6159 group level (or (gnus-group-group-level) gnus-level-killed))
6160 (gnus-group-update-group-line)))
6161 (gnus-group-position-point))
6163 (defun gnus-group-unsubscribe-current-group (&optional n)
6164 "Toggle subscription of the current group.
6165 If given numerical prefix, toggle the N next groups."
6167 (let ((groups (gnus-group-process-prefix n))
6170 (setq group (car groups)
6171 groups (cdr groups))
6172 (gnus-group-remove-mark group)
6173 (gnus-group-unsubscribe-group
6174 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
6175 gnus-level-default-unsubscribed
6176 gnus-level-default-subscribed) t)
6177 (gnus-group-update-group-line))
6178 (gnus-group-next-group 1)))
6180 (defun gnus-group-unsubscribe-group (group &optional level silent)
6181 "Toggle subscription to GROUP.
6182 Killed newsgroups are subscribed. If SILENT, don't try to update the
6185 (list (completing-read
6186 "Group: " gnus-active-hashtb nil
6187 (gnus-read-active-file-p)
6189 'gnus-group-history)))
6190 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6192 ((string-match "^[ \t]$" group)
6193 (error "Empty group name"))
6195 ;; Toggle subscription flag.
6196 (gnus-group-change-level
6197 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6198 gnus-level-subscribed)
6199 (1+ gnus-level-subscribed)
6200 gnus-level-default-subscribed)))
6202 (gnus-group-update-group group)))
6203 ((and (stringp group)
6204 (or (not (gnus-read-active-file-p))
6205 (gnus-active group)))
6206 ;; Add new newsgroup.
6207 (gnus-group-change-level
6209 (if level level gnus-level-default-subscribed)
6210 (or (and (member group gnus-zombie-list)
6213 (and (gnus-group-group-name)
6214 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6216 (gnus-group-update-group group)))
6217 (t (error "No such newsgroup: %s" group)))
6218 (gnus-group-position-point)))
6220 (defun gnus-group-transpose-groups (n)
6221 "Move the current newsgroup up N places.
6222 If given a negative prefix, move down instead. The difference between
6223 N and the number of steps taken is returned."
6225 (or (gnus-group-group-name)
6226 (error "No group on current line"))
6227 (gnus-group-kill-group 1)
6229 (forward-line (- n))
6230 (gnus-group-yank-group)
6231 (gnus-group-position-point)))
6233 (defun gnus-group-kill-all-zombies ()
6234 "Kill all zombie newsgroups."
6236 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6237 (setq gnus-zombie-list nil)
6238 (gnus-group-list-groups))
6240 (defun gnus-group-kill-region (begin end)
6241 "Kill newsgroups in current region (excluding current point).
6242 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6257 (beginning-of-line) ;Important when LINES < 1
6258 (gnus-group-kill-group lines)))
6260 (defun gnus-group-kill-group (&optional n discard)
6261 "Kill the next N groups.
6262 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6263 However, only groups that were alive can be yanked; already killed
6264 groups or zombie groups can't be yanked.
6265 The return value is the name of the group that was killed, or a list
6268 (let ((buffer-read-only nil)
6269 (groups (gnus-group-process-prefix n))
6270 group entry level out)
6271 (if (< (length groups) 10)
6272 ;; This is faster when there are few groups.
6274 (push (setq group (pop groups)) out)
6275 (gnus-group-remove-mark group)
6276 (setq level (gnus-group-group-level))
6278 (when (and (not discard)
6279 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6280 (push (cons (car entry) (nth 2 entry))
6281 gnus-list-of-killed-groups))
6282 (gnus-group-change-level
6283 (if entry entry group) gnus-level-killed (if entry nil level)))
6284 ;; If there are lots and lots of groups to be killed, we use
6285 ;; this thing instead.
6287 (setq groups (nreverse groups))
6289 (gnus-group-remove-mark (setq group (pop groups)))
6292 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6293 (push (cons (car entry) (nth 2 entry))
6294 gnus-list-of-killed-groups)
6295 (setcdr (cdr entry) (cdddr entry)))
6296 ((member group gnus-zombie-list)
6297 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6298 (gnus-make-hashtable-from-newsrc-alist)))
6300 (gnus-group-position-point)
6301 (if (< (length out) 2) (car out) (nreverse out))))
6303 (defun gnus-group-yank-group (&optional arg)
6304 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6305 inserting it before the current newsgroup. The numeric ARG specifies
6306 how many newsgroups are to be yanked. The name of the newsgroup yanked
6307 is returned, or (if several groups are yanked) a list of yanked groups
6310 (setq arg (or arg 1))
6311 (let (info group prev out)
6312 (while (>= (decf arg) 0)
6313 (if (not (setq info (pop gnus-list-of-killed-groups)))
6314 (error "No more newsgroups to yank"))
6315 (push (setq group (nth 1 info)) out)
6316 ;; Find which newsgroup to insert this one before - search
6317 ;; backward until something suitable is found. If there are no
6318 ;; other newsgroups in this buffer, just make this newsgroup the
6320 (setq prev (gnus-group-group-name))
6321 (gnus-group-change-level
6322 info (gnus-info-level (cdr info)) gnus-level-killed
6323 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6325 (gnus-group-insert-group-line-info group))
6327 (gnus-group-position-point)
6328 (if (< (length out) 2) (car out) (nreverse out))))
6330 (defun gnus-group-kill-level (level)
6331 "Kill all groups that is on a certain LEVEL."
6332 (interactive "nKill all groups on level: ")
6334 ((= level gnus-level-zombie)
6335 (setq gnus-killed-list
6336 (nconc gnus-zombie-list gnus-killed-list))
6337 (setq gnus-zombie-list nil))
6338 ((and (< level gnus-level-zombie)
6340 (or gnus-expert-user
6343 "Do you really want to kill all groups on level %d? "
6345 (let* ((prev gnus-newsrc-alist)
6348 (if (= (gnus-info-level level) level)
6349 (setcdr prev (cdr alist))
6351 (setq alist (cdr alist)))
6352 (gnus-make-hashtable-from-newsrc-alist)
6353 (gnus-group-list-groups)))
6355 (error "Can't kill; illegal level: %d" level))))
6357 (defun gnus-group-list-all-groups (&optional arg)
6358 "List all newsgroups with level ARG or lower.
6359 Default is gnus-level-unsubscribed, which lists all subscribed and most
6360 unsubscribed groups."
6362 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6364 ;; Redefine this to list ALL killed groups if prefix arg used.
6365 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6366 (defun gnus-group-list-killed (&optional arg)
6367 "List all killed newsgroups in the group buffer.
6368 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6369 entail asking the server for the groups."
6371 ;; Find all possible killed newsgroups if arg.
6373 (gnus-get-killed-groups))
6374 (if (not gnus-killed-list)
6375 (gnus-message 6 "No killed groups")
6376 (let (gnus-group-list-mode)
6377 (funcall gnus-group-prepare-function
6378 gnus-level-killed t gnus-level-killed))
6379 (goto-char (point-min)))
6380 (gnus-group-position-point))
6382 (defun gnus-group-list-zombies ()
6383 "List all zombie newsgroups in the group buffer."
6385 (if (not gnus-zombie-list)
6386 (gnus-message 6 "No zombie groups")
6387 (let (gnus-group-list-mode)
6388 (funcall gnus-group-prepare-function
6389 gnus-level-zombie t gnus-level-zombie))
6390 (goto-char (point-min)))
6391 (gnus-group-position-point))
6393 (defun gnus-group-list-active ()
6394 "List all groups that are available from the server(s)."
6396 ;; First we make sure that we have really read the active file.
6397 (unless (gnus-read-active-file-p)
6398 (let ((gnus-read-active-file t))
6399 (gnus-read-active-file)))
6400 ;; Find all groups and sort them.
6408 (setq list (cons (symbol-name sym) list))))
6412 (buffer-read-only nil))
6415 (gnus-group-insert-group-line-info (pop groups)))
6416 (goto-char (point-min))))
6418 (defun gnus-activate-all-groups (level)
6419 "Activate absolutely all groups."
6420 (interactive (list 7))
6421 (let ((gnus-activate-level level)
6422 (gnus-activate-foreign-newsgroups level))
6423 (gnus-group-get-new-news)))
6425 (defun gnus-group-get-new-news (&optional arg)
6426 "Get newly arrived articles.
6427 If ARG is a number, it specifies which levels you are interested in
6428 re-scanning. If ARG is non-nil and not a number, this will force
6429 \"hard\" re-reading of the active files from all servers."
6431 (run-hooks 'gnus-get-new-news-hook)
6432 ;; We might read in new NoCeM messages here.
6433 (when (and gnus-use-nocem
6435 (gnus-nocem-scan-groups))
6436 ;; If ARG is not a number, then we read the active file.
6437 (when (and arg (not (numberp arg)))
6438 (let ((gnus-read-active-file t))
6439 (gnus-read-active-file))
6442 (setq arg (gnus-group-default-level arg t))
6443 (if (and gnus-read-active-file (not arg))
6445 (gnus-read-active-file)
6446 (gnus-get-unread-articles arg))
6447 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6448 (gnus-get-unread-articles arg)))
6449 (run-hooks 'gnus-after-getting-new-news-hook)
6450 (gnus-group-list-groups))
6452 (defun gnus-group-get-new-news-this-group (&optional n)
6453 "Check for newly arrived news in the current group (and the N-1 next groups).
6454 The difference between N and the number of newsgroup checked is returned.
6455 If N is negative, this group and the N-1 previous groups will be checked."
6457 (let* ((groups (gnus-group-process-prefix n))
6458 (ret (if (numberp n) (- n (length groups)) 0))
6459 (beg (unless n (point)))
6461 (while (setq group (pop groups))
6462 (gnus-group-remove-mark group)
6463 (if (gnus-activate-group group 'scan)
6465 (gnus-get-unread-articles-in-group
6466 (gnus-get-info group) (gnus-active group) t)
6467 (unless (gnus-virtual-group-p group)
6468 (gnus-close-group group))
6469 (gnus-group-update-group group))
6470 (gnus-error 3 "%s error: %s" group (gnus-status-message group))))
6471 (when beg (goto-char beg))
6472 (when gnus-goto-next-group-when-activating
6473 (gnus-group-next-unread-group 1 t))
6474 (gnus-summary-position-point)
6477 (defun gnus-group-fetch-faq (group &optional faq-dir)
6478 "Fetch the FAQ for the current group."
6481 (gnus-group-real-name (gnus-group-group-name))
6482 (cond (current-prefix-arg
6484 "Faq dir: " (and (listp gnus-group-faq-directory)
6485 gnus-group-faq-directory))))))
6487 (setq faq-dir (if (listp gnus-group-faq-directory)
6488 (car gnus-group-faq-directory)
6489 gnus-group-faq-directory)))
6490 (or group (error "No group name given"))
6491 (let ((file (concat (file-name-as-directory faq-dir)
6492 (gnus-group-real-name group))))
6493 (if (not (file-exists-p file))
6494 (error "No such file: %s" file)
6497 (defun gnus-group-describe-group (force &optional group)
6498 "Display a description of the current newsgroup."
6499 (interactive (list current-prefix-arg (gnus-group-group-name)))
6500 (and force (setq gnus-description-hashtb nil))
6501 (let ((method (gnus-find-method-for-group group))
6503 (or group (error "No group name given"))
6504 (and (or (and gnus-description-hashtb
6505 ;; We check whether this group's method has been
6506 ;; queried for a description file.
6508 (gnus-group-prefixed-name "" method)
6509 gnus-description-hashtb))
6510 (setq desc (gnus-group-get-description group))
6511 (gnus-read-descriptions-file method))
6513 (or desc (gnus-gethash group gnus-description-hashtb)
6514 "No description available")))))
6516 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6517 (defun gnus-group-describe-all-groups (&optional force)
6518 "Pop up a buffer with descriptions of all newsgroups."
6520 (and force (setq gnus-description-hashtb nil))
6521 (if (not (or gnus-description-hashtb
6522 (gnus-read-all-descriptions-files)))
6523 (error "Couldn't request descriptions file"))
6524 (let ((buffer-read-only nil)
6530 (insert (format " *: %-20s %s\n" (symbol-name group)
6531 (symbol-value group)))
6532 (gnus-add-text-properties
6533 b (1+ b) (list 'gnus-group group
6534 'gnus-unread t 'gnus-marked nil
6535 'gnus-level (1+ gnus-level-subscribed))))
6536 gnus-description-hashtb)
6537 (goto-char (point-min))
6538 (gnus-group-position-point)))
6540 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6541 (defun gnus-group-apropos (regexp &optional search-description)
6542 "List all newsgroups that have names that match a regexp."
6543 (interactive "sGnus apropos (regexp): ")
6545 (obuf (current-buffer))
6547 ;; Go through all newsgroups that are known to Gnus.
6550 (and (symbol-name group)
6551 (string-match regexp (symbol-name group))
6552 (setq groups (cons (symbol-name group) groups))))
6554 ;; Also go through all descriptions that are known to Gnus.
6555 (when search-description
6558 (and (string-match regexp (symbol-value group))
6559 (gnus-active (symbol-name group))
6560 (setq groups (cons (symbol-name group) groups))))
6561 gnus-description-hashtb))
6563 (gnus-message 3 "No groups matched \"%s\"." regexp)
6564 ;; Print out all the groups.
6566 (pop-to-buffer "*Gnus Help*")
6567 (buffer-disable-undo (current-buffer))
6569 (setq groups (sort groups 'string<))
6571 ;; Groups may be entered twice into the list of groups.
6572 (if (not (string= (car groups) prev))
6574 (insert (setq prev (car groups)) "\n")
6575 (if (and gnus-description-hashtb
6576 (setq des (gnus-gethash (car groups)
6577 gnus-description-hashtb)))
6578 (insert " " des "\n"))))
6579 (setq groups (cdr groups)))
6580 (goto-char (point-min))))
6581 (pop-to-buffer obuf)))
6583 (defun gnus-group-description-apropos (regexp)
6584 "List all newsgroups that have names or descriptions that match a regexp."
6585 (interactive "sGnus description apropos (regexp): ")
6586 (if (not (or gnus-description-hashtb
6587 (gnus-read-all-descriptions-files)))
6588 (error "Couldn't request descriptions file"))
6589 (gnus-group-apropos regexp t))
6591 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6592 (defun gnus-group-list-matching (level regexp &optional all lowest)
6593 "List all groups with unread articles that match REGEXP.
6594 If the prefix LEVEL is non-nil, it should be a number that says which
6595 level to cut off listing groups.
6596 If ALL, also list groups with no unread articles.
6597 If LOWEST, don't list groups with level lower than LOWEST.
6599 This command may read the active file."
6600 (interactive "P\nsList newsgroups matching: ")
6601 ;; First make sure active file has been read.
6603 (>= (prefix-numeric-value level) gnus-level-killed))
6604 (gnus-get-killed-groups))
6605 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6606 all (or lowest 1) regexp)
6607 (goto-char (point-min))
6608 (gnus-group-position-point))
6610 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6611 "List all groups that match REGEXP.
6612 If the prefix LEVEL is non-nil, it should be a number that says which
6613 level to cut off listing groups.
6614 If LOWEST, don't list groups with level lower than LOWEST."
6615 (interactive "P\nsList newsgroups matching: ")
6616 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6618 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6619 (defun gnus-group-save-newsrc (&optional force)
6620 "Save the Gnus startup files.
6621 If FORCE, force saving whether it is necessary or not."
6623 (gnus-save-newsrc-file force))
6625 (defun gnus-group-restart (&optional arg)
6626 "Force Gnus to read the .newsrc file."
6628 (when (gnus-yes-or-no-p
6629 (format "Are you sure you want to read %s? "
6630 gnus-current-startup-file))
6631 (gnus-save-newsrc-file)
6632 (gnus-setup-news 'force)
6633 (gnus-group-list-groups arg)))
6635 (defun gnus-group-read-init-file ()
6636 "Read the Gnus elisp init file."
6638 (gnus-read-init-file))
6640 (defun gnus-group-check-bogus-groups (&optional silent)
6641 "Check bogus newsgroups.
6642 If given a prefix, don't ask for confirmation before removing a bogus
6645 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6646 (gnus-group-list-groups))
6648 (defun gnus-group-edit-global-kill (&optional article group)
6649 "Edit the global kill file.
6650 If GROUP, edit that local kill file instead."
6652 (setq gnus-current-kill-article article)
6653 (gnus-kill-file-edit-file group)
6656 (substitute-command-keys
6657 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6658 (if group "local" "global")))))
6660 (defun gnus-group-edit-local-kill (article group)
6661 "Edit a local kill file."
6662 (interactive (list nil (gnus-group-group-name)))
6663 (gnus-group-edit-global-kill article group))
6665 (defun gnus-group-force-update ()
6666 "Update `.newsrc' file."
6668 (gnus-save-newsrc-file))
6670 (defun gnus-group-suspend ()
6671 "Suspend the current Gnus session.
6672 In fact, cleanup buffers except for group mode buffer.
6673 The hook gnus-suspend-gnus-hook is called before actually suspending."
6675 (run-hooks 'gnus-suspend-gnus-hook)
6676 ;; Kill Gnus buffers except for group mode buffer.
6677 (let ((group-buf (get-buffer gnus-group-buffer)))
6678 ;; Do this on a separate list in case the user does a ^G before we finish
6679 (let ((gnus-buffer-list
6680 (delq group-buf (delq gnus-dribble-buffer
6681 (append gnus-buffer-list nil)))))
6682 (while gnus-buffer-list
6683 (gnus-kill-buffer (car gnus-buffer-list))
6684 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6687 (setq gnus-buffer-list (list group-buf))
6688 (bury-buffer group-buf)
6689 (delete-windows-on group-buf t)))))
6691 (defun gnus-group-clear-dribble ()
6692 "Clear all information from the dribble buffer."
6694 (gnus-dribble-clear)
6695 (gnus-message 7 "Cleared dribble buffer"))
6697 (defun gnus-group-exit ()
6698 "Quit reading news after updating .newsrc.eld and .newsrc.
6699 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6702 (or noninteractive ;For gnus-batch-kill
6703 (not gnus-interactive-exit) ;Without confirmation
6705 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6706 (run-hooks 'gnus-exit-gnus-hook)
6707 ;; Offer to save data from non-quitted summary buffers.
6708 (gnus-offer-save-summaries)
6709 ;; Save the newsrc file(s).
6710 (gnus-save-newsrc-file)
6712 (gnus-close-backends)
6713 ;; Reset everything.
6715 ;; Allow the user to do things after cleaning up.
6716 (run-hooks 'gnus-after-exiting-gnus-hook)))
6718 (defun gnus-close-backends ()
6719 ;; Send a close request to all backends that support such a request.
6720 (let ((methods gnus-valid-select-methods)
6723 (if (fboundp (setq func (intern (concat (caar methods)
6724 "-request-close"))))
6726 (setq methods (cdr methods)))))
6728 (defun gnus-group-quit ()
6729 "Quit reading news without updating .newsrc.eld or .newsrc.
6730 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6732 (when (or noninteractive ;For gnus-batch-kill
6733 (zerop (buffer-size))
6734 (not (gnus-server-opened gnus-select-method))
6736 (not gnus-current-startup-file)
6738 (format "Quit reading news without saving %s? "
6739 (file-name-nondirectory gnus-current-startup-file))))
6740 (run-hooks 'gnus-exit-gnus-hook)
6741 (if gnus-use-full-window
6742 (delete-other-windows)
6743 (gnus-remove-some-windows))
6745 (gnus-close-backends)
6747 ;; Allow the user to do things after cleaning up.
6748 (run-hooks 'gnus-after-exiting-gnus-hook)))
6750 (defun gnus-offer-save-summaries ()
6751 "Offer to save all active summary buffers."
6753 (let ((buflist (buffer-list))
6755 ;; Go through all buffers and find all summaries.
6757 (and (setq bufname (buffer-name (car buflist)))
6758 (string-match "Summary" bufname)
6760 (set-buffer bufname)
6761 ;; We check that this is, indeed, a summary buffer.
6762 (and (eq major-mode 'gnus-summary-mode)
6763 ;; Also make sure this isn't bogus.
6764 gnus-newsgroup-prepared))
6765 (push bufname buffers))
6766 (setq buflist (cdr buflist)))
6767 ;; Go through all these summary buffers and offer to save them.
6770 "Update summary buffer %s? "
6771 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6774 (defun gnus-group-describe-briefly ()
6775 "Give a one line description of the group mode commands."
6777 (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")))
6779 (defun gnus-group-browse-foreign-server (method)
6780 "Browse a foreign news server.
6781 If called interactively, this function will ask for a select method
6782 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6783 If not, METHOD should be a list where the first element is the method
6784 and the second element is the address."
6786 (list (let ((how (completing-read
6788 (append gnus-valid-select-methods gnus-server-alist)
6789 nil t (cons "nntp" 0) 'gnus-method-history)))
6790 ;; We either got a backend name or a virtual server name.
6791 ;; If the first, we also need an address.
6792 (if (assoc how gnus-valid-select-methods)
6794 ;; Suggested by mapjph@bath.ac.uk.
6797 (mapcar (lambda (server) (list server))
6798 gnus-secondary-servers)))
6799 ;; We got a server name, so we find the method.
6800 (gnus-server-to-method how)))))
6801 (gnus-browse-foreign-server method))
6805 ;;; Gnus summary mode
6808 (defvar gnus-summary-mode-map nil)
6810 (put 'gnus-summary-mode 'mode-class 'special)
6812 (unless gnus-summary-mode-map
6813 (setq gnus-summary-mode-map (make-keymap))
6814 (suppress-keymap gnus-summary-mode-map)
6816 ;; Non-orthogonal keys
6818 (gnus-define-keys gnus-summary-mode-map
6819 " " gnus-summary-next-page
6820 "\177" gnus-summary-prev-page
6821 [delete] gnus-summary-prev-page
6822 "\r" gnus-summary-scroll-up
6823 "n" gnus-summary-next-unread-article
6824 "p" gnus-summary-prev-unread-article
6825 "N" gnus-summary-next-article
6826 "P" gnus-summary-prev-article
6827 "\M-\C-n" gnus-summary-next-same-subject
6828 "\M-\C-p" gnus-summary-prev-same-subject
6829 "\M-n" gnus-summary-next-unread-subject
6830 "\M-p" gnus-summary-prev-unread-subject
6831 "." gnus-summary-first-unread-article
6832 "," gnus-summary-best-unread-article
6833 "\M-s" gnus-summary-search-article-forward
6834 "\M-r" gnus-summary-search-article-backward
6835 "<" gnus-summary-beginning-of-article
6836 ">" gnus-summary-end-of-article
6837 "j" gnus-summary-goto-article
6838 "^" gnus-summary-refer-parent-article
6839 "\M-^" gnus-summary-refer-article
6840 "u" gnus-summary-tick-article-forward
6841 "!" gnus-summary-tick-article-forward
6842 "U" gnus-summary-tick-article-backward
6843 "d" gnus-summary-mark-as-read-forward
6844 "D" gnus-summary-mark-as-read-backward
6845 "E" gnus-summary-mark-as-expirable
6846 "\M-u" gnus-summary-clear-mark-forward
6847 "\M-U" gnus-summary-clear-mark-backward
6848 "k" gnus-summary-kill-same-subject-and-select
6849 "\C-k" gnus-summary-kill-same-subject
6850 "\M-\C-k" gnus-summary-kill-thread
6851 "\M-\C-l" gnus-summary-lower-thread
6852 "e" gnus-summary-edit-article
6853 "#" gnus-summary-mark-as-processable
6854 "\M-#" gnus-summary-unmark-as-processable
6855 "\M-\C-t" gnus-summary-toggle-threads
6856 "\M-\C-s" gnus-summary-show-thread
6857 "\M-\C-h" gnus-summary-hide-thread
6858 "\M-\C-f" gnus-summary-next-thread
6859 "\M-\C-b" gnus-summary-prev-thread
6860 "\M-\C-u" gnus-summary-up-thread
6861 "\M-\C-d" gnus-summary-down-thread
6862 "&" gnus-summary-execute-command
6863 "c" gnus-summary-catchup-and-exit
6864 "\C-w" gnus-summary-mark-region-as-read
6865 "\C-t" gnus-summary-toggle-truncation
6866 "?" gnus-summary-mark-as-dormant
6867 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6868 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6869 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6870 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6871 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6872 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6873 "=" gnus-summary-expand-window
6874 "\C-x\C-s" gnus-summary-reselect-current-group
6875 "\M-g" gnus-summary-rescan-group
6876 "w" gnus-summary-stop-page-breaking
6877 "\C-c\C-r" gnus-summary-caesar-message
6878 "\M-t" gnus-summary-toggle-mime
6879 "f" gnus-summary-followup
6880 "F" gnus-summary-followup-with-original
6881 "C" gnus-summary-cancel-article
6882 "r" gnus-summary-reply
6883 "R" gnus-summary-reply-with-original
6884 "\C-c\C-f" gnus-summary-mail-forward
6885 "o" gnus-summary-save-article
6886 "\C-o" gnus-summary-save-article-mail
6887 "|" gnus-summary-pipe-output
6888 "\M-k" gnus-summary-edit-local-kill
6889 "\M-K" gnus-summary-edit-global-kill
6891 "\C-c\C-d" gnus-summary-describe-group
6892 "q" gnus-summary-exit
6893 "Q" gnus-summary-exit-no-update
6894 "\C-c\C-i" gnus-info-find-node
6895 gnus-mouse-2 gnus-mouse-pick-article
6896 "m" gnus-summary-mail-other-window
6897 "a" gnus-summary-post-news
6898 "x" gnus-summary-limit-to-unread
6899 "s" gnus-summary-isearch-article
6900 "t" gnus-article-hide-headers
6901 "g" gnus-summary-show-article
6902 "l" gnus-summary-goto-last-article
6903 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6904 "\C-d" gnus-summary-enter-digest-group
6906 "*" gnus-cache-enter-article
6907 "\M-*" gnus-cache-remove-article
6908 "\M-&" gnus-summary-universal-argument
6909 "\C-l" gnus-recenter
6910 "I" gnus-summary-increase-score
6911 "L" gnus-summary-lower-score
6913 "V" gnus-summary-score-map
6914 "X" gnus-uu-extract-map
6915 "S" gnus-summary-send-map)
6917 ;; Sort of orthogonal keymap
6918 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6919 "t" gnus-summary-tick-article-forward
6920 "!" gnus-summary-tick-article-forward
6921 "d" gnus-summary-mark-as-read-forward
6922 "r" gnus-summary-mark-as-read-forward
6923 "c" gnus-summary-clear-mark-forward
6924 " " gnus-summary-clear-mark-forward
6925 "e" gnus-summary-mark-as-expirable
6926 "x" gnus-summary-mark-as-expirable
6927 "?" gnus-summary-mark-as-dormant
6928 "b" gnus-summary-set-bookmark
6929 "B" gnus-summary-remove-bookmark
6930 "#" gnus-summary-mark-as-processable
6931 "\M-#" gnus-summary-unmark-as-processable
6932 "S" gnus-summary-limit-include-expunged
6933 "C" gnus-summary-catchup
6934 "H" gnus-summary-catchup-to-here
6935 "\C-c" gnus-summary-catchup-all
6936 "k" gnus-summary-kill-same-subject-and-select
6937 "K" gnus-summary-kill-same-subject
6938 "P" gnus-uu-mark-map)
6940 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6941 "c" gnus-summary-clear-above
6942 "u" gnus-summary-tick-above
6943 "m" gnus-summary-mark-above
6944 "k" gnus-summary-kill-below)
6946 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6947 "/" gnus-summary-limit-to-subject
6948 "n" gnus-summary-limit-to-articles
6949 "w" gnus-summary-pop-limit
6950 "s" gnus-summary-limit-to-subject
6951 "a" gnus-summary-limit-to-author
6952 "u" gnus-summary-limit-to-unread
6953 "m" gnus-summary-limit-to-marks
6954 "v" gnus-summary-limit-to-score
6955 "D" gnus-summary-limit-include-dormant
6956 "d" gnus-summary-limit-exclude-dormant
6957 ;; "t" gnus-summary-limit-exclude-thread
6958 "E" gnus-summary-limit-include-expunged
6959 "c" gnus-summary-limit-exclude-childless-dormant
6960 "C" gnus-summary-limit-mark-excluded-as-read)
6962 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
6963 "n" gnus-summary-next-unread-article
6964 "p" gnus-summary-prev-unread-article
6965 "N" gnus-summary-next-article
6966 "P" gnus-summary-prev-article
6967 "\C-n" gnus-summary-next-same-subject
6968 "\C-p" gnus-summary-prev-same-subject
6969 "\M-n" gnus-summary-next-unread-subject
6970 "\M-p" gnus-summary-prev-unread-subject
6971 "f" gnus-summary-first-unread-article
6972 "b" gnus-summary-best-unread-article
6973 "j" gnus-summary-goto-article
6974 "g" gnus-summary-goto-subject
6975 "l" gnus-summary-goto-last-article
6976 "p" gnus-summary-pop-article)
6978 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
6979 "k" gnus-summary-kill-thread
6980 "l" gnus-summary-lower-thread
6981 "i" gnus-summary-raise-thread
6982 "T" gnus-summary-toggle-threads
6983 "t" gnus-summary-rethread-current
6984 "^" gnus-summary-reparent-thread
6985 "s" gnus-summary-show-thread
6986 "S" gnus-summary-show-all-threads
6987 "h" gnus-summary-hide-thread
6988 "H" gnus-summary-hide-all-threads
6989 "n" gnus-summary-next-thread
6990 "p" gnus-summary-prev-thread
6991 "u" gnus-summary-up-thread
6992 "o" gnus-summary-top-thread
6993 "d" gnus-summary-down-thread
6994 "#" gnus-uu-mark-thread
6995 "\M-#" gnus-uu-unmark-thread)
6997 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
6998 "c" gnus-summary-catchup-and-exit
6999 "C" gnus-summary-catchup-all-and-exit
7000 "E" gnus-summary-exit-no-update
7001 "Q" gnus-summary-exit
7002 "Z" gnus-summary-exit
7003 "n" gnus-summary-catchup-and-goto-next-group
7004 "R" gnus-summary-reselect-current-group
7005 "G" gnus-summary-rescan-group
7006 "N" gnus-summary-next-group
7007 "P" gnus-summary-prev-group)
7009 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
7010 " " gnus-summary-next-page
7011 "n" gnus-summary-next-page
7012 "\177" gnus-summary-prev-page
7013 [delete] gnus-summary-prev-page
7014 "p" gnus-summary-prev-page
7015 "\r" gnus-summary-scroll-up
7016 "<" gnus-summary-beginning-of-article
7017 ">" gnus-summary-end-of-article
7018 "b" gnus-summary-beginning-of-article
7019 "e" gnus-summary-end-of-article
7020 "^" gnus-summary-refer-parent-article
7021 "r" gnus-summary-refer-parent-article
7022 "R" gnus-summary-refer-references
7023 "g" gnus-summary-show-article
7024 "s" gnus-summary-isearch-article)
7026 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
7027 "b" gnus-article-add-buttons
7028 "B" gnus-article-add-buttons-to-head
7029 "o" gnus-article-treat-overstrike
7030 ;; "w" gnus-article-word-wrap
7031 "w" gnus-article-fill-cited-article
7032 "c" gnus-article-remove-cr
7033 "L" gnus-article-remove-trailing-blank-lines
7034 "q" gnus-article-de-quoted-unreadable
7035 "f" gnus-article-display-x-face
7036 "l" gnus-summary-stop-page-breaking
7037 "r" gnus-summary-caesar-message
7038 "t" gnus-article-hide-headers
7039 "v" gnus-summary-verbose-headers
7040 "m" gnus-summary-toggle-mime)
7042 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
7043 "a" gnus-article-hide
7044 "h" gnus-article-hide-headers
7045 "b" gnus-article-hide-boring-headers
7046 "s" gnus-article-hide-signature
7047 "c" gnus-article-hide-citation
7048 "p" gnus-article-hide-pgp
7049 "\C-c" gnus-article-hide-citation-maybe)
7051 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
7052 "a" gnus-article-highlight
7053 "h" gnus-article-highlight-headers
7054 "c" gnus-article-highlight-citation
7055 "s" gnus-article-highlight-signature)
7057 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
7058 "z" gnus-article-date-ut
7059 "u" gnus-article-date-ut
7060 "l" gnus-article-date-local
7061 "e" gnus-article-date-lapsed
7062 "o" gnus-article-date-original)
7064 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
7066 "f" gnus-summary-fetch-faq
7067 "d" gnus-summary-describe-group
7068 "h" gnus-summary-describe-briefly
7069 "i" gnus-info-find-node)
7071 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
7072 "e" gnus-summary-expire-articles
7073 "\M-\C-e" gnus-summary-expire-articles-now
7074 "\177" gnus-summary-delete-article
7075 [delete] gnus-summary-delete-article
7076 "m" gnus-summary-move-article
7077 "r" gnus-summary-respool-article
7078 "w" gnus-summary-edit-article
7079 "c" gnus-summary-copy-article
7080 "B" gnus-summary-crosspost-article
7081 "q" gnus-summary-respool-query
7082 "i" gnus-summary-import-article)
7084 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
7085 "o" gnus-summary-save-article
7086 "m" gnus-summary-save-article-mail
7087 "r" gnus-summary-save-article-rmail
7088 "f" gnus-summary-save-article-file
7089 "b" gnus-summary-save-article-body-file
7090 "h" gnus-summary-save-article-folder
7091 "v" gnus-summary-save-article-vm
7092 "p" gnus-summary-pipe-output
7093 "s" gnus-soup-add-article)
7098 (defun gnus-summary-mode (&optional group)
7099 "Major mode for reading articles.
7101 All normal editing commands are switched off.
7102 \\<gnus-summary-mode-map>
7103 Each line in this buffer represents one article. To read an
7104 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
7105 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
7108 You can also post articles and send mail from this buffer. To
7109 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
7110 of an article, type `\\[gnus-summary-reply]'.
7112 There are approx. one gazillion commands you can execute in this
7113 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
7115 The following commands are available:
7117 \\{gnus-summary-mode-map}"
7119 (when (and menu-bar-mode
7120 (gnus-visual-p 'summary-menu 'menu))
7121 (gnus-summary-make-menu-bar))
7122 (kill-all-local-variables)
7123 (let ((locals gnus-summary-local-variables))
7125 (if (consp (car locals))
7127 (make-local-variable (caar locals))
7128 (set (caar locals) (eval (cdar locals))))
7129 (make-local-variable (car locals))
7130 (set (car locals) nil))
7131 (setq locals (cdr locals))))
7132 (gnus-make-thread-indent-array)
7133 (gnus-simplify-mode-line)
7134 (setq major-mode 'gnus-summary-mode)
7135 (setq mode-name "Summary")
7136 (make-local-variable 'minor-mode-alist)
7137 (use-local-map gnus-summary-mode-map)
7138 (buffer-disable-undo (current-buffer))
7139 (setq buffer-read-only t) ;Disable modification
7140 (setq truncate-lines t)
7141 (setq selective-display t)
7142 (setq selective-display-ellipses t) ;Display `...'
7143 (setq buffer-display-table gnus-summary-display-table)
7144 (setq gnus-newsgroup-name group)
7145 (make-local-variable 'gnus-summary-line-format)
7146 (make-local-variable 'gnus-summary-line-format-spec)
7147 (make-local-variable 'gnus-summary-mark-positions)
7148 (run-hooks 'gnus-summary-mode-hook))
7150 (defun gnus-summary-make-display-table ()
7151 ;; Change the display table. Odd characters have a tendency to mess
7152 ;; up nicely formatted displays - we make all possible glyphs
7153 ;; display only a single character.
7155 ;; We start from the standard display table, if any.
7156 (setq gnus-summary-display-table
7157 (or (copy-sequence standard-display-table)
7158 (make-display-table)))
7159 ;; Nix out all the control chars...
7161 (while (>= (setq i (1- i)) 0)
7162 (aset gnus-summary-display-table i [??])))
7163 ;; ... but not newline and cr, of course. (cr is necessary for the
7164 ;; selective display).
7165 (aset gnus-summary-display-table ?\n nil)
7166 (aset gnus-summary-display-table ?\r nil)
7167 ;; We nix out any glyphs over 126 that are not set already.
7169 (while (>= (setq i (1- i)) 127)
7170 ;; Only modify if the entry is nil.
7171 (or (aref gnus-summary-display-table i)
7172 (aset gnus-summary-display-table i [??])))))
7174 (defun gnus-summary-clear-local-variables ()
7175 (let ((locals gnus-summary-local-variables))
7177 (if (consp (car locals))
7178 (and (vectorp (caar locals))
7179 (set (caar locals) nil))
7180 (and (vectorp (car locals))
7181 (set (car locals) nil)))
7182 (setq locals (cdr locals)))))
7184 ;; Summary data functions.
7186 (defmacro gnus-data-number (data)
7189 (defmacro gnus-data-set-number (data number)
7190 `(setcar ,data ,number))
7192 (defmacro gnus-data-mark (data)
7195 (defmacro gnus-data-set-mark (data mark)
7196 `(setcar (nthcdr 1 ,data) ,mark))
7198 (defmacro gnus-data-pos (data)
7201 (defmacro gnus-data-set-pos (data pos)
7202 `(setcar (nthcdr 2 ,data) ,pos))
7204 (defmacro gnus-data-header (data)
7207 (defmacro gnus-data-level (data)
7210 (defmacro gnus-data-unread-p (data)
7211 `(= (nth 1 ,data) gnus-unread-mark))
7213 (defmacro gnus-data-pseudo-p (data)
7214 `(consp (nth 3 ,data)))
7216 (defmacro gnus-data-find (number)
7217 `(assq ,number gnus-newsgroup-data))
7219 (defmacro gnus-data-find-list (number &optional data)
7220 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7221 (memq (assq ,number bdata)
7224 (defmacro gnus-data-make (number mark pos header level)
7225 `(list ,number ,mark ,pos ,header ,level))
7227 (defun gnus-data-enter (after-article number mark pos header level offset)
7228 (let ((data (gnus-data-find-list after-article)))
7229 (or data (error "No such article: %d" after-article))
7230 (setcdr data (cons (gnus-data-make number mark pos header level)
7232 (setq gnus-newsgroup-data-reverse nil)
7233 (gnus-data-update-list (cddr data) offset)))
7235 (defun gnus-data-enter-list (after-article list &optional offset)
7237 (let ((data (and after-article (gnus-data-find-list after-article)))
7239 (or data (not after-article) (error "No such article: %d" after-article))
7240 ;; Find the last element in the list to be spliced into the main
7243 (setq list (cdr list)))
7246 (setcdr list gnus-newsgroup-data)
7247 (setq gnus-newsgroup-data ilist)
7248 (and offset (gnus-data-update-list (cdr list) offset)))
7249 (setcdr list (cdr data))
7251 (and offset (gnus-data-update-list (cdr data) offset)))
7252 (setq gnus-newsgroup-data-reverse nil))))
7254 (defun gnus-data-remove (article &optional offset)
7255 (let ((data gnus-newsgroup-data))
7256 (if (= (gnus-data-number (car data)) article)
7257 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7258 gnus-newsgroup-data-reverse nil)
7260 (and (= (gnus-data-number (cadr data)) article)
7262 (setcdr data (cddr data))
7263 (and offset (gnus-data-update-list (cdr data) offset))
7265 gnus-newsgroup-data-reverse nil)))
7266 (setq data (cdr data))))))
7268 (defmacro gnus-data-list (backward)
7270 (or gnus-newsgroup-data-reverse
7271 (setq gnus-newsgroup-data-reverse
7272 (reverse gnus-newsgroup-data)))
7273 gnus-newsgroup-data))
7275 (defun gnus-data-update-list (data offset)
7276 "Add OFFSET to the POS of all data entries in DATA."
7278 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7279 (setq data (cdr data))))
7281 (defun gnus-data-compute-positions ()
7282 "Compute the positions of all articles."
7283 (let ((data gnus-newsgroup-data)
7286 (when (setq pos (text-property-any
7287 (point-min) (point-max)
7288 'gnus-number (gnus-data-number (car data))))
7289 (gnus-data-set-pos (car data) (+ pos 3)))
7290 (setq data (cdr data)))))
7292 (defun gnus-summary-article-pseudo-p (article)
7293 "Say whether this article is a pseudo article or not."
7294 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7296 (defun gnus-article-parent-p (number)
7297 "Say whether this article is a parent or not."
7298 (let ((data (gnus-data-find-list number)))
7299 (and (cdr data) ; There has to be an article after...
7300 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7301 (gnus-data-level (nth 1 data))))))
7303 (defun gnus-article-children (number)
7304 "Return a list of all children to NUMBER."
7305 (let* ((data (gnus-data-find-list number))
7306 (level (gnus-data-level (car data)))
7308 (setq data (cdr data))
7310 (= (gnus-data-level (car data)) (1+ level)))
7311 (push (gnus-data-number (car data)) children)
7312 (setq data (cdr data)))
7315 (defmacro gnus-summary-skip-intangible ()
7316 "If the current article is intangible, then jump to a different article."
7317 '(let ((to (get-text-property (point) 'gnus-intangible)))
7318 (and to (gnus-summary-goto-subject to))))
7320 (defmacro gnus-summary-article-intangible-p ()
7321 "Say whether this article is intangible or not."
7322 '(get-text-property (point) 'gnus-intangible))
7324 ;; Some summary mode macros.
7326 (defmacro gnus-summary-article-number ()
7327 "The article number of the article on the current line.
7328 If there isn's an article number here, then we return the current
7331 (gnus-summary-skip-intangible)
7332 (or (get-text-property (point) 'gnus-number)
7333 (gnus-summary-last-subject))))
7335 (defmacro gnus-summary-article-header (&optional number)
7336 `(gnus-data-header (gnus-data-find
7337 ,(or number '(gnus-summary-article-number)))))
7339 (defmacro gnus-summary-thread-level (&optional number)
7340 `(if (and (eq gnus-summary-make-false-root 'dummy)
7341 (get-text-property (point) 'gnus-intangible))
7343 (gnus-data-level (gnus-data-find
7344 ,(or number '(gnus-summary-article-number))))))
7346 (defmacro gnus-summary-article-mark (&optional number)
7347 `(gnus-data-mark (gnus-data-find
7348 ,(or number '(gnus-summary-article-number)))))
7350 (defmacro gnus-summary-article-pos (&optional number)
7351 `(gnus-data-pos (gnus-data-find
7352 ,(or number '(gnus-summary-article-number)))))
7354 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7355 (defmacro gnus-summary-article-subject (&optional number)
7356 "Return current subject string or nil if nothing."
7359 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7360 '(gnus-data-header (assq (gnus-summary-article-number)
7361 gnus-newsgroup-data)))))
7364 (mail-header-subject headers))))
7366 (defmacro gnus-summary-article-score (&optional number)
7367 "Return current article score."
7368 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7369 gnus-newsgroup-scored))
7370 gnus-summary-default-score 0))
7372 (defun gnus-summary-article-children (&optional number)
7373 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7374 (level (gnus-data-level (car data)))
7376 (while (and (setq data (cdr data))
7377 (> (setq l (gnus-data-level (car data))) level))
7378 (and (= (1+ level) l)
7379 (setq children (cons (gnus-data-number (car data))
7381 (nreverse children)))
7383 (defun gnus-summary-article-parent (&optional number)
7384 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7385 (gnus-data-list t)))
7386 (level (gnus-data-level (car data))))
7388 () ; This is a root.
7389 ;; We search until we find an article with a level less than
7390 ;; this one. That function has to be the parent.
7391 (while (and (setq data (cdr data))
7392 (not (< (gnus-data-level (car data)) level))))
7393 (and data (gnus-data-number (car data))))))
7395 (defun gnus-unread-mark-p (mark)
7396 "Say whether MARK is the unread mark."
7397 (= mark gnus-unread-mark))
7399 (defun gnus-read-mark-p (mark)
7400 "Say whether MARK is one of the marks that mark as read.
7401 This is all marks except unread, ticked, dormant, and expirable."
7402 (not (or (= mark gnus-unread-mark)
7403 (= mark gnus-ticked-mark)
7404 (= mark gnus-dormant-mark)
7405 (= mark gnus-expirable-mark))))
7407 ;; Saving hidden threads.
7409 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
7410 (put 'gnus-save-hidden-threads 'lisp-indent-hook 0)
7411 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
7413 (defmacro gnus-save-hidden-threads (&rest forms)
7414 "Save hidden threads, eval FORMS, and restore the hidden threads."
7415 (let ((config (make-symbol "config")))
7416 `(let ((,config (gnus-hidden-threads-configuration)))
7420 (gnus-restore-hidden-threads-configuration ,config)))))
7422 (defun gnus-hidden-threads-configuration ()
7423 "Return the current hidden threads configuration."
7426 (goto-char (point-min))
7427 (while (search-forward "\r" nil t)
7428 (push (1- (point)) config))
7431 (defun gnus-restore-hidden-threads-configuration (config)
7432 "Restore hidden threads configuration from CONFIG."
7433 (let (point buffer-read-only)
7434 (while (setq point (pop config))
7435 (when (and (< point (point-max))
7437 (= (following-char) ?\n))
7438 (subst-char-in-region point (1+ point) ?\n ?\r)))))
7440 ;; Various summary mode internalish functions.
7442 (defun gnus-mouse-pick-article (e)
7445 (gnus-summary-next-page nil t))
7447 (defun gnus-summary-setup-buffer (group)
7448 "Initialize summary buffer."
7449 (let ((buffer (concat "*Summary " group "*")))
7450 (if (get-buffer buffer)
7453 (setq gnus-summary-buffer (current-buffer))
7454 (not gnus-newsgroup-prepared))
7455 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7456 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7457 (gnus-add-current-to-buffer-list)
7458 (gnus-summary-mode group)
7460 (gnus-carpal-setup-buffer 'summary))
7461 (unless gnus-single-article-buffer
7462 (make-local-variable 'gnus-article-buffer)
7463 (make-local-variable 'gnus-article-current)
7464 (make-local-variable 'gnus-original-article-buffer))
7465 (setq gnus-newsgroup-name group)
7468 (defun gnus-set-global-variables ()
7469 ;; Set the global equivalents of the summary buffer-local variables
7470 ;; to the latest values they had. These reflect the summary buffer
7471 ;; that was in action when the last article was fetched.
7472 (when (eq major-mode 'gnus-summary-mode)
7473 (setq gnus-summary-buffer (current-buffer))
7474 (let ((name gnus-newsgroup-name)
7475 (marked gnus-newsgroup-marked)
7476 (unread gnus-newsgroup-unreads)
7477 (headers gnus-current-headers)
7478 (data gnus-newsgroup-data)
7479 (summary gnus-summary-buffer)
7480 (article-buffer gnus-article-buffer)
7481 (original gnus-original-article-buffer)
7482 (gac gnus-article-current)
7483 (score-file gnus-current-score-file))
7485 (set-buffer gnus-group-buffer)
7486 (setq gnus-newsgroup-name name)
7487 (setq gnus-newsgroup-marked marked)
7488 (setq gnus-newsgroup-unreads unread)
7489 (setq gnus-current-headers headers)
7490 (setq gnus-newsgroup-data data)
7491 (setq gnus-article-current gac)
7492 (setq gnus-summary-buffer summary)
7493 (setq gnus-article-buffer article-buffer)
7494 (setq gnus-original-article-buffer original)
7495 (setq gnus-current-score-file score-file)))))
7497 (defun gnus-summary-last-article-p (&optional article)
7498 "Return whether ARTICLE is the last article in the buffer."
7499 (if (not (setq article (or article (gnus-summary-article-number))))
7500 t ; All non-existant numbers are the last article. :-)
7501 (not (cdr (gnus-data-find-list article)))))
7503 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7504 "Insert a dummy root in the summary buffer."
7506 (gnus-add-text-properties
7507 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7508 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7510 (defun gnus-make-thread-indent-array ()
7512 (unless (and gnus-thread-indent-array
7513 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7514 (setq gnus-thread-indent-array (make-vector 201 "")
7515 gnus-thread-indent-array-level gnus-thread-indent-level)
7517 (aset gnus-thread-indent-array n
7518 (make-string (* n gnus-thread-indent-level) ? ))
7521 (defun gnus-summary-insert-line
7522 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7523 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7524 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7525 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7526 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7527 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7528 (gnus-tmp-score-char
7529 (if (or (null gnus-summary-default-score)
7530 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7531 gnus-summary-zcore-fuzz)) ?
7532 (if (< gnus-tmp-score gnus-summary-default-score)
7533 gnus-score-below-mark gnus-score-over-mark)))
7534 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7535 ((memq gnus-tmp-current gnus-newsgroup-cached)
7537 (gnus-tmp-replied gnus-replied-mark)
7538 ((memq gnus-tmp-current gnus-newsgroup-saved)
7540 (t gnus-unread-mark)))
7541 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7544 ((string-match "(.+)" gnus-tmp-from)
7545 (substring gnus-tmp-from
7546 (1+ (match-beginning 0)) (1- (match-end 0))))
7547 ((string-match "<[^>]+> *$" gnus-tmp-from)
7548 (let ((beg (match-beginning 0)))
7549 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7550 (substring gnus-tmp-from (1+ (match-beginning 0))
7551 (1- (match-end 0))))
7552 (substring gnus-tmp-from 0 beg))))
7554 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7555 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7556 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7557 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7558 (buffer-read-only nil))
7559 (when (string= gnus-tmp-name "")
7560 (setq gnus-tmp-name gnus-tmp-from))
7561 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7562 (gnus-put-text-property
7564 (progn (eval gnus-summary-line-format-spec) (point))
7565 'gnus-number gnus-tmp-number)
7566 (when (gnus-visual-p 'summary-highlight 'highlight)
7568 (run-hooks 'gnus-summary-update-hook)
7571 (defun gnus-summary-update-line (&optional dont-update)
7572 ;; Update summary line after change.
7573 (when (and gnus-summary-default-score
7574 (not gnus-summary-inhibit-highlight))
7575 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7576 (article (gnus-summary-article-number))
7577 (score (gnus-summary-article-score article)))
7579 (if (and gnus-summary-mark-below
7580 (< (gnus-summary-article-score)
7581 gnus-summary-mark-below))
7582 ;; This article has a low score, so we mark it as read.
7583 (when (memq article gnus-newsgroup-unreads)
7584 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7585 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7586 ;; This article was previously marked as read on account
7587 ;; of a low score, but now it has risen, so we mark it as
7589 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7590 (gnus-summary-update-mark
7591 (if (or (null gnus-summary-default-score)
7592 (<= (abs (- score gnus-summary-default-score))
7593 gnus-summary-zcore-fuzz)) ?
7594 (if (< score gnus-summary-default-score)
7595 gnus-score-below-mark gnus-score-over-mark)) 'score))
7596 ;; Do visual highlighting.
7597 (when (gnus-visual-p 'summary-highlight 'highlight)
7598 (run-hooks 'gnus-summary-update-hook)))))
7600 (defvar gnus-tmp-new-adopts nil)
7602 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7603 ;; Sum up all elements (and sub-elements) in a list.
7605 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7607 ((and (consp thread) (cdr thread))
7610 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7613 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7616 (when (and level (zerop level) gnus-tmp-new-adopts)
7619 'gnus-summary-number-of-articles-in-thread
7620 gnus-tmp-new-adopts))))
7622 (if (> number 1) gnus-not-empty-thread-mark
7623 gnus-empty-thread-mark)
7626 (defun gnus-summary-set-local-parameters (group)
7627 "Go through the local params of GROUP and set all variable specs in that list."
7628 (let ((params (gnus-info-params (gnus-get-info group)))
7631 (setq elem (car params)
7632 params (cdr params))
7633 (and (consp elem) ; Has to be a cons.
7634 (consp (cdr elem)) ; The cdr has to be a list.
7635 (symbolp (car elem)) ; Has to be a symbol in there.
7636 (not (memq (car elem)
7637 '(quit-config to-address to-list to-group)))
7638 (progn ; So we set it.
7639 (make-local-variable (car elem))
7640 (set (car elem) (eval (nth 1 elem))))))))
7642 (defun gnus-summary-read-group (group &optional show-all no-article
7643 kill-buffer no-display)
7644 "Start reading news in newsgroup GROUP.
7645 If SHOW-ALL is non-nil, already read articles are also listed.
7646 If NO-ARTICLE is non-nil, no article is selected initially.
7647 If NO-DISPLAY, don't generate a summary buffer."
7648 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7649 (let* ((new-group (gnus-summary-setup-buffer group))
7650 (quit-config (gnus-group-quit-config group))
7651 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7653 ;; This summary buffer exists already, so we just select it.
7655 (gnus-set-global-variables)
7657 (gnus-kill-or-deaden-summary kill-buffer))
7658 (gnus-configure-windows 'summary 'force)
7659 (gnus-set-mode-line 'summary)
7660 (gnus-summary-position-point)
7663 ;; We couldn't select this group.
7665 (when (and (eq major-mode 'gnus-summary-mode)
7666 (not (equal (current-buffer) kill-buffer)))
7667 (kill-buffer (current-buffer))
7668 (if (not quit-config)
7670 (set-buffer gnus-group-buffer)
7671 (gnus-group-jump-to-group group)
7672 (gnus-group-next-unread-group 1))
7673 (if (not (buffer-name (car quit-config)))
7674 (gnus-configure-windows 'group 'force)
7675 (set-buffer (car quit-config))
7676 (and (eq major-mode 'gnus-summary-mode)
7677 (gnus-set-global-variables))
7678 (gnus-configure-windows (cdr quit-config)))))
7679 (gnus-message 3 "Can't select group")
7681 ;; The user did a `C-g' while prompting for number of articles,
7682 ;; so we exit this group.
7683 ((eq did-select 'quit)
7684 (and (eq major-mode 'gnus-summary-mode)
7685 (not (equal (current-buffer) kill-buffer))
7686 (kill-buffer (current-buffer)))
7688 (gnus-kill-or-deaden-summary kill-buffer))
7689 (if (not quit-config)
7691 (set-buffer gnus-group-buffer)
7692 (gnus-group-jump-to-group group)
7693 (gnus-group-next-unread-group 1)
7694 (gnus-configure-windows 'group 'force))
7695 (if (not (buffer-name (car quit-config)))
7696 (gnus-configure-windows 'group 'force)
7697 (set-buffer (car quit-config))
7698 (and (eq major-mode 'gnus-summary-mode)
7699 (gnus-set-global-variables))
7700 (gnus-configure-windows (cdr quit-config))))
7701 ;; Finally signal the quit.
7703 ;; The group was successfully selected.
7705 (gnus-set-global-variables)
7706 ;; Save the active value in effect when the group was entered.
7707 (setq gnus-newsgroup-active
7709 (gnus-active gnus-newsgroup-name)))
7710 ;; You can change the summary buffer in some way with this hook.
7711 (run-hooks 'gnus-select-group-hook)
7712 ;; Set any local variables in the group parameters.
7713 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7714 (gnus-update-format-specifications)
7715 ;; Do score processing.
7716 (when gnus-use-scoring
7717 (gnus-possibly-score-headers))
7718 ;; Check whether to fill in the gaps in the threads.
7719 (when gnus-build-sparse-threads
7720 (gnus-build-sparse-threads))
7721 ;; Find the initial limit.
7722 (if gnus-show-threads
7724 (let ((gnus-newsgroup-dormant nil))
7725 (gnus-summary-initial-limit show-all))
7726 (gnus-summary-initial-limit show-all))
7727 (setq gnus-newsgroup-limit
7729 (lambda (header) (mail-header-number header))
7730 gnus-newsgroup-headers)))
7731 ;; Generate the summary buffer.
7733 (gnus-summary-prepare))
7734 (when gnus-use-trees
7735 (gnus-tree-open group)
7736 (setq gnus-summary-highlight-line-function
7737 'gnus-tree-highlight-article))
7738 ;; If the summary buffer is empty, but there are some low-scored
7739 ;; articles or some excluded dormants, we include these in the
7741 (when (and (zerop (buffer-size))
7743 (cond (gnus-newsgroup-dormant
7744 (gnus-summary-limit-include-dormant))
7745 ((and gnus-newsgroup-scored show-all)
7746 (gnus-summary-limit-include-expunged))))
7747 ;; Function `gnus-apply-kill-file' must be called in this hook.
7748 (run-hooks 'gnus-apply-kill-hook)
7749 (if (and (zerop (buffer-size))
7752 ;; This newsgroup is empty.
7753 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7754 (gnus-message 6 "No unread news")
7756 (gnus-kill-or-deaden-summary kill-buffer))
7757 ;; Return nil from this function.
7759 ;; Hide conversation thread subtrees. We cannot do this in
7760 ;; gnus-summary-prepare-hook since kill processing may not
7761 ;; work with hidden articles.
7762 (and gnus-show-threads
7763 gnus-thread-hide-subtree
7764 (gnus-summary-hide-all-threads))
7765 ;; Show first unread article if requested.
7766 (if (and (not no-article)
7768 gnus-newsgroup-unreads
7769 gnus-auto-select-first)
7770 (unless (if (eq gnus-auto-select-first 'best)
7771 (gnus-summary-best-unread-article)
7772 (gnus-summary-first-unread-article))
7773 (gnus-configure-windows 'summary))
7774 ;; Don't select any articles, just move point to the first
7775 ;; article in the group.
7776 (goto-char (point-min))
7777 (gnus-summary-position-point)
7778 (gnus-set-mode-line 'summary)
7779 (gnus-configure-windows 'summary 'force))
7780 ;; If we are in async mode, we send some info to the backend.
7781 (when gnus-newsgroup-async
7782 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7784 (gnus-kill-or-deaden-summary kill-buffer))
7785 (when (get-buffer-window gnus-group-buffer t)
7786 ;; Gotta use windows, because recenter does wierd stuff if
7787 ;; the current buffer ain't the displayed window.
7788 (let ((owin (selected-window)))
7789 (select-window (get-buffer-window gnus-group-buffer t))
7790 (when (gnus-group-goto-group group)
7792 (select-window owin))))
7793 ;; Mark this buffer as "prepared".
7794 (setq gnus-newsgroup-prepared t)
7797 (defun gnus-summary-prepare ()
7798 "Generate the summary buffer."
7799 (let ((buffer-read-only nil))
7801 (setq gnus-newsgroup-data nil
7802 gnus-newsgroup-data-reverse nil)
7803 (run-hooks 'gnus-summary-generate-hook)
7804 ;; Generate the buffer, either with threads or without.
7805 (when gnus-newsgroup-headers
7806 (gnus-summary-prepare-threads
7807 (if gnus-show-threads
7808 (gnus-sort-gathered-threads
7809 (funcall gnus-summary-thread-gathering-function
7811 (gnus-cut-threads (gnus-make-threads)))))
7812 ;; Unthreaded display.
7813 (gnus-sort-articles gnus-newsgroup-headers))))
7814 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7815 ;; Call hooks for modifying summary buffer.
7816 (goto-char (point-min))
7817 (run-hooks 'gnus-summary-prepare-hook)))
7819 (defun gnus-gather-threads-by-subject (threads)
7820 "Gather threads by looking at Subject headers."
7821 (if (not gnus-summary-make-false-root)
7823 (let ((hashtb (gnus-make-hashtable 1023))
7826 subject hthread whole-subject)
7828 (setq whole-subject (mail-header-subject (caar threads)))
7831 ;; Truncate the subject.
7832 ((numberp gnus-summary-gather-subject-limit)
7833 (setq subject (gnus-simplify-subject-re whole-subject))
7834 (if (> (length subject) gnus-summary-gather-subject-limit)
7835 (substring subject 0 gnus-summary-gather-subject-limit)
7837 ;; Fuzzily simplify it.
7838 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7839 (gnus-simplify-subject-fuzzy whole-subject))
7840 ;; Just remove the leading "Re:".
7842 (gnus-simplify-subject-re whole-subject))))
7844 (if (and gnus-summary-gather-exclude-subject
7845 (string-match gnus-summary-gather-exclude-subject
7847 () ; We don't want to do anything with this article.
7848 ;; We simplify the subject before looking it up in the
7851 (if (setq hthread (gnus-gethash subject hashtb))
7853 ;; We enter a dummy root into the thread, if we
7854 ;; haven't done that already.
7855 (unless (stringp (caar hthread))
7856 (setcar hthread (list whole-subject (car hthread))))
7857 ;; We add this new gathered thread to this gathered
7859 (setcdr (car hthread)
7860 (nconc (cdar hthread) (list (car threads))))
7861 ;; Remove it from the list of threads.
7862 (setcdr prev (cdr threads))
7863 (setq threads prev))
7864 ;; Enter this thread into the hash table.
7865 (gnus-sethash subject threads hashtb)))
7867 (setq threads (cdr threads)))
7870 (defun gnus-gather-threads-by-references (threads)
7871 "Gather threads by looking at References headers."
7872 (let ((idhashtb (gnus-make-hashtable 1023))
7873 (thhashtb (gnus-make-hashtable 1023))
7876 ids references id gthread gid entered)
7878 (when (setq references (mail-header-references (caar threads)))
7879 (setq id (mail-header-id (caar threads)))
7880 (setq ids (gnus-split-references references))
7883 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7885 (gnus-sethash (car ids) id idhashtb)
7886 (gnus-sethash id threads thhashtb))
7887 (setq gthread (gnus-gethash gid thhashtb))
7889 ;; We enter a dummy root into the thread, if we
7890 ;; haven't done that already.
7891 (unless (stringp (caar gthread))
7892 (setcar gthread (list (mail-header-subject (caar gthread))
7894 ;; We add this new gathered thread to this gathered
7896 (setcdr (car gthread)
7897 (nconc (cdar gthread) (list (car threads)))))
7898 ;; Add it into the thread hash table.
7899 (gnus-sethash id gthread thhashtb)
7901 ;; Remove it from the list of threads.
7902 (setcdr prev (cdr threads))
7903 (setq threads prev))
7904 (setq ids (cdr ids))))
7906 (setq threads (cdr threads)))
7909 (defun gnus-sort-gathered-threads (threads)
7910 "Sort subtreads inside each gathered thread by article number."
7911 (let ((result threads))
7913 (when (stringp (caar threads))
7914 (setcdr (car threads)
7915 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7916 (setq threads (cdr threads)))
7919 (defun gnus-make-threads ()
7920 "Go through the dependency hashtb and find the roots. Return all threads."
7924 (unless (car (symbol-value refs))
7925 ;; These threads do not refer back to any other articles,
7926 ;; so they're roots.
7927 (setq threads (append (cdr (symbol-value refs)) threads))))
7928 gnus-newsgroup-dependencies)
7931 (defun gnus-build-sparse-threads ()
7932 (let ((headers gnus-newsgroup-headers)
7933 (deps gnus-newsgroup-dependencies)
7934 header references generation relations
7935 cthread subject child end pthread relation)
7936 ;; First we create an alist of generations/relations, where
7937 ;; generations is how much we trust the ralation, and the relation
7939 (gnus-message 7 "Making sparse threads...")
7941 (nnheader-set-temp-buffer " *gnus sparse threads*")
7942 (while (setq header (pop headers))
7943 (when (and (setq references (mail-header-references header))
7944 (not (string= references "")))
7946 (setq child (mail-header-id header)
7947 subject (mail-header-subject header))
7949 (while (search-backward ">" nil t)
7950 (setq end (1+ (point)))
7951 (when (search-backward "<" nil t)
7952 (push (list (incf generation)
7953 child (setq child (buffer-substring (point) end))
7956 (push (list (1+ generation) child nil subject) relations)
7958 (kill-buffer (current-buffer)))
7959 ;; Sort over trustworthiness.
7960 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
7961 (while (setq relation (pop relations))
7962 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
7963 (unless (car (symbol-value cthread))
7964 ;; Make this article the parent of these threads.
7965 (setcar (symbol-value cthread)
7966 (vector gnus-reffed-article-number
7970 (or (caddr relation) "") 0 0 "")))
7971 (set cthread (list (vector gnus-reffed-article-number
7973 "" "" (cadr relation)
7974 (or (caddr relation) "") 0 0 ""))))
7975 (push gnus-reffed-article-number gnus-newsgroup-limit)
7976 (push gnus-reffed-article-number gnus-newsgroup-sparse)
7977 (push (cons gnus-reffed-article-number gnus-sparse-mark)
7978 gnus-newsgroup-reads)
7979 (decf gnus-reffed-article-number)
7980 ;; Make this new thread the child of its parent.
7981 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
7982 (setcdr (symbol-value pthread)
7983 (nconc (cdr (symbol-value pthread))
7984 (list (symbol-value cthread))))
7985 (set pthread (list nil (symbol-value cthread))))))
7986 (gnus-message 7 "Making sparse threads...done")))
7988 (defun gnus-build-old-threads ()
7989 ;; Look at all the articles that refer back to old articles, and
7990 ;; fetch the headers for the articles that aren't there. This will
7991 ;; build complete threads - if the roots haven't been expired by the
7996 (when (not (car (symbol-value refs)))
7997 (setq heads (cdr (symbol-value refs)))
7999 (if (memq (mail-header-number (caar heads))
8000 gnus-newsgroup-dormant)
8001 (setq heads (cdr heads))
8002 (setq id (symbol-name refs))
8003 (while (and (setq id (gnus-build-get-header id))
8004 (not (car (gnus-gethash
8005 id gnus-newsgroup-dependencies)))))
8006 (setq heads nil)))))
8007 gnus-newsgroup-dependencies)))
8009 (defun gnus-build-get-header (id)
8010 ;; Look through the buffer of NOV lines and find the header to
8011 ;; ID. Enter this line into the dependencies hash table, and return
8012 ;; the id of the parent article (if any).
8013 (let ((deps gnus-newsgroup-dependencies)
8017 (set-buffer nntp-server-buffer)
8018 (goto-char (point-min))
8019 (while (and (not found) (search-forward id nil t))
8021 (setq found (looking-at
8022 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
8023 (regexp-quote id))))
8024 (or found (beginning-of-line 2)))
8028 (setq header (gnus-nov-parse-line
8029 (read (current-buffer)) deps))
8030 (gnus-parent-id (mail-header-references header)))))
8032 (let ((number (mail-header-number header)))
8033 (push number gnus-newsgroup-limit)
8034 (push header gnus-newsgroup-headers)
8035 (if (memq number gnus-newsgroup-unselected)
8037 (push number gnus-newsgroup-unreads)
8038 (setq gnus-newsgroup-unselected
8039 (delq number gnus-newsgroup-unselected)))
8040 (push number gnus-newsgroup-ancient)))))))
8042 (defun gnus-summary-update-article (article &optional header)
8043 "Update ARTICLE in the summary buffer."
8044 (set-buffer gnus-summary-buffer)
8045 (let* ((header (or header (gnus-summary-article-header article)))
8046 (id (mail-header-id header))
8047 (data (gnus-data-find article))
8048 (thread (gnus-id-to-thread id))
8050 (gnus-id-to-thread (or (gnus-parent-id
8051 (mail-header-references header))
8053 (buffer-read-only nil)
8055 (number (mail-header-number header))
8060 (delq thread parent))
8061 (if (gnus-summary-insert-subject id header)
8062 ;; Set the (possibly) new article number in the data structure.
8063 (gnus-data-set-number data (gnus-id-to-article id))
8067 (defun gnus-rebuild-thread (id)
8068 "Rebuild the thread containing ID."
8069 (let ((buffer-read-only nil)
8070 current thread data)
8071 (if (not gnus-show-threads)
8072 (setq thread (list (car (gnus-id-to-thread id))))
8073 ;; Get the thread this article is part of.
8074 (setq thread (gnus-remove-thread id)))
8075 (setq current (save-excursion
8076 (and (zerop (forward-line -1))
8077 (gnus-summary-article-number))))
8078 ;; If this is a gathered thread, we have to go some re-gathering.
8079 (when (stringp (car thread))
8080 (let ((subject (car thread))
8082 (setq thread (cdr thread))
8084 (unless (memq (setq thr (gnus-id-to-thread
8086 (mail-header-id (caar thread)))))
8089 (setq thread (cdr thread)))
8090 ;; We now have all (unique) roots.
8091 (if (= (length roots) 1)
8092 ;; All the loose roots are now one solid root.
8093 (setq thread (car roots))
8094 (setq thread (cons subject (gnus-sort-threads roots))))))
8096 ;; We then insert this thread into the summary buffer.
8097 (let (gnus-newsgroup-data gnus-newsgroup-threads)
8098 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
8099 (setq data (nreverse gnus-newsgroup-data))
8100 (setq threads gnus-newsgroup-threads))
8101 ;; We splice the new data into the data structure.
8102 (gnus-data-enter-list current data)
8103 (gnus-data-compute-positions)
8104 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
8106 (defun gnus-id-to-thread (id)
8107 "Return the (sub-)thread where ID appears."
8108 (gnus-gethash id gnus-newsgroup-dependencies))
8110 (defun gnus-id-to-article (id)
8111 "Return the article number of ID."
8112 (let ((thread (gnus-id-to-thread id)))
8115 (mail-header-number (car thread)))))
8117 (defun gnus-id-to-header (id)
8118 "Return the article headers of ID."
8119 (car (gnus-id-to-thread id)))
8121 (defun gnus-article-displayed-root-p (article)
8122 "Say whether ARTICLE is a root(ish) article."
8123 (let ((level (gnus-summary-thread-level article))
8124 (refs (mail-header-references (gnus-summary-article-header article)))
8130 ((null (gnus-parent-id refs)) t)
8132 (null (setq particle (gnus-id-to-article
8133 (gnus-parent-id refs))))
8134 (null (gnus-summary-thread-level particle)))))))
8136 (defun gnus-root-id (id)
8137 "Return the id of the root of the thread where ID appears."
8139 (while (and id (setq prev (car (gnus-gethash
8140 id gnus-newsgroup-dependencies))))
8142 id (gnus-parent-id (mail-header-references prev))))
8145 (defun gnus-remove-thread (id &optional dont-remove)
8146 "Remove the thread that has ID in it."
8147 (let ((dep gnus-newsgroup-dependencies)
8148 headers thread last-id)
8149 ;; First go up in this thread until we find the root.
8150 (setq last-id (gnus-root-id id))
8151 (setq headers (list (car (gnus-id-to-thread last-id))
8152 (caadr (gnus-id-to-thread last-id))))
8153 ;; We have now found the real root of this thread. It might have
8154 ;; been gathered into some loose thread, so we have to search
8155 ;; through the threads to find the thread we wanted.
8156 (let ((threads gnus-newsgroup-threads)
8159 (setq sub (car threads))
8160 (if (stringp (car sub))
8161 ;; This is a gathered threads, so we look at the roots
8162 ;; below it to find whether this article in in this
8165 (setq sub (cdr sub))
8167 (when (member (caar sub) headers)
8168 (setq thread (car threads)
8171 (setq sub (cdr sub))))
8172 ;; It's an ordinary thread, so we check it.
8173 (when (eq (car sub) (car headers))
8176 (setq threads (cdr threads)))
8177 ;; If this article is in no thread, then it's a root.
8180 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
8181 (setq thread (gnus-gethash last-id dep)))
8184 thread ; We return this thread.
8186 (if (stringp (car thread))
8188 ;; If we use dummy roots, then we have to remove the
8189 ;; dummy root as well.
8190 (when (eq gnus-summary-make-false-root 'dummy)
8193 (setq thread (cdr thread))
8195 (gnus-remove-thread-1 (car thread))
8196 (setq thread (cdr thread))))
8197 (gnus-remove-thread-1 thread))))))))
8199 (defun gnus-remove-thread-1 (thread)
8200 "Remove the thread THREAD recursively."
8201 (let ((number (mail-header-number (car thread)))
8203 (when (setq pos (text-property-any
8204 (point-min) (point-max) 'gnus-number number))
8207 (gnus-data-remove number))
8208 (setq thread (cdr thread))
8210 (gnus-remove-thread-1 (pop thread)))))
8212 (defun gnus-sort-threads (threads)
8214 (if (not gnus-thread-sort-functions)
8216 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8217 (car gnus-thread-sort-functions)
8219 ,(gnus-make-sort-function
8220 (reverse gnus-thread-sort-functions))))))
8221 (gnus-message 7 "Sorting threads...")
8224 (gnus-message 7 "Sorting threads...done")))))
8226 (defun gnus-sort-articles (articles)
8228 (when gnus-article-sort-functions
8229 (let ((func (if (= 1 (length gnus-article-sort-functions))
8230 (car gnus-article-sort-functions)
8232 ,(gnus-make-sort-function
8233 (reverse gnus-article-sort-functions))))))
8234 (gnus-message 7 "Sorting articles...")
8236 (setq gnus-newsgroup-headers (sort articles func))
8237 (gnus-message 7 "Sorting articles...done")))))
8239 (defun gnus-make-sort-function (funs)
8240 "Return a composite sort condition based on the functions in FUNC."
8242 `(or (,(car funs) t1 t2)
8243 (and (not (,(car funs) t2 t1))
8244 ,(gnus-make-sort-function (cdr funs))))
8245 `(,(car funs) t1 t2)))
8247 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8248 (defmacro gnus-thread-header (thread)
8249 ;; Return header of first article in THREAD.
8250 ;; Note that THREAD must never, ever be anything else than a variable -
8251 ;; using some other form will lead to serious barfage.
8252 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8253 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8254 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8257 (defsubst gnus-article-sort-by-number (h1 h2)
8258 "Sort articles by article number."
8259 (< (mail-header-number h1)
8260 (mail-header-number h2)))
8262 (defun gnus-thread-sort-by-number (h1 h2)
8263 "Sort threads by root article number."
8264 (gnus-article-sort-by-number
8265 (gnus-thread-header h1) (gnus-thread-header h2)))
8267 (defsubst gnus-article-sort-by-author (h1 h2)
8268 "Sort articles by root author."
8270 (let ((extract (funcall
8271 gnus-extract-address-components
8272 (mail-header-from h1))))
8273 (or (car extract) (cdr extract)))
8274 (let ((extract (funcall
8275 gnus-extract-address-components
8276 (mail-header-from h2))))
8277 (or (car extract) (cdr extract)))))
8279 (defun gnus-thread-sort-by-author (h1 h2)
8280 "Sort threads by root author."
8281 (gnus-article-sort-by-author
8282 (gnus-thread-header h1) (gnus-thread-header h2)))
8284 (defsubst gnus-article-sort-by-subject (h1 h2)
8285 "Sort articles by root subject."
8287 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8288 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8290 (defun gnus-thread-sort-by-subject (h1 h2)
8291 "Sort threads by root subject."
8292 (gnus-article-sort-by-subject
8293 (gnus-thread-header h1) (gnus-thread-header h2)))
8295 (defsubst gnus-article-sort-by-date (h1 h2)
8296 "Sort articles by root article date."
8298 (inline (gnus-sortable-date (mail-header-date h1)))
8299 (inline (gnus-sortable-date (mail-header-date h2)))))
8301 (defun gnus-thread-sort-by-date (h1 h2)
8302 "Sort threads by root article date."
8303 (gnus-article-sort-by-date
8304 (gnus-thread-header h1) (gnus-thread-header h2)))
8306 (defsubst gnus-article-sort-by-score (h1 h2)
8307 "Sort articles by root article score.
8308 Unscored articles will be counted as having a score of zero."
8309 (> (or (cdr (assq (mail-header-number h1)
8310 gnus-newsgroup-scored))
8311 gnus-summary-default-score 0)
8312 (or (cdr (assq (mail-header-number h2)
8313 gnus-newsgroup-scored))
8314 gnus-summary-default-score 0)))
8316 (defun gnus-thread-sort-by-score (h1 h2)
8317 "Sort threads by root article score."
8318 (gnus-article-sort-by-score
8319 (gnus-thread-header h1) (gnus-thread-header h2)))
8321 (defun gnus-thread-sort-by-total-score (h1 h2)
8322 "Sort threads by the sum of all scores in the thread.
8323 Unscored articles will be counted as having a score of zero."
8324 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8326 (defun gnus-thread-total-score (thread)
8327 ;; This function find the total score of THREAD.
8329 (if (stringp (car thread))
8330 (apply gnus-thread-score-function 0
8331 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8332 (gnus-thread-total-score-1 thread))
8333 (gnus-thread-total-score-1 (list thread))))
8335 (defun gnus-thread-total-score-1 (root)
8336 ;; This function find the total score of the thread below ROOT.
8337 (setq root (car root))
8338 (apply gnus-thread-score-function
8339 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8340 gnus-summary-default-score 0)
8341 (mapcar 'gnus-thread-total-score
8342 (cdr (gnus-gethash (mail-header-id root)
8343 gnus-newsgroup-dependencies)))))
8345 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8346 (defvar gnus-tmp-prev-subject nil)
8347 (defvar gnus-tmp-false-parent nil)
8348 (defvar gnus-tmp-root-expunged nil)
8349 (defvar gnus-tmp-dummy-line nil)
8351 (defun gnus-summary-prepare-threads (threads)
8352 "Prepare summary buffer from THREADS and indentation LEVEL.
8353 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8354 or a straight list of headers."
8355 (gnus-message 7 "Generating summary...")
8357 (setq gnus-newsgroup-threads threads)
8360 (let ((gnus-tmp-level 0)
8361 (default-score (or gnus-summary-default-score 0))
8362 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8363 thread number subject stack state gnus-tmp-gathered beg-match
8364 new-roots gnus-tmp-new-adopts thread-end
8365 gnus-tmp-header gnus-tmp-unread
8366 gnus-tmp-replied gnus-tmp-subject-or-nil
8367 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8368 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8369 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8371 (setq gnus-tmp-prev-subject nil)
8373 (if (vectorp (car threads))
8374 ;; If this is a straight (sic) list of headers, then a
8375 ;; threaded summary display isn't required, so we just create
8376 ;; an unthreaded one.
8377 (gnus-summary-prepare-unthreaded threads)
8379 ;; Do the threaded display.
8381 (while (or threads stack gnus-tmp-new-adopts new-roots)
8383 (if (and (= gnus-tmp-level 0)
8384 (not (setq gnus-tmp-dummy-line nil))
8387 (not gnus-tmp-false-parent)
8388 (or gnus-tmp-new-adopts new-roots))
8389 (if gnus-tmp-new-adopts
8390 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8391 thread (list (car gnus-tmp-new-adopts))
8392 gnus-tmp-header (caar thread)
8393 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8395 (setq thread (list (car new-roots))
8396 gnus-tmp-header (caar thread)
8397 new-roots (cdr new-roots))))
8400 ;; If there are some threads, we do them before the
8401 ;; threads on the stack.
8402 (setq thread threads
8403 gnus-tmp-header (caar thread))
8404 ;; There were no current threads, so we pop something off
8406 (setq state (car stack)
8407 gnus-tmp-level (car state)
8410 gnus-tmp-header (caar thread))))
8412 (setq gnus-tmp-false-parent nil)
8413 (setq gnus-tmp-root-expunged nil)
8414 (setq thread-end nil)
8416 (if (stringp gnus-tmp-header)
8417 ;; The header is a dummy root.
8419 ((eq gnus-summary-make-false-root 'adopt)
8420 ;; We let the first article adopt the rest.
8421 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8423 (setq gnus-tmp-gathered
8425 (lambda (h) (mail-header-number (car h)))
8428 (setq thread (cons (list (caar thread)
8431 (setq gnus-tmp-level -1
8432 gnus-tmp-false-parent t))
8433 ((eq gnus-summary-make-false-root 'empty)
8434 ;; We print adopted articles with empty subject fields.
8435 (setq gnus-tmp-gathered
8437 (lambda (h) (mail-header-number (car h)))
8440 (setq gnus-tmp-level -1))
8441 ((eq gnus-summary-make-false-root 'dummy)
8442 ;; We remember that we probably want to output a dummy
8444 (setq gnus-tmp-dummy-line gnus-tmp-header)
8445 (setq gnus-tmp-prev-subject gnus-tmp-header))
8447 ;; We do not make a root for the gathered
8448 ;; sub-threads at all.
8449 (setq gnus-tmp-level -1)))
8451 (setq number (mail-header-number gnus-tmp-header)
8452 subject (mail-header-subject gnus-tmp-header))
8455 ;; If the thread has changed subject, we might want to make
8456 ;; this subthread into a root.
8457 ((and (null gnus-thread-ignore-subject)
8458 (not (zerop gnus-tmp-level))
8459 gnus-tmp-prev-subject
8461 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8462 (setq new-roots (nconc new-roots (list (car thread)))
8464 gnus-tmp-header nil))
8465 ;; If the article lies outside the current limit,
8466 ;; then we do not display it.
8467 ((and (not (memq number gnus-newsgroup-limit))
8468 (not gnus-tmp-dummy-line))
8469 (setq gnus-tmp-gathered
8471 (lambda (h) (mail-header-number (car h)))
8474 (setq gnus-tmp-new-adopts (if (cdar thread)
8475 (append gnus-tmp-new-adopts
8477 gnus-tmp-new-adopts)
8479 gnus-tmp-header nil)
8480 (when (zerop gnus-tmp-level)
8481 (setq gnus-tmp-root-expunged t)))
8482 ;; Perhaps this article is to be marked as read?
8483 ((and gnus-summary-mark-below
8484 (< (or (cdr (assq number gnus-newsgroup-scored))
8486 gnus-summary-mark-below)
8487 ;; Don't touch sparse articles.
8488 (not (memq number gnus-newsgroup-sparse))
8489 (not (memq number gnus-newsgroup-ancient)))
8490 (setq gnus-newsgroup-unreads
8491 (delq number gnus-newsgroup-unreads))
8492 (if gnus-newsgroup-auto-expire
8493 (push number gnus-newsgroup-expirable)
8494 (push (cons number gnus-low-score-mark)
8495 gnus-newsgroup-reads))))
8497 (when gnus-tmp-header
8498 ;; We may have an old dummy line to output before this
8500 (when gnus-tmp-dummy-line
8501 (gnus-summary-insert-dummy-line
8502 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8503 (setq gnus-tmp-dummy-line nil))
8505 ;; Compute the mark.
8509 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8510 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8511 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8512 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8513 (t (or (cdr (assq number gnus-newsgroup-reads))
8514 gnus-ancient-mark))))
8516 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8517 gnus-tmp-header gnus-tmp-level)
8518 gnus-newsgroup-data)
8520 ;; Actually insert the line.
8522 gnus-tmp-subject-or-nil
8524 ((and gnus-thread-ignore-subject
8525 gnus-tmp-prev-subject
8526 (not (inline (gnus-subject-equal
8527 gnus-tmp-prev-subject subject))))
8529 ((zerop gnus-tmp-level)
8530 (if (and (eq gnus-summary-make-false-root 'empty)
8531 (memq number gnus-tmp-gathered)
8532 gnus-tmp-prev-subject
8533 (inline (gnus-subject-equal
8534 gnus-tmp-prev-subject subject)))
8535 gnus-summary-same-subject
8537 (t gnus-summary-same-subject)))
8538 (if (and (eq gnus-summary-make-false-root 'adopt)
8539 (= gnus-tmp-level 1)
8540 (memq number gnus-tmp-gathered))
8541 (setq gnus-tmp-opening-bracket ?\<
8542 gnus-tmp-closing-bracket ?\>)
8543 (setq gnus-tmp-opening-bracket ?\[
8544 gnus-tmp-closing-bracket ?\]))
8546 gnus-tmp-indentation
8547 (aref gnus-thread-indent-array gnus-tmp-level)
8548 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8549 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8550 gnus-summary-default-score 0)
8552 (if (or (null gnus-summary-default-score)
8553 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8554 gnus-summary-zcore-fuzz)) ?
8555 (if (< gnus-tmp-score gnus-summary-default-score)
8556 gnus-score-below-mark gnus-score-over-mark))
8558 (cond ((memq number gnus-newsgroup-processable)
8560 ((memq number gnus-newsgroup-cached)
8562 ((memq number gnus-newsgroup-replied)
8564 (t gnus-unread-mark))
8565 gnus-tmp-from (mail-header-from gnus-tmp-header)
8568 ((string-match "(.+)" gnus-tmp-from)
8569 (substring gnus-tmp-from
8570 (1+ (match-beginning 0)) (1- (match-end 0))))
8571 ((string-match "<[^>]+> *$" gnus-tmp-from)
8572 (setq beg-match (match-beginning 0))
8573 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8574 (substring gnus-tmp-from (1+ (match-beginning 0))
8575 (1- (match-end 0))))
8576 (substring gnus-tmp-from 0 beg-match)))
8578 (when (string= gnus-tmp-name "")
8579 (setq gnus-tmp-name gnus-tmp-from))
8580 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8581 (gnus-put-text-property
8583 (progn (eval gnus-summary-line-format-spec) (point))
8584 'gnus-number number)
8587 (run-hooks 'gnus-summary-update-hook)
8590 (setq gnus-tmp-prev-subject subject)))
8592 (when (nth 1 thread)
8593 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8594 (incf gnus-tmp-level)
8595 (setq threads (if thread-end nil (cdar thread)))
8597 (setq gnus-tmp-level 0)))))
8598 (gnus-message 7 "Generating summary...done"))
8600 (defun gnus-summary-prepare-unthreaded (headers)
8601 "Generate an unthreaded summary buffer based on HEADERS."
8602 (let (header number mark)
8605 ;; We may have to root out some bad articles...
8606 (when (memq (setq number (mail-header-number
8607 (setq header (pop headers))))
8608 gnus-newsgroup-limit)
8609 ;; Mark article as read when it has a low score.
8610 (when (and gnus-summary-mark-below
8611 (< (or (cdr (assq number gnus-newsgroup-scored))
8612 gnus-summary-default-score 0)
8613 gnus-summary-mark-below)
8614 (not (memq number gnus-newsgroup-ancient)))
8615 (setq gnus-newsgroup-unreads
8616 (delq number gnus-newsgroup-unreads))
8617 (if gnus-newsgroup-auto-expire
8618 (push number gnus-newsgroup-expirable)
8619 (push (cons number gnus-low-score-mark)
8620 gnus-newsgroup-reads)))
8624 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8625 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8626 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8627 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8628 (t (or (cdr (assq number gnus-newsgroup-reads))
8629 gnus-ancient-mark))))
8630 (setq gnus-newsgroup-data
8631 (cons (gnus-data-make number mark (1+ (point)) header 0)
8632 gnus-newsgroup-data))
8633 (gnus-summary-insert-line
8634 header 0 nil mark (memq number gnus-newsgroup-replied)
8635 (memq number gnus-newsgroup-expirable)
8636 (mail-header-subject header) nil
8637 (cdr (assq number gnus-newsgroup-scored))
8638 (memq number gnus-newsgroup-processable))))))
8640 (defun gnus-select-newsgroup (group &optional read-all)
8641 "Select newsgroup GROUP.
8642 If READ-ALL is non-nil, all articles in the group are selected."
8643 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8644 (info (nth 2 entry))
8645 articles fetched-articles cached)
8647 (or (gnus-check-server
8648 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8649 (error "Couldn't open server"))
8651 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8652 (gnus-activate-group group) ; Or we can activate it...
8653 (progn ; Or we bug out.
8654 (when (equal major-mode 'gnus-summary-mode)
8655 (kill-buffer (current-buffer)))
8656 (error "Couldn't request group %s: %s"
8657 group (gnus-status-message group))))
8659 (unless (gnus-request-group group t)
8660 (when (equal major-mode 'gnus-summary-mode)
8661 (kill-buffer (current-buffer)))
8662 (error "Couldn't request group %s: %s"
8663 group (gnus-status-message group)))
8665 (setq gnus-newsgroup-name group)
8666 (setq gnus-newsgroup-unselected nil)
8667 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8669 (and gnus-asynchronous
8670 (gnus-check-backend-function
8671 'request-asynchronous gnus-newsgroup-name)
8672 (setq gnus-newsgroup-async
8673 (gnus-request-asynchronous gnus-newsgroup-name)))
8675 ;; Adjust and set lists of article marks.
8677 (gnus-adjust-marked-articles info))
8679 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8680 (when (gnus-virtual-group-p group)
8681 (setq cached gnus-newsgroup-cached))
8683 (setq gnus-newsgroup-unreads
8684 (gnus-set-difference
8685 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8686 gnus-newsgroup-dormant))
8688 (setq gnus-newsgroup-processable nil)
8690 (setq articles (gnus-articles-to-read group read-all))
8694 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8696 ((eq articles 0) nil)
8698 ;; Init the dependencies hash table.
8699 (setq gnus-newsgroup-dependencies
8700 (gnus-make-hashtable (length articles)))
8701 ;; Retrieve the headers and read them in.
8702 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8703 (setq gnus-newsgroup-headers
8705 (setq gnus-headers-retrieved-by
8706 (gnus-retrieve-headers
8707 articles gnus-newsgroup-name
8708 ;; We might want to fetch old headers, but
8709 ;; not if there is only 1 article.
8710 (and gnus-fetch-old-headers
8712 (not (eq gnus-fetch-old-headers 'some))
8713 (not (numberp gnus-fetch-old-headers)))
8714 (> (length articles) 1))))))
8715 (gnus-get-newsgroup-headers-xover articles)
8716 (gnus-get-newsgroup-headers)))
8717 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
8719 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8721 (setq gnus-newsgroup-cached cached))
8723 ;; Set the initial limit.
8724 (setq gnus-newsgroup-limit (copy-sequence articles))
8725 ;; Remove canceled articles from the list of unread articles.
8726 (setq gnus-newsgroup-unreads
8727 (gnus-set-sorted-intersection
8728 gnus-newsgroup-unreads
8729 (setq fetched-articles
8730 (mapcar (lambda (headers) (mail-header-number headers))
8731 gnus-newsgroup-headers))))
8732 ;; Removed marked articles that do not exist.
8733 (gnus-update-missing-marks
8734 (gnus-sorted-complement fetched-articles articles))
8735 ;; We might want to build some more threads first.
8736 (and gnus-fetch-old-headers
8737 (eq gnus-headers-retrieved-by 'nov)
8738 (gnus-build-old-threads))
8739 ;; Check whether auto-expire is to be done in this group.
8740 (setq gnus-newsgroup-auto-expire
8741 (gnus-group-auto-expirable-p group))
8742 ;; Set up the article buffer now, if necessary.
8743 (unless gnus-single-article-buffer
8744 (gnus-article-setup-buffer))
8745 ;; First and last article in this newsgroup.
8746 (and gnus-newsgroup-headers
8747 (setq gnus-newsgroup-begin
8748 (mail-header-number (car gnus-newsgroup-headers)))
8749 (setq gnus-newsgroup-end
8751 (gnus-last-element gnus-newsgroup-headers))))
8752 (setq gnus-reffed-article-number -1)
8753 ;; GROUP is successfully selected.
8754 (or gnus-newsgroup-headers t)))))
8756 (defun gnus-articles-to-read (group read-all)
8757 ;; Find out what articles the user wants to read.
8759 ;; Select all articles if `read-all' is non-nil, or if there
8760 ;; are no unread articles.
8762 (and (zerop (length gnus-newsgroup-marked))
8763 (zerop (length gnus-newsgroup-unreads))))
8764 (gnus-uncompress-range (gnus-active group))
8765 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8766 (copy-sequence gnus-newsgroup-unreads))
8768 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8769 (scored (length scored-list))
8770 (number (length articles))
8771 (marked (+ (length gnus-newsgroup-marked)
8772 (length gnus-newsgroup-dormant)))
8780 ((and (or (<= scored marked) (= scored number))
8781 (numberp gnus-large-newsgroup)
8782 (> number gnus-large-newsgroup))
8786 "How many articles from %s (default %d): "
8787 gnus-newsgroup-name number))))
8788 (if (string-match "^[ \t]*$" input) number input)))
8789 ((and (> scored marked) (< scored number))
8792 (format "%s %s (%d scored, %d total): "
8793 "How many articles from"
8794 group scored number))))
8795 (if (string-match "^[ \t]*$" input)
8799 (setq select (if (stringp select) (string-to-number select) select))
8800 (if (or (null select) (zerop select))
8802 (if (and (not (zerop scored)) (<= (abs select) scored))
8804 (setq articles (sort scored-list '<))
8805 (setq number (length articles)))
8806 (setq articles (copy-sequence articles)))
8808 (if (< (abs select) number)
8810 ;; Select the N oldest articles.
8811 (setcdr (nthcdr (1- (abs select)) articles) nil)
8812 ;; Select the N most recent articles.
8813 (setq articles (nthcdr (- number select) articles))))
8814 (setq gnus-newsgroup-unselected
8815 (gnus-sorted-intersection
8816 gnus-newsgroup-unreads
8817 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8820 (defun gnus-killed-articles (killed articles)
8823 (if (inline (gnus-member-of-range (car articles) killed))
8824 (setq out (cons (car articles) out)))
8825 (setq articles (cdr articles)))
8828 (defun gnus-uncompress-marks (marks)
8829 "Uncompress the mark ranges in MARKS."
8830 (let ((uncompressed '(score bookmark))
8833 (if (memq (caar marks) uncompressed)
8834 (push (car marks) out)
8835 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8836 (setq marks (cdr marks)))
8839 (defun gnus-adjust-marked-articles (info)
8840 "Set all article lists and remove all marks that are no longer legal."
8841 (let* ((marked-lists (gnus-info-marks info))
8842 (active (gnus-active (gnus-info-group info)))
8845 (types gnus-article-mark-lists)
8846 (uncompressed '(score bookmark))
8847 marks var articles article mark)
8850 (setq marks (pop marked-lists))
8851 (set (setq var (intern (format "gnus-newsgroup-%s"
8852 (car (rassq (setq mark (car marks))
8854 (if (memq (car marks) uncompressed) (cdr marks)
8855 (gnus-uncompress-range (cdr marks))))
8857 (setq articles (symbol-value var))
8859 ;; All articles have to be subsets of the active articles.
8861 ;; Adjust "simple" lists.
8862 ((memq mark '(tick dormant expirable reply killed save))
8864 (when (or (< (setq article (pop articles)) min) (> article max))
8865 (set var (delq article (symbol-value var))))))
8867 ((memq mark '(score bookmark))
8869 (when (or (< (car (setq article (pop articles))) min)
8870 (> (car article) max))
8871 (set var (delq article (symbol-value var))))))))))
8873 (defun gnus-update-missing-marks (missing)
8874 "Go through the list of MISSING articles and remove them mark lists."
8876 (let ((types gnus-article-mark-lists)
8878 ;; Go through all types.
8880 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8881 (when (symbol-value var)
8882 ;; This list has articles. So we delete all missing articles
8886 (set var (delq (pop m) (symbol-value var)))))))))
8888 (defun gnus-update-marks ()
8889 "Enter the various lists of marked articles into the newsgroup info list."
8890 (let ((types gnus-article-mark-lists)
8891 (info (gnus-get-info gnus-newsgroup-name))
8892 (uncompressed '(score bookmark killed))
8893 type list newmarked symbol)
8895 ;; Add all marks lists that are non-nil to the list of marks lists.
8897 (setq type (pop types))
8898 (when (setq list (symbol-value
8900 (intern (format "gnus-newsgroup-%s"
8902 (push (cons (cdr type)
8903 (if (memq (cdr type) uncompressed) list
8904 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8907 ;; Enter these new marks into the info of the group.
8909 (setcar (nthcdr 3 info) newmarked)
8910 ;; Add the marks lists to the end of the info.
8912 (setcdr (nthcdr 2 info) (list newmarked))))
8914 ;; Cut off the end of the info if there's nothing else there.
8918 (when (nthcdr (decf i) info)
8919 (setcdr (nthcdr i info) nil)))))))
8921 (defun gnus-add-marked-articles (group type articles &optional info force)
8922 ;; Add ARTICLES of TYPE to the info of GROUP.
8923 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8924 ;; add, but replace marked articles of TYPE with ARTICLES.
8925 (let ((info (or info (gnus-get-info group)))
8926 (uncompressed '(score bookmark killed))
8929 (and (not (setq marked (nthcdr 3 info)))
8931 (setcdr (nthcdr 2 info)
8932 (list (list (cons type (gnus-compress-sequence
8934 (and (not (setq m (assq type (car marked))))
8937 (cons (cons type (gnus-compress-sequence articles t) )
8941 (setcar (nthcdr 3 info)
8942 (delq (assq type (car marked)) (car marked)))
8943 (setcdr m (gnus-compress-sequence articles t)))
8944 (setcdr m (gnus-compress-sequence
8945 (sort (nconc (gnus-uncompress-range (cdr m))
8946 (copy-sequence articles)) '<) t))))))
8948 (defun gnus-set-mode-line (where)
8949 "This function sets the mode line of the article or summary buffers.
8950 If WHERE is `summary', the summary mode line format will be used."
8951 ;; Is this mode line one we keep updated?
8952 (when (memq where gnus-updated-mode-lines)
8955 ;; We evaluate this in the summary buffer since these
8956 ;; variables are buffer-local to that buffer.
8957 (set-buffer gnus-summary-buffer)
8958 ;; We bind all these variables that are used in the `eval' form
8960 (let* ((mformat (symbol-value
8962 (format "gnus-%s-mode-line-format-spec" where))))
8963 (gnus-tmp-group-name gnus-newsgroup-name)
8964 (gnus-tmp-article-number (or gnus-current-article 0))
8965 (gnus-tmp-unread gnus-newsgroup-unreads)
8966 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
8967 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
8968 (gnus-tmp-unread-and-unselected
8969 (cond ((and (zerop gnus-tmp-unread-and-unticked)
8970 (zerop gnus-tmp-unselected)) "")
8971 ((zerop gnus-tmp-unselected)
8972 (format "{%d more}" gnus-tmp-unread-and-unticked))
8973 (t (format "{%d(+%d) more}"
8974 gnus-tmp-unread-and-unticked
8975 gnus-tmp-unselected))))
8977 (if (and gnus-current-headers
8978 (vectorp gnus-current-headers))
8979 (gnus-mode-string-quote
8980 (mail-header-subject gnus-current-headers)) ""))
8982 gnus-tmp-header);; passed as argument to any user-format-funcs
8983 (setq mode-string (eval mformat))
8984 (setq max-len (max 4 (if gnus-mode-non-string-length
8986 gnus-mode-non-string-length)
8987 (length mode-string))))
8988 ;; We might have to chop a bit of the string off...
8989 (when (> (length mode-string) max-len)
8991 (concat (gnus-truncate-string mode-string (- max-len 3))
8993 ;; Pad the mode string a bit.
8994 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
8995 ;; Update the mode line.
8996 (setq mode-line-buffer-identification (list mode-string))
8997 (set-buffer-modified-p t))))
8999 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
9000 "Go through the HEADERS list and add all Xrefs to a hash table.
9001 The resulting hash table is returned, or nil if no Xrefs were found."
9002 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
9003 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
9004 (xref-hashtb (make-vector 63 0))
9005 start group entry number xrefs header)
9007 (setq header (pop headers))
9008 (when (and (setq xrefs (mail-header-xref header))
9009 (not (memq (setq number (mail-header-number header))
9012 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
9013 (setq start (match-end 0))
9014 (setq group (if prefix
9015 (concat prefix (substring xrefs (match-beginning 1)
9017 (substring xrefs (match-beginning 1) (match-end 1))))
9019 (string-to-int (substring xrefs (match-beginning 2)
9021 (if (setq entry (gnus-gethash group xref-hashtb))
9022 (setcdr entry (cons number (cdr entry)))
9023 (gnus-sethash group (cons number nil) xref-hashtb)))))
9024 (and start xref-hashtb)))
9026 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
9027 "Look through all the headers and mark the Xrefs as read."
9028 (let ((virtual (gnus-virtual-group-p from-newsgroup))
9029 name entry info xref-hashtb idlist method nth4)
9031 (set-buffer gnus-group-buffer)
9032 (when (setq xref-hashtb
9033 (gnus-create-xref-hashtb from-newsgroup headers unreads))
9036 (unless (string= from-newsgroup (setq name (symbol-name group)))
9037 (setq idlist (symbol-value group))
9038 ;; Dead groups are not updated.
9040 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
9042 (if (stringp (setq nth4 (gnus-info-method info)))
9043 (setq nth4 (gnus-server-to-method nth4))))
9044 ;; Only do the xrefs if the group has the same
9045 ;; select method as the group we have just read.
9046 (or (gnus-methods-equal-p
9047 nth4 (gnus-find-method-for-group from-newsgroup))
9049 (equal nth4 (setq method (gnus-find-method-for-group
9051 (and (equal (car nth4) (car method))
9052 (equal (nth 1 nth4) (nth 1 method))))
9053 gnus-use-cross-reference
9054 (or (not (eq gnus-use-cross-reference t))
9056 ;; Only do cross-references on subscribed
9057 ;; groups, if that is what is wanted.
9058 (<= (gnus-info-level info) gnus-level-subscribed))
9059 (gnus-group-make-articles-read name idlist))))
9062 (defun gnus-group-make-articles-read (group articles)
9064 (entry (gnus-gethash group gnus-newsrc-hashtb))
9065 (info (nth 2 entry))
9066 (active (gnus-active group))
9068 ;; First peel off all illegal article numbers.
9070 (let ((ids articles)
9074 (if (and first (> id (cdr active)))
9076 ;; We'll end up in this situation in one particular
9077 ;; obscure situation. If you re-scan a group and get
9078 ;; a new article that is cross-posted to a different
9079 ;; group that has not been re-scanned, you might get
9080 ;; crossposted article that has a higher number than
9081 ;; Gnus believes possible. So we re-activate this
9082 ;; group as well. This might mean doing the
9083 ;; crossposting thingy will *increase* the number
9084 ;; of articles in some groups. Tsk, tsk.
9085 (setq active (or (gnus-activate-group group) active))))
9086 (if (or (> id (cdr active))
9087 (< id (car active)))
9088 (setq articles (delq id articles)))
9089 (setq ids (cdr ids)))))
9090 ;; If the read list is nil, we init it.
9092 (null (gnus-info-read info))
9094 (gnus-info-set-read info (cons 1 (1- (car active)))))
9095 ;; Then we add the read articles to the range.
9100 (gnus-info-read info) (setq articles (sort articles '<)))))
9101 ;; Then we have to re-compute how many unread
9102 ;; articles there are in this group.
9107 (setq num (- (1+ (cdr active)) (car active))))
9108 ((not (listp (cdr range)))
9109 (setq num (- (cdr active) (- (1+ (cdr range))
9113 (if (numberp (car range))
9115 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
9116 (setq range (cdr range)))
9117 (setq num (- (cdr active) num))))
9118 ;; Update the number of unread articles.
9120 ;; Update the group buffer.
9121 (gnus-group-update-group group t)))))
9123 (defun gnus-methods-equal-p (m1 m2)
9124 (let ((m1 (or m1 gnus-select-method))
9125 (m2 (or m2 gnus-select-method)))
9127 (and (eq (car m1) (car m2))
9128 (or (not (memq 'address (assoc (symbol-name (car m1))
9129 gnus-valid-select-methods)))
9130 (equal (nth 1 m1) (nth 1 m2)))))))
9132 (defsubst gnus-header-value ()
9133 (buffer-substring (match-end 0) (gnus-point-at-eol)))
9135 (defvar gnus-newsgroup-none-id 0)
9137 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
9138 (let ((cur nntp-server-buffer)
9141 (save-excursion (set-buffer gnus-summary-buffer)
9142 gnus-newsgroup-dependencies)))
9143 headers id id-dep ref-dep end ref)
9145 (set-buffer nntp-server-buffer)
9146 (run-hooks 'gnus-parse-headers-hook)
9147 (let ((case-fold-search t)
9148 in-reply-to header p lines)
9149 (goto-char (point-min))
9150 ;; Search to the beginning of the next header. Error messages
9151 ;; do not begin with 2 or 3.
9152 (while (re-search-forward "^[23][0-9]+ " nil t)
9155 ;; This implementation of this function, with nine
9156 ;; search-forwards instead of the one re-search-forward and
9157 ;; a case (which basically was the old function) is actually
9158 ;; about twice as fast, even though it looks messier. You
9159 ;; can't have everything, I guess. Speed and elegance
9160 ;; doesn't always go hand in hand.
9169 (narrow-to-region (point)
9170 (or (and (search-forward "\n.\n" nil t)
9176 (if (search-forward "\nsubject: " nil t)
9177 (gnus-header-value) "(none)"))
9181 (if (search-forward "\nfrom: " nil t)
9182 (gnus-header-value) "(nobody)"))
9186 (if (search-forward "\ndate: " nil t)
9187 (gnus-header-value) ""))
9191 (if (search-forward "\nmessage-id: " nil t)
9192 (setq id (gnus-header-value))
9193 ;; If there was no message-id, we just fake one to make
9194 ;; subsequent routines simpler.
9195 (setq id (concat "none+"
9197 (setq gnus-newsgroup-none-id
9198 (1+ gnus-newsgroup-none-id)))))))
9202 (if (search-forward "\nreferences: " nil t)
9205 (setq end (match-end 0))
9211 (search-backward ">" end t)
9214 (search-backward "<" end t)
9216 ;; Get the references from the in-reply-to header if there
9217 ;; were no references and the in-reply-to header looks
9219 (if (and (search-forward "\nin-reply-to: " nil t)
9220 (setq in-reply-to (gnus-header-value))
9221 (string-match "<[^>]+>" in-reply-to))
9222 (setq ref (substring in-reply-to (match-beginning 0)
9230 (if (search-forward "\nlines: " nil t)
9231 (if (numberp (setq lines (read cur)))
9237 (and (search-forward "\nxref: " nil t)
9238 (gnus-header-value)))))
9239 ;; We do the threading while we read the headers. The
9240 ;; message-id and the last reference are both entered into
9241 ;; the same hash table. Some tippy-toeing around has to be
9242 ;; done in case an article has arrived before the article
9243 ;; which it refers to.
9244 (if (boundp (setq id-dep (intern id dependencies)))
9245 (if (and (car (symbol-value id-dep))
9247 ;; An article with this Message-ID has already
9248 ;; been seen, so we ignore this one, except we add
9249 ;; any additional Xrefs (in case the two articles
9250 ;; came from different servers).
9252 (mail-header-set-xref
9253 (car (symbol-value id-dep))
9254 (concat (or (mail-header-xref
9255 (car (symbol-value id-dep))) "")
9256 (or (mail-header-xref header) "")))
9258 (setcar (symbol-value id-dep) header))
9259 (set id-dep (list header)))
9261 (if (boundp (setq ref-dep (intern ref dependencies)))
9262 (setcdr (symbol-value ref-dep)
9263 (nconc (cdr (symbol-value ref-dep))
9264 (list (symbol-value id-dep))))
9265 (set ref-dep (list nil (symbol-value id-dep))))
9266 (setq headers (cons header headers)))
9267 (goto-char (point-max))
9269 (nreverse headers)))))
9271 ;; The following macros and functions were written by Felix Lee
9272 ;; <flee@cse.psu.edu>.
9274 (defmacro gnus-nov-read-integer ()
9276 (if (= (following-char) ?\t)
9278 (let ((num (condition-case nil (read buffer) (error nil))))
9279 (if (numberp num) num 0)))
9280 (or (eobp) (forward-char 1))))
9282 (defmacro gnus-nov-skip-field ()
9283 '(search-forward "\t" eol 'move))
9285 (defmacro gnus-nov-field ()
9286 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9288 ;; Goes through the xover lines and returns a list of vectors
9289 (defun gnus-get-newsgroup-headers-xover (sequence &optional
9290 force-new dependencies)
9291 "Parse the news overview data in the server buffer, and return a
9292 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9293 ;; Get the Xref when the users reads the articles since most/some
9294 ;; NNTP servers do not include Xrefs when using XOVER.
9295 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9296 (let ((cur nntp-server-buffer)
9297 (dependencies (or dependencies gnus-newsgroup-dependencies))
9298 number headers header)
9300 (set-buffer nntp-server-buffer)
9301 ;; Allow the user to mangle the headers before parsing them.
9302 (run-hooks 'gnus-parse-headers-hook)
9303 (goto-char (point-min))
9304 (while (and sequence (not (eobp)))
9305 (setq number (read cur))
9306 (while (and sequence (< (car sequence) number))
9307 (setq sequence (cdr sequence)))
9309 (eq number (car sequence))
9311 (setq sequence (cdr sequence))
9313 (inline (gnus-nov-parse-line
9314 number dependencies force-new)))
9315 (setq headers (cons header headers)))))
9317 (setq headers (nreverse headers)))
9320 ;; This function has to be called with point after the article number
9321 ;; on the beginning of the line.
9322 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9324 (eol (gnus-point-at-eol))
9325 (buffer (current-buffer))
9326 header ref id id-dep ref-dep)
9328 ;; overview: [num subject from date id refs chars lines misc]
9329 (narrow-to-region (point) eol)
9330 (or (eobp) (forward-char))
9336 (gnus-nov-field) ; subject
9337 (gnus-nov-field) ; from
9338 (gnus-nov-field) ; date
9339 (setq id (or (gnus-nov-field)
9342 (setq none (1+ none)))))) ; id
9345 (let ((beg (point)))
9346 (search-forward "\t" eol)
9347 (if (search-backward ">" beg t)
9351 (search-backward "<" beg t)))
9353 (gnus-nov-field)) ; refs
9354 (gnus-nov-read-integer) ; chars
9355 (gnus-nov-read-integer) ; lines
9356 (if (= (following-char) ?\n)
9358 (gnus-nov-field)) ; misc
9361 (gnus-error 4 "Strange nov line")
9367 ;; We build the thread tree.
9369 (if (boundp (setq id-dep (intern id dependencies)))
9370 (if (and (car (symbol-value id-dep))
9372 ;; An article with this Message-ID has already been seen,
9373 ;; so we ignore this one, except we add any additional
9374 ;; Xrefs (in case the two articles came from different
9377 (mail-header-set-xref
9378 (car (symbol-value id-dep))
9379 (concat (or (mail-header-xref
9380 (car (symbol-value id-dep))) "")
9381 (or (mail-header-xref header) "")))
9383 (setcar (symbol-value id-dep) header))
9384 (set id-dep (list header))))
9387 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9388 (setcdr (symbol-value ref-dep)
9389 (nconc (cdr (symbol-value ref-dep))
9390 (list (symbol-value id-dep))))
9391 (set ref-dep (list nil (symbol-value id-dep))))))
9394 (defun gnus-article-get-xrefs ()
9395 "Fill in the Xref value in `gnus-current-headers', if necessary.
9396 This is meant to be called in `gnus-article-internal-prepare-hook'."
9397 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9398 gnus-current-headers)))
9399 (or (not gnus-use-cross-reference)
9401 (and (mail-header-xref headers)
9402 (not (string= (mail-header-xref headers) "")))
9403 (let ((case-fold-search t)
9406 (nnheader-narrow-to-headers)
9407 (goto-char (point-min))
9408 (if (or (and (eq (downcase (following-char)) ?x)
9409 (looking-at "Xref:"))
9410 (search-forward "\nXref:" nil t))
9412 (goto-char (1+ (match-end 0)))
9413 (setq xref (buffer-substring (point)
9414 (progn (end-of-line) (point))))
9415 (mail-header-set-xref headers xref))))))))
9417 (defun gnus-summary-insert-subject (id &optional old-header)
9418 "Find article ID and insert the summary line for that article."
9419 (let ((header (or old-header (gnus-read-header id)))
9420 (number (and (numberp id) id))
9423 ;; Rebuild the thread that this article is part of and go to the
9424 ;; article we have fetched.
9426 (when (setq pos (text-property-any
9427 (point-min) (point-max) 'gnus-number
9428 (mail-header-number old-header)))
9431 (gnus-data-remove (mail-header-number old-header))))
9433 (mail-header-set-number header (mail-header-number old-header)))
9434 (setq gnus-newsgroup-sparse
9435 (delq (setq number (mail-header-number header))
9436 gnus-newsgroup-sparse))
9437 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
9438 (gnus-rebuild-thread (mail-header-id header))
9439 (gnus-summary-goto-subject number nil t))
9440 (when (and (numberp number)
9442 ;; We have to update the boundaries even if we can't fetch the
9443 ;; article if ID is a number -- so that the next `P' or `N'
9444 ;; command will fetch the previous (or next) article even
9445 ;; if the one we tried to fetch this time has been canceled.
9446 (and (> number gnus-newsgroup-end)
9447 (setq gnus-newsgroup-end number))
9448 (and (< number gnus-newsgroup-begin)
9449 (setq gnus-newsgroup-begin number))
9450 (setq gnus-newsgroup-unselected
9451 (delq number gnus-newsgroup-unselected)))
9452 ;; Report back a success?
9453 (and header (mail-header-number header))))
9455 (defun gnus-summary-work-articles (n)
9456 "Return a list of articles to be worked upon. The prefix argument,
9457 the list of process marked articles, and the current article will be
9458 taken into consideration."
9460 ((and n (numberp n))
9461 ;; A numerical prefix has been given.
9462 (let ((backward (< n 0))
9468 (push (setq article (gnus-summary-article-number))
9471 (gnus-summary-find-prev nil article)
9472 (gnus-summary-find-next nil article)))
9474 (nreverse articles)))
9475 ((and (boundp 'transient-mark-mode)
9478 ;; Work on the region between point and mark.
9479 (let ((max (max (point) (mark)))
9482 (goto-char (min (point) (mark)))
9485 (push (setq article (gnus-summary-article-number)) articles)
9486 (gnus-summary-find-next nil article)
9488 (nreverse articles))))
9489 (gnus-newsgroup-processable
9490 ;; There are process-marked articles present.
9491 (reverse gnus-newsgroup-processable))
9493 ;; Just return the current article.
9494 (list (gnus-summary-article-number)))))
9496 (defun gnus-summary-search-group (&optional backward use-level)
9497 "Search for next unread newsgroup.
9498 If optional argument BACKWARD is non-nil, search backward instead."
9500 (set-buffer gnus-group-buffer)
9501 (if (gnus-group-search-forward
9502 backward nil (if use-level (gnus-group-group-level) nil))
9503 (gnus-group-group-name))))
9505 (defun gnus-summary-best-group (&optional exclude-group)
9506 "Find the name of the best unread group.
9507 If EXCLUDE-GROUP, do not go to this group."
9509 (set-buffer gnus-group-buffer)
9511 (gnus-group-best-unread-group exclude-group))))
9513 (defun gnus-summary-find-next (&optional unread article backward)
9514 (if backward (gnus-summary-find-prev)
9515 (let* ((dummy (gnus-summary-article-intangible-p))
9516 (article (or article (gnus-summary-article-number)))
9517 (arts (gnus-data-find-list article))
9519 (when (and (not dummy)
9520 (or (not gnus-summary-check-current)
9522 (not (gnus-data-unread-p (car arts)))))
9523 (setq arts (cdr arts)))
9528 (when (gnus-data-unread-p (car arts))
9529 (setq result (car arts)
9531 (setq arts (cdr arts)))
9534 (goto-char (gnus-data-pos result))
9535 (gnus-data-number result)))))
9537 (defun gnus-summary-find-prev (&optional unread article)
9538 (let* ((eobp (eobp))
9539 (article (or article (gnus-summary-article-number)))
9540 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9542 (when (and (not eobp)
9543 (or (not gnus-summary-check-current)
9545 (not (gnus-data-unread-p (car arts)))))
9546 (setq arts (cdr arts)))
9551 (and (gnus-data-unread-p (car arts))
9552 (setq result (car arts)
9554 (setq arts (cdr arts)))
9558 (goto-char (gnus-data-pos result))
9559 (gnus-data-number result)))))
9561 (defun gnus-summary-find-subject (subject &optional unread backward article)
9562 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9563 (article (or article (gnus-summary-article-number)))
9564 (articles (gnus-data-list backward))
9565 (arts (gnus-data-find-list article articles))
9567 (when (or (not gnus-summary-check-current)
9569 (not (gnus-data-unread-p (car arts))))
9570 (setq arts (cdr arts)))
9572 (and (or (not unread)
9573 (gnus-data-unread-p (car arts)))
9574 (vectorp (gnus-data-header (car arts)))
9576 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9577 (setq result (car arts)
9579 (setq arts (cdr arts)))
9581 (goto-char (gnus-data-pos result))
9582 (gnus-data-number result))))
9584 (defun gnus-summary-search-forward (&optional unread subject backward)
9585 "Search forward for an article.
9586 If UNREAD, look for unread articles. If SUBJECT, look for
9587 articles with that subject. If BACKWARD, search backward instead."
9588 (cond (subject (gnus-summary-find-subject subject unread backward))
9589 (backward (gnus-summary-find-prev unread))
9590 (t (gnus-summary-find-next unread))))
9592 (defun gnus-recenter (&optional n)
9593 "Center point in window and redisplay frame.
9594 Also do horizontal recentering."
9596 (when (and gnus-auto-center-summary
9597 (not (eq gnus-auto-center-summary 'vertical)))
9598 (gnus-horizontal-recenter))
9601 (defun gnus-summary-recenter ()
9602 "Center point in the summary window.
9603 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9604 displayed, no centering will be performed."
9605 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9606 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9607 (let* ((top (cond ((< (window-height) 4) 0)
9608 ((< (window-height) 7) 1)
9610 (height (1- (window-height)))
9611 (bottom (save-excursion (goto-char (point-max))
9612 (forward-line (- height))
9614 (window (get-buffer-window (current-buffer))))
9615 ;; The user has to want it.
9616 (when gnus-auto-center-summary
9617 (when (get-buffer-window gnus-article-buffer)
9618 ;; Only do recentering when the article buffer is displayed,
9619 ;; Set the window start to either `bottom', which is the biggest
9620 ;; possible valid number, or the second line from the top,
9621 ;; whichever is the least.
9623 window (min bottom (save-excursion
9624 (forward-line (- top)) (point)))))
9625 ;; Do horizontal recentering while we're at it.
9626 (when (and (get-buffer-window (current-buffer) t)
9627 (not (eq gnus-auto-center-summary 'vertical)))
9628 (let ((selected (selected-window)))
9629 (select-window (get-buffer-window (current-buffer) t))
9630 (gnus-summary-position-point)
9631 (gnus-horizontal-recenter)
9632 (select-window selected))))))
9634 (defun gnus-horizontal-recenter ()
9635 "Recenter the current buffer horizontally."
9636 (if (< (current-column) (/ (window-width) 2))
9637 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9638 (let* ((orig (point))
9639 (end (window-end (get-buffer-window (current-buffer) t)))
9641 ;; Find the longest line currently displayed in the window.
9642 (goto-char (window-start))
9643 (while (and (not (eobp))
9646 (setq max (max max (current-column)))
9649 ;; Scroll horizontally to center (sort of) the point.
9650 (if (> max (window-width))
9652 (get-buffer-window (current-buffer) t)
9653 (min (- (current-column) (/ (window-width) 3))
9654 (+ 2 (- max (window-width)))))
9655 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9658 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9659 (defun gnus-short-group-name (group &optional levels)
9660 "Collapse GROUP name LEVELS."
9667 (while (string-match "\\." group skip)
9668 (setq skip (match-end 0)
9671 (if (string-match ":" group)
9672 (setq foreign (substring group 0 (match-end 0))
9673 group (substring group (match-end 0))))
9675 (if (and (string-match "\\." group)
9676 (> levels (- gnus-group-uncollapsed-levels 1)))
9677 (setq name (concat name (substring group 0 1))
9678 group (substring group (match-end 0))
9680 name (concat name "."))
9681 (setq name (concat foreign name group)
9685 (defun gnus-summary-jump-to-group (newsgroup)
9686 "Move point to NEWSGROUP in group mode buffer."
9687 ;; Keep update point of group mode buffer if visible.
9688 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9689 (save-window-excursion
9690 ;; Take care of tree window mode.
9691 (if (get-buffer-window gnus-group-buffer)
9692 (pop-to-buffer gnus-group-buffer))
9693 (gnus-group-jump-to-group newsgroup))
9695 ;; Take care of tree window mode.
9696 (if (get-buffer-window gnus-group-buffer)
9697 (pop-to-buffer gnus-group-buffer)
9698 (set-buffer gnus-group-buffer))
9699 (gnus-group-jump-to-group newsgroup))))
9701 ;; This function returns a list of article numbers based on the
9702 ;; difference between the ranges of read articles in this group and
9703 ;; the range of active articles.
9704 (defun gnus-list-of-unread-articles (group)
9705 (let* ((read (gnus-info-read (gnus-get-info group)))
9706 (active (gnus-active group))
9709 ;; If none are read, then all are unread.
9711 (setq first (car active))
9712 ;; If the range of read articles is a single range, then the
9713 ;; first unread article is the article after the last read
9714 ;; article. Sounds logical, doesn't it?
9715 (if (not (listp (cdr read)))
9716 (setq first (1+ (cdr read)))
9717 ;; `read' is a list of ranges.
9718 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9723 (while (< first nlast)
9724 (setq unread (cons first unread))
9725 (setq first (1+ first))))
9726 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9727 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9728 (setq read (cdr read)))))
9729 ;; And add the last unread articles.
9730 (while (<= first last)
9731 (setq unread (cons first unread))
9732 (setq first (1+ first)))
9733 ;; Return the list of unread articles.
9736 (defun gnus-list-of-read-articles (group)
9737 "Return a list of unread, unticked and non-dormant articles."
9738 (let* ((info (gnus-get-info group))
9739 (marked (gnus-info-marks info))
9740 (active (gnus-active group)))
9742 (gnus-set-difference
9743 (gnus-sorted-complement
9744 (gnus-uncompress-range active)
9745 (gnus-list-of-unread-articles group))
9747 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9748 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9750 ;; Various summary commands
9752 (defun gnus-summary-universal-argument (arg)
9753 "Perform any operation on all articles that are process/prefixed."
9755 (gnus-set-global-variables)
9756 (let ((articles (gnus-summary-work-articles arg))
9763 (substitute-command-keys
9764 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9767 (gnus-error 1 "Undefined key")
9770 (gnus-summary-goto-subject (setq article (pop articles)))
9771 (command-execute func)
9772 (gnus-summary-remove-process-mark article)))))
9773 (gnus-summary-position-point))
9775 (defun gnus-summary-toggle-truncation (&optional arg)
9776 "Toggle truncation of summary lines.
9777 With arg, turn line truncation on iff arg is positive."
9779 (setq truncate-lines
9780 (if (null arg) (not truncate-lines)
9781 (> (prefix-numeric-value arg) 0)))
9784 (defun gnus-summary-reselect-current-group (&optional all rescan)
9785 "Exit and then reselect the current newsgroup.
9786 The prefix argument ALL means to select all articles."
9788 (gnus-set-global-variables)
9789 (let ((current-subject (gnus-summary-article-number))
9790 (group gnus-newsgroup-name))
9791 (setq gnus-newsgroup-begin nil)
9793 ;; We have to adjust the point of group mode buffer because the
9794 ;; current point was moved to the next unread newsgroup by
9796 (gnus-summary-jump-to-group group)
9799 (gnus-group-get-new-news-this-group 1)))
9800 (gnus-group-read-group all t)
9801 (gnus-summary-goto-subject current-subject)))
9803 (defun gnus-summary-rescan-group (&optional all)
9804 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9806 (gnus-summary-reselect-current-group all t))
9808 (defun gnus-summary-update-info ()
9809 (let* ((group gnus-newsgroup-name))
9810 (when gnus-newsgroup-kill-headers
9811 (setq gnus-newsgroup-killed
9812 (gnus-compress-sequence
9814 (gnus-set-sorted-intersection
9815 (gnus-uncompress-range gnus-newsgroup-killed)
9816 (setq gnus-newsgroup-unselected
9817 (sort gnus-newsgroup-unselected '<)))
9818 (setq gnus-newsgroup-unreads
9819 (sort gnus-newsgroup-unreads '<))) t)))
9820 (unless (listp (cdr gnus-newsgroup-killed))
9821 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9822 (let ((headers gnus-newsgroup-headers))
9823 (run-hooks 'gnus-exit-group-hook)
9824 (unless gnus-save-score
9825 (setq gnus-newsgroup-scored nil))
9826 ;; Set the new ranges of read articles.
9827 (gnus-update-read-articles
9828 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9829 ;; Set the current article marks.
9831 ;; Do the cross-ref thing.
9832 (when gnus-use-cross-reference
9833 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9834 ;; Do adaptive scoring, and possibly save score files.
9835 (when gnus-newsgroup-adaptive
9836 (gnus-score-adaptive))
9837 (when gnus-use-scoring
9839 ;; Do not switch windows but change the buffer to work.
9840 (set-buffer gnus-group-buffer)
9841 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9842 (gnus-group-update-group group)))))
9844 (defun gnus-summary-exit (&optional temporary)
9845 "Exit reading current newsgroup, and then return to group selection mode.
9846 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9848 (gnus-set-global-variables)
9849 (gnus-kill-save-kill-buffer)
9850 (let* ((group gnus-newsgroup-name)
9851 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9853 (buf (current-buffer)))
9854 (run-hooks 'gnus-summary-prepare-exit-hook)
9855 ;; If we have several article buffers, we kill them at exit.
9856 (unless gnus-single-article-buffer
9857 (gnus-kill-buffer gnus-original-article-buffer)
9858 (setq gnus-article-current nil))
9859 (when gnus-use-cache
9860 (gnus-cache-possibly-remove-articles)
9861 (gnus-cache-save-buffers))
9862 (when gnus-use-trees
9863 (gnus-tree-close group))
9864 ;; Make all changes in this group permanent.
9866 (gnus-summary-update-info))
9867 (gnus-close-group group)
9868 ;; Make sure where I was, and go to next newsgroup.
9869 (set-buffer gnus-group-buffer)
9871 (gnus-group-jump-to-group group))
9872 (run-hooks 'gnus-summary-exit-hook)
9874 (gnus-group-next-unread-group 1))
9877 ;; If we have several article buffers, we kill them at exit.
9878 (unless gnus-single-article-buffer
9879 (gnus-kill-buffer gnus-article-buffer)
9880 (gnus-kill-buffer gnus-original-article-buffer)
9881 (setq gnus-article-current nil))
9883 (if (not gnus-kill-summary-on-exit)
9884 (gnus-deaden-summary)
9885 ;; We set all buffer-local variables to nil. It is unclear why
9886 ;; this is needed, but if we don't, buffer-local variables are
9887 ;; not garbage-collected, it seems. This would the lead to en
9888 ;; ever-growing Emacs.
9889 (gnus-summary-clear-local-variables)
9890 (when (get-buffer gnus-article-buffer)
9891 (bury-buffer gnus-article-buffer))
9892 ;; We clear the global counterparts of the buffer-local
9893 ;; variables as well, just to be on the safe side.
9894 (gnus-configure-windows 'group 'force)
9895 (gnus-summary-clear-local-variables)
9896 ;; Return to group mode buffer.
9897 (if (eq mode 'gnus-summary-mode)
9898 (gnus-kill-buffer buf)))
9899 (setq gnus-current-select-method gnus-select-method)
9900 (pop-to-buffer gnus-group-buffer)
9901 ;; Clear the current group name.
9902 (if (not quit-config)
9904 (gnus-group-jump-to-group group)
9905 (gnus-group-next-unread-group 1)
9906 (gnus-configure-windows 'group 'force))
9907 (if (not (buffer-name (car quit-config)))
9908 (gnus-configure-windows 'group 'force)
9909 (set-buffer (car quit-config))
9910 (and (eq major-mode 'gnus-summary-mode)
9911 (gnus-set-global-variables))
9912 (gnus-configure-windows (cdr quit-config))))
9914 (setq gnus-newsgroup-name nil)))))
9916 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9917 (defun gnus-summary-exit-no-update (&optional no-questions)
9918 "Quit reading current newsgroup without updating read article info."
9920 (gnus-set-global-variables)
9921 (let* ((group gnus-newsgroup-name)
9922 (quit-config (gnus-group-quit-config group)))
9923 (when (or no-questions
9925 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9926 ;; If we have several article buffers, we kill them at exit.
9927 (unless gnus-single-article-buffer
9928 (gnus-kill-buffer gnus-article-buffer)
9929 (gnus-kill-buffer gnus-original-article-buffer)
9930 (setq gnus-article-current nil))
9931 (if (not gnus-kill-summary-on-exit)
9932 (gnus-deaden-summary)
9933 (gnus-close-group group)
9934 (gnus-summary-clear-local-variables)
9935 (set-buffer gnus-group-buffer)
9936 (gnus-summary-clear-local-variables)
9937 (when (get-buffer gnus-summary-buffer)
9938 (kill-buffer gnus-summary-buffer)))
9939 (unless gnus-single-article-buffer
9940 (setq gnus-article-current nil))
9941 (when gnus-use-trees
9942 (gnus-tree-close group))
9943 (when (get-buffer gnus-article-buffer)
9944 (bury-buffer gnus-article-buffer))
9945 ;; Return to the group buffer.
9946 (gnus-configure-windows 'group 'force)
9947 ;; Clear the current group name.
9948 (setq gnus-newsgroup-name nil)
9949 (when (equal (gnus-group-group-name) group)
9950 (gnus-group-next-unread-group 1))
9952 (if (not (buffer-name (car quit-config)))
9953 (gnus-configure-windows 'group 'force)
9954 (set-buffer (car quit-config))
9955 (when (eq major-mode 'gnus-summary-mode)
9956 (gnus-set-global-variables))
9957 (gnus-configure-windows (cdr quit-config)))))))
9961 (defvar gnus-dead-summary-mode-map nil)
9963 (if gnus-dead-summary-mode-map
9965 (setq gnus-dead-summary-mode-map (make-keymap))
9966 (suppress-keymap gnus-dead-summary-mode-map)
9967 (substitute-key-definition
9968 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
9969 (let ((keys '("\C-d" "\r" "\177")))
9971 (define-key gnus-dead-summary-mode-map
9972 (pop keys) 'gnus-summary-wake-up-the-dead))))
9974 (defvar gnus-dead-summary-mode nil
9975 "Minor mode for Gnus summary buffers.")
9977 (defun gnus-dead-summary-mode (&optional arg)
9978 "Minor mode for Gnus summary buffers."
9980 (when (eq major-mode 'gnus-summary-mode)
9981 (make-local-variable 'gnus-dead-summary-mode)
9982 (setq gnus-dead-summary-mode
9983 (if (null arg) (not gnus-dead-summary-mode)
9984 (> (prefix-numeric-value arg) 0)))
9985 (when gnus-dead-summary-mode
9986 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
9987 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
9988 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
9989 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
9990 minor-mode-map-alist)))))
9992 (defun gnus-deaden-summary ()
9993 "Make the current summary buffer into a dead summary buffer."
9994 ;; Kill any previous dead summary buffer.
9995 (when (and gnus-dead-summary
9996 (buffer-name gnus-dead-summary))
9998 (set-buffer gnus-dead-summary)
9999 (when gnus-dead-summary-mode
10000 (kill-buffer (current-buffer)))))
10001 ;; Make this the current dead summary.
10002 (setq gnus-dead-summary (current-buffer))
10003 (gnus-dead-summary-mode 1)
10004 (let ((name (buffer-name)))
10005 (when (string-match "Summary" name)
10007 (concat (substring name 0 (match-beginning 0)) "Dead "
10008 (substring name (match-beginning 0))) t))))
10010 (defun gnus-kill-or-deaden-summary (buffer)
10011 "Kill or deaden the summary BUFFER."
10012 (when (and (buffer-name buffer)
10013 (not gnus-single-article-buffer))
10015 (set-buffer buffer)
10016 (gnus-kill-buffer gnus-article-buffer)
10017 (gnus-kill-buffer gnus-original-article-buffer)))
10018 (cond (gnus-kill-summary-on-exit
10019 (when (and gnus-use-trees
10020 (and (get-buffer buffer)
10021 (buffer-name (get-buffer buffer))))
10023 (set-buffer (get-buffer buffer))
10024 (gnus-tree-close gnus-newsgroup-name)))
10025 (gnus-kill-buffer buffer))
10026 ((and (get-buffer buffer)
10027 (buffer-name (get-buffer buffer)))
10029 (set-buffer buffer)
10030 (gnus-deaden-summary)))))
10032 (defun gnus-summary-wake-up-the-dead (&rest args)
10033 "Wake up the dead summary buffer."
10035 (gnus-dead-summary-mode -1)
10036 (let ((name (buffer-name)))
10037 (when (string-match "Dead " name)
10039 (concat (substring name 0 (match-beginning 0))
10040 (substring name (match-end 0))) t)))
10041 (gnus-message 3 "This dead summary is now alive again"))
10043 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
10044 (defun gnus-summary-fetch-faq (&optional faq-dir)
10045 "Fetch the FAQ for the current group.
10046 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
10050 (if current-prefix-arg
10052 "Faq dir: " (and (listp gnus-group-faq-directory)
10053 gnus-group-faq-directory)))))
10054 (let (gnus-faq-buffer)
10055 (and (setq gnus-faq-buffer
10056 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
10057 (gnus-configure-windows 'summary-faq))))
10059 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
10060 (defun gnus-summary-describe-group (&optional force)
10061 "Describe the current newsgroup."
10063 (gnus-group-describe-group force gnus-newsgroup-name))
10065 (defun gnus-summary-describe-briefly ()
10066 "Describe summary mode commands briefly."
10069 (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")))
10071 ;; Walking around group mode buffer from summary mode.
10073 (defun gnus-summary-next-group (&optional no-article target-group backward)
10074 "Exit current newsgroup and then select next unread newsgroup.
10075 If prefix argument NO-ARTICLE is non-nil, no article is selected
10076 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
10077 previous group instead."
10079 (gnus-set-global-variables)
10080 (let ((current-group gnus-newsgroup-name)
10081 (current-buffer (current-buffer))
10083 ;; First we semi-exit this group to update Xrefs and all variables.
10084 ;; We can't do a real exit, because the window conf must remain
10085 ;; the same in case the user is prompted for info, and we don't
10086 ;; want the window conf to change before that...
10087 (gnus-summary-exit t)
10088 (while (not entered)
10089 ;; Then we find what group we are supposed to enter.
10090 (set-buffer gnus-group-buffer)
10091 (gnus-group-jump-to-group current-group)
10094 (if (eq gnus-keep-same-level 'best)
10095 (gnus-summary-best-group gnus-newsgroup-name)
10096 (gnus-summary-search-group backward gnus-keep-same-level))))
10097 (if (not target-group)
10098 ;; There are no further groups, so we return to the group
10101 (gnus-message 5 "Returning to the group buffer")
10103 (set-buffer current-buffer)
10104 (gnus-summary-exit))
10105 ;; We try to enter the target group.
10106 (gnus-group-jump-to-group target-group)
10107 (let ((unreads (gnus-group-group-unread)))
10108 (if (and (or (eq t unreads)
10109 (and unreads (not (zerop unreads))))
10110 (gnus-summary-read-group
10111 target-group nil no-article current-buffer))
10113 (setq current-group target-group
10114 target-group nil)))))))
10116 (defun gnus-summary-prev-group (&optional no-article)
10117 "Exit current newsgroup and then select previous unread newsgroup.
10118 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
10120 (gnus-summary-next-group no-article nil t))
10122 ;; Walking around summary lines.
10124 (defun gnus-summary-first-subject (&optional unread)
10125 "Go to the first unread subject.
10126 If UNREAD is non-nil, go to the first unread article.
10127 Returns the article selected or nil if there are no unread articles."
10132 ((null gnus-newsgroup-data)
10133 (gnus-message 3 "No articles in the group")
10135 ;; Pick the first article.
10137 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
10138 (gnus-data-number (car gnus-newsgroup-data)))
10139 ;; No unread articles.
10140 ((null gnus-newsgroup-unreads)
10141 (gnus-message 3 "No more unread articles")
10143 ;; Find the first unread article.
10145 (let ((data gnus-newsgroup-data))
10147 (not (gnus-data-unread-p (car data))))
10148 (setq data (cdr data)))
10151 (goto-char (gnus-data-pos (car data)))
10152 (gnus-data-number (car data)))))))
10153 (gnus-summary-position-point)))
10155 (defun gnus-summary-next-subject (n &optional unread dont-display)
10156 "Go to next N'th summary line.
10157 If N is negative, go to the previous N'th subject line.
10158 If UNREAD is non-nil, only unread articles are selected.
10159 The difference between N and the actual number of steps taken is
10162 (let ((backward (< n 0))
10164 (while (and (> n 0)
10166 (gnus-summary-find-prev unread)
10167 (gnus-summary-find-next unread)))
10169 (if (/= 0 n) (gnus-message 7 "No more%s articles"
10170 (if unread " unread" "")))
10171 (unless dont-display
10172 (gnus-summary-recenter)
10173 (gnus-summary-position-point))
10176 (defun gnus-summary-next-unread-subject (n)
10177 "Go to next N'th unread summary line."
10179 (gnus-summary-next-subject n t))
10181 (defun gnus-summary-prev-subject (n &optional unread)
10182 "Go to previous N'th summary line.
10183 If optional argument UNREAD is non-nil, only unread article is selected."
10185 (gnus-summary-next-subject (- n) unread))
10187 (defun gnus-summary-prev-unread-subject (n)
10188 "Go to previous N'th unread summary line."
10190 (gnus-summary-next-subject (- n) t))
10192 (defun gnus-summary-goto-subject (article &optional force silent)
10193 "Go the subject line of ARTICLE.
10194 If FORCE, also allow jumping to articles not currently shown."
10196 (data (gnus-data-find article)))
10197 ;; We read in the article if we have to.
10200 (gnus-summary-insert-subject article (and (vectorp force) force))
10201 (setq data (gnus-data-find article)))
10206 (gnus-message 3 "Can't find article %d" article))
10208 (goto-char (gnus-data-pos data))
10211 ;; Walking around summary lines with displaying articles.
10213 (defun gnus-summary-expand-window (&optional arg)
10214 "Make the summary buffer take up the entire Emacs frame.
10215 Given a prefix, will force an `article' buffer configuration."
10217 (gnus-set-global-variables)
10219 (gnus-configure-windows 'article 'force)
10220 (gnus-configure-windows 'summary 'force)))
10222 (defun gnus-summary-display-article (article &optional all-header)
10223 "Display ARTICLE in article buffer."
10224 (gnus-set-global-variables)
10228 (if gnus-summary-display-article-function
10229 (funcall gnus-summary-display-article-function article all-header)
10230 (gnus-article-prepare article all-header))
10231 (run-hooks 'gnus-select-article-hook)
10232 (unless (zerop gnus-current-article)
10233 (gnus-summary-goto-subject gnus-current-article))
10234 (gnus-summary-recenter)
10235 (when gnus-use-trees
10236 (gnus-possibly-generate-tree article)
10237 (gnus-highlight-selected-tree article))
10238 ;; Successfully display article.
10239 (gnus-article-set-window-start
10240 (cdr (assq article gnus-newsgroup-bookmarks))))))
10242 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10243 "Select the current article.
10244 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10245 non-nil, the article will be re-fetched even if it already present in
10246 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10248 ;; Make sure we are in the summary buffer to work around bbdb bug.
10249 (unless (eq major-mode 'gnus-summary-mode)
10250 (set-buffer gnus-summary-buffer))
10251 (let ((article (or article (gnus-summary-article-number)))
10252 (all-headers (not (not all-headers))) ;Must be T or NIL.
10253 gnus-summary-display-article-function
10256 (gnus-summary-article-pseudo-p article)
10257 (error "This is a pseudo-article."))
10260 (set-buffer gnus-summary-buffer)
10261 (if (or (and gnus-single-article-buffer
10262 (or (null gnus-current-article)
10263 (null gnus-article-current)
10264 (null (get-buffer gnus-article-buffer))
10265 (not (eq article (cdr gnus-article-current)))
10266 (not (equal (car gnus-article-current)
10267 gnus-newsgroup-name))))
10268 (and (not gnus-single-article-buffer)
10269 (or (null gnus-current-article)
10270 (not (eq gnus-current-article article))))
10272 ;; The requested article is different from the current article.
10274 (gnus-summary-display-article article all-headers)
10275 (setq did article))
10276 (if (or all-headers gnus-show-all-headers)
10277 (gnus-article-show-all-headers))
10280 (gnus-article-set-window-start
10281 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10283 (defun gnus-summary-set-current-mark (&optional current-mark)
10284 "Obsolete function."
10287 (defun gnus-summary-next-article (&optional unread subject backward push)
10288 "Select the next article.
10289 If UNREAD, only unread articles are selected.
10290 If SUBJECT, only articles with SUBJECT are selected.
10291 If BACKWARD, the previous article is selected instead of the next."
10293 (gnus-set-global-variables)
10295 ;; Is there such an article?
10296 ((and (gnus-summary-search-forward unread subject backward)
10297 (or (gnus-summary-display-article (gnus-summary-article-number))
10298 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10299 (gnus-summary-position-point))
10300 ;; If not, we try the first unread, if that is wanted.
10302 gnus-auto-select-same
10303 (or (gnus-summary-first-unread-article)
10304 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10305 (gnus-summary-position-point)
10306 (gnus-message 6 "Wrapped"))
10307 ;; Try to get next/previous article not displayed in this group.
10308 ((and gnus-auto-extend-newsgroup
10309 (not unread) (not subject))
10310 (gnus-summary-goto-article
10311 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10313 ;; Go to next/previous group.
10315 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10316 (gnus-summary-jump-to-group gnus-newsgroup-name))
10317 (let ((cmd last-command-char)
10319 (if (eq gnus-keep-same-level 'best)
10320 (gnus-summary-best-group gnus-newsgroup-name)
10321 (gnus-summary-search-group backward gnus-keep-same-level))))
10322 ;; For some reason, the group window gets selected. We change
10324 (select-window (get-buffer-window (current-buffer)))
10325 ;; Select next unread newsgroup automagically.
10327 ((not gnus-auto-select-next)
10328 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10329 ((or (eq gnus-auto-select-next 'quietly)
10330 (and (eq gnus-auto-select-next 'slightly-quietly)
10332 (and (eq gnus-auto-select-next 'almost-quietly)
10333 (gnus-summary-last-article-p)))
10335 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10336 (gnus-summary-exit)
10337 (gnus-message 7 "No more%s articles (%s)..."
10338 (if unread " unread" "")
10339 (if group (concat "selecting " group)
10341 (gnus-summary-next-group nil group backward)))
10343 (gnus-summary-walk-group-buffer
10344 gnus-newsgroup-name cmd unread backward)))))))
10346 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10347 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10348 (?\C-p (gnus-group-prev-unread-group 1))))
10349 keve key group ended)
10351 (set-buffer gnus-group-buffer)
10352 (gnus-summary-jump-to-group from-group)
10354 (if (eq gnus-keep-same-level 'best)
10355 (gnus-summary-best-group gnus-newsgroup-name)
10356 (gnus-summary-search-group backward gnus-keep-same-level))))
10359 5 "No more%s articles%s" (if unread " unread" "")
10361 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10362 (format " (Type %s for %s [%s])"
10363 (single-key-description cmd) group
10364 (car (gnus-gethash group gnus-newsrc-hashtb)))
10365 (format " (Type %s to exit %s)"
10366 (single-key-description cmd)
10367 gnus-newsgroup-name)))
10368 ;; Confirm auto selection.
10369 (setq key (car (setq keve (gnus-read-event-char))))
10372 ((assq key keystrokes)
10373 (let ((obuf (current-buffer)))
10374 (switch-to-buffer gnus-group-buffer)
10376 (gnus-group-jump-to-group group))
10377 (eval (cadr (assq key keystrokes)))
10378 (setq group (gnus-group-group-name))
10379 (switch-to-buffer obuf))
10382 (if (or (not group)
10383 (gnus-ephemeral-group-p gnus-newsgroup-name))
10384 (gnus-summary-exit)
10385 (gnus-summary-next-group nil group backward)))
10387 (push (cdr keve) unread-command-events))))))
10389 (defun gnus-read-event-char ()
10390 "Get the next event."
10391 (let ((event (read-event)))
10392 (cons (and (numberp event) event) event)))
10394 (defun gnus-summary-next-unread-article ()
10395 "Select unread article after current one."
10397 (gnus-summary-next-article t (and gnus-auto-select-same
10398 (gnus-summary-article-subject))))
10400 (defun gnus-summary-prev-article (&optional unread subject)
10401 "Select the article after the current one.
10402 If UNREAD is non-nil, only unread articles are selected."
10404 (gnus-summary-next-article unread subject t))
10406 (defun gnus-summary-prev-unread-article ()
10407 "Select unred article before current one."
10409 (gnus-summary-prev-article t (and gnus-auto-select-same
10410 (gnus-summary-article-subject))))
10412 (defun gnus-summary-next-page (&optional lines circular)
10413 "Show next page of the selected article.
10414 If at the end of the current article, select the next article.
10415 LINES says how many lines should be scrolled up.
10417 If CIRCULAR is non-nil, go to the start of the article instead of
10418 selecting the next article when reaching the end of the current
10421 (setq gnus-summary-buffer (current-buffer))
10422 (gnus-set-global-variables)
10423 (let ((article (gnus-summary-article-number))
10425 (gnus-configure-windows 'article)
10426 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
10427 (if (and (eq gnus-summary-goto-unread 'never)
10428 (not (gnus-summary-last-article-p article)))
10429 (gnus-summary-next-article)
10430 (gnus-summary-next-unread-article))
10431 (if (or (null gnus-current-article)
10432 (null gnus-article-current)
10433 (/= article (cdr gnus-article-current))
10434 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10435 ;; Selected subject is different from current article's.
10436 (gnus-summary-display-article article)
10437 (gnus-eval-in-buffer-window
10438 gnus-article-buffer
10439 (setq endp (gnus-article-next-page lines)))
10442 (gnus-summary-beginning-of-article))
10444 (gnus-message 3 "End of message"))
10446 (if (and (eq gnus-summary-goto-unread 'never)
10447 (not (gnus-summary-last-article-p article)))
10448 (gnus-summary-next-article)
10449 (gnus-summary-next-unread-article)))))))
10450 (gnus-summary-recenter)
10451 (gnus-summary-position-point)))
10453 (defun gnus-summary-prev-page (&optional lines)
10454 "Show previous page of selected article.
10455 Argument LINES specifies lines to be scrolled down."
10457 (gnus-set-global-variables)
10458 (let ((article (gnus-summary-article-number)))
10459 (gnus-configure-windows 'article)
10460 (if (or (null gnus-current-article)
10461 (null gnus-article-current)
10462 (/= article (cdr gnus-article-current))
10463 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10464 ;; Selected subject is different from current article's.
10465 (gnus-summary-display-article article)
10466 (gnus-summary-recenter)
10467 (gnus-eval-in-buffer-window gnus-article-buffer
10468 (gnus-article-prev-page lines))))
10469 (gnus-summary-position-point))
10471 (defun gnus-summary-scroll-up (lines)
10472 "Scroll up (or down) one line current article.
10473 Argument LINES specifies lines to be scrolled up (or down if negative)."
10475 (gnus-set-global-variables)
10476 (gnus-configure-windows 'article)
10477 (gnus-summary-show-thread)
10478 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10479 (gnus-eval-in-buffer-window
10480 gnus-article-buffer
10482 (if (gnus-article-next-page lines)
10483 (gnus-message 3 "End of message")))
10485 (gnus-article-prev-page (- lines))))))
10486 (gnus-summary-recenter)
10487 (gnus-summary-position-point))
10489 (defun gnus-summary-next-same-subject ()
10490 "Select next article which has the same subject as current one."
10492 (gnus-set-global-variables)
10493 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10495 (defun gnus-summary-prev-same-subject ()
10496 "Select previous article which has the same subject as current one."
10498 (gnus-set-global-variables)
10499 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10501 (defun gnus-summary-next-unread-same-subject ()
10502 "Select next unread article which has the same subject as current one."
10504 (gnus-set-global-variables)
10505 (gnus-summary-next-article t (gnus-summary-article-subject)))
10507 (defun gnus-summary-prev-unread-same-subject ()
10508 "Select previous unread article which has the same subject as current one."
10510 (gnus-set-global-variables)
10511 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10513 (defun gnus-summary-first-unread-article ()
10514 "Select the first unread article.
10515 Return nil if there are no unread articles."
10517 (gnus-set-global-variables)
10519 (if (gnus-summary-first-subject t)
10521 (gnus-summary-show-thread)
10522 (gnus-summary-first-subject t)
10523 (gnus-summary-display-article (gnus-summary-article-number))))
10524 (gnus-summary-position-point)))
10526 (defun gnus-summary-best-unread-article ()
10527 "Select the unread article with the highest score."
10529 (gnus-set-global-variables)
10530 (let ((best -1000000)
10531 (data gnus-newsgroup-data)
10534 (and (gnus-data-unread-p (car data))
10536 (gnus-summary-article-score (gnus-data-number (car data))))
10539 article (gnus-data-number (car data))))
10540 (setq data (cdr data)))
10543 (gnus-summary-goto-article article)
10544 (error "No unread articles"))
10545 (gnus-summary-position-point))))
10547 (defun gnus-summary-last-subject ()
10548 "Go to the last displayed subject line in the group."
10549 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10551 (gnus-summary-goto-subject article))))
10553 (defun gnus-summary-goto-article (article &optional all-headers force)
10554 "Fetch ARTICLE and display it if it exists.
10555 If ALL-HEADERS is non-nil, no header lines are hidden."
10561 (mapcar (lambda (number) (list (int-to-string number)))
10562 gnus-newsgroup-limit)))
10566 (if (gnus-summary-goto-subject article force)
10567 (gnus-summary-display-article article all-headers)
10568 (gnus-message 4 "Couldn't go to article %s" article) nil)
10569 (gnus-summary-position-point)))
10571 (defun gnus-summary-goto-last-article ()
10572 "Go to the previously read article."
10575 (and gnus-last-article
10576 (gnus-summary-goto-article gnus-last-article))
10577 (gnus-summary-position-point)))
10579 (defun gnus-summary-pop-article (number)
10580 "Pop one article off the history and go to the previous.
10581 NUMBER articles will be popped off."
10584 (setq gnus-newsgroup-history
10585 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10587 (gnus-summary-goto-article (car to))
10588 (error "Article history empty")))
10589 (gnus-summary-position-point))
10591 ;; Summary commands and functions for limiting the summary buffer.
10593 (defun gnus-summary-limit-to-articles (n)
10594 "Limit the summary buffer to the next N articles.
10595 If not given a prefix, use the process marked articles instead."
10597 (gnus-set-global-variables)
10599 (let ((articles (gnus-summary-work-articles n)))
10600 (setq gnus-newsgroup-processable nil)
10601 (gnus-summary-limit articles))
10602 (gnus-summary-position-point)))
10604 (defun gnus-summary-pop-limit (&optional total)
10605 "Restore the previous limit.
10606 If given a prefix, remove all limits."
10608 (gnus-set-global-variables)
10610 (setq gnus-newsgroup-limits
10611 (list (mapcar (lambda (h) (mail-header-number h))
10612 gnus-newsgroup-headers))))
10613 (unless gnus-newsgroup-limits
10614 (error "No limit to pop"))
10616 (gnus-summary-limit nil 'pop)
10617 (gnus-summary-position-point)))
10619 (defun gnus-summary-limit-to-subject (subject &optional header)
10620 "Limit the summary buffer to articles that have subjects that match a regexp."
10621 (interactive "sRegexp: ")
10623 (setq header "subject"))
10624 (when (not (equal "" subject))
10626 (let ((articles (gnus-summary-find-matching
10627 (or header "subject") subject 'all)))
10628 (or articles (error "Found no matches for \"%s\"" subject))
10629 (gnus-summary-limit articles))
10630 (gnus-summary-position-point))))
10632 (defun gnus-summary-limit-to-author (from)
10633 "Limit the summary buffer to articles that have authors that match a regexp."
10634 (interactive "sRegexp: ")
10635 (gnus-summary-limit-to-subject from "from"))
10637 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10639 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10641 (defun gnus-summary-limit-to-unread (&optional all)
10642 "Limit the summary buffer to articles that are not marked as read.
10643 If ALL is non-nil, limit strictly to unread articles."
10646 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10647 (gnus-summary-limit-to-marks
10648 ;; Concat all the marks that say that an article is read and have
10650 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10651 gnus-killed-mark gnus-kill-file-mark
10652 gnus-low-score-mark gnus-expirable-mark
10653 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10656 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10657 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10659 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10660 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10661 If REVERSE, limit the summary buffer to articles that are not marked
10662 with MARKS. MARKS can either be a string of marks or a list of marks.
10663 Returns how many articles were removed."
10664 (interactive "sMarks: ")
10665 (gnus-set-global-variables)
10667 (let ((data gnus-newsgroup-data)
10668 (marks (if (listp marks) marks
10669 (append marks nil))) ; Transform to list.
10672 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10673 (memq (gnus-data-mark (car data)) marks))
10674 (setq articles (cons (gnus-data-number (car data)) articles)))
10675 (setq data (cdr data)))
10676 (gnus-summary-limit articles))
10677 (gnus-summary-position-point)))
10679 (defun gnus-summary-limit-to-score (&optional score)
10680 "Limit to articles with score at or above SCORE."
10682 (gnus-set-global-variables)
10683 (setq score (if score
10684 (prefix-numeric-value score)
10685 (or gnus-summary-default-score 0)))
10686 (let ((data gnus-newsgroup-data)
10689 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10691 (push (gnus-data-number (car data)) articles))
10692 (setq data (cdr data)))
10694 (gnus-summary-limit articles)
10695 (gnus-summary-position-point))))
10697 (defun gnus-summary-limit-include-dormant ()
10698 "Display all the hidden articles that are marked as dormant."
10700 (gnus-set-global-variables)
10701 (or gnus-newsgroup-dormant
10702 (error "There are no dormant articles in this group"))
10704 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10705 (gnus-summary-position-point)))
10707 (defun gnus-summary-limit-exclude-dormant ()
10708 "Hide all dormant articles."
10710 (gnus-set-global-variables)
10712 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10713 (gnus-summary-position-point)))
10715 (defun gnus-summary-limit-exclude-childless-dormant ()
10716 "Hide all dormant articles that have no children."
10718 (gnus-set-global-variables)
10719 (let ((data (gnus-data-list t))
10720 articles d children)
10721 ;; Find all articles that are either not dormant or have
10723 (while (setq d (pop data))
10724 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10725 (and (setq children
10726 (gnus-article-children (gnus-data-number d)))
10729 (when (memq (car children) articles)
10734 (push (gnus-data-number d) articles)))
10735 ;; Do the limiting.
10737 (gnus-summary-limit articles)
10738 (gnus-summary-position-point))))
10740 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10741 "Mark all unread excluded articles as read.
10742 If ALL, mark even excluded ticked and dormants as read."
10744 (let ((articles (gnus-sorted-complement
10746 (mapcar (lambda (h) (mail-header-number h))
10747 gnus-newsgroup-headers)
10749 (sort gnus-newsgroup-limit '<)))
10751 (setq gnus-newsgroup-unreads nil)
10753 (setq gnus-newsgroup-dormant nil
10754 gnus-newsgroup-marked nil
10755 gnus-newsgroup-reads
10757 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10758 gnus-newsgroup-reads))
10759 (while (setq article (pop articles))
10760 (unless (or (memq article gnus-newsgroup-dormant)
10761 (memq article gnus-newsgroup-marked))
10762 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10764 (defun gnus-summary-limit (articles &optional pop)
10766 ;; We pop the previous limit off the stack and use that.
10767 (setq articles (car gnus-newsgroup-limits)
10768 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10769 ;; We use the new limit, so we push the old limit on the stack.
10770 (setq gnus-newsgroup-limits
10771 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10773 (setq gnus-newsgroup-limit articles)
10774 (let ((total (length gnus-newsgroup-data))
10775 (data (gnus-data-find-list (gnus-summary-article-number)))
10777 ;; This will do all the work of generating the new summary buffer
10778 ;; according to the new limit.
10779 (gnus-summary-prepare)
10780 ;; Hide any threads, possibly.
10781 (and gnus-show-threads
10782 gnus-thread-hide-subtree
10783 (gnus-summary-hide-all-threads))
10784 ;; Try to return to the article you were at, or one in the
10787 ;; We try to find some article after the current one.
10789 (and (gnus-summary-goto-subject
10790 (gnus-data-number (car data)) nil t)
10793 (setq data (cdr data))))
10795 ;; If there is no data, that means that we were after the last
10796 ;; article. The same goes when we can't find any articles
10797 ;; after the current one.
10799 (goto-char (point-max))
10800 (gnus-summary-find-prev)))
10801 ;; We return how many articles were removed from the summary
10802 ;; buffer as a result of the new limit.
10803 (- total (length gnus-newsgroup-data))))
10805 (defsubst gnus-invisible-cut-children (threads)
10808 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
10813 (defsubst gnus-cut-thread (thread)
10814 "Go forwards in the thread until we find an article that we want to display."
10815 (when (or (eq gnus-fetch-old-headers 'some)
10816 (eq gnus-build-sparse-threads 'some)
10817 (eq gnus-build-sparse-threads 'more))
10818 ;; Deal with old-fetched headers and sparse threads.
10822 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10823 (memq (mail-header-number (car thread)) gnus-newsgroup-ancient))
10824 (or (<= (length (cdr thread)) 1)
10825 (gnus-invisible-cut-children (cdr thread))))
10826 (setq thread (cadr thread))))
10829 (defun gnus-cut-threads (threads)
10830 "Cut off all uninteresting articles from the beginning of threads."
10831 (when (or (eq gnus-fetch-old-headers 'some)
10832 (eq gnus-build-sparse-threads 'some)
10833 (eq gnus-build-sparse-threads 'more))
10834 (let ((th threads))
10836 (setcar th (gnus-cut-thread (car th)))
10837 (setq th (cdr th)))))
10838 ;; Remove nixed out threads.
10839 (delq nil threads))
10841 (defun gnus-summary-initial-limit (&optional show-if-empty)
10842 "Figure out what the initial limit is supposed to be on group entry.
10843 This entails weeding out unwanted dormants, low-scored articles,
10844 fetch-old-headers verbiage, and so on."
10845 ;; Most groups have nothing to remove.
10846 (if (or gnus-inhibit-limiting
10847 (and (null gnus-newsgroup-dormant)
10848 (not (eq gnus-fetch-old-headers 'some))
10849 (null gnus-summary-expunge-below)
10850 (not (eq gnus-build-sparse-threads 'some))
10851 (not (eq gnus-build-sparse-threads 'more))
10852 (null gnus-thread-expunge-below)
10853 (not gnus-use-nocem)))
10855 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10856 (setq gnus-newsgroup-limit nil)
10859 (unless (car (symbol-value node))
10860 ;; These threads have no parents -- they are roots.
10861 (let ((nodes (cdr (symbol-value node)))
10864 (if (and gnus-thread-expunge-below
10865 (< (gnus-thread-total-score (car nodes))
10866 gnus-thread-expunge-below))
10867 (gnus-expunge-thread (pop nodes))
10868 (setq thread (pop nodes))
10869 (gnus-summary-limit-children thread))))))
10870 gnus-newsgroup-dependencies)
10871 ;; If this limitation resulted in an empty group, we might
10872 ;; pop the previous limit and use it instead.
10873 (when (and (not gnus-newsgroup-limit)
10875 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10876 gnus-newsgroup-limit))
10878 (defun gnus-summary-limit-children (thread)
10879 "Return 1 if this subthread is visible and 0 if it is not."
10880 ;; First we get the number of visible children to this thread. This
10881 ;; is done by recursing down the thread using this function, so this
10882 ;; will really go down to a leaf article first, before slowly
10883 ;; working its way up towards the root.
10887 (apply '+ (mapcar 'gnus-summary-limit-children
10890 (number (mail-header-number (car thread)))
10893 ;; If this article is dormant and has absolutely no visible
10894 ;; children, then this article isn't visible.
10895 (and (memq number gnus-newsgroup-dormant)
10897 ;; If this is "fetch-old-headered" and there is only one
10898 ;; visible child (or less), then we don't want this article.
10899 (and (eq gnus-fetch-old-headers 'some)
10900 (memq number gnus-newsgroup-ancient)
10902 ;; If this is a sparsely inserted article with no children,
10903 ;; we don't want it.
10904 (and (eq gnus-build-sparse-threads 'some)
10905 (memq number gnus-newsgroup-sparse)
10907 ;; If we use expunging, and this article is really
10908 ;; low-scored, then we don't want this article.
10909 (when (and gnus-summary-expunge-below
10911 (or (cdr (assq number gnus-newsgroup-scored))
10912 gnus-summary-default-score))
10913 gnus-summary-expunge-below))
10914 ;; We increase the expunge-tally here, but that has
10915 ;; nothing to do with the limits, really.
10916 (incf gnus-newsgroup-expunged-tally)
10917 ;; We also mark as read here, if that's wanted.
10918 (when (and gnus-summary-mark-below
10919 (< score gnus-summary-mark-below))
10920 (setq gnus-newsgroup-unreads
10921 (delq number gnus-newsgroup-unreads))
10922 (if gnus-newsgroup-auto-expire
10923 (push number gnus-newsgroup-expirable)
10924 (push (cons number gnus-low-score-mark)
10925 gnus-newsgroup-reads)))
10927 (and gnus-use-nocem
10928 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
10929 ;; Nope, invisible article.
10931 ;; Ok, this article is to be visible, so we add it to the limit
10933 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
10936 (defun gnus-expunge-thread (thread)
10937 "Mark all articles in THREAD as read."
10938 (let* ((number (mail-header-number (car thread))))
10939 (incf gnus-newsgroup-expunged-tally)
10940 ;; We also mark as read here, if that's wanted.
10941 (setq gnus-newsgroup-unreads
10942 (delq number gnus-newsgroup-unreads))
10943 (if gnus-newsgroup-auto-expire
10944 (push number gnus-newsgroup-expirable)
10945 (push (cons number gnus-low-score-mark)
10946 gnus-newsgroup-reads)))
10947 ;; Go recursively through all subthreads.
10948 (mapcar 'gnus-expunge-thread (cdr thread)))
10950 ;; Summary article oriented commands
10952 (defun gnus-summary-refer-parent-article (n)
10953 "Refer parent article N times.
10954 The difference between N and the number of articles fetched is returned."
10956 (gnus-set-global-variables)
10960 (let* ((header (gnus-summary-article-header))
10962 ;; If we try to find the parent of the currently
10963 ;; displayed article, then we take a look at the actual
10964 ;; References header, since this is slightly more
10965 ;; reliable than the References field we got from the
10967 (if (and (eq (mail-header-number header)
10968 (cdr gnus-article-current))
10969 (equal gnus-newsgroup-name
10970 (car gnus-article-current)))
10972 (set-buffer gnus-original-article-buffer)
10973 (nnheader-narrow-to-headers)
10975 (message-fetch-field "references")
10977 ;; It's not the current article, so we take a bet on
10978 ;; the value we got from the server.
10979 (mail-header-references header))))
10980 (if (setq ref (or ref (mail-header-references header)))
10981 (or (gnus-summary-refer-article (gnus-parent-id ref))
10982 (gnus-message 1 "Couldn't find parent"))
10983 (gnus-message 1 "No references in article %d"
10984 (gnus-summary-article-number))
10987 (gnus-summary-position-point)
10990 (defun gnus-summary-refer-references ()
10991 "Fetch all articles mentioned in the References header.
10992 Return how many articles were fetched."
10994 (gnus-set-global-variables)
10995 (let ((ref (mail-header-references (gnus-summary-article-header)))
10996 (current (gnus-summary-article-number))
10998 ;; For each Message-ID in the References header...
10999 (while (string-match "<[^>]*>" ref)
11001 ;; ... fetch that article.
11002 (gnus-summary-refer-article
11003 (prog1 (match-string 0 ref)
11004 (setq ref (substring ref (match-end 0))))))
11005 (gnus-summary-goto-subject current)
11006 (gnus-summary-position-point)
11009 (defun gnus-summary-refer-article (message-id)
11010 "Fetch an article specified by MESSAGE-ID."
11011 (interactive "sMessage-ID: ")
11012 (when (and (stringp message-id)
11013 (not (zerop (length message-id))))
11014 ;; Construct the correct Message-ID if necessary.
11015 ;; Suggested by tale@pawl.rpi.edu.
11016 (unless (string-match "^<" message-id)
11017 (setq message-id (concat "<" message-id)))
11018 (unless (string-match ">$" message-id)
11019 (setq message-id (concat message-id ">")))
11020 (let ((header (gnus-id-to-header message-id)))
11022 ;; The article is present in the buffer, to we just go to it.
11023 (gnus-summary-goto-article (mail-header-number header) nil header)
11024 ;; We fetch the article
11025 (let ((gnus-override-method
11026 (and (gnus-news-group-p gnus-newsgroup-name)
11027 gnus-refer-article-method))
11029 ;; Start the special refer-article method, if necessary.
11030 (when (and gnus-refer-article-method
11031 (gnus-news-group-p gnus-newsgroup-name))
11032 (gnus-check-server gnus-refer-article-method))
11033 ;; Fetch the header, and display the article.
11034 (if (setq number (gnus-summary-insert-subject message-id))
11035 (gnus-summary-select-article nil nil nil number)
11036 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
11038 (defun gnus-summary-enter-digest-group (&optional force)
11039 "Enter a digest group based on the current article."
11041 (gnus-set-global-variables)
11042 (gnus-summary-select-article)
11043 (let ((name (format "%s-%d"
11044 (gnus-group-prefixed-name
11045 gnus-newsgroup-name (list 'nndoc ""))
11046 gnus-current-article))
11047 (ogroup gnus-newsgroup-name)
11048 (case-fold-search t)
11049 (buf (current-buffer))
11052 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
11053 (insert-buffer-substring gnus-original-article-buffer)
11055 (goto-char (point-min))
11056 (or (search-forward "\n\n" nil t) (point)))
11057 (goto-char (point-min))
11058 (delete-matching-lines "^\\(Path\\):\\|^From ")
11061 (if (gnus-group-read-ephemeral-group
11062 name `(nndoc ,name (nndoc-address
11064 (nndoc-article-type ,(if force 'digest 'guess))) t)
11065 ;; Make all postings to this group go to the parent group.
11066 (nconc (gnus-info-params (gnus-get-info name))
11067 (list (cons 'to-group ogroup)))
11068 ;; Couldn't select this doc group.
11069 (switch-to-buffer buf)
11070 (gnus-set-global-variables)
11071 (gnus-configure-windows 'summary)
11072 (gnus-message 3 "Article couldn't be entered?"))
11073 (kill-buffer dig))))
11075 (defun gnus-summary-isearch-article (&optional regexp-p)
11076 "Do incremental search forward on the current article.
11077 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
11079 (gnus-set-global-variables)
11080 (gnus-summary-select-article)
11081 (gnus-configure-windows 'article)
11082 (gnus-eval-in-buffer-window
11083 gnus-article-buffer
11084 (goto-char (point-min))
11085 (isearch-forward regexp-p)))
11087 (defun gnus-summary-search-article-forward (regexp &optional backward)
11088 "Search for an article containing REGEXP forward.
11089 If BACKWARD, search backward instead."
11092 (format "Search article %s (regexp%s): "
11093 (if current-prefix-arg "backward" "forward")
11094 (if gnus-last-search-regexp
11095 (concat ", default " gnus-last-search-regexp)
11097 current-prefix-arg))
11098 (gnus-set-global-variables)
11099 (if (string-equal regexp "")
11100 (setq regexp (or gnus-last-search-regexp ""))
11101 (setq gnus-last-search-regexp regexp))
11102 (unless (gnus-summary-search-article regexp backward)
11103 (error "Search failed: \"%s\"" regexp)))
11105 (defun gnus-summary-search-article-backward (regexp)
11106 "Search for an article containing REGEXP backward."
11109 (format "Search article backward (regexp%s): "
11110 (if gnus-last-search-regexp
11111 (concat ", default " gnus-last-search-regexp)
11113 (gnus-summary-search-article-forward regexp 'backward))
11115 (defun gnus-summary-search-article (regexp &optional backward)
11116 "Search for an article containing REGEXP.
11117 Optional argument BACKWARD means do search for backward.
11118 `gnus-select-article-hook' is not called during the search."
11119 (let ((gnus-select-article-hook nil) ;Disable hook.
11120 (gnus-article-display-hook nil)
11121 (gnus-mark-article-hook nil) ;Inhibit marking as read.
11124 're-search-backward 're-search-forward))
11125 (sum (current-buffer))
11127 (gnus-save-hidden-threads
11128 (gnus-summary-select-article)
11129 (set-buffer gnus-article-buffer)
11131 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
11133 (re-search-backward regexp nil t)
11134 (re-search-forward regexp nil t))
11135 ;; We found the regexp.
11137 (setq found 'found)
11138 (beginning-of-line)
11140 (get-buffer-window (current-buffer))
11144 ;; We didn't find it, so we go to the next article.
11146 (if (not (if backward (gnus-summary-find-prev)
11147 (gnus-summary-find-next)))
11148 ;; No more articles.
11150 ;; Select the next article and adjust point.
11151 (gnus-summary-select-article)
11152 (set-buffer gnus-article-buffer)
11154 (goto-char (if backward (point-max) (point-min))))))
11155 (gnus-message 7 ""))
11156 ;; Return whether we found the regexp.
11157 (when (eq found 'found)
11158 (gnus-summary-show-thread)
11159 (gnus-summary-goto-subject gnus-current-article)
11160 (gnus-summary-position-point)
11163 (defun gnus-summary-find-matching (header regexp &optional backward unread
11165 "Return a list of all articles that match REGEXP on HEADER.
11166 The search stars on the current article and goes forwards unless
11167 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
11168 If UNREAD is non-nil, only unread articles will
11169 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
11170 in the comparisons."
11171 (let ((data (if (eq backward 'all) gnus-newsgroup-data
11172 (gnus-data-find-list
11173 (gnus-summary-article-number) (gnus-data-list backward))))
11174 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
11175 (case-fold-search (not not-case-fold))
11177 (or (fboundp (intern (concat "mail-header-" header)))
11178 (error "%s is not a valid header" header))
11180 (setq d (car data))
11181 (and (or (not unread) ; We want all articles...
11182 (gnus-data-unread-p d)) ; Or just unreads.
11183 (vectorp (gnus-data-header d)) ; It's not a pseudo.
11184 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
11185 (setq articles (cons (gnus-data-number d) articles))) ; Success!
11186 (setq data (cdr data)))
11187 (nreverse articles)))
11189 (defun gnus-summary-execute-command (header regexp command &optional backward)
11190 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
11191 If HEADER is an empty string (or nil), the match is done on the entire
11192 article. If BACKWARD (the prefix) is non-nil, search backward instead."
11194 (list (let ((completion-ignore-case t))
11197 (mapcar (lambda (string) (list string))
11198 '("Number" "Subject" "From" "Lines" "Date"
11199 "Message-ID" "Xref" "References" "Body"))
11200 nil 'require-match))
11201 (read-string "Regexp: ")
11202 (read-key-sequence "Command: ")
11203 current-prefix-arg))
11204 (when (equal header "Body")
11206 (gnus-set-global-variables)
11207 ;; Hidden thread subtrees must be searched as well.
11208 (gnus-summary-show-all-threads)
11209 ;; We don't want to change current point nor window configuration.
11211 (save-window-excursion
11212 (gnus-message 6 "Executing %s..." (key-description command))
11213 ;; We'd like to execute COMMAND interactively so as to give arguments.
11214 (gnus-execute header regexp
11215 `(lambda () (call-interactively ',(key-binding command)))
11217 (gnus-message 6 "Executing %s...done" (key-description command)))))
11219 (defun gnus-summary-beginning-of-article ()
11220 "Scroll the article back to the beginning."
11222 (gnus-set-global-variables)
11223 (gnus-summary-select-article)
11224 (gnus-configure-windows 'article)
11225 (gnus-eval-in-buffer-window
11226 gnus-article-buffer
11228 (goto-char (point-min))
11229 (and gnus-break-pages (gnus-narrow-to-page))))
11231 (defun gnus-summary-end-of-article ()
11232 "Scroll to the end of the article."
11234 (gnus-set-global-variables)
11235 (gnus-summary-select-article)
11236 (gnus-configure-windows 'article)
11237 (gnus-eval-in-buffer-window
11238 gnus-article-buffer
11240 (goto-char (point-max))
11242 (and gnus-break-pages (gnus-narrow-to-page))))
11244 (defun gnus-summary-show-article (&optional arg)
11245 "Force re-fetching of the current article.
11246 If ARG (the prefix) is non-nil, show the raw article without any
11247 article massaging functions being run."
11249 (gnus-set-global-variables)
11251 ;; Select the article the normal way.
11252 (gnus-summary-select-article nil 'force)
11253 ;; Bind the article treatment functions to nil.
11254 (let ((gnus-have-all-headers t)
11255 gnus-article-display-hook
11256 gnus-article-prepare-hook
11259 (gnus-summary-select-article nil 'force)))
11260 (gnus-summary-goto-subject gnus-current-article)
11261 ; (gnus-configure-windows 'article)
11262 (gnus-summary-position-point))
11264 (defun gnus-summary-verbose-headers (&optional arg)
11265 "Toggle permanent full header display.
11266 If ARG is a positive number, turn header display on.
11267 If ARG is a negative number, turn header display off."
11269 (gnus-set-global-variables)
11270 (gnus-summary-toggle-header arg)
11271 (setq gnus-show-all-headers
11272 (cond ((or (not (numberp arg))
11274 (not gnus-show-all-headers))
11278 (defun gnus-summary-toggle-header (&optional arg)
11279 "Show the headers if they are hidden, or hide them if they are shown.
11280 If ARG is a positive number, show the entire header.
11281 If ARG is a negative number, hide the unwanted header lines."
11283 (gnus-set-global-variables)
11285 (set-buffer gnus-article-buffer)
11286 (let* ((buffer-read-only nil)
11287 (inhibit-point-motion-hooks t)
11288 (hidden (text-property-any
11289 (goto-char (point-min)) (search-forward "\n\n")
11292 (goto-char (point-min))
11293 (when (search-forward "\n\n" nil t)
11294 (delete-region (point-min) (1- (point))))
11295 (goto-char (point-min))
11297 (set-buffer gnus-original-article-buffer)
11298 (goto-char (point-min))
11299 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11300 (insert-buffer-substring gnus-original-article-buffer 1 e)
11301 (let ((gnus-inhibit-hiding t))
11302 (run-hooks 'gnus-article-display-hook))
11303 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11304 (gnus-article-hide-headers)))))
11306 (defun gnus-summary-show-all-headers ()
11307 "Make all header lines visible."
11309 (gnus-set-global-variables)
11310 (gnus-article-show-all-headers))
11312 (defun gnus-summary-toggle-mime (&optional arg)
11313 "Toggle MIME processing.
11314 If ARG is a positive number, turn MIME processing on."
11316 (gnus-set-global-variables)
11317 (setq gnus-show-mime
11318 (if (null arg) (not gnus-show-mime)
11319 (> (prefix-numeric-value arg) 0)))
11320 (gnus-summary-select-article t 'force))
11322 (defun gnus-summary-caesar-message (&optional arg)
11323 "Caesar rotate the current article by 13.
11324 The numerical prefix specifies how manu places to rotate each letter
11327 (gnus-set-global-variables)
11328 (gnus-summary-select-article)
11329 (let ((mail-header-separator ""))
11330 (gnus-eval-in-buffer-window
11331 gnus-article-buffer
11334 (let ((start (window-start)))
11335 (news-caesar-buffer-body arg)
11336 (set-window-start (get-buffer-window (current-buffer)) start))))))
11338 (defun gnus-summary-stop-page-breaking ()
11339 "Stop page breaking in the current article."
11341 (gnus-set-global-variables)
11342 (gnus-summary-select-article)
11343 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
11345 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11346 "Move the current article to a different newsgroup.
11347 If N is a positive number, move the N next articles.
11348 If N is a negative number, move the N previous articles.
11349 If N is nil and any articles have been marked with the process mark,
11350 move those articles instead.
11351 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11352 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11353 re-spool using this method.
11355 For this function to work, both the current newsgroup and the
11356 newsgroup that you want to move to have to support the `request-move'
11357 and `request-accept' functions."
11359 (unless action (setq action 'move))
11360 (gnus-set-global-variables)
11361 ;; Check whether the source group supports the required functions.
11362 (cond ((and (eq action 'move)
11363 (not (gnus-check-backend-function
11364 'request-move-article gnus-newsgroup-name)))
11365 (error "The current group does not support article moving"))
11366 ((and (eq action 'crosspost)
11367 (not (gnus-check-backend-function
11368 'request-replace-article gnus-newsgroup-name)))
11369 (error "The current group does not support article editing")))
11370 (let ((articles (gnus-summary-work-articles n))
11371 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11372 (names '((move "Move" "Moving")
11373 (copy "Copy" "Copying")
11374 (crosspost "Crosspost" "Crossposting")))
11375 (copy-buf (save-excursion
11376 (nnheader-set-temp-buffer " *copy article*")))
11377 art-group to-method new-xref article to-groups)
11378 (unless (assq action names)
11379 (error "Unknown action %s" action))
11380 ;; Read the newsgroup name.
11381 (when (and (not to-newsgroup)
11382 (not select-method))
11384 (gnus-read-move-group-name
11385 (cadr (assq action names))
11386 (symbol-value (intern (format "gnus-current-%s-group" action)))
11388 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11389 (setq to-method (or select-method
11390 (gnus-find-method-for-group to-newsgroup)))
11391 ;; Check the method we are to move this article to...
11392 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11393 (error "%s does not support article copying" (car to-method)))
11394 (or (gnus-check-server to-method)
11395 (error "Can't open server %s" (car to-method)))
11396 (gnus-message 6 "%s to %s: %s..."
11397 (caddr (assq action names))
11398 (or (car select-method) to-newsgroup) articles)
11400 (setq article (pop articles))
11404 ;; Move the article.
11406 (gnus-request-move-article
11407 article ; Article to move
11408 gnus-newsgroup-name ; From newsgrouo
11409 (nth 1 (gnus-find-method-for-group
11410 gnus-newsgroup-name)) ; Server
11411 (list 'gnus-request-accept-article
11412 to-newsgroup (list 'quote select-method)
11413 (not articles)) ; Accept form
11414 (not articles))) ; Only save nov last time
11415 ;; Copy the article.
11418 (set-buffer copy-buf)
11419 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11420 (gnus-request-accept-article
11421 to-newsgroup select-method (not articles))))
11422 ;; Crosspost the article.
11423 ((eq action 'crosspost)
11424 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11425 (setq new-xref (concat gnus-newsgroup-name ":" article))
11426 (if (and xref (not (string= xref "")))
11428 (when (string-match "^Xref: " xref)
11429 (setq xref (substring xref (match-end 0))))
11430 (setq new-xref (concat xref " " new-xref)))
11431 (setq new-xref (concat (system-name) " " new-xref)))
11433 (set-buffer copy-buf)
11434 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11435 (nnheader-replace-header "xref" new-xref)
11436 (gnus-request-accept-article
11437 to-newsgroup select-method (not articles)))))))
11438 (if (not art-group)
11439 (gnus-message 1 "Couldn't %s article %s"
11440 (cadr (assq action names)) article)
11443 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11445 (gnus-group-prefixed-name
11448 (gnus-find-method-for-group to-newsgroup)))
11449 gnus-newsrc-hashtb)))
11450 (info (nth 2 entry))
11451 (to-group (gnus-info-group info)))
11452 ;; Update the group that has been moved to.
11454 (memq action '(move copy)))
11455 (unless (member to-group to-groups)
11456 (push to-group to-groups))
11458 (unless (memq article gnus-newsgroup-unreads)
11459 (gnus-info-set-read
11460 info (gnus-add-to-range (gnus-info-read info)
11461 (list (cdr art-group)))))
11463 ;; Copy any marks over to the new group.
11464 (let ((marks gnus-article-mark-lists)
11465 (to-article (cdr art-group)))
11467 ;; See whether the article is to be put in the cache.
11468 (when gnus-use-cache
11469 (gnus-cache-possibly-enter-article
11470 to-group to-article
11471 (let ((header (copy-sequence
11472 (gnus-summary-article-header article))))
11473 (mail-header-set-number header to-article)
11475 (memq article gnus-newsgroup-marked)
11476 (memq article gnus-newsgroup-dormant)
11477 (memq article gnus-newsgroup-unreads)))
11480 (when (memq article (symbol-value
11481 (intern (format "gnus-newsgroup-%s"
11483 ;; If the other group is the same as this group,
11484 ;; then we have to add the mark to the list.
11485 (when (equal to-group gnus-newsgroup-name)
11486 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
11489 (intern (format "gnus-newsgroup-%s"
11491 ;; Copy mark to other group.
11492 (gnus-add-marked-articles
11493 to-group (cdar marks) (list to-article) info))
11494 (setq marks (cdr marks)))))
11496 ;; Update the Xref header in this article to point to
11497 ;; the new crossposted article we have just created.
11498 (when (eq action 'crosspost)
11500 (set-buffer copy-buf)
11501 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11502 (nnheader-replace-header
11503 "xref" (concat new-xref " " (gnus-group-prefixed-name
11504 (car art-group) to-method)
11505 ":" (cdr art-group)))
11506 (gnus-request-replace-article
11507 article gnus-newsgroup-name (current-buffer)))))
11509 (gnus-summary-goto-subject article)
11510 (when (eq action 'move)
11511 (gnus-summary-mark-article article gnus-canceled-mark)))
11512 (gnus-summary-remove-process-mark article))
11513 ;; Re-activate all groups that have been moved to.
11515 (gnus-activate-group (pop to-groups)))
11517 (gnus-kill-buffer copy-buf)
11518 (gnus-summary-position-point)
11519 (gnus-set-mode-line 'summary)))
11521 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11522 "Move the current article to a different newsgroup.
11523 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11524 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
11525 re-spool using this method."
11527 (gnus-summary-move-article n nil select-method 'copy))
11529 (defun gnus-summary-crosspost-article (&optional n)
11530 "Crosspost the current article to some other group."
11532 (gnus-summary-move-article n nil nil 'crosspost))
11534 (defvar gnus-summary-respool-default-method nil
11535 "Default method for respooling an article.
11536 If nil, use to the current newsgroup method.")
11538 (defun gnus-summary-respool-article (&optional n method)
11539 "Respool the current article.
11540 The article will be squeezed through the mail spooling process again,
11541 which means that it will be put in some mail newsgroup or other
11542 depending on `nnmail-split-methods'.
11543 If N is a positive number, respool the N next articles.
11544 If N is a negative number, respool the N previous articles.
11545 If N is nil and any articles have been marked with the process mark,
11546 respool those articles instead.
11548 Respooling can be done both from mail groups and \"real\" newsgroups.
11549 In the former case, the articles in question will be moved from the
11550 current group into whatever groups they are destined to. In the
11551 latter case, they will be copied into the relevant groups."
11553 (list current-prefix-arg
11554 (let* ((methods (gnus-methods-using 'respool))
11556 (symbol-name (or gnus-summary-respool-default-method
11557 (car (gnus-find-method-for-group
11558 gnus-newsgroup-name)))))
11560 (gnus-completing-read
11561 methname "What backend do you want to use when? "
11562 methods nil t nil 'gnus-method-history))
11565 ((zerop (length (setq ms (gnus-servers-using-backend method))))
11566 (list (intern method) ""))
11570 (cdr (completing-read
11572 (mapcar (lambda (m) (cons (cadr m) m)) ms) nil t)))))))
11573 (gnus-set-global-variables)
11575 (error "No method given for respooling"))
11576 (if (assoc (symbol-name
11577 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11578 (gnus-methods-using 'respool))
11579 (gnus-summary-move-article n nil method)
11580 (gnus-summary-copy-article n nil method)))
11582 (defun gnus-summary-import-article (file)
11583 "Import a random file into a mail newsgroup."
11584 (interactive "fImport file: ")
11585 (gnus-set-global-variables)
11586 (let ((group gnus-newsgroup-name)
11587 (now (current-time))
11589 (or (gnus-check-backend-function 'request-accept-article group)
11590 (error "%s does not support article importing" group))
11591 (or (file-readable-p file)
11592 (not (file-regular-p file))
11593 (error "Can't read %s" file))
11595 (set-buffer (get-buffer-create " *import file*"))
11596 (buffer-disable-undo (current-buffer))
11598 (insert-file-contents file)
11599 (goto-char (point-min))
11600 (unless (nnheader-article-p)
11601 ;; This doesn't look like an article, so we fudge some headers.
11602 (setq atts (file-attributes file)
11603 lines (count-lines (point-min) (point-max)))
11604 (insert "From: " (read-string "From: ") "\n"
11605 "Subject: " (read-string "Subject: ") "\n"
11606 "Date: " (timezone-make-date-arpa-standard
11607 (current-time-string (nth 5 atts))
11608 (current-time-zone now)
11609 (current-time-zone now)) "\n"
11610 "Message-ID: " (gnus-inews-message-id) "\n"
11611 "Lines: " (int-to-string lines) "\n"
11612 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11613 (gnus-request-accept-article group nil t)
11614 (kill-buffer (current-buffer)))))
11616 (defun gnus-summary-expire-articles (&optional now)
11617 "Expire all articles that are marked as expirable in the current group."
11619 (gnus-set-global-variables)
11620 (when (gnus-check-backend-function
11621 'request-expire-articles gnus-newsgroup-name)
11622 ;; This backend supports expiry.
11623 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11624 (expirable (if total
11625 (gnus-list-of-read-articles gnus-newsgroup-name)
11626 (setq gnus-newsgroup-expirable
11627 (sort gnus-newsgroup-expirable '<))))
11628 (expiry-wait (if now 'immediate
11629 (gnus-group-get-parameter
11630 gnus-newsgroup-name 'expiry-wait)))
11633 ;; There are expirable articles in this group, so we run them
11634 ;; through the expiry process.
11635 (gnus-message 6 "Expiring articles...")
11636 ;; The list of articles that weren't expired is returned.
11638 (let ((nnmail-expiry-wait-function nil)
11639 (nnmail-expiry-wait expiry-wait))
11640 (setq es (gnus-request-expire-articles
11641 expirable gnus-newsgroup-name)))
11642 (setq es (gnus-request-expire-articles
11643 expirable gnus-newsgroup-name)))
11644 (or total (setq gnus-newsgroup-expirable es))
11645 ;; We go through the old list of expirable, and mark all
11646 ;; really expired articles as nonexistent.
11647 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11648 (let ((gnus-use-cache nil))
11650 (unless (memq (car expirable) es)
11651 (when (gnus-data-find (car expirable))
11652 (gnus-summary-mark-article
11653 (car expirable) gnus-canceled-mark)))
11654 (setq expirable (cdr expirable)))))
11655 (gnus-message 6 "Expiring articles...done")))))
11657 (defun gnus-summary-expire-articles-now ()
11658 "Expunge all expirable articles in the current group.
11659 This means that *all* articles that are marked as expirable will be
11660 deleted forever, right now."
11662 (gnus-set-global-variables)
11663 (or gnus-expert-user
11665 "Are you really, really, really sure you want to delete all these messages? ")
11667 (gnus-summary-expire-articles t))
11669 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11670 (defun gnus-summary-delete-article (&optional n)
11671 "Delete the N next (mail) articles.
11672 This command actually deletes articles. This is not a marking
11673 command. The article will disappear forever from your life, never to
11675 If N is negative, delete backwards.
11676 If N is nil and articles have been marked with the process mark,
11677 delete these instead."
11679 (gnus-set-global-variables)
11680 (or (gnus-check-backend-function 'request-expire-articles
11681 gnus-newsgroup-name)
11682 (error "The current newsgroup does not support article deletion."))
11683 ;; Compute the list of articles to delete.
11684 (let ((articles (gnus-summary-work-articles n))
11686 (if (and gnus-novice-user
11687 (not (gnus-y-or-n-p
11688 (format "Do you really want to delete %s forever? "
11689 (if (> (length articles) 1)
11690 (format "these %s articles" (length articles))
11691 "this article")))))
11693 ;; Delete the articles.
11694 (setq not-deleted (gnus-request-expire-articles
11695 articles gnus-newsgroup-name 'force))
11697 (gnus-summary-remove-process-mark (car articles))
11698 ;; The backend might not have been able to delete the article
11700 (or (memq (car articles) not-deleted)
11701 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11702 (setq articles (cdr articles))))
11703 (gnus-summary-position-point)
11704 (gnus-set-mode-line 'summary)
11707 (defun gnus-summary-edit-article (&optional force)
11708 "Enter into a buffer and edit the current article.
11709 This will have permanent effect only in mail groups.
11710 If FORCE is non-nil, allow editing of articles even in read-only
11714 (set-buffer gnus-summary-buffer)
11715 (gnus-set-global-variables)
11716 (when (and (not force)
11717 (gnus-group-read-only-p))
11718 (error "The current newsgroup does not support article editing."))
11719 (gnus-summary-select-article t nil t)
11720 (gnus-configure-windows 'article)
11721 (select-window (get-buffer-window gnus-article-buffer))
11722 (gnus-message 6 "C-c C-c to end edits")
11723 (setq buffer-read-only nil)
11725 (use-local-map (copy-keymap (current-local-map)))
11726 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11727 (buffer-enable-undo)
11729 (goto-char (point-min))
11730 (search-forward "\n\n" nil t)))
11732 (defun gnus-summary-edit-article-done ()
11733 "Make edits to the current article permanent."
11735 (if (gnus-group-read-only-p)
11737 (gnus-summary-edit-article-postpone)
11739 1 "The current newsgroup does not support article editing."))
11740 (let ((buf (format "%s" (buffer-string))))
11743 (if (not (gnus-request-replace-article
11744 (cdr gnus-article-current) (car gnus-article-current)
11746 (error "Couldn't replace article.")
11747 (gnus-article-mode)
11748 (use-local-map gnus-article-mode-map)
11749 (setq buffer-read-only t)
11750 (buffer-disable-undo (current-buffer))
11751 (gnus-configure-windows 'summary)
11752 (gnus-summary-update-article (cdr gnus-article-current))
11753 (when gnus-use-cache
11754 (gnus-cache-update-article
11755 (cdr gnus-article-current) (car gnus-article-current)))
11756 (when gnus-keep-backlog
11757 (gnus-backlog-remove-article
11758 (car gnus-article-current) (cdr gnus-article-current))))
11760 (when (get-buffer gnus-original-article-buffer)
11761 (set-buffer gnus-original-article-buffer)
11762 (setq gnus-original-article nil)))
11763 (setq gnus-article-current nil
11764 gnus-current-article nil)
11765 (run-hooks 'gnus-article-display-hook)
11766 (and (gnus-visual-p 'summary-highlight 'highlight)
11767 (run-hooks 'gnus-visual-mark-article-hook)))))
11769 (defun gnus-summary-edit-article-postpone ()
11770 "Postpone changes to the current article."
11772 (gnus-article-mode)
11773 (use-local-map gnus-article-mode-map)
11774 (setq buffer-read-only t)
11775 (buffer-disable-undo (current-buffer))
11776 (gnus-configure-windows 'summary)
11777 (and (gnus-visual-p 'summary-highlight 'highlight)
11778 (run-hooks 'gnus-visual-mark-article-hook)))
11780 (defun gnus-summary-respool-query ()
11781 "Query where the respool algorithm would put this article."
11783 (gnus-set-global-variables)
11784 (gnus-summary-select-article)
11786 (set-buffer gnus-article-buffer)
11788 (goto-char (point-min))
11789 (search-forward "\n\n")
11790 (narrow-to-region (point-min) (point))
11791 (pp-eval-expression
11792 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11794 ;; Summary marking commands.
11796 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11797 "Mark articles which has the same subject as read, and then select the next.
11798 If UNMARK is positive, remove any kind of mark.
11799 If UNMARK is negative, tick articles."
11801 (gnus-set-global-variables)
11803 (setq unmark (prefix-numeric-value unmark)))
11805 (gnus-summary-mark-same-subject
11806 (gnus-summary-article-subject) unmark)))
11807 ;; Select next unread article. If auto-select-same mode, should
11808 ;; select the first unread article.
11809 (gnus-summary-next-article t (and gnus-auto-select-same
11810 (gnus-summary-article-subject)))
11811 (gnus-message 7 "%d article%s marked as %s"
11812 count (if (= count 1) " is" "s are")
11813 (if unmark "unread" "read"))))
11815 (defun gnus-summary-kill-same-subject (&optional unmark)
11816 "Mark articles which has the same subject as read.
11817 If UNMARK is positive, remove any kind of mark.
11818 If UNMARK is negative, tick articles."
11820 (gnus-set-global-variables)
11822 (setq unmark (prefix-numeric-value unmark)))
11824 (gnus-summary-mark-same-subject
11825 (gnus-summary-article-subject) unmark)))
11826 ;; If marked as read, go to next unread subject.
11828 ;; Go to next unread subject.
11829 (gnus-summary-next-subject 1 t))
11830 (gnus-message 7 "%d articles are marked as %s"
11831 count (if unmark "unread" "read"))))
11833 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11834 "Mark articles with same SUBJECT as read, and return marked number.
11835 If optional argument UNMARK is positive, remove any kinds of marks.
11836 If optional argument UNMARK is negative, mark articles as unread instead."
11840 ((null unmark) ; Mark as read.
11843 (gnus-summary-mark-article-as-read gnus-killed-mark)
11844 (gnus-summary-show-thread) t)
11845 (gnus-summary-find-subject subject))
11846 (setq count (1+ count))))
11847 ((> unmark 0) ; Tick.
11850 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11851 (gnus-summary-show-thread) t)
11852 (gnus-summary-find-subject subject))
11853 (setq count (1+ count))))
11854 (t ; Mark as unread.
11857 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11858 (gnus-summary-show-thread) t)
11859 (gnus-summary-find-subject subject))
11860 (setq count (1+ count)))))
11861 (gnus-set-mode-line 'summary)
11862 ;; Return the number of marked articles.
11865 (defun gnus-summary-mark-as-processable (n &optional unmark)
11866 "Set the process mark on the next N articles.
11867 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11868 the process mark instead. The difference between N and the actual
11869 number of articles marked is returned."
11871 (gnus-set-global-variables)
11872 (let ((backward (< n 0))
11877 (gnus-summary-remove-process-mark
11878 (gnus-summary-article-number))
11879 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11880 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11882 (if (/= 0 n) (gnus-message 7 "No more articles"))
11883 (gnus-summary-recenter)
11884 (gnus-summary-position-point)
11887 (defun gnus-summary-unmark-as-processable (n)
11888 "Remove the process mark from the next N articles.
11889 If N is negative, mark backward instead. The difference between N and
11890 the actual number of articles marked is returned."
11892 (gnus-set-global-variables)
11893 (gnus-summary-mark-as-processable n t))
11895 (defun gnus-summary-unmark-all-processable ()
11896 "Remove the process mark from all articles."
11898 (gnus-set-global-variables)
11900 (while gnus-newsgroup-processable
11901 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11902 (gnus-summary-position-point))
11904 (defun gnus-summary-mark-as-expirable (n)
11905 "Mark N articles forward as expirable.
11906 If N is negative, mark backward instead. The difference between N and
11907 the actual number of articles marked is returned."
11909 (gnus-set-global-variables)
11910 (gnus-summary-mark-forward n gnus-expirable-mark))
11912 (defun gnus-summary-mark-article-as-replied (article)
11913 "Mark ARTICLE replied and update the summary line."
11914 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11915 (let ((buffer-read-only nil))
11916 (when (gnus-summary-goto-subject article)
11917 (gnus-summary-update-secondary-mark article))))
11919 (defun gnus-summary-set-bookmark (article)
11920 "Set a bookmark in current article."
11921 (interactive (list (gnus-summary-article-number)))
11922 (gnus-set-global-variables)
11923 (if (or (not (get-buffer gnus-article-buffer))
11924 (not gnus-current-article)
11925 (not gnus-article-current)
11926 (not (equal gnus-newsgroup-name (car gnus-article-current))))
11927 (error "No current article selected"))
11928 ;; Remove old bookmark, if one exists.
11929 (let ((old (assq article gnus-newsgroup-bookmarks)))
11930 (if old (setq gnus-newsgroup-bookmarks
11931 (delq old gnus-newsgroup-bookmarks))))
11932 ;; Set the new bookmark, which is on the form
11933 ;; (article-number . line-number-in-body).
11934 (setq gnus-newsgroup-bookmarks
11938 (set-buffer gnus-article-buffer)
11942 (goto-char (point-min))
11943 (search-forward "\n\n" nil t)
11946 gnus-newsgroup-bookmarks))
11947 (gnus-message 6 "A bookmark has been added to the current article."))
11949 (defun gnus-summary-remove-bookmark (article)
11950 "Remove the bookmark from the current article."
11951 (interactive (list (gnus-summary-article-number)))
11952 (gnus-set-global-variables)
11953 ;; Remove old bookmark, if one exists.
11954 (let ((old (assq article gnus-newsgroup-bookmarks)))
11957 (setq gnus-newsgroup-bookmarks
11958 (delq old gnus-newsgroup-bookmarks))
11959 (gnus-message 6 "Removed bookmark."))
11960 (gnus-message 6 "No bookmark in current article."))))
11962 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11963 (defun gnus-summary-mark-as-dormant (n)
11964 "Mark N articles forward as dormant.
11965 If N is negative, mark backward instead. The difference between N and
11966 the actual number of articles marked is returned."
11968 (gnus-set-global-variables)
11969 (gnus-summary-mark-forward n gnus-dormant-mark))
11971 (defun gnus-summary-set-process-mark (article)
11972 "Set the process mark on ARTICLE and update the summary line."
11973 (setq gnus-newsgroup-processable
11975 (delq article gnus-newsgroup-processable)))
11976 (when (gnus-summary-goto-subject article)
11977 (gnus-summary-show-thread)
11978 (gnus-summary-update-secondary-mark article)))
11980 (defun gnus-summary-remove-process-mark (article)
11981 "Remove the process mark from ARTICLE and update the summary line."
11982 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
11983 (when (gnus-summary-goto-subject article)
11984 (gnus-summary-show-thread)
11985 (gnus-summary-update-secondary-mark article)))
11987 (defun gnus-summary-set-saved-mark (article)
11988 "Set the process mark on ARTICLE and update the summary line."
11989 (push article gnus-newsgroup-saved)
11990 (when (gnus-summary-goto-subject article)
11991 (gnus-summary-update-secondary-mark article)))
11993 (defun gnus-summary-mark-forward (n &optional mark no-expire)
11994 "Mark N articles as read forwards.
11995 If N is negative, mark backwards instead.
11996 Mark with MARK. If MARK is ? , ?! or ??, articles will be
11998 The difference between N and the actual number of articles marked is
12001 (gnus-set-global-variables)
12002 (let ((backward (< n 0))
12003 (gnus-summary-goto-unread
12004 (and gnus-summary-goto-unread
12005 (not (eq gnus-summary-goto-unread 'never))
12006 (not (memq mark (list gnus-unread-mark
12007 gnus-ticked-mark gnus-dormant-mark)))))
12009 (mark (or mark gnus-del-mark)))
12010 (while (and (> n 0)
12011 (gnus-summary-mark-article nil mark no-expire)
12012 (zerop (gnus-summary-next-subject
12014 (and gnus-summary-goto-unread
12015 (not (eq gnus-summary-goto-unread 'never)))
12018 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12019 (gnus-summary-recenter)
12020 (gnus-summary-position-point)
12021 (gnus-set-mode-line 'summary)
12024 (defun gnus-summary-mark-article-as-read (mark)
12025 "Mark the current article quickly as read with MARK."
12026 (let ((article (gnus-summary-article-number)))
12027 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12028 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12029 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12030 (setq gnus-newsgroup-reads
12031 (cons (cons article mark) gnus-newsgroup-reads))
12032 ;; Possibly remove from cache, if that is used.
12033 (and gnus-use-cache (gnus-cache-enter-remove-article article))
12034 ;; Allow the backend to change the mark.
12035 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
12036 ;; Check for auto-expiry.
12037 (when (and gnus-newsgroup-auto-expire
12038 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12039 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12040 (= mark gnus-ancient-mark)
12041 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
12042 (setq mark gnus-expirable-mark)
12043 (push article gnus-newsgroup-expirable))
12044 ;; Set the mark in the buffer.
12045 (gnus-summary-update-mark mark 'unread)
12048 (defun gnus-summary-mark-article-as-unread (mark)
12049 "Mark the current article quickly as unread with MARK."
12050 (let ((article (gnus-summary-article-number)))
12051 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12052 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12053 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12054 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
12055 (cond ((= mark gnus-ticked-mark)
12056 (push article gnus-newsgroup-marked))
12057 ((= mark gnus-dormant-mark)
12058 (push article gnus-newsgroup-dormant))
12060 (push article gnus-newsgroup-unreads)))
12061 (setq gnus-newsgroup-reads
12062 (delq (assq article gnus-newsgroup-reads)
12063 gnus-newsgroup-reads))
12065 ;; See whether the article is to be put in the cache.
12066 (and gnus-use-cache
12067 (vectorp (gnus-summary-article-header article))
12069 (gnus-cache-possibly-enter-article
12070 gnus-newsgroup-name article
12071 (gnus-summary-article-header article)
12072 (= mark gnus-ticked-mark)
12073 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12076 (gnus-summary-update-mark mark 'unread)
12079 (defun gnus-summary-mark-article (&optional article mark no-expire)
12080 "Mark ARTICLE with MARK. MARK can be any character.
12081 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
12082 `??' (dormant) and `?E' (expirable).
12083 If MARK is nil, then the default character `?D' is used.
12084 If ARTICLE is nil, then the article on the current line will be
12086 ;; The mark might be a string.
12087 (and (stringp mark)
12088 (setq mark (aref mark 0)))
12089 ;; If no mark is given, then we check auto-expiring.
12090 (and (not no-expire)
12091 gnus-newsgroup-auto-expire
12093 (and (numberp mark)
12094 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
12095 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
12096 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
12097 (setq mark gnus-expirable-mark))
12098 (let* ((mark (or mark gnus-del-mark))
12099 (article (or article (gnus-summary-article-number))))
12100 (or article (error "No article on current line"))
12101 (if (or (= mark gnus-unread-mark)
12102 (= mark gnus-ticked-mark)
12103 (= mark gnus-dormant-mark))
12104 (gnus-mark-article-as-unread article mark)
12105 (gnus-mark-article-as-read article mark))
12107 ;; See whether the article is to be put in the cache.
12108 (and gnus-use-cache
12109 (not (= mark gnus-canceled-mark))
12110 (vectorp (gnus-summary-article-header article))
12112 (gnus-cache-possibly-enter-article
12113 gnus-newsgroup-name article
12114 (gnus-summary-article-header article)
12115 (= mark gnus-ticked-mark)
12116 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
12118 (if (gnus-summary-goto-subject article nil t)
12119 (let ((buffer-read-only nil))
12120 (gnus-summary-show-thread)
12122 (gnus-summary-update-mark mark 'unread)
12125 (defun gnus-summary-update-secondary-mark (article)
12126 "Update the secondary (read, process, cache) mark."
12127 (gnus-summary-update-mark
12128 (cond ((memq article gnus-newsgroup-processable)
12130 ((memq article gnus-newsgroup-cached)
12132 ((memq article gnus-newsgroup-replied)
12134 ((memq article gnus-newsgroup-saved)
12136 (t gnus-unread-mark))
12138 (when (gnus-visual-p 'summary-highlight 'highlight)
12139 (run-hooks 'gnus-summary-update-hook))
12142 (defun gnus-summary-update-mark (mark type)
12143 (beginning-of-line)
12144 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
12145 (buffer-read-only nil))
12147 (<= (+ forward (point)) (point-max)))
12148 ;; Go to the right position on the line.
12149 (goto-char (+ forward (point)))
12150 ;; Replace the old mark with the new mark.
12151 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
12152 ;; Optionally update the marks by some user rule.
12153 (when (eq type 'unread)
12154 (gnus-data-set-mark
12155 (gnus-data-find (gnus-summary-article-number)) mark)
12156 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
12158 (defun gnus-mark-article-as-read (article &optional mark)
12159 "Enter ARTICLE in the pertinent lists and remove it from others."
12160 ;; Make the article expirable.
12161 (let ((mark (or mark gnus-del-mark)))
12162 (if (= mark gnus-expirable-mark)
12163 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
12164 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
12165 ;; Remove from unread and marked lists.
12166 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12167 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12168 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12169 (push (cons article mark) gnus-newsgroup-reads)
12170 ;; Possibly remove from cache, if that is used.
12171 (when gnus-use-cache
12172 (gnus-cache-enter-remove-article article))))
12174 (defun gnus-mark-article-as-unread (article &optional mark)
12175 "Enter ARTICLE in the pertinent lists and remove it from others."
12176 (let ((mark (or mark gnus-ticked-mark)))
12177 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
12178 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
12179 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
12180 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
12181 (cond ((= mark gnus-ticked-mark)
12182 (push article gnus-newsgroup-marked))
12183 ((= mark gnus-dormant-mark)
12184 (push article gnus-newsgroup-dormant))
12186 (push article gnus-newsgroup-unreads)))
12187 (setq gnus-newsgroup-reads
12188 (delq (assq article gnus-newsgroup-reads)
12189 gnus-newsgroup-reads))))
12191 (defalias 'gnus-summary-mark-as-unread-forward
12192 'gnus-summary-tick-article-forward)
12193 (make-obsolete 'gnus-summary-mark-as-unread-forward
12194 'gnus-summary-tick-article-forward)
12195 (defun gnus-summary-tick-article-forward (n)
12196 "Tick N articles forwards.
12197 If N is negative, tick backwards instead.
12198 The difference between N and the number of articles ticked is returned."
12200 (gnus-summary-mark-forward n gnus-ticked-mark))
12202 (defalias 'gnus-summary-mark-as-unread-backward
12203 'gnus-summary-tick-article-backward)
12204 (make-obsolete 'gnus-summary-mark-as-unread-backward
12205 'gnus-summary-tick-article-backward)
12206 (defun gnus-summary-tick-article-backward (n)
12207 "Tick N articles backwards.
12208 The difference between N and the number of articles ticked is returned."
12210 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
12212 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12213 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
12214 (defun gnus-summary-tick-article (&optional article clear-mark)
12215 "Mark current article as unread.
12216 Optional 1st argument ARTICLE specifies article number to be marked as unread.
12217 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
12219 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
12220 gnus-ticked-mark)))
12222 (defun gnus-summary-mark-as-read-forward (n)
12223 "Mark N articles as read forwards.
12224 If N is negative, mark backwards instead.
12225 The difference between N and the actual number of articles marked is
12228 (gnus-summary-mark-forward n gnus-del-mark t))
12230 (defun gnus-summary-mark-as-read-backward (n)
12231 "Mark the N articles as read backwards.
12232 The difference between N and the actual number of articles marked is
12235 (gnus-summary-mark-forward (- n) gnus-del-mark t))
12237 (defun gnus-summary-mark-as-read (&optional article mark)
12238 "Mark current article as read.
12239 ARTICLE specifies the article to be marked as read.
12240 MARK specifies a string to be inserted at the beginning of the line."
12241 (gnus-summary-mark-article article mark))
12243 (defun gnus-summary-clear-mark-forward (n)
12244 "Clear marks from N articles forward.
12245 If N is negative, clear backward instead.
12246 The difference between N and the number of marks cleared is returned."
12248 (gnus-summary-mark-forward n gnus-unread-mark))
12250 (defun gnus-summary-clear-mark-backward (n)
12251 "Clear marks from N articles backward.
12252 The difference between N and the number of marks cleared is returned."
12254 (gnus-summary-mark-forward (- n) gnus-unread-mark))
12256 (defun gnus-summary-mark-unread-as-read ()
12257 "Intended to be used by `gnus-summary-mark-article-hook'."
12258 (when (memq gnus-current-article gnus-newsgroup-unreads)
12259 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
12261 (defun gnus-summary-mark-read-and-unread-as-read ()
12262 "Intended to be used by `gnus-summary-mark-article-hook'."
12263 (let ((mark (gnus-summary-article-mark)))
12264 (when (or (gnus-unread-mark-p mark)
12265 (gnus-read-mark-p mark))
12266 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
12268 (defun gnus-summary-mark-region-as-read (point mark all)
12269 "Mark all unread articles between point and mark as read.
12270 If given a prefix, mark all articles between point and mark as read,
12271 even ticked and dormant ones."
12272 (interactive "r\nP")
12276 (beginning-of-line)
12281 (memq (setq article (gnus-summary-article-number))
12282 gnus-newsgroup-unreads))
12283 (gnus-summary-mark-article article gnus-del-mark))
12285 (gnus-summary-find-next))))))
12287 (defun gnus-summary-mark-below (score mark)
12288 "Mark articles with score less than SCORE with MARK."
12289 (interactive "P\ncMark: ")
12290 (gnus-set-global-variables)
12291 (setq score (if score
12292 (prefix-numeric-value score)
12293 (or gnus-summary-default-score 0)))
12295 (set-buffer gnus-summary-buffer)
12296 (goto-char (point-min))
12299 (and (< (gnus-summary-article-score) score)
12300 (gnus-summary-mark-article nil mark))
12301 (gnus-summary-find-next)))))
12303 (defun gnus-summary-kill-below (&optional score)
12304 "Mark articles with score below SCORE as read."
12306 (gnus-set-global-variables)
12307 (gnus-summary-mark-below score gnus-killed-mark))
12309 (defun gnus-summary-clear-above (&optional score)
12310 "Clear all marks from articles with score above SCORE."
12312 (gnus-set-global-variables)
12313 (gnus-summary-mark-above score gnus-unread-mark))
12315 (defun gnus-summary-tick-above (&optional score)
12316 "Tick all articles with score above SCORE."
12318 (gnus-set-global-variables)
12319 (gnus-summary-mark-above score gnus-ticked-mark))
12321 (defun gnus-summary-mark-above (score mark)
12322 "Mark articles with score over SCORE with MARK."
12323 (interactive "P\ncMark: ")
12324 (gnus-set-global-variables)
12325 (setq score (if score
12326 (prefix-numeric-value score)
12327 (or gnus-summary-default-score 0)))
12329 (set-buffer gnus-summary-buffer)
12330 (goto-char (point-min))
12332 (if (> (gnus-summary-article-score) score)
12333 (gnus-summary-mark-article nil mark))
12335 (gnus-summary-find-next)))))
12337 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12338 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12339 (defun gnus-summary-limit-include-expunged ()
12340 "Display all the hidden articles that were expunged for low scores."
12342 (gnus-set-global-variables)
12343 (let ((buffer-read-only nil))
12344 (let ((scored gnus-newsgroup-scored)
12347 (or (gnus-summary-goto-subject (caar scored))
12348 (and (setq h (gnus-summary-article-header (caar scored)))
12349 (< (cdar scored) gnus-summary-expunge-below)
12350 (setq headers (cons h headers))))
12351 (setq scored (cdr scored)))
12352 (or headers (error "No expunged articles hidden."))
12353 (goto-char (point-min))
12354 (gnus-summary-prepare-unthreaded (nreverse headers)))
12355 (goto-char (point-min))
12356 (gnus-summary-position-point)))
12358 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12359 "Mark all articles not marked as unread in this newsgroup as read.
12360 If prefix argument ALL is non-nil, all articles are marked as read.
12361 If QUIETLY is non-nil, no questions will be asked.
12362 If TO-HERE is non-nil, it should be a point in the buffer. All
12363 articles before this point will be marked as read.
12364 The number of articles marked as read is returned."
12366 (gnus-set-global-variables)
12369 (not gnus-interactive-catchup) ;Without confirmation?
12373 "Mark absolutely all articles as read? "
12374 "Mark all unread articles as read? ")))
12376 (not gnus-newsgroup-adaptive)
12377 (not gnus-newsgroup-auto-expire))
12380 (setq gnus-newsgroup-marked nil
12381 gnus-newsgroup-dormant nil))
12382 (setq gnus-newsgroup-unreads nil))
12383 ;; We actually mark all articles as canceled, which we
12384 ;; have to do when using auto-expiry or adaptive scoring.
12385 (gnus-summary-show-all-threads)
12386 (if (gnus-summary-first-subject (not all))
12388 (if to-here (< (point) to-here) t)
12389 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12390 (gnus-summary-find-next (not all)))))
12392 (setq gnus-newsgroup-unreads nil))
12393 (gnus-set-mode-line 'summary)))
12394 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12395 (if (and (not to-here) (eq 'nnvirtual (car method)))
12396 (nnvirtual-catchup-group
12397 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12398 (gnus-summary-position-point)))
12400 (defun gnus-summary-catchup-to-here (&optional all)
12401 "Mark all unticked articles before the current one as read.
12402 If ALL is non-nil, also mark ticked and dormant articles as read."
12404 (gnus-set-global-variables)
12406 (gnus-save-hidden-threads
12407 (let ((beg (point)))
12408 ;; We check that there are unread articles.
12409 (when (or all (gnus-summary-find-prev))
12410 (gnus-summary-catchup all t beg)))))
12411 (gnus-summary-position-point))
12413 (defun gnus-summary-catchup-all (&optional quietly)
12414 "Mark all articles in this newsgroup as read."
12416 (gnus-set-global-variables)
12417 (gnus-summary-catchup t quietly))
12419 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12420 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12421 If prefix argument ALL is non-nil, all articles are marked as read."
12423 (gnus-set-global-variables)
12424 (gnus-summary-catchup all quietly nil 'fast)
12425 ;; Select next newsgroup or exit.
12426 (if (eq gnus-auto-select-next 'quietly)
12427 (gnus-summary-next-group nil)
12428 (gnus-summary-exit)))
12430 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12431 "Mark all articles in this newsgroup as read, and then exit."
12433 (gnus-set-global-variables)
12434 (gnus-summary-catchup-and-exit t quietly))
12436 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12437 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12438 "Mark all articles in this group as read and select the next group.
12439 If given a prefix, mark all articles, unread as well as ticked, as
12442 (gnus-set-global-variables)
12444 (gnus-summary-catchup all))
12445 (gnus-summary-next-article t nil nil t))
12447 ;; Thread-based commands.
12449 (defun gnus-summary-articles-in-thread (&optional article)
12450 "Return a list of all articles in the current thread.
12451 If ARTICLE is non-nil, return all articles in the thread that starts
12452 with that article."
12453 (let* ((article (or article (gnus-summary-article-number)))
12454 (data (gnus-data-find-list article))
12455 (top-level (gnus-data-level (car data)))
12457 (cond ((null gnus-thread-operation-ignore-subject)
12458 (gnus-simplify-subject-re
12459 (mail-header-subject (gnus-data-header (car data)))))
12460 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12461 (gnus-simplify-subject-fuzzy
12462 (mail-header-subject (gnus-data-header (car data)))))
12464 (end-point (save-excursion
12465 (if (gnus-summary-go-to-next-thread)
12466 (point) (point-max))))
12469 (< (gnus-data-pos (car data)) end-point))
12470 (when (or (not top-subject)
12471 (string= top-subject
12472 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12473 (gnus-simplify-subject-fuzzy
12474 (mail-header-subject
12475 (gnus-data-header (car data))))
12476 (gnus-simplify-subject-re
12477 (mail-header-subject
12478 (gnus-data-header (car data)))))))
12479 (push (gnus-data-number (car data)) articles))
12480 (unless (and (setq data (cdr data))
12481 (> (gnus-data-level (car data)) top-level))
12483 ;; Return the list of articles.
12484 (nreverse articles)))
12486 (defun gnus-summary-rethread-current ()
12487 "Rethread the thread the current article is part of."
12489 (gnus-set-global-variables)
12490 (let* ((gnus-show-threads t)
12491 (article (gnus-summary-article-number))
12492 (id (mail-header-id (gnus-summary-article-header)))
12493 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12495 (error "No article on the current line"))
12496 (gnus-rebuild-thread id)
12497 (gnus-summary-goto-subject article)))
12499 (defun gnus-summary-reparent-thread ()
12500 "Make current article child of the marked (or previous) article.
12502 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12503 is non-nil or the Subject: of both articles are the same."
12505 (or (not (gnus-group-read-only-p))
12506 (error "The current newsgroup does not support article editing."))
12507 (or (<= (length gnus-newsgroup-processable) 1)
12508 (error "No more than one article may be marked."))
12509 (save-window-excursion
12510 (let ((gnus-article-buffer " *reparent*")
12511 (current-article (gnus-summary-article-number))
12512 ; first grab the marked article, otherwise one line up.
12513 (parent-article (if (not (null gnus-newsgroup-processable))
12514 (car gnus-newsgroup-processable)
12516 (if (eq (forward-line -1) 0)
12517 (gnus-summary-article-number)
12518 (error "Beginning of summary buffer."))))))
12519 (or (not (eq current-article parent-article))
12520 (error "An article may not be self-referential."))
12521 (let ((message-id (mail-header-id
12522 (gnus-summary-article-header parent-article))))
12523 (or (and message-id (not (equal message-id "")))
12524 (error "No message-id in desired parent."))
12525 (gnus-summary-select-article t t nil current-article)
12526 (set-buffer gnus-article-buffer)
12527 (setq buffer-read-only nil)
12528 (let ((buf (format "%s" (buffer-string))))
12531 (goto-char (point-min))
12532 (if (search-forward-regexp "^References: " nil t)
12533 (insert message-id " " )
12534 (insert "References: " message-id "\n"))
12535 (or (gnus-request-replace-article current-article
12536 (car gnus-article-current)
12537 gnus-article-buffer)
12538 (error "Couldn't replace article."))
12539 (set-buffer gnus-summary-buffer)
12540 (gnus-summary-unmark-all-processable)
12541 (gnus-summary-rethread-current)
12542 (gnus-message 3 "Article %d is now the child of article %d."
12543 current-article parent-article)))))
12545 (defun gnus-summary-toggle-threads (&optional arg)
12546 "Toggle showing conversation threads.
12547 If ARG is positive number, turn showing conversation threads on."
12549 (gnus-set-global-variables)
12550 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12551 (setq gnus-show-threads
12552 (if (null arg) (not gnus-show-threads)
12553 (> (prefix-numeric-value arg) 0)))
12554 (gnus-summary-prepare)
12555 (gnus-summary-goto-subject current)
12556 (gnus-summary-position-point)))
12558 (defun gnus-summary-show-all-threads ()
12559 "Show all threads."
12561 (gnus-set-global-variables)
12563 (let ((buffer-read-only nil))
12564 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12565 (gnus-summary-position-point))
12567 (defun gnus-summary-show-thread ()
12568 "Show thread subtrees.
12569 Returns nil if no thread was there to be shown."
12571 (gnus-set-global-variables)
12572 (let ((buffer-read-only nil)
12574 ;; first goto end then to beg, to have point at beg after let
12575 (end (progn (end-of-line) (point)))
12576 (beg (progn (beginning-of-line) (point))))
12578 ;; Any hidden lines here?
12579 (search-forward "\r" end t)
12580 (subst-char-in-region beg end ?\^M ?\n t)
12582 (gnus-summary-position-point))))
12584 (defun gnus-summary-hide-all-threads ()
12585 "Hide all thread subtrees."
12587 (gnus-set-global-variables)
12589 (goto-char (point-min))
12590 (gnus-summary-hide-thread)
12591 (while (zerop (gnus-summary-next-thread 1 t))
12592 (gnus-summary-hide-thread)))
12593 (gnus-summary-position-point))
12595 (defun gnus-summary-hide-thread ()
12596 "Hide thread subtrees.
12597 Returns nil if no threads were there to be hidden."
12599 (gnus-set-global-variables)
12600 (let ((buffer-read-only nil)
12602 (article (gnus-summary-article-number)))
12604 ;; Go forward until either the buffer ends or the subthread
12606 (when (and (not (eobp))
12607 (or (zerop (gnus-summary-next-thread 1 t))
12608 (goto-char (point-max))))
12610 (if (and (> (point) start)
12611 (search-backward "\n" start t))
12613 (subst-char-in-region start (point) ?\n ?\^M)
12614 (gnus-summary-goto-subject article))
12617 ;;(gnus-summary-position-point)
12620 (defun gnus-summary-go-to-next-thread (&optional previous)
12621 "Go to the same level (or less) next thread.
12622 If PREVIOUS is non-nil, go to previous thread instead.
12623 Return the article number moved to, or nil if moving was impossible."
12624 (let ((level (gnus-summary-thread-level))
12625 (way (if previous -1 1))
12628 (while (and (not (eobp))
12629 (< level (gnus-summary-thread-level)))
12630 (forward-line way))
12637 (gnus-summary-article-number)
12638 (goto-char beg)))))
12640 (defun gnus-summary-go-to-next-thread-old (&optional previous)
12641 "Go to the same level (or less) next thread.
12642 If PREVIOUS is non-nil, go to previous thread instead.
12643 Return the article number moved to, or nil if moving was impossible."
12644 (if (and (eq gnus-summary-make-false-root 'dummy)
12645 (gnus-summary-article-intangible-p))
12646 (let ((beg (point)))
12647 (while (and (zerop (forward-line 1))
12648 (not (gnus-summary-article-intangible-p))
12649 (not (zerop (save-excursion
12650 (gnus-summary-thread-level))))))
12656 (let* ((level (gnus-summary-thread-level))
12657 (article (gnus-summary-article-number))
12658 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12661 (if (<= (gnus-data-level (car data)) level)
12662 (setq oart (gnus-data-number (car data))
12664 (setq data (cdr data))))
12666 (gnus-summary-goto-subject oart)))))
12668 (defun gnus-summary-next-thread (n &optional silent)
12669 "Go to the same level next N'th thread.
12670 If N is negative, search backward instead.
12671 Returns the difference between N and the number of skips actually
12674 If SILENT, don't output messages."
12676 (gnus-set-global-variables)
12677 (let ((backward (< n 0))
12680 (while (and (> n 0)
12681 (gnus-summary-go-to-next-thread backward))
12684 (gnus-summary-position-point))
12685 (when (and (not silent) (/= 0 n))
12686 (gnus-message 7 "No more threads"))
12689 (defun gnus-summary-prev-thread (n)
12690 "Go to the same level previous N'th thread.
12691 Returns the difference between N and the number of skips actually
12694 (gnus-set-global-variables)
12695 (gnus-summary-next-thread (- n)))
12697 (defun gnus-summary-go-down-thread ()
12698 "Go down one level in the current thread."
12699 (let ((children (gnus-summary-article-children)))
12701 (gnus-summary-goto-subject (car children)))))
12703 (defun gnus-summary-go-up-thread ()
12704 "Go up one level in the current thread."
12705 (let ((parent (gnus-summary-article-parent)))
12707 (gnus-summary-goto-subject parent))))
12709 (defun gnus-summary-down-thread (n)
12710 "Go down thread N steps.
12711 If N is negative, go up instead.
12712 Returns the difference between N and how many steps down that were
12715 (gnus-set-global-variables)
12718 (while (and (> n 0)
12719 (if up (gnus-summary-go-up-thread)
12720 (gnus-summary-go-down-thread)))
12722 (gnus-summary-position-point)
12723 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12726 (defun gnus-summary-up-thread (n)
12727 "Go up thread N steps.
12728 If N is negative, go up instead.
12729 Returns the difference between N and how many steps down that were
12732 (gnus-set-global-variables)
12733 (gnus-summary-down-thread (- n)))
12735 (defun gnus-summary-top-thread ()
12736 "Go to the top of the thread."
12738 (gnus-set-global-variables)
12739 (while (gnus-summary-go-up-thread))
12740 (gnus-summary-article-number))
12742 (defun gnus-summary-kill-thread (&optional unmark)
12743 "Mark articles under current thread as read.
12744 If the prefix argument is positive, remove any kinds of marks.
12745 If the prefix argument is negative, tick articles instead."
12747 (gnus-set-global-variables)
12749 (setq unmark (prefix-numeric-value unmark)))
12750 (let ((articles (gnus-summary-articles-in-thread)))
12752 ;; Expand the thread.
12753 (gnus-summary-show-thread)
12754 ;; Mark all the articles.
12756 (gnus-summary-goto-subject (car articles))
12757 (cond ((null unmark)
12758 (gnus-summary-mark-article-as-read gnus-killed-mark))
12760 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12762 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12763 (setq articles (cdr articles))))
12764 ;; Hide killed subtrees.
12766 gnus-thread-hide-killed
12767 (gnus-summary-hide-thread))
12768 ;; If marked as read, go to next unread subject.
12770 ;; Go to next unread subject.
12771 (gnus-summary-next-subject 1 t)))
12772 (gnus-set-mode-line 'summary))
12774 ;; Summary sorting commands
12776 (defun gnus-summary-sort-by-number (&optional reverse)
12777 "Sort summary buffer by article number.
12778 Argument REVERSE means reverse order."
12780 (gnus-summary-sort 'number reverse))
12782 (defun gnus-summary-sort-by-author (&optional reverse)
12783 "Sort summary buffer by author name alphabetically.
12784 If case-fold-search is non-nil, case of letters is ignored.
12785 Argument REVERSE means reverse order."
12787 (gnus-summary-sort 'author reverse))
12789 (defun gnus-summary-sort-by-subject (&optional reverse)
12790 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12791 If case-fold-search is non-nil, case of letters is ignored.
12792 Argument REVERSE means reverse order."
12794 (gnus-summary-sort 'subject reverse))
12796 (defun gnus-summary-sort-by-date (&optional reverse)
12797 "Sort summary buffer by date.
12798 Argument REVERSE means reverse order."
12800 (gnus-summary-sort 'date reverse))
12802 (defun gnus-summary-sort-by-score (&optional reverse)
12803 "Sort summary buffer by score.
12804 Argument REVERSE means reverse order."
12806 (gnus-summary-sort 'score reverse))
12808 (defun gnus-summary-sort (predicate reverse)
12809 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12810 (gnus-set-global-variables)
12811 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12812 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12813 (gnus-thread-sort-functions
12818 (,thread t2 t1)))))
12819 (gnus-article-sort-functions
12824 (,article t2 t1)))))
12826 (gnus-summary-prepare-hook nil))
12827 ;; We do the sorting by regenerating the threads.
12828 (gnus-summary-prepare)
12829 ;; Hide subthreads if needed.
12830 (when (and gnus-show-threads gnus-thread-hide-subtree)
12831 (gnus-summary-hide-all-threads)))
12832 ;; If in async mode, we send some info to the backend.
12833 (when gnus-newsgroup-async
12834 (gnus-request-asynchronous
12835 gnus-newsgroup-name gnus-newsgroup-data)))
12837 (defun gnus-sortable-date (date)
12838 "Make sortable string by string-lessp from DATE.
12839 Timezone package is used."
12842 (setq date (inline (timezone-fix-time
12844 (aref (inline (timezone-parse-date date)) 4))))
12846 (timezone-make-sortable-date
12847 (aref date 0) (aref date 1) (aref date 2)
12849 (timezone-make-time-string
12850 (aref date 3) (aref date 4) (aref date 5))))))
12853 ;; Summary saving commands.
12855 (defun gnus-summary-save-article (&optional n not-saved)
12856 "Save the current article using the default saver function.
12857 If N is a positive number, save the N next articles.
12858 If N is a negative number, save the N previous articles.
12859 If N is nil and any articles have been marked with the process mark,
12860 save those articles instead.
12861 The variable `gnus-default-article-saver' specifies the saver function."
12863 (gnus-set-global-variables)
12864 (let ((articles (gnus-summary-work-articles n))
12865 file header article)
12867 (setq header (gnus-summary-article-header
12868 (setq article (pop articles))))
12869 (if (not (vectorp header))
12870 ;; This is a pseudo-article.
12871 (if (assq 'name header)
12872 (gnus-copy-file (cdr (assq 'name header)))
12873 (gnus-message 1 "Article %d is unsaveable" article))
12874 ;; This is a real article.
12875 (save-window-excursion
12876 (gnus-summary-select-article t nil nil article))
12877 (unless gnus-save-all-headers
12878 ;; Remove headers accoring to `gnus-saved-headers'.
12879 (let ((gnus-visible-headers
12880 (or gnus-saved-headers gnus-visible-headers)))
12881 (gnus-article-hide-headers nil t)))
12882 ;; Remove any X-Gnus lines.
12884 (set-buffer gnus-article-buffer)
12886 (let ((buffer-read-only nil))
12887 (nnheader-narrow-to-headers)
12888 (while (re-search-forward "^X-Gnus" nil t)
12889 (gnus-delete-line)))))
12890 (save-window-excursion
12891 (if (not gnus-default-article-saver)
12892 (error "No default saver is defined.")
12893 (setq file (funcall
12894 gnus-default-article-saver
12896 ((not gnus-prompt-before-saving)
12898 ((eq gnus-prompt-before-saving 'always)
12901 (gnus-summary-remove-process-mark article)
12903 (gnus-summary-set-saved-mark article))))
12904 (gnus-summary-position-point)
12907 (defun gnus-summary-pipe-output (&optional arg)
12908 "Pipe the current article to a subprocess.
12909 If N is a positive number, pipe the N next articles.
12910 If N is a negative number, pipe the N previous articles.
12911 If N is nil and any articles have been marked with the process mark,
12912 pipe those articles instead."
12914 (gnus-set-global-variables)
12915 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12916 (gnus-summary-save-article arg t))
12917 (gnus-configure-windows 'pipe))
12919 (defun gnus-summary-save-article-mail (&optional arg)
12920 "Append the current article to an mail file.
12921 If N is a positive number, save the N next articles.
12922 If N is a negative number, save the N previous articles.
12923 If N is nil and any articles have been marked with the process mark,
12924 save those articles instead."
12926 (gnus-set-global-variables)
12927 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12928 (gnus-summary-save-article arg)))
12930 (defun gnus-summary-save-article-rmail (&optional arg)
12931 "Append the current article to an rmail file.
12932 If N is a positive number, save the N next articles.
12933 If N is a negative number, save the N previous articles.
12934 If N is nil and any articles have been marked with the process mark,
12935 save those articles instead."
12937 (gnus-set-global-variables)
12938 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12939 (gnus-summary-save-article arg)))
12941 (defun gnus-summary-save-article-file (&optional arg)
12942 "Append the current article to a file.
12943 If N is a positive number, save the N next articles.
12944 If N is a negative number, save the N previous articles.
12945 If N is nil and any articles have been marked with the process mark,
12946 save those articles instead."
12948 (gnus-set-global-variables)
12949 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12950 (gnus-summary-save-article arg)))
12952 (defun gnus-summary-save-article-body-file (&optional arg)
12953 "Append the current article body to a file.
12954 If N is a positive number, save the N next articles.
12955 If N is a negative number, save the N previous articles.
12956 If N is nil and any articles have been marked with the process mark,
12957 save those articles instead."
12959 (gnus-set-global-variables)
12960 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12961 (gnus-summary-save-article arg)))
12963 (defun gnus-get-split-value (methods)
12964 "Return a value based on the split METHODS."
12965 (let (split-name method result match)
12968 (set-buffer gnus-original-article-buffer)
12970 (nnheader-narrow-to-headers)
12972 (goto-char (point-min))
12973 (setq method (pop methods))
12974 (setq match (car method))
12977 ;; Regular expression.
12979 (re-search-forward match nil t)
12981 ((gnus-functionp match)
12985 (setq result (funcall match gnus-newsgroup-name))))
12990 (setq result (eval match)))))
12991 (setq split-name (append (cdr method) split-name))
12992 (cond ((stringp result)
12993 (push result split-name))
12995 (setq split-name (append result split-name)))))))))
12998 (defun gnus-read-move-group-name (prompt default articles prefix)
12999 "Read a group name."
13000 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
13001 (minibuffer-confirm-incomplete nil) ; XEmacs
13008 (assoc (symbol-name
13009 (car (gnus-find-method-for-group
13011 gnus-valid-select-methods))
13012 (push (list (symbol-name g)) group-map)))
13013 gnus-active-hashtb))
13015 (format "%s %s to:"
13017 (if (> (length articles) 1)
13018 (format "these %d articles" (length articles))
13023 (gnus-completing-read default prom
13024 group-map nil nil prefix
13025 'gnus-group-history))
13026 ((= 1 (length split-name))
13027 (gnus-completing-read (car split-name) prom group-map
13029 'gnus-group-history))
13031 (gnus-completing-read nil prom
13032 (mapcar (lambda (el) (list el))
13033 (nreverse split-name))
13035 'gnus-group-history)))))
13037 (if (or (string= to-newsgroup "")
13038 (string= to-newsgroup prefix))
13039 (setq to-newsgroup (or default "")))
13040 (or (gnus-active to-newsgroup)
13041 (gnus-activate-group to-newsgroup)
13042 (error "No such group: %s" to-newsgroup)))
13045 (defun gnus-read-save-file-name (prompt default-name)
13046 (let* ((split-name (gnus-get-split-value gnus-split-methods))
13048 ;; Let the split methods have their say.
13050 ;; No split name was found.
13053 (concat prompt " (default "
13054 (file-name-nondirectory default-name) ") ")
13055 (file-name-directory default-name)
13057 ;; A single split name was found
13058 ((= 1 (length split-name))
13060 (concat prompt " (default " (car split-name) ") ")
13061 gnus-article-save-directory
13062 (concat gnus-article-save-directory (car split-name))))
13063 ;; A list of splits was found.
13065 (setq split-name (nreverse split-name))
13067 (let ((file-name-history (nconc split-name file-name-history)))
13070 (concat prompt " (`M-p' for defaults) ")
13071 gnus-article-save-directory
13072 (car split-name))))
13073 (car (push result file-name-history)))))))
13074 ;; If we have read a directory, we append the default file name.
13075 (when (file-directory-p file)
13076 (setq file (concat (file-name-as-directory file)
13077 (file-name-nondirectory default-name))))
13078 ;; Possibly translate some charaters.
13079 (nnheader-translate-file-chars file)))
13081 (defun gnus-article-archive-name (group)
13082 "Return the first instance of an \"Archive-name\" in the current buffer."
13083 (let ((case-fold-search t))
13084 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
13085 (match-string 1))))
13087 (defun gnus-summary-save-in-rmail (&optional filename)
13088 "Append this article to Rmail file.
13089 Optional argument FILENAME specifies file name.
13090 Directory to save to is default to `gnus-article-save-directory'."
13092 (gnus-set-global-variables)
13093 (let ((default-name
13094 (funcall gnus-rmail-save-name gnus-newsgroup-name
13095 gnus-current-headers gnus-newsgroup-last-rmail)))
13097 (cond ((eq filename 'default)
13099 (filename filename)
13100 (t (gnus-read-save-file-name
13101 "Save in rmail file:" default-name))))
13102 (gnus-make-directory (file-name-directory filename))
13103 (gnus-eval-in-buffer-window
13104 gnus-original-article-buffer
13108 (gnus-output-to-rmail filename))))
13109 ;; Remember the directory name to save articles
13110 (setq gnus-newsgroup-last-rmail filename)))
13112 (defun gnus-summary-save-in-mail (&optional filename)
13113 "Append this article to Unix mail file.
13114 Optional argument FILENAME specifies file name.
13115 Directory to save to is default to `gnus-article-save-directory'."
13117 (gnus-set-global-variables)
13118 (let ((default-name
13119 (funcall gnus-mail-save-name gnus-newsgroup-name
13120 gnus-current-headers gnus-newsgroup-last-mail)))
13122 (cond ((eq filename 'default)
13124 (filename filename)
13125 (t (gnus-read-save-file-name
13126 "Save in Unix mail file:" default-name))))
13128 (expand-file-name filename
13130 (file-name-directory default-name))))
13131 (gnus-make-directory (file-name-directory filename))
13132 (gnus-eval-in-buffer-window
13133 gnus-original-article-buffer
13137 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
13138 (gnus-output-to-rmail filename)
13139 (let ((mail-use-rfc822 t))
13140 (rmail-output filename 1 t t))))))
13141 ;; Remember the directory name to save articles.
13142 (setq gnus-newsgroup-last-mail filename)))
13144 (defun gnus-summary-save-in-file (&optional filename)
13145 "Append this article to file.
13146 Optional argument FILENAME specifies file name.
13147 Directory to save to is default to `gnus-article-save-directory'."
13149 (gnus-set-global-variables)
13150 (let ((default-name
13151 (funcall gnus-file-save-name gnus-newsgroup-name
13152 gnus-current-headers gnus-newsgroup-last-file)))
13154 (cond ((eq filename 'default)
13156 (filename filename)
13157 (t (gnus-read-save-file-name
13158 "Save in file:" default-name))))
13159 (gnus-make-directory (file-name-directory filename))
13160 (gnus-eval-in-buffer-window
13161 gnus-original-article-buffer
13165 (gnus-output-to-file filename))))
13166 ;; Remember the directory name to save articles.
13167 (setq gnus-newsgroup-last-file filename)))
13169 (defun gnus-summary-save-body-in-file (&optional filename)
13170 "Append this article body to a file.
13171 Optional argument FILENAME specifies file name.
13172 The directory to save in defaults to `gnus-article-save-directory'."
13174 (gnus-set-global-variables)
13175 (let ((default-name
13176 (funcall gnus-file-save-name gnus-newsgroup-name
13177 gnus-current-headers gnus-newsgroup-last-file)))
13179 (cond ((eq filename 'default)
13181 (filename filename)
13182 (t (gnus-read-save-file-name
13183 "Save body in file:" default-name))))
13184 (gnus-make-directory (file-name-directory filename))
13185 (gnus-eval-in-buffer-window
13186 gnus-article-buffer
13190 (goto-char (point-min))
13191 (and (search-forward "\n\n" nil t)
13192 (narrow-to-region (point) (point-max)))
13193 (gnus-output-to-file filename))))
13194 ;; Remember the directory name to save articles.
13195 (setq gnus-newsgroup-last-file filename)))
13197 (defun gnus-summary-save-in-pipe (&optional command)
13198 "Pipe this article to subprocess."
13200 (gnus-set-global-variables)
13202 (cond ((eq command 'default)
13203 gnus-last-shell-command)
13205 (t (read-string "Shell command on article: "
13206 gnus-last-shell-command))))
13207 (if (string-equal command "")
13208 (setq command gnus-last-shell-command))
13209 (gnus-eval-in-buffer-window
13210 gnus-article-buffer
13213 (shell-command-on-region (point-min) (point-max) command nil)))
13214 (setq gnus-last-shell-command command))
13216 ;; Summary extract commands
13218 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
13219 (let ((buffer-read-only nil)
13220 (article (gnus-summary-article-number))
13222 (or (gnus-summary-goto-subject article)
13223 (error (format "No such article: %d" article)))
13224 (gnus-summary-position-point)
13225 ;; If all commands are to be bunched up on one line, we collect
13227 (if gnus-view-pseudos-separately
13229 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
13232 (setq action (cdr (assq 'action (car ps))))
13233 (setq files (list (cdr (assq 'name (car ps)))))
13234 (while (and ps (cdr ps)
13235 (string= (or action "1")
13236 (or (cdr (assq 'action (cadr ps))) "2")))
13237 (setq files (cons (cdr (assq 'name (cadr ps))) files))
13238 (setcdr ps (cddr ps)))
13241 (if (not (string-match "%s" action))
13242 (setq files (cons " " files)))
13243 (setq files (cons " " files))
13244 (and (assq 'execute (car ps))
13245 (setcdr (assq 'execute (car ps))
13246 (funcall (if (string-match "%s" action)
13249 (mapconcat (lambda (f) f) files " ")))))
13250 (setq ps (cdr ps)))))
13251 (if (and gnus-view-pseudos (not not-view))
13253 (and (assq 'execute (car pslist))
13254 (gnus-execute-command (cdr (assq 'execute (car pslist)))
13255 (eq gnus-view-pseudos 'not-confirm)))
13256 (setq pslist (cdr pslist)))
13259 (setq after-article (or (cdr (assq 'article (car pslist)))
13260 (gnus-summary-article-number)))
13261 (gnus-summary-goto-subject after-article)
13264 (insert " " (file-name-nondirectory
13265 (cdr (assq 'name (car pslist))))
13266 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
13268 (forward-line -1) ; back to `b'
13269 (gnus-add-text-properties
13270 b (1- e) (list 'gnus-number gnus-reffed-article-number
13271 gnus-mouse-face-prop gnus-mouse-face))
13273 after-article gnus-reffed-article-number
13274 gnus-unread-mark b (car pslist) 0 (- e b))
13275 (push gnus-reffed-article-number gnus-newsgroup-unreads)
13276 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
13277 (setq pslist (cdr pslist)))))))
13279 (defun gnus-pseudos< (p1 p2)
13280 (let ((c1 (cdr (assq 'action p1)))
13281 (c2 (cdr (assq 'action p2))))
13282 (and c1 c2 (string< c1 c2))))
13284 (defun gnus-request-pseudo-article (props)
13285 (cond ((assq 'execute props)
13286 (gnus-execute-command (cdr (assq 'execute props)))))
13287 (let ((gnus-current-article (gnus-summary-article-number)))
13288 (run-hooks 'gnus-mark-article-hook)))
13290 (defun gnus-execute-command (command &optional automatic)
13292 (gnus-article-setup-buffer)
13293 (set-buffer gnus-article-buffer)
13294 (setq buffer-read-only nil)
13295 (let ((command (if automatic command (read-string "Command: " command)))
13296 ;; Just binding this here doesn't help, because there might
13297 ;; be output from the process after exiting the scope of
13299 ;; (buffer-read-only nil)
13302 (insert "$ " command "\n\n")
13303 (if gnus-view-pseudo-asynchronously
13304 (start-process "gnus-execute" nil "sh" "-c" command)
13305 (call-process "sh" nil t nil "-c" command)))))
13307 (defun gnus-copy-file (file &optional to)
13310 (list (read-file-name "Copy file: " default-directory)
13311 (read-file-name "Copy file to: " default-directory)))
13312 (gnus-set-global-variables)
13313 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13314 (and (file-directory-p to)
13315 (setq to (concat (file-name-as-directory to)
13316 (file-name-nondirectory file))))
13317 (copy-file file to))
13319 ;; Summary kill commands.
13321 (defun gnus-summary-edit-global-kill (article)
13322 "Edit the \"global\" kill file."
13323 (interactive (list (gnus-summary-article-number)))
13324 (gnus-set-global-variables)
13325 (gnus-group-edit-global-kill article))
13327 (defun gnus-summary-edit-local-kill ()
13328 "Edit a local kill file applied to the current newsgroup."
13330 (gnus-set-global-variables)
13331 (setq gnus-current-headers (gnus-summary-article-header))
13332 (gnus-set-global-variables)
13333 (gnus-group-edit-local-kill
13334 (gnus-summary-article-number) gnus-newsgroup-name))
13338 ;;; Gnus article mode
13341 (put 'gnus-article-mode 'mode-class 'special)
13343 (if gnus-article-mode-map
13345 (setq gnus-article-mode-map (make-keymap))
13346 (suppress-keymap gnus-article-mode-map)
13348 (gnus-define-keys gnus-article-mode-map
13349 " " gnus-article-goto-next-page
13350 "\177" gnus-article-goto-prev-page
13351 [delete] gnus-article-goto-prev-page
13352 "\C-c^" gnus-article-refer-article
13353 "h" gnus-article-show-summary
13354 "s" gnus-article-show-summary
13355 "\C-c\C-m" gnus-article-mail
13356 "?" gnus-article-describe-briefly
13357 gnus-mouse-2 gnus-article-push-button
13358 "\r" gnus-article-press-button
13359 "\t" gnus-article-next-button
13360 "\M-\t" gnus-article-prev-button
13361 "\C-c\C-b" gnus-bug)
13363 (substitute-key-definition
13364 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13366 (defun gnus-article-mode ()
13367 "Major mode for displaying an article.
13369 All normal editing commands are switched off.
13371 The following commands are available:
13373 \\<gnus-article-mode-map>
13374 \\[gnus-article-next-page]\t Scroll the article one page forwards
13375 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13376 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13377 \\[gnus-article-show-summary]\t Display the summary buffer
13378 \\[gnus-article-mail]\t Send a reply to the address near point
13379 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13380 \\[gnus-info-find-node]\t Go to the Gnus info node"
13382 (when (and menu-bar-mode
13383 (gnus-visual-p 'article-menu 'menu))
13384 (gnus-article-make-menu-bar))
13385 (kill-all-local-variables)
13386 (gnus-simplify-mode-line)
13387 (setq mode-name "Article")
13388 (setq major-mode 'gnus-article-mode)
13389 (make-local-variable 'minor-mode-alist)
13390 (or (assq 'gnus-show-mime minor-mode-alist)
13391 (setq minor-mode-alist
13392 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13393 (use-local-map gnus-article-mode-map)
13394 (make-local-variable 'page-delimiter)
13395 (setq page-delimiter gnus-page-delimiter)
13396 (buffer-disable-undo (current-buffer))
13397 (setq buffer-read-only t) ;Disable modification
13398 (run-hooks 'gnus-article-mode-hook))
13400 (defun gnus-article-setup-buffer ()
13401 "Initialize the article buffer."
13402 (let* ((name (if gnus-single-article-buffer "*Article*"
13403 (concat "*Article " gnus-newsgroup-name "*")))
13405 (progn (string-match "\\*Article" name)
13406 (concat " *Original Article"
13407 (substring name (match-end 0))))))
13408 (setq gnus-article-buffer name)
13409 (setq gnus-original-article-buffer original)
13410 ;; This might be a variable local to the summary buffer.
13411 (unless gnus-single-article-buffer
13413 (set-buffer gnus-summary-buffer)
13414 (setq gnus-article-buffer name)
13415 (setq gnus-original-article-buffer original)
13416 (gnus-set-global-variables))
13417 (make-local-variable 'gnus-summary-buffer))
13418 ;; Init original article buffer.
13420 (set-buffer (get-buffer-create gnus-original-article-buffer))
13421 (buffer-disable-undo (current-buffer))
13422 (setq major-mode 'gnus-original-article-mode)
13423 (make-local-variable 'gnus-original-article))
13424 (if (get-buffer name)
13427 (buffer-disable-undo (current-buffer))
13428 (setq buffer-read-only t)
13429 (gnus-add-current-to-buffer-list)
13430 (or (eq major-mode 'gnus-article-mode)
13431 (gnus-article-mode))
13434 (set-buffer (get-buffer-create name))
13435 (gnus-add-current-to-buffer-list)
13436 (gnus-article-mode)
13437 (current-buffer)))))
13439 ;; Set article window start at LINE, where LINE is the number of lines
13440 ;; from the head of the article.
13441 (defun gnus-article-set-window-start (&optional line)
13443 (get-buffer-window gnus-article-buffer t)
13445 (set-buffer gnus-article-buffer)
13446 (goto-char (point-min))
13449 (gnus-message 6 "Moved to bookmark")
13450 (search-forward "\n\n" nil t)
13451 (forward-line line)
13454 (defun gnus-kill-all-overlays ()
13455 "Delete all overlays in the current buffer."
13456 (when (fboundp 'overlay-lists)
13457 (let* ((overlayss (overlay-lists))
13458 (buffer-read-only nil)
13459 (overlays (nconc (car overlayss) (cdr overlayss))))
13461 (delete-overlay (pop overlays))))))
13463 (defun gnus-request-article-this-buffer (article group)
13464 "Get an article and insert it into this buffer."
13465 (let (do-update-line)
13469 (gnus-kill-all-overlays)
13470 (setq group (or group gnus-newsgroup-name))
13472 ;; Open server if it has closed.
13473 (gnus-check-server (gnus-find-method-for-group group))
13475 ;; Using `gnus-request-article' directly will insert the article into
13476 ;; `nntp-server-buffer' - so we'll save some time by not having to
13477 ;; copy it from the server buffer into the article buffer.
13479 ;; We only request an article by message-id when we do not have the
13480 ;; headers for it, so we'll have to get those.
13481 (when (stringp article)
13482 (let ((gnus-override-method gnus-refer-article-method))
13483 (gnus-read-header article)))
13485 ;; If the article number is negative, that means that this article
13486 ;; doesn't belong in this newsgroup (possibly), so we find its
13487 ;; message-id and request it by id instead of number.
13488 (when (and (numberp article)
13489 gnus-summary-buffer
13490 (get-buffer gnus-summary-buffer)
13491 (buffer-name (get-buffer gnus-summary-buffer)))
13493 (set-buffer gnus-summary-buffer)
13494 (let ((header (gnus-summary-article-header article)))
13497 ((memq article gnus-newsgroup-sparse)
13498 ;; This is a sparse gap article.
13499 (setq do-update-line article)
13500 (setq article (mail-header-id header))
13501 (let ((gnus-override-method gnus-refer-article-method))
13502 (gnus-read-header article))
13503 (setq gnus-newsgroup-sparse
13504 (delq article gnus-newsgroup-sparse)))
13506 ;; It's a real article.
13507 (setq article (mail-header-id header)))
13509 ;; It is an extracted pseudo-article.
13510 (setq article 'pseudo)
13511 (gnus-request-pseudo-article header))))
13513 (let ((method (gnus-find-method-for-group
13514 gnus-newsgroup-name)))
13515 (if (not (eq (car method) 'nneething))
13517 (let ((dir (concat (file-name-as-directory (nth 1 method))
13518 (mail-header-subject header))))
13519 (if (file-directory-p dir)
13521 (setq article 'nneething)
13522 (gnus-group-enter-directory dir)))))))))
13525 ;; Refuse to select canceled articles.
13526 ((and (numberp article)
13527 gnus-summary-buffer
13528 (get-buffer gnus-summary-buffer)
13529 (buffer-name (get-buffer gnus-summary-buffer))
13530 (eq (cdr (save-excursion
13531 (set-buffer gnus-summary-buffer)
13532 (assq article gnus-newsgroup-reads)))
13533 gnus-canceled-mark))
13535 ;; We first check `gnus-original-article-buffer'.
13536 ((and (get-buffer gnus-original-article-buffer)
13539 (set-buffer gnus-original-article-buffer)
13540 (and (equal (car gnus-original-article) group)
13541 (eq (cdr gnus-original-article) article))))
13542 (insert-buffer-substring gnus-original-article-buffer)
13544 ;; Check the backlog.
13545 ((and gnus-keep-backlog
13546 (gnus-backlog-request-article group article (current-buffer)))
13548 ;; Check the cache.
13549 ((and gnus-use-cache
13551 (gnus-cache-request-article article group))
13553 ;; Get the article and put into the article buffer.
13554 ((or (stringp article) (numberp article))
13555 (let ((gnus-override-method
13556 (and (stringp article) gnus-refer-article-method))
13557 (buffer-read-only nil))
13559 (gnus-kill-all-overlays)
13560 (if (gnus-request-article article group (current-buffer))
13562 (and gnus-keep-backlog
13564 (gnus-backlog-enter-article
13565 group article (current-buffer)))
13567 ;; It was a pseudo.
13570 ;; Take the article from the original article buffer
13571 ;; and place it in the buffer it's supposed to be in.
13572 (when (and (get-buffer gnus-article-buffer)
13573 ;;(numberp article)
13574 (equal (buffer-name (current-buffer))
13575 (buffer-name (get-buffer gnus-article-buffer))))
13577 (if (get-buffer gnus-original-article-buffer)
13578 (set-buffer (get-buffer gnus-original-article-buffer))
13579 (set-buffer (get-buffer-create gnus-original-article-buffer))
13580 (buffer-disable-undo (current-buffer))
13581 (setq major-mode 'gnus-original-article-mode)
13582 (setq buffer-read-only t)
13583 (gnus-add-current-to-buffer-list))
13584 (let (buffer-read-only)
13586 (insert-buffer-substring gnus-article-buffer))
13587 (setq gnus-original-article (cons group article))))
13589 ;; Update sparse articles.
13590 (when (and do-update-line
13591 (or (numberp article)
13592 (stringp article)))
13593 (let ((buf (current-buffer)))
13594 (set-buffer gnus-summary-buffer)
13595 (gnus-summary-update-article do-update-line)
13596 (gnus-summary-goto-subject do-update-line nil t)
13597 (set-window-point (get-buffer-window (current-buffer) t)
13599 (set-buffer buf))))))
13601 (defun gnus-read-header (id &optional header)
13602 "Read the headers of article ID and enter them into the Gnus system."
13603 (let ((group gnus-newsgroup-name)
13604 (gnus-override-method
13605 (and (gnus-news-group-p gnus-newsgroup-name)
13606 gnus-refer-article-method))
13608 ;; First we check to see whether the header in question is already
13611 ;; This is a Message-ID.
13612 (setq header (or header (gnus-id-to-header id)))
13613 ;; This is an article number.
13614 (setq header (or header (gnus-summary-article-header id))))
13616 (not (memq (mail-header-number header) gnus-newsgroup-sparse)))
13617 ;; We have found the header.
13619 ;; We have to really fetch the header to this article.
13621 (if (gnus-check-backend-function 'request-head group)
13622 (gnus-request-head id group)
13623 (gnus-request-article id group)))
13625 (set-buffer nntp-server-buffer)
13626 (and (search-forward "\n\n" nil t)
13627 (delete-region (1- (point)) (point-max)))
13628 (goto-char (point-max))
13630 (goto-char (point-min))
13634 ((cdr where) (cdr where))
13635 (header (mail-header-number header))
13636 (t gnus-reffed-article-number))
13638 (insert " Article retrieved.\n"))
13640 ; (memq (mail-header-number header) gnus-newsgroup-sparse))
13641 ; (setcar (gnus-id-to-thread id) nil))
13642 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13643 () ; Malformed head.
13644 (unless (memq (mail-header-number header) gnus-newsgroup-sparse)
13645 (if (and (stringp id)
13646 (not (string= (gnus-group-real-name group)
13648 ;; If we fetched by Message-ID and the article came
13649 ;; from a different group, we fudge some bogus article
13650 ;; numbers for this article.
13651 (mail-header-set-number header gnus-reffed-article-number))
13652 (decf gnus-reffed-article-number)
13653 (push header gnus-newsgroup-headers)
13654 (setq gnus-current-headers header)
13655 (push (mail-header-number header) gnus-newsgroup-limit))
13658 (defun gnus-article-prepare (article &optional all-headers header)
13659 "Prepare ARTICLE in article mode buffer.
13660 ARTICLE should either be an article number or a Message-ID.
13661 If ARTICLE is an id, HEADER should be the article headers.
13662 If ALL-HEADERS is non-nil, no headers are hidden."
13664 ;; Make sure we start in a summary buffer.
13665 (unless (eq major-mode 'gnus-summary-mode)
13666 (set-buffer gnus-summary-buffer))
13667 (setq gnus-summary-buffer (current-buffer))
13668 ;; Make sure the connection to the server is alive.
13669 (unless (gnus-server-opened
13670 (gnus-find-method-for-group gnus-newsgroup-name))
13671 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13672 (gnus-request-group gnus-newsgroup-name t))
13673 (let* ((article (if header (mail-header-number header) article))
13674 (summary-buffer (current-buffer))
13675 (internal-hook gnus-article-internal-prepare-hook)
13676 (group gnus-newsgroup-name)
13679 (gnus-article-setup-buffer)
13680 (set-buffer gnus-article-buffer)
13681 ;; Deactivate active regions.
13682 (when (and (boundp 'transient-mark-mode)
13683 transient-mark-mode)
13684 (setq mark-active nil))
13685 (if (not (setq result (let ((buffer-read-only nil))
13686 (gnus-request-article-this-buffer
13688 ;; There is no such article.
13690 (when (and (numberp article)
13691 (not (memq article gnus-newsgroup-sparse)))
13692 (setq gnus-article-current
13693 (cons gnus-newsgroup-name article))
13694 (set-buffer gnus-summary-buffer)
13695 (setq gnus-current-article article)
13696 (gnus-summary-mark-article article gnus-canceled-mark))
13697 (unless (memq article gnus-newsgroup-sparse)
13699 1 "No such article (may have expired or been canceled)")))
13700 (if (or (eq result 'pseudo) (eq result 'nneething))
13703 (set-buffer summary-buffer)
13704 (setq gnus-last-article gnus-current-article
13705 gnus-newsgroup-history (cons gnus-current-article
13706 gnus-newsgroup-history)
13707 gnus-current-article 0
13708 gnus-current-headers nil
13709 gnus-article-current nil)
13710 (if (eq result 'nneething)
13711 (gnus-configure-windows 'summary)
13712 (gnus-configure-windows 'article))
13713 (gnus-set-global-variables))
13714 (gnus-set-mode-line 'article))
13715 ;; The result from the `request' was an actual article -
13716 ;; or at least some text that is now displayed in the
13718 (if (and (numberp article)
13719 (not (eq article gnus-current-article)))
13720 ;; Seems like a new article has been selected.
13721 ;; `gnus-current-article' must be an article number.
13723 (set-buffer summary-buffer)
13724 (setq gnus-last-article gnus-current-article
13725 gnus-newsgroup-history (cons gnus-current-article
13726 gnus-newsgroup-history)
13727 gnus-current-article article
13728 gnus-current-headers
13729 (gnus-summary-article-header gnus-current-article)
13730 gnus-article-current
13731 (cons gnus-newsgroup-name gnus-current-article))
13732 (unless (vectorp gnus-current-headers)
13733 (setq gnus-current-headers nil))
13734 (gnus-summary-show-thread)
13735 (run-hooks 'gnus-mark-article-hook)
13736 (gnus-set-mode-line 'summary)
13737 (and (gnus-visual-p 'article-highlight 'highlight)
13738 (run-hooks 'gnus-visual-mark-article-hook))
13739 ;; Set the global newsgroup variables here.
13740 ;; Suggested by Jim Sisolak
13741 ;; <sisolak@trans4.neep.wisc.edu>.
13742 (gnus-set-global-variables)
13743 (setq gnus-have-all-headers
13744 (or all-headers gnus-show-all-headers))
13745 (and gnus-use-cache
13746 (vectorp (gnus-summary-article-header article))
13747 (gnus-cache-possibly-enter-article
13749 (gnus-summary-article-header article)
13750 (memq article gnus-newsgroup-marked)
13751 (memq article gnus-newsgroup-dormant)
13752 (memq article gnus-newsgroup-unreads)))))
13753 (when (or (numberp article)
13755 ;; Hooks for getting information from the article.
13756 ;; This hook must be called before being narrowed.
13757 (let (buffer-read-only)
13758 (run-hooks 'internal-hook)
13759 (run-hooks 'gnus-article-prepare-hook)
13760 ;; Decode MIME message.
13762 (if (or (not gnus-strict-mime)
13763 (gnus-fetch-field "Mime-Version"))
13764 (funcall gnus-show-mime-method)
13765 (funcall gnus-decode-encoded-word-method)))
13766 ;; Perform the article display hooks.
13767 (run-hooks 'gnus-article-display-hook))
13769 (goto-char (point-min))
13770 (and gnus-break-pages (gnus-narrow-to-page)))
13771 (gnus-set-mode-line 'article)
13772 (gnus-configure-windows 'article)
13773 (goto-char (point-min))
13776 (defun gnus-article-show-all-headers ()
13777 "Show all article headers in article mode buffer."
13779 (gnus-article-setup-buffer)
13780 (set-buffer gnus-article-buffer)
13781 (let ((buffer-read-only nil))
13782 (gnus-unhide-text (point-min) (point-max)))))
13784 (defun gnus-article-hide-headers-if-wanted ()
13785 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13786 Provided for backwards compatibility."
13787 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13788 gnus-inhibit-hiding
13789 (gnus-article-hide-headers)))
13791 (defsubst gnus-article-header-rank ()
13792 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13793 (let ((list gnus-sorted-header-list)
13796 (when (looking-at (car list))
13798 (setq list (cdr list))
13802 (defun gnus-article-hide-headers (&optional arg delete)
13803 "Toggle whether to hide unwanted headers and possibly sort them as well.
13804 If given a negative prefix, always show; if given a positive prefix,
13807 (unless (gnus-article-check-hidden-text 'headers arg)
13808 ;; This function might be inhibited.
13809 (unless gnus-inhibit-hiding
13811 (set-buffer gnus-article-buffer)
13813 (let ((buffer-read-only nil)
13814 (props (nconc (list 'gnus-type 'headers)
13815 gnus-hidden-properties))
13816 (max (1+ (length gnus-sorted-header-list)))
13817 (ignored (when (not (stringp gnus-visible-headers))
13818 (cond ((stringp gnus-ignored-headers)
13819 gnus-ignored-headers)
13820 ((listp gnus-ignored-headers)
13821 (mapconcat 'identity gnus-ignored-headers
13824 (cond ((stringp gnus-visible-headers)
13825 gnus-visible-headers)
13826 ((and gnus-visible-headers
13827 (listp gnus-visible-headers))
13828 (mapconcat 'identity gnus-visible-headers "\\|"))))
13830 ;; First we narrow to just the headers.
13832 (goto-char (point-min))
13833 ;; Hide any "From " lines at the beginning of (mail) articles.
13834 (while (looking-at "From ")
13837 (gnus-hide-text (point-min) (point) props))
13838 ;; Then treat the rest of the header lines.
13841 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13842 ;; Then we use the two regular expressions
13843 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13844 ;; select which header lines is to remain visible in the
13846 (goto-char (point-min))
13847 (while (re-search-forward "^[^ \t]*:" nil t)
13848 (beginning-of-line)
13849 ;; We add the headers we want to keep to a list and delete
13850 ;; them from the buffer.
13851 (gnus-put-text-property
13852 (point) (1+ (point)) 'message-rank
13853 (if (or (and visible (looking-at visible))
13855 (not (looking-at ignored))))
13856 (gnus-article-header-rank)
13859 (message-sort-headers-1)
13860 (when (setq beg (text-property-any
13861 (point-min) (point-max) 'message-rank (+ 2 max)))
13862 ;; We make the unwanted headers invisible.
13864 (delete-region beg (point-max))
13865 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13866 (gnus-hide-text-type beg (point-max) 'headers))
13867 ;; Work around XEmacs lossage.
13868 (gnus-put-text-property (point-min) beg 'invisible nil))))))))
13870 (defun gnus-article-hide-boring-headers (&optional arg)
13871 "Toggle hiding of headers that aren't very interesting.
13872 If given a negative prefix, always show; if given a positive prefix,
13875 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13877 (set-buffer gnus-article-buffer)
13879 (let ((buffer-read-only nil)
13880 (list gnus-boring-article-headers)
13881 (inhibit-point-motion-hooks t)
13883 (nnheader-narrow-to-headers)
13885 (setq elem (pop list))
13886 (goto-char (point-min))
13888 ;; Hide empty headers.
13890 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13892 (gnus-hide-text-type
13893 (progn (beginning-of-line) (point))
13896 (if (re-search-forward "^[^ \t]" nil t)
13897 (match-beginning 0)
13900 ;; Hide boring Newsgroups header.
13901 ((eq elem 'newsgroups)
13902 (when (equal (message-fetch-field "newsgroups")
13903 (gnus-group-real-name gnus-newsgroup-name))
13904 (gnus-article-hide-header "newsgroups")))
13905 ((eq elem 'followup-to)
13906 (when (equal (message-fetch-field "followup-to")
13907 (message-fetch-field "newsgroups"))
13908 (gnus-article-hide-header "followup-to")))
13909 ((eq elem 'reply-to)
13910 (let ((from (message-fetch-field "from"))
13911 (reply-to (message-fetch-field "reply-to")))
13915 (nth 1 (funcall gnus-extract-address-components from))
13916 (nth 1 (funcall gnus-extract-address-components
13918 (gnus-article-hide-header "reply-to"))))
13920 (let ((date (message-fetch-field "date")))
13922 (< (gnus-days-between date (current-time-string))
13924 (gnus-article-hide-header "date")))))))))))
13926 (defun gnus-article-hide-header (header)
13928 (goto-char (point-min))
13929 (when (re-search-forward (concat "^" header ":") nil t)
13930 (gnus-hide-text-type
13931 (progn (beginning-of-line) (point))
13934 (if (re-search-forward "^[^ \t]" nil t)
13935 (match-beginning 0)
13937 'boring-headers))))
13939 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
13940 (defun gnus-article-treat-overstrike ()
13941 "Translate overstrikes into bold text."
13944 (set-buffer gnus-article-buffer)
13945 (let ((buffer-read-only nil))
13946 (while (search-forward "\b" nil t)
13947 (let ((next (following-char))
13948 (previous (char-after (- (point) 2))))
13949 (cond ((eq next previous)
13950 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
13951 (gnus-put-text-property (point) (1+ (point)) 'face 'bold))
13953 (gnus-put-text-property (1- (point)) (1+ (point)) 'invisible t)
13954 (gnus-put-text-property
13955 (- (point) 2) (1- (point)) 'face 'underline))
13957 (gnus-put-text-property (- (point) 2) (point) 'invisible t)
13958 (gnus-put-text-property
13959 (point) (1+ (point)) 'face 'underline))))))))
13961 (defun gnus-article-word-wrap ()
13962 "Format too long lines."
13965 (set-buffer gnus-article-buffer)
13966 (let ((buffer-read-only nil))
13968 (goto-char (point-min))
13969 (search-forward "\n\n" nil t)
13971 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
13972 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
13973 (adaptive-fill-mode t))
13974 (while (not (eobp))
13975 (and (>= (current-column) (min fill-column (window-width)))
13976 (/= (preceding-char) ?:)
13977 (fill-paragraph nil))
13978 (end-of-line 2))))))
13980 (defun gnus-article-remove-cr ()
13981 "Remove carriage returns from an article."
13984 (set-buffer gnus-article-buffer)
13985 (let ((buffer-read-only nil))
13986 (goto-char (point-min))
13987 (while (search-forward "\r" nil t)
13988 (replace-match "" t t)))))
13990 (defun gnus-article-remove-trailing-blank-lines ()
13991 "Remove all trailing blank lines from the article."
13994 (set-buffer gnus-article-buffer)
13995 (let ((buffer-read-only nil))
13996 (goto-char (point-max))
14000 (while (looking-at "^[ \t]*$")
14005 (defun gnus-article-display-x-face (&optional force)
14006 "Look for an X-Face header and display it if present."
14007 (interactive (list 'force))
14009 (set-buffer gnus-article-buffer)
14010 ;; Delete the old process, if any.
14011 (when (process-status "gnus-x-face")
14012 (delete-process "gnus-x-face"))
14013 (let ((inhibit-point-motion-hooks t)
14014 (case-fold-search nil)
14017 (nnheader-narrow-to-headers)
14018 (setq from (message-fetch-field "from"))
14019 (goto-char (point-min))
14020 (when (and gnus-article-x-face-command
14022 ;; Check whether this face is censored.
14023 (not gnus-article-x-face-too-ugly)
14024 (and gnus-article-x-face-too-ugly from
14025 (not (string-match gnus-article-x-face-too-ugly
14027 ;; Has to be present.
14028 (re-search-forward "^X-Face: " nil t))
14029 ;; We now have the area of the buffer where the X-Face is stored.
14030 (let ((beg (point))
14031 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
14032 ;; We display the face.
14033 (if (symbolp gnus-article-x-face-command)
14034 ;; The command is a lisp function, so we call it.
14035 (if (gnus-functionp gnus-article-x-face-command)
14036 (funcall gnus-article-x-face-command beg end)
14037 (error "%s is not a function" gnus-article-x-face-command))
14038 ;; The command is a string, so we interpret the command
14039 ;; as a, well, command, and fork it off.
14040 (let ((process-connection-type nil))
14041 (process-kill-without-query
14043 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
14044 (process-send-region "gnus-x-face" beg end)
14045 (process-send-eof "gnus-x-face")))))))))
14047 (defalias 'gnus-header-decode-quoted-printable 'gnus-decode-rfc1522)
14048 (defun gnus-decode-rfc1522 ()
14049 "Hack to remove QP encoding from headers."
14050 (let ((case-fold-search t)
14051 (inhibit-point-motion-hooks t)
14052 (buffer-read-only nil)
14056 (goto-char (point-min))
14057 (or (search-forward "\n\n" nil t) (point-max)))
14059 (while (re-search-forward
14060 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
14061 (setq string (match-string 1))
14062 (narrow-to-region (match-beginning 0) (match-end 0))
14063 (delete-region (point-min) (point-max))
14065 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
14066 (subst-char-in-region (point-min) (point-max) ?_ ? )
14068 (goto-char (point-min))))))
14070 (defun gnus-article-de-quoted-unreadable (&optional force)
14071 "Do a naive translation of a quoted-printable-encoded article.
14072 This is in no way, shape or form meant as a replacement for real MIME
14073 processing, but is simply a stop-gap measure until MIME support is
14075 If FORCE, decode the article whether it is marked as quoted-printable
14077 (interactive (list 'force))
14079 (set-buffer gnus-article-buffer)
14080 (let ((case-fold-search t)
14081 (buffer-read-only nil)
14082 (type (gnus-fetch-field "content-transfer-encoding")))
14083 (gnus-decode-rfc1522)
14085 (and type (string-match "quoted-printable" (downcase type))))
14086 (goto-char (point-min))
14087 (search-forward "\n\n" nil 'move)
14088 (gnus-mime-decode-quoted-printable (point) (point-max))))))
14090 (defun gnus-mime-decode-quoted-printable (from to)
14091 "Decode Quoted-Printable in the region between FROM and TO."
14094 (while (search-forward "=" to t)
14095 (cond ((eq (following-char) ?\n)
14098 ((looking-at "[0-9A-F][0-9A-F]")
14099 (subst-char-in-region
14100 (1- (point)) (point) ?=
14101 (hexl-hex-string-to-integer
14102 (buffer-substring (point) (+ 2 (point)))))
14106 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
14108 (defun gnus-article-hide-pgp (&optional arg)
14109 "Toggle hiding of any PGP headers and signatures in the current article.
14110 If given a negative prefix, always show; if given a positive prefix,
14113 (unless (gnus-article-check-hidden-text 'pgp arg)
14115 (set-buffer gnus-article-buffer)
14116 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
14117 buffer-read-only beg end)
14119 (goto-char (point-min))
14120 ;; Hide the "header".
14121 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
14122 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14124 ;; Hide the actual signature.
14125 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
14126 (setq end (1+ (match-beginning 0)))
14129 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
14131 ;; Perhaps we shouldn't hide to the end of the buffer
14132 ;; if there is no end to the signature?
14135 ;; Hide "- " PGP quotation markers.
14136 (when (and beg end)
14137 (narrow-to-region beg end)
14138 (goto-char (point-min))
14139 (while (re-search-forward "^- " nil t)
14140 (gnus-hide-text (match-beginning 0) (match-end 0) props))
14143 (defun gnus-article-hide-signature (&optional arg)
14144 "Hide the signature in the current article.
14145 If given a negative prefix, always show; if given a positive prefix,
14148 (unless (gnus-article-check-hidden-text 'signature arg)
14150 (set-buffer gnus-article-buffer)
14152 (let ((buffer-read-only nil))
14153 (when (gnus-narrow-to-signature)
14154 (gnus-hide-text-type (point-min) (point-max) 'signature)))))))
14156 (defun gnus-article-strip-leading-blank-lines ()
14157 "Remove all blank lines from the beginning of the article."
14160 (set-buffer gnus-article-buffer)
14161 (let (buffer-read-only)
14162 (goto-char (point-min))
14163 (when (search-forward "\n\n" nil t)
14164 (while (looking-at "[ \t]$")
14165 (gnus-delete-line))))))
14167 (defvar mime::preview/content-list)
14168 (defvar mime::preview-content-info/point-min)
14169 (defun gnus-narrow-to-signature ()
14170 "Narrow to the signature."
14172 (if (and (boundp 'mime::preview/content-list)
14173 mime::preview/content-list)
14174 (let ((pcinfo (car (last mime::preview/content-list))))
14176 (funcall (intern "mime::preview-content-info/point-min") pcinfo)
14179 (goto-char (point-max))
14180 (when (re-search-backward gnus-signature-separator nil t)
14182 (when (or (null gnus-signature-limit)
14183 (and (numberp gnus-signature-limit)
14184 (< (- (point-max) (point)) gnus-signature-limit))
14185 (and (gnus-functionp gnus-signature-limit)
14186 (funcall gnus-signature-limit))
14187 (and (stringp gnus-signature-limit)
14188 (not (re-search-forward gnus-signature-limit nil t))))
14189 (narrow-to-region (point) (point-max))
14192 (defun gnus-article-check-hidden-text (type arg)
14193 "Return nil if hiding is necessary."
14195 (set-buffer gnus-article-buffer)
14196 (let ((hide (gnus-article-hidden-text-p type)))
14197 (cond ((or (and (null arg) (eq hide 'hidden))
14198 (and arg (< 0 (prefix-numeric-value arg))))
14199 (gnus-article-show-hidden-text type))
14201 (gnus-article-show-hidden-text type t))
14204 (defun gnus-article-hidden-text-p (type)
14205 "Say whether the current buffer contains hidden text of type TYPE."
14206 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type)))
14208 (if (get-text-property pos 'invisible)
14212 (defun gnus-article-hide (&optional arg force)
14213 "Hide all the gruft in the current article.
14214 This means that PGP stuff, signatures, cited text and (some)
14215 headers will be hidden.
14216 If given a prefix, show the hidden text instead."
14217 (interactive (list current-prefix-arg 'force))
14218 (gnus-article-hide-headers arg)
14219 (gnus-article-hide-pgp arg)
14220 (gnus-article-hide-citation-maybe arg force)
14221 (gnus-article-hide-signature arg))
14223 (defun gnus-article-show-hidden-text (type &optional hide)
14224 "Show all hidden text of type TYPE.
14225 If HIDE, hide the text instead."
14227 (set-buffer gnus-article-buffer)
14228 (let ((buffer-read-only nil)
14229 (inhibit-point-motion-hooks t)
14231 (while (gnus-goto-char (text-property-any
14232 beg (point-max) 'gnus-type type))
14236 (gnus-hide-text beg (point) gnus-hidden-properties)
14237 (gnus-unhide-text beg (point)))
14238 (setq beg (point)))
14241 (defvar gnus-article-time-units
14242 `((year . ,(* 365.25 24 60 60))
14243 (week . ,(* 7 24 60 60))
14244 (day . ,(* 24 60 60))
14245 (hour . ,(* 60 60))
14248 "Mapping from time units to seconds.")
14250 (defun gnus-article-date-ut (&optional type highlight)
14251 "Convert DATE date to universal time in the current article.
14252 If TYPE is `local', convert to local time; if it is `lapsed', output
14253 how much time has lapsed since DATE."
14254 (interactive (list 'ut t))
14255 (let* ((header (or gnus-current-headers
14256 (gnus-summary-article-header) ""))
14257 (date (and (vectorp header) (mail-header-date header)))
14258 (date-regexp "^Date: \\|^X-Sent: ")
14259 (now (current-time))
14260 (inhibit-point-motion-hooks t)
14262 (when (and date (not (string= date "")))
14264 (set-buffer gnus-article-buffer)
14266 (nnheader-narrow-to-headers)
14267 (let ((buffer-read-only nil))
14268 ;; Delete any old Date headers.
14269 (if (re-search-forward date-regexp nil t)
14271 (setq bface (get-text-property (gnus-point-at-bol) 'face)
14272 eface (get-text-property (1- (gnus-point-at-eol))
14274 (message-remove-header date-regexp t)
14275 (beginning-of-line))
14276 (goto-char (point-max)))
14277 (insert (gnus-make-date-line date type))
14278 ;; Do highlighting.
14280 (when (and (gnus-visual-p 'article-highlight 'highlight)
14281 (looking-at "\\([^:]+\\): *\\(.*\\)$"))
14282 (gnus-put-text-property (match-beginning 1) (match-end 1)
14284 (gnus-put-text-property (match-beginning 2) (match-end 2)
14285 'face eface))))))))
14287 (defun gnus-make-date-line (date type)
14288 "Return a DATE line of TYPE."
14290 ;; Convert to the local timezone. We have to slap a
14291 ;; `condition-case' round the calls to the timezone
14292 ;; functions since they aren't particularly resistant to
14295 (concat "Date: " (condition-case ()
14296 (timezone-make-date-arpa-standard date)
14299 ;; Convert to Universal Time.
14303 (timezone-make-date-arpa-standard date nil "UT")
14306 ;; Get the original date from the article.
14307 ((eq type 'original)
14308 (concat "Date: " date "\n"))
14309 ;; Do an X-Sent lapsed format.
14311 ;; If the date is seriously mangled, the timezone
14312 ;; functions are liable to bug out, so we condition-case
14313 ;; the entire thing.
14314 (let* ((now (current-time))
14319 (timezone-make-date-arpa-standard
14320 (current-time-string now)
14321 (current-time-zone now) "UT"))
14323 (timezone-make-date-arpa-standard
14326 (real-sec (+ (* (float (car real-time)) 65536)
14328 (sec (abs real-sec))
14331 ((equal real-time '(0 0))
14332 "X-Sent: Unknown\n")
14338 ;; This is a bit convoluted, but basically we go
14339 ;; through the time units for years, weeks, etc,
14340 ;; and divide things to see whether that results
14341 ;; in positive answers.
14344 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
14345 ;; The (remaining) seconds are too few to
14346 ;; be divided into this time unit.
14348 ;; It's big enough, so we output it.
14349 (setq sec (- sec (* num (cdr unit))))
14351 (concat (if prev ", " "") (int-to-string
14353 " " (symbol-name (car unit))
14354 (if (> num 1) "s" ""))
14356 gnus-article-time-units "")
14357 ;; If dates are odd, then it might appear like the
14358 ;; article was sent in the future.
14361 " in the future\n"))))))
14363 (error "Unknown conversion type: %s" type))))
14365 (defun gnus-article-date-local (&optional highlight)
14366 "Convert the current article date to the local timezone."
14367 (interactive (list t))
14368 (gnus-article-date-ut 'local highlight))
14370 (defun gnus-article-date-original (&optional highlight)
14371 "Convert the current article date to what it was originally.
14372 This is only useful if you have used some other date conversion
14373 function and want to see what the date was before converting."
14374 (interactive (list t))
14375 (gnus-article-date-ut 'original highlight))
14377 (defun gnus-article-date-lapsed (&optional highlight)
14378 "Convert the current article date to time lapsed since it was sent."
14379 (interactive (list t))
14380 (gnus-article-date-ut 'lapsed highlight))
14382 (defun gnus-article-maybe-highlight ()
14383 "Do some article highlighting if `gnus-visual' is non-nil."
14384 (if (gnus-visual-p 'article-highlight 'highlight)
14385 (gnus-article-highlight-some)))
14389 (defun gnus-output-to-rmail (file-name)
14390 "Append the current article to an Rmail file named FILE-NAME."
14392 ;; Most of these codes are borrowed from rmailout.el.
14393 (setq file-name (expand-file-name file-name))
14394 (setq rmail-default-rmail-file file-name)
14395 (let ((artbuf (current-buffer))
14396 (tmpbuf (get-buffer-create " *Gnus-output*")))
14398 (or (get-file-buffer file-name)
14399 (file-exists-p file-name)
14400 (if (gnus-yes-or-no-p
14401 (concat "\"" file-name "\" does not exist, create it? "))
14402 (let ((file-buffer (create-file-buffer file-name)))
14404 (set-buffer file-buffer)
14405 (rmail-insert-rmail-file-header)
14406 (let ((require-final-newline nil))
14407 (write-region (point-min) (point-max) file-name t 1)))
14408 (kill-buffer file-buffer))
14409 (error "Output file does not exist")))
14410 (set-buffer tmpbuf)
14411 (buffer-disable-undo (current-buffer))
14413 (insert-buffer-substring artbuf)
14414 (gnus-convert-article-to-rmail)
14415 ;; Decide whether to append to a file or to an Emacs buffer.
14416 (let ((outbuf (get-file-buffer file-name)))
14418 (append-to-file (point-min) (point-max) file-name)
14419 ;; File has been visited, in buffer OUTBUF.
14420 (set-buffer outbuf)
14421 (let ((buffer-read-only nil)
14422 (msg (and (boundp 'rmail-current-message)
14423 (symbol-value 'rmail-current-message))))
14424 ;; If MSG is non-nil, buffer is in RMAIL mode.
14427 (narrow-to-region (point-max) (point-max))))
14428 (insert-buffer-substring tmpbuf)
14431 (goto-char (point-min))
14433 (search-backward "\^_")
14434 (narrow-to-region (point) (point-max))
14435 (goto-char (1+ (point-min)))
14436 (rmail-count-new-messages t)
14437 (rmail-show-message msg)))))))
14438 (kill-buffer tmpbuf)))
14440 (defun gnus-output-to-file (file-name)
14441 "Append the current article to a file named FILE-NAME."
14442 (setq file-name (expand-file-name file-name))
14443 (let ((artbuf (current-buffer))
14444 (tmpbuf (get-buffer-create " *Gnus-output*")))
14446 (set-buffer tmpbuf)
14447 (buffer-disable-undo (current-buffer))
14449 (insert-buffer-substring artbuf)
14450 ;; Append newline at end of the buffer as separator, and then
14451 ;; save it to file.
14452 (goto-char (point-max))
14454 (append-to-file (point-min) (point-max) file-name))
14455 (kill-buffer tmpbuf)))
14457 (defun gnus-convert-article-to-rmail ()
14458 "Convert article in current buffer to Rmail message format."
14459 (let ((buffer-read-only nil))
14460 ;; Convert article directly into Babyl format.
14461 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14462 (goto-char (point-min))
14463 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14464 (while (search-forward "\n\^_" nil t) ;single char
14465 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14466 (goto-char (point-max))
14469 (defun gnus-narrow-to-page (&optional arg)
14470 "Narrow the article buffer to a page.
14471 If given a numerical ARG, move forward ARG pages."
14473 (setq arg (if arg (prefix-numeric-value arg) 0))
14475 (set-buffer gnus-article-buffer)
14476 (goto-char (point-min))
14478 (when (gnus-visual-p 'page-marker)
14479 (let ((buffer-read-only nil))
14480 (gnus-remove-text-with-property 'gnus-prev)
14481 (gnus-remove-text-with-property 'gnus-next)))
14484 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14486 (re-search-forward page-delimiter nil 'move arg)))
14487 (goto-char (match-end 0)))
14490 (if (re-search-forward page-delimiter nil 'move)
14491 (match-beginning 0)
14493 (when (and (gnus-visual-p 'page-marker)
14494 (not (= (point-min) 1)))
14496 (goto-char (point-min))
14497 (gnus-insert-prev-page-button)))
14498 (when (and (gnus-visual-p 'page-marker)
14499 (not (= (1- (point-max)) (buffer-size))))
14501 (goto-char (point-max))
14502 (gnus-insert-next-page-button)))))
14504 ;; Article mode commands
14506 (defun gnus-article-goto-next-page ()
14507 "Show the next page of the article."
14509 (when (gnus-article-next-page)
14510 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
14512 (defun gnus-article-goto-prev-page ()
14513 "Show the next page of the article."
14515 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))
14516 (gnus-article-prev-page nil)))
14518 (defun gnus-article-next-page (&optional lines)
14519 "Show the next page of the current article.
14520 If end of article, return non-nil. Otherwise return nil.
14521 Argument LINES specifies lines to be scrolled up."
14523 (move-to-window-line -1)
14524 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14525 (if (save-excursion
14527 (and (pos-visible-in-window-p) ;Not continuation line.
14529 ;; Nothing in this page.
14530 (if (or (not gnus-break-pages)
14533 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14535 (gnus-narrow-to-page 1) ;Go to next page.
14537 ;; More in this page.
14541 ;; Long lines may cause an end-of-buffer error.
14542 (goto-char (point-max))))
14543 (move-to-window-line 0)
14546 (defun gnus-article-prev-page (&optional lines)
14547 "Show previous page of current article.
14548 Argument LINES specifies lines to be scrolled down."
14550 (move-to-window-line 0)
14551 (if (and gnus-break-pages
14553 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14555 (gnus-narrow-to-page -1) ;Go to previous page.
14556 (goto-char (point-max))
14560 (scroll-down lines)
14562 (move-to-window-line 0))))
14564 (defun gnus-article-refer-article ()
14565 "Read article specified by message-id around point."
14567 (let ((point (point)))
14568 (search-forward ">" nil t) ;Move point to end of "<....>".
14569 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14570 (let ((message-id (match-string 1)))
14572 (set-buffer gnus-summary-buffer)
14573 (gnus-summary-refer-article message-id))
14574 (goto-char (point))
14575 (error "No references around point"))))
14577 (defun gnus-article-show-summary ()
14578 "Reconfigure windows to show summary buffer."
14580 (gnus-configure-windows 'article)
14581 (gnus-summary-goto-subject gnus-current-article))
14583 (defun gnus-article-describe-briefly ()
14584 "Describe article mode commands briefly."
14587 (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")))
14589 (defun gnus-article-summary-command ()
14590 "Execute the last keystroke in the summary buffer."
14592 (let ((obuf (current-buffer))
14593 (owin (current-window-configuration))
14595 (switch-to-buffer gnus-summary-buffer 'norecord)
14596 (setq func (lookup-key (current-local-map) (this-command-keys)))
14597 (call-interactively func)
14599 (set-window-configuration owin)
14600 (set-window-point (get-buffer-window (current-buffer)) (point))))
14602 (defun gnus-article-summary-command-nosave ()
14603 "Execute the last keystroke in the summary buffer."
14606 (pop-to-buffer gnus-summary-buffer 'norecord)
14607 (setq func (lookup-key (current-local-map) (this-command-keys)))
14608 (call-interactively func)))
14610 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14611 "Read a summary buffer key sequence and execute it from the article buffer."
14614 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14615 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14619 (set-buffer gnus-summary-buffer)
14620 (push (or key last-command-event) unread-command-events)
14621 (setq keys (read-key-sequence nil)))
14624 (if (member keys nosaves)
14626 (pop-to-buffer gnus-summary-buffer 'norecord)
14627 (if (setq func (lookup-key (current-local-map) keys))
14628 (call-interactively func)
14630 (let ((obuf (current-buffer))
14631 (owin (current-window-configuration))
14634 (if not-restore-window
14635 (pop-to-buffer gnus-summary-buffer 'norecord)
14636 (switch-to-buffer gnus-summary-buffer 'norecord))
14637 (setq in-buffer (current-buffer))
14638 (if (setq func (lookup-key (current-local-map) keys))
14639 (call-interactively func)
14641 (when (eq in-buffer (current-buffer))
14643 (unless not-restore-window
14644 (set-window-configuration owin))
14645 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14649 ;;; Kill file handling.
14653 (defalias 'gnus-batch-kill 'gnus-batch-score)
14655 (defun gnus-batch-score ()
14656 "Run batched scoring.
14657 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14658 Newsgroups is a list of strings in Bnews format. If you want to score
14659 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14660 score the alt hierarchy, you'd say \"!alt.all\"."
14663 (gnus-newsrc-parse-options
14664 (apply (function concat)
14665 (mapcar (lambda (g) (concat g " "))
14666 command-line-args-left))))
14667 (gnus-expert-user t)
14668 (nnmail-spool-file nil)
14669 (gnus-use-dribble-file nil)
14670 (yes (car yes-and-no))
14671 (no (cdr yes-and-no))
14673 ;; Disable verbose message.
14674 gnus-novice-user gnus-large-newsgroup)
14675 ;; Eat all arguments.
14676 (setq command-line-args-left nil)
14679 ;; Apply kills to specified newsgroups in command line arguments.
14680 (setq newsrc (cdr gnus-newsrc-alist))
14682 (setq group (caar newsrc))
14683 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14684 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14686 (or (eq (car entry) t)
14687 (not (zerop (car entry)))))
14688 (if yes (string-match yes group) t)
14689 (or (null no) (not (string-match no group))))
14691 (gnus-summary-read-group group nil t nil t)
14692 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14693 (gnus-summary-exit))))
14694 (setq newsrc (cdr newsrc)))
14696 (switch-to-buffer gnus-group-buffer)
14697 (gnus-group-save-newsrc)))
14699 (defun gnus-apply-kill-file ()
14700 "Apply a kill file to the current newsgroup.
14701 Returns the number of articles marked as read."
14702 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14703 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14704 (gnus-apply-kill-file-internal)
14707 (defun gnus-kill-save-kill-buffer ()
14708 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14709 (when (get-file-buffer file)
14711 (set-buffer (get-file-buffer file))
14712 (and (buffer-modified-p) (save-buffer))
14713 (kill-buffer (current-buffer))))))
14715 (defvar gnus-kill-file-name "KILL"
14716 "Suffix of the kill files.")
14718 (defun gnus-newsgroup-kill-file (newsgroup)
14719 "Return the name of a kill file name for NEWSGROUP.
14720 If NEWSGROUP is nil, return the global kill file name instead."
14722 ;; The global KILL file is placed at top of the directory.
14723 ((or (null newsgroup)
14724 (string-equal newsgroup ""))
14725 (expand-file-name gnus-kill-file-name
14726 gnus-kill-files-directory))
14727 ;; Append ".KILL" to newsgroup name.
14728 ((gnus-use-long-file-name 'not-kill)
14729 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14730 "." gnus-kill-file-name)
14731 gnus-kill-files-directory))
14732 ;; Place "KILL" under the hierarchical directory.
14734 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14735 "/" gnus-kill-file-name)
14736 gnus-kill-files-directory))))
14743 (defvar gnus-dribble-ignore nil)
14744 (defvar gnus-dribble-eval-file nil)
14746 (defun gnus-dribble-file-name ()
14747 "Return the dribble file for the current .newsrc."
14749 (if gnus-dribble-directory
14750 (concat (file-name-as-directory gnus-dribble-directory)
14751 (file-name-nondirectory gnus-current-startup-file))
14752 gnus-current-startup-file)
14755 (defun gnus-dribble-enter (string)
14756 "Enter STRING into the dribble buffer."
14757 (if (and (not gnus-dribble-ignore)
14758 gnus-dribble-buffer
14759 (buffer-name gnus-dribble-buffer))
14760 (let ((obuf (current-buffer)))
14761 (set-buffer gnus-dribble-buffer)
14762 (insert string "\n")
14763 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14764 (set-buffer obuf))))
14766 (defun gnus-dribble-read-file ()
14767 "Read the dribble file from disk."
14768 (let ((dribble-file (gnus-dribble-file-name)))
14770 (set-buffer (setq gnus-dribble-buffer
14772 (file-name-nondirectory dribble-file))))
14773 (gnus-add-current-to-buffer-list)
14775 (setq buffer-file-name dribble-file)
14777 (buffer-disable-undo (current-buffer))
14778 (bury-buffer (current-buffer))
14779 (set-buffer-modified-p nil)
14780 (let ((auto (make-auto-save-file-name))
14781 (gnus-dribble-ignore t)
14783 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14784 ;; Load whichever file is newest -- the auto save file
14785 ;; or the "real" file.
14786 (if (file-newer-than-file-p auto dribble-file)
14787 (insert-file-contents auto)
14788 (insert-file-contents dribble-file))
14789 (unless (zerop (buffer-size))
14790 (set-buffer-modified-p t))
14791 ;; Set the file modes to reflect the .newsrc file modes.
14793 (when (and (file-exists-p gnus-current-startup-file)
14794 (setq modes (file-modes gnus-current-startup-file)))
14795 (set-file-modes dribble-file modes))
14796 ;; Possibly eval the file later.
14797 (when (gnus-y-or-n-p
14798 "Auto-save file exists. Do you want to read it? ")
14799 (setq gnus-dribble-eval-file t)))))))
14801 (defun gnus-dribble-eval-file ()
14802 (when gnus-dribble-eval-file
14803 (setq gnus-dribble-eval-file nil)
14805 (let ((gnus-dribble-ignore t))
14806 (set-buffer gnus-dribble-buffer)
14807 (eval-buffer (current-buffer))))))
14809 (defun gnus-dribble-delete-file ()
14810 (when (file-exists-p (gnus-dribble-file-name))
14811 (delete-file (gnus-dribble-file-name)))
14812 (when gnus-dribble-buffer
14814 (set-buffer gnus-dribble-buffer)
14815 (let ((auto (make-auto-save-file-name)))
14816 (if (file-exists-p auto)
14817 (delete-file auto))
14819 (set-buffer-modified-p nil)))))
14821 (defun gnus-dribble-save ()
14822 (when (and gnus-dribble-buffer
14823 (buffer-name gnus-dribble-buffer))
14825 (set-buffer gnus-dribble-buffer)
14828 (defun gnus-dribble-clear ()
14829 (when (gnus-buffer-exists-p gnus-dribble-buffer)
14831 (set-buffer gnus-dribble-buffer)
14833 (set-buffer-modified-p nil)
14834 (setq buffer-saved-size (buffer-size)))))
14838 ;;; Server Communication
14841 (defun gnus-start-news-server (&optional confirm)
14842 "Open a method for getting news.
14843 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14845 (if gnus-current-select-method
14846 ;; Stream is already opened.
14848 ;; Open NNTP server.
14849 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14852 ;; Read server name with completion.
14853 (setq gnus-nntp-server
14854 (completing-read "NNTP server: "
14855 (mapcar (lambda (server) (list server))
14856 (cons (list gnus-nntp-server)
14857 gnus-secondary-servers))
14858 nil nil gnus-nntp-server))))
14860 (if (and gnus-nntp-server
14861 (stringp gnus-nntp-server)
14862 (not (string= gnus-nntp-server "")))
14863 (setq gnus-select-method
14864 (cond ((or (string= gnus-nntp-server "")
14865 (string= gnus-nntp-server "::"))
14866 (list 'nnspool (system-name)))
14867 ((string-match "^:" gnus-nntp-server)
14868 (list 'nnmh gnus-nntp-server
14869 (list 'nnmh-directory
14870 (file-name-as-directory
14872 (concat "~/" (substring
14873 gnus-nntp-server 1)))))
14874 (list 'nnmh-get-new-mail nil)))
14876 (list 'nntp gnus-nntp-server)))))
14878 (setq how (car gnus-select-method))
14879 (cond ((eq how 'nnspool)
14881 (gnus-message 5 "Looking up local news spool..."))
14884 (gnus-message 5 "Looking up mh spool..."))
14887 (setq gnus-current-select-method gnus-select-method)
14888 (run-hooks 'gnus-open-server-hook)
14890 ;; gnus-open-server-hook might have opened it
14891 (gnus-server-opened gnus-select-method)
14892 (gnus-open-server gnus-select-method)
14895 "%s (%s) open error: '%s'. Continue? "
14896 (car gnus-select-method) (cadr gnus-select-method)
14897 (gnus-status-message gnus-select-method)))
14898 (gnus-error 1 "Couldn't open server on %s"
14899 (nth 1 gnus-select-method))))))
14901 (defun gnus-check-group (group)
14902 "Try to make sure that the server where GROUP exists is alive."
14903 (let ((method (gnus-find-method-for-group group)))
14904 (or (gnus-server-opened method)
14905 (gnus-open-server method))))
14907 (defun gnus-check-server (&optional method silent)
14908 "Check whether the connection to METHOD is down.
14909 If METHOD is nil, use `gnus-select-method'.
14910 If it is down, start it up (again)."
14911 (let ((method (or method gnus-select-method)))
14912 ;; Transform virtual server names into select methods.
14913 (when (stringp method)
14914 (setq method (gnus-server-to-method method)))
14915 (if (gnus-server-opened method)
14916 ;; The stream is already opened.
14918 ;; Open the server.
14920 (gnus-message 5 "Opening %s server%s..." (car method)
14921 (if (equal (nth 1 method) "") ""
14922 (format " on %s" (nth 1 method)))))
14923 (run-hooks 'gnus-open-server-hook)
14925 (gnus-open-server method)
14929 (defun gnus-get-function (method function)
14930 "Return a function symbol based on METHOD and FUNCTION."
14931 ;; Translate server names into methods.
14933 (error "Attempted use of a nil select method"))
14934 (when (stringp method)
14935 (setq method (gnus-server-to-method method)))
14936 (let ((func (intern (format "%s-%s" (car method) function))))
14937 ;; If the functions isn't bound, we require the backend in
14939 (unless (fboundp func)
14940 (require (car method))
14941 (unless (fboundp func)
14942 ;; This backend doesn't implement this function.
14943 (error "No such function: %s" func)))
14948 ;;; Interface functions to the backends.
14951 (defun gnus-open-server (method)
14952 "Open a connection to METHOD."
14953 (when (stringp method)
14954 (setq method (gnus-server-to-method method)))
14955 (let ((elem (assoc method gnus-opened-servers)))
14956 ;; If this method was previously denied, we just return nil.
14957 (if (eq (nth 1 elem) 'denied)
14959 (gnus-message 1 "Denied server")
14961 ;; Open the server.
14963 (funcall (gnus-get-function method 'open-server)
14964 (nth 1 method) (nthcdr 2 method))))
14965 ;; If this hasn't been opened before, we add it to the list.
14967 (setq elem (list method nil)
14968 gnus-opened-servers (cons elem gnus-opened-servers)))
14969 ;; Set the status of this server.
14970 (setcar (cdr elem) (if result 'ok 'denied))
14971 ;; Return the result from the "open" call.
14974 (defun gnus-close-server (method)
14975 "Close the connection to METHOD."
14976 (when (stringp method)
14977 (setq method (gnus-server-to-method method)))
14978 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
14980 (defun gnus-request-list (method)
14981 "Request the active file from METHOD."
14982 (when (stringp method)
14983 (setq method (gnus-server-to-method method)))
14984 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
14986 (defun gnus-request-list-newsgroups (method)
14987 "Request the newsgroups file from METHOD."
14988 (when (stringp method)
14989 (setq method (gnus-server-to-method method)))
14990 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
14992 (defun gnus-request-newgroups (date method)
14993 "Request all new groups since DATE from METHOD."
14994 (when (stringp method)
14995 (setq method (gnus-server-to-method method)))
14996 (funcall (gnus-get-function method 'request-newgroups)
14997 date (nth 1 method)))
14999 (defun gnus-server-opened (method)
15000 "Check whether a connection to METHOD has been opened."
15001 (when (stringp method)
15002 (setq method (gnus-server-to-method method)))
15003 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
15005 (defun gnus-status-message (method)
15006 "Return the status message from METHOD.
15007 If METHOD is a string, it is interpreted as a group name. The method
15008 this group uses will be queried."
15009 (let ((method (if (stringp method) (gnus-find-method-for-group method)
15011 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
15013 (defun gnus-request-group (group &optional dont-check method)
15014 "Request GROUP. If DONT-CHECK, no information is required."
15015 (let ((method (or method (gnus-find-method-for-group group))))
15016 (when (stringp method)
15017 (setq method (gnus-server-to-method method)))
15018 (funcall (gnus-get-function method 'request-group)
15019 (gnus-group-real-name group) (nth 1 method) dont-check)))
15021 (defun gnus-request-asynchronous (group &optional articles)
15022 "Request that GROUP behave asynchronously.
15023 ARTICLES is the `data' of the group."
15024 (let ((method (gnus-find-method-for-group group)))
15025 (funcall (gnus-get-function method 'request-asynchronous)
15026 (gnus-group-real-name group) (nth 1 method) articles)))
15028 (defun gnus-list-active-group (group)
15029 "Request active information on GROUP."
15030 (let ((method (gnus-find-method-for-group group))
15031 (func 'list-active-group))
15032 (when (gnus-check-backend-function func group)
15033 (funcall (gnus-get-function method func)
15034 (gnus-group-real-name group) (nth 1 method)))))
15036 (defun gnus-request-group-description (group)
15037 "Request a description of GROUP."
15038 (let ((method (gnus-find-method-for-group group))
15039 (func 'request-group-description))
15040 (when (gnus-check-backend-function func group)
15041 (funcall (gnus-get-function method func)
15042 (gnus-group-real-name group) (nth 1 method)))))
15044 (defun gnus-close-group (group)
15045 "Request the GROUP be closed."
15046 (let ((method (gnus-find-method-for-group group)))
15047 (funcall (gnus-get-function method 'close-group)
15048 (gnus-group-real-name group) (nth 1 method))))
15050 (defun gnus-retrieve-headers (articles group &optional fetch-old)
15051 "Request headers for ARTICLES in GROUP.
15052 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
15053 (let ((method (gnus-find-method-for-group group)))
15054 (if (and gnus-use-cache (numberp (car articles)))
15055 (gnus-cache-retrieve-headers articles group fetch-old)
15056 (funcall (gnus-get-function method 'retrieve-headers)
15057 articles (gnus-group-real-name group) (nth 1 method)
15060 (defun gnus-retrieve-groups (groups method)
15061 "Request active information on GROUPS from METHOD."
15062 (when (stringp method)
15063 (setq method (gnus-server-to-method method)))
15064 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
15066 (defun gnus-request-type (group &optional article)
15067 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15068 (let ((method (gnus-find-method-for-group group)))
15069 (if (not (gnus-check-backend-function 'request-type (car method)))
15071 (funcall (gnus-get-function method 'request-type)
15072 (gnus-group-real-name group) article))))
15074 (defun gnus-request-update-mark (group article mark)
15075 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
15076 (let ((method (gnus-find-method-for-group group)))
15077 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
15079 (funcall (gnus-get-function method 'request-update-mark)
15080 (gnus-group-real-name group) article mark))))
15082 (defun gnus-request-article (article group &optional buffer)
15083 "Request the ARTICLE in GROUP.
15084 ARTICLE can either be an article number or an article Message-ID.
15085 If BUFFER, insert the article in that group."
15086 (let ((method (gnus-find-method-for-group group)))
15087 (funcall (gnus-get-function method 'request-article)
15088 article (gnus-group-real-name group) (nth 1 method) buffer)))
15090 (defun gnus-request-head (article group)
15091 "Request the head of ARTICLE in GROUP."
15092 (let ((method (gnus-find-method-for-group group)))
15093 (funcall (gnus-get-function method 'request-head)
15094 article (gnus-group-real-name group) (nth 1 method))))
15096 (defun gnus-request-body (article group)
15097 "Request the body of ARTICLE in GROUP."
15098 (let ((method (gnus-find-method-for-group group)))
15099 (funcall (gnus-get-function method 'request-body)
15100 article (gnus-group-real-name group) (nth 1 method))))
15102 (defun gnus-request-post (method)
15103 "Post the current buffer using METHOD."
15104 (when (stringp method)
15105 (setq method (gnus-server-to-method method)))
15106 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
15108 (defun gnus-request-scan (group method)
15109 "Request a SCAN being performed in GROUP from METHOD.
15110 If GROUP is nil, all groups on METHOD are scanned."
15111 (let ((method (if group (gnus-find-method-for-group group) method)))
15112 (funcall (gnus-get-function method 'request-scan)
15113 (and group (gnus-group-real-name group)) (nth 1 method))))
15115 (defsubst gnus-request-update-info (info method)
15116 "Request that METHOD update INFO."
15117 (when (stringp method)
15118 (setq method (gnus-server-to-method method)))
15119 (when (gnus-check-backend-function 'request-update-info (car method))
15120 (funcall (gnus-get-function method 'request-update-info)
15121 (gnus-group-real-name (gnus-info-group info))
15122 info (nth 1 method))))
15124 (defun gnus-request-expire-articles (articles group &optional force)
15125 (let ((method (gnus-find-method-for-group group)))
15126 (funcall (gnus-get-function method 'request-expire-articles)
15127 articles (gnus-group-real-name group) (nth 1 method)
15130 (defun gnus-request-move-article
15131 (article group server accept-function &optional last)
15132 (let ((method (gnus-find-method-for-group group)))
15133 (funcall (gnus-get-function method 'request-move-article)
15134 article (gnus-group-real-name group)
15135 (nth 1 method) accept-function last)))
15137 (defun gnus-request-accept-article (group method &optional last)
15138 ;; Make sure there's a newline at the end of the article.
15139 (when (stringp method)
15140 (setq method (gnus-server-to-method method)))
15141 (when (and (not method)
15143 (setq method (gnus-find-method-for-group group)))
15144 (goto-char (point-max))
15147 (let ((func (car (or method (gnus-find-method-for-group group)))))
15148 (funcall (intern (format "%s-request-accept-article" func))
15149 (if (stringp group) (gnus-group-real-name group) group)
15153 (defun gnus-request-replace-article (article group buffer)
15154 (let ((func (car (gnus-find-method-for-group group))))
15155 (funcall (intern (format "%s-request-replace-article" func))
15156 article (gnus-group-real-name group) buffer)))
15158 (defun gnus-request-associate-buffer (group)
15159 (let ((method (gnus-find-method-for-group group)))
15160 (funcall (gnus-get-function method 'request-associate-buffer)
15161 (gnus-group-real-name group))))
15163 (defun gnus-request-restore-buffer (article group)
15164 "Request a new buffer restored to the state of ARTICLE."
15165 (let ((method (gnus-find-method-for-group group)))
15166 (funcall (gnus-get-function method 'request-restore-buffer)
15167 article (gnus-group-real-name group) (nth 1 method))))
15169 (defun gnus-request-create-group (group &optional method)
15170 (when (stringp method)
15171 (setq method (gnus-server-to-method method)))
15172 (let ((method (or method (gnus-find-method-for-group group))))
15173 (funcall (gnus-get-function method 'request-create-group)
15174 (gnus-group-real-name group) (nth 1 method))))
15176 (defun gnus-request-delete-group (group &optional force)
15177 (let ((method (gnus-find-method-for-group group)))
15178 (funcall (gnus-get-function method 'request-delete-group)
15179 (gnus-group-real-name group) force (nth 1 method))))
15181 (defun gnus-request-rename-group (group new-name)
15182 (let ((method (gnus-find-method-for-group group)))
15183 (funcall (gnus-get-function method 'request-rename-group)
15184 (gnus-group-real-name group)
15185 (gnus-group-real-name new-name) (nth 1 method))))
15187 (defun gnus-member-of-valid (symbol group)
15188 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
15189 (memq symbol (assoc
15190 (symbol-name (car (gnus-find-method-for-group group)))
15191 gnus-valid-select-methods)))
15193 (defun gnus-method-option-p (method option)
15194 "Return non-nil if select METHOD has OPTION as a parameter."
15195 (when (stringp method)
15196 (setq method (gnus-server-to-method method)))
15197 (memq option (assoc (format "%s" (car method))
15198 gnus-valid-select-methods)))
15200 (defun gnus-server-extend-method (group method)
15201 ;; This function "extends" a virtual server. If the server is
15202 ;; "hello", and the select method is ("hello" (my-var "something"))
15203 ;; in the group "alt.alt", this will result in a new virtual server
15204 ;; called "hello+alt.alt".
15206 (gnus-copy-sequence
15207 (if (equal (car method) "native") gnus-select-method
15208 (cdr (assoc (car method) gnus-server-alist))))))
15209 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
15210 (nconc entry (cdr method))))
15212 (defun gnus-find-method-for-group (group &optional info)
15213 "Find the select method that GROUP uses."
15214 (or gnus-override-method
15216 gnus-select-method)
15217 (let ((info (or info (gnus-get-info group)))
15220 (not (setq method (gnus-info-method info)))
15221 (equal method "native"))
15224 (cond ((stringp method)
15225 (gnus-server-to-method method))
15226 ((stringp (car method))
15227 (gnus-server-extend-method group method))
15230 (cond ((equal (cadr method) "")
15232 ((null (cadr method))
15233 (list (car method) ""))
15235 (gnus-server-add-address method)))))))
15237 (defun gnus-check-backend-function (func group)
15238 "Check whether GROUP supports function FUNC."
15239 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
15241 (fboundp (intern (format "%s-%s" method func)))))
15243 (defun gnus-methods-using (feature)
15244 "Find all methods that have FEATURE."
15245 (let ((valids gnus-valid-select-methods)
15248 (if (memq feature (car valids))
15249 (setq outs (cons (car valids) outs)))
15250 (setq valids (cdr valids)))
15255 ;;; Active & Newsrc File Handling
15258 (defun gnus-setup-news (&optional rawfile level dont-connect)
15259 "Setup news information.
15260 If RAWFILE is non-nil, the .newsrc file will also be read.
15261 If LEVEL is non-nil, the news will be set up at level LEVEL."
15262 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
15265 ;; Clear some variables to re-initialize news information.
15266 (setq gnus-newsrc-alist nil
15267 gnus-active-hashtb nil)
15268 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
15269 (gnus-read-newsrc-file rawfile))
15271 (when (and (not (assoc "archive" gnus-server-alist))
15272 gnus-message-archive-method)
15273 (push (cons "archive" gnus-message-archive-method)
15274 gnus-server-alist))
15276 ;; If we don't read the complete active file, we fill in the
15278 (if (or (null gnus-read-active-file)
15279 (eq gnus-read-active-file 'some))
15280 (gnus-update-active-hashtb-from-killed))
15282 ;; Read the active file and create `gnus-active-hashtb'.
15283 ;; If `gnus-read-active-file' is nil, then we just create an empty
15284 ;; hash table. The partial filling out of the hash table will be
15285 ;; done in `gnus-get-unread-articles'.
15286 (and gnus-read-active-file
15288 (gnus-read-active-file))
15290 (or gnus-active-hashtb
15291 (setq gnus-active-hashtb (make-vector 4095 0)))
15293 ;; Initialize the cache.
15294 (when gnus-use-cache
15297 ;; Possibly eval the dribble file.
15298 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
15300 ;; Slave Gnusii should then clear the dribble buffer.
15301 (when (and init gnus-slave)
15302 (gnus-dribble-clear))
15304 (gnus-update-format-specifications)
15306 ;; See whether we need to read the description file.
15307 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
15308 (not gnus-description-hashtb)
15310 gnus-read-active-file)
15311 (gnus-read-all-descriptions-files))
15313 ;; Find new newsgroups and treat them.
15314 (if (and init gnus-check-new-newsgroups (not level)
15315 (gnus-check-server gnus-select-method))
15316 (gnus-find-new-newsgroups))
15318 ;; We might read in new NoCeM messages here.
15319 (when (and gnus-use-nocem
15321 (not dont-connect))
15322 (gnus-nocem-scan-groups))
15324 ;; Find the number of unread articles in each non-dead group.
15325 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
15326 (gnus-get-unread-articles level))
15328 (if (and init gnus-check-bogus-newsgroups
15329 gnus-read-active-file (not level)
15330 (gnus-server-opened gnus-select-method))
15331 (gnus-check-bogus-newsgroups))))
15333 (defun gnus-find-new-newsgroups (&optional arg)
15334 "Search for new newsgroups and add them.
15335 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
15336 The `-n' option line from .newsrc is respected.
15337 If ARG (the prefix), use the `ask-server' method to query
15338 the server for new groups."
15340 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
15341 (null gnus-read-active-file)
15342 (eq gnus-read-active-file 'some))
15343 'ask-server gnus-check-new-newsgroups)))
15344 (unless (gnus-check-first-time-used)
15345 (if (or (consp check)
15346 (eq check 'ask-server))
15347 ;; Ask the server for new groups.
15348 (gnus-ask-server-for-new-groups)
15349 ;; Go through the active hashtb and look for new groups.
15351 group new-newsgroups)
15352 (gnus-message 5 "Looking for new newsgroups...")
15353 (unless gnus-have-read-active-file
15354 (gnus-read-active-file))
15355 (setq gnus-newsrc-last-checked-date (current-time-string))
15356 (unless gnus-killed-hashtb
15357 (gnus-make-hashtable-from-killed))
15358 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
15359 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
15362 (if (or (null (setq group (symbol-name sym)))
15364 (null (symbol-value sym))
15365 (gnus-gethash group gnus-killed-hashtb)
15366 (gnus-gethash group gnus-newsrc-hashtb))
15368 (let ((do-sub (gnus-matches-options-n group)))
15370 ((eq do-sub 'subscribe)
15371 (setq groups (1+ groups))
15372 (gnus-sethash group group gnus-killed-hashtb)
15373 (funcall gnus-subscribe-options-newsgroup-method group))
15374 ((eq do-sub 'ignore)
15377 (setq groups (1+ groups))
15378 (gnus-sethash group group gnus-killed-hashtb)
15379 (if gnus-subscribe-hierarchical-interactive
15380 (setq new-newsgroups (cons group new-newsgroups))
15381 (funcall gnus-subscribe-newsgroup-method group)))))))
15382 gnus-active-hashtb)
15383 (when new-newsgroups
15384 (gnus-subscribe-hierarchical-interactive new-newsgroups))
15385 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15387 (gnus-message 6 "%d new newsgroup%s arrived."
15388 groups (if (> groups 1) "s have" " has"))
15389 (gnus-message 6 "No new newsgroups.")))))))
15391 (defun gnus-matches-options-n (group)
15392 ;; Returns `subscribe' if the group is to be unconditionally
15393 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
15394 ;; no match for the group.
15396 ;; First we check the two user variables.
15398 ((and gnus-options-subscribe
15399 (string-match gnus-options-subscribe group))
15401 ((and gnus-auto-subscribed-groups
15402 (string-match gnus-auto-subscribed-groups group))
15404 ((and gnus-options-not-subscribe
15405 (string-match gnus-options-not-subscribe group))
15407 ;; Then we go through the list that was retrieved from the .newsrc
15408 ;; file. This list has elements on the form
15409 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15410 ;; is in the reverse order of the options line) is returned.
15412 (let ((regs gnus-newsrc-options-n))
15414 (not (string-match (caar regs) group)))
15415 (setq regs (cdr regs)))
15416 (and regs (cdar regs))))))
15418 (defun gnus-ask-server-for-new-groups ()
15419 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15420 (methods (cons gnus-select-method
15422 (when gnus-message-archive-method
15425 (and (consp gnus-check-new-newsgroups)
15426 gnus-check-new-newsgroups)
15427 gnus-secondary-select-methods))))
15429 (new-date (current-time-string))
15430 group new-newsgroups got-new method hashtb
15431 gnus-override-subscribe-method)
15432 ;; Go through both primary and secondary select methods and
15433 ;; request new newsgroups.
15434 (while (setq method (gnus-server-get-method nil (pop methods)))
15435 (setq new-newsgroups nil)
15436 (setq gnus-override-subscribe-method method)
15437 (when (and (gnus-check-server method)
15438 (gnus-request-newgroups date method))
15441 (setq hashtb (gnus-make-hashtable 100))
15442 (set-buffer nntp-server-buffer)
15443 ;; Enter all the new groups into a hashtable.
15444 (gnus-active-to-gnus-format method hashtb 'ignore))
15445 ;; Now all new groups from `method' are in `hashtb'.
15447 (lambda (group-sym)
15448 (if (or (null (setq group (symbol-name group-sym)))
15449 (not (boundp group-sym))
15450 (null (symbol-value group-sym))
15451 (gnus-gethash group gnus-newsrc-hashtb)
15452 (member group gnus-zombie-list)
15453 (member group gnus-killed-list))
15454 ;; The group is already known.
15456 ;; Make this group active.
15457 (when (symbol-value group-sym)
15458 (gnus-set-active group (symbol-value group-sym)))
15459 ;; Check whether we want it or not.
15460 (let ((do-sub (gnus-matches-options-n group)))
15462 ((eq do-sub 'subscribe)
15464 (gnus-sethash group group gnus-killed-hashtb)
15465 (funcall gnus-subscribe-options-newsgroup-method group))
15466 ((eq do-sub 'ignore)
15470 (gnus-sethash group group gnus-killed-hashtb)
15471 (if gnus-subscribe-hierarchical-interactive
15472 (push group new-newsgroups)
15473 (funcall gnus-subscribe-newsgroup-method group)))))))
15475 (when new-newsgroups
15476 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15477 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15479 (gnus-message 6 "%d new newsgroup%s arrived."
15480 groups (if (> groups 1) "s have" " has")))
15481 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15484 (defun gnus-check-first-time-used ()
15485 (if (or (> (length gnus-newsrc-alist) 1)
15486 (file-exists-p gnus-startup-file)
15487 (file-exists-p (concat gnus-startup-file ".el"))
15488 (file-exists-p (concat gnus-startup-file ".eld")))
15490 (gnus-message 6 "First time user; subscribing you to default groups")
15491 (unless (gnus-read-active-file-p)
15492 (gnus-read-active-file))
15493 (setq gnus-newsrc-last-checked-date (current-time-string))
15494 (let ((groups gnus-default-subscribed-newsgroups)
15498 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15501 (if (null (setq group (symbol-name sym)))
15503 (let ((do-sub (gnus-matches-options-n group)))
15505 ((eq do-sub 'subscribe)
15506 (gnus-sethash group group gnus-killed-hashtb)
15507 (funcall gnus-subscribe-options-newsgroup-method group))
15508 ((eq do-sub 'ignore)
15511 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15512 gnus-active-hashtb)
15514 (if (gnus-active (car groups))
15515 (gnus-group-change-level
15516 (car groups) gnus-level-default-subscribed gnus-level-killed))
15517 (setq groups (cdr groups)))
15518 (gnus-group-make-help-group)
15519 (and gnus-novice-user
15520 (gnus-message 7 "`A k' to list killed groups"))))))
15522 (defun gnus-subscribe-group (group previous &optional method)
15523 (gnus-group-change-level
15525 (list t group gnus-level-default-subscribed nil nil method)
15527 gnus-level-default-subscribed gnus-level-killed previous t))
15529 ;; `gnus-group-change-level' is the fundamental function for changing
15530 ;; subscription levels of newsgroups. This might mean just changing
15531 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15532 ;; again, which subscribes/unsubscribes a group, which is equally
15533 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15534 ;; from 8-9 to 1-7 means that you remove the group from the list of
15535 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15536 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15537 ;; which is trivial.
15538 ;; ENTRY can either be a string (newsgroup name) or a list (if
15539 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15540 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15542 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15543 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15545 (defun gnus-group-change-level (entry level &optional oldlevel
15546 previous fromkilled)
15547 (let (group info active num)
15548 ;; Glean what info we can from the arguments
15550 (if fromkilled (setq group (nth 1 entry))
15551 (setq group (car (nth 2 entry))))
15552 (setq group entry))
15553 (if (and (stringp entry)
15555 (< oldlevel gnus-level-zombie))
15556 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15557 (if (and (not oldlevel)
15559 (setq oldlevel (gnus-info-level (nth 2 entry)))
15560 (setq oldlevel (or oldlevel 9)))
15561 (if (stringp previous)
15562 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15564 (if (and (>= oldlevel gnus-level-zombie)
15565 (gnus-gethash group gnus-newsrc-hashtb))
15566 ;; We are trying to subscribe a group that is already
15570 (or (gnus-ephemeral-group-p group)
15571 (gnus-dribble-enter
15572 (format "(gnus-group-change-level %S %S %S %S %S)"
15573 group level oldlevel (car (nth 2 previous)) fromkilled)))
15575 ;; Then we remove the newgroup from any old structures, if needed.
15576 ;; If the group was killed, we remove it from the killed or zombie
15577 ;; list. If not, and it is in fact going to be killed, we remove
15578 ;; it from the newsrc hash table and assoc.
15580 ((>= oldlevel gnus-level-zombie)
15581 (if (= oldlevel gnus-level-zombie)
15582 (setq gnus-zombie-list (delete group gnus-zombie-list))
15583 (setq gnus-killed-list (delete group gnus-killed-list))))
15585 (if (and (>= level gnus-level-zombie)
15588 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15590 (setcdr (gnus-gethash (car (nth 3 entry))
15591 gnus-newsrc-hashtb)
15593 (setcdr (cdr entry) (cdddr entry))))))
15595 ;; Finally we enter (if needed) the list where it is supposed to
15596 ;; go, and change the subscription level. If it is to be killed,
15597 ;; we enter it into the killed or zombie list.
15599 ((>= level gnus-level-zombie)
15600 ;; Remove from the hash table.
15601 (gnus-sethash group nil gnus-newsrc-hashtb)
15602 ;; We do not enter foreign groups into the list of dead
15604 (unless (gnus-group-foreign-p group)
15605 (if (= level gnus-level-zombie)
15606 (setq gnus-zombie-list (cons group gnus-zombie-list))
15607 (setq gnus-killed-list (cons group gnus-killed-list)))))
15609 ;; If the list is to be entered into the newsrc assoc, and
15610 ;; it was killed, we have to create an entry in the newsrc
15611 ;; hashtb format and fix the pointers in the newsrc assoc.
15612 (if (< oldlevel gnus-level-zombie)
15613 ;; It was alive, and it is going to stay alive, so we
15614 ;; just change the level and don't change any pointers or
15615 ;; hash table entries.
15616 (setcar (cdaddr entry) level)
15618 (setq info (cdr entry)
15620 (setq active (gnus-active group))
15622 (if active (- (1+ (cdr active)) (car active)) t))
15623 ;; Check whether the group is foreign. If so, the
15624 ;; foreign select method has to be entered into the
15626 (let ((method (or gnus-override-subscribe-method
15627 (gnus-group-method group))))
15628 (if (eq method gnus-select-method)
15629 (setq info (list group level nil))
15630 (setq info (list group level nil nil method)))))
15633 (let ((p gnus-newsrc-alist))
15637 (setq entry (cons info (cddr previous)))
15640 (setcdr (cdr previous) entry)
15641 (gnus-sethash group (cons num (cdr previous))
15642 gnus-newsrc-hashtb))
15643 (setcdr previous entry)
15644 (gnus-sethash group (cons num previous)
15645 gnus-newsrc-hashtb))
15647 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15648 (when gnus-group-change-level-function
15649 (funcall gnus-group-change-level-function group level oldlevel)))))
15651 (defun gnus-kill-newsgroup (newsgroup)
15652 "Obsolete function. Kills a newsgroup."
15653 (gnus-group-change-level
15654 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15656 (defun gnus-check-bogus-newsgroups (&optional confirm)
15657 "Remove bogus newsgroups.
15658 If CONFIRM is non-nil, the user has to confirm the deletion of every
15660 (let ((newsrc (cdr gnus-newsrc-alist))
15661 bogus group entry info)
15662 (gnus-message 5 "Checking bogus newsgroups...")
15663 (unless (gnus-read-active-file-p)
15664 (gnus-read-active-file))
15665 (when (gnus-read-active-file-p)
15666 ;; Find all bogus newsgroup that are subscribed.
15668 (setq info (pop newsrc)
15669 group (gnus-info-group info))
15670 (unless (or (gnus-active group) ; Active
15671 (gnus-info-method info) ; Foreign
15673 (not (gnus-y-or-n-p
15674 (format "Remove bogus newsgroup: %s " group)))))
15675 ;; Found a bogus newsgroup.
15676 (push group bogus)))
15677 ;; Remove all bogus subscribed groups by first killing them, and
15678 ;; then removing them from the list of killed groups.
15680 (when (setq entry (gnus-gethash (setq group (pop bogus))
15681 gnus-newsrc-hashtb))
15682 (gnus-group-change-level entry gnus-level-killed)
15683 (setq gnus-killed-list (delete group gnus-killed-list))))
15684 ;; Then we remove all bogus groups from the list of killed and
15685 ;; zombie groups. They are are removed without confirmation.
15686 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15689 (setq killed (symbol-value (car dead-lists)))
15691 (unless (gnus-active (setq group (pop killed)))
15692 ;; The group is bogus.
15693 ;; !!!Slow as hell.
15694 (set (car dead-lists)
15695 (delete group (symbol-value (car dead-lists))))))
15696 (setq dead-lists (cdr dead-lists))))
15697 (gnus-message 5 "Checking bogus newsgroups...done"))))
15699 (defun gnus-check-duplicate-killed-groups ()
15700 "Remove duplicates from the list of killed groups."
15702 (let ((killed gnus-killed-list))
15704 (gnus-message 9 "%d" (length killed))
15705 (setcdr killed (delete (car killed) (cdr killed)))
15706 (setq killed (cdr killed)))))
15708 ;; We want to inline a function from gnus-cache, so we cheat here:
15711 (require 'gnus-cache))
15713 (defun gnus-get-unread-articles-in-group (info active &optional update)
15715 ;; Allow the backend to update the info in the group.
15717 (gnus-request-update-info
15718 info (gnus-find-method-for-group (gnus-info-group info))))
15719 (gnus-activate-group (gnus-info-group info) nil t))
15720 (let* ((range (gnus-info-read info))
15722 ;; If a cache is present, we may have to alter the active info.
15723 (when (and gnus-use-cache info)
15724 (inline (gnus-cache-possibly-alter-active
15725 (gnus-info-group info) active)))
15726 ;; Modify the list of read articles according to what articles
15727 ;; are available; then tally the unread articles and add the
15728 ;; number to the group hash table entry.
15730 ((zerop (cdr active))
15733 (setq num (- (1+ (cdr active)) (car active))))
15734 ((not (listp (cdr range)))
15735 ;; Fix a single (num . num) range according to the
15736 ;; active hash table.
15737 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15738 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15739 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15740 ;; Compute number of unread articles.
15741 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15743 ;; The read list is a list of ranges. Fix them according to
15744 ;; the active hash table.
15745 ;; First peel off any elements that are below the lower
15747 (while (and (cdr range)
15749 (or (and (atom (cadr range)) (cadr range))
15751 (if (numberp (car range))
15754 (or (and (numberp (cadr range))
15757 (setcdr (car range)
15758 (or (and (numberp (nth 1 range)) (nth 1 range))
15760 (setcdr range (cddr range)))
15761 ;; Adjust the first element to be the same as the lower limit.
15762 (if (and (not (atom (car range)))
15763 (< (cdar range) (car active)))
15764 (setcdr (car range) (1- (car active))))
15765 ;; Then we want to peel off any elements that are higher
15766 ;; than the upper active limit.
15767 (let ((srange range))
15768 ;; Go past all legal elements.
15769 (while (and (cdr srange)
15770 (<= (or (and (atom (cadr srange))
15772 (caadr srange)) (cdr active)))
15773 (setq srange (cdr srange)))
15775 ;; Nuke all remaining illegal elements.
15776 (setcdr srange nil))
15778 ;; Adjust the final element.
15779 (if (and (not (atom (car srange)))
15780 (> (cdar srange) (cdr active)))
15781 (setcdr (car srange) (cdr active))))
15782 ;; Compute the number of unread articles.
15784 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15786 (or (and (atom (car range)) (car range))
15788 (setq range (cdr range)))
15789 (setq num (max 0 (- (cdr active) num)))))
15790 ;; Set the number of unread articles.
15792 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
15795 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15796 ;; and compute how many unread articles there are in each group.
15797 (defun gnus-get-unread-articles (&optional level)
15798 (let* ((newsrc (cdr gnus-newsrc-alist))
15799 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15802 (cond ((and gnus-activate-foreign-newsgroups
15803 (not (numberp gnus-activate-foreign-newsgroups)))
15804 (1+ gnus-level-subscribed))
15805 ((numberp gnus-activate-foreign-newsgroups)
15806 gnus-activate-foreign-newsgroups)
15809 info group active method)
15810 (gnus-message 5 "Checking new news...")
15813 (setq active (gnus-active (setq group (gnus-info-group
15814 (setq info (pop newsrc))))))
15816 ;; Check newsgroups. If the user doesn't want to check them, or
15817 ;; they can't be checked (for instance, if the news server can't
15818 ;; be reached) we just set the number of unread articles in this
15819 ;; newsgroup to t. This means that Gnus thinks that there are
15820 ;; unread articles, but it has no idea how many.
15821 (if (and (setq method (gnus-info-method info))
15822 (not (gnus-server-equal
15824 (setq method (gnus-server-get-method nil method))))
15825 (not (gnus-secondary-method-p method)))
15826 ;; These groups are foreign. Check the level.
15827 (when (<= (gnus-info-level info) foreign-level)
15828 (setq active (gnus-activate-group group 'scan))
15829 (unless (inline (gnus-virtual-group-p group))
15830 (inline (gnus-close-group group)))
15831 (when (fboundp (intern (concat (symbol-name (car method))
15832 "-request-update-info")))
15833 (inline (gnus-request-update-info info method))))
15834 ;; These groups are native or secondary.
15835 (when (and (<= (gnus-info-level info) level)
15836 (not gnus-read-active-file))
15837 (setq active (gnus-activate-group group 'scan))
15838 (inline (gnus-close-group group))))
15840 ;; Get the number of unread articles in the group.
15842 (inline (gnus-get-unread-articles-in-group info active))
15843 ;; The group couldn't be reached, so we nix out the number of
15844 ;; unread articles and stuff.
15845 (gnus-set-active group nil)
15846 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
15848 (gnus-message 5 "Checking new news...done")))
15850 ;; Create a hash table out of the newsrc alist. The `car's of the
15851 ;; alist elements are used as keys.
15852 (defun gnus-make-hashtable-from-newsrc-alist ()
15853 (let ((alist gnus-newsrc-alist)
15854 (ohashtb gnus-newsrc-hashtb)
15856 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15858 (setq prev (setq gnus-newsrc-alist
15859 (if (equal (caar gnus-newsrc-alist)
15862 (cons (list "dummy.group" 0 nil) alist)))))
15866 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
15868 gnus-newsrc-hashtb)
15870 alist (cdr alist)))))
15872 (defun gnus-make-hashtable-from-killed ()
15873 "Create a hash table from the killed and zombie lists."
15874 (let ((lists '(gnus-killed-list gnus-zombie-list))
15876 (setq gnus-killed-hashtb
15877 (gnus-make-hashtable
15878 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15879 (while (setq list (pop lists))
15880 (setq list (symbol-value list))
15882 (gnus-sethash (car list) (pop list) gnus-killed-hashtb)))))
15884 (defun gnus-activate-group (group &optional scan dont-check)
15885 ;; Check whether a group has been activated or not.
15886 ;; If SCAN, request a scan of that group as well.
15887 (let ((method (gnus-find-method-for-group group))
15889 (and (gnus-check-server method)
15890 ;; We escape all bugs and quit here to make it possible to
15891 ;; continue if a group is so out-there that it reports bugs
15895 (gnus-check-backend-function 'request-scan (car method))
15896 (gnus-request-scan group method))
15899 (gnus-request-group group dont-check)
15903 (set-buffer nntp-server-buffer)
15904 (goto-char (point-min))
15905 ;; Parse the result we got from `gnus-request-group'.
15906 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
15908 (goto-char (match-beginning 1))
15910 group (setq active (cons (read (current-buffer))
15911 (read (current-buffer)))))
15912 ;; Return the new active info.
15915 (defun gnus-update-read-articles (group unread)
15916 "Update the list of read and ticked articles in GROUP using the
15917 UNREAD and TICKED lists.
15918 Note: UNSELECTED has to be sorted over `<'.
15919 Returns whether the updating was successful."
15920 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
15921 (entry (gnus-gethash group gnus-newsrc-hashtb))
15922 (info (nth 2 entry))
15924 (unread (sort (copy-sequence unread) '<))
15926 (if (or (not info) (not active))
15927 ;; There is no info on this group if it was, in fact,
15928 ;; killed. Gnus stores no information on killed groups, so
15929 ;; there's nothing to be done.
15930 ;; One could store the information somewhere temporarily,
15931 ;; perhaps... Hmmm...
15933 ;; Remove any negative articles numbers.
15934 (while (and unread (< (car unread) 0))
15935 (setq unread (cdr unread)))
15936 ;; Remove any expired article numbers
15937 (while (and unread (< (car unread) (car active)))
15938 (setq unread (cdr unread)))
15939 ;; Compute the ranges of read articles by looking at the list of
15940 ;; unread articles.
15942 (if (/= (car unread) prev)
15943 (setq read (cons (if (= prev (1- (car unread))) prev
15944 (cons prev (1- (car unread)))) read)))
15945 (setq prev (1+ (car unread)))
15946 (setq unread (cdr unread)))
15947 (when (<= prev (cdr active))
15948 (setq read (cons (cons prev (cdr active)) read)))
15949 ;; Enter this list into the group info.
15950 (gnus-info-set-read
15951 info (if (> (length read) 1) (nreverse read) read))
15952 ;; Set the number of unread articles in gnus-newsrc-hashtb.
15953 (gnus-get-unread-articles-in-group info (gnus-active group))
15956 (defun gnus-make-articles-unread (group articles)
15957 "Mark ARTICLES in GROUP as unread."
15958 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
15959 (gnus-gethash (gnus-group-real-name group)
15960 gnus-newsrc-hashtb))))
15961 (ranges (gnus-info-read info))
15964 (when (gnus-member-of-range
15965 (setq article (pop articles)) ranges)
15966 (setq news (cons article news))))
15968 (gnus-info-set-read
15969 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
15970 (gnus-group-update-group group t))))
15972 ;; Enter all dead groups into the hashtb.
15973 (defun gnus-update-active-hashtb-from-killed ()
15974 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
15975 (lists (list gnus-killed-list gnus-zombie-list))
15978 (setq killed (car lists))
15980 (gnus-sethash (car killed) nil hashtb)
15981 (setq killed (cdr killed)))
15982 (setq lists (cdr lists)))))
15984 (defun gnus-get-killed-groups ()
15985 "Go through the active hashtb and all all unknown groups as killed."
15986 ;; First make sure active file has been read.
15987 (unless (gnus-read-active-file-p)
15988 (let ((gnus-read-active-file t))
15989 (gnus-read-active-file)))
15990 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
15991 ;; Go through all newsgroups that are known to Gnus - enlarge kill list.
15995 (group (symbol-name sym)))
15996 (if (or (null group)
15997 (gnus-gethash group gnus-killed-hashtb)
15998 (gnus-gethash group gnus-newsrc-hashtb))
16000 (let ((do-sub (gnus-matches-options-n group)))
16001 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
16003 (setq groups (1+ groups))
16004 (setq gnus-killed-list
16005 (cons group gnus-killed-list))
16006 (gnus-sethash group group gnus-killed-hashtb))))))
16007 gnus-active-hashtb))
16009 ;; Get the active file(s) from the backend(s).
16010 (defun gnus-read-active-file ()
16011 (gnus-group-set-mode-line)
16014 (if (gnus-check-server gnus-select-method)
16015 ;; The native server is available.
16016 (cons gnus-select-method gnus-secondary-select-methods)
16017 ;; The native server is down, so we just do the
16019 gnus-secondary-select-methods)
16020 ;; Also read from the archive server.
16021 (when gnus-message-archive-method
16022 (list "archive"))))
16024 (setq gnus-have-read-active-file nil)
16026 (set-buffer nntp-server-buffer)
16028 (let* ((method (if (stringp (car methods))
16029 (gnus-server-get-method nil (car methods))
16031 (where (nth 1 method))
16032 (mesg (format "Reading active file%s via %s..."
16033 (if (and where (not (zerop (length where))))
16034 (concat " from " where) "")
16036 (gnus-message 5 mesg)
16037 (when (gnus-check-server method)
16038 ;; Request that the backend scan its incoming messages.
16039 (and (gnus-check-backend-function 'request-scan (car method))
16040 (gnus-request-scan nil method))
16042 ((and (eq gnus-read-active-file 'some)
16043 (gnus-check-backend-function 'retrieve-groups (car method)))
16044 (let ((newsrc (cdr gnus-newsrc-alist))
16045 (gmethod (gnus-server-get-method nil method))
16047 (while (setq info (pop newsrc))
16048 (when (gnus-server-equal
16049 (gnus-find-method-for-group
16050 (gnus-info-group info) info)
16052 (push (gnus-group-real-name (gnus-info-group info))
16055 (gnus-check-server method)
16056 (setq list-type (gnus-retrieve-groups groups method))
16060 1.2 "Cannot read partial active file from %s server."
16062 ((eq list-type 'active)
16063 (gnus-active-to-gnus-format method gnus-active-hashtb))
16065 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
16067 (if (not (gnus-request-list method))
16068 (unless (equal method gnus-message-archive-method)
16069 (gnus-error 1 "Cannot read active file from %s server."
16071 (gnus-active-to-gnus-format method gnus-active-hashtb)
16072 ;; We mark this active file as read.
16073 (push method gnus-have-read-active-file)
16074 (gnus-message 5 "%sdone" mesg))))))
16075 (setq methods (cdr methods))))))
16077 ;; Read an active file and place the results in `gnus-active-hashtb'.
16078 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
16080 (setq method gnus-select-method))
16081 (let ((cur (current-buffer))
16083 (if (and gnus-active-hashtb
16084 (not (equal method gnus-select-method)))
16086 (setq gnus-active-hashtb
16087 (if (equal method gnus-select-method)
16088 (gnus-make-hashtable
16089 (count-lines (point-min) (point-max)))
16090 (gnus-make-hashtable 4096)))))))
16091 ;; Delete unnecessary lines.
16092 (goto-char (point-min))
16093 (while (search-forward "\nto." nil t)
16094 (delete-region (1+ (match-beginning 0))
16095 (progn (forward-line 1) (point))))
16096 (or (string= gnus-ignored-newsgroups "")
16098 (goto-char (point-min))
16099 (delete-matching-lines gnus-ignored-newsgroups)))
16100 ;; Make the group names readable as a lisp expression even if they
16101 ;; contain special characters.
16102 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
16103 (goto-char (point-max))
16104 (while (re-search-backward "[][';?()#]" nil t)
16106 ;; If these are groups from a foreign select method, we insert the
16107 ;; group prefix in front of the group names.
16108 (and method (not (gnus-server-equal
16109 (gnus-server-get-method nil method)
16110 (gnus-server-get-method nil gnus-select-method)))
16111 (let ((prefix (gnus-group-prefixed-name "" method)))
16112 (goto-char (point-min))
16113 (while (and (not (eobp))
16114 (progn (insert prefix)
16115 (zerop (forward-line 1)))))))
16116 ;; Store the active file in a hash table.
16117 (goto-char (point-min))
16118 (if (string-match "%[oO]" gnus-group-line-format)
16119 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
16120 ;; If we want information on moderated groups, we use this
16122 (let* ((mod-hashtb (make-vector 7 0))
16123 (m (intern "m" mod-hashtb))
16125 (while (not (eobp))
16126 (condition-case nil
16128 (narrow-to-region (point) (gnus-point-at-eol))
16129 (setq group (let ((obarray hashtb)) (read cur)))
16130 (if (and (numberp (setq max (read cur)))
16131 (numberp (setq min (read cur)))
16133 (skip-chars-forward " \t")
16135 (or (= (following-char) ?=)
16136 (= (following-char) ?x)
16137 (= (following-char) ?j)))))
16138 (set group (cons min max))
16140 ;; Enter moderated groups into a list.
16141 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
16142 (setq gnus-moderated-list
16143 (cons (symbol-name group) gnus-moderated-list))))
16150 ;; And if we do not care about moderation, we use this loop,
16151 ;; which is faster.
16152 (let (group max min)
16153 (while (not (eobp))
16156 (narrow-to-region (point) (gnus-point-at-eol))
16157 ;; group gets set to a symbol interned in the hash table
16158 ;; (what a hack!!) - jwz
16159 (setq group (let ((obarray hashtb)) (read cur)))
16160 (if (and (numberp (setq max (read cur)))
16161 (numberp (setq min (read cur)))
16163 (skip-chars-forward " \t")
16165 (or (= (following-char) ?=)
16166 (= (following-char) ?x)
16167 (= (following-char) ?j)))))
16168 (set group (cons min max))
16176 (gnus-message 3 "Warning - illegal active: %s"
16178 (gnus-point-at-bol) (gnus-point-at-eol)))))))
16180 (forward-line 1))))))
16182 (defun gnus-groups-to-gnus-format (method &optional hashtb)
16183 ;; Parse a "groups" active file.
16184 (let ((cur (current-buffer))
16186 (if (and method gnus-active-hashtb)
16188 (setq gnus-active-hashtb
16189 (gnus-make-hashtable
16190 (count-lines (point-min) (point-max)))))))
16191 (prefix (and method
16192 (not (gnus-server-equal
16193 (gnus-server-get-method nil method)
16194 (gnus-server-get-method nil gnus-select-method)))
16195 (gnus-group-prefixed-name "" method))))
16197 (goto-char (point-min))
16198 ;; We split this into to separate loops, one with the prefix
16199 ;; and one without to speed the reading up somewhat.
16201 (let (min max opoint group)
16202 (while (not (eobp))
16205 (read cur) (read cur)
16206 (setq min (read cur)
16209 (skip-chars-forward " \t")
16212 (set (let ((obarray hashtb)) (read cur))
16214 (error (and group (symbolp group) (set group nil))))
16216 (let (min max group)
16217 (while (not (eobp))
16219 (if (= (following-char) ?2)
16221 (read cur) (read cur)
16222 (setq min (read cur)
16224 (set (setq group (let ((obarray hashtb)) (read cur)))
16226 (error (and group (symbolp group) (set group nil))))
16227 (forward-line 1))))))
16229 (defun gnus-read-newsrc-file (&optional force)
16230 "Read startup file.
16231 If FORCE is non-nil, the .newsrc file is read."
16232 ;; Reset variables that might be defined in the .newsrc.eld file.
16233 (let ((variables gnus-variable-list))
16235 (set (car variables) nil)
16236 (setq variables (cdr variables))))
16237 (let* ((newsrc-file gnus-current-startup-file)
16238 (quick-file (concat newsrc-file ".el")))
16240 ;; We always load the .newsrc.eld file. If always contains
16241 ;; much information that can not be gotten from the .newsrc
16242 ;; file (ticked articles, killed groups, foreign methods, etc.)
16243 (gnus-read-newsrc-el-file quick-file)
16245 (if (and (file-exists-p gnus-current-startup-file)
16247 (and (file-newer-than-file-p newsrc-file quick-file)
16248 (file-newer-than-file-p newsrc-file
16249 (concat quick-file "d")))
16250 (not gnus-newsrc-alist)))
16251 ;; We read the .newsrc file. Note that if there if a
16252 ;; .newsrc.eld file exists, it has already been read, and
16253 ;; the `gnus-newsrc-hashtb' has been created. While reading
16254 ;; the .newsrc file, Gnus will only use the information it
16255 ;; can find there for changing the data already read -
16256 ;; ie. reading the .newsrc file will not trash the data
16257 ;; already read (except for read articles).
16259 (gnus-message 5 "Reading %s..." newsrc-file)
16260 (set-buffer (find-file-noselect newsrc-file))
16261 (buffer-disable-undo (current-buffer))
16262 (gnus-newsrc-to-gnus-format)
16263 (kill-buffer (current-buffer))
16264 (gnus-message 5 "Reading %s...done" newsrc-file)))
16266 ;; Read any slave files.
16268 (gnus-master-read-slave-newsrc))
16270 ;; Convert old to new.
16271 (gnus-convert-old-newsrc))))
16273 (defun gnus-continuum-version (version)
16274 "Return VERSION as a floating point number."
16275 (when (string-match "^\\([^ ]+\\)? ?Gnus v?\\([0-9.]+\\)$" version)
16276 (let* ((alpha (and (match-beginning 1) (match-string 1 version)))
16277 (number (match-string 2 version))
16279 (string-match "\\([0-9]\\)\\.\\([0-9]+\\)\\.?\\([0-9]+\\)?" number)
16280 (setq major (string-to-number (match-string 1 number)))
16281 (setq minor (string-to-number (match-string 2 number)))
16282 (setq least (if (match-beginning 3)
16283 (string-to-number (match-string 3 number))
16287 (format "%s00%02d%02d"
16289 ((string= alpha "(ding)") "4.99")
16290 ((string= alpha "September") "5.01")
16291 ((string= alpha "Red") "5.03"))
16293 (format "%d.%02d%20d" major minor least))))))
16295 (defun gnus-convert-old-newsrc ()
16296 "Convert old newsrc into the new format, if needed."
16297 (let ((fcv (and gnus-newsrc-file-version
16298 (gnus-continuum-version gnus-newsrc-file-version))))
16300 ;; No .newsrc.eld file was loaded.
16302 ;; Gnus 5 .newsrc.eld was loaded.
16303 ((< fcv (gnus-continuum-version "September Gnus v0.1"))
16304 (gnus-convert-old-ticks)))))
16306 (defun gnus-convert-old-ticks ()
16307 (let ((newsrc (cdr gnus-newsrc-alist))
16308 marks info dormant ticked)
16309 (while (setq info (pop newsrc))
16310 (when (setq marks (gnus-info-marks info))
16311 (setq dormant (cdr (assq 'dormant marks))
16312 ticked (cdr (assq 'tick marks)))
16313 (when (or dormant ticked)
16314 (gnus-info-set-read
16317 (gnus-info-read info)
16318 (nconc (gnus-uncompress-range dormant)
16319 (gnus-uncompress-range ticked)))))))))
16321 (defun gnus-read-newsrc-el-file (file)
16322 (let ((ding-file (concat file "d")))
16323 ;; We always, always read the .eld file.
16324 (gnus-message 5 "Reading %s..." ding-file)
16325 (let (gnus-newsrc-assoc)
16326 (condition-case nil
16327 (load ding-file t t t)
16329 (gnus-error 1 "Error in %s" ding-file)))
16330 (when gnus-newsrc-assoc
16331 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
16332 (gnus-make-hashtable-from-newsrc-alist)
16333 (when (file-newer-than-file-p file ding-file)
16334 ;; Old format quick file
16335 (gnus-message 5 "Reading %s..." file)
16336 ;; The .el file is newer than the .eld file, so we read that one
16338 (gnus-read-old-newsrc-el-file file))))
16340 ;; Parse the old-style quick startup file
16341 (defun gnus-read-old-newsrc-el-file (file)
16342 (let (newsrc killed marked group m info)
16344 (let ((gnus-killed-assoc nil)
16345 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
16347 (condition-case nil
16350 (setq newsrc gnus-newsrc-assoc
16351 killed gnus-killed-assoc
16352 marked gnus-marked-assoc)))
16353 (setq gnus-newsrc-alist nil)
16354 (while (setq info (gnus-get-info (setq group (pop newsrc))))
16357 (gnus-info-set-read info (cddr group))
16358 (gnus-info-set-level
16359 info (if (nth 1 group) gnus-level-default-subscribed
16360 gnus-level-default-unsubscribed))
16361 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
16364 (if (nth 1 group) gnus-level-default-subscribed
16365 gnus-level-default-unsubscribed)
16367 gnus-newsrc-alist))
16368 ;; Copy marks into info.
16369 (when (setq m (assoc (car group) marked))
16370 (unless (nthcdr 3 info)
16371 (nconc info (list nil)))
16372 (gnus-info-set-marks
16373 info (list (cons 'tick (gnus-compress-sequence
16374 (sort (cdr m) '<) t))))))
16375 (setq newsrc killed)
16377 (setcar newsrc (caar newsrc))
16378 (setq newsrc (cdr newsrc)))
16379 (setq gnus-killed-list killed))
16380 ;; The .el file version of this variable does not begin with
16381 ;; "options", while the .eld version does, so we just add it if it
16384 gnus-newsrc-options
16386 (and (not (string-match "^ *options" gnus-newsrc-options))
16387 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
16388 (and (not (string-match "\n$" gnus-newsrc-options))
16389 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
16390 ;; Finally, if we read some options lines, we parse them.
16391 (or (string= gnus-newsrc-options "")
16392 (gnus-newsrc-parse-options gnus-newsrc-options))))
16394 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
16395 (gnus-make-hashtable-from-newsrc-alist)))
16397 (defun gnus-make-newsrc-file (file)
16398 "Make server dependent file name by catenating FILE and server host name."
16399 (let* ((file (expand-file-name file nil))
16400 (real-file (concat file "-" (nth 1 gnus-select-method))))
16401 (if (or (file-exists-p real-file)
16402 (file-exists-p (concat real-file ".el"))
16403 (file-exists-p (concat real-file ".eld")))
16406 (defun gnus-newsrc-to-gnus-format ()
16407 (setq gnus-newsrc-options "")
16408 (setq gnus-newsrc-options-n nil)
16410 (or gnus-active-hashtb
16411 (setq gnus-active-hashtb (make-vector 4095 0)))
16412 (let ((buf (current-buffer))
16413 (already-read (> (length gnus-newsrc-alist) 1))
16414 group subscribed options-symbol newsrc Options-symbol
16416 (goto-char (point-min))
16417 ;; We intern the symbol `options' in the active hashtb so that we
16418 ;; can `eq' against it later.
16419 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
16420 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
16422 (while (not (eobp))
16423 ;; We first read the first word on the line by narrowing and
16424 ;; then reading into `gnus-active-hashtb'. Most groups will
16425 ;; already exist in that hashtb, so this will save some string
16429 (progn (skip-chars-forward "^ \t!:\n") (point)))
16430 (goto-char (point-min))
16432 (and (/= (point-min) (point-max))
16433 (let ((obarray gnus-active-hashtb)) (read buf))))
16435 ;; Now, the symbol we have read is either `options' or a group
16436 ;; name. If it is an options line, we just add it to a string.
16438 ((or (eq symbol options-symbol)
16439 (eq symbol Options-symbol))
16440 (setq gnus-newsrc-options
16441 ;; This concating is quite inefficient, but since our
16442 ;; thorough studies show that approx 99.37% of all
16443 ;; .newsrc files only contain a single options line, we
16444 ;; don't give a damn, frankly, my dear.
16445 (concat gnus-newsrc-options
16447 (gnus-point-at-bol)
16448 ;; Options may continue on the next line.
16449 (or (and (re-search-forward "^[^ \t]" nil 'move)
16450 (progn (beginning-of-line) (point)))
16454 ;; Group names can be just numbers.
16455 (when (numberp symbol)
16456 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
16457 (or (boundp symbol) (set symbol nil))
16458 ;; It was a group name.
16459 (setq subscribed (= (following-char) ?:)
16460 group (symbol-name symbol)
16463 ;; If the line ends here, this is clearly a buggy line, so
16464 ;; we put point a the beginning of line and let the cond
16465 ;; below do the error handling.
16466 (beginning-of-line)
16467 ;; We skip to the beginning of the ranges.
16468 (skip-chars-forward "!: \t"))
16469 ;; We are now at the beginning of the list of read articles.
16470 ;; We read them range by range.
16473 ((looking-at "[0-9]+")
16474 ;; We narrow and read a number instead of buffer-substring/
16475 ;; string-to-int because it's faster. narrow/widen is
16476 ;; faster than save-restriction/narrow, and save-restriction
16477 ;; produces a garbage object.
16479 (narrow-to-region (match-beginning 0) (match-end 0))
16482 ;; If the next character is a dash, then this is a range.
16483 (if (= (following-char) ?-)
16485 ;; We read the upper bound of the range.
16487 (if (not (looking-at "[0-9]+"))
16488 ;; This is a buggy line, by we pretend that
16489 ;; it's kinda OK. Perhaps the user should be
16491 (setq reads (cons num1 reads))
16496 (narrow-to-region (match-beginning 0)
16501 ;; It was just a simple number, so we add it to the
16503 (setq reads (cons num1 reads)))
16504 ;; If the next char in ?\n, then we have reached the end
16505 ;; of the line and return nil.
16506 (/= (following-char) ?\n))
16507 ((= (following-char) ?\n)
16508 ;; End of line, so we end.
16511 ;; Not numbers and not eol, so this might be a buggy
16514 ;; If it was eob instead of ?\n, we allow it.
16516 ;; The line was buggy.
16518 (gnus-error 3.1 "Mangled line: %s"
16519 (buffer-substring (gnus-point-at-bol)
16520 (gnus-point-at-eol)))))
16522 ;; Skip past ", ". Spaces are illegal in these ranges, but
16523 ;; we allow them, because it's a common mistake to put a
16524 ;; space after the comma.
16525 (skip-chars-forward ", "))
16527 ;; We have already read .newsrc.eld, so we gently update the
16528 ;; data in the hash table with the information we have just
16531 (let ((info (gnus-get-info group))
16534 ;; There is an entry for this file in the alist.
16536 (gnus-info-set-read info (nreverse reads))
16537 ;; We update the level very gently. In fact, we
16538 ;; only change it if there's been a status change
16539 ;; from subscribed to unsubscribed, or vice versa.
16540 (setq level (gnus-info-level info))
16541 (cond ((and (<= level gnus-level-subscribed)
16543 (setq level (if reads
16544 gnus-level-default-unsubscribed
16545 (1+ gnus-level-default-unsubscribed))))
16546 ((and (> level gnus-level-subscribed) subscribed)
16547 (setq level gnus-level-default-subscribed)))
16548 (gnus-info-set-level info level))
16549 ;; This is a new group.
16550 (setq info (list group
16552 gnus-level-default-subscribed
16554 (1+ gnus-level-subscribed)
16555 gnus-level-default-unsubscribed))
16556 (nreverse reads))))
16557 (setq newsrc (cons info newsrc))))))
16560 (setq newsrc (nreverse newsrc))
16562 (if (not already-read)
16564 ;; We now have two newsrc lists - `newsrc', which is what we
16565 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16566 ;; what we've read from .newsrc.eld. We have to merge these
16567 ;; lists. We do this by "attaching" any (foreign) groups in the
16568 ;; gnus-newsrc-alist to the (native) group that precedes them.
16569 (let ((rc (cdr gnus-newsrc-alist))
16570 (prev gnus-newsrc-alist)
16573 (or (null (nth 4 (car rc))) ; It's a native group.
16574 (assoc (caar rc) newsrc) ; It's already in the alist.
16575 (if (setq entry (assoc (caar prev) newsrc))
16576 (setcdr (setq mentry (memq entry newsrc))
16577 (cons (car rc) (cdr mentry)))
16578 (setq newsrc (cons (car rc) newsrc))))
16582 (setq gnus-newsrc-alist newsrc)
16583 ;; We make the newsrc hashtb.
16584 (gnus-make-hashtable-from-newsrc-alist)
16586 ;; Finally, if we read some options lines, we parse them.
16587 (or (string= gnus-newsrc-options "")
16588 (gnus-newsrc-parse-options gnus-newsrc-options))))
16590 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16591 ;; The return value will be a list on the form
16592 ;; ((regexp1 . ignore)
16593 ;; (regexp2 . subscribe)...)
16594 ;; When handling new newsgroups, groups that match a `ignore' regexp
16595 ;; will be ignored, and groups that match a `subscribe' regexp will be
16596 ;; subscribed. A line like
16597 ;; options -n !all rec.all
16598 ;; will lead to a list that looks like
16599 ;; (("^rec\\..+" . subscribe)
16600 ;; ("^.+" . ignore))
16601 ;; So all "rec.*" groups will be subscribed, while all the other
16602 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16603 ;; different from "options -n rec.all !all".
16604 (defun gnus-newsrc-parse-options (options)
16607 (gnus-set-work-buffer)
16608 (insert (regexp-quote options))
16609 ;; First we treat all continuation lines.
16610 (goto-char (point-min))
16611 (while (re-search-forward "\n[ \t]+" nil t)
16612 (replace-match " " t t))
16613 ;; Then we transform all "all"s into ".+"s.
16614 (goto-char (point-min))
16615 (while (re-search-forward "\\ball\\b" nil t)
16616 (replace-match ".+" t t))
16617 (goto-char (point-min))
16618 ;; We remove all other options than the "-n" ones.
16619 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16620 (replace-match " ")
16622 (goto-char (point-min))
16624 ;; We are only interested in "options -n" lines - we
16625 ;; ignore the other option lines.
16626 (while (re-search-forward "[ \t]-n" nil t)
16628 (or (save-excursion
16629 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16631 (gnus-point-at-eol)))
16632 ;; Search for all "words"...
16633 (while (re-search-forward "[^ \t,\n]+" eol t)
16634 (if (= (char-after (match-beginning 0)) ?!)
16635 ;; If the word begins with a bang (!), this is a "not"
16636 ;; spec. We put this spec (minus the bang) and the
16637 ;; symbol `ignore' into the list.
16638 (setq out (cons (cons (concat
16639 "^" (buffer-substring
16640 (1+ (match-beginning 0))
16643 ;; There was no bang, so this is a "yes" spec.
16644 (setq out (cons (cons (concat "^" (match-string 0))
16645 'subscribe) out)))))
16647 (setq gnus-newsrc-options-n out))))
16649 (defun gnus-save-newsrc-file (&optional force)
16650 "Save .newsrc file."
16651 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16652 ;; from the variable gnus-newsrc-alist.
16653 (when (and (or gnus-newsrc-alist gnus-killed-list)
16654 gnus-current-startup-file)
16656 (if (and (or gnus-use-dribble-file gnus-slave)
16658 (or (not gnus-dribble-buffer)
16659 (not (buffer-name gnus-dribble-buffer))
16660 (zerop (save-excursion
16661 (set-buffer gnus-dribble-buffer)
16663 (gnus-message 4 "(No changes need to be saved)")
16664 (run-hooks 'gnus-save-newsrc-hook)
16666 (gnus-slave-save-newsrc)
16668 (when gnus-save-newsrc-file
16669 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16670 (gnus-gnus-to-newsrc-format)
16671 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16672 ;; Save .newsrc.eld.
16673 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16674 (make-local-variable 'version-control)
16675 (setq version-control 'never)
16676 (setq buffer-file-name
16677 (concat gnus-current-startup-file ".eld"))
16678 (setq default-directory (file-name-directory buffer-file-name))
16679 (gnus-add-current-to-buffer-list)
16680 (buffer-disable-undo (current-buffer))
16682 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16683 (gnus-gnus-to-quick-newsrc-format)
16684 (run-hooks 'gnus-save-quick-newsrc-hook)
16686 (kill-buffer (current-buffer))
16688 5 "Saving %s.eld...done" gnus-current-startup-file))
16689 (gnus-dribble-delete-file)
16690 (gnus-group-set-mode-line)))))
16692 (defun gnus-gnus-to-quick-newsrc-format ()
16693 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16694 (insert ";; Gnus startup file.\n")
16695 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16696 (insert ";; to read .newsrc.\n")
16697 (insert "(setq gnus-newsrc-file-version "
16698 (prin1-to-string gnus-version) ")\n")
16700 (if gnus-save-killed-list gnus-variable-list
16701 ;; Remove the `gnus-killed-list' from the list of variables
16702 ;; to be saved, if required.
16703 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16704 ;; Peel off the "dummy" group.
16705 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16707 ;; Insert the variables into the file.
16709 (when (and (boundp (setq variable (pop variables)))
16710 (symbol-value variable))
16711 (insert "(setq " (symbol-name variable) " '")
16712 (prin1 (symbol-value variable) (current-buffer))
16715 (defun gnus-gnus-to-newsrc-format ()
16716 ;; Generate and save the .newsrc file.
16718 (set-buffer (create-file-buffer gnus-current-startup-file))
16719 (let ((newsrc (cdr gnus-newsrc-alist))
16720 (standard-output (current-buffer))
16721 info ranges range method)
16722 (setq buffer-file-name gnus-current-startup-file)
16723 (setq default-directory (file-name-directory buffer-file-name))
16724 (buffer-disable-undo (current-buffer))
16727 (if gnus-newsrc-options (insert gnus-newsrc-options))
16728 ;; Write subscribed and unsubscribed.
16729 (while (setq info (pop newsrc))
16730 ;; Don't write foreign groups to .newsrc.
16731 (when (or (null (setq method (gnus-info-method info)))
16732 (equal method "native")
16733 (gnus-server-equal method gnus-select-method))
16734 (insert (gnus-info-group info)
16735 (if (> (gnus-info-level info) gnus-level-subscribed)
16737 (when (setq ranges (gnus-info-read info))
16739 (if (not (listp (cdr ranges)))
16740 (if (= (car ranges) (cdr ranges))
16741 (princ (car ranges))
16742 (princ (car ranges))
16744 (princ (cdr ranges)))
16745 (while (setq range (pop ranges))
16746 (if (or (atom range) (= (car range) (cdr range)))
16747 (princ (or (and (atom range) range) (car range)))
16748 (princ (car range))
16750 (princ (cdr range)))
16751 (if ranges (insert ",")))))
16753 (make-local-variable 'version-control)
16754 (setq version-control 'never)
16755 ;; It has been reported that sometime the modtime on the .newsrc
16756 ;; file seems to be off. We really do want to overwrite it, so
16757 ;; we clear the modtime here before saving. It's a bit odd,
16759 ;; sometimes the modtime clear isn't sufficient. most brute force:
16760 ;; delete the silly thing entirely first. but this fails to provide
16761 ;; such niceties as .newsrc~ creation.
16762 (if gnus-modtime-botch
16763 (delete-file gnus-startup-file)
16764 (clear-visited-file-modtime))
16765 (run-hooks 'gnus-save-standard-newsrc-hook)
16767 (kill-buffer (current-buffer)))))
16771 ;;; Slave functions.
16774 (defun gnus-slave-save-newsrc ()
16776 (set-buffer gnus-dribble-buffer)
16778 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16779 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16781 (defun gnus-master-read-slave-newsrc ()
16784 (file-name-directory gnus-current-startup-file)
16788 (file-name-nondirectory gnus-current-startup-file)
16792 (if (not slave-files)
16793 () ; There are no slave files to read.
16794 (gnus-message 7 "Reading slave newsrcs...")
16796 (set-buffer (get-buffer-create " *gnus slave*"))
16797 (buffer-disable-undo (current-buffer))
16799 (sort (mapcar (lambda (file)
16800 (list (nth 5 (file-attributes file)) file))
16803 (or (< (caar f1) (caar f2))
16804 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16807 (setq file (nth 1 (car slave-files)))
16808 (insert-file-contents file)
16809 (if (condition-case ()
16811 (eval-buffer (current-buffer))
16814 (gnus-error 3.2 "Possible error in %s" file)
16816 (or gnus-slave ; Slaves shouldn't delete these files.
16820 (setq slave-files (cdr slave-files))))
16821 (gnus-message 7 "Reading slave newsrcs...done"))))
16825 ;;; Group description.
16828 (defun gnus-read-all-descriptions-files ()
16829 (let ((methods (cons gnus-select-method
16831 (when gnus-message-archive-method
16833 gnus-secondary-select-methods))))
16835 (gnus-read-descriptions-file (car methods))
16836 (setq methods (cdr methods)))
16839 (defun gnus-read-descriptions-file (&optional method)
16840 (let ((method (or method gnus-select-method)))
16841 (when (stringp method)
16842 (setq method (gnus-server-to-method method)))
16843 ;; We create the hashtable whether we manage to read the desc file
16844 ;; to avoid trying to re-read after a failed read.
16845 (or gnus-description-hashtb
16846 (setq gnus-description-hashtb
16847 (gnus-make-hashtable (length gnus-active-hashtb))))
16848 ;; Mark this method's desc file as read.
16849 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16850 gnus-description-hashtb)
16852 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16854 ((not (gnus-check-server method))
16855 (gnus-message 1 "Couldn't open server")
16857 ((not (gnus-request-list-newsgroups method))
16858 (gnus-message 1 "Couldn't read newsgroups descriptions")
16864 (set-buffer nntp-server-buffer)
16865 (goto-char (point-min))
16866 (if (or (search-forward "\n.\n" nil t)
16867 (goto-char (point-max)))
16869 (beginning-of-line)
16870 (narrow-to-region (point-min) (point))))
16871 (goto-char (point-min))
16872 (while (not (eobp))
16873 ;; If we get an error, we set group to 0, which is not a
16877 (let ((obarray gnus-description-hashtb))
16878 ;; Group is set to a symbol interned in this
16880 (read nntp-server-buffer))
16882 (skip-chars-forward " \t")
16883 ;; ... which leads to this line being effectively ignored.
16884 (and (symbolp group)
16885 (set group (buffer-substring
16886 (point) (progn (end-of-line) (point)))))
16887 (forward-line 1))))
16888 (gnus-message 5 "Reading descriptions file...done")
16891 (defun gnus-group-get-description (group)
16892 "Get the description of a group by sending XGTITLE to the server."
16893 (when (gnus-request-group-description group)
16895 (set-buffer nntp-server-buffer)
16896 (goto-char (point-min))
16897 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
16898 (match-string 1)))))
16902 ;;; Buffering of read articles.
16905 (defvar gnus-backlog-buffer " *Gnus Backlog*")
16906 (defvar gnus-backlog-articles nil)
16907 (defvar gnus-backlog-hashtb nil)
16909 (defun gnus-backlog-buffer ()
16910 "Return the backlog buffer."
16911 (or (get-buffer gnus-backlog-buffer)
16913 (set-buffer (get-buffer-create gnus-backlog-buffer))
16914 (buffer-disable-undo (current-buffer))
16915 (setq buffer-read-only t)
16916 (gnus-add-current-to-buffer-list)
16917 (get-buffer gnus-backlog-buffer))))
16919 (defun gnus-backlog-setup ()
16920 "Initialize backlog variables."
16921 (unless gnus-backlog-hashtb
16922 (setq gnus-backlog-hashtb (make-vector 1023 0))))
16924 (gnus-add-shutdown 'gnus-backlog-shutdown 'gnus)
16926 (defun gnus-backlog-shutdown ()
16927 "Clear all backlog variables and buffers."
16928 (when (get-buffer gnus-backlog-buffer)
16929 (kill-buffer gnus-backlog-buffer))
16930 (setq gnus-backlog-hashtb nil
16931 gnus-backlog-articles nil))
16933 (defun gnus-backlog-enter-article (group number buffer)
16934 (gnus-backlog-setup)
16935 (let ((ident (intern (concat group ":" (int-to-string number))
16936 gnus-backlog-hashtb))
16938 (if (memq ident gnus-backlog-articles)
16939 () ; It's already kept.
16940 ;; Remove the oldest article, if necessary.
16941 (and (numberp gnus-keep-backlog)
16942 (>= (length gnus-backlog-articles) gnus-keep-backlog)
16943 (gnus-backlog-remove-oldest-article))
16944 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
16945 ;; Insert the new article.
16947 (set-buffer (gnus-backlog-buffer))
16948 (let (buffer-read-only)
16949 (goto-char (point-max))
16950 (or (bolp) (insert "\n"))
16952 (insert-buffer-substring buffer)
16953 ;; Tag the beginning of the article with the ident.
16954 (gnus-put-text-property b (1+ b) 'gnus-backlog ident))))))
16956 (defun gnus-backlog-remove-oldest-article ()
16958 (set-buffer (gnus-backlog-buffer))
16959 (goto-char (point-min))
16960 (if (zerop (buffer-size))
16961 () ; The buffer is empty.
16962 (let ((ident (get-text-property (point) 'gnus-backlog))
16964 ;; Remove the ident from the list of articles.
16966 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16967 ;; Delete the article itself.
16969 (point) (next-single-property-change
16970 (1+ (point)) 'gnus-backlog nil (point-max)))))))
16972 (defun gnus-backlog-remove-article (group number)
16973 "Remove article NUMBER in GROUP from the backlog."
16974 (when (numberp number)
16975 (gnus-backlog-setup)
16976 (let ((ident (intern (concat group ":" (int-to-string number))
16977 gnus-backlog-hashtb))
16979 (when (memq ident gnus-backlog-articles)
16980 ;; It was in the backlog.
16982 (set-buffer (gnus-backlog-buffer))
16983 (let (buffer-read-only)
16984 (when (setq beg (text-property-any
16985 (point-min) (point-max) 'gnus-backlog
16987 ;; Find the end (i. e., the beginning of the next article).
16989 (next-single-property-change
16990 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))
16991 (delete-region beg end)
16995 (defun gnus-backlog-request-article (group number buffer)
16996 (when (numberp number)
16997 (gnus-backlog-setup)
16998 (let ((ident (intern (concat group ":" (int-to-string number))
16999 gnus-backlog-hashtb))
17001 (when (memq ident gnus-backlog-articles)
17002 ;; It was in the backlog.
17004 (set-buffer (gnus-backlog-buffer))
17005 (if (not (setq beg (text-property-any
17006 (point-min) (point-max) 'gnus-backlog
17008 ;; It wasn't in the backlog after all.
17010 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
17011 ;; Find the end (i. e., the beginning of the next article).
17013 (next-single-property-change
17014 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
17015 (let ((buffer-read-only nil))
17017 (insert-buffer-substring gnus-backlog-buffer beg end)
17020 ;; Allow redefinition of Gnus functions.
17022 (gnus-ems-redefine)
17026 ;;; gnus.el ends here