1 ;;; gnus.el --- a newsreader for GNU Emacs
2 ;; Copyright (C) 1987,88,89,90,93,94,95,96 Free Software Foundation, Inc.
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;; Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval '(run-hooks 'gnus-load-hook))
35 (eval-when-compile (require 'cl))
37 ;; Site dependent variables. These variables should be defined in
40 (defvar gnus-default-nntp-server nil
41 "Specify a default NNTP server.
42 This variable should be defined in paths.el, and should never be set
44 If you want to change servers, you should use `gnus-select-method'.
45 See the documentation to that variable.")
47 (defvar gnus-backup-default-subscribed-newsgroups
48 '("news.announce.newusers" "news.groups.questions" "gnu.emacs.gnus")
49 "Default default new newsgroups the first time Gnus is run.
50 Should be set in paths.el, and shouldn't be touched by the user.")
52 (defvar gnus-local-domain nil
53 "Local domain name without a host name.
54 The DOMAINNAME environment variable is used instead if it is defined.
55 If the `system-name' function returns the full Internet name, there is
56 no need to set this variable.")
58 (defvar gnus-local-organization nil
59 "String with a description of what organization (if any) the user belongs to.
60 The ORGANIZATION environment variable is used instead if it is defined.
61 If this variable contains a function, this function will be called
62 with the current newsgroup name as the argument. The function should
65 In any case, if the string (either in the variable, in the environment
66 variable, or returned by the function) is a file name, the contents of
67 this file will be used as the organization.")
69 (defvar gnus-use-generic-from nil
70 "If nil, the full host name will be the system name prepended to the domain name.
71 If this is a string, the full host name will be this string.
72 If this is non-nil, non-string, the domain name will be used as the
75 (defvar gnus-use-generic-path nil
76 "If nil, use the NNTP server name in the Path header.
77 If stringp, use this; if non-nil, use no host name (user name only).")
79 ;; Customization variables
81 ;; Don't touch this variable.
82 (defvar gnus-nntp-service "nntp"
83 "*NNTP service name (\"nntp\" or 119).
84 This is an obsolete variable, which is scarcely used. If you use an
85 nntp server for your newsgroup and want to change the port number
86 used to 899, you would say something along these lines:
88 (setq gnus-select-method '(nntp \"my.nntp.server\" (nntp-port-number 899)))")
90 (defvar gnus-nntpserver-file "/etc/nntpserver"
91 "*A file with only the name of the nntp server in it.")
93 ;; This function is used to check both the environment variable
94 ;; NNTPSERVER and the /etc/nntpserver file to see whether one can find
95 ;; an nntp server name default.
96 (defun gnus-getenv-nntpserver ()
97 (or (getenv "NNTPSERVER")
98 (and (file-readable-p gnus-nntpserver-file)
100 (set-buffer (get-buffer-create " *gnus nntp*"))
101 (buffer-disable-undo (current-buffer))
102 (insert-file-contents gnus-nntpserver-file)
103 (let ((name (buffer-string)))
105 (if (string-match "^[ \t\n]*$" name)
108 (kill-buffer (current-buffer))))))))
110 (defvar gnus-select-method
112 (list 'nntp (or (condition-case ()
113 (gnus-getenv-nntpserver)
115 (if (and gnus-default-nntp-server
116 (not (string= gnus-default-nntp-server "")))
117 gnus-default-nntp-server)
119 (if (or (null gnus-nntp-service)
120 (equal gnus-nntp-service "nntp"))
122 (list gnus-nntp-service)))
123 "*Default method for selecting a newsgroup.
124 This variable should be a list, where the first element is how the
125 news is to be fetched, the second is the address.
127 For instance, if you want to get your news via NNTP from
128 \"flab.flab.edu\", you could say:
130 (setq gnus-select-method '(nntp \"flab.flab.edu\"))
132 If you want to use your local spool, say:
134 (setq gnus-select-method (list 'nnspool (system-name)))
136 If you use this variable, you must set `gnus-nntp-server' to nil.
138 There is a lot more to know about select methods and virtual servers -
139 see the manual for details.")
141 (defvar gnus-message-archive-method
142 '(nnfolder "archive" (nnfolder-directory "~/Mail/archive/")
143 (nnfolder-active-file "~/Mail/archive/active")
144 (nnfolder-get-new-mail nil)
145 (nnfolder-inhibit-expiry t))
146 "*Method used for archiving messages you've sent.
147 This should be a mail method.")
149 (defvar gnus-refer-article-method nil
150 "*Preferred method for fetching an article by Message-ID.
151 If you are reading news from the local spool (with nnspool), fetching
152 articles by Message-ID is painfully slow. By setting this method to an
153 nntp method, you might get acceptable results.
155 The value of this variable must be a valid select method as discussed
156 in the documentation of `gnus-select-method'.")
158 (defvar gnus-secondary-select-methods nil
159 "*A list of secondary methods that will be used for reading news.
160 This is a list where each element is a complete select method (see
161 `gnus-select-method').
163 If, for instance, you want to read your mail with the nnml backend,
164 you could set this variable:
166 (setq gnus-secondary-select-methods '((nnml \"\")))")
168 (defvar gnus-secondary-servers nil
169 "*List of NNTP servers that the user can choose between interactively.
170 To make Gnus query you for a server, you have to give `gnus' a
171 non-numeric prefix - `C-u M-x gnus', in short.")
173 (defvar gnus-nntp-server nil
174 "*The name of the host running the NNTP server.
175 This variable is semi-obsolete. Use the `gnus-select-method'
178 (defvar gnus-startup-file "~/.newsrc"
179 "*Your `.newsrc' file.
180 `.newsrc-SERVER' will be used instead if that exists.")
182 (defvar gnus-init-file "~/.gnus"
183 "*Your Gnus elisp startup file.
184 If a file with the .el or .elc suffixes exist, it will be read
187 (defvar gnus-group-faq-directory
188 '("/ftp@mirrors.aol.com:/pub/rtfm/usenet/"
189 "/ftp@src.doc.ic.ac.uk:/usenet/news-FAQS/"
190 "/ftp@ftp.seas.gwu.edu:/pub/rtfm/"
191 "/ftp@rtfm.mit.edu:/pub/usenet/news.answers/"
192 "/ftp@ftp.uni-paderborn.de:/pub/FAQ/"
193 "/ftp@ftp.sunet.se:/pub/usenet/"
194 "/ftp@nctuccca.edu.tw:/USENET/FAQ/"
195 "/ftp@hwarang.postech.ac.kr:/pub/usenet/news.answers/"
196 "/ftp@ftp.hk.super.net:/mirror/faqs/")
197 "*Directory where the group FAQs are stored.
198 This will most commonly be on a remote machine, and the file will be
201 This variable can also be a list of directories. In that case, the
202 first element in the list will be used by default, and the others will
203 be used as backup sites.
205 Note that Gnus uses an aol machine as the default directory. If this
206 feels fundamentally unclean, just think of it as a way to finally get
207 something of value back from them.
209 If the default site is too slow, try one of these:
211 North America: mirrors.aol.com /pub/rtfm/usenet
212 ftp.seas.gwu.edu /pub/rtfm
213 rtfm.mit.edu /pub/usenet/news.answers
214 Europe: ftp.uni-paderborn.de /pub/FAQ
215 src.doc.ic.ac.uk /usenet/news-FAQS
216 ftp.sunet.se /pub/usenet
217 Asia: nctuccca.edu.tw /USENET/FAQ
218 hwarang.postech.ac.kr /pub/usenet/news.answers
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 (or (getenv "SAVEDIR") "~/News/")
283 "*Name of the directory articles will be saved in (default \"~/News\").
284 Initialized from the SAVEDIR environment variable.")
286 (defvar gnus-kill-files-directory (or (getenv "SAVEDIR") "~/News/")
287 "*Name of the directory where kill files will be stored (default \"~/News\").
288 Initialized from the SAVEDIR environment variable.")
290 (defvar gnus-default-article-saver 'gnus-summary-save-in-rmail
291 "*A function to save articles in your favorite format.
292 The function must be interactively callable (in other words, it must
293 be an Emacs command).
295 Gnus provides the following functions:
297 * gnus-summary-save-in-rmail (Rmail format)
298 * gnus-summary-save-in-mail (Unix mail format)
299 * gnus-summary-save-in-folder (MH folder)
300 * gnus-summary-save-in-file (article format).
301 * gnus-summary-save-in-vm (use VM's folder format).")
303 (defvar gnus-prompt-before-saving 'always
304 "*This variable says how much prompting is to be done when saving articles.
305 If it is nil, no prompting will be done, and the articles will be
306 saved to the default files. If this variable is `always', each and
307 every article that is saved will be preceded by a prompt, even when
308 saving large batches of articles. If this variable is neither nil not
309 `always', there the user will be prompted once for a file name for
310 each invocation of the saving commands.")
312 (defvar gnus-rmail-save-name (function gnus-plain-save-name)
313 "*A function generating a file name to save articles in Rmail format.
314 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
316 (defvar gnus-mail-save-name (function gnus-plain-save-name)
317 "*A function generating a file name to save articles in Unix mail format.
318 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE.")
320 (defvar gnus-folder-save-name (function gnus-folder-save-name)
321 "*A function generating a file name to save articles in MH folder.
322 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER.")
324 (defvar gnus-file-save-name (function gnus-numeric-save-name)
325 "*A function generating a file name to save articles in article format.
326 The function is called with NEWSGROUP, HEADERS, and optional
329 (defvar gnus-split-methods
330 '((gnus-article-archive-name))
331 "*Variable used to suggest where articles are to be saved.
332 For instance, if you would like to save articles related to Gnus in
333 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
334 you could set this variable to something like:
336 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
337 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
339 This variable is an alist where the where the key is the match and the
340 value is a list of possible files to save in if the match is non-nil.
342 If the match is a string, it is used as a regexp match on the
343 article. If the match is a symbol, that symbol will be funcalled
344 from the buffer of the article to be saved with the newsgroup as the
345 parameter. If it is a list, it will be evaled in the same buffer.
347 If this form or function returns a string, this string will be used as
348 a possible file name; and if it returns a non-nil list, that list will
349 be used as possible file names.")
351 (defvar gnus-move-split-methods nil
352 "*Variable used to suggest where articles are to be moved to.
353 It uses the same syntax as the `gnus-split-methods' variable.")
355 (defvar gnus-save-score nil
356 "*If non-nil, save group scoring info.")
358 (defvar gnus-use-adaptive-scoring nil
359 "*If non-nil, use some adaptive scoring scheme.")
361 (defvar gnus-use-cache nil
362 "*If nil, Gnus will ignore the article cache.
363 If `passive', it will allow entering (and reading) articles
364 explicitly entered into the cache. If anything else, use the
365 cache to the full extent of the law.")
367 (defvar gnus-use-trees nil
368 "*If non-nil, display a thread tree buffer.")
370 (defvar gnus-use-grouplens nil
371 "*If non-nil, use GroupLens ratings.")
373 (defvar gnus-keep-backlog nil
374 "*If non-nil, Gnus will keep read articles for later re-retrieval.
375 If it is a number N, then Gnus will only keep the last N articles
376 read. If it is neither nil nor a number, Gnus will keep all read
377 articles. This is not a good idea.")
379 (defvar gnus-use-nocem nil
380 "*If non-nil, Gnus will read NoCeM cancel messages.")
382 (defvar gnus-use-demon nil
383 "If non-nil, Gnus might use some demons.")
385 (defvar gnus-use-scoring t
386 "*If non-nil, enable scoring.")
388 (defvar gnus-use-picons nil
389 "*If non-nil, display picons.")
391 (defvar gnus-fetch-old-headers nil
392 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
393 If an unread article in the group refers to an older, already read (or
394 just marked as read) article, the old article will not normally be
395 displayed in the Summary buffer. If this variable is non-nil, Gnus
396 will attempt to grab the headers to the old articles, and thereby
397 build complete threads. If it has the value `some', only enough
398 headers to connect otherwise loose threads will be displayed.
399 This variable can also be a number. In that case, no more than that
400 number of old headers will be fetched.
402 The server has to support NOV for any of this to work.")
405 ;(defvar gnus-visual t
406 ; "*If non-nil, will do various highlighting.
407 ;If nil, no mouse highlights (or any other highlights) will be
408 ;performed. This might speed up Gnus some when generating large group
409 ;and summary buffers.")
411 (defvar gnus-novice-user t
412 "*Non-nil means that you are a usenet novice.
413 If non-nil, verbose messages may be displayed and confirmations may be
416 (defvar gnus-expert-user nil
417 "*Non-nil means that you will never be asked for confirmation about anything.
418 And that means *anything*.")
420 (defvar gnus-verbose 7
421 "*Integer that says how verbose Gnus should be.
422 The higher the number, the more messages Gnus will flash to say what
423 it's doing. At zero, Gnus will be totally mute; at five, Gnus will
424 display most important messages; and at ten, Gnus will keep on
425 jabbering all the time.")
427 (defvar gnus-keep-same-level nil
428 "*Non-nil means that the next newsgroup after the current will be on the same level.
429 When you type, for instance, `n' after reading the last article in the
430 current newsgroup, you will go to the next newsgroup. If this variable
431 is nil, the next newsgroup will be the next from the group
433 If this variable is non-nil, Gnus will either put you in the
434 next newsgroup with the same level, or, if no such newsgroup is
435 available, the next newsgroup with the lowest possible level higher
436 than the current level.
437 If this variable is `best', Gnus will make the next newsgroup the one
438 with the best level.")
440 (defvar gnus-summary-make-false-root 'adopt
441 "*nil means that Gnus won't gather loose threads.
442 If the root of a thread has expired or been read in a previous
443 session, the information necessary to build a complete thread has been
444 lost. Instead of having many small sub-threads from this original thread
445 scattered all over the summary buffer, Gnus can gather them.
447 If non-nil, Gnus will try to gather all loose sub-threads from an
448 original thread into one large thread.
450 If this variable is non-nil, it should be one of `none', `adopt',
453 If this variable is `none', Gnus will not make a false root, but just
454 present the sub-threads after another.
455 If this variable is `dummy', Gnus will create a dummy root that will
456 have all the sub-threads as children.
457 If this variable is `adopt', Gnus will make one of the \"children\"
458 the parent and mark all the step-children as such.
459 If this variable is `empty', the \"children\" are printed with empty
460 subject fields. (Or rather, they will be printed with a string
461 given by the `gnus-summary-same-subject' variable.)")
463 (defvar gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
464 "*A regexp to match subjects to be excluded from loose thread gathering.
465 As loose thread gathering is done on subjects only, that means that
466 there can be many false gatherings performed. By rooting out certain
467 common subjects, gathering might become saner.")
469 (defvar gnus-summary-gather-subject-limit nil
470 "*Maximum length of subject comparisons when gathering loose threads.
471 Use nil to compare full subjects. Setting this variable to a low
472 number will help gather threads that have been corrupted by
473 newsreaders chopping off subject lines, but it might also mean that
474 unrelated articles that have subject that happen to begin with the
475 same few characters will be incorrectly gathered.
477 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
478 comparing subjects.")
480 (defvar gnus-simplify-ignored-prefixes nil
481 "*Regexp, matches for which are removed from subject lines when simplifying.")
483 (defvar gnus-build-sparse-threads nil
484 "*If non-nil, fill in the gaps in threads.
485 If `some', only fill in the gaps that are needed to tie loose threads
486 together. If `more', fill in all leaf nodes that Gnus can find. If
487 non-nil and non-`some', fill in all gaps that Gnus manages to guess.")
489 (defvar gnus-summary-thread-gathering-function 'gnus-gather-threads-by-subject
490 "Function used for gathering loose threads.
491 There are two pre-defined functions: `gnus-gather-threads-by-subject',
492 which only takes Subjects into consideration; and
493 `gnus-gather-threads-by-references', which compared the References
494 headers of the articles to find matches.")
496 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
497 (defvar gnus-summary-same-subject ""
498 "*String indicating that the current article has the same subject as the previous.
499 This variable will only be used if the value of
500 `gnus-summary-make-false-root' is `empty'.")
502 (defvar gnus-summary-goto-unread t
503 "*If non-nil, marking commands will go to the next unread article.
504 If `never', \\<gnus-summary-mode-map>\\[gnus-summary-next-page] will go to the next article,
505 whether it is read or not.")
507 (defvar gnus-group-goto-unread t
508 "*If non-nil, movement commands will go to the next unread and subscribed group.")
510 (defvar gnus-goto-next-group-when-activating t
511 "*If non-nil, the \\<gnus-group-mode-map>\\[gnus-group-get-new-news-this-group] command will advance point to the next group.")
513 (defvar gnus-check-new-newsgroups t
514 "*Non-nil means that Gnus will add new newsgroups at startup.
515 If this variable is `ask-server', Gnus will ask the server for new
516 groups since the last time it checked. This means that the killed list
517 is no longer necessary, so you could set `gnus-save-killed-list' to
520 A variant is to have this variable be a list of select methods. Gnus
521 will then use the `ask-server' method on all these select methods to
522 query for new groups from all those servers.
525 (setq gnus-check-new-newsgroups
526 '((nntp \"some.server\") (nntp \"other.server\")))
528 If this variable is nil, then you have to tell Gnus explicitly to
529 check for new newsgroups with \\<gnus-group-mode-map>\\[gnus-find-new-newsgroups].")
531 (defvar gnus-check-bogus-newsgroups nil
532 "*Non-nil means that Gnus will check and remove bogus newsgroup at startup.
533 If this variable is nil, then you have to tell Gnus explicitly to
534 check for bogus newsgroups with \\<gnus-group-mode-map>\\[gnus-group-check-bogus-groups].")
536 (defvar gnus-read-active-file t
537 "*Non-nil means that Gnus will read the entire active file at startup.
538 If this variable is nil, Gnus will only know about the groups in your
541 If this variable is `some', Gnus will try to only read the relevant
542 parts of the active file from the server. Not all servers support
543 this, and it might be quite slow with other servers, but this should
544 generally be faster than both the t and nil value.
546 If you set this variable to nil or `some', you probably still want to
547 be told about new newsgroups that arrive. To do that, set
548 `gnus-check-new-newsgroups' to `ask-server'. This may not work
549 properly with all servers.")
551 (defvar gnus-level-subscribed 5
552 "*Groups with levels less than or equal to this variable are subscribed.")
554 (defvar gnus-level-unsubscribed 7
555 "*Groups with levels less than or equal to this variable are unsubscribed.
556 Groups with levels less than `gnus-level-subscribed', which should be
557 less than this variable, are subscribed.")
559 (defvar gnus-level-zombie 8
560 "*Groups with this level are zombie groups.")
562 (defvar gnus-level-killed 9
563 "*Groups with this level are killed.")
565 (defvar gnus-level-default-subscribed 3
566 "*New subscribed groups will be subscribed at this level.")
568 (defvar gnus-level-default-unsubscribed 6
569 "*New unsubscribed groups will be unsubscribed at this level.")
571 (defvar gnus-activate-level (1+ gnus-level-subscribed)
572 "*Groups higher than this level won't be activated on startup.
573 Setting this variable to something log might save lots of time when
574 you have many groups that you aren't interested in.")
576 (defvar gnus-activate-foreign-newsgroups 4
577 "*If nil, Gnus will not check foreign newsgroups at startup.
578 If it is non-nil, it should be a number between one and nine. Foreign
579 newsgroups that have a level lower or equal to this number will be
580 activated on startup. For instance, if you want to active all
581 subscribed newsgroups, but not the rest, you'd set this variable to
582 `gnus-level-subscribed'.
584 If you subscribe to lots of newsgroups from different servers, startup
585 might take a while. By setting this variable to nil, you'll save time,
586 but you won't be told how many unread articles there are in the
589 (defvar gnus-save-newsrc-file t
590 "*Non-nil means that Gnus will save the `.newsrc' file.
591 Gnus always saves its own startup file, which is called
592 \".newsrc.eld\". The file called \".newsrc\" is in a format that can
593 be readily understood by other newsreaders. If you don't plan on
594 using other newsreaders, set this variable to nil to save some time on
597 (defvar gnus-save-killed-list t
598 "*If non-nil, save the list of killed groups to the startup file.
599 If you set this variable to nil, you'll save both time (when starting
600 and quitting) and space (both memory and disk), but it will also mean
601 that Gnus has no record of which groups are new and which are old, so
602 the automatic new newsgroups subscription methods become meaningless.
604 You should always set `gnus-check-new-newsgroups' to `ask-server' or
605 nil if you set this variable to nil.")
607 (defvar gnus-interactive-catchup t
608 "*If non-nil, require your confirmation when catching up a group.")
610 (defvar gnus-interactive-post t
611 "*If non-nil, group name will be asked for when posting.")
613 (defvar gnus-interactive-exit t
614 "*If non-nil, require your confirmation when exiting Gnus.")
616 (defvar gnus-kill-killed t
617 "*If non-nil, Gnus will apply kill files to already killed articles.
618 If it is nil, Gnus will never apply kill files to articles that have
619 already been through the scoring process, which might very well save lots
622 (defvar gnus-extract-address-components 'gnus-extract-address-components
623 "*Function for extracting address components from a From header.
624 Two pre-defined function exist: `gnus-extract-address-components',
625 which is the default, quite fast, and too simplistic solution, and
626 `mail-extract-address-components', which works much better, but is
629 (defvar gnus-summary-default-score 0
630 "*Default article score level.
631 If this variable is nil, scoring will be disabled.")
633 (defvar gnus-summary-zcore-fuzz 0
634 "*Fuzziness factor for the zcore in the summary buffer.
635 Articles with scores closer than this to `gnus-summary-default-score'
636 will not be marked.")
638 (defvar gnus-simplify-subject-fuzzy-regexp nil
639 "*Strings to be removed when doing fuzzy matches.
640 This can either be a regular expression or list of regular expressions
641 that will be removed from subject strings if fuzzy subject
642 simplification is selected.")
644 (defvar gnus-permanently-visible-groups nil
645 "*Regexp to match groups that should always be listed in the group buffer.
646 This means that they will still be listed when there are no unread
647 articles in the groups.")
649 (defvar gnus-list-groups-with-ticked-articles t
650 "*If non-nil, list groups that have only ticked articles.
651 If nil, only list groups that have unread articles.")
653 (defvar gnus-group-default-list-level gnus-level-subscribed
654 "*Default listing level.
655 Ignored if `gnus-group-use-permanent-levels' is non-nil.")
657 (defvar gnus-group-use-permanent-levels nil
658 "*If non-nil, once you set a level, Gnus will use this level.")
660 (defvar gnus-group-list-inactive-groups t
661 "*If non-nil, inactive groups will be listed.")
663 (defvar gnus-show-mime nil
664 "*If non-nil, do mime processing of articles.
665 The articles will simply be fed to the function given by
666 `gnus-show-mime-method'.")
668 (defvar gnus-strict-mime t
669 "*If nil, MIME-decode even if there is no Mime-Version header in the article.")
671 (defvar gnus-show-mime-method 'metamail-buffer
672 "*Function to process a MIME message.
673 The function is called from the article buffer.")
675 (defvar gnus-decode-encoded-word-method (lambda ())
676 "*Function to decode a MIME encoded-words.
677 The function is called from the article buffer.")
679 (defvar gnus-show-threads t
680 "*If non-nil, display threads in summary mode.")
682 (defvar gnus-thread-hide-subtree nil
683 "*If non-nil, hide all threads initially.
684 If threads are hidden, you have to run the command
685 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
686 to expose hidden threads.")
688 (defvar gnus-thread-hide-killed t
689 "*If non-nil, hide killed threads automatically.")
691 (defvar gnus-thread-ignore-subject nil
692 "*If non-nil, ignore subjects and do all threading based on the Reference header.
693 If nil, which is the default, articles that have different subjects
694 from their parents will start separate threads.")
696 (defvar gnus-thread-operation-ignore-subject t
697 "*If non-nil, subjects will be ignored when doing thread commands.
698 This affects commands like `gnus-summary-kill-thread' and
699 `gnus-summary-lower-thread'.
701 If this variable is nil, articles in the same thread with different
702 subjects will not be included in the operation in question. If this
703 variable is `fuzzy', only articles that have subjects that are fuzzily
704 equal will be included.")
706 (defvar gnus-thread-indent-level 4
707 "*Number that says how much each sub-thread should be indented.")
709 (defvar gnus-ignored-newsgroups
710 (purecopy (mapconcat 'identity
711 '("^to\\." ; not "real" groups
712 "^[0-9. \t]+ " ; all digits in name
713 "[][\"#'()]" ; bogus characters
716 "*A regexp to match uninteresting newsgroups in the active file.
717 Any lines in the active file matching this regular expression are
718 removed from the newsgroup list before anything else is done to it,
719 thus making them effectively non-existent.")
721 (defvar gnus-ignored-headers
722 "^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:"
723 "*All headers that match this regexp will be hidden.
724 This variable can also be a list of regexps of headers to be ignored.
725 If `gnus-visible-headers' is non-nil, this variable will be ignored.")
727 (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-"
728 "*All headers that do not match this regexp will be hidden.
729 This variable can also be a list of regexp of headers to remain visible.
730 If this variable is non-nil, `gnus-ignored-headers' will be ignored.")
732 (defvar gnus-sorted-header-list
733 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" "^To:"
734 "^Cc:" "^Date:" "^Organization:")
735 "*This variable is a list of regular expressions.
736 If it is non-nil, headers that match the regular expressions will
737 be placed first in the article buffer in the sequence specified by
740 (defvar gnus-boring-article-headers
741 '(empty followup-to reply-to)
742 "*Headers that are only to be displayed if they have interesting data.
743 Possible values in this list are `empty', `newsgroups', `followup-to',
744 `reply-to', and `date'.")
746 (defvar gnus-show-all-headers nil
747 "*If non-nil, don't hide any headers.")
749 (defvar gnus-save-all-headers t
750 "*If non-nil, don't remove any headers before saving.")
752 (defvar gnus-saved-headers gnus-visible-headers
753 "*Headers to keep if `gnus-save-all-headers' is nil.
754 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
755 If that variable is nil, however, all headers that match this regexp
756 will be kept while the rest will be deleted before saving.")
758 (defvar gnus-inhibit-startup-message nil
759 "*If non-nil, the startup message will not be displayed.")
761 (defvar gnus-signature-separator "^-- *$"
762 "Regexp matching signature separator.")
764 (defvar gnus-signature-limit nil
765 "Provide a limit to what is considered a signature.
766 If it is a number, no signature may not be longer (in characters) than
767 that number. If it is a function, the function will be called without
768 any parameters, and if it returns nil, there is no signature in the
769 buffer. If it is a string, it will be used as a regexp. If it
770 matches, the text in question is not a signature.")
772 (defvar gnus-auto-extend-newsgroup t
773 "*If non-nil, extend newsgroup forward and backward when requested.")
775 (defvar gnus-auto-select-first t
776 "*If nil, don't select the first unread article when entering a group.
777 If this variable is `best', select the highest-scored unread article
778 in the group. If neither nil nor `best', select the first unread
781 If you want to prevent automatic selection of the first unread article
782 in some newsgroups, set the variable to nil in
783 `gnus-select-group-hook'.")
785 (defvar gnus-auto-select-next t
786 "*If non-nil, offer to go to the next group from the end of the previous.
787 If the value is t and the next newsgroup is empty, Gnus will exit
788 summary mode and go back to group mode. If the value is neither nil
789 nor t, Gnus will select the following unread newsgroup. In
790 particular, if the value is the symbol `quietly', the next unread
791 newsgroup will be selected without any confirmation, and if it is
792 `almost-quietly', the next group will be selected without any
793 confirmation if you are located on the last article in the group.
794 Finally, if this variable is `slightly-quietly', the `Z n' command
795 will go to the next group without confirmation.")
797 (defvar gnus-auto-select-same nil
798 "*If non-nil, select the next article with the same subject.")
800 (defvar gnus-summary-check-current nil
801 "*If non-nil, consider the current article when moving.
802 The \"unread\" movement commands will stay on the same line if the
803 current article is unread.")
805 (defvar gnus-auto-center-summary t
806 "*If non-nil, always center the current summary buffer.
807 In particular, if `vertical' do only vertical recentering. If non-nil
808 and non-`vertical', do both horizontal and vertical recentering.")
810 (defvar gnus-break-pages t
811 "*If non-nil, do page breaking on articles.
812 The page delimiter is specified by the `gnus-page-delimiter'
815 (defvar gnus-page-delimiter "^\^L"
816 "*Regexp describing what to use as article page delimiters.
817 The default value is \"^\^L\", which is a form linefeed at the
818 beginning of a line.")
820 (defvar gnus-use-full-window t
821 "*If non-nil, use the entire Emacs screen.")
823 (defvar gnus-window-configuration nil
824 "Obsolete variable. See `gnus-buffer-configuration'.")
826 (defvar gnus-window-min-width 2
827 "*Minimum width of Gnus buffers.")
829 (defvar gnus-window-min-height 1
830 "*Minimum height of Gnus buffers.")
832 (defvar gnus-buffer-configuration
836 (if gnus-carpal '(group-carpal 4))))
840 (if gnus-carpal '(summary-carpal 4))))
847 (if gnus-carpal '(summary-carpal 4))
849 (vertical ((height . 5) (width . 15)
851 (left . -1) (top . 1))
861 (if gnus-carpal '(summary-carpal 4))
862 (if gnus-use-trees '(tree 0.25))
867 (if gnus-carpal '(server-carpal 2))))
871 (if gnus-carpal '(browse-carpal 2))))
887 (article 1.0 point)))
898 (edit-group 1.0 point)))
902 (edit-server 1.0 point)))
906 (edit-score 1.0 point)))
933 (if gnus-carpal '(summary-carpal 4))
934 ("*Shell Command Output*" 1.0)))
942 "Window configuration for all possible Gnus buffers.
943 This variable is a list of lists. Each of these lists has a NAME and
944 a RULE. The NAMEs are commonsense names like `group', which names a
945 rule used when displaying the group buffer; `summary', which names a
946 rule for what happens when you enter a group and do not display an
947 article buffer; and so on. See the value of this variable for a
948 complete list of NAMEs.
950 Each RULE is a list of vectors. The first element in this vector is
951 the name of the buffer to be displayed; the second element is the
952 percentage of the screen this buffer is to occupy (a number in the
953 0.0-0.99 range); the optional third element is `point', which should
954 be present to denote which buffer point is to go to after making this
955 buffer configuration.")
957 (defvar gnus-window-to-buffer
958 '((group . gnus-group-buffer)
959 (summary . gnus-summary-buffer)
960 (article . gnus-article-buffer)
961 (server . gnus-server-buffer)
962 (browse . "*Gnus Browse Server*")
963 (edit-group . gnus-group-edit-buffer)
964 (edit-server . gnus-server-edit-buffer)
965 (group-carpal . gnus-carpal-group-buffer)
966 (summary-carpal . gnus-carpal-summary-buffer)
967 (server-carpal . gnus-carpal-server-buffer)
968 (browse-carpal . gnus-carpal-browse-buffer)
969 (edit-score . gnus-score-edit-buffer)
970 (mail . gnus-mail-buffer)
971 (post . gnus-post-news-buffer)
972 (faq . gnus-faq-buffer)
973 (picons . "*Picons*")
974 (tree . gnus-tree-buffer)
975 (info . gnus-info-buffer)
976 (article-copy . gnus-article-copy)
977 (draft . gnus-draft-buffer))
978 "Mapping from short symbols to buffer names or buffer variables.")
980 (defvar gnus-carpal nil
981 "*If non-nil, display clickable icons.")
983 (defvar gnus-subscribe-newsgroup-method 'gnus-subscribe-zombies
984 "*Function called with a group name when new group is detected.
985 A few pre-made functions are supplied: `gnus-subscribe-randomly'
986 inserts new groups at the beginning of the list of groups;
987 `gnus-subscribe-alphabetically' inserts new groups in strict
988 alphabetic order; `gnus-subscribe-hierarchically' inserts new groups
989 in hierarchical newsgroup order; `gnus-subscribe-interactively' asks
990 for your decision; `gnus-subscribe-killed' kills all new groups.")
992 ;; Suggested by a bug report by Hallvard B Furuseth.
993 ;; <h.b.furuseth@usit.uio.no>.
994 (defvar gnus-subscribe-options-newsgroup-method
995 (function gnus-subscribe-alphabetically)
996 "*This function is called to subscribe newsgroups mentioned on \"options -n\" lines.
997 If, for instance, you want to subscribe to all newsgroups in the
998 \"no\" and \"alt\" hierarchies, you'd put the following in your
1001 options -n no.all alt.all
1003 Gnus will the subscribe all new newsgroups in these hierarchies with
1004 the subscription method in this variable.")
1006 (defvar gnus-subscribe-hierarchical-interactive nil
1007 "*If non-nil, Gnus will offer to subscribe hierarchically.
1008 When a new hierarchy appears, Gnus will ask the user:
1010 'alt.binaries': Do you want to subscribe to this hierarchy? ([d]ys):
1012 If the user pressed `d', Gnus will descend the hierarchy, `y' will
1013 subscribe to all newsgroups in the hierarchy and `s' will skip this
1014 hierarchy in its entirety.")
1016 (defvar gnus-group-sort-function 'gnus-group-sort-by-alphabet
1017 "*Function used for sorting the group buffer.
1018 This function will be called with group info entries as the arguments
1019 for the groups to be sorted. Pre-made functions include
1020 `gnus-group-sort-by-alphabet', `gnus-group-sort-by-unread',
1021 `gnus-group-sort-by-level', `gnus-group-sort-by-score', and
1022 `gnus-group-sort-by-rank'.
1024 This variable can also be a list of sorting functions. In that case,
1025 the most significant sort function should be the last function in the
1028 ;; Mark variables suggested by Thomas Michanek
1029 ;; <Thomas.Michanek@telelogic.se>.
1030 (defvar gnus-unread-mark ?
1031 "*Mark used for unread articles.")
1032 (defvar gnus-ticked-mark ?!
1033 "*Mark used for ticked articles.")
1034 (defvar gnus-dormant-mark ??
1035 "*Mark used for dormant articles.")
1036 (defvar gnus-del-mark ?r
1037 "*Mark used for del'd articles.")
1038 (defvar gnus-read-mark ?R
1039 "*Mark used for read articles.")
1040 (defvar gnus-expirable-mark ?E
1041 "*Mark used for expirable articles.")
1042 (defvar gnus-killed-mark ?K
1043 "*Mark used for killed articles.")
1044 (defvar gnus-souped-mark ?F
1045 "*Mark used for killed articles.")
1046 (defvar gnus-kill-file-mark ?X
1047 "*Mark used for articles killed by kill files.")
1048 (defvar gnus-low-score-mark ?Y
1049 "*Mark used for articles with a low score.")
1050 (defvar gnus-catchup-mark ?C
1051 "*Mark used for articles that are caught up.")
1052 (defvar gnus-replied-mark ?A
1053 "*Mark used for articles that have been replied to.")
1054 (defvar gnus-cached-mark ?*
1055 "*Mark used for articles that are in the cache.")
1056 (defvar gnus-saved-mark ?S
1057 "*Mark used for articles that have been saved to.")
1058 (defvar gnus-process-mark ?#
1060 (defvar gnus-ancient-mark ?O
1061 "*Mark used for ancient articles.")
1062 (defvar gnus-sparse-mark ?Q
1063 "*Mark used for sparsely reffed articles.")
1064 (defvar gnus-canceled-mark ?G
1065 "*Mark used for canceled articles.")
1066 (defvar gnus-score-over-mark ?+
1067 "*Score mark used for articles with high scores.")
1068 (defvar gnus-score-below-mark ?-
1069 "*Score mark used for articles with low scores.")
1070 (defvar gnus-empty-thread-mark ?
1071 "*There is no thread under the article.")
1072 (defvar gnus-not-empty-thread-mark ?=
1073 "*There is a thread under the article.")
1075 (defvar gnus-view-pseudo-asynchronously nil
1076 "*If non-nil, Gnus will view pseudo-articles asynchronously.")
1078 (defvar gnus-view-pseudos nil
1079 "*If `automatic', pseudo-articles will be viewed automatically.
1080 If `not-confirm', pseudos will be viewed automatically, and the user
1081 will not be asked to confirm the command.")
1083 (defvar gnus-view-pseudos-separately t
1084 "*If non-nil, one pseudo-article will be created for each file to be viewed.
1085 If nil, all files that use the same viewing command will be given as a
1086 list of parameters to that command.")
1088 (defvar gnus-insert-pseudo-articles t
1089 "*If non-nil, insert pseudo-articles when decoding articles.")
1091 (defvar gnus-group-line-format "%M%S%p%P%5y: %(%g%)%l\n"
1092 "*Format of group lines.
1093 It works along the same lines as a normal formatting string,
1094 with some simple extensions.
1096 %M Only marked articles (character, \"*\" or \" \")
1097 %S Whether the group is subscribed (character, \"U\", \"K\", \"Z\" or \" \")
1098 %L Level of subscribedness (integer)
1099 %N Number of unread articles (integer)
1100 %I Number of dormant articles (integer)
1101 %i Number of ticked and dormant (integer)
1102 %T Number of ticked articles (integer)
1103 %R Number of read articles (integer)
1104 %t Total number of articles (integer)
1105 %y Number of unread, unticked articles (integer)
1106 %G Group name (string)
1107 %g Qualified group name (string)
1108 %D Group description (string)
1109 %s Select method (string)
1110 %o Moderated group (char, \"m\")
1111 %p Process mark (char)
1112 %O Moderated group (string, \"(m)\" or \"\")
1113 %P Topic indentation (string)
1114 %l Whether there are GroupLens predictions for this group (string)
1115 %n Select from where (string)
1116 %z A string that look like `<%s:%n>' if a foreign select method is used
1117 %u User defined specifier. The next character in the format string should
1118 be a letter. Gnus will call the function gnus-user-format-function-X,
1119 where X is the letter following %u. The function will be passed the
1120 current header as argument. The function should return a string, which
1121 will be inserted into the buffer just like information from any other
1124 Text between %( and %) will be highlighted with `gnus-mouse-face' when
1125 the mouse point move inside the area. There can only be one such area.
1127 Note that this format specification is not always respected. For
1128 reasons of efficiency, when listing killed groups, this specification
1129 is ignored altogether. If the spec is changed considerably, your
1130 output may end up looking strange when listing both alive and killed
1133 If you use %o or %O, reading the active file will be slower and quite
1134 a bit of extra memory will be used. %D will also worsen performance.
1135 Also note that if you change the format specification to include any
1136 of these specs, you must probably re-start Gnus to see them go into
1139 (defvar gnus-summary-line-format "%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n"
1140 "*The format specification of the lines in the summary buffer.
1142 It works along the same lines as a normal formatting string,
1143 with some simple extensions.
1145 %N Article number, left padded with spaces (string)
1147 %s Subject if it is at the root of a thread, and \"\" otherwise (string)
1148 %n Name of the poster (string)
1149 %a Extracted name of the poster (string)
1150 %A Extracted address of the poster (string)
1151 %F Contents of the From: header (string)
1152 %x Contents of the Xref: header (string)
1153 %D Date of the article (string)
1154 %d Date of the article (string) in DD-MMM format
1155 %M Message-id of the article (string)
1156 %r References of the article (string)
1157 %c Number of characters in the article (integer)
1158 %L Number of lines in the article (integer)
1159 %I Indentation based on thread level (a string of spaces)
1160 %T A string with two possible values: 80 spaces if the article
1161 is on thread level two or larger and 0 spaces on level one
1162 %R \"A\" if this article has been replied to, \" \" otherwise (character)
1163 %U Status of this article (character, \"R\", \"K\", \"-\" or \" \")
1164 %[ Opening bracket (character, \"[\" or \"<\")
1165 %] Closing bracket (character, \"]\" or \">\")
1166 %> Spaces of length thread-level (string)
1167 %< Spaces of length (- 20 thread-level) (string)
1168 %i Article score (number)
1169 %z Article zcore (character)
1170 %t Number of articles under the current thread (number).
1171 %e Whether the thread is empty or not (character).
1172 %l GroupLens score (number)
1173 %u User defined specifier. The next character in the format string should
1174 be a letter. Gnus will call the function gnus-user-format-function-X,
1175 where X is the letter following %u. The function will be passed the
1176 current header as argument. The function should return a string, which
1177 will be inserted into the summary just like information from any other
1180 Text between %( and %) will be highlighted with `gnus-mouse-face'
1181 when the mouse point is placed inside the area. There can only be one
1184 The %U (status), %R (replied) and %z (zcore) specs have to be handled
1185 with care. For reasons of efficiency, Gnus will compute what column
1186 these characters will end up in, and \"hard-code\" that. This means that
1187 it is illegal to have these specs after a variable-length spec. Well,
1188 you might not be arrested, but your summary buffer will look strange,
1189 which is bad enough.
1191 The smart choice is to have these specs as for to the left as
1194 This restriction may disappear in later versions of Gnus.")
1196 (defvar gnus-summary-dummy-line-format
1198 "*The format specification for the dummy roots in the summary buffer.
1199 It works along the same lines as a normal formatting string,
1200 with some simple extensions.
1204 (defvar gnus-summary-mode-line-format "Gnus: %%b [%A] %Z"
1205 "*The format specification for the summary mode line.
1206 It works along the same lines as a normal formatting string,
1207 with some simple extensions:
1210 %p Unprefixed group name
1211 %A Current article number
1213 %U Number of unread articles in the group
1214 %e Number of unselected articles in the group
1215 %Z A string with unread/unselected article counts
1216 %g Shortish group name
1217 %S Subject of the current article
1218 %u User-defined spec
1219 %s Current score file name
1220 %d Number of dormant articles
1221 %r Number of articles that have been marked as read in this session
1222 %E Number of articles expunged by the score files")
1224 (defvar gnus-article-mode-line-format "Gnus: %%b %S"
1225 "*The format specification for the article mode line.
1226 See `gnus-summary-mode-line-format' for a closer description.")
1228 (defvar gnus-group-mode-line-format "Gnus: %%b {%M:%S}"
1229 "*The format specification for the group mode line.
1230 It works along the same lines as a normal formatting string,
1231 with some simple extensions:
1233 %S The native news server.
1234 %M The native select method.")
1236 (defvar gnus-valid-select-methods
1237 '(("nntp" post address prompt-address)
1238 ("nnspool" post address)
1239 ("nnvirtual" post-mail virtual prompt-address)
1240 ("nnmbox" mail respool address)
1241 ("nnml" mail respool address)
1242 ("nnmh" mail respool address)
1243 ("nndir" post-mail prompt-address address)
1244 ("nneething" none address prompt-address)
1245 ("nndoc" none address prompt-address)
1246 ("nnbabyl" mail address respool)
1247 ("nnkiboze" post address virtual)
1248 ("nnsoup" post-mail address)
1249 ("nndraft" post-mail)
1250 ("nnfolder" mail respool address))
1251 "An alist of valid select methods.
1252 The first element of each list lists should be a string with the name
1253 of the select method. The other elements may be be the category of
1254 this method (ie. `post', `mail', `none' or whatever) or other
1255 properties that this method has (like being respoolable).
1256 If you implement a new select method, all you should have to change is
1257 this variable. I think.")
1259 (defvar gnus-updated-mode-lines '(group article summary tree)
1260 "*List of buffers that should update their mode lines.
1261 The list may contain the symbols `group', `article' and `summary'. If
1262 the corresponding symbol is present, Gnus will keep that mode line
1263 updated with information that may be pertinent.
1264 If this variable is nil, screen refresh may be quicker.")
1266 ;; Added by Keinonen Kari <kk85613@cs.tut.fi>.
1267 (defvar gnus-mode-non-string-length nil
1268 "*Max length of mode-line non-string contents.
1269 If this is nil, Gnus will take space as is needed, leaving the rest
1270 of the modeline intact.")
1273 ;(defvar gnus-mouse-face 'highlight
1274 ; "*Face used for mouse highlighting in Gnus.
1275 ;No mouse highlights will be done if `gnus-visual' is nil.")
1277 (defvar gnus-summary-mark-below nil
1278 "*Mark all articles with a score below this variable as read.
1279 This variable is local to each summary buffer and usually set by the
1282 (defvar gnus-article-sort-functions '(gnus-article-sort-by-number)
1283 "*List of functions used for sorting articles in the summary buffer.
1284 This variable is only used when not using a threaded display.")
1286 (defvar gnus-thread-sort-functions '(gnus-thread-sort-by-number)
1287 "*List of functions used for sorting threads in the summary buffer.
1288 By default, threads are sorted by article number.
1290 Each function takes two threads and return non-nil if the first thread
1291 should be sorted before the other. If you use more than one function,
1292 the primary sort function should be the last. You should probably
1293 always include `gnus-thread-sort-by-number' in the list of sorting
1294 functions -- preferably first.
1296 Ready-mady functions include `gnus-thread-sort-by-number',
1297 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
1298 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
1299 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').")
1301 (defvar gnus-thread-score-function '+
1302 "*Function used for calculating the total score of a thread.
1304 The function is called with the scores of the article and each
1305 subthread and should then return the score of the thread.
1307 Some functions you can use are `+', `max', or `min'.")
1309 (defvar gnus-summary-expunge-below nil
1310 "All articles that have a score less than this variable will be expunged.")
1312 (defvar gnus-thread-expunge-below nil
1313 "All threads that have a total score less than this variable will be expunged.
1314 See `gnus-thread-score-function' for en explanation of what a
1315 \"thread score\" is.")
1317 (defvar gnus-auto-subscribed-groups
1318 "^nnml\\|^nnfolder\\|^nnmbox\\|^nnmh\\|^nnbabyl"
1319 "*All new groups that match this regexp will be subscribed automatically.
1320 Note that this variable only deals with new groups. It has no effect
1321 whatsoever on old groups.")
1323 (defvar gnus-options-subscribe nil
1324 "*All new groups matching this regexp will be subscribed unconditionally.
1325 Note that this variable deals only with new newsgroups. This variable
1326 does not affect old newsgroups.")
1328 (defvar gnus-options-not-subscribe nil
1329 "*All new groups matching this regexp will be ignored.
1330 Note that this variable deals only with new newsgroups. This variable
1331 does not affect old (already subscribed) newsgroups.")
1333 (defvar gnus-auto-expirable-newsgroups nil
1334 "*Groups in which to automatically mark read articles as expirable.
1335 If non-nil, this should be a regexp that should match all groups in
1336 which to perform auto-expiry. This only makes sense for mail groups.")
1338 (defvar gnus-total-expirable-newsgroups nil
1339 "*Groups in which to perform expiry of all read articles.
1340 Use with extreme caution. All groups that match this regexp will be
1341 expiring - which means that all read articles will be deleted after
1342 (say) one week. (This only goes for mail groups and the like, of
1345 (defvar gnus-group-uncollapsed-levels 1
1346 "Number of group name elements to leave alone when making a short group name.")
1348 (defvar gnus-hidden-properties '(invisible t intangible t)
1349 "Property list to use for hiding text.")
1351 (defvar gnus-modtime-botch nil
1352 "*Non-nil means .newsrc should be deleted prior to save. Its use is
1353 due to the bogus appearance that .newsrc was modified on disc.")
1357 (defvar gnus-group-mode-hook nil
1358 "*A hook for Gnus group mode.")
1360 (defvar gnus-summary-mode-hook nil
1361 "*A hook for Gnus summary mode.
1362 This hook is run before any variables are set in the summary buffer.")
1364 (defvar gnus-article-mode-hook nil
1365 "*A hook for Gnus article mode.")
1367 (defvar gnus-summary-prepare-exit-hook nil
1368 "*A hook called when preparing to exit from the summary buffer.
1369 It calls `gnus-summary-expire-articles' by default.")
1370 (add-hook 'gnus-summary-prepare-exit-hook 'gnus-summary-expire-articles)
1372 (defvar gnus-summary-exit-hook nil
1373 "*A hook called on exit from the summary buffer.")
1375 (defvar gnus-group-catchup-group-hook nil
1376 "*A hook run when catching up a group from the group buffer.")
1378 (defvar gnus-open-server-hook nil
1379 "*A hook called just before opening connection to the news server.")
1381 (defvar gnus-load-hook nil
1382 "*A hook run while Gnus is loaded.")
1384 (defvar gnus-startup-hook nil
1385 "*A hook called at startup.
1386 This hook is called after Gnus is connected to the NNTP server.")
1388 (defvar gnus-get-new-news-hook nil
1389 "*A hook run just before Gnus checks for new news.")
1391 (defvar gnus-after-getting-new-news-hook nil
1392 "*A hook run after Gnus checks for new news.")
1394 (defvar gnus-group-prepare-function 'gnus-group-prepare-flat
1395 "*A function that is called to generate the group buffer.
1396 The function is called with three arguments: The first is a number;
1397 all group with a level less or equal to that number should be listed,
1398 if the second is non-nil, empty groups should also be displayed. If
1399 the third is non-nil, it is a number. No groups with a level lower
1400 than this number should be displayed.
1402 The only current function implemented is `gnus-group-prepare-flat'.")
1404 (defvar gnus-group-prepare-hook nil
1405 "*A hook called after the group buffer has been generated.
1406 If you want to modify the group buffer, you can use this hook.")
1408 (defvar gnus-summary-prepare-hook nil
1409 "*A hook called after the summary buffer has been generated.
1410 If you want to modify the summary buffer, you can use this hook.")
1412 (defvar gnus-summary-generate-hook nil
1413 "*A hook run just before generating the summary buffer.
1414 This hook is commonly used to customize threading variables and the
1417 (defvar gnus-article-prepare-hook nil
1418 "*A hook called after an article has been prepared in the article buffer.
1419 If you want to run a special decoding program like nkf, use this hook.")
1421 ;(defvar gnus-article-display-hook nil
1422 ; "*A hook called after the article is displayed in the article buffer.
1423 ;The hook is designed to change the contents of the article
1424 ;buffer. Typical functions that this hook may contain are
1425 ;`gnus-article-hide-headers' (hide selected headers),
1426 ;`gnus-article-maybe-highlight' (perform fancy article highlighting),
1427 ;`gnus-article-hide-signature' (hide signature) and
1428 ;`gnus-article-treat-overstrike' (turn \"^H_\" into bold characters).")
1429 ;(add-hook 'gnus-article-display-hook 'gnus-article-hide-headers-if-wanted)
1430 ;(add-hook 'gnus-article-display-hook 'gnus-article-treat-overstrike)
1431 ;(add-hook 'gnus-article-display-hook 'gnus-article-maybe-highlight)
1433 (defvar gnus-article-x-face-command
1434 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
1435 "String or function to be executed to display an X-Face header.
1436 If it is a string, the command will be executed in a sub-shell
1437 asynchronously. The compressed face will be piped to this command.")
1439 (defvar gnus-article-x-face-too-ugly nil
1440 "Regexp matching posters whose face shouldn't be shown automatically.")
1442 (defvar gnus-select-group-hook nil
1443 "*A hook called when a newsgroup is selected.
1445 If you'd like to simplify subjects like the
1446 `gnus-summary-next-same-subject' command does, you can use the
1449 (setq gnus-select-group-hook
1452 (mapcar (lambda (header)
1453 (mail-header-set-subject
1455 (gnus-simplify-subject
1456 (mail-header-subject header) 're-only)))
1457 gnus-newsgroup-headers))))")
1459 (defvar gnus-select-article-hook nil
1460 "*A hook called when an article is selected.")
1462 (defvar gnus-apply-kill-hook '(gnus-apply-kill-file)
1463 "*A hook called to apply kill files to a group.
1464 This hook is intended to apply a kill file to the selected newsgroup.
1465 The function `gnus-apply-kill-file' is called by default.
1467 Since a general kill file is too heavy to use only for a few
1468 newsgroups, I recommend you to use a lighter hook function. For
1469 example, if you'd like to apply a kill file to articles which contains
1470 a string `rmgroup' in subject in newsgroup `control', you can use the
1473 (setq gnus-apply-kill-hook
1476 (cond ((string-match \"control\" gnus-newsgroup-name)
1477 (gnus-kill \"Subject\" \"rmgroup\")
1478 (gnus-expunge \"X\"))))))")
1480 (defvar gnus-visual-mark-article-hook
1481 (list 'gnus-highlight-selected-summary)
1482 "*Hook run after selecting an article in the summary buffer.
1483 It is meant to be used for highlighting the article in some way. It
1484 is not run if `gnus-visual' is nil.")
1486 (defvar gnus-parse-headers-hook nil
1487 "*A hook called before parsing the headers.")
1489 (defvar gnus-exit-group-hook nil
1490 "*A hook called when exiting (not quitting) summary mode.")
1492 (defvar gnus-suspend-gnus-hook nil
1493 "*A hook called when suspending (not exiting) Gnus.")
1495 (defvar gnus-exit-gnus-hook nil
1496 "*A hook called when exiting Gnus.")
1498 (defvar gnus-after-exiting-gnus-hook nil
1499 "*A hook called after exiting Gnus.")
1501 (defvar gnus-save-newsrc-hook nil
1502 "*A hook called before saving any of the newsrc files.")
1504 (defvar gnus-save-quick-newsrc-hook nil
1505 "*A hook called just before saving the quick newsrc file.
1506 Can be used to turn version control on or off.")
1508 (defvar gnus-save-standard-newsrc-hook nil
1509 "*A hook called just before saving the standard newsrc file.
1510 Can be used to turn version control on or off.")
1512 (defvar gnus-summary-update-hook
1513 (list 'gnus-summary-highlight-line)
1514 "*A hook called when a summary line is changed.
1515 The hook will not be called if `gnus-visual' is nil.
1517 The default function `gnus-summary-highlight-line' will
1518 highlight the line according to the `gnus-summary-highlight'
1521 (defvar gnus-group-update-hook '(gnus-group-highlight-line)
1522 "*A hook called when a group line is changed.
1523 The hook will not be called if `gnus-visual' is nil.
1525 The default function `gnus-group-highlight-line' will
1526 highlight the line according to the `gnus-group-highlight'
1529 (defvar gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1530 "*A hook called when an article is selected for the first time.
1531 The hook is intended to mark an article as read (or unread)
1532 automatically when it is selected.")
1534 (defvar gnus-group-change-level-function nil
1535 "Function run when a group level is changed.
1536 It is called with three parameters -- GROUP, LEVEL and OLDLEVEL.")
1538 ;; Remove any hilit infestation.
1539 (add-hook 'gnus-startup-hook
1541 (remove-hook 'gnus-summary-prepare-hook
1542 'hilit-rehighlight-buffer-quietly)
1543 (remove-hook 'gnus-summary-prepare-hook 'hilit-install-line-hooks)
1544 (setq gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read))
1545 (remove-hook 'gnus-article-prepare-hook
1546 'hilit-rehighlight-buffer-quietly)))
1549 ;; Internal variables
1551 (defvar gnus-server-alist nil
1552 "List of available servers.")
1554 (defvar gnus-topic-active-topology nil)
1555 (defvar gnus-topic-active-alist nil)
1557 (defvar gnus-topic-indentation "") ;; Obsolete variable.
1559 (defvar gnus-goto-missing-group-function nil)
1561 (defvar gnus-override-subscribe-method nil)
1563 (defvar gnus-group-goto-next-group-function nil
1564 "Function to override finding the next group after listing groups.")
1566 (defconst gnus-article-mark-lists
1567 '((marked . tick) (replied . reply)
1568 (expirable . expire) (killed . killed)
1569 (bookmarks . bookmark) (dormant . dormant)
1570 (scored . score) (saved . save)
1574 ;; Avoid highlighting in kill files.
1575 (defvar gnus-summary-inhibit-highlight nil)
1576 (defvar gnus-newsgroup-selected-overlay nil)
1578 (defvar gnus-inhibit-hiding nil)
1579 (defvar gnus-group-indentation "")
1580 (defvar gnus-inhibit-limiting nil)
1581 (defvar gnus-created-frames nil)
1583 (defvar gnus-article-mode-map nil)
1584 (defvar gnus-dribble-buffer nil)
1585 (defvar gnus-headers-retrieved-by nil)
1586 (defvar gnus-article-reply nil)
1587 (defvar gnus-override-method nil)
1588 (defvar gnus-article-check-size nil)
1590 (defvar gnus-current-score-file nil)
1591 (defvar gnus-newsgroup-adaptive-score-file nil)
1592 (defvar gnus-scores-exclude-files nil)
1594 (defvar gnus-opened-servers nil)
1596 (defvar gnus-current-move-group nil)
1598 (defvar gnus-newsgroup-dependencies nil)
1599 (defvar gnus-newsgroup-async nil)
1600 (defconst gnus-group-edit-buffer "*Gnus edit newsgroup*")
1602 (defvar gnus-newsgroup-adaptive nil)
1604 (defvar gnus-summary-display-table nil)
1605 (defvar gnus-summary-display-article-function nil)
1607 (defvar gnus-summary-highlight-line-function nil
1608 "Function called after highlighting a summary line.")
1610 (defvar gnus-group-line-format-alist
1611 `((?M gnus-tmp-marked-mark ?c)
1612 (?S gnus-tmp-subscribed ?c)
1613 (?L gnus-tmp-level ?d)
1614 (?N (cond ((eq number t) "*" )
1618 (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1619 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))))))
1621 (?R gnus-tmp-number-of-read ?s)
1622 (?t gnus-tmp-number-total ?d)
1623 (?y gnus-tmp-number-of-unread ?s)
1624 (?I (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked))) ?d)
1625 (?T (gnus-range-length (cdr (assq 'tick gnus-tmp-marked))) ?d)
1626 (?i (+ (gnus-range-length (cdr (assq 'dormant gnus-tmp-marked)))
1627 (gnus-range-length (cdr (assq 'tick gnus-tmp-marked)))) ?d)
1628 (?g gnus-tmp-group ?s)
1629 (?G gnus-tmp-qualified-group ?s)
1630 (?c (gnus-short-group-name gnus-tmp-group) ?s)
1631 (?D gnus-tmp-newsgroup-description ?s)
1632 (?o gnus-tmp-moderated ?c)
1633 (?O gnus-tmp-moderated-string ?s)
1634 (?p gnus-tmp-process-marked ?c)
1635 (?s gnus-tmp-news-server ?s)
1636 (?n gnus-tmp-news-method ?s)
1637 (?P gnus-group-indentation ?s)
1638 (?l gnus-tmp-grouplens ?s)
1639 (?z gnus-tmp-news-method-string ?s)
1640 (?u gnus-tmp-user-defined ?s)))
1642 (defvar gnus-summary-line-format-alist
1643 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1644 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1645 (?s gnus-tmp-subject-or-nil ?s)
1646 (?n gnus-tmp-name ?s)
1647 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1649 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1651 (?F gnus-tmp-from ?s)
1652 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1653 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1654 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1655 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1656 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1657 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1658 (?L gnus-tmp-lines ?d)
1659 (?I gnus-tmp-indentation ?s)
1660 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1661 (?R gnus-tmp-replied ?c)
1662 (?\[ gnus-tmp-opening-bracket ?c)
1663 (?\] gnus-tmp-closing-bracket ?c)
1664 (?\> (make-string gnus-tmp-level ? ) ?s)
1665 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1666 (?i gnus-tmp-score ?d)
1667 (?z gnus-tmp-score-char ?c)
1668 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1669 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1670 (?U gnus-tmp-unread ?c)
1671 (?t (gnus-summary-number-of-articles-in-thread
1672 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1674 (?e (gnus-summary-number-of-articles-in-thread
1675 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1677 (?u gnus-tmp-user-defined ?s))
1678 "An alist of format specifications that can appear in summary lines,
1679 and what variables they correspond with, along with the type of the
1680 variable (string, integer, character, etc).")
1682 (defvar gnus-summary-dummy-line-format-alist
1683 `((?S gnus-tmp-subject ?s)
1684 (?N gnus-tmp-number ?d)
1685 (?u gnus-tmp-user-defined ?s)))
1687 (defvar gnus-summary-mode-line-format-alist
1688 `((?G gnus-tmp-group-name ?s)
1689 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1690 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1691 (?A gnus-tmp-article-number ?d)
1692 (?Z gnus-tmp-unread-and-unselected ?s)
1693 (?V gnus-version ?s)
1694 (?U gnus-tmp-unread ?d)
1695 (?S gnus-tmp-subject ?s)
1696 (?e gnus-tmp-unselected ?d)
1697 (?u gnus-tmp-user-defined ?s)
1698 (?d (length gnus-newsgroup-dormant) ?d)
1699 (?t (length gnus-newsgroup-marked) ?d)
1700 (?r (length gnus-newsgroup-reads) ?d)
1701 (?E gnus-newsgroup-expunged-tally ?d)
1702 (?s (gnus-current-score-file-nondirectory) ?s)))
1704 (defvar gnus-article-mode-line-format-alist
1705 gnus-summary-mode-line-format-alist)
1707 (defvar gnus-group-mode-line-format-alist
1708 `((?S gnus-tmp-news-server ?s)
1709 (?M gnus-tmp-news-method ?s)
1710 (?u gnus-tmp-user-defined ?s)))
1712 (defvar gnus-have-read-active-file nil)
1714 (defconst gnus-maintainer
1715 "gnus-bug@ifi.uio.no (The Gnus Bugfixing Girls + Boys)"
1716 "The mail address of the Gnus maintainers.")
1718 (defconst gnus-version "September Gnus v0.50"
1719 "Version number for this version of Gnus.")
1721 (defvar gnus-info-nodes
1722 '((gnus-group-mode "(gnus)The Group Buffer")
1723 (gnus-summary-mode "(gnus)The Summary Buffer")
1724 (gnus-article-mode "(gnus)The Article Buffer"))
1725 "Assoc list of major modes and related Info nodes.")
1727 (defvar gnus-group-buffer "*Group*")
1728 (defvar gnus-summary-buffer "*Summary*")
1729 (defvar gnus-article-buffer "*Article*")
1730 (defvar gnus-server-buffer "*Server*")
1732 (defvar gnus-work-buffer " *gnus work*")
1734 (defvar gnus-original-article-buffer " *Original Article*")
1735 (defvar gnus-original-article nil)
1737 (defvar gnus-buffer-list nil
1738 "Gnus buffers that should be killed on exit.")
1740 (defvar gnus-slave nil
1741 "Whether this Gnus is a slave or not.")
1743 (defvar gnus-variable-list
1744 '(gnus-newsrc-options gnus-newsrc-options-n
1745 gnus-newsrc-last-checked-date
1746 gnus-newsrc-alist gnus-server-alist
1747 gnus-killed-list gnus-zombie-list
1748 gnus-topic-topology gnus-topic-alist
1750 "Gnus variables saved in the quick startup file.")
1752 (defvar gnus-newsrc-options nil
1753 "Options line in the .newsrc file.")
1755 (defvar gnus-newsrc-options-n nil
1756 "List of regexps representing groups to be subscribed/ignored unconditionally.")
1758 (defvar gnus-newsrc-last-checked-date nil
1759 "Date Gnus last asked server for new newsgroups.")
1761 (defvar gnus-topic-topology nil
1762 "The complete topic hierarchy.")
1764 (defvar gnus-topic-alist nil
1765 "The complete topic-group alist.")
1767 (defvar gnus-newsrc-alist nil
1768 "Assoc list of read articles.
1769 gnus-newsrc-hashtb should be kept so that both hold the same information.")
1771 (defvar gnus-newsrc-hashtb nil
1772 "Hashtable of gnus-newsrc-alist.")
1774 (defvar gnus-killed-list nil
1775 "List of killed newsgroups.")
1777 (defvar gnus-killed-hashtb nil
1778 "Hash table equivalent of gnus-killed-list.")
1780 (defvar gnus-zombie-list nil
1781 "List of almost dead newsgroups.")
1783 (defvar gnus-description-hashtb nil
1784 "Descriptions of newsgroups.")
1786 (defvar gnus-list-of-killed-groups nil
1787 "List of newsgroups that have recently been killed by the user.")
1789 (defvar gnus-active-hashtb nil
1790 "Hashtable of active articles.")
1792 (defvar gnus-moderated-list nil
1793 "List of moderated newsgroups.")
1795 (defvar gnus-group-marked nil)
1797 (defvar gnus-current-startup-file nil
1798 "Startup file for the current host.")
1800 (defvar gnus-last-search-regexp nil
1801 "Default regexp for article search command.")
1803 (defvar gnus-last-shell-command nil
1804 "Default shell command on article.")
1806 (defvar gnus-current-select-method nil
1807 "The current method for selecting a newsgroup.")
1809 (defvar gnus-group-list-mode nil)
1811 (defvar gnus-article-internal-prepare-hook nil)
1813 (defvar gnus-newsgroup-name nil)
1814 (defvar gnus-newsgroup-begin nil)
1815 (defvar gnus-newsgroup-end nil)
1816 (defvar gnus-newsgroup-last-rmail nil)
1817 (defvar gnus-newsgroup-last-mail nil)
1818 (defvar gnus-newsgroup-last-folder nil)
1819 (defvar gnus-newsgroup-last-file nil)
1820 (defvar gnus-newsgroup-auto-expire nil)
1821 (defvar gnus-newsgroup-active nil)
1823 (defvar gnus-newsgroup-data nil)
1824 (defvar gnus-newsgroup-data-reverse nil)
1825 (defvar gnus-newsgroup-limit nil)
1826 (defvar gnus-newsgroup-limits nil)
1828 (defvar gnus-newsgroup-unreads nil
1829 "List of unread articles in the current newsgroup.")
1831 (defvar gnus-newsgroup-unselected nil
1832 "List of unselected unread articles in the current newsgroup.")
1834 (defvar gnus-newsgroup-reads nil
1835 "Alist of read articles and article marks in the current newsgroup.")
1837 (defvar gnus-newsgroup-expunged-tally nil)
1839 (defvar gnus-newsgroup-marked nil
1840 "List of ticked articles in the current newsgroup (a subset of unread art).")
1842 (defvar gnus-newsgroup-killed nil
1843 "List of ranges of articles that have been through the scoring process.")
1845 (defvar gnus-newsgroup-cached nil
1846 "List of articles that come from the article cache.")
1848 (defvar gnus-newsgroup-saved nil
1849 "List of articles that have been saved.")
1851 (defvar gnus-newsgroup-kill-headers nil)
1853 (defvar gnus-newsgroup-replied nil
1854 "List of articles that have been replied to in the current newsgroup.")
1856 (defvar gnus-newsgroup-expirable nil
1857 "List of articles in the current newsgroup that can be expired.")
1859 (defvar gnus-newsgroup-processable nil
1860 "List of articles in the current newsgroup that can be processed.")
1862 (defvar gnus-newsgroup-bookmarks nil
1863 "List of articles in the current newsgroup that have bookmarks.")
1865 (defvar gnus-newsgroup-dormant nil
1866 "List of dormant articles in the current newsgroup.")
1868 (defvar gnus-newsgroup-scored nil
1869 "List of scored articles in the current newsgroup.")
1871 (defvar gnus-newsgroup-headers nil
1872 "List of article headers in the current newsgroup.")
1874 (defvar gnus-newsgroup-threads nil)
1876 (defvar gnus-newsgroup-prepared nil
1877 "Whether the current group has been prepared properly.")
1879 (defvar gnus-newsgroup-ancient nil
1880 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1882 (defvar gnus-newsgroup-sparse nil)
1884 (defvar gnus-current-article nil)
1885 (defvar gnus-article-current nil)
1886 (defvar gnus-current-headers nil)
1887 (defvar gnus-have-all-headers nil)
1888 (defvar gnus-last-article nil)
1889 (defvar gnus-newsgroup-history nil)
1890 (defvar gnus-current-kill-article nil)
1892 ;; Save window configuration.
1893 (defvar gnus-prev-winconf nil)
1895 (defvar gnus-summary-mark-positions nil)
1896 (defvar gnus-group-mark-positions nil)
1898 (defvar gnus-reffed-article-number nil)
1900 ;;; Let the byte-compiler know that we know about this variable.
1901 (defvar rmail-default-rmail-file)
1903 (defvar gnus-cache-removable-articles nil)
1905 (defvar gnus-dead-summary nil)
1907 (defconst gnus-summary-local-variables
1908 '(gnus-newsgroup-name
1909 gnus-newsgroup-begin gnus-newsgroup-end
1910 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1911 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1912 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1913 gnus-newsgroup-unselected gnus-newsgroup-marked
1914 gnus-newsgroup-reads gnus-newsgroup-saved
1915 gnus-newsgroup-replied gnus-newsgroup-expirable
1916 gnus-newsgroup-processable gnus-newsgroup-killed
1917 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1918 gnus-newsgroup-headers gnus-newsgroup-threads
1919 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1920 gnus-current-article gnus-current-headers gnus-have-all-headers
1921 gnus-last-article gnus-article-internal-prepare-hook
1922 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1923 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1924 gnus-newsgroup-async
1925 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1926 gnus-summary-mark-below gnus-newsgroup-active gnus-scores-exclude-files
1927 gnus-newsgroup-history gnus-newsgroup-ancient
1928 gnus-newsgroup-sparse
1929 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1930 gnus-newsgroup-adaptive-score-file
1931 (gnus-newsgroup-expunged-tally . 0)
1932 gnus-cache-removable-articles gnus-newsgroup-cached
1933 gnus-newsgroup-data gnus-newsgroup-data-reverse
1934 gnus-newsgroup-limit gnus-newsgroup-limits)
1935 "Variables that are buffer-local to the summary buffers.")
1937 (defconst gnus-bug-message
1938 "Sending a bug report to the Gnus Towers.
1939 ========================================
1941 The buffer below is a mail buffer. When you press `C-c C-c', it will
1942 be sent to the Gnus Bug Exterminators.
1944 At the bottom of the buffer you'll see lots of variable settings.
1945 Please do not delete those. They will tell the Bug People what your
1946 environment is, so that it will be easier to locate the bugs.
1948 If you have found a bug that makes Emacs go \"beep\", set
1949 debug-on-error to t (`M-x set-variable RET debug-on-error RET t RET')
1950 and include the backtrace in your bug report.
1952 Please describe the bug in annoying, painstaking detail.
1954 Thank you for your help in stamping out bugs.
1957 ;;; End of variables.
1959 ;; Define some autoload functions Gnus might use.
1962 ;; This little mapcar goes through the list below and marks the
1963 ;; symbols in question as autoloaded functions.
1966 (let ((interactive (nth 1 (memq ':interactive package))))
1970 (when (consp function)
1971 (setq keymap (car (memq 'keymap function)))
1972 (setq function (car function)))
1973 (autoload function (car package) nil interactive keymap)))
1974 (if (eq (nth 1 package) ':interactive)
1977 '(("metamail" metamail-buffer)
1978 ("info" Info-goto-node)
1979 ("hexl" hexl-hex-string-to-integer)
1980 ("pp" pp pp-to-string pp-eval-expression)
1981 ("mail-extr" mail-extract-address-components)
1982 ("nnmail" nnmail-split-fancy nnmail-article-group)
1983 ("nnvirtual" nnvirtual-catchup-group)
1984 ("timezone" timezone-make-date-arpa-standard timezone-fix-time
1985 timezone-make-sortable-date timezone-make-time-string)
1986 ("sendmail" mail-position-on-field mail-setup)
1987 ("rmailout" rmail-output)
1988 ("rnewspost" news-mail-other-window news-reply-yank-original
1989 news-caesar-buffer-body)
1990 ("rmail" rmail-insert-rmail-file-header rmail-count-new-messages
1992 ("gnus-soup" :interactive t
1993 gnus-group-brew-soup gnus-brew-soup gnus-soup-add-article
1994 gnus-soup-send-replies gnus-soup-save-areas gnus-soup-pack-packet)
1995 ("nnsoup" nnsoup-pack-replies)
1996 ("gnus-mh" gnus-mh-mail-setup gnus-summary-save-article-folder
1997 gnus-Folder-save-name gnus-folder-save-name)
1998 ("gnus-mh" :interactive t gnus-summary-save-in-folder)
1999 ("gnus-vis" gnus-group-make-menu-bar gnus-summary-make-menu-bar
2000 gnus-server-make-menu-bar gnus-article-make-menu-bar
2001 gnus-browse-make-menu-bar gnus-highlight-selected-summary
2002 gnus-summary-highlight-line gnus-carpal-setup-buffer
2003 gnus-group-highlight-line
2004 gnus-article-add-button gnus-insert-next-page-button
2005 gnus-insert-prev-page-button gnus-visual-turn-off-edit-menu)
2006 ("gnus-vis" :interactive t
2007 gnus-article-push-button gnus-article-press-button
2008 gnus-article-highlight gnus-article-highlight-some
2009 gnus-article-highlight-headers gnus-article-highlight-signature
2010 gnus-article-add-buttons gnus-article-add-buttons-to-head
2011 gnus-article-next-button gnus-article-prev-button)
2012 ("gnus-demon" gnus-demon-add-nocem gnus-demon-add-scanmail
2013 gnus-demon-add-disconnection gnus-demon-add-handler
2014 gnus-demon-remove-handler)
2015 ("gnus-demon" :interactive t
2016 gnus-demon-init gnus-demon-cancel)
2017 ("gnus-salt" gnus-highlight-selected-tree gnus-possibly-generate-tree
2018 gnus-tree-open gnus-tree-close)
2019 ("gnus-nocem" gnus-nocem-scan-groups gnus-nocem-close
2020 gnus-nocem-unwanted-article-p)
2021 ("gnus-srvr" gnus-enter-server-buffer gnus-server-set-info)
2022 ("gnus-srvr" gnus-browse-foreign-server)
2023 ("gnus-cite" :interactive t
2024 gnus-article-highlight-citation gnus-article-hide-citation-maybe
2025 gnus-article-hide-citation gnus-article-fill-cited-article)
2026 ("gnus-kill" gnus-kill gnus-apply-kill-file-internal
2027 gnus-kill-file-edit-file gnus-kill-file-raise-followups-to-author
2028 gnus-execute gnus-expunge)
2029 ("gnus-cache" gnus-cache-possibly-enter-article gnus-cache-save-buffers
2030 gnus-cache-possibly-remove-articles gnus-cache-request-article
2031 gnus-cache-retrieve-headers gnus-cache-possibly-alter-active
2032 gnus-cache-enter-remove-article gnus-cached-article-p
2033 gnus-cache-open gnus-cache-close gnus-cache-update-article)
2034 ("gnus-cache" :interactive t gnus-jog-cache gnus-cache-enter-article
2035 gnus-cache-remove-article)
2036 ("gnus-score" :interactive t
2037 gnus-summary-increase-score gnus-summary-lower-score
2038 gnus-score-flush-cache gnus-score-close
2039 gnus-score-raise-same-subject-and-select
2040 gnus-score-raise-same-subject gnus-score-default
2041 gnus-score-raise-thread gnus-score-lower-same-subject-and-select
2042 gnus-score-lower-same-subject gnus-score-lower-thread
2043 gnus-possibly-score-headers)
2045 (gnus-summary-score-map keymap) gnus-score-save gnus-score-headers
2046 gnus-current-score-file-nondirectory gnus-score-adaptive
2047 gnus-score-find-trace gnus-score-file-name)
2048 ("gnus-edit" :interactive t gnus-score-customize)
2049 ("gnus-topic" :interactive t gnus-topic-mode)
2050 ("gnus-topic" gnus-topic-remove-group)
2051 ("gnus-salt" :interactive t gnus-pick-mode gnus-binary-mode)
2052 ("gnus-uu" (gnus-uu-extract-map keymap) (gnus-uu-mark-map keymap))
2053 ("gnus-uu" :interactive t
2054 gnus-uu-digest-mail-forward gnus-uu-digest-post-forward
2055 gnus-uu-mark-series gnus-uu-mark-region gnus-uu-mark-buffer
2056 gnus-uu-mark-by-regexp gnus-uu-mark-all
2057 gnus-uu-mark-sparse gnus-uu-mark-thread gnus-uu-decode-uu
2058 gnus-uu-decode-uu-and-save gnus-uu-decode-unshar
2059 gnus-uu-decode-unshar-and-save gnus-uu-decode-save
2060 gnus-uu-decode-binhex gnus-uu-decode-uu-view
2061 gnus-uu-decode-uu-and-save-view gnus-uu-decode-unshar-view
2062 gnus-uu-decode-unshar-and-save-view gnus-uu-decode-save-view
2063 gnus-uu-decode-binhex-view)
2064 ("gnus-msg" (gnus-summary-send-map keymap)
2065 gnus-mail-yank-original gnus-mail-send-and-exit
2066 gnus-sendmail-setup-mail gnus-article-mail
2067 gnus-inews-message-id gnus-new-mail gnus-mail-reply)
2068 ("gnus-msg" :interactive t
2069 gnus-group-post-news gnus-group-mail gnus-summary-post-news
2070 gnus-summary-followup gnus-summary-followup-with-original
2071 gnus-summary-followup-and-reply
2072 gnus-summary-followup-and-reply-with-original
2073 gnus-summary-cancel-article gnus-summary-supersede-article
2074 gnus-post-news gnus-inews-news gnus-cancel-news
2075 gnus-summary-reply gnus-summary-reply-with-original
2076 gnus-summary-mail-forward gnus-summary-mail-other-window
2078 ("gnus-picon" :interactive t gnus-article-display-picons
2079 gnus-group-display-picons gnus-picons-article-display-x-face)
2080 ("gnus-gl" bbb-login bbb-logout bbb-grouplens-group-p
2081 gnus-grouplens-mode)
2082 ("gnus-vm" gnus-vm-mail-setup)
2083 ("gnus-vm" :interactive t gnus-summary-save-in-vm
2084 gnus-summary-save-article-vm gnus-yank-article))))
2088 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2089 ;; If you want the cursor to go somewhere else, set these two
2090 ;; functions in some startup hook to whatever you want.
2091 (defalias 'gnus-summary-position-point 'gnus-goto-colon)
2092 (defalias 'gnus-group-position-point 'gnus-goto-colon)
2094 ;;; Various macros and substs.
2096 (defun gnus-header-from (header)
2097 (mail-header-from header))
2099 (defmacro gnus-eval-in-buffer-window (buffer &rest forms)
2100 "Pop to BUFFER, evaluate FORMS, and then return to the original window."
2101 (let ((tempvar (make-symbol "GnusStartBufferWindow")))
2102 `(let ((,tempvar (selected-window)))
2105 (pop-to-buffer ,buffer)
2107 (select-window ,tempvar)))))
2109 (defmacro gnus-gethash (string hashtable)
2110 "Get hash value of STRING in HASHTABLE."
2111 `(symbol-value (intern-soft ,string ,hashtable)))
2113 (defmacro gnus-sethash (string value hashtable)
2114 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2115 `(set (intern ,string ,hashtable) ,value))
2117 (defmacro gnus-intern-safe (string hashtable)
2118 "Set hash value. Arguments are STRING, VALUE, and HASHTABLE."
2119 `(let ((symbol (intern ,string ,hashtable)))
2124 (defmacro gnus-group-unread (group)
2125 "Get the currently computed number of unread articles in GROUP."
2126 `(car (gnus-gethash ,group gnus-newsrc-hashtb)))
2128 (defmacro gnus-group-entry (group)
2129 "Get the newsrc entry for GROUP."
2130 `(gnus-gethash ,group gnus-newsrc-hashtb))
2132 (defmacro gnus-active (group)
2133 "Get active info on GROUP."
2134 `(gnus-gethash ,group gnus-active-hashtb))
2136 (defmacro gnus-set-active (group active)
2137 "Set GROUP's active info."
2138 `(gnus-sethash ,group ,active gnus-active-hashtb))
2140 ;; modified by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2141 ;; function `substring' might cut on a middle of multi-octet
2143 (defun gnus-truncate-string (str width)
2144 (substring str 0 width))
2146 ;; Added by Geoffrey T. Dairiki <dairiki@u.washington.edu>. A safe way
2147 ;; to limit the length of a string. This function is necessary since
2148 ;; `(substr "abc" 0 30)' pukes with "Args out of range".
2149 (defsubst gnus-limit-string (str width)
2150 (if (> (length str) width)
2151 (substring str 0 width)
2154 (defsubst gnus-simplify-subject-re (subject)
2155 "Remove \"Re:\" from subject lines."
2156 (if (string-match "^[Rr][Ee]: *" subject)
2157 (substring subject (match-end 0))
2160 (defsubst gnus-goto-char (point)
2161 (and point (goto-char point)))
2163 (defmacro gnus-buffer-exists-p (buffer)
2164 `(let ((buffer ,buffer))
2166 (funcall (if (stringp buffer) 'get-buffer 'buffer-name)
2169 (defmacro gnus-kill-buffer (buffer)
2170 `(let ((buf ,buffer))
2171 (if (gnus-buffer-exists-p buf)
2172 (kill-buffer buf))))
2174 (defsubst gnus-point-at-bol ()
2175 "Return point at the beginning of the line."
2182 (defsubst gnus-point-at-eol ()
2183 "Return point at the end of the line."
2190 (defun gnus-alive-p ()
2191 "Say whether Gnus is running or not."
2192 (and gnus-group-buffer
2193 (get-buffer gnus-group-buffer)))
2195 ;; Delete the current line (and the next N lines.);
2196 (defmacro gnus-delete-line (&optional n)
2197 `(delete-region (progn (beginning-of-line) (point))
2198 (progn (forward-line ,(or n 1)) (point))))
2200 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
2201 (defvar gnus-init-inhibit nil)
2202 (defun gnus-read-init-file (&optional inhibit-next)
2203 (if gnus-init-inhibit
2204 (setq gnus-init-inhibit nil)
2205 (setq gnus-init-inhibit inhibit-next)
2207 (or (and (file-exists-p gnus-init-file)
2208 ;; Don't try to load a directory.
2209 (not (file-directory-p gnus-init-file)))
2210 (file-exists-p (concat gnus-init-file ".el"))
2211 (file-exists-p (concat gnus-init-file ".elc")))
2213 (load gnus-init-file nil t)
2215 (error "Error in %s: %s" gnus-init-file var))))))
2217 ;; Info access macros.
2219 (defmacro gnus-info-group (info)
2221 (defmacro gnus-info-rank (info)
2223 (defmacro gnus-info-read (info)
2225 (defmacro gnus-info-marks (info)
2227 (defmacro gnus-info-method (info)
2229 (defmacro gnus-info-params (info)
2232 (defmacro gnus-info-level (info)
2233 `(let ((rank (gnus-info-rank ,info)))
2237 (defmacro gnus-info-score (info)
2238 `(let ((rank (gnus-info-rank ,info)))
2239 (or (and (consp rank) (cdr rank)) 0)))
2241 (defmacro gnus-info-set-group (info group)
2242 `(setcar ,info ,group))
2243 (defmacro gnus-info-set-rank (info rank)
2244 `(setcar (nthcdr 1 ,info) ,rank))
2245 (defmacro gnus-info-set-read (info read)
2246 `(setcar (nthcdr 2 ,info) ,read))
2247 (defmacro gnus-info-set-marks (info marks)
2248 `(setcar (nthcdr 3 ,info) ,marks))
2249 (defmacro gnus-info-set-method (info method)
2250 `(setcar (nthcdr 4 ,info) ,method))
2251 (defmacro gnus-info-set-params (info params)
2252 `(setcar (nthcdr 5 ,info) ,params))
2254 (defmacro gnus-info-set-level (info level)
2255 `(let ((rank (cdr ,info)))
2256 (if (consp (car rank))
2257 (setcar (car rank) ,level)
2258 (setcar rank ,level))))
2259 (defmacro gnus-info-set-score (info score)
2260 `(let ((rank (cdr ,info)))
2261 (if (consp (car rank))
2262 (setcdr (car rank) ,score)
2263 (setcar rank (cons (car rank) ,score)))))
2265 (defmacro gnus-get-info (group)
2266 `(nth 2 (gnus-gethash ,group gnus-newsrc-hashtb)))
2268 (defun gnus-byte-code (func)
2269 "Return a form that can be `eval'ed based on FUNC."
2270 (let ((fval (symbol-function func)))
2271 (if (byte-code-function-p fval)
2272 (let ((flist (append fval nil)))
2273 (setcar flist 'byte-code)
2275 (cons 'progn (cddr fval)))))
2277 ;;; Load the compatability functions.
2284 ;; Format specs. The chunks below are the machine-generated forms
2285 ;; that are to be evaled as the result of the default format strings.
2286 ;; We write them in here to get them byte-compiled. That way the
2287 ;; default actions will be quite fast, while still retaining the full
2288 ;; flexibility of the user-defined format specs.
2290 ;; First we have lots of dummy defvars to let the compiler know these
2291 ;; are really dynamic variables.
2293 (defvar gnus-tmp-unread)
2294 (defvar gnus-tmp-replied)
2295 (defvar gnus-tmp-score-char)
2296 (defvar gnus-tmp-indentation)
2297 (defvar gnus-tmp-opening-bracket)
2298 (defvar gnus-tmp-lines)
2299 (defvar gnus-tmp-name)
2300 (defvar gnus-tmp-closing-bracket)
2301 (defvar gnus-tmp-subject-or-nil)
2302 (defvar gnus-tmp-subject)
2303 (defvar gnus-tmp-marked)
2304 (defvar gnus-tmp-marked-mark)
2305 (defvar gnus-tmp-subscribed)
2306 (defvar gnus-tmp-process-marked)
2307 (defvar gnus-tmp-number-of-unread)
2308 (defvar gnus-tmp-group-name)
2309 (defvar gnus-tmp-group)
2310 (defvar gnus-tmp-article-number)
2311 (defvar gnus-tmp-unread-and-unselected)
2312 (defvar gnus-tmp-news-method)
2313 (defvar gnus-tmp-news-server)
2314 (defvar gnus-tmp-article-number)
2315 (defvar gnus-mouse-face)
2316 (defvar gnus-mouse-face-prop)
2318 (defun gnus-summary-line-format-spec ()
2319 (insert gnus-tmp-unread gnus-tmp-replied
2320 gnus-tmp-score-char gnus-tmp-indentation)
2325 gnus-tmp-opening-bracket
2326 (format "%4d: %-20s"
2328 (if (> (length gnus-tmp-name) 20)
2329 (substring gnus-tmp-name 0 20)
2331 gnus-tmp-closing-bracket)
2333 gnus-mouse-face-prop gnus-mouse-face)
2334 (insert " " gnus-tmp-subject-or-nil "\n"))
2336 (defvar gnus-summary-line-format-spec
2337 (gnus-byte-code 'gnus-summary-line-format-spec))
2339 (defun gnus-summary-dummy-line-format-spec ()
2346 gnus-mouse-face-prop gnus-mouse-face)
2347 (insert " " gnus-tmp-subject "\n"))
2349 (defvar gnus-summary-dummy-line-format-spec
2350 (gnus-byte-code 'gnus-summary-dummy-line-format-spec))
2352 (defun gnus-group-line-format-spec ()
2353 (insert gnus-tmp-marked-mark gnus-tmp-subscribed
2354 gnus-tmp-process-marked
2355 gnus-group-indentation
2356 (format "%5s: " gnus-tmp-number-of-unread))
2360 (insert gnus-tmp-group "\n")
2362 gnus-mouse-face-prop gnus-mouse-face))
2363 (defvar gnus-group-line-format-spec
2364 (gnus-byte-code 'gnus-group-line-format-spec))
2366 (defvar gnus-format-specs
2367 `((version . ,emacs-version)
2368 (group ,gnus-group-line-format ,gnus-group-line-format-spec)
2369 (summary-dummy ,gnus-summary-dummy-line-format
2370 ,gnus-summary-dummy-line-format-spec)
2371 (summary ,gnus-summary-line-format ,gnus-summary-line-format-spec)))
2373 (defvar gnus-article-mode-line-format-spec nil)
2374 (defvar gnus-summary-mode-line-format-spec nil)
2375 (defvar gnus-group-mode-line-format-spec nil)
2377 ;;; Phew. All that gruft is over, fortunately.
2381 ;;; Gnus Utility Functions
2384 (defun gnus-extract-address-components (from)
2386 ;; First find the address - the thing with the @ in it. This may
2387 ;; not be accurate in mail addresses, but does the trick most of
2388 ;; the time in news messages.
2389 (if (string-match "\\b[^@ \t<>]+[!@][^@ \t<>]+\\b" from)
2390 (setq address (substring from (match-beginning 0) (match-end 0))))
2391 ;; Then we check whether the "name <address>" format is used.
2393 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>
2394 ;; Linear white space is not required.
2395 (string-match (concat "[ \t]*<" (regexp-quote address) ">") from)
2396 (and (setq name (substring from 0 (match-beginning 0)))
2397 ;; Strip any quotes from the name.
2398 (string-match "\".*\"" name)
2399 (setq name (substring name 1 (1- (match-end 0))))))
2400 ;; If not, then "address (name)" is used.
2402 (and (string-match "(.+)" from)
2403 (setq name (substring from (1+ (match-beginning 0))
2404 (1- (match-end 0)))))
2405 (and (string-match "()" from)
2406 (setq name address))
2407 ;; Fix by MORIOKA Tomohiko <morioka@jaist.ac.jp>.
2408 ;; XOVER might not support folded From headers.
2409 (and (string-match "(.*" from)
2410 (setq name (substring from (1+ (match-beginning 0))
2412 ;; Fix by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
2413 (list (or name from) (or address from))))
2415 (defun gnus-fetch-field (field)
2416 "Return the value of the header FIELD of current article."
2419 (let ((case-fold-search t))
2420 (nnheader-narrow-to-headers)
2421 (mail-fetch-field field)))))
2423 (defun gnus-goto-colon ()
2425 (search-forward ":" (gnus-point-at-eol) t))
2428 (defun gnus-update-format (var)
2429 "Update the format specification near point."
2434 ;; Find the end of the current word.
2435 (re-search-forward "[ \t\n]" nil t)
2437 (when (re-search-backward "\\(gnus-[-a-z]+-line-format\\)" nil t)
2438 (match-string 1)))))
2439 (let* ((type (intern (progn (string-match "gnus-\\([-a-z]+\\)-line" var)
2440 (match-string 1 var))))
2441 (entry (assq type gnus-format-specs))
2444 (setq gnus-format-specs (delq entry gnus-format-specs)))
2446 (intern (format "%s-spec" var))
2447 (gnus-parse-format (setq value (symbol-value (intern var)))
2448 (symbol-value (intern (format "%s-alist" var)))
2449 (not (string-match "mode" var))))
2450 (setq spec (symbol-value (intern (format "%s-spec" var))))
2451 (push (list type value spec) gnus-format-specs)
2453 (pop-to-buffer "*Gnus Format*")
2455 (lisp-interaction-mode)
2456 (insert (pp-to-string spec))))
2458 (defun gnus-update-format-specifications (&optional force)
2459 "Update all (necessary) format specifications."
2460 ;; Make the indentation array.
2461 (gnus-make-thread-indent-array)
2463 ;; See whether all the stored info needs to be flushed.
2465 (not (equal emacs-version
2466 (cdr (assq 'version gnus-format-specs)))))
2467 (setq gnus-format-specs nil))
2469 ;; Go through all the formats and see whether they need updating.
2470 (let ((types '(summary summary-dummy group
2471 summary-mode group-mode article-mode))
2472 new-format entry type val)
2473 (while (setq type (pop types))
2474 ;; Jump to the proper buffer to find out the value of
2475 ;; the variable, if possible. (It may be buffer-local.)
2477 (let ((buffer (intern (format "gnus-%s-buffer" type)))
2479 (when (and (boundp buffer)
2480 (setq val (symbol-value buffer))
2482 (buffer-name (get-buffer val)))
2483 (set-buffer (get-buffer val)))
2484 (setq new-format (symbol-value
2485 (intern (format "gnus-%s-line-format" type))))))
2486 (setq entry (cdr (assq type gnus-format-specs)))
2488 (equal (car entry) new-format))
2489 ;; Use the old format.
2490 (set (intern (format "gnus-%s-line-format-spec" type))
2492 ;; This is a new format.
2494 (if (not (stringp new-format))
2495 ;; This is a function call or something.
2497 ;; This is a "real" format.
2501 (intern (format "gnus-%s-line-format-alist"
2502 (if (eq type 'article-mode)
2503 'summary-mode type))))
2504 (not (string-match "mode$" (symbol-name type))))))
2505 ;; Enter the new format spec into the list.
2508 (setcar (cdr entry) val)
2509 (setcar entry new-format))
2510 (push (list type new-format val) gnus-format-specs))
2511 (set (intern (format "gnus-%s-line-format-spec" type)) val))))
2513 (gnus-update-group-mark-positions)
2514 (gnus-update-summary-mark-positions))
2516 (defun gnus-update-summary-mark-positions ()
2517 "Compute where the summary marks are to go."
2519 (let ((gnus-replied-mark 129)
2520 (gnus-score-below-mark 130)
2521 (gnus-score-over-mark 130)
2525 (gnus-set-work-buffer)
2526 (gnus-summary-insert-line
2527 [0 "" "" "" "" "" 0 0 ""] 0 nil 128 t nil "" nil 1)
2528 (goto-char (point-min))
2529 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2531 (goto-char (point-min))
2532 (push (cons 'replied (and (search-forward "\201" nil t) (- (point) 2)))
2534 (goto-char (point-min))
2535 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2537 (setq gnus-summary-mark-positions pos))))
2539 (defun gnus-update-group-mark-positions ()
2541 (let ((gnus-process-mark 128)
2542 (gnus-group-marked '("dummy.group")))
2543 (gnus-set-active "dummy.group" '(0 . 0))
2544 (gnus-set-work-buffer)
2545 (gnus-group-insert-group-line "dummy.group" 0 nil 0 nil)
2546 (goto-char (point-min))
2547 (setq gnus-group-mark-positions
2548 (list (cons 'process (and (search-forward "\200" nil t)
2549 (- (point) 2))))))))
2551 (defvar gnus-mouse-face-0 'highlight)
2552 (defvar gnus-mouse-face-1 'highlight)
2553 (defvar gnus-mouse-face-2 'highlight)
2554 (defvar gnus-mouse-face-3 'highlight)
2555 (defvar gnus-mouse-face-4 'highlight)
2557 (defun gnus-mouse-face-function (form type)
2559 (point) (progn ,@form (point))
2560 gnus-mouse-face-prop
2563 `(quote ,(symbol-value (intern (format "gnus-mouse-face-%d" type)))))))
2565 (defvar gnus-face-0 'bold)
2566 (defvar gnus-face-1 'italic)
2567 (defvar gnus-face-2 'bold-italic)
2568 (defvar gnus-face-3 'bold)
2569 (defvar gnus-face-4 'bold)
2571 (defun gnus-face-face-function (form type)
2573 (point) (progn ,@form (point))
2574 'face ',(symbol-value (intern (format "gnus-face-%d" type)))))
2576 (defun gnus-max-width-function (el max-width)
2577 (or (numberp max-width) (signal 'wrong-type-argument '(numberp max-width)))
2579 `(if (> (length ,el) ,max-width)
2580 (substring ,el 0 ,max-width)
2582 `(let ((val (eval ,el)))
2584 (setq val (int-to-string val)))
2585 (if (> (length val) ,max-width)
2586 (substring val 0 ,max-width)
2589 (defun gnus-parse-format (format spec-alist &optional insert)
2590 ;; This function parses the FORMAT string with the help of the
2591 ;; SPEC-ALIST and returns a list that can be eval'ed to return the
2592 ;; string. If the FORMAT string contains the specifiers %( and %)
2593 ;; the text between them will have the mouse-face text property.
2595 "\\`\\(.*\\)%[0-9]?[{(]\\(.*\\)%[0-9]?[})]\\(.*\n?\\)\\'"
2597 (gnus-parse-complex-format format spec-alist)
2598 ;; This is a simple format.
2599 (gnus-parse-simple-format format spec-alist insert)))
2601 (defun gnus-parse-complex-format (format spec-alist)
2603 (gnus-set-work-buffer)
2605 (goto-char (point-min))
2606 (while (re-search-forward "\"" nil t)
2607 (replace-match "\\\"" nil t))
2608 (goto-char (point-min))
2610 (while (re-search-forward "%\\([0-9]+\\)?\\([{}()]\\)" nil t)
2611 (let ((number (if (match-beginning 1)
2612 (match-string 1) "0"))
2613 (delim (aref (match-string 2) 0)))
2614 (if (or (= delim ?\() (= delim ?\{))
2615 (replace-match (concat "\"(" (if (= delim ?\() "mouse" "face")
2617 (replace-match "\")\""))))
2618 (goto-char (point-max))
2620 (goto-char (point-min))
2621 (let ((form (read (current-buffer))))
2622 (cons 'progn (gnus-complex-form-to-spec form spec-alist)))))
2624 (defun gnus-complex-form-to-spec (form spec-alist)
2629 (gnus-parse-simple-format sform spec-alist t)
2630 (funcall (intern (format "gnus-%s-face-function" (car sform)))
2631 (gnus-complex-form-to-spec (cddr sform) spec-alist)
2635 (defun gnus-parse-simple-format (format spec-alist &optional insert)
2636 ;; This function parses the FORMAT string with the help of the
2637 ;; SPEC-ALIST and returns a list that can be eval'ed to return a
2640 spec flist fstring newspec elem beg result dontinsert)
2642 (gnus-set-work-buffer)
2644 (goto-char (point-min))
2645 (while (re-search-forward "%[-0-9]*\\(,[0-9]+\\)?\\([^0-9]\\)\\(.\\)?"
2647 (if (= (setq spec (string-to-char (match-string 2))) ?%)
2649 beg (1+ (match-beginning 0)))
2650 ;; First check if there are any specs that look anything like
2651 ;; "%12,12A", ie. with a "max width specification". These have
2652 ;; to be treated specially.
2653 (if (setq beg (match-beginning 1))
2657 (1+ (match-beginning 1)) (match-end 1))))
2659 (setq beg (match-beginning 2)))
2660 ;; Find the specification from `spec-alist'.
2661 (unless (setq elem (cdr (assq spec spec-alist)))
2662 (setq elem '("*" ?s)))
2663 ;; Treat user defined format specifiers specially.
2664 (when (eq (car elem) 'gnus-tmp-user-defined)
2667 (list (intern (concat "gnus-user-format-function-"
2669 'gnus-tmp-header) ?s))
2670 (delete-region (match-beginning 3) (match-end 3)))
2671 (if (not (zerop max-width))
2672 (let ((el (car elem)))
2673 (cond ((= (cadr elem) ?c)
2674 (setq el (list 'char-to-string el)))
2676 (setq el (list 'int-to-string el))))
2677 (setq flist (cons (gnus-max-width-function el max-width)
2681 (setq flist (cons (car elem) flist))
2682 (setq newspec (cadr elem)))))
2683 ;; Remove the old specification (and possibly a ",12" string).
2684 (delete-region beg (match-end 2))
2685 ;; Insert the new specification.
2688 (setq fstring (buffer-substring 1 (point-max))))
2689 ;; Do some postprocessing to increase efficiency.
2694 ((string= fstring "")
2696 ;; Not a format string.
2697 ((not (string-match "%" fstring))
2699 ;; A format string with just a single string spec.
2700 ((string= fstring "%s")
2702 ;; A single character.
2703 ((string= fstring "%c")
2706 ((string= fstring "%d")
2709 (list `(princ ,(car flist)))
2710 (list `(int-to-string ,(car flist)))))
2711 ;; Just lots of chars and strings.
2712 ((string-match "\\`\\(%[cs]\\)+\\'" fstring)
2714 ;; A single string spec at the beginning of the spec.
2715 ((string-match "\\`%[sc][^%]+\\'" fstring)
2716 (list (car flist) (substring fstring 2)))
2717 ;; A single string spec in the middle of the spec.
2718 ((string-match "\\`\\([^%]+\\)%[sc]\\([^%]+\\)\\'" fstring)
2719 (list (match-string 1 fstring) (car flist) (match-string 2 fstring)))
2720 ;; A single string spec in the end of the spec.
2721 ((string-match "\\`\\([^%]+\\)%[sc]\\'" fstring)
2722 (list (match-string 1 fstring) (car flist)))
2723 ;; A more complex spec.
2725 (list (cons 'format (cons fstring (nreverse flist)))))))
2731 (cons 'insert result)))
2732 (cond ((stringp result)
2735 (cons 'concat result))
2738 (defun gnus-eval-format (format &optional alist props)
2739 "Eval the format variable FORMAT, using ALIST.
2740 If PROPS, insert the result."
2741 (let ((form (gnus-parse-format format alist props)))
2743 (add-text-properties (point) (progn (eval form) (point)) props)
2746 (defun gnus-remove-text-with-property (prop)
2747 "Delete all text in the current buffer with text property PROP."
2749 (goto-char (point-min))
2751 (while (get-text-property (point) prop)
2753 (goto-char (next-single-property-change (point) prop nil (point-max))))))
2755 (defun gnus-set-work-buffer ()
2756 (if (get-buffer gnus-work-buffer)
2758 (set-buffer gnus-work-buffer)
2760 (set-buffer (get-buffer-create gnus-work-buffer))
2761 (kill-all-local-variables)
2762 (buffer-disable-undo (current-buffer))
2763 (gnus-add-current-to-buffer-list)))
2765 ;; Article file names when saving.
2767 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2768 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2769 If variable `gnus-use-long-file-name' is nil, it is ~/News/News.group/num.
2770 Otherwise, it is like ~/News/news/group/num."
2773 (concat (if (gnus-use-long-file-name 'not-save)
2774 (gnus-capitalize-newsgroup newsgroup)
2775 (gnus-newsgroup-directory-form newsgroup))
2776 "/" (int-to-string (mail-header-number headers)))
2777 (or gnus-article-save-directory "~/News"))))
2779 (string-equal (file-name-directory default)
2780 (file-name-directory last-file))
2781 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2783 (or last-file default))))
2785 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2786 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2787 If variable `gnus-use-long-file-name' is non-nil, it is
2788 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2791 (concat (if (gnus-use-long-file-name 'not-save)
2793 (gnus-newsgroup-directory-form newsgroup))
2794 "/" (int-to-string (mail-header-number headers)))
2795 (or gnus-article-save-directory "~/News"))))
2797 (string-equal (file-name-directory default)
2798 (file-name-directory last-file))
2799 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2801 (or last-file default))))
2803 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2804 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2805 If variable `gnus-use-long-file-name' is non-nil, it is
2806 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2809 (if (gnus-use-long-file-name 'not-save)
2810 (gnus-capitalize-newsgroup newsgroup)
2811 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2812 (or gnus-article-save-directory "~/News"))))
2814 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2815 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2816 If variable `gnus-use-long-file-name' is non-nil, it is
2817 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2820 (if (gnus-use-long-file-name 'not-save)
2822 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2823 (or gnus-article-save-directory "~/News"))))
2825 ;; For subscribing new newsgroup
2827 (defun gnus-subscribe-hierarchical-interactive (groups)
2828 (let ((groups (sort groups 'string<))
2829 prefixes prefix start ans group starts)
2831 (setq prefixes (list "^"))
2832 (while (and groups prefixes)
2833 (while (not (string-match (car prefixes) (car groups)))
2834 (setq prefixes (cdr prefixes)))
2835 (setq prefix (car prefixes))
2836 (setq start (1- (length prefix)))
2837 (if (and (string-match "[^\\.]\\." (car groups) start)
2840 (concat "^" (substring (car groups) 0 (match-end 0))))
2841 (string-match prefix (cadr groups)))
2843 (setq prefixes (cons prefix prefixes))
2844 (message "Descend hierarchy %s? ([y]nsq): "
2845 (substring prefix 1 (1- (length prefix))))
2846 (setq ans (read-char))
2849 (string-match prefix
2850 (setq group (car groups))))
2851 (setq gnus-killed-list
2852 (cons group gnus-killed-list))
2853 (gnus-sethash group group gnus-killed-hashtb)
2854 (setq groups (cdr groups)))
2855 (setq starts (cdr starts)))
2858 (string-match prefix
2859 (setq group (car groups))))
2860 (gnus-sethash group group gnus-killed-hashtb)
2861 (gnus-subscribe-alphabetically (car groups))
2862 (setq groups (cdr groups)))
2863 (setq starts (cdr starts)))
2866 (setq group (car groups))
2867 (setq gnus-killed-list (cons group gnus-killed-list))
2868 (gnus-sethash group group gnus-killed-hashtb)
2869 (setq groups (cdr groups))))
2871 (message "Subscribe %s? ([n]yq)" (car groups))
2872 (setq ans (read-char))
2873 (setq group (car groups))
2875 (gnus-subscribe-alphabetically (car groups))
2876 (gnus-sethash group group gnus-killed-hashtb))
2879 (setq group (car groups))
2880 (setq gnus-killed-list (cons group gnus-killed-list))
2881 (gnus-sethash group group gnus-killed-hashtb)
2882 (setq groups (cdr groups))))
2884 (setq gnus-killed-list (cons group gnus-killed-list))
2885 (gnus-sethash group group gnus-killed-hashtb)))
2886 (setq groups (cdr groups)))))))
2888 (defun gnus-subscribe-randomly (newsgroup)
2889 "Subscribe new NEWSGROUP by making it the first newsgroup."
2890 (gnus-subscribe-newsgroup newsgroup))
2892 (defun gnus-subscribe-alphabetically (newgroup)
2893 "Subscribe new NEWSGROUP and insert it in alphabetical order."
2894 (let ((groups (cdr gnus-newsrc-alist))
2896 (while (and (not before) groups)
2897 (if (string< newgroup (caar groups))
2898 (setq before (caar groups))
2899 (setq groups (cdr groups))))
2900 (gnus-subscribe-newsgroup newgroup before)))
2902 (defun gnus-subscribe-hierarchically (newgroup)
2903 "Subscribe new NEWSGROUP and insert it in hierarchical newsgroup order."
2904 ;; Basic ideas by mike-w@cs.aukuni.ac.nz (Mike Williams)
2906 (set-buffer (find-file-noselect gnus-current-startup-file))
2907 (let ((groupkey newgroup)
2909 (while (and (not before) groupkey)
2910 (goto-char (point-min))
2912 (concat "^\\(" (regexp-quote groupkey) ".*\\)[!:]")))
2913 (while (and (re-search-forward groupkey-re nil t)
2915 (setq before (match-string 1))
2916 (string< before newgroup)))))
2917 ;; Remove tail of newsgroup name (eg. a.b.c -> a.b)
2919 (if (string-match "^\\(.*\\)\\.[^.]+$" groupkey)
2920 (substring groupkey (match-beginning 1) (match-end 1)))))
2921 (gnus-subscribe-newsgroup newgroup before))))
2923 (defun gnus-subscribe-interactively (group)
2924 "Subscribe the new GROUP interactively.
2925 It is inserted in hierarchical newsgroup order if subscribed. If not,
2927 (if (gnus-y-or-n-p (format "Subscribe new newsgroup: %s " group))
2928 (gnus-subscribe-hierarchically group)
2929 (push group gnus-killed-list)))
2931 (defun gnus-subscribe-zombies (group)
2932 "Make the new GROUP into a zombie group."
2933 (push group gnus-zombie-list))
2935 (defun gnus-subscribe-killed (group)
2936 "Make the new GROUP a killed group."
2937 (push group gnus-killed-list))
2939 (defun gnus-subscribe-newsgroup (newsgroup &optional next)
2940 "Subscribe new NEWSGROUP.
2941 If NEXT is non-nil, it is inserted before NEXT. Otherwise it is made
2942 the first newsgroup."
2943 ;; We subscribe the group by changing its level to `subscribed'.
2944 (gnus-group-change-level
2945 newsgroup gnus-level-default-subscribed
2946 gnus-level-killed (gnus-gethash (or next "dummy.group") gnus-newsrc-hashtb))
2947 (gnus-message 5 "Subscribe newsgroup: %s" newsgroup))
2951 (defun gnus-newsgroup-directory-form (newsgroup)
2952 "Make hierarchical directory name from NEWSGROUP name."
2953 (let ((newsgroup (gnus-newsgroup-savable-name newsgroup))
2954 (len (length newsgroup))
2956 ;; If this is a foreign group, we don't want to translate the
2958 (if (setq idx (string-match ":" newsgroup))
2959 (aset newsgroup idx ?/)
2961 ;; Replace all occurrences of `.' with `/'.
2963 (if (= (aref newsgroup idx) ?.)
2964 (aset newsgroup idx ?/))
2965 (setq idx (1+ idx)))
2968 (defun gnus-newsgroup-savable-name (group)
2969 ;; Replace any slashes in a group name (eg. an ange-ftp nndoc group)
2971 (nnheader-replace-chars-in-string group ?/ ?.))
2973 (defun gnus-make-directory (dir)
2974 "Make DIRECTORY recursively."
2975 ;; Why don't we use `(make-directory dir 'parents)'? That's just one
2976 ;; of the many mysteries of the universe.
2977 (let* ((dir (expand-file-name dir default-directory))
2979 (if (string-match "/$" dir)
2980 (setq dir (substring dir 0 (match-beginning 0))))
2981 ;; First go down the path until we find a directory that exists.
2982 (while (not (file-exists-p dir))
2983 (setq dirs (cons dir dirs))
2984 (string-match "/[^/]+$" dir)
2985 (setq dir (substring dir 0 (match-beginning 0))))
2986 ;; Then create all the subdirs.
2987 (while (and dirs (not err))
2989 (make-directory (car dirs))
2990 (error (setq err t)))
2991 (setq dirs (cdr dirs)))
2992 ;; We return whether we were successful or not.
2995 (defun gnus-capitalize-newsgroup (newsgroup)
2996 "Capitalize NEWSGROUP name."
2997 (and (not (zerop (length newsgroup)))
2998 (concat (char-to-string (upcase (aref newsgroup 0)))
2999 (substring newsgroup 1))))
3001 ;; Various... things.
3003 (defun gnus-simplify-subject (subject &optional re-only)
3004 "Remove `Re:' and words in parentheses.
3005 If RE-ONLY is non-nil, strip leading `Re:'s only."
3006 (let ((case-fold-search t)) ;Ignore case.
3007 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
3008 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
3009 (setq subject (substring subject (match-end 0))))
3010 ;; Remove uninteresting prefixes.
3011 (if (and (not re-only)
3012 gnus-simplify-ignored-prefixes
3013 (string-match gnus-simplify-ignored-prefixes subject))
3014 (setq subject (substring subject (match-end 0))))
3015 ;; Remove words in parentheses from end.
3017 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
3018 (setq subject (substring subject 0 (match-beginning 0)))))
3019 ;; Return subject string.
3022 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
3024 ;; Written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
3025 (defun gnus-simplify-buffer-fuzzy ()
3026 (goto-char (point-min))
3027 (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*" nil t)
3028 (goto-char (match-beginning 0))
3030 (looking-at "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*")
3031 (looking-at "^[[].*:[ \t].*[]]$"))
3032 (goto-char (point-min))
3033 (while (re-search-forward "^[ \t]*\\(re\\|fwd\\)[[{(^0-9]*[])}]?[:;][ \t]*"
3035 (replace-match "" t t))
3036 (goto-char (point-min))
3037 (while (re-search-forward "^[[].*:[ \t].*[]]$" nil t)
3038 (goto-char (match-end 0))
3041 (progn (goto-char (match-beginning 0)))
3042 (re-search-forward ":"))))
3043 (goto-char (point-min))
3044 (while (re-search-forward "[ \t\n]*[[{(][^()\n]*[]})][ \t]*$" nil t)
3045 (replace-match "" t t))
3046 (goto-char (point-min))
3047 (while (re-search-forward "[ \t]+" nil t)
3048 (replace-match " " t t))
3049 (goto-char (point-min))
3050 (while (re-search-forward "[ \t]+$" nil t)
3051 (replace-match "" t t))
3052 (goto-char (point-min))
3053 (while (re-search-forward "^[ \t]+" nil t)
3054 (replace-match "" t t))
3055 (goto-char (point-min))
3056 (if gnus-simplify-subject-fuzzy-regexp
3057 (if (listp gnus-simplify-subject-fuzzy-regexp)
3058 (let ((list gnus-simplify-subject-fuzzy-regexp))
3060 (goto-char (point-min))
3061 (while (re-search-forward (car list) nil t)
3062 (replace-match "" t t))
3063 (setq list (cdr list))))
3064 (while (re-search-forward gnus-simplify-subject-fuzzy-regexp nil t)
3065 (replace-match "" t t)))))
3067 (defun gnus-simplify-subject-fuzzy (subject)
3068 "Siplify a subject string fuzzily."
3070 (gnus-set-work-buffer)
3071 (let ((case-fold-search t))
3073 (inline (gnus-simplify-buffer-fuzzy))
3076 ;; Add the current buffer to the list of buffers to be killed on exit.
3077 (defun gnus-add-current-to-buffer-list ()
3078 (or (memq (current-buffer) gnus-buffer-list)
3079 (setq gnus-buffer-list (cons (current-buffer) gnus-buffer-list))))
3081 (defun gnus-string> (s1 s2)
3082 (not (or (string< s1 s2)
3085 ;;; General various misc type functions.
3087 (defun gnus-clear-system ()
3088 "Clear all variables and buffers."
3089 ;; Clear Gnus variables.
3090 (let ((variables gnus-variable-list))
3092 (set (car variables) nil)
3093 (setq variables (cdr variables))))
3094 ;; Clear other internal variables.
3095 (setq gnus-list-of-killed-groups nil
3096 gnus-have-read-active-file nil
3097 gnus-newsrc-alist nil
3098 gnus-newsrc-hashtb nil
3099 gnus-killed-list nil
3100 gnus-zombie-list nil
3101 gnus-killed-hashtb nil
3102 gnus-active-hashtb nil
3103 gnus-moderated-list nil
3104 gnus-description-hashtb nil
3105 gnus-newsgroup-headers nil
3106 gnus-newsgroup-name nil
3107 gnus-server-alist nil
3108 gnus-group-list-mode nil
3109 gnus-topic-active-topology nil
3110 gnus-topic-active-alist nil
3111 gnus-opened-servers nil
3112 gnus-current-select-method nil)
3113 ;; Reset any score variables.
3114 (when gnus-use-scoring
3116 ;; Kill the startup file.
3117 (and gnus-current-startup-file
3118 (get-file-buffer gnus-current-startup-file)
3119 (kill-buffer (get-file-buffer gnus-current-startup-file)))
3120 ;; Save any cache buffers.
3121 (when gnus-use-cache
3122 (gnus-cache-save-buffers))
3123 ;; Clear the dribble buffer.
3124 (gnus-dribble-clear)
3125 ;; Close down NoCeM.
3126 (when gnus-use-nocem
3128 ;; Shut down the demons.
3129 (when gnus-use-demon
3130 (gnus-demon-cancel))
3131 ;; Kill global KILL file buffer.
3132 (when (get-file-buffer (gnus-newsgroup-kill-file nil))
3133 (kill-buffer (get-file-buffer (gnus-newsgroup-kill-file nil))))
3134 (gnus-kill-buffer nntp-server-buffer)
3136 (when gnus-keep-backlog
3137 (gnus-backlog-shutdown))
3138 ;; Kill Gnus buffers.
3139 (while gnus-buffer-list
3140 (gnus-kill-buffer (pop gnus-buffer-list)))
3141 ;; Remove Gnus frames.
3142 (while gnus-created-frames
3143 (when (frame-live-p (car gnus-created-frames))
3144 ;; We slap a condition-case around this `delete-frame' to ensure
3145 ;; agains errors if we try do delete the single frame that's left.
3147 (delete-frame (car gnus-created-frames))
3149 (pop gnus-created-frames)))
3151 (defun gnus-windows-old-to-new (setting)
3152 ;; First we take care of the really, really old Gnus 3 actions.
3153 (when (symbolp setting)
3155 ;; Take care of ooold GNUS 3.x values.
3156 (cond ((eq setting 'SelectArticle) 'article)
3157 ((memq setting '(SelectSubject ExpandSubject)) 'summary)
3158 ((memq setting '(SelectNewsgroup ExitNewsgroup)) 'group)
3160 (if (or (listp setting)
3161 (not (and gnus-window-configuration
3162 (memq setting '(group summary article)))))
3164 (let* ((setting (if (eq setting 'group)
3165 (if (assq 'newsgroup gnus-window-configuration)
3167 'newsgroups) setting))
3168 (elem (cadr (assq setting gnus-window-configuration)))
3169 (total (apply '+ elem))
3170 (types '(group summary article))
3171 (pbuf (if (eq setting 'newsgroups) 'group 'summary))
3176 (or (not (numberp (nth i elem)))
3177 (zerop (nth i elem))
3179 (setq perc (/ (float (nth 0 elem)) total))
3180 (setq out (cons (if (eq pbuf (nth i types))
3181 (vector (nth i types) perc 'point)
3182 (vector (nth i types) perc))
3185 (list (nreverse out)))))
3188 (defun gnus-add-configuration (conf)
3189 "Add the window configuration CONF to `gnus-buffer-configuration'."
3190 (setq gnus-buffer-configuration
3191 (cons conf (delq (assq (car conf) gnus-buffer-configuration)
3192 gnus-buffer-configuration))))
3194 (defvar gnus-frame-list nil)
3196 (defun gnus-configure-frame (split &optional window)
3197 "Split WINDOW according to SPLIT."
3199 (setq window (get-buffer-window (current-buffer))))
3200 (select-window window)
3201 ;; This might be an old-stylee buffer config.
3202 (when (vectorp split)
3203 (setq split (append split nil)))
3204 (when (or (consp (car split))
3205 (vectorp (car split)))
3207 (push 'vertical split))
3208 ;; The SPLIT might be something that is to be evaled to
3209 ;; return a new SPLIT.
3210 (while (and (not (assq (car split) gnus-window-to-buffer))
3211 (gnus-functionp (car split)))
3212 (setq split (eval split)))
3213 (let* ((type (car split))
3215 (len (if (eq type 'horizontal) (window-width) (window-height)))
3217 (window-min-width (or gnus-window-min-width window-min-width))
3218 (window-min-height (or gnus-window-min-height window-min-height))
3219 s result new-win rest comp-subs size sub)
3221 ;; Nothing to do here.
3223 ;; Don't switch buffers.
3225 (and (memq 'point split) window))
3226 ;; This is a buffer to be selected.
3227 ((not (memq type '(frame horizontal vertical)))
3228 (let ((buffer (cond ((stringp type) type)
3229 (t (cdr (assq type gnus-window-to-buffer)))))
3232 (error "Illegal buffer type: %s" type))
3233 (unless (setq buf (get-buffer (if (symbolp buffer)
3234 (symbol-value buffer) buffer)))
3235 (setq buf (get-buffer-create (if (symbolp buffer)
3236 (symbol-value buffer) buffer))))
3237 (switch-to-buffer buf)
3238 ;; We return the window if it has the `point' spec.
3239 (and (memq 'point split) window)))
3240 ;; This is a frame split.
3242 (unless gnus-frame-list
3243 (setq gnus-frame-list (list (window-frame
3244 (get-buffer-window (current-buffer))))))
3246 params frame fresult)
3247 (while (< i (length subs))
3248 ;; Frame parameter is gotten from the sub-split.
3249 (setq params (cadr (elt subs i)))
3250 ;; It should be a list.
3251 (unless (listp params)
3253 ;; Create a new frame?
3254 (unless (setq frame (elt gnus-frame-list i))
3255 (nconc gnus-frame-list (list (setq frame (make-frame params))))
3256 (push frame gnus-created-frames))
3257 ;; Is the old frame still alive?
3258 (unless (frame-live-p frame)
3259 (setcar (nthcdr i gnus-frame-list)
3260 (setq frame (make-frame params))))
3261 ;; Select the frame in question and do more splits there.
3262 (select-frame frame)
3263 (setq fresult (or (gnus-configure-frame (elt subs i)) fresult))
3265 ;; Select the frame that has the selected buffer.
3267 (select-frame (window-frame fresult)))))
3268 ;; This is a normal split.
3270 (when (> (length subs) 0)
3271 ;; First we have to compute the sizes of all new windows.
3273 (setq sub (append (pop subs) nil))
3274 (while (and (not (assq (car sub) gnus-window-to-buffer))
3275 (gnus-functionp (car sub)))
3276 (setq sub (eval sub)))
3278 (push sub comp-subs)
3279 (setq size (cadar comp-subs))
3280 (cond ((equal size 1.0)
3281 (setq rest (car comp-subs))
3284 (setq s (floor (* size len))))
3288 (error "Illegal size: %s" size)))
3289 ;; Try to make sure that we are inside the safe limits.
3291 ((eq type 'horizontal)
3292 (setq s (max s window-min-width)))
3293 ((eq type 'vertical)
3294 (setq s (max s window-min-height))))
3295 (setcar (cdar comp-subs) s)
3297 ;; Take care of the "1.0" spec.
3299 (setcar (cdr rest) (- len total))
3300 (error "No 1.0 specs in %s" split))
3301 ;; The we do the actual splitting in a nice recursive
3303 (setq comp-subs (nreverse comp-subs))
3305 (if (null (cdr comp-subs))
3306 (setq new-win window)
3308 (split-window window (cadar comp-subs)
3309 (eq type 'horizontal))))
3310 (setq result (or (gnus-configure-frame
3311 (car comp-subs) window) result))
3312 (select-window new-win)
3313 (setq window new-win)
3314 (setq comp-subs (cdr comp-subs))))
3315 ;; Return the proper window, if any.
3317 (select-window result))))))
3319 (defvar gnus-frame-split-p nil)
3321 (defun gnus-configure-windows (setting &optional force)
3322 (setq setting (gnus-windows-old-to-new setting))
3323 (let ((split (if (symbolp setting)
3324 (cadr (assq setting gnus-buffer-configuration))
3326 (in-buf (current-buffer))
3327 rule val w height hor ohor heights sub jump-buffer
3328 rel total to-buf all-visible)
3330 (setq gnus-frame-split-p nil)
3333 (error "No such setting: %s" setting))
3335 (if (and (setq all-visible (gnus-all-windows-visible-p split))
3337 ;; All the windows mentioned are already visible, so we just
3338 ;; put point in the assigned buffer, and do not touch the
3340 (select-window all-visible)
3342 ;; Either remove all windows or just remove all Gnus windows.
3343 (let ((frame (selected-frame)))
3345 (if gnus-use-full-window
3346 ;; We want to remove all other windows.
3347 (if (not gnus-frame-split-p)
3348 ;; This is not a `frame' split, so we ignore the
3350 (delete-other-windows)
3351 ;; This is a `frame' split, so we delete all windows
3355 (unless (eq (cdr (assq 'minibuffer
3356 (frame-parameters frame)))
3358 (select-frame frame)
3359 (delete-other-windows)))
3361 ;; Just remove some windows.
3362 (gnus-remove-some-windows)
3363 (switch-to-buffer nntp-server-buffer))
3364 (select-frame frame)))
3366 (switch-to-buffer nntp-server-buffer)
3367 (gnus-configure-frame split (get-buffer-window (current-buffer))))))
3369 (defun gnus-all-windows-visible-p (split)
3370 (when (vectorp split)
3371 (setq split (append split nil)))
3372 (when (or (consp (car split))
3373 (vectorp (car split)))
3375 (push 'vertical split))
3376 ;; The SPLIT might be something that is to be evaled to
3377 ;; return a new SPLIT.
3378 (while (and (not (assq (car split) gnus-window-to-buffer))
3379 (gnus-functionp (car split)))
3380 (setq split (eval split)))
3381 (let* ((type (elt split 0)))
3385 ((not (or (eq type 'horizontal) (eq type 'vertical) (eq type 'frame)))
3386 (let ((buffer (cond ((stringp type) type)
3387 (t (cdr (assq type gnus-window-to-buffer)))))
3390 (error "Illegal buffer type: %s" type))
3391 (when (setq buf (get-buffer (if (symbolp buffer) (symbol-value buffer)
3393 (setq win (get-buffer-window buf t)))
3395 (if (memq 'point split)
3399 (when (eq type 'frame)
3400 (setq gnus-frame-split-p t))
3401 (let ((n (mapcar 'gnus-all-windows-visible-p
3405 (cond ((windowp (car n))
3412 (defun gnus-window-top-edge (&optional window)
3413 (nth 1 (window-edges window)))
3415 (defun gnus-remove-some-windows ()
3416 (let ((buffers gnus-window-to-buffer)
3417 buf bufs lowest-buf lowest)
3419 ;; Remove windows on all known Gnus buffers.
3421 (setq buf (cdar buffers))
3423 (setq buf (and (boundp buf) (symbol-value buf))))
3425 (get-buffer-window buf)
3427 (setq bufs (cons buf bufs))
3429 (if (or (not lowest)
3430 (< (gnus-window-top-edge) lowest))
3432 (setq lowest (gnus-window-top-edge))
3433 (setq lowest-buf buf)))))
3434 (setq buffers (cdr buffers)))
3435 ;; Remove windows on *all* summary buffers.
3439 (let ((buf (window-buffer win)))
3440 (if (string-match "^\\*Summary" (buffer-name buf))
3442 (setq bufs (cons buf bufs))
3444 (if (or (not lowest)
3445 (< (gnus-window-top-edge) lowest))
3447 (setq lowest-buf buf)
3448 (setq lowest (gnus-window-top-edge))))))))))
3451 (pop-to-buffer lowest-buf)
3452 (switch-to-buffer nntp-server-buffer)))
3454 (and (not (eq (car bufs) lowest-buf))
3455 (delete-windows-on (car bufs)))
3456 (setq bufs (cdr bufs))))))
3458 (defun gnus-version ()
3459 "Version numbers of this version of Gnus."
3461 (let ((methods gnus-valid-select-methods)
3464 ;; Go through all the legal select methods and add their version
3465 ;; numbers to the total version string. Only the backends that are
3466 ;; currently in use will have their message numbers taken into
3469 (setq meth (intern (concat (caar methods) "-version")))
3471 (stringp (symbol-value meth))
3472 (setq mess (concat mess "; " (symbol-value meth))))
3473 (setq methods (cdr methods)))
3474 (gnus-message 2 mess)))
3476 (defun gnus-info-find-node ()
3477 "Find Info documentation of Gnus."
3479 ;; Enlarge info window if needed.
3480 (let ((mode major-mode)
3482 (Info-goto-node (cadr (assq mode gnus-info-nodes)))
3483 (setq gnus-info-buffer (current-buffer))
3484 (gnus-configure-windows 'info)))
3486 (defun gnus-days-between (date1 date2)
3487 ;; Return the number of days between date1 and date2.
3488 (- (gnus-day-number date1) (gnus-day-number date2)))
3490 (defun gnus-day-number (date)
3491 (let ((dat (mapcar (lambda (s) (and s (string-to-int s)) )
3492 (timezone-parse-date date))))
3493 (timezone-absolute-from-gregorian
3494 (nth 1 dat) (nth 2 dat) (car dat))))
3496 (defun gnus-encode-date (date)
3497 "Convert DATE to internal time."
3498 (let* ((parse (timezone-parse-date date))
3499 (date (mapcar (lambda (d) (and d (string-to-int d))) parse))
3500 (time (mapcar 'string-to-int (timezone-parse-time (aref parse 3)))))
3501 (encode-time (caddr time) (cadr time) (car time)
3502 (caddr date) (cadr date) (car date) (nth 4 date))))
3504 (defun gnus-time-minus (t1 t2)
3505 "Subtract two internal times."
3506 (let ((borrow (< (cadr t1) (cadr t2))))
3507 (list (- (car t1) (car t2) (if borrow 1 0))
3508 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))
3510 (defun gnus-file-newer-than (file date)
3511 (let ((fdate (nth 5 (file-attributes file))))
3512 (or (> (car fdate) (car date))
3513 (and (= (car fdate) (car date))
3514 (> (nth 1 fdate) (nth 1 date))))))
3516 (defmacro gnus-local-set-keys (&rest plist)
3517 "Set the keys in PLIST in the current keymap."
3518 `(gnus-define-keys-1 (current-local-map) ',plist))
3520 (defmacro gnus-define-keys (keymap &rest plist)
3521 "Define all keys in PLIST in KEYMAP."
3522 `(gnus-define-keys-1 (quote ,keymap) (quote ,plist)))
3524 (put 'gnus-define-keys 'lisp-indent-function 1)
3525 (put 'gnus-define-keys 'lisp-indent-hook 1)
3526 (put 'gnus-define-keymap 'lisp-indent-function 1)
3527 (put 'gnus-define-keymap 'lisp-indent-hook 1)
3529 (defmacro gnus-define-keymap (keymap &rest plist)
3530 "Define all keys in PLIST in KEYMAP."
3531 `(gnus-define-keys-1 ,keymap (quote ,plist)))
3533 (defun gnus-define-keys-1 (keymap plist)
3535 (error "Can't set keys in a null keymap"))
3536 (cond ((symbolp keymap)
3537 (setq keymap (symbol-value keymap)))
3540 (set (car keymap) nil)
3541 (define-prefix-command (car keymap))
3542 (define-key (symbol-value (caddr keymap)) (cadr keymap) (car keymap))
3543 (setq keymap (symbol-value (car keymap)))))
3546 (when (symbolp (setq key (pop plist)))
3547 (setq key (symbol-value key)))
3548 (define-key keymap key (pop plist)))))
3550 (defun gnus-group-read-only-p (&optional group)
3551 "Check whether GROUP supports editing or not.
3552 If GROUP is nil, `gnus-newsgroup-name' will be checked instead. Note
3553 that that variable is buffer-local to the summary buffers."
3554 (let ((group (or group gnus-newsgroup-name)))
3555 (not (gnus-check-backend-function 'request-replace-article group))))
3557 (defun gnus-group-total-expirable-p (group)
3558 "Check whether GROUP is total-expirable or not."
3559 (let ((params (gnus-info-params (gnus-get-info group))))
3560 (or (memq 'total-expire params)
3561 (cdr (assq 'total-expire params)) ; (total-expire . t)
3562 (and gnus-total-expirable-newsgroups ; Check var.
3563 (string-match gnus-total-expirable-newsgroups group)))))
3565 (defun gnus-group-auto-expirable-p (group)
3566 "Check whether GROUP is total-expirable or not."
3567 (let ((params (gnus-info-params (gnus-get-info group))))
3568 (or (memq 'auto-expire params)
3569 (cdr (assq 'auto-expire params)) ; (auto-expire . t)
3570 (and gnus-auto-expirable-newsgroups ; Check var.
3571 (string-match gnus-auto-expirable-newsgroups group)))))
3573 (defun gnus-virtual-group-p (group)
3574 "Say whether GROUP is virtual or not."
3575 (memq 'virtual (assoc (symbol-name (car (gnus-find-method-for-group group)))
3576 gnus-valid-select-methods)))
3578 (defsubst gnus-simplify-subject-fully (subject)
3579 "Simplify a subject string according to the user's wishes."
3581 ((null gnus-summary-gather-subject-limit)
3582 (gnus-simplify-subject-re subject))
3583 ((eq gnus-summary-gather-subject-limit 'fuzzy)
3584 (gnus-simplify-subject-fuzzy subject))
3585 ((numberp gnus-summary-gather-subject-limit)
3586 (gnus-limit-string (gnus-simplify-subject-re subject)
3587 gnus-summary-gather-subject-limit))
3591 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
3592 "Check whether two subjects are equal. If optional argument
3593 simple-first is t, first argument is already simplified."
3595 ((null simple-first)
3596 (equal (gnus-simplify-subject-fully s1)
3597 (gnus-simplify-subject-fully s2)))
3600 (gnus-simplify-subject-fully s2)))))
3602 ;; Returns a list of writable groups.
3603 (defun gnus-writable-groups ()
3604 (let ((alist gnus-newsrc-alist)
3606 (while (setq group (car (pop alist)))
3607 (unless (gnus-group-read-only-p group)
3608 (push group groups)))
3611 ;; Two silly functions to ensure that all `y-or-n-p' questions clear
3613 (defun gnus-y-or-n-p (prompt)
3618 (defun gnus-yes-or-no-p (prompt)
3620 (yes-or-no-p prompt)
3623 ;; Check whether to use long file names.
3624 (defun gnus-use-long-file-name (symbol)
3625 ;; The variable has to be set...
3626 (and gnus-use-long-file-name
3627 ;; If it isn't a list, then we return t.
3628 (or (not (listp gnus-use-long-file-name))
3629 ;; If it is a list, and the list contains `symbol', we
3631 (not (memq symbol gnus-use-long-file-name)))))
3633 ;; I suspect there's a better way, but I haven't taken the time to do
3634 ;; it yet. -erik selberg@cs.washington.edu
3635 (defun gnus-dd-mmm (messy-date)
3636 "Return a string like DD-MMM from a big messy string"
3637 (let ((datevec (timezone-parse-date messy-date)))
3640 ;; Make sure leading zeroes are stripped.
3641 (number-to-string (string-to-number (aref datevec 2)))
3645 (nth (1- (string-to-number (aref datevec 1)))
3646 timezone-months-assoc))
3649 ;; Make a hash table (default and minimum size is 255).
3650 ;; Optional argument HASHSIZE specifies the table size.
3651 (defun gnus-make-hashtable (&optional hashsize)
3652 (make-vector (if hashsize (max (gnus-create-hash-size hashsize) 255) 255) 0))
3654 ;; Make a number that is suitable for hashing; bigger than MIN and one
3656 (defun gnus-create-hash-size (min)
3662 ;; Show message if message has a lower level than `gnus-verbose'.
3663 ;; Guideline for numbers:
3664 ;; 1 - error messages, 3 - non-serious error messages, 5 - messages
3665 ;; for things that take a long time, 7 - not very important messages
3666 ;; on stuff, 9 - messages inside loops.
3667 (defun gnus-message (level &rest args)
3668 (if (<= level gnus-verbose)
3669 (apply 'message args)
3670 ;; We have to do this format thingy here even if the result isn't
3671 ;; shown - the return value has to be the same as the return value
3673 (apply 'format args)))
3675 (defun gnus-functionp (form)
3676 "Return non-nil if FORM is funcallable."
3677 (or (and (symbolp form) (fboundp form))
3678 (and (listp form) (eq (car form) 'lambda))))
3680 ;; Generate a unique new group name.
3681 (defun gnus-generate-new-group-name (leaf)
3684 (while (gnus-gethash name gnus-newsrc-hashtb)
3685 (setq name (concat leaf "<" (int-to-string (setq num (1+ num))) ">")))
3688 ;; Find out whether the gnus-visual TYPE is wanted.
3689 (defun gnus-visual-p (&optional type class)
3690 (and gnus-visual ; Has to be non-nil, at least.
3691 (if (not type) ; We don't care about type.
3693 (if (listp gnus-visual) ; It's a list, so we check it.
3694 (or (memq type gnus-visual)
3695 (memq class gnus-visual))
3698 (defun gnus-parent-id (references)
3699 "Return the last Message-ID in REFERENCES."
3700 (when (and references
3701 (string-match "\\(<[^<>]+>\\)[ \t\n]*\\'" references))
3702 (substring references (match-beginning 1) (match-end 1))))
3704 (defun gnus-split-references (references)
3705 "Return a list of Message-IDs in REFERENCES."
3708 (while (string-match "<[^>]+>" references beg)
3709 (push (substring references (match-beginning 0) (setq beg (match-end 0)))
3713 (defun gnus-ephemeral-group-p (group)
3714 "Say whether GROUP is ephemeral or not."
3715 (gnus-group-get-parameter group 'quit-config))
3717 (defun gnus-group-quit-config (group)
3718 "Return the quit-config of GROUP."
3719 (gnus-group-get-parameter group 'quit-config))
3721 (defun gnus-simplify-mode-line ()
3722 "Make mode lines a bit simpler."
3723 (setq mode-line-modified "-- ")
3724 (when (listp mode-line-format)
3725 (make-local-variable 'mode-line-format)
3726 (setq mode-line-format (copy-sequence mode-line-format))
3727 (when (equal (nth 3 mode-line-format) " ")
3728 (setcar (nthcdr 3 mode-line-format) " "))))
3730 ;;; List and range functions
3732 (defun gnus-last-element (list)
3733 "Return last element of LIST."
3735 (setq list (cdr list)))
3738 (defun gnus-copy-sequence (list)
3739 "Do a complete, total copy of a list."
3740 (if (and (consp list) (not (consp (cdr list))))
3741 (cons (car list) (cdr list))
3742 (mapcar (lambda (elem) (if (consp elem)
3743 (if (consp (cdr elem))
3744 (gnus-copy-sequence elem)
3745 (cons (car elem) (cdr elem)))
3749 (defun gnus-set-difference (list1 list2)
3750 "Return a list of elements of LIST1 that do not appear in LIST2."
3751 (let ((list1 (copy-sequence list1)))
3753 (setq list1 (delq (car list2) list1))
3754 (setq list2 (cdr list2)))
3757 (defun gnus-sorted-complement (list1 list2)
3758 "Return a list of elements of LIST1 that do not appear in LIST2.
3759 Both lists have to be sorted over <."
3761 (if (or (null list1) (null list2))
3763 (while (and list1 list2)
3764 (cond ((= (car list1) (car list2))
3765 (setq list1 (cdr list1)
3767 ((< (car list1) (car list2))
3768 (setq out (cons (car list1) out))
3769 (setq list1 (cdr list1)))
3771 (setq out (cons (car list2) out))
3772 (setq list2 (cdr list2)))))
3773 (nconc (nreverse out) (or list1 list2)))))
3775 (defun gnus-intersection (list1 list2)
3778 (if (memq (car list2) list1)
3779 (setq result (cons (car list2) result)))
3780 (setq list2 (cdr list2)))
3783 (defun gnus-sorted-intersection (list1 list2)
3784 ;; LIST1 and LIST2 have to be sorted over <.
3786 (while (and list1 list2)
3787 (cond ((= (car list1) (car list2))
3788 (setq out (cons (car list1) out)
3791 ((< (car list1) (car list2))
3792 (setq list1 (cdr list1)))
3794 (setq list2 (cdr list2)))))
3797 (defun gnus-set-sorted-intersection (list1 list2)
3798 ;; LIST1 and LIST2 have to be sorted over <.
3799 ;; This function modifies LIST1.
3800 (let* ((top (cons nil list1))
3802 (while (and list1 list2)
3803 (cond ((= (car list1) (car list2))
3807 ((< (car list1) (car list2))
3808 (setcdr prev (cdr list1))
3809 (setq list1 (cdr list1)))
3811 (setq list2 (cdr list2)))))
3815 (defun gnus-compress-sequence (numbers &optional always-list)
3816 "Convert list of numbers to a list of ranges or a single range.
3817 If ALWAYS-LIST is non-nil, this function will always release a list of
3819 (let* ((first (car numbers))
3820 (last (car numbers))
3824 (if (not (listp (cdr numbers)))
3827 (cond ((= last (car numbers)) nil) ;Omit duplicated number
3828 ((= (1+ last) (car numbers)) ;Still in sequence
3829 (setq last (car numbers)))
3830 (t ;End of one sequence
3832 (cons (if (= first last) first
3833 (cons first last)) result))
3834 (setq first (car numbers))
3835 (setq last (car numbers))))
3836 (setq numbers (cdr numbers)))
3837 (if (and (not always-list) (null result))
3838 (if (= first last) (list first) (cons first last))
3839 (nreverse (cons (if (= first last) first (cons first last))
3842 (defalias 'gnus-uncompress-sequence 'gnus-uncompress-range)
3843 (defun gnus-uncompress-range (ranges)
3844 "Expand a list of ranges into a list of numbers.
3845 RANGES is either a single range on the form `(num . num)' or a list of
3847 (let (first last result)
3851 ((not (listp (cdr ranges)))
3852 (setq first (car ranges))
3853 (setq last (cdr ranges))
3854 (while (<= first last)
3855 (setq result (cons first result))
3856 (setq first (1+ first)))
3860 (if (atom (car ranges))
3861 (if (numberp (car ranges))
3862 (setq result (cons (car ranges) result)))
3863 (setq first (caar ranges))
3864 (setq last (cdar ranges))
3865 (while (<= first last)
3866 (setq result (cons first result))
3867 (setq first (1+ first))))
3868 (setq ranges (cdr ranges)))
3869 (nreverse result)))))
3871 (defun gnus-add-to-range (ranges list)
3872 "Return a list of ranges that has all articles from both RANGES and LIST.
3873 Note: LIST has to be sorted over `<'."
3875 (gnus-compress-sequence list t)
3876 (setq list (copy-sequence list))
3877 (or (listp (cdr ranges))
3878 (setq ranges (list ranges)))
3880 ilist lowest highest temp)
3881 (while (and ranges list)
3883 (setq lowest (or (and (atom (car ranges)) (car ranges))
3885 (while (and list (cdr list) (< (cadr list) lowest))
3886 (setq list (cdr list)))
3887 (if (< (car ilist) lowest)
3890 (setq list (cdr list))
3892 (setq out (nconc (gnus-compress-sequence ilist t) out))))
3893 (setq highest (or (and (atom (car ranges)) (car ranges))
3895 (while (and list (<= (car list) highest))
3896 (setq list (cdr list)))
3897 (setq ranges (cdr ranges)))
3899 (setq out (nconc (gnus-compress-sequence list t) out)))
3900 (setq out (sort out (lambda (r1 r2)
3901 (< (or (and (atom r1) r1) (car r1))
3902 (or (and (atom r2) r2) (car r2))))))
3905 (if (atom (car ranges))
3907 (if (atom (cadr ranges))
3908 (if (= (1+ (car ranges)) (cadr ranges))
3910 (setcar ranges (cons (car ranges)
3912 (setcdr ranges (cddr ranges))))
3913 (if (= (1+ (car ranges)) (caadr ranges))
3915 (setcar (cadr ranges) (car ranges))
3916 (setcar ranges (cadr ranges))
3917 (setcdr ranges (cddr ranges))))))
3919 (if (atom (cadr ranges))
3920 (if (= (1+ (cdar ranges)) (cadr ranges))
3922 (setcdr (car ranges) (cadr ranges))
3923 (setcdr ranges (cddr ranges))))
3924 (if (= (1+ (cdar ranges)) (caadr ranges))
3926 (setcdr (car ranges) (cdadr ranges))
3927 (setcdr ranges (cddr ranges)))))))
3928 (setq ranges (cdr ranges)))
3931 (defun gnus-remove-from-range (ranges list)
3932 "Return a list of ranges that has all articles from LIST removed from RANGES.
3933 Note: LIST has to be sorted over `<'."
3934 ;; !!! This function shouldn't look like this, but I've got a headache.
3935 (gnus-compress-sequence
3936 (gnus-sorted-complement
3937 (gnus-uncompress-range ranges) list)))
3939 (defun gnus-member-of-range (number ranges)
3940 (if (not (listp (cdr ranges)))
3941 (and (>= number (car ranges))
3942 (<= number (cdr ranges)))
3945 (if (numberp (car ranges))
3946 (>= number (car ranges))
3947 (>= number (caar ranges)))
3949 (if (if (numberp (car ranges))
3950 (= number (car ranges))
3951 (and (>= number (caar ranges))
3952 (<= number (cdar ranges))))
3953 (setq not-stop nil))
3954 (setq ranges (cdr ranges)))
3957 (defun gnus-range-length (range)
3958 "Return the length RANGE would have if uncompressed."
3959 (length (gnus-uncompress-range range)))
3961 (defun gnus-sublist-p (list sublist)
3962 "Test whether all elements in SUBLIST are members of LIST."
3965 (unless (memq (pop sublist) list)
3975 (defvar gnus-group-mode-map nil)
3976 (put 'gnus-group-mode 'mode-class 'special)
3978 (unless gnus-group-mode-map
3979 (setq gnus-group-mode-map (make-keymap))
3980 (suppress-keymap gnus-group-mode-map)
3982 (gnus-define-keys gnus-group-mode-map
3983 " " gnus-group-read-group
3984 "=" gnus-group-select-group
3985 "\r" gnus-group-select-group
3986 "\M-\r" gnus-group-quick-select-group
3987 "j" gnus-group-jump-to-group
3988 "n" gnus-group-next-unread-group
3989 "p" gnus-group-prev-unread-group
3990 "\177" gnus-group-prev-unread-group
3991 [delete] gnus-group-prev-unread-group
3992 "N" gnus-group-next-group
3993 "P" gnus-group-prev-group
3994 "\M-n" gnus-group-next-unread-group-same-level
3995 "\M-p" gnus-group-prev-unread-group-same-level
3996 "," gnus-group-best-unread-group
3997 "." gnus-group-first-unread-group
3998 "u" gnus-group-unsubscribe-current-group
3999 "U" gnus-group-unsubscribe-group
4000 "c" gnus-group-catchup-current
4001 "C" gnus-group-catchup-current-all
4002 "l" gnus-group-list-groups
4003 "L" gnus-group-list-all-groups
4005 "g" gnus-group-get-new-news
4006 "\M-g" gnus-group-get-new-news-this-group
4007 "R" gnus-group-restart
4008 "r" gnus-group-read-init-file
4009 "B" gnus-group-browse-foreign-server
4010 "b" gnus-group-check-bogus-groups
4011 "F" gnus-find-new-newsgroups
4012 "\C-c\C-d" gnus-group-describe-group
4013 "\M-d" gnus-group-describe-all-groups
4014 "\C-c\C-a" gnus-group-apropos
4015 "\C-c\M-\C-a" gnus-group-description-apropos
4016 "a" gnus-group-post-news
4017 "\ek" gnus-group-edit-local-kill
4018 "\eK" gnus-group-edit-global-kill
4019 "\C-k" gnus-group-kill-group
4020 "\C-y" gnus-group-yank-group
4021 "\C-w" gnus-group-kill-region
4022 "\C-x\C-t" gnus-group-transpose-groups
4023 "\C-c\C-l" gnus-group-list-killed
4024 "\C-c\C-x" gnus-group-expire-articles
4025 "\C-c\M-\C-x" gnus-group-expire-all-groups
4027 "s" gnus-group-save-newsrc
4028 "z" gnus-group-suspend
4029 "Z" gnus-group-clear-dribble
4032 "?" gnus-group-describe-briefly
4033 "\C-c\C-i" gnus-info-find-node
4034 "\M-e" gnus-group-edit-group-method
4035 "^" gnus-group-enter-server-mode
4036 gnus-mouse-2 gnus-mouse-pick-group
4037 "<" beginning-of-buffer
4040 "\C-c\C-s" gnus-group-sort-groups
4042 "\C-c\M-g" gnus-activate-all-groups
4043 "\M-&" gnus-group-universal-argument
4044 "#" gnus-group-mark-group
4045 "\M-#" gnus-group-unmark-group)
4047 (gnus-define-keys (gnus-group-mark-map "M" gnus-group-mode-map)
4048 "m" gnus-group-mark-group
4049 "u" gnus-group-unmark-group
4050 "w" gnus-group-mark-region
4051 "m" gnus-group-mark-buffer
4052 "r" gnus-group-mark-regexp
4053 "U" gnus-group-unmark-all-groups)
4055 (gnus-define-keys (gnus-group-group-map "G" gnus-group-mode-map)
4056 "d" gnus-group-make-directory-group
4057 "h" gnus-group-make-help-group
4058 "a" gnus-group-make-archive-group
4059 "k" gnus-group-make-kiboze-group
4060 "m" gnus-group-make-group
4061 "E" gnus-group-edit-group
4062 "e" gnus-group-edit-group-method
4063 "p" gnus-group-edit-group-parameters
4064 "v" gnus-group-add-to-virtual
4065 "V" gnus-group-make-empty-virtual
4066 "D" gnus-group-enter-directory
4067 "f" gnus-group-make-doc-group
4068 "r" gnus-group-rename-group
4069 "\177" gnus-group-delete-group
4070 [delete] gnus-group-delete-group)
4072 (gnus-define-keys (gnus-group-soup-map "s" gnus-group-group-map)
4073 "b" gnus-group-brew-soup
4074 "w" gnus-soup-save-areas
4075 "s" gnus-soup-send-replies
4076 "p" gnus-soup-pack-packet
4077 "r" nnsoup-pack-replies)
4079 (gnus-define-keys (gnus-group-sort-map "S" gnus-group-group-map)
4080 "s" gnus-group-sort-groups
4081 "a" gnus-group-sort-groups-by-alphabet
4082 "u" gnus-group-sort-groups-by-unread
4083 "l" gnus-group-sort-groups-by-level
4084 "v" gnus-group-sort-groups-by-score
4085 "r" gnus-group-sort-groups-by-rank
4086 "m" gnus-group-sort-groups-by-method)
4088 (gnus-define-keys (gnus-group-list-map "A" gnus-group-mode-map)
4089 "k" gnus-group-list-killed
4090 "z" gnus-group-list-zombies
4091 "s" gnus-group-list-groups
4092 "u" gnus-group-list-all-groups
4093 "A" gnus-group-list-active
4094 "a" gnus-group-apropos
4095 "d" gnus-group-description-apropos
4096 "m" gnus-group-list-matching
4097 "M" gnus-group-list-all-matching
4098 "l" gnus-group-list-level)
4100 (gnus-define-keys (gnus-group-score-map "W" gnus-group-mode-map)
4101 "f" gnus-score-flush-cache)
4103 (gnus-define-keys (gnus-group-help-map "H" gnus-group-mode-map)
4104 "f" gnus-group-fetch-faq)
4106 (gnus-define-keys (gnus-group-sub-map "S" gnus-group-mode-map)
4107 "l" gnus-group-set-current-level
4108 "t" gnus-group-unsubscribe-current-group
4109 "s" gnus-group-unsubscribe-group
4110 "k" gnus-group-kill-group
4111 "y" gnus-group-yank-group
4112 "w" gnus-group-kill-region
4113 "\C-k" gnus-group-kill-level
4114 "z" gnus-group-kill-all-zombies))
4116 (defun gnus-group-mode ()
4117 "Major mode for reading news.
4119 All normal editing commands are switched off.
4120 \\<gnus-group-mode-map>
4121 The group buffer lists (some of) the groups available. For instance,
4122 `\\[gnus-group-list-groups]' will list all subscribed groups with unread articles, while `\\[gnus-group-list-zombies]'
4123 lists all zombie groups.
4125 Groups that are displayed can be entered with `\\[gnus-group-read-group]'. To subscribe
4126 to a group not displayed, type `\\[gnus-group-unsubscribe-group]'.
4128 For more in-depth information on this mode, read the manual (`\\[gnus-info-find-node]').
4130 The following commands are available:
4132 \\{gnus-group-mode-map}"
4134 (when (and menu-bar-mode
4135 (gnus-visual-p 'group-menu 'menu))
4136 (gnus-group-make-menu-bar))
4137 (kill-all-local-variables)
4138 (gnus-simplify-mode-line)
4139 (setq major-mode 'gnus-group-mode)
4140 (setq mode-name "Group")
4141 (gnus-group-set-mode-line)
4142 (setq mode-line-process nil)
4143 (use-local-map gnus-group-mode-map)
4144 (buffer-disable-undo (current-buffer))
4145 (setq truncate-lines t)
4146 (setq buffer-read-only t)
4147 (run-hooks 'gnus-group-mode-hook))
4149 (defun gnus-mouse-pick-group (e)
4150 "Enter the group under the mouse pointer."
4153 (gnus-group-read-group nil))
4155 ;; Look at LEVEL and find out what the level is really supposed to be.
4156 ;; If LEVEL is non-nil, LEVEL will be returned, if not, what happens
4157 ;; will depend on whether `gnus-group-use-permanent-levels' is used.
4158 (defun gnus-group-default-level (&optional level number-or-nil)
4160 (gnus-group-use-permanent-levels
4161 (setq gnus-group-default-list-level
4162 (or level gnus-group-default-list-level))
4163 (or gnus-group-default-list-level gnus-level-subscribed))
4167 (or level gnus-group-default-list-level gnus-level-subscribed))))
4170 (defun gnus-slave-no-server (&optional arg)
4171 "Read network news as a slave, without connecting to local server"
4173 (gnus-no-server arg t))
4176 (defun gnus-no-server (&optional arg slave)
4178 If ARG is a positive number, Gnus will use that as the
4179 startup level. If ARG is nil, Gnus will be started at level 2.
4180 If ARG is non-nil and not a positive number, Gnus will
4181 prompt the user for the name of an NNTP server to use.
4182 As opposed to `gnus', this command will not connect to the local server."
4184 (make-local-variable 'gnus-group-use-permanent-levels)
4185 (setq gnus-group-use-permanent-levels t)
4186 (gnus (or arg (1- gnus-level-default-subscribed)) t slave))
4189 (defun gnus-slave (&optional arg)
4190 "Read news as a slave."
4192 (gnus arg nil 'slave))
4195 (defun gnus-other-frame (&optional arg)
4196 "Pop up a frame to read news."
4198 (if (get-buffer gnus-group-buffer)
4199 (let ((pop-up-frames t))
4201 (select-frame (make-frame))
4205 (defun gnus (&optional arg dont-connect slave)
4207 If ARG is non-nil and a positive number, Gnus will use that as the
4208 startup level. If ARG is non-nil and not a positive number, Gnus will
4209 prompt the user for the name of an NNTP server to use."
4212 (if (get-buffer gnus-group-buffer)
4214 (switch-to-buffer gnus-group-buffer)
4215 (gnus-group-get-new-news))
4218 (nnheader-init-server-buffer)
4219 (gnus-read-init-file)
4220 (setq gnus-slave slave)
4222 (gnus-group-setup-buffer)
4223 (let ((buffer-read-only nil))
4225 (if (not gnus-inhibit-startup-message)
4227 (gnus-group-startup-message)
4230 (let ((level (and (numberp arg) (> arg 0) arg))
4236 (gnus-start-news-server (and arg (not level))))))
4237 (if (and (not dont-connect)
4240 (run-hooks 'gnus-startup-hook)
4241 ;; NNTP server is successfully open.
4243 ;; Find the current startup file name.
4244 (setq gnus-current-startup-file
4245 (gnus-make-newsrc-file gnus-startup-file))
4247 ;; Read the dribble file.
4248 (and (or gnus-slave gnus-use-dribble-file) (gnus-dribble-read-file))
4250 ;; Allow using GroupLens predictions.
4251 (when gnus-use-grouplens
4253 (add-hook 'gnus-summary-mode-hook 'gnus-grouplens-mode))
4255 (gnus-summary-make-display-table)
4256 ;; Do the actual startup.
4257 (gnus-setup-news nil level dont-connect)
4258 ;; Generate the group buffer.
4259 (gnus-group-list-groups level)
4260 (gnus-group-first-unread-group)
4261 (gnus-configure-windows 'group)
4262 (gnus-group-set-mode-line))))))
4264 (defun gnus-unload ()
4265 "Unload all Gnus features."
4267 (or (boundp 'load-history)
4268 (error "Sorry, `gnus-unload' is not implemented in this Emacs version."))
4269 (let ((history load-history)
4272 (and (string-match "^\\(gnus\\|nn\\)" (caar history))
4273 (setq feature (cdr (assq 'provide (car history))))
4274 (unload-feature feature 'force))
4275 (setq history (cdr history)))))
4277 (defun gnus-compile ()
4278 "Byte-compile the user-defined format specs."
4280 (let ((entries gnus-format-specs)
4281 entry gnus-tmp-func)
4283 (gnus-message 7 "Compiling format specs...")
4286 (setq entry (pop entries))
4287 (if (eq (car entry) 'version)
4288 (setq gnus-format-specs (delq entry gnus-format-specs))
4289 (when (and (listp (caddr entry))
4290 (not (eq 'byte-code (caaddr entry))))
4291 (fset 'gnus-tmp-func
4292 `(lambda () ,(caddr entry)))
4293 (byte-compile 'gnus-tmp-func)
4294 (setcar (cddr entry) (gnus-byte-code 'gnus-tmp-func)))))
4296 (push (cons 'version emacs-version) gnus-format-specs)
4298 (gnus-message 7 "Compiling user specs...done"))))
4300 (defun gnus-indent-rigidly (start end arg)
4301 "Indent rigidly using only spaces and no tabs."
4304 (narrow-to-region start end)
4305 (indent-rigidly start end arg)
4306 (goto-char (point-min))
4307 (while (search-forward "\t" nil t)
4308 (replace-match " " t t)))))
4310 (defun gnus-group-startup-message (&optional x y)
4311 "Insert startup message in current buffer."
4312 ;; Insert the message.
4317 _ ___ __ ___ __ _ ___
4336 ;; And then hack it.
4337 (gnus-indent-rigidly (point-min) (point-max)
4338 (/ (max (- (window-width) (or x 46)) 0) 2))
4339 (goto-char (point-min))
4341 (let* ((pheight (count-lines (point-min) (point-max)))
4342 (wheight (window-height))
4343 (rest (- wheight pheight)))
4344 (insert (make-string (max 0 (* 2 (/ rest 3))) ?\n)))
4346 (goto-char (point-min))
4347 (and (search-forward "Praxis" nil t)
4348 (put-text-property (match-beginning 0) (match-end 0) 'face 'bold))
4349 (goto-char (point-min))
4350 (let* ((mode-string (gnus-group-set-mode-line)))
4351 (setq mode-line-buffer-identification
4352 (list (concat gnus-version (substring (car mode-string) 4))))
4353 (set-buffer-modified-p t)))
4355 (defun gnus-group-setup-buffer ()
4356 (or (get-buffer gnus-group-buffer)
4358 (switch-to-buffer gnus-group-buffer)
4359 (gnus-add-current-to-buffer-list)
4361 (and gnus-carpal (gnus-carpal-setup-buffer 'group)))))
4363 (defun gnus-group-list-groups (&optional level unread lowest)
4364 "List newsgroups with level LEVEL or lower that have unread articles.
4365 Default is all subscribed groups.
4366 If argument UNREAD is non-nil, groups with no unread articles are also
4368 (interactive (list (if current-prefix-arg
4369 (prefix-numeric-value current-prefix-arg)
4371 (gnus-group-default-level nil t)
4372 gnus-group-default-list-level
4373 gnus-level-subscribed))))
4375 (setq level (car gnus-group-list-mode)
4376 unread (cdr gnus-group-list-mode)))
4377 (setq level (gnus-group-default-level level))
4378 (gnus-group-setup-buffer) ;May call from out of group buffer
4379 (gnus-update-format-specifications)
4380 (let ((case-fold-search nil)
4381 (props (text-properties-at (gnus-point-at-bol)))
4382 (group (gnus-group-group-name)))
4383 (set-buffer gnus-group-buffer)
4384 (funcall gnus-group-prepare-function level unread lowest)
4385 (if (zerop (buffer-size))
4386 (gnus-message 5 gnus-no-groups-message)
4387 (goto-char (point-max))
4388 (when (or (not gnus-group-goto-next-group-function)
4389 (not (funcall gnus-group-goto-next-group-function
4392 ;; Go to the first group with unread articles.
4393 (gnus-group-search-forward t)
4394 ;; Find the right group to put point on. If the current group
4395 ;; has disappeared in the new listing, try to find the next
4396 ;; one. If no next one can be found, just leave point at the
4397 ;; first newsgroup in the buffer.
4398 (if (not (gnus-goto-char
4400 (point-min) (point-max)
4401 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
4402 (let ((newsrc (cdddr (gnus-gethash group gnus-newsrc-hashtb))))
4404 (not (gnus-goto-char
4406 (point-min) (point-max) 'gnus-group
4408 (caar newsrc) gnus-active-hashtb)))))
4409 (setq newsrc (cdr newsrc)))
4410 (or newsrc (progn (goto-char (point-max))
4411 (forward-line -1)))))))
4412 ;; Adjust cursor point.
4413 (gnus-group-position-point))))
4415 (defun gnus-group-list-level (level &optional all)
4416 "List groups on LEVEL.
4417 If ALL (the prefix), also list groups that have no unread articles."
4418 (interactive "nList groups on level: \nP")
4419 (gnus-group-list-groups level all level))
4421 (defun gnus-group-prepare-flat (level &optional all lowest regexp)
4422 "List all newsgroups with unread articles of level LEVEL or lower.
4423 If ALL is non-nil, list groups that have no unread articles.
4424 If LOWEST is non-nil, list all newsgroups of level LOWEST or higher.
4425 If REGEXP, only list groups matching REGEXP."
4426 (set-buffer gnus-group-buffer)
4427 (let ((buffer-read-only nil)
4428 (newsrc (cdr gnus-newsrc-alist))
4429 (lowest (or lowest 1))
4430 info clevel unread group params)
4432 (if (< lowest gnus-level-zombie)
4433 ;; List living groups.
4435 (setq info (car newsrc)
4436 group (gnus-info-group info)
4437 params (gnus-info-params info)
4439 unread (car (gnus-gethash group gnus-newsrc-hashtb)))
4440 (and unread ; This group might be bogus
4442 (string-match regexp group))
4443 (<= (setq clevel (gnus-info-level info)) level)
4445 (or all ; We list all groups?
4446 (and gnus-group-list-inactive-groups
4447 (eq unread t)) ; We list unactivated groups
4448 (> unread 0) ; We list groups with unread articles
4449 (and gnus-list-groups-with-ticked-articles
4450 (cdr (assq 'tick (gnus-info-marks info))))
4451 ; And groups with tickeds
4452 ;; Check for permanent visibility.
4453 (and gnus-permanently-visible-groups
4454 (string-match gnus-permanently-visible-groups
4456 (memq 'visible params)
4457 (cdr (assq 'visible params)))
4458 (gnus-group-insert-group-line
4459 group (gnus-info-level info)
4460 (gnus-info-marks info) unread (gnus-info-method info)))))
4462 ;; List dead groups.
4463 (and (>= level gnus-level-zombie) (<= lowest gnus-level-zombie)
4464 (gnus-group-prepare-flat-list-dead
4465 (setq gnus-zombie-list (sort gnus-zombie-list 'string<))
4466 gnus-level-zombie ?Z
4468 (and (>= level gnus-level-killed) (<= lowest gnus-level-killed)
4469 (gnus-group-prepare-flat-list-dead
4470 (setq gnus-killed-list (sort gnus-killed-list 'string<))
4471 gnus-level-killed ?K regexp))
4473 (gnus-group-set-mode-line)
4474 (setq gnus-group-list-mode (cons level all))
4475 (run-hooks 'gnus-group-prepare-hook)))
4477 (defun gnus-group-prepare-flat-list-dead (groups level mark regexp)
4478 ;; List zombies and killed lists somewhat faster, which was
4479 ;; suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>. It does
4480 ;; this by ignoring the group format specification altogether.
4483 ;; This loop is used when listing groups that match some
4486 (setq group (pop groups))
4487 (when (string-match regexp group)
4488 (add-text-properties
4489 (point) (prog1 (1+ (point))
4490 (insert " " mark " *: " group "\n"))
4491 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4493 'gnus-level level))))
4494 ;; This loop is used when listing all groups.
4496 (add-text-properties
4497 (point) (prog1 (1+ (point))
4498 (insert " " mark " *: "
4499 (setq group (pop groups)) "\n"))
4500 (list 'gnus-group (gnus-intern-safe group gnus-active-hashtb)
4502 'gnus-level level))))))
4504 (defmacro gnus-group-real-name (group)
4505 "Find the real name of a foreign newsgroup."
4506 `(let ((gname ,group))
4507 (if (string-match ":[^:]+$" gname)
4508 (substring gname (1+ (match-beginning 0)))
4511 (defsubst gnus-server-add-address (method)
4512 (let ((method-name (symbol-name (car method))))
4513 (if (and (memq 'address (assoc method-name gnus-valid-select-methods))
4514 (not (assq (intern (concat method-name "-address")) method)))
4515 (append method (list (list (intern (concat method-name "-address"))
4519 (defsubst gnus-server-get-method (group method)
4520 ;; Input either a server name, and extended server name, or a
4521 ;; select method, and return a select method.
4522 (cond ((stringp method)
4523 (gnus-server-to-method method))
4524 ((and (stringp (car method)) group)
4525 (gnus-server-extend-method group method))
4527 (gnus-server-add-address method))))
4529 (defun gnus-server-to-method (server)
4530 "Map virtual server names to select methods."
4532 ;; Perhaps this is the native server?
4533 (and (equal server "native") gnus-select-method)
4534 ;; It should be in the server alist.
4535 (cdr (assoc server gnus-server-alist))
4536 ;; If not, we look through all the opened server
4537 ;; to see whether we can find it there.
4538 (let ((opened gnus-opened-servers))
4540 (not (equal server (format "%s:%s" (caaar opened)
4545 (defmacro gnus-method-equal (ss1 ss2)
4546 "Say whether two servers are equal."
4550 (and (= (length s1) (length s2))
4552 (while (and s1 (member (car s1) s2))
4556 (defun gnus-server-equal (m1 m2)
4557 "Say whether two methods are equal."
4558 (let ((m1 (cond ((null m1) gnus-select-method)
4559 ((stringp m1) (gnus-server-to-method m1))
4561 (m2 (cond ((null m2) gnus-select-method)
4562 ((stringp m2) (gnus-server-to-method m2))
4564 (gnus-method-equal m1 m2)))
4566 (defun gnus-group-prefixed-name (group method)
4567 "Return the whole name from GROUP and METHOD."
4568 (and (stringp method) (setq method (gnus-server-to-method method)))
4569 (concat (format "%s" (car method))
4571 (or (assoc (format "%s" (car method))
4572 (gnus-methods-using 'address))
4573 (gnus-server-equal method gnus-message-archive-method))
4575 (not (string= (nth 1 method) "")))
4576 (concat "+" (nth 1 method)))
4579 (defun gnus-group-real-prefix (group)
4580 "Return the prefix of the current group name."
4581 (if (string-match "^[^:]+:" group)
4582 (substring group 0 (match-end 0))
4585 (defun gnus-group-method (group)
4586 "Return the server or method used for selecting GROUP."
4587 (let ((prefix (gnus-group-real-prefix group)))
4588 (if (equal prefix "")
4590 (let ((servers gnus-opened-servers)
4592 backend possible found)
4593 (if (string-match "^[^\\+]+\\+" prefix)
4594 (setq backend (intern (substring prefix 0 (1- (match-end 0))))
4595 server (substring prefix (match-end 0) (1- (length prefix))))
4596 (setq backend (intern (substring prefix 0 (1- (length prefix))))))
4598 (when (eq (caaar servers) backend)
4599 (setq possible (caar servers))
4600 (when (equal (cadaar servers) server)
4601 (setq found (caar servers))))
4603 (or (car (rassoc found gnus-server-alist))
4605 (car (rassoc possible gnus-server-alist))
4607 (list backend server))))))
4609 (defsubst gnus-secondary-method-p (method)
4610 "Return whether METHOD is a secondary select method."
4611 (let ((methods gnus-secondary-select-methods)
4612 (gmethod (gnus-server-get-method nil method)))
4614 (not (equal (gnus-server-get-method nil (car methods))
4616 (setq methods (cdr methods)))
4619 (defun gnus-group-foreign-p (group)
4620 "Say whether a group is foreign or not."
4621 (and (not (gnus-group-native-p group))
4622 (not (gnus-group-secondary-p group))))
4624 (defun gnus-group-native-p (group)
4625 "Say whether the group is native or not."
4626 (not (string-match ":" group)))
4628 (defun gnus-group-secondary-p (group)
4629 "Say whether the group is secondary or not."
4630 (gnus-secondary-method-p (gnus-find-method-for-group group)))
4632 (defun gnus-group-get-parameter (group &optional symbol)
4633 "Returns the group parameters for GROUP.
4634 If SYMBOL, return the value of that symbol in the group parameters."
4635 (let ((params (gnus-info-params (gnus-get-info group))))
4637 (gnus-group-parameter-value params symbol)
4640 (defun gnus-group-parameter-value (params symbol)
4641 "Return the value of SYMBOL in group PARAMS."
4642 (or (car (memq symbol params)) ; It's either a simple symbol
4643 (cdr (assq symbol params)))) ; or a cons.
4645 (defun gnus-group-add-parameter (group param)
4646 "Add parameter PARAM to GROUP."
4647 (let ((info (gnus-get-info group)))
4649 () ; This is a dead group. We just ignore it.
4650 ;; Cons the new param to the old one and update.
4651 (gnus-group-set-info (cons param (gnus-info-params info))
4654 (defun gnus-group-set-parameter (group name value)
4655 "Set parameter NAME to VALUE in GROUP."
4656 (let ((info (gnus-get-info group)))
4658 () ; This is a dead group. We just ignore it.
4659 (let ((old-params (gnus-info-params info))
4660 (new-params (list (cons name value))))
4662 (if (or (not (listp (car old-params)))
4663 (not (eq (caar old-params) name)))
4664 (setq new-params (append new-params (list (car old-params)))))
4665 (setq old-params (cdr old-params)))
4666 (gnus-group-set-info new-params group 'params)))))
4668 (defun gnus-group-add-score (group &optional score)
4669 "Add SCORE to the GROUP score.
4670 If SCORE is nil, add 1 to the score of GROUP."
4671 (let ((info (gnus-get-info group)))
4672 (gnus-info-set-score info (+ (gnus-info-score info) (or score 1)))))
4674 (defun gnus-summary-bubble-group ()
4675 "Increase the score of the current group.
4676 This is a handy function to add to `gnus-summary-exit-hook' to
4677 increase the score of each group you read."
4678 (gnus-group-add-score gnus-newsgroup-name))
4680 (defun gnus-group-set-info (info &optional method-only-group part)
4681 (let* ((entry (gnus-gethash
4682 (or method-only-group (gnus-info-group info))
4683 gnus-newsrc-hashtb))
4685 (info (if method-only-group (nth 2 entry) info))
4687 (when method-only-group
4689 (error "Trying to change non-existent group %s" method-only-group))
4690 ;; We have received parts of the actual group info - either the
4691 ;; select method or the group parameters. We first check
4692 ;; whether we have to extend the info, and if so, do that.
4693 (let ((len (length info))
4694 (total (if (eq part 'method) 5 6)))
4696 (setcdr (nthcdr (1- len) info)
4697 (make-list (- total len) nil)))
4698 ;; Then we enter the new info.
4699 (setcar (nthcdr (1- total) info) part-info)))
4701 ;; This is a new group, so we just create it.
4703 (set-buffer gnus-group-buffer)
4704 (setq method (gnus-info-method info))
4705 (when (gnus-server-equal method "native")
4708 ;; It's a foreign group...
4709 (gnus-group-make-group
4710 (gnus-group-real-name (gnus-info-group info))
4711 (if (stringp method) method
4712 (prin1-to-string (car method)))
4714 (nth 1 (gnus-info-method info))))
4715 ;; It's a native group.
4716 (gnus-group-make-group (gnus-info-group info)))
4717 (gnus-message 6 "Note: New group created")
4719 (gnus-gethash (gnus-group-prefixed-name
4720 (gnus-group-real-name (gnus-info-group info))
4721 (or (gnus-info-method info) gnus-select-method))
4722 gnus-newsrc-hashtb))))
4723 ;; Whether it was a new group or not, we now have the entry, so we
4724 ;; can do the update.
4727 (setcar (nthcdr 2 entry) info)
4728 (when (and (not (eq (car entry) t))
4729 (gnus-active (gnus-info-group info)))
4730 (let ((marked (gnus-info-marks info)))
4731 (setcar entry (length (gnus-list-of-unread-articles
4733 (error "No such group: %s" (gnus-info-group info)))))
4735 (defun gnus-group-set-method-info (group select-method)
4736 (gnus-group-set-info select-method group 'method))
4738 (defun gnus-group-set-params-info (group params)
4739 (gnus-group-set-info params group 'params))
4741 (defun gnus-group-update-group-line ()
4742 "Update the current line in the group buffer."
4743 (let* ((buffer-read-only nil)
4744 (group (gnus-group-group-name))
4745 (gnus-group-indentation (gnus-group-group-indentation))
4746 (entry (and group (gnus-gethash group gnus-newsrc-hashtb))))
4748 (not (gnus-ephemeral-group-p group))
4750 (concat "(gnus-group-set-info '"
4751 (prin1-to-string (nth 2 entry)) ")")))
4753 (gnus-group-insert-group-line-info group)
4755 (gnus-group-position-point)))
4757 (defun gnus-group-insert-group-line-info (group)
4758 "Insert GROUP on the current line."
4759 (let ((entry (gnus-gethash group gnus-newsrc-hashtb))
4763 ;; (Un)subscribed group.
4764 (setq info (nth 2 entry))
4765 (gnus-group-insert-group-line
4766 group (gnus-info-level info) (gnus-info-marks info)
4767 (or (car entry) t) (gnus-info-method info)))
4768 ;; This group is dead.
4769 (gnus-group-insert-group-line
4771 (if (member group gnus-zombie-list) gnus-level-zombie gnus-level-killed)
4773 (if (setq active (gnus-active group))
4774 (- (1+ (cdr active)) (car active)) 0)
4777 (defun gnus-group-insert-group-line
4778 (gnus-tmp-group gnus-tmp-level gnus-tmp-marked number
4780 "Insert a group line in the group buffer."
4781 (let* ((gnus-tmp-active (gnus-active gnus-tmp-group))
4782 (gnus-tmp-number-total
4784 (1+ (- (cdr gnus-tmp-active) (car gnus-tmp-active)))
4786 (gnus-tmp-number-of-unread
4787 (if (numberp number) (int-to-string (max 0 number))
4789 (gnus-tmp-number-of-read
4790 (if (numberp number)
4791 (int-to-string (max 0 (- gnus-tmp-number-total number)))
4793 (gnus-tmp-subscribed
4794 (cond ((<= gnus-tmp-level gnus-level-subscribed) ? )
4795 ((<= gnus-tmp-level gnus-level-unsubscribed) ?U)
4796 ((= gnus-tmp-level gnus-level-zombie) ?Z)
4798 (gnus-tmp-qualified-group (gnus-group-real-name gnus-tmp-group))
4799 (gnus-tmp-newsgroup-description
4800 (if gnus-description-hashtb
4801 (or (gnus-gethash gnus-tmp-group gnus-description-hashtb) "")
4804 (if (member gnus-tmp-group gnus-moderated-list) ?m ? ))
4805 (gnus-tmp-moderated-string
4806 (if (eq gnus-tmp-moderated ?m) "(m)" ""))
4808 (gnus-server-get-method gnus-tmp-group gnus-tmp-method))
4809 (gnus-tmp-news-server (or (cadr gnus-tmp-method) ""))
4810 (gnus-tmp-news-method (or (car gnus-tmp-method) ""))
4811 (gnus-tmp-news-method-string
4813 (format "(%s:%s)" (car gnus-tmp-method)
4814 (cadr gnus-tmp-method)) ""))
4815 (gnus-tmp-marked-mark
4816 (if (and (numberp number)
4818 (cdr (assq 'tick gnus-tmp-marked)))
4820 (gnus-tmp-process-marked
4821 (if (member gnus-tmp-group gnus-group-marked)
4822 gnus-process-mark ? ))
4824 (or (and gnus-use-grouplens
4825 (bbb-grouplens-group-p gnus-tmp-group))
4827 (buffer-read-only nil)
4828 header gnus-tmp-header) ; passed as parameter to user-funcs.
4830 (add-text-properties
4834 (eval gnus-group-line-format-spec))
4835 `(gnus-group ,(gnus-intern-safe gnus-tmp-group gnus-active-hashtb)
4836 gnus-unread ,(if (numberp number)
4837 (string-to-int gnus-tmp-number-of-unread)
4839 gnus-marked ,gnus-tmp-marked-mark
4840 gnus-indentation ,gnus-group-indentation
4841 gnus-level ,gnus-tmp-level))
4842 (when (gnus-visual-p 'group-highlight 'highlight)
4844 (run-hooks 'gnus-group-update-hook)
4846 ;; Allow XEmacs to remove front-sticky text properties.
4847 (gnus-group-remove-excess-properties)))
4849 (defun gnus-group-update-group (group &optional visible-only)
4850 "Update all lines where GROUP appear.
4851 If VISIBLE-ONLY is non-nil, the group won't be displayed if it isn't
4854 (set-buffer gnus-group-buffer)
4855 ;; The buffer may be narrowed.
4858 (let ((ident (gnus-intern-safe group gnus-active-hashtb))
4860 found buffer-read-only visible)
4861 ;; Enter the current status into the dribble buffer.
4862 (let ((entry (gnus-gethash group gnus-newsrc-hashtb)))
4863 (if (and entry (not (gnus-ephemeral-group-p group)))
4865 (concat "(gnus-group-set-info '" (prin1-to-string (nth 2 entry))
4867 ;; Find all group instances. If topics are in use, each group
4868 ;; may be listed in more than once.
4869 (while (setq loc (text-property-any
4870 loc (point-max) 'gnus-group ident))
4873 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4875 (gnus-group-insert-group-line-info group))
4876 (setq loc (1+ loc)))
4877 (unless (or found visible-only)
4878 ;; No such line in the buffer, find out where it's supposed to
4879 ;; go, and insert it there (or at the end of the buffer).
4880 (if gnus-goto-missing-group-function
4881 (funcall gnus-goto-missing-group-function group)
4882 (let ((entry (cddr (gnus-gethash group gnus-newsrc-hashtb))))
4883 (while (and entry (car entry)
4887 (point-min) (point-max)
4888 'gnus-group (gnus-intern-safe
4889 (caar entry) gnus-active-hashtb)))))
4890 (setq entry (cdr entry)))
4891 (or entry (goto-char (point-max)))))
4892 ;; Finally insert the line.
4893 (let ((gnus-group-indentation (gnus-group-group-indentation)))
4894 (gnus-group-insert-group-line-info group)))
4895 (gnus-group-set-mode-line)))))
4897 (defun gnus-group-set-mode-line ()
4898 (when (memq 'group gnus-updated-mode-lines)
4899 (let* ((gformat (or gnus-group-mode-line-format-spec
4900 (setq gnus-group-mode-line-format-spec
4902 gnus-group-mode-line-format
4903 gnus-group-mode-line-format-alist))))
4904 (gnus-tmp-news-server (cadr gnus-select-method))
4905 (gnus-tmp-news-method (car gnus-select-method))
4907 gnus-tmp-header ;Dummy binding for user-defined formats
4908 ;; Get the resulting string.
4909 (mode-string (eval gformat)))
4910 ;; If the line is too long, we chop it off.
4911 (when (> (length mode-string) max-len)
4912 (setq mode-string (substring mode-string 0 (- max-len 4))))
4914 (setq mode-line-buffer-identification (list mode-string))
4915 (set-buffer-modified-p t)))))
4917 (defun gnus-group-group-name ()
4918 "Get the name of the newsgroup on the current line."
4919 (let ((group (get-text-property (gnus-point-at-bol) 'gnus-group)))
4920 (and group (symbol-name group))))
4922 (defun gnus-group-group-level ()
4923 "Get the level of the newsgroup on the current line."
4924 (get-text-property (gnus-point-at-bol) 'gnus-level))
4926 (defun gnus-group-group-indentation ()
4927 "Get the indentation of the newsgroup on the current line."
4928 (or (get-text-property (gnus-point-at-bol) 'gnus-indentation) ""))
4930 (defun gnus-group-group-unread ()
4931 "Get the number of unread articles of the newsgroup on the current line."
4932 (get-text-property (gnus-point-at-bol) 'gnus-unread))
4934 (defun gnus-group-search-forward (&optional backward all level first-too)
4935 "Find the next newsgroup with unread articles.
4936 If BACKWARD is non-nil, find the previous newsgroup instead.
4937 If ALL is non-nil, just find any newsgroup.
4938 If LEVEL is non-nil, find group with level LEVEL, or higher if no such
4940 If FIRST-TOO, the current line is also eligible as a target."
4941 (let ((way (if backward -1 1))
4942 (low gnus-level-killed)
4945 (if (and backward (progn (beginning-of-line)) (bobp))
4947 (or first-too (forward-line way))
4955 (get-text-property (point) 'gnus-unread)))
4956 (and (numberp unread) (> unread 0)))
4957 (setq lev (get-text-property (point)
4959 (<= lev gnus-level-subscribed)))
4961 (and (setq lev (get-text-property (point)
4970 (zerop (forward-line way)))))
4972 (progn (gnus-group-position-point) t)
4973 (goto-char (or pos beg))
4976 ;;; Gnus group mode commands
4980 (defun gnus-group-mark-group (n &optional unmark no-advance)
4981 "Mark the current group."
4983 (let ((buffer-read-only nil)
4987 (setq group (gnus-group-group-name))
4991 (or (cdr (assq 'process gnus-group-mark-positions)) 2))
4996 (setq gnus-group-marked (delete group gnus-group-marked)))
4998 (setq gnus-group-marked
4999 (cons group (delete group gnus-group-marked))))
5001 (or no-advance (zerop (gnus-group-next-group 1))))
5003 (gnus-summary-position-point)
5006 (defun gnus-group-unmark-group (n)
5007 "Remove the mark from the current group."
5009 (gnus-group-mark-group n 'unmark)
5010 (gnus-group-position-point))
5012 (defun gnus-group-unmark-all-groups ()
5013 "Unmark all groups."
5015 (let ((groups gnus-group-marked))
5018 (gnus-group-remove-mark (pop groups)))))
5019 (gnus-group-position-point))
5021 (defun gnus-group-mark-region (unmark beg end)
5022 "Mark all groups between point and mark.
5023 If UNMARK, remove the mark instead."
5024 (interactive "P\nr")
5025 (let ((num (count-lines beg end)))
5028 (- num (gnus-group-mark-group num unmark)))))
5030 (defun gnus-group-mark-buffer (&optional unmark)
5031 "Mark all groups in the buffer.
5032 If UNMARK, remove the mark instead."
5034 (gnus-group-mark-region unmark (point-min) (point-max)))
5036 (defun gnus-group-mark-regexp (regexp)
5037 "Mark all groups that match some regexp."
5038 (interactive "sMark (regexp): ")
5039 (let ((alist (cdr gnus-newsrc-alist))
5042 (when (string-match regexp (setq group (gnus-info-group (pop alist))))
5043 (gnus-group-set-mark group))))
5044 (gnus-group-position-point))
5046 (defun gnus-group-remove-mark (group)
5047 "Remove the process mark from GROUP and move point there.
5048 Return nil if the group isn't displayed."
5049 (if (gnus-group-goto-group group)
5051 (gnus-group-mark-group 1 'unmark t)
5053 (setq gnus-group-marked
5054 (delete group gnus-group-marked))
5057 (defun gnus-group-set-mark (group)
5058 "Set the process mark on GROUP."
5059 (if (gnus-group-goto-group group)
5061 (gnus-group-mark-group 1 nil t))
5062 (setq gnus-group-marked (cons group (delete group gnus-group-marked)))))
5064 (defun gnus-group-universal-argument (arg &optional groups func)
5065 "Perform any command on all groups accoring to the process/prefix convention."
5067 (let ((groups (or groups (gnus-group-process-prefix arg)))
5069 (if (eq (setq func (or func
5072 (substitute-command-keys
5073 "\\<gnus-group-mode-map>\\[gnus-group-universal-argument]")))))
5076 (message "Undefined key")
5079 (gnus-group-remove-mark (setq group (pop groups)))
5080 (command-execute func))))
5081 (gnus-group-position-point))
5083 (defun gnus-group-process-prefix (n)
5084 "Return a list of groups to work on.
5085 Take into consideration N (the prefix) and the list of marked groups."
5088 (setq n (prefix-numeric-value n))
5089 ;; There is a prefix, so we return a list of the N next
5091 (let ((way (if (< n 0) -1 1))
5096 (setq group (gnus-group-group-name)))
5097 (setq groups (cons group groups))
5099 (gnus-group-next-group way)))
5101 ((and (boundp 'transient-mark-mode)
5104 ;; Work on the region between point and mark.
5105 (let ((max (max (point) (mark)))
5108 (goto-char (min (point) (mark)))
5111 (push (gnus-group-group-name) groups)
5112 (zerop (gnus-group-next-group 1))
5114 (nreverse groups))))
5116 ;; No prefix, but a list of marked articles.
5117 (reverse gnus-group-marked))
5119 ;; Neither marked articles or a prefix, so we return the
5121 (let ((group (gnus-group-group-name)))
5122 (and group (list group))))))
5124 ;; Selecting groups.
5126 (defun gnus-group-read-group (&optional all no-article group)
5127 "Read news in this newsgroup.
5128 If the prefix argument ALL is non-nil, already read articles become
5129 readable. IF ALL is a number, fetch this number of articles. If the
5130 optional argument NO-ARTICLE is non-nil, no article will be
5131 auto-selected upon group entry. If GROUP is non-nil, fetch that
5134 (let ((group (or group (gnus-group-group-name)))
5135 number active marked entry)
5136 (or group (error "No group on current line"))
5137 (setq marked (nth 3 (nth 2 (setq entry (gnus-gethash
5138 group gnus-newsrc-hashtb)))))
5139 ;; This group might be a dead group. In that case we have to get
5140 ;; the number of unread articles from `gnus-active-hashtb'.
5142 (cond ((numberp all) all)
5144 ((setq active (gnus-active group))
5145 (- (1+ (cdr active)) (car active)))))
5146 (gnus-summary-read-group
5147 group (or all (and (numberp number)
5148 (zerop (+ number (length (cdr (assq 'tick marked)))
5149 (length (cdr (assq 'dormant marked)))))))
5152 (defun gnus-group-select-group (&optional all)
5153 "Select this newsgroup.
5154 No article is selected automatically.
5155 If ALL is non-nil, already read articles become readable.
5156 If ALL is a number, fetch this number of articles."
5158 (gnus-group-read-group all t))
5160 (defun gnus-group-quick-select-group (&optional all)
5161 "Select the current group \"quickly\".
5162 This means that no highlighting or scoring will be performed."
5165 gnus-score-find-score-files-function
5166 gnus-apply-kill-hook
5167 gnus-summary-expunge-below)
5168 (gnus-group-read-group all t)))
5170 (defun gnus-group-visible-select-group (&optional all)
5171 "Select the current group without hiding any articles."
5173 (let ((gnus-inhibit-limiting t))
5174 (gnus-group-read-group all t)))
5177 (defun gnus-fetch-group (group)
5178 "Start Gnus if necessary and enter GROUP.
5179 Returns whether the fetching was successful or not."
5180 (interactive "sGroup name: ")
5181 (or (get-buffer gnus-group-buffer)
5183 (gnus-group-read-group nil nil group))
5185 ;; Enter a group that is not in the group buffer. Non-nil is returned
5186 ;; if selection was successful.
5187 (defun gnus-group-read-ephemeral-group
5188 (group method &optional activate quit-config)
5189 (let ((group (if (gnus-group-foreign-p group) group
5190 (gnus-group-prefixed-name group method))))
5193 `(t nil (,group ,gnus-level-default-subscribed nil nil ,method
5194 ((quit-config . ,(if quit-config quit-config
5195 (cons (current-buffer) 'summary))))))
5197 (set-buffer gnus-group-buffer)
5198 (or (gnus-check-server method)
5199 (error "Unable to contact server: %s" (gnus-status-message method)))
5200 (if activate (or (gnus-request-group group)
5201 (error "Couldn't request group")))
5203 (gnus-group-read-group t t group)
5207 (defun gnus-group-jump-to-group (group)
5208 "Jump to newsgroup GROUP."
5210 (list (completing-read
5211 "Group: " gnus-active-hashtb nil
5212 (memq gnus-select-method gnus-have-read-active-file))))
5214 (if (equal group "")
5215 (error "Empty group name"))
5217 (let ((b (text-property-any
5218 (point-min) (point-max)
5219 'gnus-group (gnus-intern-safe group gnus-active-hashtb))))
5220 (unless (gnus-ephemeral-group-p group)
5222 ;; Either go to the line in the group buffer...
5224 ;; ... or insert the line.
5227 (gnus-activate-group group)
5228 (error "%s error: %s" group (gnus-status-message group)))
5230 (gnus-group-update-group group)
5231 (goto-char (text-property-any
5232 (point-min) (point-max)
5233 'gnus-group (gnus-intern-safe group gnus-active-hashtb)))))
5234 ;; Adjust cursor point.
5235 (gnus-group-position-point)))
5237 (defun gnus-group-goto-group (group)
5238 "Goto to newsgroup GROUP."
5240 (let ((b (text-property-any (point-min) (point-max)
5241 'gnus-group (gnus-intern-safe
5242 group gnus-active-hashtb))))
5243 (and b (goto-char b)))))
5245 (defun gnus-group-next-group (n)
5246 "Go to next N'th newsgroup.
5247 If N is negative, search backward instead.
5248 Returns the difference between N and the number of skips actually
5251 (gnus-group-next-unread-group n t))
5253 (defun gnus-group-next-unread-group (n &optional all level)
5254 "Go to next N'th unread newsgroup.
5255 If N is negative, search backward instead.
5256 If ALL is non-nil, choose any newsgroup, unread or not.
5257 If LEVEL is non-nil, choose the next group with level LEVEL, or, if no
5258 such group can be found, the next group with a level higher than
5260 Returns the difference between N and the number of skips actually
5263 (let ((backward (< n 0))
5266 (gnus-group-search-forward
5267 backward (or (not gnus-group-goto-unread) all) level))
5269 (if (/= 0 n) (gnus-message 7 "No more%s newsgroups%s" (if all "" " unread")
5270 (if level " on this level or higher" "")))
5273 (defun gnus-group-prev-group (n)
5274 "Go to previous N'th newsgroup.
5275 Returns the difference between N and the number of skips actually
5278 (gnus-group-next-unread-group (- n) t))
5280 (defun gnus-group-prev-unread-group (n)
5281 "Go to previous N'th unread newsgroup.
5282 Returns the difference between N and the number of skips actually
5285 (gnus-group-next-unread-group (- n)))
5287 (defun gnus-group-next-unread-group-same-level (n)
5288 "Go to next N'th unread newsgroup on the same level.
5289 If N is negative, search backward instead.
5290 Returns the difference between N and the number of skips actually
5293 (gnus-group-next-unread-group n t (gnus-group-group-level))
5294 (gnus-group-position-point))
5296 (defun gnus-group-prev-unread-group-same-level (n)
5297 "Go to next N'th unread newsgroup on the same level.
5298 Returns the difference between N and the number of skips actually
5301 (gnus-group-next-unread-group (- n) t (gnus-group-group-level))
5302 (gnus-group-position-point))
5304 (defun gnus-group-best-unread-group (&optional exclude-group)
5305 "Go to the group with the highest level.
5306 If EXCLUDE-GROUP, do not go to that group."
5308 (goto-char (point-min))
5311 (while (setq unread (get-text-property (point) 'gnus-unread))
5312 (if (and (numberp unread) (> unread 0))
5314 (if (and (< (get-text-property (point) 'gnus-level) best)
5315 (or (not exclude-group)
5316 (not (equal exclude-group (gnus-group-group-name)))))
5318 (setq best (get-text-property (point) 'gnus-level))
5319 (setq best-point (point))))))
5321 (if best-point (goto-char best-point))
5322 (gnus-summary-position-point)
5323 (and best-point (gnus-group-group-name))))
5325 (defun gnus-group-first-unread-group ()
5326 "Go to the first group with unread articles."
5329 (let ((opoint (point))
5331 (goto-char (point-min))
5332 (if (or (eq (setq unread (gnus-group-group-unread)) t) ; Not active.
5333 (and (numberp unread) ; Not a topic.
5334 (not (zerop unread))) ; Has unread articles.
5335 (zerop (gnus-group-next-unread-group 1))) ; Next unread group.
5338 nil)) ; Not success.
5339 (gnus-group-position-point)))
5341 (defun gnus-group-enter-server-mode ()
5342 "Jump to the server buffer."
5344 (gnus-enter-server-buffer))
5346 (defun gnus-group-make-group (name &optional method address)
5347 "Add a new newsgroup.
5348 The user will be prompted for a NAME, for a select METHOD, and an
5352 (read-string "Group name: ")
5355 "Method: " (append gnus-valid-select-methods gnus-server-alist)
5357 (if (assoc method gnus-valid-select-methods)
5359 (if (memq 'prompt-address
5360 (assoc method gnus-valid-select-methods))
5361 (read-string "Address: ")
5363 (list method "")))))
5366 (set-buffer gnus-group-buffer)
5367 (let* ((meth (and method (if address (list (intern method) address)
5369 (nname (if method (gnus-group-prefixed-name name meth) name))
5371 (and (gnus-gethash nname gnus-newsrc-hashtb)
5372 (error "Group %s already exists" nname))
5373 (gnus-group-change-level
5374 (setq info (list t nname gnus-level-default-subscribed nil nil meth))
5375 gnus-level-default-subscribed gnus-level-killed
5376 (and (gnus-group-group-name)
5377 (gnus-gethash (gnus-group-group-name)
5378 gnus-newsrc-hashtb))
5380 (gnus-set-active nname (cons 1 0))
5381 (or (gnus-ephemeral-group-p name)
5383 (concat "(gnus-group-set-info '" (prin1-to-string (cdr info)) ")")))
5384 (gnus-group-insert-group-line-info nname)
5386 (when (assoc (symbol-name (car meth)) gnus-valid-select-methods)
5387 (require (car meth)))
5388 (gnus-check-server meth)
5389 (and (gnus-check-backend-function 'request-create-group nname)
5390 (gnus-request-create-group nname))
5393 (defun gnus-group-delete-group (group &optional force)
5394 "Delete the current group.
5395 If FORCE (the prefix) is non-nil, all the articles in the group will
5396 be deleted. This is \"deleted\" as in \"removed forever from the face
5397 of the Earth\". There is no undo."
5399 (list (gnus-group-group-name)
5400 current-prefix-arg))
5401 (or group (error "No group to rename"))
5402 (or (gnus-check-backend-function 'request-delete-group group)
5403 (error "This backend does not support group deletion"))
5405 (if (not (gnus-yes-or-no-p
5407 "Do you really want to delete %s%s? "
5408 group (if force " and all its contents" ""))))
5410 (gnus-message 6 "Deleting group %s..." group)
5411 (if (not (gnus-request-delete-group group force))
5413 (gnus-message 3 "Couldn't delete group %s" group)
5415 (gnus-message 6 "Deleting group %s...done" group)
5416 (gnus-group-goto-group group)
5417 (gnus-group-kill-group 1 t)
5419 (gnus-group-position-point)))
5421 (defun gnus-group-rename-group (group new-name)
5424 (gnus-group-group-name)
5426 (or (gnus-check-backend-function
5427 'request-rename-group (gnus-group-group-name))
5428 (error "This backend does not support renaming groups"))
5429 (read-string "New group name: "))))
5431 (or (gnus-check-backend-function 'request-rename-group group)
5432 (error "This backend does not support renaming groups"))
5434 (or group (error "No group to rename"))
5435 (and (string-match "^[ \t]*$" new-name)
5436 (error "Not a valid group name"))
5438 ;; We find the proper prefixed name.
5440 (gnus-group-prefixed-name
5441 (gnus-group-real-name new-name)
5442 (gnus-info-method (gnus-get-info group))))
5444 (gnus-message 6 "Renaming group %s to %s..." group new-name)
5446 (if (not (gnus-request-rename-group group new-name))
5448 (gnus-message 3 "Couldn't rename group %s to %s" group new-name)
5450 ;; We rename the group internally by killing it...
5451 (gnus-group-goto-group group)
5452 (gnus-group-kill-group)
5453 ;; ... changing its name ...
5454 (setcar (cdar gnus-list-of-killed-groups) new-name)
5455 ;; ... and then yanking it. Magic!
5456 (gnus-group-yank-group)
5457 (gnus-set-active new-name (gnus-active group))
5458 (gnus-message 6 "Renaming group %s to %s...done" group new-name)
5460 (gnus-group-position-point)))
5462 (defun gnus-group-edit-group (group &optional part)
5463 "Edit the group on the current line."
5464 (interactive (list (gnus-group-group-name)))
5465 (let* ((part (or part 'info))
5466 (done-func `(lambda ()
5467 "Exit editing mode and update the information."
5469 (gnus-group-edit-group-done ',part ,group)))
5470 (winconf (current-window-configuration))
5472 (or group (error "No group on current line"))
5473 (or (setq info (gnus-get-info group))
5474 (error "Killed group; can't be edited"))
5475 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5476 (gnus-configure-windows 'edit-group)
5477 (gnus-add-current-to-buffer-list)
5479 ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
5480 (use-local-map (copy-keymap emacs-lisp-mode-map))
5481 (local-set-key "\C-c\C-c" done-func)
5482 (make-local-variable 'gnus-prev-winconf)
5483 (setq gnus-prev-winconf winconf)
5488 ";; Type `C-c C-c' after editing the select method.\n\n")
5490 ";; Type `C-c C-c' after editing the group parameters.\n\n")
5492 ";; Type `C-c C-c' after editing the group info.\n\n")))
5495 (cond ((eq part 'method)
5496 (or (gnus-info-method info) "native"))
5498 (gnus-info-params info))
5502 (defun gnus-group-edit-group-method (group)
5503 "Edit the select method of GROUP."
5504 (interactive (list (gnus-group-group-name)))
5505 (gnus-group-edit-group group 'method))
5507 (defun gnus-group-edit-group-parameters (group)
5508 "Edit the group parameters of GROUP."
5509 (interactive (list (gnus-group-group-name)))
5510 (gnus-group-edit-group group 'params))
5512 (defun gnus-group-edit-group-done (part group)
5513 "Get info from buffer, update variables and jump to the group buffer."
5514 (set-buffer (get-buffer-create gnus-group-edit-buffer))
5515 (goto-char (point-min))
5516 (let* ((form (read (current-buffer)))
5517 (winconf gnus-prev-winconf)
5518 (method (cond ((eq part 'info) (nth 4 form))
5519 ((eq part 'method) form)
5521 (info (cond ((eq part 'info) form)
5522 ((eq part 'method) (gnus-get-info group))
5525 (if (or (not method)
5527 gnus-select-method method))
5528 (gnus-group-real-name (car info))
5529 (gnus-group-prefixed-name
5530 (gnus-group-real-name (car info)) method))
5532 (when (and new-group
5533 (not (equal new-group group)))
5534 (when (gnus-group-goto-group group)
5535 (gnus-group-kill-group 1))
5536 (gnus-activate-group new-group))
5538 (if (and info new-group)
5540 (setq info (gnus-copy-sequence info))
5541 (setcar info new-group)
5542 (unless (gnus-server-equal method "native")
5543 (unless (nthcdr 3 info)
5544 (nconc info (list nil nil)))
5545 (unless (nthcdr 4 info)
5546 (nconc info (list nil)))
5547 (gnus-info-set-method info method))
5548 (gnus-group-set-info info))
5549 (gnus-group-set-info form (or new-group group) part))
5550 (kill-buffer (current-buffer))
5551 (and winconf (set-window-configuration winconf))
5552 (set-buffer gnus-group-buffer)
5553 (gnus-group-update-group (or new-group group))
5554 (gnus-group-position-point)))
5556 (defun gnus-group-make-help-group ()
5557 "Create the Gnus documentation group."
5559 (let ((path load-path)
5560 (name (gnus-group-prefixed-name "gnus-help" '(nndoc "gnus-help")))
5562 (and (gnus-gethash name gnus-newsrc-hashtb)
5563 (error "Documentation group already exists"))
5565 (setq dir (file-name-as-directory (expand-file-name (pop path)))
5567 (when (or (file-exists-p (setq file (concat dir "gnus-tut.txt")))
5569 (setq file (concat (file-name-directory
5570 (directory-file-name dir))
5571 "etc/gnus-tut.txt"))))
5574 (message "Couldn't find doc group")
5575 (gnus-group-make-group
5576 (gnus-group-real-name name)
5578 (list 'nndoc-address file)
5579 (list 'nndoc-article-type 'mbox)))))
5580 (gnus-group-position-point))
5582 (defun gnus-group-make-doc-group (file type)
5583 "Create a group that uses a single file as the source."
5585 (list (read-file-name "File name: ")
5586 (and current-prefix-arg 'ask)))
5587 (when (eq type 'ask)
5592 "%sFile type (mbox, babyl, digest, forward, mmfd, guess) [mbdfag]: "
5594 (setq found (cond ((= (setq char (read-char)) ?m) 'mbox)
5595 ((= char ?b) 'babyl)
5596 ((= char ?d) 'digest)
5597 ((= char ?f) 'forward)
5599 (t (setq err (format "%c unknown. " char))
5602 (let* ((file (expand-file-name file))
5603 (name (gnus-generate-new-group-name
5604 (gnus-group-prefixed-name
5605 (file-name-nondirectory file) '(nndoc "")))))
5606 (gnus-group-make-group
5607 (gnus-group-real-name name)
5609 (list 'nndoc-address file)
5610 (list 'nndoc-article-type (or type 'guess))))
5612 (gnus-group-position-point)))
5614 (defun gnus-group-make-archive-group (&optional all)
5615 "Create the (ding) Gnus archive group of the most recent articles.
5616 Given a prefix, create a full group."
5618 (let ((group (gnus-group-prefixed-name
5619 (if all "ding.archives" "ding.recent") '(nndir ""))))
5620 (and (gnus-gethash group gnus-newsrc-hashtb)
5621 (error "Archive group already exists"))
5622 (gnus-group-make-group
5623 (gnus-group-real-name group)
5624 (list 'nndir (if all "hpc" "edu")
5625 (list 'nndir-directory
5626 (if all gnus-group-archive-directory
5627 gnus-group-recent-archive-directory)))))
5629 (gnus-group-position-point))
5631 (defun gnus-group-make-directory-group (dir)
5632 "Create an nndir group.
5633 The user will be prompted for a directory. The contents of this
5634 directory will be used as a newsgroup. The directory should contain
5635 mail messages or news articles in files that have numeric names."
5637 (list (read-file-name "Create group from directory: ")))
5638 (or (file-exists-p dir) (error "No such directory"))
5639 (or (file-directory-p dir) (error "Not a directory"))
5643 (while (or (not group) (gnus-gethash group gnus-newsrc-hashtb))
5645 (gnus-group-prefixed-name
5646 (concat (file-name-as-directory (directory-file-name dir))
5649 (setq ext (format "<%d>" (setq i (1+ i)))))
5650 (gnus-group-make-group
5651 (gnus-group-real-name group)
5652 (list 'nndir group (list 'nndir-directory dir))))
5654 (gnus-group-position-point))
5656 (defun gnus-group-make-kiboze-group (group address scores)
5657 "Create an nnkiboze group.
5658 The user will be prompted for a name, a regexp to match groups, and
5659 score file entries for articles to include in the group."
5662 (read-string "nnkiboze group name: ")
5663 (read-string "Source groups (regexp): ")
5664 (let ((headers (mapcar (lambda (group) (list group))
5665 '("subject" "from" "number" "date" "message-id"
5666 "references" "chars" "lines" "xref"
5667 "followup" "all" "body" "head")))
5668 scores header regexp regexps)
5669 (while (not (equal "" (setq header (completing-read
5670 "Match on header: " headers nil t))))
5672 (while (not (equal "" (setq regexp (read-string
5673 (format "Match on %s (string): "
5675 (setq regexps (cons (list regexp nil nil 'r) regexps)))
5676 (setq scores (cons (cons header regexps) scores)))
5678 (gnus-group-make-group group "nnkiboze" address)
5680 (gnus-set-work-buffer)
5681 (let (emacs-lisp-mode-hook)
5682 (pp scores (current-buffer)))
5683 (write-region (point-min) (point-max)
5684 (gnus-score-file-name (concat "nnkiboze:" group))))
5686 (gnus-group-position-point))
5688 (defun gnus-group-add-to-virtual (n vgroup)
5689 "Add the current group to a virtual group."
5691 (list current-prefix-arg
5692 (completing-read "Add to virtual group: " gnus-newsrc-hashtb nil t
5694 (or (eq (car (gnus-find-method-for-group vgroup)) 'nnvirtual)
5695 (error "%s is not an nnvirtual group" vgroup))
5696 (let* ((groups (gnus-group-process-prefix n))
5697 (method (gnus-info-method (gnus-get-info vgroup))))
5698 (setcar (cdr method)
5700 (nth 1 method) "\\|"
5703 (gnus-group-remove-mark s)
5704 (concat "\\(^" (regexp-quote s) "$\\)"))
5706 (gnus-group-position-point))
5708 (defun gnus-group-make-empty-virtual (group)
5709 "Create a new, fresh, empty virtual group."
5710 (interactive "sCreate new, empty virtual group: ")
5711 (let* ((method (list 'nnvirtual "^$"))
5712 (pgroup (gnus-group-prefixed-name group method)))
5713 ;; Check whether it exists already.
5714 (and (gnus-gethash pgroup gnus-newsrc-hashtb)
5715 (error "Group %s already exists." pgroup))
5716 ;; Subscribe the new group after the group on the current line.
5717 (gnus-subscribe-group pgroup (gnus-group-group-name) method)
5718 (gnus-group-update-group pgroup)
5720 (gnus-group-position-point)))
5722 (defun gnus-group-enter-directory (dir)
5723 "Enter an ephemeral nneething group."
5724 (interactive "DDirectory to read: ")
5725 (let* ((method (list 'nneething dir))
5726 (leaf (gnus-group-prefixed-name
5727 (file-name-nondirectory (directory-file-name dir))
5729 (name (gnus-generate-new-group-name leaf)))
5730 (let ((nneething-read-only t))
5731 (or (gnus-group-read-ephemeral-group
5733 (cons (current-buffer) (if (eq major-mode 'gnus-summary-mode)
5735 (error "Couldn't enter %s" dir)))))
5737 ;; Group sorting commands
5738 ;; Suggested by Joe Hildebrand <hildjj@idaho.fuentez.com>.
5740 (defun gnus-group-sort-groups (func &optional reverse)
5741 "Sort the group buffer according to FUNC.
5742 If REVERSE, reverse the sorting order."
5743 (interactive (list gnus-group-sort-function
5744 current-prefix-arg))
5746 ((not (listp func)) func)
5748 ((= 1 (length func)) (car func))
5750 ,(gnus-make-sort-function
5751 (reverse func)))))))
5752 ;; We peel off the dummy group from the alist.
5754 (when (equal (car (gnus-info-group gnus-newsrc-alist)) "dummy.group")
5755 (pop gnus-newsrc-alist))
5757 (setq gnus-newsrc-alist
5758 (sort gnus-newsrc-alist func))
5760 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist)))
5761 ;; Regenerate the hash table.
5762 (gnus-make-hashtable-from-newsrc-alist)
5763 (gnus-group-list-groups))))
5765 (defun gnus-group-sort-groups-by-alphabet (&optional reverse)
5766 "Sort the group buffer alphabetically by group name.
5767 If REVERSE, sort in reverse order."
5769 (gnus-group-sort-groups 'gnus-group-sort-by-alphabet reverse))
5771 (defun gnus-group-sort-groups-by-unread (&optional reverse)
5772 "Sort the group buffer by number of unread articles.
5773 If REVERSE, sort in reverse order."
5775 (gnus-group-sort-groups 'gnus-group-sort-by-unread reverse))
5777 (defun gnus-group-sort-groups-by-level (&optional reverse)
5778 "Sort the group buffer by group level.
5779 If REVERSE, sort in reverse order."
5781 (gnus-group-sort-groups 'gnus-group-sort-by-level reverse))
5783 (defun gnus-group-sort-groups-by-score (&optional reverse)
5784 "Sort the group buffer by group score.
5785 If REVERSE, sort in reverse order."
5787 (gnus-group-sort-groups 'gnus-group-sort-by-score reverse))
5789 (defun gnus-group-sort-groups-by-rank (&optional reverse)
5790 "Sort the group buffer by group rank.
5791 If REVERSE, sort in reverse order."
5793 (gnus-group-sort-groups 'gnus-group-sort-by-rank reverse))
5795 (defun gnus-group-sort-groups-by-method (&optional reverse)
5796 "Sort the group buffer alphabetically by backend name.
5797 If REVERSE, sort in reverse order."
5799 (gnus-group-sort-groups 'gnus-group-sort-by-method reverse))
5801 (defun gnus-group-sort-by-alphabet (info1 info2)
5802 "Sort alphabetically."
5803 (string< (gnus-info-group info1) (gnus-info-group info2)))
5805 (defun gnus-group-sort-by-unread (info1 info2)
5806 "Sort by number of unread articles."
5807 (let ((n1 (car (gnus-gethash (gnus-info-group info1) gnus-newsrc-hashtb)))
5808 (n2 (car (gnus-gethash (gnus-info-group info2) gnus-newsrc-hashtb))))
5809 (< (or (and (numberp n1) n1) 0)
5810 (or (and (numberp n2) n2) 0))))
5812 (defun gnus-group-sort-by-level (info1 info2)
5814 (< (gnus-info-level info1) (gnus-info-level info2)))
5816 (defun gnus-group-sort-by-method (info1 info2)
5817 "Sort alphabetically by backend name."
5818 (string< (symbol-name (car (gnus-find-method-for-group
5819 (gnus-info-group info1) info1)))
5820 (symbol-name (car (gnus-find-method-for-group
5821 (gnus-info-group info2) info2)))))
5823 (defun gnus-group-sort-by-score (info1 info2)
5824 "Sort by group score."
5825 (< (gnus-info-score info1) (gnus-info-score info2)))
5827 (defun gnus-group-sort-by-rank (info1 info2)
5828 "Sort by level and score."
5829 (let ((level1 (gnus-info-level info1))
5830 (level2 (gnus-info-level info2)))
5831 (or (< level1 level2)
5832 (and (= level1 level2)
5833 (< (gnus-info-score info1) (gnus-info-score info2))))))
5835 ;; Group catching up.
5837 (defun gnus-group-catchup-current (&optional n all)
5838 "Mark all articles not marked as unread in current newsgroup as read.
5839 If prefix argument N is numeric, the ARG next newsgroups will be
5840 caught up. If ALL is non-nil, marked articles will also be marked as
5841 read. Cross references (Xref: header) of articles are ignored.
5842 The difference between N and actual number of newsgroups that were
5843 caught up is returned."
5845 (if (not (or (not gnus-interactive-catchup) ;Without confirmation?
5849 "Do you really want to mark all articles as read? "
5850 "Mark all unread articles as read? "))))
5852 (let ((groups (gnus-group-process-prefix n))
5855 ;; Virtual groups have to be given special treatment.
5856 (let ((method (gnus-find-method-for-group (car groups))))
5857 (if (eq 'nnvirtual (car method))
5858 (nnvirtual-catchup-group
5859 (gnus-group-real-name (car groups)) (nth 1 method) all)))
5860 (gnus-group-remove-mark (car groups))
5862 (gnus-group-goto-group (car groups))
5863 (gnus-group-catchup (car groups) all))
5864 (gnus-group-update-group-line)
5865 (setq ret (1+ ret)))
5866 (setq groups (cdr groups)))
5867 (gnus-group-next-unread-group 1)
5870 (defun gnus-group-catchup-current-all (&optional n)
5871 "Mark all articles in current newsgroup as read.
5872 Cross references (Xref: header) of articles are ignored."
5874 (gnus-group-catchup-current n 'all))
5876 (defun gnus-group-catchup (group &optional all)
5877 "Mark all articles in GROUP as read.
5878 If ALL is non-nil, all articles are marked as read.
5879 The return value is the number of articles that were marked as read,
5880 or nil if no action could be taken."
5881 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5883 ;; Do the updating only if the newsgroup isn't killed.
5884 (if (not (numberp (car entry)))
5885 (gnus-message 1 "Can't catch up; non-active group")
5886 ;; Do auto-expirable marks if that's required.
5887 (when (gnus-group-auto-expirable-p group)
5888 (gnus-add-marked-articles
5889 group 'expire (gnus-list-of-unread-articles group))
5891 (let ((marks (nth 3 (nth 2 entry))))
5892 (gnus-add-marked-articles
5893 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks))))
5894 (gnus-add-marked-articles
5895 group 'expire (gnus-uncompress-range (cdr (assq 'tick marks)))))))
5897 (gnus-update-read-articles group nil)
5898 ;; Also nix out the lists of marks and dormants.
5900 (gnus-add-marked-articles group 'tick nil nil 'force)
5901 (gnus-add-marked-articles group 'dormant nil nil 'force))
5902 (run-hooks 'gnus-group-catchup-group-hook)
5905 (defun gnus-group-expire-articles (&optional n)
5906 "Expire all expirable articles in the current newsgroup."
5908 (let ((groups (gnus-group-process-prefix n))
5911 (error "No groups to expire"))
5912 (while (setq group (pop groups))
5913 (gnus-group-remove-mark group)
5914 (when (gnus-check-backend-function 'request-expire-articles group)
5915 (gnus-message 6 "Expiring articles in %s..." group)
5916 (let* ((info (gnus-get-info group))
5917 (expirable (if (gnus-group-total-expirable-p group)
5918 (cons nil (gnus-list-of-read-articles group))
5919 (assq 'expire (gnus-info-marks info))))
5920 (expiry-wait (gnus-group-get-parameter group 'expiry-wait)))
5924 (gnus-compress-sequence
5926 ;; We set the expiry variables to the groupp
5928 (let ((nnmail-expiry-wait-function nil)
5929 (nnmail-expiry-wait expiry-wait))
5930 (gnus-request-expire-articles
5931 (gnus-uncompress-sequence (cdr expirable)) group))
5932 ;; Just expire using the normal expiry values.
5933 (gnus-request-expire-articles
5934 (gnus-uncompress-sequence (cdr expirable)) group)))))
5935 (gnus-message 6 "Expiring articles in %s...done" group)))
5936 (gnus-group-position-point))))
5938 (defun gnus-group-expire-all-groups ()
5939 "Expire all expirable articles in all newsgroups."
5942 (gnus-message 5 "Expiring...")
5943 (let ((gnus-group-marked (mapcar (lambda (info) (gnus-info-group info))
5944 (cdr gnus-newsrc-alist))))
5945 (gnus-group-expire-articles nil)))
5946 (gnus-group-position-point)
5947 (gnus-message 5 "Expiring...done"))
5949 (defun gnus-group-set-current-level (n level)
5950 "Set the level of the next N groups to LEVEL."
5955 (let ((s (read-string
5956 (format "Level (default %s): "
5957 (or (gnus-group-group-level)
5958 gnus-level-default-subscribed)))))
5959 (if (string-match "^\\s-*$" s)
5960 (int-to-string (or (gnus-group-group-level)
5961 gnus-level-default-subscribed))
5963 (or (and (>= level 1) (<= level gnus-level-killed))
5964 (error "Illegal level: %d" level))
5965 (let ((groups (gnus-group-process-prefix n))
5967 (while (setq group (pop groups))
5968 (gnus-group-remove-mark group)
5969 (gnus-message 6 "Changed level of %s from %d to %d"
5970 group (or (gnus-group-group-level) gnus-level-killed)
5972 (gnus-group-change-level
5973 group level (or (gnus-group-group-level) gnus-level-killed))
5974 (gnus-group-update-group-line)))
5975 (gnus-group-position-point))
5977 (defun gnus-group-unsubscribe-current-group (&optional n)
5978 "Toggle subscription of the current group.
5979 If given numerical prefix, toggle the N next groups."
5981 (let ((groups (gnus-group-process-prefix n))
5984 (setq group (car groups)
5985 groups (cdr groups))
5986 (gnus-group-remove-mark group)
5987 (gnus-group-unsubscribe-group
5988 group (if (<= (gnus-group-group-level) gnus-level-subscribed)
5989 gnus-level-default-unsubscribed
5990 gnus-level-default-subscribed) t)
5991 (gnus-group-update-group-line))
5992 (gnus-group-next-group 1)))
5994 (defun gnus-group-unsubscribe-group (group &optional level silent)
5995 "Toggle subscription to GROUP.
5996 Killed newsgroups are subscribed. If SILENT, don't try to update the
5999 (list (completing-read
6000 "Group: " gnus-active-hashtb nil
6001 (memq gnus-select-method gnus-have-read-active-file))))
6002 (let ((newsrc (gnus-gethash group gnus-newsrc-hashtb)))
6004 ((string-match "^[ \t]$" group)
6005 (error "Empty group name"))
6007 ;; Toggle subscription flag.
6008 (gnus-group-change-level
6009 newsrc (if level level (if (<= (nth 1 (nth 2 newsrc))
6010 gnus-level-subscribed)
6011 (1+ gnus-level-subscribed)
6012 gnus-level-default-subscribed)))
6014 (gnus-group-update-group group)))
6015 ((and (stringp group)
6016 (or (not (memq gnus-select-method gnus-have-read-active-file))
6017 (gnus-active group)))
6018 ;; Add new newsgroup.
6019 (gnus-group-change-level
6021 (if level level gnus-level-default-subscribed)
6022 (or (and (member group gnus-zombie-list)
6025 (and (gnus-group-group-name)
6026 (gnus-gethash (gnus-group-group-name) gnus-newsrc-hashtb)))
6028 (gnus-group-update-group group)))
6029 (t (error "No such newsgroup: %s" group)))
6030 (gnus-group-position-point)))
6032 (defun gnus-group-transpose-groups (n)
6033 "Move the current newsgroup up N places.
6034 If given a negative prefix, move down instead. The difference between
6035 N and the number of steps taken is returned."
6037 (or (gnus-group-group-name)
6038 (error "No group on current line"))
6039 (gnus-group-kill-group 1)
6041 (forward-line (- n))
6042 (gnus-group-yank-group)
6043 (gnus-group-position-point)))
6045 (defun gnus-group-kill-all-zombies ()
6046 "Kill all zombie newsgroups."
6048 (setq gnus-killed-list (nconc gnus-zombie-list gnus-killed-list))
6049 (setq gnus-zombie-list nil)
6050 (gnus-group-list-groups))
6052 (defun gnus-group-kill-region (begin end)
6053 "Kill newsgroups in current region (excluding current point).
6054 The killed newsgroups can be yanked by using \\[gnus-group-yank-group]."
6069 (beginning-of-line) ;Important when LINES < 1
6070 (gnus-group-kill-group lines)))
6072 (defun gnus-group-kill-group (&optional n discard)
6073 "Kill the next N groups.
6074 The killed newsgroups can be yanked by using \\[gnus-group-yank-group].
6075 However, only groups that were alive can be yanked; already killed
6076 groups or zombie groups can't be yanked.
6077 The return value is the name of the group that was killed, or a list
6080 (let ((buffer-read-only nil)
6081 (groups (gnus-group-process-prefix n))
6082 group entry level out)
6083 (if (< (length groups) 10)
6084 ;; This is faster when there are few groups.
6086 (push (setq group (pop groups)) out)
6087 (gnus-group-remove-mark group)
6088 (setq level (gnus-group-group-level))
6090 (when (and (not discard)
6091 (setq entry (gnus-gethash group gnus-newsrc-hashtb)))
6092 (push (cons (car entry) (nth 2 entry))
6093 gnus-list-of-killed-groups))
6094 (gnus-group-change-level
6095 (if entry entry group) gnus-level-killed (if entry nil level)))
6096 ;; If there are lots and lots of groups to be killed, we use
6097 ;; this thing instead.
6099 (setq groups (nreverse groups))
6101 (gnus-group-remove-mark (setq group (pop groups)))
6104 ((setq entry (gnus-gethash group gnus-newsrc-hashtb))
6105 (push (cons (car entry) (nth 2 entry))
6106 gnus-list-of-killed-groups)
6107 (setcdr (cdr entry) (cdddr entry)))
6108 ((member group gnus-zombie-list)
6109 (setq gnus-zombie-list (delete group gnus-zombie-list)))))
6110 (gnus-make-hashtable-from-newsrc-alist)))
6112 (gnus-group-position-point)
6113 (if (< (length out) 2) (car out) (nreverse out))))
6115 (defun gnus-group-yank-group (&optional arg)
6116 "Yank the last newsgroups killed with \\[gnus-group-kill-group],
6117 inserting it before the current newsgroup. The numeric ARG specifies
6118 how many newsgroups are to be yanked. The name of the newsgroup yanked
6119 is returned, or (if several groups are yanked) a list of yanked groups
6122 (setq arg (or arg 1))
6123 (let (info group prev out)
6124 (while (>= (decf arg) 0)
6125 (if (not (setq info (pop gnus-list-of-killed-groups)))
6126 (error "No more newsgroups to yank"))
6127 (push (setq group (nth 1 info)) out)
6128 ;; Find which newsgroup to insert this one before - search
6129 ;; backward until something suitable is found. If there are no
6130 ;; other newsgroups in this buffer, just make this newsgroup the
6132 (setq prev (gnus-group-group-name))
6133 (gnus-group-change-level
6134 info (gnus-info-level (cdr info)) gnus-level-killed
6135 (and prev (gnus-gethash prev gnus-newsrc-hashtb))
6137 (gnus-group-insert-group-line-info group))
6139 (gnus-group-position-point)
6140 (if (< (length out) 2) (car out) (nreverse out))))
6142 (defun gnus-group-kill-level (level)
6143 "Kill all groups that is on a certain LEVEL."
6144 (interactive "nKill all groups on level: ")
6146 ((= level gnus-level-zombie)
6147 (setq gnus-killed-list
6148 (nconc gnus-zombie-list gnus-killed-list))
6149 (setq gnus-zombie-list nil))
6150 ((and (< level gnus-level-zombie)
6152 (or gnus-expert-user
6155 "Do you really want to kill all groups on level %d? "
6157 (let* ((prev gnus-newsrc-alist)
6160 (if (= (gnus-info-level level) level)
6161 (setcdr prev (cdr alist))
6163 (setq alist (cdr alist)))
6164 (gnus-make-hashtable-from-newsrc-alist)
6165 (gnus-group-list-groups)))
6167 (error "Can't kill; illegal level: %d" level))))
6169 (defun gnus-group-list-all-groups (&optional arg)
6170 "List all newsgroups with level ARG or lower.
6171 Default is gnus-level-unsubscribed, which lists all subscribed and most
6172 unsubscribed groups."
6174 (gnus-group-list-groups (or arg gnus-level-unsubscribed) t))
6176 ;; Redefine this to list ALL killed groups if prefix arg used.
6177 ;; Rewritten by engstrom@src.honeywell.com (Eric Engstrom).
6178 (defun gnus-group-list-killed (&optional arg)
6179 "List all killed newsgroups in the group buffer.
6180 If ARG is non-nil, list ALL killed groups known to Gnus. This may
6181 entail asking the server for the groups."
6183 ;; Find all possible killed newsgroups if arg.
6185 ;; First make sure active file has been read.
6186 (unless gnus-have-read-active-file
6187 (let ((gnus-read-active-file t))
6188 (gnus-read-active-file)))
6189 (or gnus-killed-hashtb (gnus-make-hashtable-from-killed))
6190 ;; Go through all newsgroups that are known to Gnus - enlarge kill list
6194 (group (symbol-name sym)))
6195 (if (or (null group)
6196 (gnus-gethash group gnus-killed-hashtb)
6197 (gnus-gethash group gnus-newsrc-hashtb))
6199 (let ((do-sub (gnus-matches-options-n group)))
6200 (if (or (eq do-sub 'subscribe) (eq do-sub 'ignore))
6202 (setq groups (1+ groups))
6203 (setq gnus-killed-list
6204 (cons group gnus-killed-list))
6205 (gnus-sethash group group gnus-killed-hashtb))))))
6206 gnus-active-hashtb))
6207 (if (not gnus-killed-list)
6208 (gnus-message 6 "No killed groups")
6209 (let (gnus-group-list-mode)
6210 (funcall gnus-group-prepare-function
6211 gnus-level-killed t gnus-level-killed))
6212 (goto-char (point-min)))
6213 (gnus-group-position-point))
6215 (defun gnus-group-list-zombies ()
6216 "List all zombie newsgroups in the group buffer."
6218 (if (not gnus-zombie-list)
6219 (gnus-message 6 "No zombie groups")
6220 (let (gnus-group-list-mode)
6221 (funcall gnus-group-prepare-function
6222 gnus-level-zombie t gnus-level-zombie))
6223 (goto-char (point-min)))
6224 (gnus-group-position-point))
6226 (defun gnus-group-list-active ()
6227 "List all groups that are available from the server(s)."
6229 ;; First we make sure that we have really read the active file.
6230 (unless gnus-have-read-active-file
6231 (let ((gnus-read-active-file t))
6232 (gnus-read-active-file)))
6233 ;; Find all groups and sort them.
6239 (and (symbol-value sym)
6240 (setq list (cons (symbol-name sym) list))))
6244 (buffer-read-only nil))
6247 (gnus-group-insert-group-line-info (car groups))
6248 (setq groups (cdr groups)))
6249 (goto-char (point-min))))
6251 (defun gnus-activate-all-groups (level)
6252 "Activate absolutely all groups."
6253 (interactive (list 7))
6254 (let ((gnus-activate-level level)
6255 (gnus-activate-foreign-newsgroups level))
6256 (gnus-group-get-new-news)))
6258 (defun gnus-group-get-new-news (&optional arg)
6259 "Get newly arrived articles.
6260 If ARG is a number, it specifies which levels you are interested in
6261 re-scanning. If ARG is non-nil and not a number, this will force
6262 \"hard\" re-reading of the active files from all servers."
6264 (run-hooks 'gnus-get-new-news-hook)
6265 ;; We might read in new NoCeM messages here.
6266 (when (and gnus-use-nocem
6268 (gnus-nocem-scan-groups))
6269 ;; If ARG is not a number, then we read the active file.
6270 (when (and arg (not (numberp arg)))
6271 (let ((gnus-read-active-file t))
6272 (gnus-read-active-file))
6275 (setq arg (gnus-group-default-level arg t))
6276 (if (and gnus-read-active-file (not arg))
6278 (gnus-read-active-file)
6279 (gnus-get-unread-articles arg))
6280 (let ((gnus-read-active-file (if arg nil gnus-read-active-file)))
6281 (gnus-get-unread-articles arg)))
6282 (run-hooks 'gnus-after-getting-new-news-hook)
6283 (gnus-group-list-groups))
6285 (defun gnus-group-get-new-news-this-group (&optional n)
6286 "Check for newly arrived news in the current group (and the N-1 next groups).
6287 The difference between N and the number of newsgroup checked is returned.
6288 If N is negative, this group and the N-1 previous groups will be checked."
6290 (let* ((groups (gnus-group-process-prefix n))
6291 (ret (if (numberp n) (- n (length groups)) 0))
6294 (setq group (car groups)
6295 groups (cdr groups))
6296 (gnus-group-remove-mark group)
6297 (unless (gnus-get-new-news-in-group group)
6299 (gnus-message 3 "%s error: %s" group (gnus-status-message group))))
6300 (when gnus-goto-next-group-when-activating
6301 (gnus-group-next-unread-group 1 t))
6302 (gnus-summary-position-point)
6305 (defun gnus-get-new-news-in-group (group)
6306 (when (and group (gnus-activate-group group 'scan))
6307 (gnus-get-unread-articles-in-group
6308 (gnus-get-info group) (gnus-active group) t)
6309 (gnus-close-group group)
6310 (when (gnus-group-goto-group group)
6311 (gnus-group-update-group-line))
6314 (defun gnus-group-fetch-faq (group &optional faq-dir)
6315 "Fetch the FAQ for the current group."
6318 (gnus-group-real-name (gnus-group-group-name))
6319 (cond (current-prefix-arg
6321 "Faq dir: " (and (listp gnus-group-faq-directory)
6322 gnus-group-faq-directory))))))
6324 (setq faq-dir (if (listp gnus-group-faq-directory)
6325 (car gnus-group-faq-directory)
6326 gnus-group-faq-directory)))
6327 (or group (error "No group name given"))
6328 (let ((file (concat (file-name-as-directory faq-dir)
6329 (gnus-group-real-name group))))
6330 (if (not (file-exists-p file))
6331 (error "No such file: %s" file)
6334 (defun gnus-group-describe-group (force &optional group)
6335 "Display a description of the current newsgroup."
6336 (interactive (list current-prefix-arg (gnus-group-group-name)))
6337 (and force (setq gnus-description-hashtb nil))
6338 (let ((method (gnus-find-method-for-group group))
6340 (or group (error "No group name given"))
6341 (and (or (and gnus-description-hashtb
6342 ;; We check whether this group's method has been
6343 ;; queried for a description file.
6345 (gnus-group-prefixed-name "" method)
6346 gnus-description-hashtb))
6347 (setq desc (gnus-group-get-description group))
6348 (gnus-read-descriptions-file method))
6350 (or desc (gnus-gethash group gnus-description-hashtb)
6351 "No description available")))))
6353 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6354 (defun gnus-group-describe-all-groups (&optional force)
6355 "Pop up a buffer with descriptions of all newsgroups."
6357 (and force (setq gnus-description-hashtb nil))
6358 (if (not (or gnus-description-hashtb
6359 (gnus-read-all-descriptions-files)))
6360 (error "Couldn't request descriptions file"))
6361 (let ((buffer-read-only nil)
6367 (insert (format " *: %-20s %s\n" (symbol-name group)
6368 (symbol-value group)))
6369 (add-text-properties
6370 b (1+ b) (list 'gnus-group group
6371 'gnus-unread t 'gnus-marked nil
6372 'gnus-level (1+ gnus-level-subscribed))))
6373 gnus-description-hashtb)
6374 (goto-char (point-min))
6375 (gnus-group-position-point)))
6377 ;; Suggested by by Daniel Quinlan <quinlan@best.com>.
6378 (defun gnus-group-apropos (regexp &optional search-description)
6379 "List all newsgroups that have names that match a regexp."
6380 (interactive "sGnus apropos (regexp): ")
6382 (obuf (current-buffer))
6384 ;; Go through all newsgroups that are known to Gnus.
6387 (and (symbol-name group)
6388 (string-match regexp (symbol-name group))
6389 (setq groups (cons (symbol-name group) groups))))
6391 ;; Go through all descriptions that are known to Gnus.
6392 (if search-description
6395 (and (string-match regexp (symbol-value group))
6396 (gnus-active (symbol-name group))
6397 (setq groups (cons (symbol-name group) groups))))
6398 gnus-description-hashtb))
6400 (gnus-message 3 "No groups matched \"%s\"." regexp)
6401 ;; Print out all the groups.
6403 (pop-to-buffer "*Gnus Help*")
6404 (buffer-disable-undo (current-buffer))
6406 (setq groups (sort groups 'string<))
6408 ;; Groups may be entered twice into the list of groups.
6409 (if (not (string= (car groups) prev))
6411 (insert (setq prev (car groups)) "\n")
6412 (if (and gnus-description-hashtb
6413 (setq des (gnus-gethash (car groups)
6414 gnus-description-hashtb)))
6415 (insert " " des "\n"))))
6416 (setq groups (cdr groups)))
6417 (goto-char (point-min))))
6418 (pop-to-buffer obuf)))
6420 (defun gnus-group-description-apropos (regexp)
6421 "List all newsgroups that have names or descriptions that match a regexp."
6422 (interactive "sGnus description apropos (regexp): ")
6423 (if (not (or gnus-description-hashtb
6424 (gnus-read-all-descriptions-files)))
6425 (error "Couldn't request descriptions file"))
6426 (gnus-group-apropos regexp t))
6428 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6429 (defun gnus-group-list-matching (level regexp &optional all lowest)
6430 "List all groups with unread articles that match REGEXP.
6431 If the prefix LEVEL is non-nil, it should be a number that says which
6432 level to cut off listing groups.
6433 If ALL, also list groups with no unread articles.
6434 If LOWEST, don't list groups with level lower than LOWEST."
6435 (interactive "P\nsList newsgroups matching: ")
6436 (gnus-group-prepare-flat (or level gnus-level-subscribed)
6437 all (or lowest 1) regexp)
6438 (goto-char (point-min))
6439 (gnus-group-position-point))
6441 (defun gnus-group-list-all-matching (level regexp &optional lowest)
6442 "List all groups that match REGEXP.
6443 If the prefix LEVEL is non-nil, it should be a number that says which
6444 level to cut off listing groups.
6445 If LOWEST, don't list groups with level lower than LOWEST."
6446 (interactive "P\nsList newsgroups matching: ")
6447 (gnus-group-list-matching (or level gnus-level-killed) regexp t lowest))
6449 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
6450 (defun gnus-group-save-newsrc (&optional force)
6451 "Save the Gnus startup files.
6452 If FORCE, force saving whether it is necessary or not."
6454 (gnus-save-newsrc-file force))
6456 (defun gnus-group-restart (&optional arg)
6457 "Force Gnus to read the .newsrc file."
6459 (when (gnus-yes-or-no-p
6460 (format "Are you sure you want to read %s? "
6461 gnus-current-startup-file))
6462 (gnus-save-newsrc-file)
6463 (gnus-setup-news 'force)
6464 (gnus-group-list-groups arg)))
6466 (defun gnus-group-read-init-file ()
6467 "Read the Gnus elisp init file."
6469 (gnus-read-init-file))
6471 (defun gnus-group-check-bogus-groups (&optional silent)
6472 "Check bogus newsgroups.
6473 If given a prefix, don't ask for confirmation before removing a bogus
6476 (gnus-check-bogus-newsgroups (and (not silent) (not gnus-expert-user)))
6477 (gnus-group-list-groups))
6479 (defun gnus-group-edit-global-kill (&optional article group)
6480 "Edit the global kill file.
6481 If GROUP, edit that local kill file instead."
6483 (setq gnus-current-kill-article article)
6484 (gnus-kill-file-edit-file group)
6487 (substitute-command-keys
6488 (format "Editing a %s kill file (Type \\[gnus-kill-file-exit] to exit)"
6489 (if group "local" "global")))))
6491 (defun gnus-group-edit-local-kill (article group)
6492 "Edit a local kill file."
6493 (interactive (list nil (gnus-group-group-name)))
6494 (gnus-group-edit-global-kill article group))
6496 (defun gnus-group-force-update ()
6497 "Update `.newsrc' file."
6499 (gnus-save-newsrc-file))
6501 (defun gnus-group-suspend ()
6502 "Suspend the current Gnus session.
6503 In fact, cleanup buffers except for group mode buffer.
6504 The hook gnus-suspend-gnus-hook is called before actually suspending."
6506 (run-hooks 'gnus-suspend-gnus-hook)
6507 ;; Kill Gnus buffers except for group mode buffer.
6508 (let ((group-buf (get-buffer gnus-group-buffer)))
6509 ;; Do this on a separate list in case the user does a ^G before we finish
6510 (let ((gnus-buffer-list
6511 (delq group-buf (delq gnus-dribble-buffer
6512 (append gnus-buffer-list nil)))))
6513 (while gnus-buffer-list
6514 (gnus-kill-buffer (car gnus-buffer-list))
6515 (setq gnus-buffer-list (cdr gnus-buffer-list))))
6518 (setq gnus-buffer-list (list group-buf))
6519 (bury-buffer group-buf)
6520 (delete-windows-on group-buf t)))))
6522 (defun gnus-group-clear-dribble ()
6523 "Clear all information from the dribble buffer."
6525 (gnus-dribble-clear)
6526 (gnus-message 7 "Cleared dribble buffer"))
6528 (defun gnus-group-exit ()
6529 "Quit reading news after updating .newsrc.eld and .newsrc.
6530 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6533 (or noninteractive ;For gnus-batch-kill
6534 (not (gnus-server-opened gnus-select-method)) ;NNTP connection closed
6535 (not gnus-interactive-exit) ;Without confirmation
6537 (gnus-y-or-n-p "Are you sure you want to quit reading news? "))
6538 (run-hooks 'gnus-exit-gnus-hook)
6539 ;; Close down GroupLens.
6540 (when gnus-use-grouplens
6542 ;; Offer to save data from non-quitted summary buffers.
6543 (gnus-offer-save-summaries)
6544 ;; Save the newsrc file(s).
6545 (gnus-save-newsrc-file)
6547 (gnus-close-backends)
6548 ;; Shut down the cache.
6549 (when gnus-use-cache
6551 ;; Reset everything.
6553 ;; Allow the user to do things after cleaning up.
6554 (run-hooks 'gnus-after-exiting-gnus-hook)))
6556 (defun gnus-close-backends ()
6557 ;; Send a close request to all backends that support such a request.
6558 (let ((methods gnus-valid-select-methods)
6561 (if (fboundp (setq func (intern (concat (caar methods)
6562 "-request-close"))))
6564 (setq methods (cdr methods)))))
6566 (defun gnus-group-quit ()
6567 "Quit reading news without updating .newsrc.eld or .newsrc.
6568 The hook `gnus-exit-gnus-hook' is called before actually exiting."
6570 (when (or noninteractive ;For gnus-batch-kill
6571 (zerop (buffer-size))
6572 (not (gnus-server-opened gnus-select-method))
6574 (not gnus-current-startup-file)
6576 (format "Quit reading news without saving %s? "
6577 (file-name-nondirectory gnus-current-startup-file))))
6578 (run-hooks 'gnus-exit-gnus-hook)
6579 (if gnus-use-full-window
6580 (delete-other-windows)
6581 (gnus-remove-some-windows))
6583 (gnus-close-backends)
6584 ;; Shut down the cache.
6585 (when gnus-use-cache
6588 ;; Allow the user to do things after cleaning up.
6589 (run-hooks 'gnus-after-exiting-gnus-hook)))
6591 (defun gnus-offer-save-summaries ()
6592 "Offer to save all active summary buffers."
6594 (let ((buflist (buffer-list))
6596 ;; Go through all buffers and find all summaries.
6598 (and (setq bufname (buffer-name (car buflist)))
6599 (string-match "Summary" bufname)
6601 (set-buffer bufname)
6602 ;; We check that this is, indeed, a summary buffer.
6603 (and (eq major-mode 'gnus-summary-mode)
6604 ;; Also make sure this isn't bogus.
6605 gnus-newsgroup-prepared))
6606 (push bufname buffers))
6607 (setq buflist (cdr buflist)))
6608 ;; Go through all these summary buffers and offer to save them.
6611 "Update summary buffer %s? "
6612 (lambda (buf) (set-buffer buf) (gnus-summary-exit))
6615 (defun gnus-group-describe-briefly ()
6616 "Give a one line description of the group mode commands."
6618 (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")))
6620 (defun gnus-group-browse-foreign-server (method)
6621 "Browse a foreign news server.
6622 If called interactively, this function will ask for a select method
6623 (nntp, nnspool, etc.) and a server address (eg. nntp.some.where).
6624 If not, METHOD should be a list where the first element is the method
6625 and the second element is the address."
6627 (list (let ((how (completing-read
6629 (append gnus-valid-select-methods gnus-server-alist)
6630 nil t (cons "nntp" 0))))
6631 ;; We either got a backend name or a virtual server name.
6632 ;; If the first, we also need an address.
6633 (if (assoc how gnus-valid-select-methods)
6635 ;; Suggested by mapjph@bath.ac.uk.
6638 (mapcar (lambda (server) (list server))
6639 gnus-secondary-servers)))
6640 ;; We got a server name, so we find the method.
6641 (gnus-server-to-method how)))))
6642 (gnus-browse-foreign-server method))
6646 ;;; Gnus summary mode
6649 (defvar gnus-summary-mode-map nil)
6651 (put 'gnus-summary-mode 'mode-class 'special)
6653 (unless gnus-summary-mode-map
6654 (setq gnus-summary-mode-map (make-keymap))
6655 (suppress-keymap gnus-summary-mode-map)
6657 ;; Non-orthogonal keys
6659 (gnus-define-keys gnus-summary-mode-map
6660 " " gnus-summary-next-page
6661 "\177" gnus-summary-prev-page
6662 [delete] gnus-summary-prev-page
6663 "\r" gnus-summary-scroll-up
6664 "n" gnus-summary-next-unread-article
6665 "p" gnus-summary-prev-unread-article
6666 "N" gnus-summary-next-article
6667 "P" gnus-summary-prev-article
6668 "\M-\C-n" gnus-summary-next-same-subject
6669 "\M-\C-p" gnus-summary-prev-same-subject
6670 "\M-n" gnus-summary-next-unread-subject
6671 "\M-p" gnus-summary-prev-unread-subject
6672 "." gnus-summary-first-unread-article
6673 "," gnus-summary-best-unread-article
6674 "\M-s" gnus-summary-search-article-forward
6675 "\M-r" gnus-summary-search-article-backward
6676 "<" gnus-summary-beginning-of-article
6677 ">" gnus-summary-end-of-article
6678 "j" gnus-summary-goto-article
6679 "^" gnus-summary-refer-parent-article
6680 "\M-^" gnus-summary-refer-article
6681 "u" gnus-summary-tick-article-forward
6682 "!" gnus-summary-tick-article-forward
6683 "U" gnus-summary-tick-article-backward
6684 "d" gnus-summary-mark-as-read-forward
6685 "D" gnus-summary-mark-as-read-backward
6686 "E" gnus-summary-mark-as-expirable
6687 "\M-u" gnus-summary-clear-mark-forward
6688 "\M-U" gnus-summary-clear-mark-backward
6689 "k" gnus-summary-kill-same-subject-and-select
6690 "\C-k" gnus-summary-kill-same-subject
6691 "\M-\C-k" gnus-summary-kill-thread
6692 "\M-\C-l" gnus-summary-lower-thread
6693 "e" gnus-summary-edit-article
6694 "#" gnus-summary-mark-as-processable
6695 "\M-#" gnus-summary-unmark-as-processable
6696 "\M-\C-t" gnus-summary-toggle-threads
6697 "\M-\C-s" gnus-summary-show-thread
6698 "\M-\C-h" gnus-summary-hide-thread
6699 "\M-\C-f" gnus-summary-next-thread
6700 "\M-\C-b" gnus-summary-prev-thread
6701 "\M-\C-u" gnus-summary-up-thread
6702 "\M-\C-d" gnus-summary-down-thread
6703 "&" gnus-summary-execute-command
6704 "c" gnus-summary-catchup-and-exit
6705 "\C-w" gnus-summary-mark-region-as-read
6706 "\C-t" gnus-summary-toggle-truncation
6707 "?" gnus-summary-mark-as-dormant
6708 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
6709 "\C-c\C-s\C-n" gnus-summary-sort-by-number
6710 "\C-c\C-s\C-a" gnus-summary-sort-by-author
6711 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
6712 "\C-c\C-s\C-d" gnus-summary-sort-by-date
6713 "\C-c\C-s\C-i" gnus-summary-sort-by-score
6714 "=" gnus-summary-expand-window
6715 "\C-x\C-s" gnus-summary-reselect-current-group
6716 "\M-g" gnus-summary-rescan-group
6717 "w" gnus-summary-stop-page-breaking
6718 "\C-c\C-r" gnus-summary-caesar-message
6719 "\M-t" gnus-summary-toggle-mime
6720 "f" gnus-summary-followup
6721 "F" gnus-summary-followup-with-original
6722 "C" gnus-summary-cancel-article
6723 "r" gnus-summary-reply
6724 "R" gnus-summary-reply-with-original
6725 "\C-c\C-f" gnus-summary-mail-forward
6726 "o" gnus-summary-save-article
6727 "\C-o" gnus-summary-save-article-mail
6728 "|" gnus-summary-pipe-output
6729 "\M-k" gnus-summary-edit-local-kill
6730 "\M-K" gnus-summary-edit-global-kill
6732 "\C-c\C-d" gnus-summary-describe-group
6733 "q" gnus-summary-exit
6734 "Q" gnus-summary-exit-no-update
6735 "\C-c\C-i" gnus-info-find-node
6736 gnus-mouse-2 gnus-mouse-pick-article
6737 "m" gnus-summary-mail-other-window
6738 "a" gnus-summary-post-news
6739 "x" gnus-summary-limit-to-unread
6740 "s" gnus-summary-isearch-article
6741 "t" gnus-article-hide-headers
6742 "g" gnus-summary-show-article
6743 "l" gnus-summary-goto-last-article
6744 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
6745 "\C-d" gnus-summary-enter-digest-group
6747 "*" gnus-cache-enter-article
6748 "\M-*" gnus-cache-remove-article
6749 "\M-&" gnus-summary-universal-argument
6750 "\C-l" gnus-recenter
6751 "I" gnus-summary-increase-score
6752 "L" gnus-summary-lower-score
6754 "V" gnus-summary-score-map
6755 "X" gnus-uu-extract-map
6756 "S" gnus-summary-send-map)
6758 ;; Sort of orthogonal keymap
6759 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
6760 "t" gnus-summary-tick-article-forward
6761 "!" gnus-summary-tick-article-forward
6762 "d" gnus-summary-mark-as-read-forward
6763 "r" gnus-summary-mark-as-read-forward
6764 "c" gnus-summary-clear-mark-forward
6765 " " gnus-summary-clear-mark-forward
6766 "e" gnus-summary-mark-as-expirable
6767 "x" gnus-summary-mark-as-expirable
6768 "?" gnus-summary-mark-as-dormant
6769 "b" gnus-summary-set-bookmark
6770 "B" gnus-summary-remove-bookmark
6771 "#" gnus-summary-mark-as-processable
6772 "\M-#" gnus-summary-unmark-as-processable
6773 "S" gnus-summary-limit-include-expunged
6774 "C" gnus-summary-catchup
6775 "H" gnus-summary-catchup-to-here
6776 "\C-c" gnus-summary-catchup-all
6777 "k" gnus-summary-kill-same-subject-and-select
6778 "K" gnus-summary-kill-same-subject
6779 "P" gnus-uu-mark-map)
6781 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mode-map)
6782 "c" gnus-summary-clear-above
6783 "u" gnus-summary-tick-above
6784 "m" gnus-summary-mark-above
6785 "k" gnus-summary-kill-below)
6787 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
6788 "/" gnus-summary-limit-to-subject
6789 "n" gnus-summary-limit-to-articles
6790 "w" gnus-summary-pop-limit
6791 "s" gnus-summary-limit-to-subject
6792 "a" gnus-summary-limit-to-author
6793 "u" gnus-summary-limit-to-unread
6794 "m" gnus-summary-limit-to-marks
6795 "v" gnus-summary-limit-to-score
6796 "D" gnus-summary-limit-include-dormant
6797 "d" gnus-summary-limit-exclude-dormant
6798 ;; "t" gnus-summary-limit-exclude-thread
6799 "E" gnus-summary-limit-include-expunged
6800 "c" gnus-summary-limit-exclude-childless-dormant
6801 "C" gnus-summary-limit-mark-excluded-as-read)
6803 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
6804 "n" gnus-summary-next-unread-article
6805 "p" gnus-summary-prev-unread-article
6806 "N" gnus-summary-next-article
6807 "P" gnus-summary-prev-article
6808 "\C-n" gnus-summary-next-same-subject
6809 "\C-p" gnus-summary-prev-same-subject
6810 "\M-n" gnus-summary-next-unread-subject
6811 "\M-p" gnus-summary-prev-unread-subject
6812 "f" gnus-summary-first-unread-article
6813 "b" gnus-summary-best-unread-article
6814 "j" gnus-summary-goto-article
6815 "g" gnus-summary-goto-subject
6816 "l" gnus-summary-goto-last-article
6817 "p" gnus-summary-pop-article)
6819 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
6820 "k" gnus-summary-kill-thread
6821 "l" gnus-summary-lower-thread
6822 "i" gnus-summary-raise-thread
6823 "T" gnus-summary-toggle-threads
6824 "t" gnus-summary-rethread-current
6825 "^" gnus-summary-reparent-thread
6826 "s" gnus-summary-show-thread
6827 "S" gnus-summary-show-all-threads
6828 "h" gnus-summary-hide-thread
6829 "H" gnus-summary-hide-all-threads
6830 "n" gnus-summary-next-thread
6831 "p" gnus-summary-prev-thread
6832 "u" gnus-summary-up-thread
6833 "o" gnus-summary-top-thread
6834 "d" gnus-summary-down-thread
6835 "#" gnus-uu-mark-thread
6836 "\M-#" gnus-uu-unmark-thread)
6838 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
6839 "c" gnus-summary-catchup-and-exit
6840 "C" gnus-summary-catchup-all-and-exit
6841 "E" gnus-summary-exit-no-update
6842 "Q" gnus-summary-exit
6843 "Z" gnus-summary-exit
6844 "n" gnus-summary-catchup-and-goto-next-group
6845 "R" gnus-summary-reselect-current-group
6846 "G" gnus-summary-rescan-group
6847 "N" gnus-summary-next-group
6848 "P" gnus-summary-prev-group)
6850 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
6851 " " gnus-summary-next-page
6852 "n" gnus-summary-next-page
6853 "\177" gnus-summary-prev-page
6854 [delete] gnus-summary-prev-page
6855 "p" gnus-summary-prev-page
6856 "\r" gnus-summary-scroll-up
6857 "<" gnus-summary-beginning-of-article
6858 ">" gnus-summary-end-of-article
6859 "b" gnus-summary-beginning-of-article
6860 "e" gnus-summary-end-of-article
6861 "^" gnus-summary-refer-parent-article
6862 "r" gnus-summary-refer-parent-article
6863 "R" gnus-summary-refer-references
6864 "g" gnus-summary-show-article
6865 "s" gnus-summary-isearch-article)
6867 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
6868 "b" gnus-article-add-buttons
6869 "B" gnus-article-add-buttons-to-head
6870 "o" gnus-article-treat-overstrike
6871 ;; "w" gnus-article-word-wrap
6872 "w" gnus-article-fill-cited-article
6873 "c" gnus-article-remove-cr
6874 "L" gnus-article-remove-trailing-blank-lines
6875 "q" gnus-article-de-quoted-unreadable
6876 "f" gnus-article-display-x-face
6877 "l" gnus-summary-stop-page-breaking
6878 "r" gnus-summary-caesar-message
6879 "t" gnus-article-hide-headers
6880 "v" gnus-summary-verbose-headers
6881 "m" gnus-summary-toggle-mime)
6883 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
6884 "a" gnus-article-hide
6885 "h" gnus-article-hide-headers
6886 "b" gnus-article-hide-boring-headers
6887 "s" gnus-article-hide-signature
6888 "c" gnus-article-hide-citation
6889 "p" gnus-article-hide-pgp
6890 "\C-c" gnus-article-hide-citation-maybe)
6892 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
6893 "a" gnus-article-highlight
6894 "h" gnus-article-highlight-headers
6895 "c" gnus-article-highlight-citation
6896 "s" gnus-article-highlight-signature)
6898 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
6899 "z" gnus-article-date-ut
6900 "u" gnus-article-date-ut
6901 "l" gnus-article-date-local
6902 "e" gnus-article-date-lapsed
6903 "o" gnus-article-date-original)
6905 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
6907 "f" gnus-summary-fetch-faq
6908 "d" gnus-summary-describe-group
6909 "h" gnus-summary-describe-briefly
6910 "i" gnus-info-find-node)
6912 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
6913 "e" gnus-summary-expire-articles
6914 "\M-\C-e" gnus-summary-expire-articles-now
6915 "\177" gnus-summary-delete-article
6916 [delete] gnus-summary-delete-article
6917 "m" gnus-summary-move-article
6918 "r" gnus-summary-respool-article
6919 "w" gnus-summary-edit-article
6920 "c" gnus-summary-copy-article
6921 "B" gnus-summary-crosspost-article
6922 "q" gnus-summary-respool-query
6923 "i" gnus-summary-import-article)
6925 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
6926 "o" gnus-summary-save-article
6927 "m" gnus-summary-save-article-mail
6928 "r" gnus-summary-save-article-rmail
6929 "f" gnus-summary-save-article-file
6930 "b" gnus-summary-save-article-body-file
6931 "h" gnus-summary-save-article-folder
6932 "v" gnus-summary-save-article-vm
6933 "p" gnus-summary-pipe-output
6934 "s" gnus-soup-add-article)
6939 (defun gnus-summary-mode (&optional group)
6940 "Major mode for reading articles.
6942 All normal editing commands are switched off.
6943 \\<gnus-summary-mode-map>
6944 Each line in this buffer represents one article. To read an
6945 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
6946 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
6949 You can also post articles and send mail from this buffer. To
6950 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
6951 of an article, type `\\[gnus-summary-reply]'.
6953 There are approx. one gazillion commands you can execute in this
6954 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
6956 The following commands are available:
6958 \\{gnus-summary-mode-map}"
6960 (when (and menu-bar-mode
6961 (gnus-visual-p 'summary-menu 'menu))
6962 (gnus-summary-make-menu-bar))
6963 (kill-all-local-variables)
6964 (let ((locals gnus-summary-local-variables))
6966 (if (consp (car locals))
6968 (make-local-variable (caar locals))
6969 (set (caar locals) (eval (cdar locals))))
6970 (make-local-variable (car locals))
6971 (set (car locals) nil))
6972 (setq locals (cdr locals))))
6973 (gnus-make-thread-indent-array)
6974 (gnus-simplify-mode-line)
6975 (setq major-mode 'gnus-summary-mode)
6976 (setq mode-name "Summary")
6977 (make-local-variable 'minor-mode-alist)
6978 (use-local-map gnus-summary-mode-map)
6979 (buffer-disable-undo (current-buffer))
6980 (setq buffer-read-only t) ;Disable modification
6981 (setq truncate-lines t)
6982 (setq selective-display t)
6983 (setq selective-display-ellipses t) ;Display `...'
6984 (setq buffer-display-table gnus-summary-display-table)
6985 (setq gnus-newsgroup-name group)
6986 (run-hooks 'gnus-summary-mode-hook))
6988 (defun gnus-summary-make-display-table ()
6989 ;; Change the display table. Odd characters have a tendency to mess
6990 ;; up nicely formatted displays - we make all possible glyphs
6991 ;; display only a single character.
6993 ;; We start from the standard display table, if any.
6994 (setq gnus-summary-display-table
6995 (or (copy-sequence standard-display-table)
6996 (make-display-table)))
6997 ;; Nix out all the control chars...
6999 (while (>= (setq i (1- i)) 0)
7000 (aset gnus-summary-display-table i [??])))
7001 ;; ... but not newline and cr, of course. (cr is necessary for the
7002 ;; selective display).
7003 (aset gnus-summary-display-table ?\n nil)
7004 (aset gnus-summary-display-table ?\r nil)
7005 ;; We nix out any glyphs over 126 that are not set already.
7007 (while (>= (setq i (1- i)) 127)
7008 ;; Only modify if the entry is nil.
7009 (or (aref gnus-summary-display-table i)
7010 (aset gnus-summary-display-table i [??])))))
7012 (defun gnus-summary-clear-local-variables ()
7013 (let ((locals gnus-summary-local-variables))
7015 (if (consp (car locals))
7016 (and (vectorp (caar locals))
7017 (set (caar locals) nil))
7018 (and (vectorp (car locals))
7019 (set (car locals) nil)))
7020 (setq locals (cdr locals)))))
7022 ;; Summary data functions.
7024 (defmacro gnus-data-number (data)
7027 (defmacro gnus-data-set-number (data number)
7028 `(setcar ,data ,number))
7030 (defmacro gnus-data-mark (data)
7033 (defmacro gnus-data-set-mark (data mark)
7034 `(setcar (nthcdr 1 ,data) ,mark))
7036 (defmacro gnus-data-pos (data)
7039 (defmacro gnus-data-set-pos (data pos)
7040 `(setcar (nthcdr 2 ,data) ,pos))
7042 (defmacro gnus-data-header (data)
7045 (defmacro gnus-data-level (data)
7048 (defmacro gnus-data-unread-p (data)
7049 `(= (nth 1 ,data) gnus-unread-mark))
7051 (defmacro gnus-data-pseudo-p (data)
7052 `(consp (nth 3 ,data)))
7054 (defmacro gnus-data-find (number)
7055 `(assq ,number gnus-newsgroup-data))
7057 (defmacro gnus-data-find-list (number &optional data)
7058 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
7059 (memq (assq ,number bdata)
7062 (defmacro gnus-data-make (number mark pos header level)
7063 `(list ,number ,mark ,pos ,header ,level))
7065 (defun gnus-data-enter (after-article number mark pos header level offset)
7066 (let ((data (gnus-data-find-list after-article)))
7067 (or data (error "No such article: %d" after-article))
7068 (setcdr data (cons (gnus-data-make number mark pos header level)
7070 (setq gnus-newsgroup-data-reverse nil)
7071 (gnus-data-update-list (cddr data) offset)))
7073 (defun gnus-data-enter-list (after-article list &optional offset)
7075 (let ((data (and after-article (gnus-data-find-list after-article)))
7077 (or data (not after-article) (error "No such article: %d" after-article))
7078 ;; Find the last element in the list to be spliced into the main
7081 (setq list (cdr list)))
7084 (setcdr list gnus-newsgroup-data)
7085 (setq gnus-newsgroup-data ilist)
7086 (and offset (gnus-data-update-list (cdr list) offset)))
7087 (setcdr list (cdr data))
7089 (and offset (gnus-data-update-list (cdr data) offset)))
7090 (setq gnus-newsgroup-data-reverse nil))))
7092 (defun gnus-data-remove (article &optional offset)
7093 (let ((data gnus-newsgroup-data))
7094 (if (= (gnus-data-number (car data)) article)
7095 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
7096 gnus-newsgroup-data-reverse nil)
7098 (and (= (gnus-data-number (cadr data)) article)
7100 (setcdr data (cddr data))
7101 (and offset (gnus-data-update-list (cdr data) offset))
7103 gnus-newsgroup-data-reverse nil)))
7104 (setq data (cdr data))))))
7106 (defmacro gnus-data-list (backward)
7108 (or gnus-newsgroup-data-reverse
7109 (setq gnus-newsgroup-data-reverse
7110 (reverse gnus-newsgroup-data)))
7111 gnus-newsgroup-data))
7113 (defun gnus-data-update-list (data offset)
7114 "Add OFFSET to the POS of all data entries in DATA."
7116 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
7117 (setq data (cdr data))))
7119 (defun gnus-data-compute-positions ()
7120 "Compute the positions of all articles."
7121 (let ((data gnus-newsgroup-data)
7124 (when (setq pos (text-property-any
7125 (point-min) (point-max)
7126 'gnus-number (gnus-data-number (car data))))
7127 (gnus-data-set-pos (car data) (+ pos 3)))
7128 (setq data (cdr data)))))
7130 (defun gnus-summary-article-pseudo-p (article)
7131 "Say whether this article is a pseudo article or not."
7132 (not (vectorp (gnus-data-header (gnus-data-find article)))))
7134 (defun gnus-article-parent-p (number)
7135 "Say whether this article is a parent or not."
7136 (let ((data (gnus-data-find-list number)))
7137 (and (cdr data) ; There has to be an article after...
7138 (< (gnus-data-level (car data)) ; And it has to have a higher level.
7139 (gnus-data-level (nth 1 data))))))
7141 (defun gnus-article-children (number)
7142 "Return a list of all children to NUMBER."
7143 (let* ((data (gnus-data-find-list number))
7144 (level (gnus-data-level (car data)))
7146 (setq data (cdr data))
7148 (= (gnus-data-level (car data)) (1+ level)))
7149 (push (gnus-data-number (car data)) children)
7150 (setq data (cdr data)))
7153 (defmacro gnus-summary-skip-intangible ()
7154 "If the current article is intangible, then jump to a different article."
7155 '(let ((to (get-text-property (point) 'gnus-intangible)))
7156 (and to (gnus-summary-goto-subject to))))
7158 (defmacro gnus-summary-article-intangible-p ()
7159 "Say whether this article is intangible or not."
7160 '(get-text-property (point) 'gnus-intangible))
7162 ;; Some summary mode macros.
7164 (defmacro gnus-summary-article-number ()
7165 "The article number of the article on the current line.
7166 If there isn's an article number here, then we return the current
7169 (gnus-summary-skip-intangible)
7170 (or (get-text-property (point) 'gnus-number)
7171 (gnus-summary-last-subject))))
7173 (defmacro gnus-summary-article-header (&optional number)
7174 `(gnus-data-header (gnus-data-find
7175 ,(or number '(gnus-summary-article-number)))))
7177 (defmacro gnus-summary-thread-level (&optional number)
7178 `(if (and (eq gnus-summary-make-false-root 'dummy)
7179 (get-text-property (point) 'gnus-intangible))
7181 (gnus-data-level (gnus-data-find
7182 ,(or number '(gnus-summary-article-number))))))
7184 (defmacro gnus-summary-article-mark (&optional number)
7185 `(gnus-data-mark (gnus-data-find
7186 ,(or number '(gnus-summary-article-number)))))
7188 (defmacro gnus-summary-article-pos (&optional number)
7189 `(gnus-data-pos (gnus-data-find
7190 ,(or number '(gnus-summary-article-number)))))
7192 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
7193 (defmacro gnus-summary-article-subject (&optional number)
7194 "Return current subject string or nil if nothing."
7197 `(gnus-data-header (assq ,number gnus-newsgroup-data))
7198 '(gnus-data-header (assq (gnus-summary-article-number)
7199 gnus-newsgroup-data)))))
7202 (mail-header-subject headers))))
7204 (defmacro gnus-summary-article-score (&optional number)
7205 "Return current article score."
7206 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
7207 gnus-newsgroup-scored))
7208 gnus-summary-default-score 0))
7210 (defun gnus-summary-article-children (&optional number)
7211 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
7212 (level (gnus-data-level (car data)))
7214 (while (and (setq data (cdr data))
7215 (> (setq l (gnus-data-level (car data))) level))
7216 (and (= (1+ level) l)
7217 (setq children (cons (gnus-data-number (car data))
7219 (nreverse children)))
7221 (defun gnus-summary-article-parent (&optional number)
7222 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
7223 (gnus-data-list t)))
7224 (level (gnus-data-level (car data)))
7227 () ; This is a root.
7228 ;; We search until we find an article with a level less than
7229 ;; this one. That function has to be the parent.
7230 (while (and (setq data (cdr data))
7231 (not (< (gnus-data-level (car data)) level))))
7232 (and data (gnus-data-number (car data))))))
7234 (defun gnus-unread-mark-p (mark)
7235 "Say whether MARK is the unread mark."
7236 (= mark gnus-unread-mark))
7238 (defun gnus-read-mark-p (mark)
7239 "Say whether MARK is one of the marks that mark as read.
7240 This is all marks except unread, ticked, dormant, and expirable."
7241 (not (or (= mark gnus-unread-mark)
7242 (= mark gnus-ticked-mark)
7243 (= mark gnus-dormant-mark)
7244 (= mark gnus-expirable-mark))))
7246 ;; Various summary mode internalish functions.
7248 (defun gnus-mouse-pick-article (e)
7251 (gnus-summary-next-page nil t))
7253 (defun gnus-summary-setup-buffer (group)
7254 "Initialize summary buffer."
7255 (let ((buffer (concat "*Summary " group "*")))
7256 (if (get-buffer buffer)
7259 (setq gnus-summary-buffer (current-buffer))
7260 (not gnus-newsgroup-prepared))
7261 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
7262 (setq gnus-summary-buffer (set-buffer (get-buffer-create buffer)))
7263 (gnus-add-current-to-buffer-list)
7264 (gnus-summary-mode group)
7266 (gnus-carpal-setup-buffer 'summary))
7267 (unless gnus-single-article-buffer
7268 (make-local-variable 'gnus-article-buffer)
7269 (make-local-variable 'gnus-article-current)
7270 (make-local-variable 'gnus-original-article-buffer))
7271 (setq gnus-newsgroup-name group)
7274 (defun gnus-set-global-variables ()
7275 ;; Set the global equivalents of the summary buffer-local variables
7276 ;; to the latest values they had. These reflect the summary buffer
7277 ;; that was in action when the last article was fetched.
7278 (when (eq major-mode 'gnus-summary-mode)
7279 (setq gnus-summary-buffer (current-buffer))
7280 (let ((name gnus-newsgroup-name)
7281 (marked gnus-newsgroup-marked)
7282 (unread gnus-newsgroup-unreads)
7283 (headers gnus-current-headers)
7284 (data gnus-newsgroup-data)
7285 (summary gnus-summary-buffer)
7286 (article-buffer gnus-article-buffer)
7287 (original gnus-original-article-buffer)
7288 (gac gnus-article-current)
7289 (score-file gnus-current-score-file))
7291 (set-buffer gnus-group-buffer)
7292 (setq gnus-newsgroup-name name)
7293 (setq gnus-newsgroup-marked marked)
7294 (setq gnus-newsgroup-unreads unread)
7295 (setq gnus-current-headers headers)
7296 (setq gnus-newsgroup-data data)
7297 (setq gnus-article-current gac)
7298 (setq gnus-summary-buffer summary)
7299 (setq gnus-article-buffer article-buffer)
7300 (setq gnus-original-article-buffer original)
7301 (setq gnus-current-score-file score-file)))))
7303 (defun gnus-summary-last-article-p (&optional article)
7304 "Return whether ARTICLE is the last article in the buffer."
7305 (if (not (setq article (or article (gnus-summary-article-number))))
7306 t ; All non-existant numbers are the last article. :-)
7307 (cdr (gnus-data-find-list article))))
7309 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
7310 "Insert a dummy root in the summary buffer."
7312 (add-text-properties
7313 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
7314 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
7316 (defvar gnus-thread-indent-array nil)
7317 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
7318 (defun gnus-make-thread-indent-array ()
7320 (if (and gnus-thread-indent-array
7321 (= gnus-thread-indent-level gnus-thread-indent-array-level))
7323 (setq gnus-thread-indent-array (make-vector 201 "")
7324 gnus-thread-indent-array-level gnus-thread-indent-level)
7326 (aset gnus-thread-indent-array n
7327 (make-string (* n gnus-thread-indent-level) ? ))
7330 (defun gnus-summary-insert-line
7331 (gnus-tmp-header gnus-tmp-level gnus-tmp-current gnus-tmp-unread
7332 gnus-tmp-replied gnus-tmp-expirable gnus-tmp-subject-or-nil
7333 &optional gnus-tmp-dummy gnus-tmp-score gnus-tmp-process)
7334 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
7335 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
7336 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
7337 (gnus-tmp-score-char
7338 (if (or (null gnus-summary-default-score)
7339 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
7340 gnus-summary-zcore-fuzz)) ?
7341 (if (< gnus-tmp-score gnus-summary-default-score)
7342 gnus-score-below-mark gnus-score-over-mark)))
7343 (gnus-tmp-replied (cond (gnus-tmp-process gnus-process-mark)
7344 ((memq gnus-tmp-current gnus-newsgroup-cached)
7346 (gnus-tmp-replied gnus-replied-mark)
7347 ((memq gnus-tmp-current gnus-newsgroup-saved)
7349 (t gnus-unread-mark)))
7350 (gnus-tmp-from (mail-header-from gnus-tmp-header))
7353 ((string-match "(.+)" gnus-tmp-from)
7354 (substring gnus-tmp-from
7355 (1+ (match-beginning 0)) (1- (match-end 0))))
7356 ((string-match "<[^>]+> *$" gnus-tmp-from)
7357 (let ((beg (match-beginning 0)))
7358 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
7359 (substring gnus-tmp-from (1+ (match-beginning 0))
7360 (1- (match-end 0))))
7361 (substring gnus-tmp-from 0 beg))))
7363 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
7364 (gnus-tmp-number (mail-header-number gnus-tmp-header))
7365 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
7366 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
7367 (buffer-read-only nil))
7368 (when (string= gnus-tmp-name "")
7369 (setq gnus-tmp-name gnus-tmp-from))
7370 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
7373 (progn (eval gnus-summary-line-format-spec) (point))
7374 'gnus-number gnus-tmp-number)
7375 (when (gnus-visual-p 'summary-highlight 'highlight)
7377 (run-hooks 'gnus-summary-update-hook)
7380 (defun gnus-summary-update-line (&optional dont-update)
7381 ;; Update summary line after change.
7382 (when (and gnus-summary-default-score
7383 (not gnus-summary-inhibit-highlight))
7384 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
7385 (article (gnus-summary-article-number))
7386 (score (gnus-summary-article-score article)))
7388 (if (and gnus-summary-mark-below
7389 (< (gnus-summary-article-score)
7390 gnus-summary-mark-below))
7391 ;; This article has a low score, so we mark it as read.
7392 (when (memq article gnus-newsgroup-unreads)
7393 (gnus-summary-mark-article-as-read gnus-low-score-mark))
7394 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
7395 ;; This article was previously marked as read on account
7396 ;; of a low score, but now it has risen, so we mark it as
7398 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
7399 (gnus-summary-update-mark
7400 (if (or (null gnus-summary-default-score)
7401 (<= (abs (- score gnus-summary-default-score))
7402 gnus-summary-zcore-fuzz)) ?
7403 (if (< score gnus-summary-default-score)
7404 gnus-score-below-mark gnus-score-over-mark)) 'score))
7405 ;; Do visual highlighting.
7406 (when (gnus-visual-p 'summary-highlight 'highlight)
7407 (run-hooks 'gnus-summary-update-hook)))))
7409 (defvar gnus-tmp-new-adopts nil)
7411 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
7412 ;; Sum up all elements (and sub-elements) in a list.
7414 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
7416 ((and (consp thread) (cdr thread))
7419 'gnus-summary-number-of-articles-in-thread (cdr thread))))
7422 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
7425 (when (and level (zerop level) gnus-tmp-new-adopts)
7428 'gnus-summary-number-of-articles-in-thread
7429 gnus-tmp-new-adopts))))
7431 (if (> number 1) gnus-not-empty-thread-mark
7432 gnus-empty-thread-mark)
7435 (defun gnus-summary-set-local-parameters (group)
7436 "Go through the local params of GROUP and set all variable specs in that list."
7437 (let ((params (gnus-info-params (gnus-get-info group)))
7440 (setq elem (car params)
7441 params (cdr params))
7442 (and (consp elem) ; Has to be a cons.
7443 (consp (cdr elem)) ; The cdr has to be a list.
7444 (symbolp (car elem)) ; Has to be a symbol in there.
7445 (not (memq (car elem)
7446 '(quit-config to-address to-list to-group)))
7447 (progn ; So we set it.
7448 (make-local-variable (car elem))
7449 (set (car elem) (eval (nth 1 elem))))))))
7451 (defun gnus-summary-read-group
7452 (group &optional show-all no-article kill-buffer no-display)
7453 "Start reading news in newsgroup GROUP.
7454 If SHOW-ALL is non-nil, already read articles are also listed.
7455 If NO-ARTICLE is non-nil, no article is selected initially.
7456 If NO-DISPLAY, don't generate a summary buffer."
7457 (gnus-message 5 "Retrieving newsgroup: %s..." group)
7458 (let* ((new-group (gnus-summary-setup-buffer group))
7459 (quit-config (gnus-group-quit-config group))
7460 (did-select (and new-group (gnus-select-newsgroup group show-all))))
7462 ;; This summary buffer exists already, so we just select it.
7464 (gnus-set-global-variables)
7466 (gnus-kill-or-deaden-summary kill-buffer))
7467 (gnus-configure-windows 'summary 'force)
7468 (gnus-set-mode-line 'summary)
7469 (gnus-summary-position-point)
7472 ;; We couldn't select this group.
7474 (when (and (eq major-mode 'gnus-summary-mode)
7475 (not (equal (current-buffer) kill-buffer)))
7476 (kill-buffer (current-buffer))
7477 (if (not quit-config)
7479 (set-buffer gnus-group-buffer)
7480 (gnus-group-jump-to-group group)
7481 (gnus-group-next-unread-group 1))
7482 (if (not (buffer-name (car quit-config)))
7483 (gnus-configure-windows 'group 'force)
7484 (set-buffer (car quit-config))
7485 (and (eq major-mode 'gnus-summary-mode)
7486 (gnus-set-global-variables))
7487 (gnus-configure-windows (cdr quit-config)))))
7488 (gnus-message 3 "Can't select group")
7490 ;; The user did a `C-g' while prompting for number of articles,
7491 ;; so we exit this group.
7492 ((eq did-select 'quit)
7493 (and (eq major-mode 'gnus-summary-mode)
7494 (not (equal (current-buffer) kill-buffer))
7495 (kill-buffer (current-buffer)))
7497 (gnus-kill-or-deaden-summary kill-buffer))
7498 (if (not quit-config)
7500 (set-buffer gnus-group-buffer)
7501 (gnus-group-jump-to-group group)
7502 (gnus-group-next-unread-group 1)
7503 (gnus-configure-windows 'group 'force))
7504 (if (not (buffer-name (car quit-config)))
7505 (gnus-configure-windows 'group 'force)
7506 (set-buffer (car quit-config))
7507 (and (eq major-mode 'gnus-summary-mode)
7508 (gnus-set-global-variables))
7509 (gnus-configure-windows (cdr quit-config))))
7510 ;; Finally signal the quit.
7512 ;; The group was successfully selected.
7514 (gnus-set-global-variables)
7515 ;; Save the active value in effect when the group was entered.
7516 (setq gnus-newsgroup-active
7518 (gnus-active gnus-newsgroup-name)))
7519 ;; You can change the summary buffer in some way with this hook.
7520 (run-hooks 'gnus-select-group-hook)
7521 ;; Set any local variables in the group parameters.
7522 (gnus-summary-set-local-parameters gnus-newsgroup-name)
7523 (gnus-update-format-specifications)
7524 ;; Do score processing.
7525 (when gnus-use-scoring
7526 (gnus-possibly-score-headers))
7527 ;; Check whether to fill in the gaps in the threads.
7528 (when gnus-build-sparse-threads
7529 (gnus-build-sparse-threads))
7530 ;; Find the initial limit.
7532 (let ((gnus-newsgroup-dormant nil))
7533 (gnus-summary-initial-limit show-all))
7534 (gnus-summary-initial-limit show-all))
7535 ;; Generate the summary buffer.
7537 (gnus-summary-prepare))
7538 (when gnus-use-trees
7539 (gnus-tree-open group)
7540 (setq gnus-summary-highlight-line-function
7541 'gnus-tree-highlight-article))
7542 ;; If the summary buffer is empty, but there are some low-scored
7543 ;; articles or some excluded dormants, we include these in the
7545 (when (and (zerop (buffer-size))
7547 (cond (gnus-newsgroup-dormant
7548 (gnus-summary-limit-include-dormant))
7549 ((and gnus-newsgroup-scored show-all)
7550 (gnus-summary-limit-include-expunged))))
7551 ;; Function `gnus-apply-kill-file' must be called in this hook.
7552 (run-hooks 'gnus-apply-kill-hook)
7553 (if (and (zerop (buffer-size))
7556 ;; This newsgroup is empty.
7557 (gnus-summary-catchup-and-exit nil t) ;Without confirmations.
7558 (gnus-message 6 "No unread news")
7560 (gnus-kill-or-deaden-summary kill-buffer))
7561 ;; Return nil from this function.
7563 ;; Hide conversation thread subtrees. We cannot do this in
7564 ;; gnus-summary-prepare-hook since kill processing may not
7565 ;; work with hidden articles.
7566 (and gnus-show-threads
7567 gnus-thread-hide-subtree
7568 (gnus-summary-hide-all-threads))
7569 ;; Show first unread article if requested.
7570 (if (and (not no-article)
7572 gnus-newsgroup-unreads
7573 gnus-auto-select-first)
7574 (if (eq gnus-auto-select-first 'best)
7575 (gnus-summary-best-unread-article)
7576 (gnus-summary-first-unread-article))
7577 ;; Don't select any articles, just move point to the first
7578 ;; article in the group.
7579 (goto-char (point-min))
7580 (gnus-summary-position-point)
7581 (gnus-set-mode-line 'summary)
7582 (gnus-configure-windows 'summary 'force))
7583 ;; If we are in async mode, we send some info to the backend.
7584 (when gnus-newsgroup-async
7585 (gnus-request-asynchronous gnus-newsgroup-name gnus-newsgroup-data))
7587 (gnus-kill-or-deaden-summary kill-buffer))
7588 (when (get-buffer-window gnus-group-buffer t)
7589 ;; Gotta use windows, because recenter does wierd stuff if
7590 ;; the current buffer ain't the displayed window.
7591 (let ((owin (selected-window)))
7592 (select-window (get-buffer-window gnus-group-buffer t))
7593 (when (gnus-group-goto-group group)
7595 (select-window owin))))
7596 ;; Mark this buffer as "prepared".
7597 (setq gnus-newsgroup-prepared t)
7600 (defun gnus-summary-prepare ()
7601 "Generate the summary buffer."
7602 (let ((buffer-read-only nil))
7604 (setq gnus-newsgroup-data nil
7605 gnus-newsgroup-data-reverse nil)
7606 (run-hooks 'gnus-summary-generate-hook)
7607 ;; Generate the buffer, either with threads or without.
7608 (when gnus-newsgroup-headers
7609 (gnus-summary-prepare-threads
7610 (if gnus-show-threads
7611 (gnus-sort-gathered-threads
7612 (funcall gnus-summary-thread-gathering-function
7614 (gnus-cut-threads (gnus-make-threads)))))
7615 ;; Unthreaded display.
7616 (gnus-sort-articles gnus-newsgroup-headers))))
7617 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
7618 ;; Call hooks for modifying summary buffer.
7619 (goto-char (point-min))
7620 (run-hooks 'gnus-summary-prepare-hook)))
7622 (defun gnus-gather-threads-by-subject (threads)
7623 "Gather threads by looking at Subject headers."
7624 (if (not gnus-summary-make-false-root)
7626 (let ((hashtb (gnus-make-hashtable 1023))
7629 subject hthread whole-subject)
7631 (setq whole-subject (mail-header-subject (caar threads)))
7632 (if (and gnus-summary-gather-exclude-subject
7633 (string-match gnus-summary-gather-exclude-subject
7635 () ; We don't want to do anything with this article.
7636 ;; We simplify the subject before looking it up in the
7640 ;; Truncate the subject.
7641 ((numberp gnus-summary-gather-subject-limit)
7642 (setq subject (gnus-simplify-subject-re whole-subject))
7643 (if (> (length subject) gnus-summary-gather-subject-limit)
7644 (substring subject 0 gnus-summary-gather-subject-limit)
7646 ;; Fuzzily simplify it.
7647 ((eq 'fuzzy gnus-summary-gather-subject-limit)
7648 (gnus-simplify-subject-fuzzy whole-subject))
7649 ;; Just remove the leading "Re:".
7651 (gnus-simplify-subject-re whole-subject))))
7653 (if (setq hthread (gnus-gethash subject hashtb))
7655 ;; We enter a dummy root into the thread, if we
7656 ;; haven't done that already.
7657 (unless (stringp (caar hthread))
7658 (setcar hthread (list whole-subject (car hthread))))
7659 ;; We add this new gathered thread to this gathered
7661 (setcdr (car hthread)
7662 (nconc (cdar hthread) (list (car threads))))
7663 ;; Remove it from the list of threads.
7664 (setcdr prev (cdr threads))
7665 (setq threads prev))
7666 ;; Enter this thread into the hash table.
7667 (gnus-sethash subject threads hashtb)))
7669 (setq threads (cdr threads)))
7672 (defun gnus-gather-threads-by-references (threads)
7673 "Gather threads by looking at References headers."
7674 (let ((idhashtb (gnus-make-hashtable 1023))
7675 (thhashtb (gnus-make-hashtable 1023))
7678 ids references id gthread gid entered)
7680 (when (setq references (mail-header-references (caar threads)))
7681 (setq id (mail-header-id (caar threads)))
7682 (setq ids (gnus-split-references references))
7685 (if (not (setq gid (gnus-gethash (car ids) idhashtb)))
7687 (gnus-sethash (car ids) id idhashtb)
7688 (gnus-sethash id threads thhashtb))
7689 (setq gthread (gnus-gethash gid thhashtb))
7691 ;; We enter a dummy root into the thread, if we
7692 ;; haven't done that already.
7693 (unless (stringp (caar gthread))
7694 (setcar gthread (list (mail-header-subject (caar gthread))
7696 ;; We add this new gathered thread to this gathered
7698 (setcdr (car gthread)
7699 (nconc (cdar gthread) (list (car threads)))))
7700 ;; Add it into the thread hash table.
7701 (gnus-sethash id gthread thhashtb)
7703 ;; Remove it from the list of threads.
7704 (setcdr prev (cdr threads))
7705 (setq threads prev))
7706 (setq ids (cdr ids))))
7708 (setq threads (cdr threads)))
7711 (defun gnus-sort-gathered-threads (threads)
7712 "Sort subtreads inside each gathered thread by article number."
7713 (let ((result threads))
7715 (when (stringp (caar threads))
7716 (setcdr (car threads)
7717 (sort (cdar threads) 'gnus-thread-sort-by-number)))
7718 (setq threads (cdr threads)))
7721 (defun gnus-make-threads ()
7722 "Go through the dependency hashtb and find the roots. Return all threads."
7726 (unless (car (symbol-value refs))
7727 ;; These threads do not refer back to any other articles,
7728 ;; so they're roots.
7729 (setq threads (append (cdr (symbol-value refs)) threads))))
7730 gnus-newsgroup-dependencies)
7733 (defun gnus-build-sparse-threads ()
7734 (let ((headers gnus-newsgroup-headers)
7735 (deps gnus-newsgroup-dependencies)
7736 header references generation relations
7737 cthread subject child end pthread relation)
7738 ;; First we create an alist of generations/relations, where
7739 ;; generations is how much we trust the ralation, and the relation
7741 (gnus-message 7 "Making sparse threads...")
7743 (nnheader-set-temp-buffer " *gnus sparse threads*")
7744 (while (setq header (pop headers))
7745 (when (and (setq references (mail-header-references header))
7746 (not (string= references "")))
7748 (setq child (downcase (mail-header-id header))
7749 subject (mail-header-subject header))
7751 (while (search-backward ">" nil t)
7752 (setq end (1+ (point)))
7753 (when (search-backward "<" nil t)
7754 (push (list (incf generation)
7755 child (setq child (downcase
7756 (buffer-substring (point) end)))
7759 (push (list (1+ generation) child nil subject) relations)
7761 (kill-buffer (current-buffer)))
7762 ;; Sort over trustworthiness.
7763 (setq relations (sort relations (lambda (r1 r2) (< (car r1) (car r2)))))
7764 (while (setq relation (pop relations))
7765 (when (if (boundp (setq cthread (intern (cadr relation) deps)))
7766 (unless (car (symbol-value cthread))
7767 ;; Make this article the parent of these threads.
7768 (setcar (symbol-value cthread)
7769 (vector gnus-reffed-article-number
7773 (or (caddr relation) "") 0 0 "")))
7774 (set cthread (list (vector gnus-reffed-article-number
7776 "" "" (cadr relation)
7777 (or (caddr relation) "") 0 0 ""))))
7778 (push gnus-reffed-article-number gnus-newsgroup-limit)
7779 (push gnus-reffed-article-number gnus-newsgroup-sparse)
7780 (push (cons gnus-reffed-article-number gnus-sparse-mark)
7781 gnus-newsgroup-reads)
7782 (decf gnus-reffed-article-number)
7783 ;; Make this new thread the child of its parent.
7784 (if (boundp (setq pthread (intern (or (caddr relation) "none") deps)))
7785 (setcdr (symbol-value pthread)
7786 (nconc (cdr (symbol-value pthread))
7787 (list (symbol-value cthread))))
7788 (set pthread (list nil (symbol-value cthread))))))
7789 (gnus-message 7 "Making sparse threads...done")))
7791 (defun gnus-build-old-threads ()
7792 ;; Look at all the articles that refer back to old articles, and
7793 ;; fetch the headers for the articles that aren't there. This will
7794 ;; build complete threads - if the roots haven't been expired by the
7799 (when (not (car (symbol-value refs)))
7800 (setq heads (cdr (symbol-value refs)))
7802 (if (memq (mail-header-number (caar heads))
7803 gnus-newsgroup-dormant)
7804 (setq heads (cdr heads))
7805 (setq id (symbol-name refs))
7806 (while (and (setq id (gnus-build-get-header id))
7807 (not (car (gnus-gethash
7808 id gnus-newsgroup-dependencies)))))
7809 (setq heads nil)))))
7810 gnus-newsgroup-dependencies)))
7812 (defun gnus-build-get-header (id)
7813 ;; Look through the buffer of NOV lines and find the header to
7814 ;; ID. Enter this line into the dependencies hash table, and return
7815 ;; the id of the parent article (if any).
7816 (let ((deps gnus-newsgroup-dependencies)
7820 (set-buffer nntp-server-buffer)
7821 (goto-char (point-min))
7822 (while (and (not found) (search-forward id nil t))
7824 (setq found (looking-at
7825 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
7826 (regexp-quote id))))
7827 (or found (beginning-of-line 2)))
7832 (setq header (gnus-nov-parse-line
7833 (read (current-buffer)) deps))
7834 (gnus-parent-id (mail-header-references header))))))
7836 (let ((number (mail-header-number header)))
7837 (push number gnus-newsgroup-limit)
7838 (push header gnus-newsgroup-headers)
7839 (if (memq number gnus-newsgroup-unselected)
7841 (push number gnus-newsgroup-unreads)
7842 (setq gnus-newsgroup-unselected
7843 (delq number gnus-newsgroup-unselected)))
7844 (push number gnus-newsgroup-ancient)))))))
7846 (defun gnus-summary-update-article (article &optional header)
7847 "Update ARTICLE in the summary buffer."
7848 (let ((id (mail-header-id (gnus-summary-article-header article)))
7849 (data (gnus-data-find article)))
7850 (setcar (gnus-id-to-thread id) nil)
7851 (gnus-summary-insert-subject id)
7852 ;; Set the (possibly) new article number in the data structure.
7853 (gnus-data-set-number data (gnus-id-to-article id))))
7855 (defun gnus-rebuild-thread (id)
7856 "Rebuild the thread containing ID."
7857 (let ((dep gnus-newsgroup-dependencies)
7858 (buffer-read-only nil)
7859 current headers refs thread art data)
7860 (if (not gnus-show-threads)
7861 (setq thread (list (car (gnus-id-to-thread id))))
7862 ;; Get the thread this article is part of.
7863 (setq thread (gnus-remove-thread id)))
7864 (setq current (save-excursion
7865 (and (zerop (forward-line -1))
7866 (gnus-summary-article-number))))
7867 ;; If this is a gathered thread, we have to go some re-gathering.
7868 (when (stringp (car thread))
7869 (let ((subject (car thread))
7871 (setq thread (cdr thread))
7873 (unless (memq (setq thr (gnus-id-to-thread
7875 (mail-header-id (caar thread)))))
7878 (setq thread (cdr thread)))
7879 ;; We now have all (unique) roots.
7880 (if (= (length roots) 1)
7881 ;; All the loose roots are now one solid root.
7882 (setq thread (car roots))
7883 (setq thread (cons subject (gnus-sort-threads roots))))))
7886 ;; We then insert this thread into the summary buffer.
7887 (let (gnus-newsgroup-data gnus-newsgroup-threads)
7888 (gnus-summary-prepare-threads (list thread))
7889 (setq data (nreverse gnus-newsgroup-data))
7890 (setq threads gnus-newsgroup-threads))
7891 ;; We splice the new data into the data structure.
7892 (gnus-data-enter-list current data)
7893 (gnus-data-compute-positions)
7894 (setq gnus-newsgroup-threads (nconc threads gnus-newsgroup-threads)))))
7896 (defun gnus-id-to-thread (id)
7897 "Return the (sub-)thread where ID appears."
7898 (gnus-gethash (downcase id) gnus-newsgroup-dependencies))
7900 (defun gnus-id-to-article (id)
7901 "Return the article number of ID."
7902 (let ((thread (gnus-id-to-thread id)))
7904 (mail-header-number (car thread)))))
7906 (defun gnus-id-to-header (id)
7907 "Return the article headers of ID."
7908 (car (gnus-id-to-thread id)))
7910 (defun gnus-article-displayed-root-p (article)
7911 "Say whether ARTICLE is a root(ish) article."
7912 (let ((level (gnus-summary-thread-level article))
7918 (null (setq particle (gnus-id-to-article
7920 (mail-header-references
7921 (gnus-summary-article-header article))))))
7922 (null (gnus-summary-thread-level particle)))))))
7924 (defun gnus-root-id (id)
7925 "Return the id of the root of the thread where ID appears."
7927 (while (and id (setq prev (car (gnus-gethash
7929 gnus-newsgroup-dependencies))))
7931 id (gnus-parent-id (mail-header-references prev))))
7934 (defun gnus-remove-thread (id &optional dont-remove)
7935 "Remove the thread that has ID in it."
7936 (let ((dep gnus-newsgroup-dependencies)
7937 headers thread prev last-id)
7938 ;; First go up in this thread until we find the root.
7939 (setq last-id (gnus-root-id id))
7940 (setq headers (list (car (gnus-id-to-thread last-id))
7941 (caadr (gnus-id-to-thread last-id))))
7942 ;; We have now found the real root of this thread. It might have
7943 ;; been gathered into some loose thread, so we have to search
7944 ;; through the threads to find the thread we wanted.
7945 (let ((threads gnus-newsgroup-threads)
7948 (setq sub (car threads))
7949 (if (stringp (car sub))
7950 ;; This is a gathered threads, so we look at the roots
7951 ;; below it to find whether this article in in this
7954 (setq sub (cdr sub))
7956 (when (member (caar sub) headers)
7957 (setq thread (car threads)
7960 (setq sub (cdr sub))))
7961 ;; It's an ordinary thread, so we check it.
7962 (when (eq (car sub) (car headers))
7965 (setq threads (cdr threads)))
7966 ;; If this article is in no thread, then it's a root.
7969 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
7970 (setq thread (gnus-gethash (downcase last-id) dep)))
7973 thread ; We return this thread.
7975 (if (stringp (car thread))
7977 ;; If we use dummy roots, then we have to remove the
7978 ;; dummy root as well.
7979 (when (eq gnus-summary-make-false-root 'dummy)
7982 (setq thread (cdr thread))
7984 (gnus-remove-thread-1 (car thread))
7985 (setq thread (cdr thread))))
7986 (gnus-remove-thread-1 thread))))))))
7988 (defun gnus-remove-thread-1 (thread)
7989 "Remove the thread THREAD recursively."
7990 (let ((number (mail-header-number (car thread)))
7992 (when (setq pos (text-property-any
7993 (point-min) (point-max) 'gnus-number number))
7996 (gnus-data-remove number))
7997 (setq thread (cdr thread))
7999 (gnus-remove-thread-1 (car thread))
8000 (setq thread (cdr thread)))))
8002 (defun gnus-sort-threads (threads)
8004 (if (not gnus-thread-sort-functions)
8006 (let ((func (if (= 1 (length gnus-thread-sort-functions))
8007 (car gnus-thread-sort-functions)
8009 ,(gnus-make-sort-function
8010 (reverse gnus-thread-sort-functions))))))
8011 (gnus-message 7 "Sorting threads...")
8014 (gnus-message 7 "Sorting threads...done")))))
8016 (defun gnus-sort-articles (articles)
8018 (when gnus-article-sort-functions
8019 (let ((func (if (= 1 (length gnus-article-sort-functions))
8020 (car gnus-article-sort-functions)
8022 ,(gnus-make-sort-function
8023 (reverse gnus-article-sort-functions))))))
8024 (gnus-message 7 "Sorting articles...")
8026 (setq gnus-newsgroup-headers (sort articles func))
8027 (gnus-message 7 "Sorting articles...done")))))
8029 (defun gnus-make-sort-function (funs)
8030 "Return a composite sort condition based on the functions in FUNC."
8032 `(or (,(car funs) t1 t2)
8033 (and (not (,(car funs) t2 t1))
8034 ,(gnus-make-sort-function (cdr funs))))
8035 `(,(car funs) t1 t2)))
8037 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
8038 (defmacro gnus-thread-header (thread)
8039 ;; Return header of first article in THREAD.
8040 ;; Note that THREAD must never, ever be anything else than a variable -
8041 ;; using some other form will lead to serious barfage.
8042 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
8043 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
8044 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
8047 (defsubst gnus-article-sort-by-number (h1 h2)
8048 "Sort articles by article number."
8049 (< (mail-header-number h1)
8050 (mail-header-number h2)))
8052 (defun gnus-thread-sort-by-number (h1 h2)
8053 "Sort threads by root article number."
8054 (gnus-article-sort-by-number
8055 (gnus-thread-header h1) (gnus-thread-header h2)))
8057 (defsubst gnus-article-sort-by-author (h1 h2)
8058 "Sort articles by root author."
8060 (let ((extract (funcall
8061 gnus-extract-address-components
8062 (mail-header-from h1))))
8063 (or (car extract) (cdr extract)))
8064 (let ((extract (funcall
8065 gnus-extract-address-components
8066 (mail-header-from h2))))
8067 (or (car extract) (cdr extract)))))
8069 (defun gnus-thread-sort-by-author (h1 h2)
8070 "Sort threads by root author."
8071 (gnus-article-sort-by-author
8072 (gnus-thread-header h1) (gnus-thread-header h2)))
8074 (defsubst gnus-article-sort-by-subject (h1 h2)
8075 "Sort articles by root subject."
8077 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
8078 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
8080 (defun gnus-thread-sort-by-subject (h1 h2)
8081 "Sort threads by root subject."
8082 (gnus-article-sort-by-subject
8083 (gnus-thread-header h1) (gnus-thread-header h2)))
8085 (defsubst gnus-article-sort-by-date (h1 h2)
8086 "Sort articles by root article date."
8088 (gnus-sortable-date (mail-header-date h1))
8089 (gnus-sortable-date (mail-header-date h2))))
8091 (defun gnus-thread-sort-by-date (h1 h2)
8092 "Sort threads by root article date."
8093 (gnus-article-sort-by-date
8094 (gnus-thread-header h1) (gnus-thread-header h2)))
8096 (defsubst gnus-article-sort-by-score (h1 h2)
8097 "Sort articles by root article score.
8098 Unscored articles will be counted as having a score of zero."
8099 (> (or (cdr (assq (mail-header-number h1)
8100 gnus-newsgroup-scored))
8101 gnus-summary-default-score 0)
8102 (or (cdr (assq (mail-header-number h2)
8103 gnus-newsgroup-scored))
8104 gnus-summary-default-score 0)))
8106 (defun gnus-thread-sort-by-score (h1 h2)
8107 "Sort threads by root article score."
8108 (gnus-article-sort-by-score
8109 (gnus-thread-header h1) (gnus-thread-header h2)))
8111 (defun gnus-thread-sort-by-total-score (h1 h2)
8112 "Sort threads by the sum of all scores in the thread.
8113 Unscored articles will be counted as having a score of zero."
8114 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
8116 (defun gnus-thread-total-score (thread)
8117 ;; This function find the total score of THREAD.
8119 (if (stringp (car thread))
8120 (apply gnus-thread-score-function 0
8121 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
8122 (gnus-thread-total-score-1 thread))
8123 (gnus-thread-total-score-1 (list thread))))
8125 (defun gnus-thread-total-score-1 (root)
8126 ;; This function find the total score of the thread below ROOT.
8127 (setq root (car root))
8128 (apply gnus-thread-score-function
8129 (or (cdr (assq (mail-header-number root) gnus-newsgroup-scored))
8130 gnus-summary-default-score 0)
8131 (mapcar 'gnus-thread-total-score
8132 (cdr (gnus-gethash (downcase (mail-header-id root))
8133 gnus-newsgroup-dependencies)))))
8135 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8136 (defvar gnus-tmp-prev-subject nil)
8137 (defvar gnus-tmp-false-parent nil)
8138 (defvar gnus-tmp-root-expunged nil)
8139 (defvar gnus-tmp-dummy-line nil)
8141 (defun gnus-summary-prepare-threads (threads)
8142 "Prepare summary buffer from THREADS and indentation LEVEL.
8143 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
8144 or a straight list of headers."
8145 (gnus-message 7 "Generating summary...")
8147 (setq gnus-newsgroup-threads threads)
8150 (let ((gnus-tmp-level 0)
8151 (default-score (or gnus-summary-default-score 0))
8152 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
8153 thread number subject stack state gnus-tmp-gathered beg-match
8154 new-roots gnus-tmp-new-adopts thread-end
8155 gnus-tmp-header gnus-tmp-unread
8156 gnus-tmp-replied gnus-tmp-subject-or-nil
8157 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
8158 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
8159 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
8161 (setq gnus-tmp-prev-subject nil)
8163 (if (vectorp (car threads))
8164 ;; If this is a straight (sic) list of headers, then a
8165 ;; threaded summary display isn't required, so we just create
8166 ;; an unthreaded one.
8167 (gnus-summary-prepare-unthreaded threads)
8169 ;; Do the threaded display.
8171 (while (or threads stack gnus-tmp-new-adopts new-roots)
8173 (if (and (= gnus-tmp-level 0)
8174 (not (setq gnus-tmp-dummy-line nil))
8177 (not gnus-tmp-false-parent)
8178 (or gnus-tmp-new-adopts new-roots))
8179 (if gnus-tmp-new-adopts
8180 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
8181 thread (list (car gnus-tmp-new-adopts))
8182 gnus-tmp-header (caar thread)
8183 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
8185 (setq thread (list (car new-roots))
8186 gnus-tmp-header (caar thread)
8187 new-roots (cdr new-roots))))
8190 ;; If there are some threads, we do them before the
8191 ;; threads on the stack.
8192 (setq thread threads
8193 gnus-tmp-header (caar thread))
8194 ;; There were no current threads, so we pop something off
8196 (setq state (car stack)
8197 gnus-tmp-level (car state)
8200 gnus-tmp-header (caar thread))))
8202 (setq gnus-tmp-false-parent nil)
8203 (setq gnus-tmp-root-expunged nil)
8204 (setq thread-end nil)
8206 (if (stringp gnus-tmp-header)
8207 ;; The header is a dummy root.
8209 ((eq gnus-summary-make-false-root 'adopt)
8210 ;; We let the first article adopt the rest.
8211 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
8213 (setq gnus-tmp-gathered
8215 (lambda (h) (mail-header-number (car h)))
8218 (setq thread (cons (list (caar thread)
8221 (setq gnus-tmp-level -1
8222 gnus-tmp-false-parent t))
8223 ((eq gnus-summary-make-false-root 'empty)
8224 ;; We print adopted articles with empty subject fields.
8225 (setq gnus-tmp-gathered
8227 (lambda (h) (mail-header-number (car h)))
8230 (setq gnus-tmp-level -1))
8231 ((eq gnus-summary-make-false-root 'dummy)
8232 ;; We remember that we probably want to output a dummy
8234 (setq gnus-tmp-dummy-line gnus-tmp-header)
8235 (setq gnus-tmp-prev-subject gnus-tmp-header))
8237 ;; We do not make a root for the gathered
8238 ;; sub-threads at all.
8239 (setq gnus-tmp-level -1)))
8241 (setq number (mail-header-number gnus-tmp-header)
8242 subject (mail-header-subject gnus-tmp-header))
8245 ;; If the thread has changed subject, we might want to make
8246 ;; this subthread into a root.
8247 ((and (null gnus-thread-ignore-subject)
8248 (not (zerop gnus-tmp-level))
8249 gnus-tmp-prev-subject
8251 (gnus-subject-equal gnus-tmp-prev-subject subject))))
8252 (setq new-roots (nconc new-roots (list (car thread)))
8254 gnus-tmp-header nil))
8255 ;; If the article lies outside the current limit,
8256 ;; then we do not display it.
8257 ((and (not (memq number gnus-newsgroup-limit))
8258 (not gnus-tmp-dummy-line))
8259 (setq gnus-tmp-gathered
8261 (lambda (h) (mail-header-number (car h)))
8264 (setq gnus-tmp-new-adopts (if (cdar thread)
8265 (append gnus-tmp-new-adopts
8267 gnus-tmp-new-adopts)
8269 gnus-tmp-header nil)
8270 (when (zerop gnus-tmp-level)
8271 (setq gnus-tmp-root-expunged t)))
8272 ;; Perhaps this article is to be marked as read?
8273 ((and gnus-summary-mark-below
8274 (< (or (cdr (assq number gnus-newsgroup-scored))
8276 gnus-summary-mark-below)
8277 ;; Don't touch sparse articles.
8278 (not (memq number gnus-newsgroup-sparse)))
8279 (setq gnus-newsgroup-unreads
8280 (delq number gnus-newsgroup-unreads))
8281 (if gnus-newsgroup-auto-expire
8282 (push number gnus-newsgroup-expirable)
8283 (push (cons number gnus-low-score-mark)
8284 gnus-newsgroup-reads))))
8286 (when gnus-tmp-header
8287 ;; We may have an old dummy line to output before this
8289 (when gnus-tmp-dummy-line
8290 (gnus-summary-insert-dummy-line
8291 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
8292 (setq gnus-tmp-dummy-line nil))
8294 ;; Compute the mark.
8298 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8299 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8300 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8301 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8302 (t (or (cdr (assq number gnus-newsgroup-reads))
8303 gnus-ancient-mark))))
8305 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
8306 gnus-tmp-header gnus-tmp-level)
8307 gnus-newsgroup-data)
8309 ;; Actually insert the line.
8311 gnus-tmp-subject-or-nil
8313 ((and gnus-thread-ignore-subject
8314 gnus-tmp-prev-subject
8315 (not (inline (gnus-subject-equal
8316 gnus-tmp-prev-subject subject))))
8318 ((zerop gnus-tmp-level)
8319 (if (and (eq gnus-summary-make-false-root 'empty)
8320 (memq number gnus-tmp-gathered)
8321 gnus-tmp-prev-subject
8322 (inline (gnus-subject-equal
8323 gnus-tmp-prev-subject subject)))
8324 gnus-summary-same-subject
8326 (t gnus-summary-same-subject)))
8327 (if (and (eq gnus-summary-make-false-root 'adopt)
8328 (= gnus-tmp-level 1)
8329 (memq number gnus-tmp-gathered))
8330 (setq gnus-tmp-opening-bracket ?\<
8331 gnus-tmp-closing-bracket ?\>)
8332 (setq gnus-tmp-opening-bracket ?\[
8333 gnus-tmp-closing-bracket ?\]))
8335 gnus-tmp-indentation
8336 (aref gnus-thread-indent-array gnus-tmp-level)
8337 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
8338 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
8339 gnus-summary-default-score 0)
8341 (if (or (null gnus-summary-default-score)
8342 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
8343 gnus-summary-zcore-fuzz)) ?
8344 (if (< gnus-tmp-score gnus-summary-default-score)
8345 gnus-score-below-mark gnus-score-over-mark))
8347 (cond ((memq number gnus-newsgroup-processable)
8349 ((memq number gnus-newsgroup-cached)
8351 ((memq number gnus-newsgroup-replied)
8353 (t gnus-unread-mark))
8354 gnus-tmp-from (mail-header-from gnus-tmp-header)
8357 ((string-match "(.+)" gnus-tmp-from)
8358 (substring gnus-tmp-from
8359 (1+ (match-beginning 0)) (1- (match-end 0))))
8360 ((string-match "<[^>]+> *$" gnus-tmp-from)
8361 (setq beg-match (match-beginning 0))
8362 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
8363 (substring gnus-tmp-from (1+ (match-beginning 0))
8364 (1- (match-end 0))))
8365 (substring gnus-tmp-from 0 beg-match)))
8367 (when (string= gnus-tmp-name "")
8368 (setq gnus-tmp-name gnus-tmp-from))
8369 (or (numberp gnus-tmp-lines) (setq gnus-tmp-lines 0))
8372 (progn (eval gnus-summary-line-format-spec) (point))
8373 'gnus-number number)
8376 (run-hooks 'gnus-summary-update-hook)
8379 (setq gnus-tmp-prev-subject subject)))
8381 (when (nth 1 thread)
8382 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
8383 (incf gnus-tmp-level)
8384 (setq threads (if thread-end nil (cdar thread)))
8386 (setq gnus-tmp-level 0)))))
8387 (gnus-message 7 "Generating summary...done"))
8389 (defun gnus-summary-prepare-unthreaded (headers)
8390 "Generate an unthreaded summary buffer based on HEADERS."
8391 (let (header number mark)
8394 (setq header (car headers)
8395 headers (cdr headers)
8396 number (mail-header-number header))
8398 ;; We may have to root out some bad articles...
8399 (when (memq number gnus-newsgroup-limit)
8400 (when (and gnus-summary-mark-below
8401 (< (or (cdr (assq number gnus-newsgroup-scored))
8402 gnus-summary-default-score 0)
8403 gnus-summary-mark-below))
8404 (setq gnus-newsgroup-unreads
8405 (delq number gnus-newsgroup-unreads))
8406 (if gnus-newsgroup-auto-expire
8407 (push number gnus-newsgroup-expirable)
8408 (push (cons number gnus-low-score-mark)
8409 gnus-newsgroup-reads)))
8413 ((memq number gnus-newsgroup-marked) gnus-ticked-mark)
8414 ((memq number gnus-newsgroup-dormant) gnus-dormant-mark)
8415 ((memq number gnus-newsgroup-unreads) gnus-unread-mark)
8416 ((memq number gnus-newsgroup-expirable) gnus-expirable-mark)
8417 (t (or (cdr (assq number gnus-newsgroup-reads))
8418 gnus-ancient-mark))))
8419 (setq gnus-newsgroup-data
8420 (cons (gnus-data-make number mark (1+ (point)) header 0)
8421 gnus-newsgroup-data))
8422 (gnus-summary-insert-line
8423 header 0 nil mark (memq number gnus-newsgroup-replied)
8424 (memq number gnus-newsgroup-expirable)
8425 (mail-header-subject header) nil
8426 (cdr (assq number gnus-newsgroup-scored))
8427 (memq number gnus-newsgroup-processable))))))
8429 (defun gnus-select-newsgroup (group &optional read-all)
8430 "Select newsgroup GROUP.
8431 If READ-ALL is non-nil, all articles in the group are selected."
8432 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
8433 (info (nth 2 entry))
8434 articles fetched-articles cached)
8436 (or (gnus-check-server
8437 (setq gnus-current-select-method (gnus-find-method-for-group group)))
8438 (error "Couldn't open server"))
8440 (or (and entry (not (eq (car entry) t))) ; Either it's active...
8441 (gnus-activate-group group) ; Or we can activate it...
8442 (progn ; Or we bug out.
8443 (when (equal major-mode 'gnus-summary-mode)
8444 (kill-buffer (current-buffer)))
8445 (error "Couldn't request group %s: %s"
8446 group (gnus-status-message group))))
8448 (setq gnus-newsgroup-name group)
8449 (setq gnus-newsgroup-unselected nil)
8450 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
8452 (and gnus-asynchronous
8453 (gnus-check-backend-function
8454 'request-asynchronous gnus-newsgroup-name)
8455 (setq gnus-newsgroup-async
8456 (gnus-request-asynchronous gnus-newsgroup-name)))
8458 ;; Adjust and set lists of article marks.
8460 (gnus-adjust-marked-articles info))
8462 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8463 (when (gnus-virtual-group-p group)
8464 (setq cached gnus-newsgroup-cached))
8466 (setq gnus-newsgroup-unreads
8467 (gnus-set-difference
8468 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
8469 gnus-newsgroup-dormant))
8471 (setq gnus-newsgroup-processable nil)
8473 (setq articles (gnus-articles-to-read group read-all))
8477 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
8479 ((eq articles 0) nil)
8481 ;; Init the dependencies hash table.
8482 (setq gnus-newsgroup-dependencies
8483 (gnus-make-hashtable (length articles)))
8484 ;; Retrieve the headers and read them in.
8485 (gnus-message 5 "Fetching headers...")
8486 (setq gnus-newsgroup-headers
8488 (setq gnus-headers-retrieved-by
8489 (gnus-retrieve-headers
8490 articles gnus-newsgroup-name
8491 ;; We might want to fetch old headers, but
8492 ;; not if there is only 1 article.
8493 (and gnus-fetch-old-headers
8495 (not (eq gnus-fetch-old-headers 'some))
8496 (not (numberp gnus-fetch-old-headers)))
8497 (> (length articles) 1))))))
8498 (gnus-get-newsgroup-headers-xover articles)
8499 (gnus-get-newsgroup-headers)))
8500 (gnus-message 5 "Fetching headers...done")
8502 ;; Kludge to avoid having cached articles nixed out in virtual groups.
8504 (setq gnus-newsgroup-cached cached))
8506 ;; Set the initial limit.
8507 (setq gnus-newsgroup-limit (copy-sequence articles))
8508 ;; Remove canceled articles from the list of unread articles.
8509 (setq gnus-newsgroup-unreads
8510 (gnus-set-sorted-intersection
8511 gnus-newsgroup-unreads
8512 (setq fetched-articles
8513 (mapcar (lambda (headers) (mail-header-number headers))
8514 gnus-newsgroup-headers))))
8515 ;; Removed marked articles that do not exist.
8516 (gnus-update-missing-marks
8517 (gnus-sorted-complement fetched-articles articles))
8518 ;; We might want to build some more threads first.
8519 (and gnus-fetch-old-headers
8520 (eq gnus-headers-retrieved-by 'nov)
8521 (gnus-build-old-threads))
8522 ;; Check whether auto-expire is to be done in this group.
8523 (setq gnus-newsgroup-auto-expire
8524 (gnus-group-auto-expirable-p group))
8525 ;; First and last article in this newsgroup.
8526 (and gnus-newsgroup-headers
8527 (setq gnus-newsgroup-begin
8528 (mail-header-number (car gnus-newsgroup-headers)))
8529 (setq gnus-newsgroup-end
8531 (gnus-last-element gnus-newsgroup-headers))))
8532 (setq gnus-reffed-article-number -1)
8533 ;; GROUP is successfully selected.
8534 (or gnus-newsgroup-headers t)))))
8536 (defun gnus-articles-to-read (group read-all)
8537 ;; Find out what articles the user wants to read.
8539 ;; Select all articles if `read-all' is non-nil, or if there
8540 ;; are no unread articles.
8542 (and (zerop (length gnus-newsgroup-marked))
8543 (zerop (length gnus-newsgroup-unreads))))
8544 (gnus-uncompress-range (gnus-active group))
8545 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
8546 (copy-sequence gnus-newsgroup-unreads))
8548 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
8549 (scored (length scored-list))
8550 (number (length articles))
8551 (marked (+ (length gnus-newsgroup-marked)
8552 (length gnus-newsgroup-dormant)))
8560 ((and (or (<= scored marked) (= scored number))
8561 (numberp gnus-large-newsgroup)
8562 (> number gnus-large-newsgroup))
8566 "How many articles from %s (default %d): "
8567 gnus-newsgroup-name number))))
8568 (if (string-match "^[ \t]*$" input) number input)))
8569 ((and (> scored marked) (< scored number))
8572 (format "%s %s (%d scored, %d total): "
8573 "How many articles from"
8574 group scored number))))
8575 (if (string-match "^[ \t]*$" input)
8579 (setq select (if (stringp select) (string-to-number select) select))
8580 (if (or (null select) (zerop select))
8582 (if (and (not (zerop scored)) (<= (abs select) scored))
8584 (setq articles (sort scored-list '<))
8585 (setq number (length articles)))
8586 (setq articles (copy-sequence articles)))
8588 (if (< (abs select) number)
8590 ;; Select the N oldest articles.
8591 (setcdr (nthcdr (1- (abs select)) articles) nil)
8592 ;; Select the N most recent articles.
8593 (setq articles (nthcdr (- number select) articles))))
8594 (setq gnus-newsgroup-unselected
8595 (gnus-sorted-intersection
8596 gnus-newsgroup-unreads
8597 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
8600 (defun gnus-killed-articles (killed articles)
8603 (if (inline (gnus-member-of-range (car articles) killed))
8604 (setq out (cons (car articles) out)))
8605 (setq articles (cdr articles)))
8608 (defun gnus-uncompress-marks (marks)
8609 "Uncompress the mark ranges in MARKS."
8610 (let ((uncompressed '(score bookmark))
8613 (if (memq (caar marks) uncompressed)
8614 (push (car marks) out)
8615 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
8616 (setq marks (cdr marks)))
8619 (defun gnus-adjust-marked-articles (info)
8620 "Set all article lists and remove all marks that are no longer legal."
8621 (let* ((marked-lists (gnus-info-marks info))
8622 (active (gnus-active (gnus-info-group info)))
8625 (types gnus-article-mark-lists)
8626 (uncompressed '(score bookmark))
8627 marks var articles article mark)
8630 (setq marks (pop marked-lists))
8631 (set (setq var (intern (format "gnus-newsgroup-%s"
8632 (car (rassq (setq mark (car marks))
8634 (if (memq (car marks) uncompressed) (cdr marks)
8635 (gnus-uncompress-range (cdr marks))))
8637 (setq articles (symbol-value var))
8639 ;; All articles have to be subsets of the active articles.
8641 ;; Adjust "simple" lists.
8642 ((memq mark '(tick dormant expirable reply killed save))
8644 (when (or (< (setq article (pop articles)) min) (> article max))
8645 (set var (delq article (symbol-value var))))))
8647 ((memq mark '(score bookmark))
8649 (when (or (< (car (setq article (pop articles))) min)
8650 (> (car article) max))
8651 (set var (delq article (symbol-value var))))))))))
8653 (defun gnus-update-missing-marks (missing)
8654 "Go through the list of MISSING articles and remove them mark lists."
8656 (let ((types gnus-article-mark-lists)
8658 ;; Go through all types.
8660 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
8661 (when (symbol-value var)
8662 ;; This list has articles. So we delete all missing articles
8666 (set var (delq (pop m) (symbol-value var)))))))))
8668 (defun gnus-update-marks ()
8669 "Enter the various lists of marked articles into the newsgroup info list."
8670 (let ((types gnus-article-mark-lists)
8671 (info (gnus-get-info gnus-newsgroup-name))
8672 (uncompressed '(score bookmark killed))
8673 var type list newmarked symbol)
8675 ;; Add all marks lists that are non-nil to the list of marks lists.
8677 (setq type (pop types))
8678 (when (setq list (symbol-value
8680 (intern (format "gnus-newsgroup-%s"
8682 (push (cons (cdr type)
8683 (if (memq (cdr type) uncompressed) list
8684 (gnus-compress-sequence (set symbol (sort list '<)) t)))
8687 ;; Enter these new marks into the info of the group.
8689 (setcar (nthcdr 3 info) newmarked)
8690 ;; Add the marks lists to the end of the info.
8692 (setcdr (nthcdr 2 info) (list newmarked))))
8694 ;; Cut off the end of the info if there's nothing else there.
8698 (when (nthcdr (decf i) info)
8699 (setcdr (nthcdr i info) nil)))))))
8701 (defun gnus-add-marked-articles (group type articles &optional info force)
8702 ;; Add ARTICLES of TYPE to the info of GROUP.
8703 ;; If INFO is non-nil, use that info. If FORCE is non-nil, don't
8704 ;; add, but replace marked articles of TYPE with ARTICLES.
8705 (let ((info (or info (gnus-get-info group)))
8706 (uncompressed '(score bookmark killed))
8709 (and (not (setq marked (nthcdr 3 info)))
8711 (setcdr (nthcdr 2 info)
8712 (list (list (cons type (gnus-compress-sequence
8714 (and (not (setq m (assq type (car marked))))
8717 (cons (cons type (gnus-compress-sequence articles t) )
8721 (setcar (nthcdr 3 info)
8722 (delq (assq type (car marked)) (car marked)))
8723 (setcdr m (gnus-compress-sequence articles t)))
8724 (setcdr m (gnus-compress-sequence
8725 (sort (nconc (gnus-uncompress-range m)
8726 (copy-sequence articles)) '<) t))))))
8728 (defun gnus-set-mode-line (where)
8729 "This function sets the mode line of the article or summary buffers.
8730 If WHERE is `summary', the summary mode line format will be used."
8731 ;; Is this mode line one we keep updated?
8732 (when (memq where gnus-updated-mode-lines)
8735 ;; We evaluate this in the summary buffer since these
8736 ;; variables are buffer-local to that buffer.
8737 (set-buffer gnus-summary-buffer)
8738 ;; We bind all these variables that are used in the `eval' form
8740 (let* ((mformat (symbol-value
8742 (format "gnus-%s-mode-line-format-spec" where))))
8743 (gnus-tmp-group-name gnus-newsgroup-name)
8744 (gnus-tmp-article-number (or gnus-current-article 0))
8745 (gnus-tmp-unread gnus-newsgroup-unreads)
8746 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
8747 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
8748 (gnus-tmp-unread-and-unselected
8749 (cond ((and (zerop gnus-tmp-unread-and-unticked)
8750 (zerop gnus-tmp-unselected)) "")
8751 ((zerop gnus-tmp-unselected)
8752 (format "{%d more}" gnus-tmp-unread-and-unticked))
8753 (t (format "{%d(+%d) more}"
8754 gnus-tmp-unread-and-unticked
8755 gnus-tmp-unselected))))
8757 (if (and gnus-current-headers
8758 (vectorp gnus-current-headers))
8759 (mail-header-subject gnus-current-headers) ""))
8761 gnus-tmp-header);; passed as argument to any user-format-funcs
8762 (setq mode-string (eval mformat))
8763 (setq max-len (max 4 (if gnus-mode-non-string-length
8765 gnus-mode-non-string-length)
8766 (length mode-string))))
8767 ;; We might have to chop a bit of the string off...
8768 (when (> (length mode-string) max-len)
8770 (concat (gnus-truncate-string mode-string (- max-len 3))
8772 ;; Pad the mode string a bit.
8773 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
8774 ;; Update the mode line.
8775 (setq mode-line-buffer-identification (list mode-string))
8776 (set-buffer-modified-p t))))
8778 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
8779 "Go through the HEADERS list and add all Xrefs to a hash table.
8780 The resulting hash table is returned, or nil if no Xrefs were found."
8781 (let* ((from-method (gnus-find-method-for-group from-newsgroup))
8782 (virtual (gnus-virtual-group-p from-newsgroup))
8783 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
8784 (xref-hashtb (make-vector 63 0))
8785 start group entry number xrefs header)
8787 (setq header (pop headers))
8788 (when (and (setq xrefs (mail-header-xref header))
8789 (not (memq (setq number (mail-header-number header))
8792 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
8793 (setq start (match-end 0))
8794 (setq group (concat prefix (substring xrefs (match-beginning 1)
8797 (string-to-int (substring xrefs (match-beginning 2)
8799 (if (setq entry (gnus-gethash group xref-hashtb))
8800 (setcdr entry (cons number (cdr entry)))
8801 (gnus-sethash group (cons number nil) xref-hashtb)))))
8802 (and start xref-hashtb)))
8804 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
8805 "Look through all the headers and mark the Xrefs as read."
8806 (let ((virtual (gnus-virtual-group-p from-newsgroup))
8807 name entry info xref-hashtb idlist method nth4)
8809 (set-buffer gnus-group-buffer)
8810 (when (setq xref-hashtb
8811 (gnus-create-xref-hashtb from-newsgroup headers unreads))
8814 (unless (string= from-newsgroup (setq name (symbol-name group)))
8815 (setq idlist (symbol-value group))
8816 ;; Dead groups are not updated.
8818 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
8820 (if (stringp (setq nth4 (gnus-info-method info)))
8821 (setq nth4 (gnus-server-to-method nth4))))
8822 ;; Only do the xrefs if the group has the same
8823 ;; select method as the group we have just read.
8824 (or (gnus-methods-equal-p
8825 nth4 (gnus-find-method-for-group from-newsgroup))
8827 (equal nth4 (setq method (gnus-find-method-for-group
8829 (and (equal (car nth4) (car method))
8830 (equal (nth 1 nth4) (nth 1 method))))
8831 gnus-use-cross-reference
8832 (or (not (eq gnus-use-cross-reference t))
8834 ;; Only do cross-references on subscribed
8835 ;; groups, if that is what is wanted.
8836 (<= (gnus-info-level info) gnus-level-subscribed))
8837 (gnus-group-make-articles-read name idlist))))
8840 (defun gnus-group-make-articles-read (group articles)
8842 (entry (gnus-gethash group gnus-newsrc-hashtb))
8843 (info (nth 2 entry))
8844 (active (gnus-active group))
8846 ;; First peel off all illegal article numbers.
8848 (let ((ids articles)
8852 (if (and first (> id (cdr active)))
8854 ;; We'll end up in this situation in one particular
8855 ;; obscure situation. If you re-scan a group and get
8856 ;; a new article that is cross-posted to a different
8857 ;; group that has not been re-scanned, you might get
8858 ;; crossposted article that has a higher number than
8859 ;; Gnus believes possible. So we re-activate this
8860 ;; group as well. This might mean doing the
8861 ;; crossposting thingy will *increase* the number
8862 ;; of articles in some groups. Tsk, tsk.
8863 (setq active (or (gnus-activate-group group) active))))
8864 (if (or (> id (cdr active))
8865 (< id (car active)))
8866 (setq articles (delq id articles)))
8867 (setq ids (cdr ids)))))
8868 ;; If the read list is nil, we init it.
8870 (null (gnus-info-read info))
8872 (gnus-info-set-read info (cons 1 (1- (car active)))))
8873 ;; Then we add the read articles to the range.
8878 (gnus-info-read info) (setq articles (sort articles '<)))))
8879 ;; Then we have to re-compute how many unread
8880 ;; articles there are in this group.
8885 (setq num (- (1+ (cdr active)) (car active))))
8886 ((not (listp (cdr range)))
8887 (setq num (- (cdr active) (- (1+ (cdr range))
8891 (if (numberp (car range))
8893 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
8894 (setq range (cdr range)))
8895 (setq num (- (cdr active) num))))
8896 ;; Update the number of unread articles.
8898 ;; Update the group buffer.
8899 (gnus-group-update-group group t)))))
8901 (defun gnus-methods-equal-p (m1 m2)
8902 (let ((m1 (or m1 gnus-select-method))
8903 (m2 (or m2 gnus-select-method)))
8905 (and (eq (car m1) (car m2))
8906 (or (not (memq 'address (assoc (symbol-name (car m1))
8907 gnus-valid-select-methods)))
8908 (equal (nth 1 m1) (nth 1 m2)))))))
8910 (defsubst gnus-header-value ()
8911 (buffer-substring (match-end 0) (gnus-point-at-eol)))
8913 (defvar gnus-newsgroup-none-id 0)
8915 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
8916 (let ((cur nntp-server-buffer)
8919 (save-excursion (set-buffer gnus-summary-buffer)
8920 gnus-newsgroup-dependencies)))
8921 headers id id-dep ref-dep end ref)
8923 (set-buffer nntp-server-buffer)
8924 (let ((case-fold-search t)
8925 in-reply-to header number p lines)
8926 (goto-char (point-min))
8927 ;; Search to the beginning of the next header. Error messages
8928 ;; do not begin with 2 or 3.
8929 (while (re-search-forward "^[23][0-9]+ " nil t)
8932 ;; This implementation of this function, with nine
8933 ;; search-forwards instead of the one re-search-forward and
8934 ;; a case (which basically was the old function) is actually
8935 ;; about twice as fast, even though it looks messier. You
8936 ;; can't have everything, I guess. Speed and elegance
8937 ;; doesn't always go hand in hand.
8946 (narrow-to-region (point)
8947 (or (and (search-forward "\n.\n" nil t)
8953 (if (search-forward "\nsubject: " nil t)
8954 (gnus-header-value) "(none)"))
8958 (if (search-forward "\nfrom: " nil t)
8959 (gnus-header-value) "(nobody)"))
8963 (if (search-forward "\ndate: " nil t)
8964 (gnus-header-value) ""))
8968 (if (search-forward "\nmessage-id: " nil t)
8969 (setq id (gnus-header-value))
8970 ;; If there was no message-id, we just fake one to make
8971 ;; subsequent routines simpler.
8972 (setq id (concat "none+"
8974 (setq gnus-newsgroup-none-id
8975 (1+ gnus-newsgroup-none-id)))))))
8979 (if (search-forward "\nreferences: " nil t)
8982 (setq end (match-end 0))
8989 (search-backward ">" end t)
8992 (search-backward "<" end t)
8994 ;; Get the references from the in-reply-to header if there
8995 ;; were no references and the in-reply-to header looks
8997 (if (and (search-forward "\nin-reply-to: " nil t)
8998 (setq in-reply-to (gnus-header-value))
8999 (string-match "<[^>]+>" in-reply-to))
9001 (setq ref (substring in-reply-to (match-beginning 0)
9003 (setq ref (downcase ref))))
9010 (if (search-forward "\nlines: " nil t)
9011 (if (numberp (setq lines (read cur)))
9017 (and (search-forward "\nxref: " nil t)
9018 (gnus-header-value)))))
9019 ;; We do the threading while we read the headers. The
9020 ;; message-id and the last reference are both entered into
9021 ;; the same hash table. Some tippy-toeing around has to be
9022 ;; done in case an article has arrived before the article
9023 ;; which it refers to.
9024 (if (boundp (setq id-dep (intern (downcase id) dependencies)))
9025 (if (and (car (symbol-value id-dep))
9027 ;; An article with this Message-ID has already
9028 ;; been seen, so we ignore this one, except we add
9029 ;; any additional Xrefs (in case the two articles
9030 ;; came from different servers).
9032 (mail-header-set-xref
9033 (car (symbol-value id-dep))
9034 (concat (or (mail-header-xref
9035 (car (symbol-value id-dep))) "")
9036 (or (mail-header-xref header) "")))
9038 (setcar (symbol-value id-dep) header))
9039 (set id-dep (list header)))
9041 (if (boundp (setq ref-dep (intern ref dependencies)))
9042 (setcdr (symbol-value ref-dep)
9043 (nconc (cdr (symbol-value ref-dep))
9044 (list (symbol-value id-dep))))
9045 (set ref-dep (list nil (symbol-value id-dep))))
9046 (setq headers (cons header headers)))
9047 (goto-char (point-max))
9049 (nreverse headers)))))
9051 ;; The following macros and functions were written by Felix Lee
9052 ;; <flee@cse.psu.edu>.
9054 (defmacro gnus-nov-read-integer ()
9056 (if (= (following-char) ?\t)
9058 (let ((num (condition-case nil (read buffer) (error nil))))
9059 (if (numberp num) num 0)))
9060 (or (eobp) (forward-char 1))))
9062 (defmacro gnus-nov-skip-field ()
9063 '(search-forward "\t" eol 'move))
9065 (defmacro gnus-nov-field ()
9066 '(buffer-substring (point) (if (gnus-nov-skip-field) (1- (point)) eol)))
9068 ;; Goes through the xover lines and returns a list of vectors
9069 (defun gnus-get-newsgroup-headers-xover (sequence &optional force-new)
9070 "Parse the news overview data in the server buffer, and return a
9071 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
9072 ;; Get the Xref when the users reads the articles since most/some
9073 ;; NNTP servers do not include Xrefs when using XOVER.
9074 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
9075 (let ((cur nntp-server-buffer)
9076 (dependencies gnus-newsgroup-dependencies)
9077 number headers header)
9079 (set-buffer nntp-server-buffer)
9080 ;; Allow the user to mangle the headers before parsing them.
9081 (run-hooks 'gnus-parse-headers-hook)
9082 ;; Allow the user to mangle the headers before parsing them.
9083 (run-hooks 'gnus-parse-headers-hook)
9084 (goto-char (point-min))
9085 (while (and sequence (not (eobp)))
9086 (setq number (read cur))
9087 (while (and sequence (< (car sequence) number))
9088 (setq sequence (cdr sequence)))
9090 (eq number (car sequence))
9092 (setq sequence (cdr sequence))
9094 (inline (gnus-nov-parse-line
9095 number dependencies force-new)))
9096 (setq headers (cons header headers)))))
9098 (setq headers (nreverse headers)))
9101 ;; This function has to be called with point after the article number
9102 ;; on the beginning of the line.
9103 (defun gnus-nov-parse-line (number dependencies &optional force-new)
9105 (eol (gnus-point-at-eol))
9106 (buffer (current-buffer))
9107 header ref id id-dep ref-dep)
9109 ;; overview: [num subject from date id refs chars lines misc]
9110 (narrow-to-region (point) eol)
9111 (or (eobp) (forward-char))
9117 (gnus-nov-field) ; subject
9118 (gnus-nov-field) ; from
9119 (gnus-nov-field) ; date
9120 (setq id (or (gnus-nov-field)
9123 (setq none (1+ none)))))) ; id
9126 (let ((beg (point)))
9127 (search-forward "\t" eol)
9128 (if (search-backward ">" beg t)
9134 (search-backward "<" beg t)
9137 (gnus-nov-field)) ; refs
9138 (gnus-nov-read-integer) ; chars
9139 (gnus-nov-read-integer) ; lines
9140 (if (= (following-char) ?\n)
9142 (gnus-nov-field)) ; misc
9146 (gnus-message 4 "Strange nov line")
9152 ;; We build the thread tree.
9154 (if (boundp (setq id-dep (intern (downcase id) dependencies)))
9155 (if (and (car (symbol-value id-dep))
9157 ;; An article with this Message-ID has already been seen,
9158 ;; so we ignore this one, except we add any additional
9159 ;; Xrefs (in case the two articles came from different
9162 (mail-header-set-xref
9163 (car (symbol-value id-dep))
9164 (concat (or (mail-header-xref
9165 (car (symbol-value id-dep))) "")
9166 (or (mail-header-xref header) "")))
9168 (setcar (symbol-value id-dep) header))
9169 (set id-dep (list header))))
9172 (if (boundp (setq ref-dep (intern (or ref "none") dependencies)))
9173 (setcdr (symbol-value ref-dep)
9174 (nconc (cdr (symbol-value ref-dep))
9175 (list (symbol-value id-dep))))
9176 (set ref-dep (list nil (symbol-value id-dep))))))
9179 (defun gnus-article-get-xrefs ()
9180 "Fill in the Xref value in `gnus-current-headers', if necessary.
9181 This is meant to be called in `gnus-article-internal-prepare-hook'."
9182 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
9183 gnus-current-headers)))
9184 (or (not gnus-use-cross-reference)
9186 (and (mail-header-xref headers)
9187 (not (string= (mail-header-xref headers) "")))
9188 (let ((case-fold-search t)
9191 (nnheader-narrow-to-headers)
9192 (goto-char (point-min))
9193 (if (or (and (eq (downcase (following-char)) ?x)
9194 (looking-at "Xref:"))
9195 (search-forward "\nXref:" nil t))
9197 (goto-char (1+ (match-end 0)))
9198 (setq xref (buffer-substring (point)
9199 (progn (end-of-line) (point))))
9200 (mail-header-set-xref headers xref))))))))
9202 (defun gnus-summary-insert-subject (id)
9203 "Find article ID and insert the summary line for that article."
9204 (let ((header (gnus-read-header id))
9205 (number (and (numberp id) id)))
9207 ;; Rebuild the thread that this article is part of and go to the
9208 ;; article we have fetched.
9209 (gnus-rebuild-thread (mail-header-id header))
9210 (gnus-summary-goto-subject (setq number (mail-header-number header))))
9211 (when (and (numberp number)
9213 ;; We have to update the boundaries even if we can't fetch the
9214 ;; article if ID is a number -- so that the next `P' or `N'
9215 ;; command will fetch the previous (or next) article even
9216 ;; if the one we tried to fetch this time has been canceled.
9217 (and (> number gnus-newsgroup-end)
9218 (setq gnus-newsgroup-end number))
9219 (and (< number gnus-newsgroup-begin)
9220 (setq gnus-newsgroup-begin number))
9221 (setq gnus-newsgroup-unselected
9222 (delq number gnus-newsgroup-unselected)))
9223 ;; Report back a success?
9224 (and header number)))
9226 (defun gnus-summary-work-articles (n)
9227 "Return a list of articles to be worked upon. The prefix argument,
9228 the list of process marked articles, and the current article will be
9229 taken into consideration."
9231 ((and n (numberp n))
9232 ;; A numerical prefix has been given.
9233 (let ((backward (< n 0))
9239 (push (setq article (gnus-summary-article-number))
9242 (gnus-summary-find-prev nil article)
9243 (gnus-summary-find-next nil article)))
9245 (nreverse articles)))
9246 ((and (boundp 'transient-mark-mode)
9249 ;; Work on the region between point and mark.
9250 (let ((max (max (point) (mark)))
9253 (goto-char (min (point) (mark)))
9256 (push (setq article (gnus-summary-article-number)) articles)
9257 (gnus-summary-find-next nil article)
9259 (nreverse articles))))
9260 (gnus-newsgroup-processable
9261 ;; There are process-marked articles present.
9262 (reverse gnus-newsgroup-processable))
9264 ;; Just return the current article.
9265 (list (gnus-summary-article-number)))))
9267 (defun gnus-summary-search-group (&optional backward use-level)
9268 "Search for next unread newsgroup.
9269 If optional argument BACKWARD is non-nil, search backward instead."
9271 (set-buffer gnus-group-buffer)
9272 (if (gnus-group-search-forward
9273 backward nil (if use-level (gnus-group-group-level) nil))
9274 (gnus-group-group-name))))
9276 (defun gnus-summary-best-group (&optional exclude-group)
9277 "Find the name of the best unread group.
9278 If EXCLUDE-GROUP, do not go to this group."
9280 (set-buffer gnus-group-buffer)
9282 (gnus-group-best-unread-group exclude-group))))
9284 (defun gnus-summary-find-next (&optional unread article backward)
9285 (if backward (gnus-summary-find-prev)
9286 (let* ((article (or article (gnus-summary-article-number)))
9287 (arts (gnus-data-find-list article))
9289 (when (or (not gnus-summary-check-current)
9291 (not (gnus-data-unread-p (car arts))))
9292 (setq arts (cdr arts)))
9297 (when (gnus-data-unread-p (car arts))
9298 (setq result (car arts)
9300 (setq arts (cdr arts)))
9303 (goto-char (gnus-data-pos result))
9304 (gnus-data-number result)))))
9306 (defun gnus-summary-find-prev (&optional unread article)
9307 (let* ((article (or article (gnus-summary-article-number)))
9308 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
9310 (when (or (not gnus-summary-check-current)
9312 (not (gnus-data-unread-p (car arts))))
9313 (setq arts (cdr arts)))
9318 (and (gnus-data-unread-p (car arts))
9319 (setq result (car arts)
9321 (setq arts (cdr arts)))
9325 (goto-char (gnus-data-pos result))
9326 (gnus-data-number result)))))
9328 (defun gnus-summary-find-subject (subject &optional unread backward article)
9329 (let* ((simp-subject (gnus-simplify-subject-fully subject))
9330 (article (or article (gnus-summary-article-number)))
9331 (articles (gnus-data-list backward))
9332 (arts (gnus-data-find-list article articles))
9334 (when (or (not gnus-summary-check-current)
9336 (not (gnus-data-unread-p (car arts))))
9337 (setq arts (cdr arts)))
9339 (and (or (not unread)
9340 (gnus-data-unread-p (car arts)))
9341 (vectorp (gnus-data-header (car arts)))
9343 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
9344 (setq result (car arts)
9346 (setq arts (cdr arts)))
9348 (goto-char (gnus-data-pos result))
9349 (gnus-data-number result))))
9351 (defun gnus-summary-search-forward (&optional unread subject backward)
9352 "Search forward for an article.
9353 If UNREAD, look for unread articles. If SUBJECT, look for
9354 articles with that subject. If BACKWARD, search backward instead."
9355 (cond (subject (gnus-summary-find-subject subject unread backward))
9356 (backward (gnus-summary-find-prev unread))
9357 (t (gnus-summary-find-next unread))))
9359 (defun gnus-recenter (&optional n)
9360 "Center point in window and redisplay frame.
9361 Also do horizontal recentering."
9363 (when (and gnus-auto-center-summary
9364 (not (eq gnus-auto-center-summary 'vertical)))
9365 (gnus-horizontal-recenter))
9368 (defun gnus-summary-recenter ()
9369 "Center point in the summary window.
9370 If `gnus-auto-center-summary' is nil, or the article buffer isn't
9371 displayed, no centering will be performed."
9372 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
9373 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
9374 (let* ((top (cond ((< (window-height) 4) 0)
9375 ((< (window-height) 7) 1)
9377 (height (1- (window-height)))
9378 (bottom (save-excursion (goto-char (point-max))
9379 (forward-line (- height))
9381 (window (get-buffer-window (current-buffer))))
9382 ;; The user has to want it.
9383 (when gnus-auto-center-summary
9384 (when (get-buffer-window gnus-article-buffer)
9385 ;; Only do recentering when the article buffer is displayed,
9386 ;; Set the window start to either `bottom', which is the biggest
9387 ;; possible valid number, or the second line from the top,
9388 ;; whichever is the least.
9390 window (min bottom (save-excursion
9391 (forward-line (- top)) (point)))))
9392 ;; Do horizontal recentering while we're at it.
9393 (when (and (get-buffer-window (current-buffer) t)
9394 (not (eq gnus-auto-center-summary 'vertical)))
9395 (let ((selected (selected-window)))
9396 (select-window (get-buffer-window (current-buffer) t))
9397 (gnus-summary-position-point)
9398 (gnus-horizontal-recenter)
9399 (select-window selected))))))
9401 (defun gnus-horizontal-recenter ()
9402 "Recenter the current buffer horizontally."
9403 (if (< (current-column) (/ (window-width) 2))
9404 (set-window-hscroll (get-buffer-window (current-buffer) t) 0)
9405 (let* ((orig (point))
9406 (end (window-end (get-buffer-window (current-buffer) t)))
9408 ;; Find the longest line currently displayed in the window.
9409 (goto-char (window-start))
9410 (while (and (not (eobp))
9413 (setq max (max max (current-column)))
9416 ;; Scroll horizontally to center (sort of) the point.
9417 (if (> max (window-width))
9419 (get-buffer-window (current-buffer) t)
9420 (min (- (current-column) (/ (window-width) 3))
9421 (+ 2 (- max (window-width)))))
9422 (set-window-hscroll (get-buffer-window (current-buffer) t) 0))
9425 ;; Function written by Stainless Steel Rat <ratinox@ccs.neu.edu>.
9426 (defun gnus-short-group-name (group &optional levels)
9427 "Collapse GROUP name LEVELS."
9434 (while (string-match "\\." group skip)
9435 (setq skip (match-end 0)
9438 (if (string-match ":" group)
9439 (setq foreign (substring group 0 (match-end 0))
9440 group (substring group (match-end 0))))
9442 (if (and (string-match "\\." group)
9443 (> levels (- gnus-group-uncollapsed-levels 1)))
9444 (setq name (concat name (substring group 0 1))
9445 group (substring group (match-end 0))
9447 name (concat name "."))
9448 (setq name (concat foreign name group)
9452 (defun gnus-summary-jump-to-group (newsgroup)
9453 "Move point to NEWSGROUP in group mode buffer."
9454 ;; Keep update point of group mode buffer if visible.
9455 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
9456 (save-window-excursion
9457 ;; Take care of tree window mode.
9458 (if (get-buffer-window gnus-group-buffer)
9459 (pop-to-buffer gnus-group-buffer))
9460 (gnus-group-jump-to-group newsgroup))
9462 ;; Take care of tree window mode.
9463 (if (get-buffer-window gnus-group-buffer)
9464 (pop-to-buffer gnus-group-buffer)
9465 (set-buffer gnus-group-buffer))
9466 (gnus-group-jump-to-group newsgroup))))
9468 ;; This function returns a list of article numbers based on the
9469 ;; difference between the ranges of read articles in this group and
9470 ;; the range of active articles.
9471 (defun gnus-list-of-unread-articles (group)
9472 (let* ((read (gnus-info-read (gnus-get-info group)))
9473 (active (gnus-active group))
9476 ;; If none are read, then all are unread.
9478 (setq first (car active))
9479 ;; If the range of read articles is a single range, then the
9480 ;; first unread article is the article after the last read
9481 ;; article. Sounds logical, doesn't it?
9482 (if (not (listp (cdr read)))
9483 (setq first (1+ (cdr read)))
9484 ;; `read' is a list of ranges.
9485 (if (/= (setq nlast (or (and (numberp (car read)) (car read))
9490 (while (< first nlast)
9491 (setq unread (cons first unread))
9492 (setq first (1+ first))))
9493 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
9494 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
9495 (setq read (cdr read)))))
9496 ;; And add the last unread articles.
9497 (while (<= first last)
9498 (setq unread (cons first unread))
9499 (setq first (1+ first)))
9500 ;; Return the list of unread articles.
9503 (defun gnus-list-of-read-articles (group)
9504 "Return a list of unread, unticked and non-dormant articles."
9505 (let* ((info (gnus-get-info group))
9506 (marked (gnus-info-marks info))
9507 (active (gnus-active group)))
9509 (gnus-set-difference
9510 (gnus-sorted-complement
9511 (gnus-uncompress-range active)
9512 (gnus-list-of-unread-articles group))
9514 (gnus-uncompress-range (cdr (assq 'dormant marked)))
9515 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
9517 ;; Various summary commands
9519 (defun gnus-summary-universal-argument (arg)
9520 "Perform any operation on all articles that are process/prefixed."
9522 (gnus-set-global-variables)
9523 (let ((articles (gnus-summary-work-articles arg))
9530 (substitute-command-keys
9531 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
9535 (message "Undefined key")
9539 (gnus-summary-goto-subject (setq article (pop articles)))
9540 (command-execute func)
9541 (gnus-summary-remove-process-mark article)))))
9542 (gnus-summary-position-point))
9544 (defun gnus-summary-toggle-truncation (&optional arg)
9545 "Toggle truncation of summary lines.
9546 With arg, turn line truncation on iff arg is positive."
9548 (setq truncate-lines
9549 (if (null arg) (not truncate-lines)
9550 (> (prefix-numeric-value arg) 0)))
9553 (defun gnus-summary-reselect-current-group (&optional all rescan)
9554 "Exit and then reselect the current newsgroup.
9555 The prefix argument ALL means to select all articles."
9557 (gnus-set-global-variables)
9558 (let ((current-subject (gnus-summary-article-number))
9559 (group gnus-newsgroup-name))
9560 (setq gnus-newsgroup-begin nil)
9562 ;; We have to adjust the point of group mode buffer because the
9563 ;; current point was moved to the next unread newsgroup by
9565 (gnus-summary-jump-to-group group)
9568 (gnus-group-get-new-news-this-group 1)))
9569 (gnus-group-read-group all t)
9570 (gnus-summary-goto-subject current-subject)))
9572 (defun gnus-summary-rescan-group (&optional all)
9573 "Exit the newsgroup, ask for new articles, and select the newsgroup."
9575 (gnus-summary-reselect-current-group all t))
9577 (defun gnus-summary-update-info ()
9578 (let* ((group gnus-newsgroup-name))
9579 (when gnus-newsgroup-kill-headers
9580 (setq gnus-newsgroup-killed
9581 (gnus-compress-sequence
9583 (gnus-set-sorted-intersection
9584 (gnus-uncompress-range gnus-newsgroup-killed)
9585 (setq gnus-newsgroup-unselected
9586 (sort gnus-newsgroup-unselected '<)))
9587 (setq gnus-newsgroup-unreads
9588 (sort gnus-newsgroup-unreads '<))) t)))
9589 (unless (listp (cdr gnus-newsgroup-killed))
9590 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
9591 (let ((headers gnus-newsgroup-headers))
9592 (run-hooks 'gnus-exit-group-hook)
9593 (unless gnus-save-score
9594 (setq gnus-newsgroup-scored nil))
9595 ;; Set the new ranges of read articles.
9596 (gnus-update-read-articles
9597 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
9598 ;; Set the current article marks.
9600 ;; Do the cross-ref thing.
9601 (when gnus-use-cross-reference
9602 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
9603 ;; Do adaptive scoring, and possibly save score files.
9604 (when gnus-newsgroup-adaptive
9605 (gnus-score-adaptive))
9606 (when gnus-use-scoring
9608 ;; Do not switch windows but change the buffer to work.
9609 (set-buffer gnus-group-buffer)
9610 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
9611 (gnus-group-update-group group)))))
9613 (defun gnus-summary-exit (&optional temporary)
9614 "Exit reading current newsgroup, and then return to group selection mode.
9615 gnus-exit-group-hook is called with no arguments if that value is non-nil."
9617 (gnus-set-global-variables)
9618 (gnus-kill-save-kill-buffer)
9619 (let* ((group gnus-newsgroup-name)
9620 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
9622 (buf (current-buffer)))
9623 (run-hooks 'gnus-summary-prepare-exit-hook)
9624 ;; If we have several article buffers, we kill them at exit.
9625 (unless gnus-single-article-buffer
9626 (gnus-kill-buffer gnus-article-buffer)
9627 (gnus-kill-buffer gnus-original-article-buffer))
9628 (when gnus-use-cache
9629 (gnus-cache-possibly-remove-articles)
9630 (gnus-cache-save-buffers))
9631 (when gnus-use-trees
9632 (gnus-tree-close group))
9633 ;; Make all changes in this group permanent.
9635 (gnus-summary-update-info))
9636 (gnus-close-group group)
9637 ;; Make sure where I was, and go to next newsgroup.
9638 (set-buffer gnus-group-buffer)
9640 (gnus-group-jump-to-group group)
9641 (gnus-group-next-unread-group 1))
9642 (run-hooks 'gnus-summary-exit-hook)
9645 ;; If we have several article buffers, we kill them at exit.
9646 (unless gnus-single-article-buffer
9647 (gnus-kill-buffer gnus-article-buffer)
9648 (gnus-kill-buffer gnus-original-article-buffer))
9650 (if (not gnus-kill-summary-on-exit)
9651 (gnus-deaden-summary)
9652 ;; We set all buffer-local variables to nil. It is unclear why
9653 ;; this is needed, but if we don't, buffer-local variables are
9654 ;; not garbage-collected, it seems. This would the lead to en
9655 ;; ever-growing Emacs.
9656 (gnus-summary-clear-local-variables)
9657 (when (get-buffer gnus-article-buffer)
9658 (bury-buffer gnus-article-buffer))
9659 ;; We clear the global counterparts of the buffer-local
9660 ;; variables as well, just to be on the safe side.
9661 (gnus-configure-windows 'group 'force)
9662 (gnus-summary-clear-local-variables)
9663 ;; Return to group mode buffer.
9664 (if (eq mode 'gnus-summary-mode)
9665 (gnus-kill-buffer buf)))
9666 (setq gnus-current-select-method gnus-select-method)
9667 (pop-to-buffer gnus-group-buffer)
9668 ;; Clear the current group name.
9669 (if (not quit-config)
9671 (gnus-group-jump-to-group group)
9672 (gnus-group-next-unread-group 1)
9673 (gnus-configure-windows 'group 'force))
9674 (if (not (buffer-name (car quit-config)))
9675 (gnus-configure-windows 'group 'force)
9676 (set-buffer (car quit-config))
9677 (and (eq major-mode 'gnus-summary-mode)
9678 (gnus-set-global-variables))
9679 (gnus-configure-windows (cdr quit-config))))
9681 (setq gnus-newsgroup-name nil)))))
9683 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
9684 (defun gnus-summary-exit-no-update (&optional no-questions)
9685 "Quit reading current newsgroup without updating read article info."
9687 (gnus-set-global-variables)
9688 (let* ((group gnus-newsgroup-name)
9689 (quit-config (gnus-group-quit-config group)))
9690 (when (or no-questions
9692 (gnus-y-or-n-p "Do you really wanna quit reading this group? "))
9693 ;; If we have several article buffers, we kill them at exit.
9694 (unless gnus-single-article-buffer
9695 (gnus-kill-buffer gnus-article-buffer)
9696 (gnus-kill-buffer gnus-original-article-buffer))
9697 (if (not gnus-kill-summary-on-exit)
9698 (gnus-deaden-summary)
9699 (gnus-close-group group)
9700 (gnus-summary-clear-local-variables)
9701 (set-buffer gnus-group-buffer)
9702 (gnus-summary-clear-local-variables)
9703 (when (get-buffer gnus-summary-buffer)
9704 (kill-buffer gnus-summary-buffer)))
9705 (when gnus-use-trees
9706 (gnus-tree-close group))
9707 (when (get-buffer gnus-article-buffer)
9708 (bury-buffer gnus-article-buffer))
9709 ;; Return to the group buffer.
9710 (gnus-configure-windows 'group 'force)
9711 ;; Clear the current group name.
9712 (setq gnus-newsgroup-name nil)
9713 (when (equal (gnus-group-group-name) group)
9714 (gnus-group-next-unread-group 1))
9716 (if (not (buffer-name (car quit-config)))
9717 (gnus-configure-windows 'group 'force)
9718 (set-buffer (car quit-config))
9719 (when (eq major-mode 'gnus-summary-mode)
9720 (gnus-set-global-variables))
9721 (gnus-configure-windows (cdr quit-config)))))))
9725 (defvar gnus-dead-summary-mode-map nil)
9727 (if gnus-dead-summary-mode-map
9729 (setq gnus-dead-summary-mode-map (make-keymap))
9730 (suppress-keymap gnus-dead-summary-mode-map)
9731 (substitute-key-definition
9732 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
9733 (let ((keys '("\C-d" "\r" "\177")))
9735 (define-key gnus-dead-summary-mode-map
9736 (pop keys) 'gnus-summary-wake-up-the-dead))))
9738 (defvar gnus-dead-summary-mode nil
9739 "Minor mode for Gnus summary buffers.")
9741 (defun gnus-dead-summary-mode (&optional arg)
9742 "Minor mode for Gnus summary buffers."
9744 (when (eq major-mode 'gnus-summary-mode)
9745 (make-local-variable 'gnus-dead-summary-mode)
9746 (setq gnus-dead-summary-mode
9747 (if (null arg) (not gnus-dead-summary-mode)
9748 (> (prefix-numeric-value arg) 0)))
9749 (when gnus-dead-summary-mode
9750 (unless (assq 'gnus-dead-summary-mode minor-mode-alist)
9751 (push '(gnus-dead-summary-mode " Dead") minor-mode-alist))
9752 (unless (assq 'gnus-dead-summary-mode minor-mode-map-alist)
9753 (push (cons 'gnus-dead-summary-mode gnus-dead-summary-mode-map)
9754 minor-mode-map-alist)))))
9756 (defun gnus-deaden-summary ()
9757 "Make the current summary buffer into a dead summary buffer."
9758 ;; Kill any previous dead summary buffer.
9759 (when (and gnus-dead-summary
9760 (buffer-name gnus-dead-summary))
9762 (set-buffer gnus-dead-summary)
9763 (when gnus-dead-summary-mode
9764 (kill-buffer (current-buffer)))))
9765 ;; Make this the current dead summary.
9766 (setq gnus-dead-summary (current-buffer))
9767 (gnus-dead-summary-mode 1)
9768 (let ((name (buffer-name)))
9769 (when (string-match "Summary" name)
9771 (concat (substring name 0 (match-beginning 0)) "Dead "
9772 (substring name (match-beginning 0))) t))))
9774 (defun gnus-kill-or-deaden-summary (buffer)
9775 "Kill or deaden the summary BUFFER."
9776 (cond (gnus-kill-summary-on-exit
9777 (when (and gnus-use-trees
9778 (and (get-buffer buffer)
9779 (buffer-name (get-buffer buffer))))
9781 (set-buffer (get-buffer buffer))
9782 (gnus-tree-close gnus-newsgroup-name)))
9783 (gnus-kill-buffer buffer))
9784 ((and (get-buffer buffer)
9785 (buffer-name (get-buffer buffer)))
9788 (gnus-deaden-summary)))))
9790 (defun gnus-summary-wake-up-the-dead (&rest args)
9791 "Wake up the dead summary buffer."
9793 (gnus-dead-summary-mode -1)
9794 (let ((name (buffer-name)))
9795 (when (string-match "Dead " name)
9797 (concat (substring name 0 (match-beginning 0))
9798 (substring name (match-end 0))) t)))
9799 (gnus-message 3 "This dead summary is now alive again"))
9801 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
9802 (defun gnus-summary-fetch-faq (&optional faq-dir)
9803 "Fetch the FAQ for the current group.
9804 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
9808 (if current-prefix-arg
9810 "Faq dir: " (and (listp gnus-group-faq-directory)
9811 gnus-group-faq-directory)))))
9812 (let (gnus-faq-buffer)
9813 (and (setq gnus-faq-buffer
9814 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
9815 (gnus-configure-windows 'summary-faq))))
9817 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
9818 (defun gnus-summary-describe-group (&optional force)
9819 "Describe the current newsgroup."
9821 (gnus-group-describe-group force gnus-newsgroup-name))
9823 (defun gnus-summary-describe-briefly ()
9824 "Describe summary mode commands briefly."
9827 (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")))
9829 ;; Walking around group mode buffer from summary mode.
9831 (defun gnus-summary-next-group (&optional no-article target-group backward)
9832 "Exit current newsgroup and then select next unread newsgroup.
9833 If prefix argument NO-ARTICLE is non-nil, no article is selected
9834 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
9835 previous group instead."
9837 (gnus-set-global-variables)
9838 (let ((current-group gnus-newsgroup-name)
9839 (current-buffer (current-buffer))
9841 ;; First we semi-exit this group to update Xrefs and all variables.
9842 ;; We can't do a real exit, because the window conf must remain
9843 ;; the same in case the user is prompted for info, and we don't
9844 ;; want the window conf to change before that...
9845 (gnus-summary-exit t)
9846 (while (not entered)
9847 ;; Then we find what group we are supposed to enter.
9848 (set-buffer gnus-group-buffer)
9849 (gnus-group-jump-to-group current-group)
9852 (if (eq gnus-keep-same-level 'best)
9853 (gnus-summary-best-group gnus-newsgroup-name)
9854 (gnus-summary-search-group backward gnus-keep-same-level))))
9855 (if (not target-group)
9856 ;; There are no further groups, so we return to the group
9859 (gnus-message 5 "Returning to the group buffer")
9861 (set-buffer current-buffer)
9862 (gnus-summary-exit))
9863 ;; We try to enter the target group.
9864 (gnus-group-jump-to-group target-group)
9865 (let ((unreads (gnus-group-group-unread)))
9866 (if (and (or (eq t unreads)
9867 (and unreads (not (zerop unreads))))
9868 (gnus-summary-read-group
9869 target-group nil no-article current-buffer))
9871 (setq current-group target-group
9872 target-group nil)))))))
9874 (defun gnus-summary-prev-group (&optional no-article)
9875 "Exit current newsgroup and then select previous unread newsgroup.
9876 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
9878 (gnus-summary-next-group no-article nil t))
9880 ;; Walking around summary lines.
9882 (defun gnus-summary-first-subject (&optional unread)
9883 "Go to the first unread subject.
9884 If UNREAD is non-nil, go to the first unread article.
9885 Returns the article selected or nil if there are no unread articles."
9890 ((null gnus-newsgroup-data)
9891 (gnus-message 3 "No articles in the group")
9893 ;; Pick the first article.
9895 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
9896 (gnus-data-number (car gnus-newsgroup-data)))
9897 ;; No unread articles.
9898 ((null gnus-newsgroup-unreads)
9899 (gnus-message 3 "No more unread articles")
9901 ;; Find the first unread article.
9903 (let ((data gnus-newsgroup-data))
9905 (not (gnus-data-unread-p (car data))))
9906 (setq data (cdr data)))
9909 (goto-char (gnus-data-pos (car data)))
9910 (gnus-data-number (car data)))))))
9911 (gnus-summary-position-point)))
9913 (defun gnus-summary-next-subject (n &optional unread dont-display)
9914 "Go to next N'th summary line.
9915 If N is negative, go to the previous N'th subject line.
9916 If UNREAD is non-nil, only unread articles are selected.
9917 The difference between N and the actual number of steps taken is
9920 (let ((backward (< n 0))
9924 (gnus-summary-find-prev unread)
9925 (gnus-summary-find-next unread)))
9927 (if (/= 0 n) (gnus-message 7 "No more%s articles"
9928 (if unread " unread" "")))
9929 (unless dont-display
9930 (gnus-summary-recenter)
9931 (gnus-summary-position-point))
9934 (defun gnus-summary-next-unread-subject (n)
9935 "Go to next N'th unread summary line."
9937 (gnus-summary-next-subject n t))
9939 (defun gnus-summary-prev-subject (n &optional unread)
9940 "Go to previous N'th summary line.
9941 If optional argument UNREAD is non-nil, only unread article is selected."
9943 (gnus-summary-next-subject (- n) unread))
9945 (defun gnus-summary-prev-unread-subject (n)
9946 "Go to previous N'th unread summary line."
9948 (gnus-summary-next-subject (- n) t))
9950 (defun gnus-summary-goto-subject (article &optional force silent)
9951 "Go the subject line of ARTICLE.
9952 If FORCE, also allow jumping to articles not currently shown."
9954 (data (gnus-data-find article)))
9955 ;; We read in the article if we have to.
9958 (gnus-summary-insert-subject article)
9959 (setq data (gnus-data-find article)))
9964 (gnus-message 3 "Can't find article %d" article))
9966 (goto-char (gnus-data-pos data))
9969 ;; Walking around summary lines with displaying articles.
9971 (defun gnus-summary-expand-window (&optional arg)
9972 "Make the summary buffer take up the entire Emacs frame.
9973 Given a prefix, will force an `article' buffer configuration."
9975 (gnus-set-global-variables)
9977 (gnus-configure-windows 'article 'force)
9978 (gnus-configure-windows 'summary 'force)))
9980 (defun gnus-summary-display-article (article &optional all-header)
9981 "Display ARTICLE in article buffer."
9982 (gnus-set-global-variables)
9986 (if gnus-summary-display-article-function
9987 (funcall gnus-summary-display-article-function article all-header)
9988 (gnus-article-prepare article all-header))
9989 (run-hooks 'gnus-select-article-hook)
9990 (gnus-summary-recenter)
9991 (gnus-summary-goto-subject article)
9992 (when gnus-use-trees
9993 (gnus-possibly-generate-tree article)
9994 (gnus-highlight-selected-tree article))
9995 ;; Successfully display article.
9996 (gnus-article-set-window-start
9997 (cdr (assq article gnus-newsgroup-bookmarks)))
10000 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
10001 "Select the current article.
10002 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
10003 non-nil, the article will be re-fetched even if it already present in
10004 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
10006 (let ((article (or article (gnus-summary-article-number)))
10007 (all-headers (not (not all-headers))) ;Must be T or NIL.
10008 gnus-summary-display-article-function
10011 (gnus-summary-article-pseudo-p article)
10012 (error "This is a pseudo-article."))
10015 (set-buffer gnus-summary-buffer)
10016 (if (or (and gnus-single-article-buffer
10017 (or (null gnus-current-article)
10018 (null gnus-article-current)
10019 (null (get-buffer gnus-article-buffer))
10020 (not (eq article (cdr gnus-article-current)))
10021 (not (equal (car gnus-article-current)
10022 gnus-newsgroup-name))))
10023 (and (not gnus-single-article-buffer)
10024 (null gnus-current-article))
10026 ;; The requested article is different from the current article.
10028 (gnus-summary-display-article article all-headers)
10029 (setq did article))
10030 (if (or all-headers gnus-show-all-headers)
10031 (gnus-article-show-all-headers))
10034 (gnus-article-set-window-start
10035 (cdr (assq article gnus-newsgroup-bookmarks)))))))
10037 (defun gnus-summary-set-current-mark (&optional current-mark)
10038 "Obsolete function."
10041 (defun gnus-summary-next-article (&optional unread subject backward push)
10042 "Select the next article.
10043 If UNREAD, only unread articles are selected.
10044 If SUBJECT, only articles with SUBJECT are selected.
10045 If BACKWARD, the previous article is selected instead of the next."
10047 (gnus-set-global-variables)
10050 ;; Is there such an article?
10051 ((and (gnus-summary-search-forward unread subject backward)
10052 (or (gnus-summary-display-article (gnus-summary-article-number))
10053 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10054 (gnus-summary-position-point))
10055 ;; If not, we try the first unread, if that is wanted.
10057 gnus-auto-select-same
10058 (or (gnus-summary-first-unread-article)
10059 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
10060 (gnus-summary-position-point)
10061 (gnus-message 6 "Wrapped"))
10062 ;; Try to get next/previous article not displayed in this group.
10063 ((and gnus-auto-extend-newsgroup
10064 (not unread) (not subject))
10065 (gnus-summary-goto-article
10066 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
10068 ;; Go to next/previous group.
10070 (or (gnus-ephemeral-group-p gnus-newsgroup-name)
10071 (gnus-summary-jump-to-group gnus-newsgroup-name))
10072 (let ((cmd last-command-char)
10074 (if (eq gnus-keep-same-level 'best)
10075 (gnus-summary-best-group gnus-newsgroup-name)
10076 (gnus-summary-search-group backward gnus-keep-same-level))))
10077 ;; For some reason, the group window gets selected. We change
10079 (select-window (get-buffer-window (current-buffer)))
10080 ;; Select next unread newsgroup automagically.
10082 ((not gnus-auto-select-next)
10083 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
10084 ((or (eq gnus-auto-select-next 'quietly)
10085 (and (eq gnus-auto-select-next 'slightly-quietly)
10087 (and (eq gnus-auto-select-next 'almost-quietly)
10088 (gnus-summary-last-article-p)))
10090 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
10091 (gnus-summary-exit)
10092 (gnus-message 7 "No more%s articles (%s)..."
10093 (if unread " unread" "")
10094 (if group (concat "selecting " group)
10096 (gnus-summary-next-group nil group backward)))
10098 (gnus-summary-walk-group-buffer
10099 gnus-newsgroup-name cmd unread backward))))))))
10101 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward)
10102 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
10103 (?\C-p (gnus-group-prev-unread-group 1))))
10104 keve key group ended)
10106 (set-buffer gnus-group-buffer)
10107 (gnus-summary-jump-to-group from-group)
10109 (if (eq gnus-keep-same-level 'best)
10110 (gnus-summary-best-group gnus-newsgroup-name)
10111 (gnus-summary-search-group backward gnus-keep-same-level))))
10114 5 "No more%s articles%s" (if unread " unread" "")
10116 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
10117 (format " (Type %s for %s [%s])"
10118 (single-key-description cmd) group
10119 (car (gnus-gethash group gnus-newsrc-hashtb)))
10120 (format " (Type %s to exit %s)"
10121 (single-key-description cmd)
10122 gnus-newsgroup-name)))
10123 ;; Confirm auto selection.
10124 (setq key (car (setq keve (gnus-read-event-char))))
10127 ((assq key keystrokes)
10128 (let ((obuf (current-buffer)))
10129 (switch-to-buffer gnus-group-buffer)
10131 (gnus-group-jump-to-group group))
10132 (eval (cadr (assq key keystrokes)))
10133 (setq group (gnus-group-group-name))
10134 (switch-to-buffer obuf))
10137 (if (or (not group)
10138 (gnus-ephemeral-group-p gnus-newsgroup-name))
10139 (gnus-summary-exit)
10140 (gnus-summary-next-group nil group backward)))
10142 (push (cdr keve) unread-command-events))))))
10144 (defun gnus-read-event-char ()
10145 "Get the next event."
10146 (let ((event (read-event)))
10147 (cons (and (numberp event) event) event)))
10149 (defun gnus-summary-next-unread-article ()
10150 "Select unread article after current one."
10152 (gnus-summary-next-article t (and gnus-auto-select-same
10153 (gnus-summary-article-subject))))
10155 (defun gnus-summary-prev-article (&optional unread subject)
10156 "Select the article after the current one.
10157 If UNREAD is non-nil, only unread articles are selected."
10159 (gnus-summary-next-article unread subject t))
10161 (defun gnus-summary-prev-unread-article ()
10162 "Select unred article before current one."
10164 (gnus-summary-prev-article t (and gnus-auto-select-same
10165 (gnus-summary-article-subject))))
10167 (defun gnus-summary-next-page (&optional lines circular)
10168 "Show next page of the selected article.
10169 If at the end of the current article, select the next article.
10170 LINES says how many lines should be scrolled up.
10172 If CIRCULAR is non-nil, go to the start of the article instead of
10173 selecting the next article when reaching the end of the current
10176 (setq gnus-summary-buffer (current-buffer))
10177 (gnus-set-global-variables)
10178 (let ((article (gnus-summary-article-number))
10180 (gnus-configure-windows 'article)
10181 (if (or (null gnus-current-article)
10182 (null gnus-article-current)
10183 (/= article (cdr gnus-article-current))
10184 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10185 ;; Selected subject is different from current article's.
10186 (gnus-summary-display-article article)
10187 (gnus-eval-in-buffer-window
10188 gnus-article-buffer
10189 (setq endp (gnus-article-next-page lines)))
10192 (gnus-summary-beginning-of-article))
10194 (gnus-message 3 "End of message"))
10196 (if (and (eq gnus-summary-goto-unread 'never)
10197 (not (eq article gnus-newsgroup-end)))
10198 (gnus-summary-next-article)
10199 (gnus-summary-next-unread-article))))))
10200 (gnus-summary-recenter)
10201 (gnus-summary-position-point)))
10203 (defun gnus-summary-prev-page (&optional lines)
10204 "Show previous page of selected article.
10205 Argument LINES specifies lines to be scrolled down."
10207 (gnus-set-global-variables)
10208 (let ((article (gnus-summary-article-number)))
10209 (gnus-configure-windows 'article)
10210 (if (or (null gnus-current-article)
10211 (null gnus-article-current)
10212 (/= article (cdr gnus-article-current))
10213 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
10214 ;; Selected subject is different from current article's.
10215 (gnus-summary-display-article article)
10216 (gnus-summary-recenter)
10217 (gnus-eval-in-buffer-window gnus-article-buffer
10218 (gnus-article-prev-page lines))))
10219 (gnus-summary-position-point))
10221 (defun gnus-summary-scroll-up (lines)
10222 "Scroll up (or down) one line current article.
10223 Argument LINES specifies lines to be scrolled up (or down if negative)."
10225 (gnus-set-global-variables)
10226 (gnus-configure-windows 'article)
10227 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
10228 (gnus-eval-in-buffer-window
10229 gnus-article-buffer
10231 (if (gnus-article-next-page lines)
10232 (gnus-message 3 "End of message")))
10234 (gnus-article-prev-page (- lines))))))
10235 (gnus-summary-recenter)
10236 (gnus-summary-position-point))
10238 (defun gnus-summary-next-same-subject ()
10239 "Select next article which has the same subject as current one."
10241 (gnus-set-global-variables)
10242 (gnus-summary-next-article nil (gnus-summary-article-subject)))
10244 (defun gnus-summary-prev-same-subject ()
10245 "Select previous article which has the same subject as current one."
10247 (gnus-set-global-variables)
10248 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
10250 (defun gnus-summary-next-unread-same-subject ()
10251 "Select next unread article which has the same subject as current one."
10253 (gnus-set-global-variables)
10254 (gnus-summary-next-article t (gnus-summary-article-subject)))
10256 (defun gnus-summary-prev-unread-same-subject ()
10257 "Select previous unread article which has the same subject as current one."
10259 (gnus-set-global-variables)
10260 (gnus-summary-prev-article t (gnus-summary-article-subject)))
10262 (defun gnus-summary-first-unread-article ()
10263 "Select the first unread article.
10264 Return nil if there are no unread articles."
10266 (gnus-set-global-variables)
10268 (if (gnus-summary-first-subject t)
10270 (gnus-summary-show-thread)
10271 (gnus-summary-first-subject t)
10272 (gnus-summary-display-article (gnus-summary-article-number))))
10273 (gnus-summary-position-point)))
10275 (defun gnus-summary-best-unread-article ()
10276 "Select the unread article with the highest score."
10278 (gnus-set-global-variables)
10279 (let ((best -1000000)
10280 (data gnus-newsgroup-data)
10283 (and (gnus-data-unread-p (car data))
10285 (gnus-summary-article-score (gnus-data-number (car data))))
10288 article (gnus-data-number (car data))))
10289 (setq data (cdr data)))
10291 (gnus-summary-goto-article article)
10292 (error "No unread articles"))
10293 (gnus-summary-position-point)))
10295 (defun gnus-summary-last-subject ()
10296 "Go to the last displayed subject line in the group."
10297 (let ((article (gnus-data-number (car (gnus-data-list t)))))
10299 (gnus-summary-goto-subject article))))
10301 (defun gnus-summary-goto-article (article &optional all-headers force)
10302 "Fetch ARTICLE and display it if it exists.
10303 If ALL-HEADERS is non-nil, no header lines are hidden."
10309 (mapcar (lambda (number) (list (int-to-string number)))
10310 gnus-newsgroup-limit)))
10314 (if (gnus-summary-goto-subject article force)
10315 (gnus-summary-display-article article all-headers)
10316 (gnus-message 4 "Couldn't go to article %s" article) nil)
10317 (gnus-summary-position-point)))
10319 (defun gnus-summary-goto-last-article ()
10320 "Go to the previously read article."
10323 (and gnus-last-article
10324 (gnus-summary-goto-article gnus-last-article))
10325 (gnus-summary-position-point)))
10327 (defun gnus-summary-pop-article (number)
10328 "Pop one article off the history and go to the previous.
10329 NUMBER articles will be popped off."
10332 (setq gnus-newsgroup-history
10333 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
10335 (gnus-summary-goto-article (car to))
10336 (error "Article history empty")))
10337 (gnus-summary-position-point))
10339 ;; Summary commands and functions for limiting the summary buffer.
10341 (defun gnus-summary-limit-to-articles (n)
10342 "Limit the summary buffer to the next N articles.
10343 If not given a prefix, use the process marked articles instead."
10345 (gnus-set-global-variables)
10347 (let ((articles (gnus-summary-work-articles n)))
10348 (setq gnus-newsgroup-processable nil)
10349 (gnus-summary-limit articles))
10350 (gnus-summary-position-point)))
10352 (defun gnus-summary-pop-limit (&optional total)
10353 "Restore the previous limit.
10354 If given a prefix, remove all limits."
10356 (gnus-set-global-variables)
10358 (setq gnus-newsgroup-limits
10359 (list (mapcar (lambda (h) (mail-header-number h))
10360 gnus-newsgroup-headers))))
10361 (unless gnus-newsgroup-limits
10362 (error "No limit to pop"))
10364 (gnus-summary-limit nil 'pop)
10365 (gnus-summary-position-point)))
10367 (defun gnus-summary-limit-to-subject (subject &optional header)
10368 "Limit the summary buffer to articles that have subjects that match a regexp."
10369 (interactive "sRegexp: ")
10371 (setq header "subject"))
10372 (when (not (equal "" subject))
10374 (let ((articles (gnus-summary-find-matching
10375 (or header "subject") subject 'all)))
10376 (or articles (error "Found no matches for \"%s\"" subject))
10377 (gnus-summary-limit articles))
10378 (gnus-summary-position-point))))
10380 (defun gnus-summary-limit-to-author (from)
10381 "Limit the summary buffer to articles that have authors that match a regexp."
10382 (interactive "sRegexp: ")
10383 (gnus-summary-limit-to-subject from "from"))
10385 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10387 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
10389 (defun gnus-summary-limit-to-unread (&optional all)
10390 "Limit the summary buffer to articles that are not marked as read.
10391 If ALL is non-nil, limit strictly to unread articles."
10394 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
10395 (gnus-summary-limit-to-marks
10396 ;; Concat all the marks that say that an article is read and have
10398 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
10399 gnus-killed-mark gnus-kill-file-mark
10400 gnus-low-score-mark gnus-expirable-mark
10401 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark)
10404 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10405 (make-obsolete 'gnus-summary-delete-marked-with 'gnus-summary-limit-to-marks)
10407 (defun gnus-summary-limit-to-marks (marks &optional reverse)
10408 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
10409 If REVERSE, limit the summary buffer to articles that are not marked
10410 with MARKS. MARKS can either be a string of marks or a list of marks.
10411 Returns how many articles were removed."
10412 (interactive "sMarks: ")
10413 (gnus-set-global-variables)
10415 (let ((data gnus-newsgroup-data)
10416 (marks (if (listp marks) marks
10417 (append marks nil))) ; Transform to list.
10420 (and (if reverse (not (memq (gnus-data-mark (car data)) marks))
10421 (memq (gnus-data-mark (car data)) marks))
10422 (setq articles (cons (gnus-data-number (car data)) articles)))
10423 (setq data (cdr data)))
10424 (gnus-summary-limit articles))
10425 (gnus-summary-position-point)))
10427 (defun gnus-summary-limit-to-score (&optional score)
10428 "Limit to articles with score at or above SCORE."
10430 (gnus-set-global-variables)
10431 (setq score (if score
10432 (prefix-numeric-value score)
10433 (or gnus-summary-default-score 0)))
10434 (let ((data gnus-newsgroup-data)
10437 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
10439 (push (gnus-data-number (car data)) articles))
10440 (setq data (cdr data)))
10442 (gnus-summary-limit articles)
10443 (gnus-summary-position-point))))
10445 (defun gnus-summary-limit-include-dormant ()
10446 "Display all the hidden articles that are marked as dormant."
10448 (gnus-set-global-variables)
10449 (or gnus-newsgroup-dormant
10450 (error "There are no dormant articles in this group"))
10452 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
10453 (gnus-summary-position-point)))
10455 (defun gnus-summary-limit-exclude-dormant ()
10456 "Hide all dormant articles."
10458 (gnus-set-global-variables)
10460 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
10461 (gnus-summary-position-point)))
10463 (defun gnus-summary-limit-exclude-childless-dormant ()
10464 "Hide all dormant articles that have no children."
10466 (gnus-set-global-variables)
10467 (let ((data (gnus-data-list t))
10468 articles d children)
10469 ;; Find all articles that are either not dormant or have
10471 (while (setq d (pop data))
10472 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
10473 (and (setq children
10474 (gnus-article-children (gnus-data-number d)))
10477 (when (memq (car children) articles)
10482 (push (gnus-data-number d) articles)))
10483 ;; Do the limiting.
10485 (gnus-summary-limit articles)
10486 (gnus-summary-position-point))))
10488 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
10489 "Mark all unread excluded articles as read.
10490 If ALL, mark even excluded ticked and dormants as read."
10492 (let ((articles (gnus-sorted-complement
10494 (mapcar (lambda (h) (mail-header-number h))
10495 gnus-newsgroup-headers)
10497 (sort gnus-newsgroup-limit '<)))
10499 (setq gnus-newsgroup-unreads nil)
10501 (setq gnus-newsgroup-dormant nil
10502 gnus-newsgroup-marked nil
10503 gnus-newsgroup-reads
10505 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
10506 gnus-newsgroup-reads))
10507 (while (setq article (pop articles))
10508 (unless (or (memq article gnus-newsgroup-dormant)
10509 (memq article gnus-newsgroup-marked))
10510 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
10512 (defun gnus-summary-limit (articles &optional pop)
10514 ;; We pop the previous limit off the stack and use that.
10515 (setq articles (car gnus-newsgroup-limits)
10516 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
10517 ;; We use the new limit, so we push the old limit on the stack.
10518 (setq gnus-newsgroup-limits
10519 (cons gnus-newsgroup-limit gnus-newsgroup-limits)))
10521 (setq gnus-newsgroup-limit articles)
10522 (let ((total (length gnus-newsgroup-data))
10523 (data (gnus-data-find-list (gnus-summary-article-number)))
10525 ;; This will do all the work of generating the new summary buffer
10526 ;; according to the new limit.
10527 (gnus-summary-prepare)
10528 ;; Hide any threads, possibly.
10529 (and gnus-show-threads
10530 gnus-thread-hide-subtree
10531 (gnus-summary-hide-all-threads))
10532 ;; Try to return to the article you were at, or one in the
10535 ;; We try to find some article after the current one.
10537 (and (gnus-summary-goto-subject
10538 (gnus-data-number (car data)) nil t)
10541 (setq data (cdr data))))
10543 ;; If there is no data, that means that we were after the last
10544 ;; article. The same goes when we can't find any articles
10545 ;; after the current one.
10547 (goto-char (point-max))
10548 (gnus-summary-find-prev)))
10549 ;; We return how many articles were removed from the summary
10550 ;; buffer as a result of the new limit.
10551 (- total (length gnus-newsgroup-data))))
10553 (defsubst gnus-cut-thread (thread)
10554 "Go forwards in the thread until we find an article that we want to display."
10555 (if (eq gnus-fetch-old-headers 'some)
10557 (memq (mail-header-number (car thread))
10558 gnus-newsgroup-ancient)
10559 (<= (length (cdr thread)) 1))
10560 (setq thread (cadr thread)))
10562 (memq (mail-header-number (car thread)) gnus-newsgroup-sparse)
10563 (= (length (cdr thread)) 1))
10564 (setq thread (cadr thread))))
10567 (defun gnus-cut-threads (threads)
10568 "Cut off all uninteresting articles from the beginning of threads."
10569 (when (or (eq gnus-fetch-old-headers 'some)
10570 (eq gnus-build-sparse-threads 'some)
10571 (eq gnus-build-sparse-threads 'more))
10572 (let ((th threads))
10574 (setcar th (gnus-cut-thread (car th)))
10575 (setq th (cdr th)))))
10578 (defun gnus-summary-initial-limit (&optional show-if-empty)
10579 "Figure out what the initial limit is supposed to be on group entry.
10580 This entails weeding out unwanted dormants, low-scored articles,
10581 fetch-old-headers verbiage, and so on."
10582 ;; Most groups have nothing to remove.
10583 (if (or gnus-inhibit-limiting
10584 (and (null gnus-newsgroup-dormant)
10585 (not (eq gnus-fetch-old-headers 'some))
10586 (null gnus-summary-expunge-below)
10587 (not (eq gnus-build-sparse-threads 'some))
10588 (not (eq gnus-build-sparse-threads 'more))
10589 (null gnus-thread-expunge-below)
10590 (not gnus-use-nocem)))
10592 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10593 (setq gnus-newsgroup-limit nil)
10596 (unless (car (symbol-value node))
10597 ;; These threads have no parents -- they are roots.
10598 (let ((nodes (cdr (symbol-value node)))
10601 (if (and gnus-thread-expunge-below
10602 (< (gnus-thread-total-score (car nodes))
10603 gnus-thread-expunge-below))
10604 (gnus-expunge-thread (pop nodes))
10605 (setq thread (pop nodes))
10606 (gnus-summary-limit-children thread))))))
10607 gnus-newsgroup-dependencies)
10608 ;; If this limitation resulted in an empty group, we might
10609 ;; pop the previous limit and use it instead.
10610 (when (and (not gnus-newsgroup-limit)
10612 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
10613 gnus-newsgroup-limit))
10615 (defun gnus-summary-limit-children (thread)
10616 "Return 1 if this subthread is visible and 0 if it is not."
10617 ;; First we get the number of visible children to this thread. This
10618 ;; is done by recursing down the thread using this function, so this
10619 ;; will really go down to a leaf article first, before slowly
10620 ;; working its way up towards the root.
10624 (apply '+ (mapcar 'gnus-summary-limit-children
10627 (number (mail-header-number (car thread)))
10630 ;; If this article is dormant and has absolutely no visible
10631 ;; children, then this article isn't visible.
10632 (and (memq number gnus-newsgroup-dormant)
10634 ;; If this is a "fetch-old-headered" and there is only one
10635 ;; visible child (or less), then we don't want this article.
10636 (and (eq gnus-fetch-old-headers 'some)
10637 (memq number gnus-newsgroup-ancient)
10639 ;; If this is a sparsely inserted article with no children,
10640 ;; we don't want it.
10641 (and (eq gnus-build-sparse-threads 'some)
10642 (memq number gnus-newsgroup-sparse)
10644 ;; If we use expunging, and this article is really
10645 ;; low-scored, then we don't want this article.
10646 (when (and gnus-summary-expunge-below
10648 (or (cdr (assq number gnus-newsgroup-scored))
10649 gnus-summary-default-score))
10650 gnus-summary-expunge-below))
10651 ;; We increase the expunge-tally here, but that has
10652 ;; nothing to do with the limits, really.
10653 (incf gnus-newsgroup-expunged-tally)
10654 ;; We also mark as read here, if that's wanted.
10655 (when (and gnus-summary-mark-below
10656 (< score gnus-summary-mark-below))
10657 (setq gnus-newsgroup-unreads
10658 (delq number gnus-newsgroup-unreads))
10659 (if gnus-newsgroup-auto-expire
10660 (push number gnus-newsgroup-expirable)
10661 (push (cons number gnus-low-score-mark)
10662 gnus-newsgroup-reads)))
10664 (and gnus-use-nocem
10665 (gnus-nocem-unwanted-article-p (mail-header-id (car thread)))))
10666 ;; Nope, invisible article.
10668 ;; Ok, this article is to be visible, so we add it to the limit
10670 (setq gnus-newsgroup-limit (cons number gnus-newsgroup-limit))
10673 (defun gnus-expunge-thread (thread)
10674 "Mark all articles in THREAD as read."
10675 (let* ((number (mail-header-number (car thread))))
10676 (incf gnus-newsgroup-expunged-tally)
10677 ;; We also mark as read here, if that's wanted.
10678 (setq gnus-newsgroup-unreads
10679 (delq number gnus-newsgroup-unreads))
10680 (if gnus-newsgroup-auto-expire
10681 (push number gnus-newsgroup-expirable)
10682 (push (cons number gnus-low-score-mark)
10683 gnus-newsgroup-reads)))
10684 ;; Go recursively through all subthreads.
10685 (mapcar 'gnus-expunge-thread (cdr thread)))
10687 ;; Summary article oriented commands
10689 (defun gnus-summary-refer-parent-article (n)
10690 "Refer parent article N times.
10691 The difference between N and the number of articles fetched is returned."
10693 (gnus-set-global-variables)
10697 (let* ((header (gnus-summary-article-header))
10699 ;; If we try to find the parent of the currently
10700 ;; displayed article, then we take a look at the actual
10701 ;; References header, since this is slightly more
10702 ;; reliable than the References field we got from the
10704 (if (and (eq (mail-header-number header)
10705 (cdr gnus-article-current))
10706 (equal gnus-newsgroup-name
10707 (car gnus-article-current)))
10709 (set-buffer gnus-original-article-buffer)
10710 (nnheader-narrow-to-headers)
10712 (mail-fetch-field "references")
10714 ;; It's not the current article, so we take a bet on
10715 ;; the value we got from the server.
10716 (mail-header-references header))))
10717 (if (setq ref (or ref (mail-header-references header)))
10718 (or (gnus-summary-refer-article (gnus-parent-id ref))
10719 (gnus-message 1 "Couldn't find parent"))
10720 (gnus-message 1 "No references in article %d"
10721 (gnus-summary-article-number))
10724 (gnus-summary-position-point)
10727 (defun gnus-summary-refer-references ()
10728 "Fetch all articles mentioned in the References header.
10729 Return how many articles were fetched."
10731 (gnus-set-global-variables)
10732 (let ((ref (mail-header-references (gnus-summary-article-header)))
10733 (current (gnus-summary-article-number))
10735 ;; For each Message-ID in the References header...
10736 (while (string-match "<[^>]*>" ref)
10738 ;; ... fetch that article.
10739 (gnus-summary-refer-article
10740 (prog1 (match-string 0 ref)
10741 (setq ref (substring ref (match-end 0))))))
10742 (gnus-summary-goto-subject current)
10743 (gnus-summary-position-point)
10746 (defun gnus-summary-refer-article (message-id)
10747 "Fetch an article specified by MESSAGE-ID."
10748 (interactive "sMessage-ID: ")
10749 (when (and (stringp message-id)
10750 (not (zerop (length message-id))))
10751 ;; Construct the correct Message-ID if necessary.
10752 ;; Suggested by tale@pawl.rpi.edu.
10753 (unless (string-match "^<" message-id)
10754 (setq message-id (concat "<" message-id)))
10755 (unless (string-match ">$" message-id)
10756 (setq message-id (concat message-id ">")))
10757 (let ((header (car (gnus-gethash (downcase message-id)
10758 gnus-newsgroup-dependencies))))
10760 ;; The article is present in the buffer, to we just go to it.
10761 (gnus-summary-goto-article (mail-header-number header) nil t)
10762 ;; We fetch the article
10763 (let ((gnus-override-method gnus-refer-article-method)
10765 ;; Start the special refer-article method, if necessary.
10766 (when gnus-refer-article-method
10767 (gnus-check-server gnus-refer-article-method))
10768 ;; Fetch the header, and display the article.
10769 (if (setq number (gnus-summary-insert-subject message-id))
10770 (gnus-summary-select-article nil nil nil number)
10771 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
10773 (defun gnus-summary-enter-digest-group (&optional force)
10774 "Enter a digest group based on the current article."
10776 (gnus-set-global-variables)
10777 (gnus-summary-select-article)
10778 (let ((name (format "%s-%d"
10779 (gnus-group-prefixed-name
10780 gnus-newsgroup-name (list 'nndoc ""))
10781 gnus-current-article))
10782 (ogroup gnus-newsgroup-name)
10783 (case-fold-search t)
10784 (buf (current-buffer))
10787 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
10788 (insert-buffer-substring gnus-original-article-buffer)
10790 (goto-char (point-min))
10791 (or (search-forward "\n\n" nil t) (point)))
10792 (goto-char (point-min))
10793 (delete-matching-lines "^\\(Path\\):\\|^From ")
10796 (if (gnus-group-read-ephemeral-group
10797 name `(nndoc ,name (nndoc-address
10799 (nndoc-article-type ,(if force 'digest 'guess))) t)
10800 ;; Make all postings to this group go to the parent group.
10801 (nconc (gnus-info-params (gnus-get-info name))
10802 (list (cons 'to-group ogroup)))
10803 ;; Couldn't select this doc group.
10804 (switch-to-buffer buf)
10805 (gnus-set-global-variables)
10806 (gnus-configure-windows 'summary)
10807 (gnus-message 3 "Article couldn't be entered?"))
10808 (kill-buffer dig))))
10810 (defun gnus-summary-isearch-article (&optional regexp-p)
10811 "Do incremental search forward on the current article.
10812 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
10814 (gnus-set-global-variables)
10815 (gnus-summary-select-article)
10816 (gnus-configure-windows 'article)
10817 (gnus-eval-in-buffer-window
10818 gnus-article-buffer
10819 (goto-char (point-min))
10820 (isearch-forward regexp-p)))
10822 (defun gnus-summary-search-article-forward (regexp &optional backward)
10823 "Search for an article containing REGEXP forward.
10824 If BACKWARD, search backward instead."
10827 (format "Search article %s (regexp%s): "
10828 (if current-prefix-arg "backward" "forward")
10829 (if gnus-last-search-regexp
10830 (concat ", default " gnus-last-search-regexp)
10832 current-prefix-arg))
10833 (gnus-set-global-variables)
10834 (if (string-equal regexp "")
10835 (setq regexp (or gnus-last-search-regexp ""))
10836 (setq gnus-last-search-regexp regexp))
10837 (if (gnus-summary-search-article regexp backward)
10838 (gnus-article-set-window-start
10839 (cdr (assq (gnus-summary-article-number) gnus-newsgroup-bookmarks)))
10840 (error "Search failed: \"%s\"" regexp)))
10842 (defun gnus-summary-search-article-backward (regexp)
10843 "Search for an article containing REGEXP backward."
10846 (format "Search article backward (regexp%s): "
10847 (if gnus-last-search-regexp
10848 (concat ", default " gnus-last-search-regexp)
10850 (gnus-summary-search-article-forward regexp 'backward))
10852 (defun gnus-summary-search-article (regexp &optional backward)
10853 "Search for an article containing REGEXP.
10854 Optional argument BACKWARD means do search for backward.
10855 gnus-select-article-hook is not called during the search."
10856 (let ((gnus-select-article-hook nil) ;Disable hook.
10857 (gnus-mark-article-hook nil) ;Inhibit marking as read.
10860 (function re-search-backward) (function re-search-forward)))
10863 ;; Hidden thread subtrees must be searched for ,too.
10864 (gnus-summary-show-all-threads)
10865 ;; First of all, search current article.
10866 ;; We don't want to read article again from NNTP server nor reset
10868 (gnus-summary-select-article)
10869 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10870 (setq last gnus-current-article)
10871 (gnus-eval-in-buffer-window
10872 gnus-article-buffer
10875 ;; Begin search from current point.
10876 (setq found (funcall re-search regexp nil t))))
10877 ;; Then search next articles.
10878 (while (and (not found)
10879 (gnus-summary-display-article
10880 (if backward (gnus-summary-find-prev)
10881 (gnus-summary-find-next))))
10882 (gnus-message 9 "Searching article: %d..." gnus-current-article)
10883 (gnus-eval-in-buffer-window
10884 gnus-article-buffer
10887 (goto-char (if backward (point-max) (point-min)))
10888 (setq found (funcall re-search regexp nil t)))))
10890 ;; Adjust article pointer.
10891 (or (eq last gnus-current-article)
10892 (setq gnus-last-article last))
10893 ;; Return T if found such article.
10896 (defun gnus-summary-find-matching (header regexp &optional backward unread
10898 "Return a list of all articles that match REGEXP on HEADER.
10899 The search stars on the current article and goes forwards unless
10900 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
10901 If UNREAD is non-nil, only unread articles will
10902 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
10903 in the comparisons."
10904 (let ((data (if (eq backward 'all) gnus-newsgroup-data
10905 (gnus-data-find-list
10906 (gnus-summary-article-number) (gnus-data-list backward))))
10907 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
10908 (case-fold-search (not not-case-fold))
10910 (or (fboundp (intern (concat "mail-header-" header)))
10911 (error "%s is not a valid header" header))
10913 (setq d (car data))
10914 (and (or (not unread) ; We want all articles...
10915 (gnus-data-unread-p d)) ; Or just unreads.
10916 (vectorp (gnus-data-header d)) ; It's not a pseudo.
10917 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
10918 (setq articles (cons (gnus-data-number d) articles))) ; Success!
10919 (setq data (cdr data)))
10920 (nreverse articles)))
10922 (defun gnus-summary-execute-command (header regexp command &optional backward)
10923 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
10924 If HEADER is an empty string (or nil), the match is done on the entire
10925 article. If BACKWARD (the prefix) is non-nil, search backward instead."
10927 (list (let ((completion-ignore-case t))
10930 (mapcar (lambda (string) (list string))
10931 '("Number" "Subject" "From" "Lines" "Date"
10932 "Message-ID" "Xref" "References" "Body"))
10933 nil 'require-match))
10934 (read-string "Regexp: ")
10935 (read-key-sequence "Command: ")
10936 current-prefix-arg))
10937 (when (equal header "Body")
10939 (gnus-set-global-variables)
10940 ;; Hidden thread subtrees must be searched as well.
10941 (gnus-summary-show-all-threads)
10942 ;; We don't want to change current point nor window configuration.
10944 (save-window-excursion
10945 (gnus-message 6 "Executing %s..." (key-description command))
10946 ;; We'd like to execute COMMAND interactively so as to give arguments.
10947 (gnus-execute header regexp
10948 `(lambda () (call-interactively ',(key-binding command)))
10950 (gnus-message 6 "Executing %s...done" (key-description command)))))
10952 (defun gnus-summary-beginning-of-article ()
10953 "Scroll the article back to the beginning."
10955 (gnus-set-global-variables)
10956 (gnus-summary-select-article)
10957 (gnus-configure-windows 'article)
10958 (gnus-eval-in-buffer-window
10959 gnus-article-buffer
10961 (goto-char (point-min))
10962 (and gnus-break-pages (gnus-narrow-to-page))))
10964 (defun gnus-summary-end-of-article ()
10965 "Scroll to the end of the article."
10967 (gnus-set-global-variables)
10968 (gnus-summary-select-article)
10969 (gnus-configure-windows 'article)
10970 (gnus-eval-in-buffer-window
10971 gnus-article-buffer
10973 (goto-char (point-max))
10975 (and gnus-break-pages (gnus-narrow-to-page))))
10977 (defun gnus-summary-show-article (&optional arg)
10978 "Force re-fetching of the current article.
10979 If ARG (the prefix) is non-nil, show the raw article without any
10980 article massaging functions being run."
10982 (gnus-set-global-variables)
10984 ;; Select the article the normal way.
10985 (gnus-summary-select-article nil 'force)
10986 ;; Bind the article treatment functions to nil.
10987 (let ((gnus-have-all-headers t)
10988 gnus-article-display-hook
10989 gnus-article-prepare-hook
10991 (gnus-summary-select-article nil 'force)))
10992 ; (gnus-configure-windows 'article)
10993 (gnus-summary-position-point))
10995 (defun gnus-summary-verbose-headers (&optional arg)
10996 "Toggle permanent full header display.
10997 If ARG is a positive number, turn header display on.
10998 If ARG is a negative number, turn header display off."
11000 (gnus-set-global-variables)
11001 (gnus-summary-toggle-header arg)
11002 (setq gnus-show-all-headers
11003 (cond ((or (not (numberp arg))
11005 (not gnus-show-all-headers))
11009 (defun gnus-summary-toggle-header (&optional arg)
11010 "Show the headers if they are hidden, or hide them if they are shown.
11011 If ARG is a positive number, show the entire header.
11012 If ARG is a negative number, hide the unwanted header lines."
11014 (gnus-set-global-variables)
11016 (set-buffer gnus-article-buffer)
11017 (let* ((buffer-read-only nil)
11018 (inhibit-point-motion-hooks t)
11019 (hidden (text-property-any
11020 (goto-char (point-min)) (search-forward "\n\n")
11023 (goto-char (point-min))
11024 (when (search-forward "\n\n" nil t)
11025 (delete-region (point-min) (1- (point))))
11026 (goto-char (point-min))
11028 (set-buffer gnus-original-article-buffer)
11029 (goto-char (point-min))
11030 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
11031 (insert-buffer-substring gnus-original-article-buffer 1 e)
11032 (let ((gnus-inhibit-hiding t))
11033 (run-hooks 'gnus-article-display-hook))
11034 (if (or (not hidden) (and (numberp arg) (< arg 0)))
11035 (gnus-article-hide-headers)))))
11037 (defun gnus-summary-show-all-headers ()
11038 "Make all header lines visible."
11040 (gnus-set-global-variables)
11041 (gnus-article-show-all-headers))
11043 (defun gnus-summary-toggle-mime (&optional arg)
11044 "Toggle MIME processing.
11045 If ARG is a positive number, turn MIME processing on."
11047 (gnus-set-global-variables)
11048 (setq gnus-show-mime
11049 (if (null arg) (not gnus-show-mime)
11050 (> (prefix-numeric-value arg) 0)))
11051 (gnus-summary-select-article t 'force))
11053 (defun gnus-summary-caesar-message (&optional arg)
11054 "Caesar rotate the current article by 13.
11055 The numerical prefix specifies how manu places to rotate each letter
11058 (gnus-set-global-variables)
11059 (gnus-summary-select-article)
11060 (let ((mail-header-separator ""))
11061 (gnus-eval-in-buffer-window
11062 gnus-article-buffer
11065 (let ((start (window-start)))
11066 (news-caesar-buffer-body arg)
11067 (set-window-start (get-buffer-window (current-buffer)) start))))))
11069 (defun gnus-summary-stop-page-breaking ()
11070 "Stop page breaking in the current article."
11072 (gnus-set-global-variables)
11073 (gnus-summary-select-article)
11074 (gnus-eval-in-buffer-window gnus-article-buffer (widen)))
11076 (defun gnus-summary-move-article (&optional n to-newsgroup select-method action)
11077 "Move the current article to a different newsgroup.
11078 If N is a positive number, move the N next articles.
11079 If N is a negative number, move the N previous articles.
11080 If N is nil and any articles have been marked with the process mark,
11081 move those articles instead.
11082 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11083 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
11084 re-spool using this method.
11086 For this function to work, both the current newsgroup and the
11087 newsgroup that you want to move to have to support the `request-move'
11088 and `request-accept' functions."
11090 (unless action (setq action 'move))
11091 (gnus-set-global-variables)
11092 ;; Check whether the source group supports the required functions.
11093 (cond ((and (eq action 'move)
11094 (not (gnus-check-backend-function
11095 'request-move-article gnus-newsgroup-name)))
11096 (error "The current group does not support article moving"))
11097 ((and (eq action 'crosspost)
11098 (not (gnus-check-backend-function
11099 'request-replace-article gnus-newsgroup-name)))
11100 (error "The current group does not support article editing")))
11101 (let ((articles (gnus-summary-work-articles n))
11102 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
11103 (names '((move "move" "Moving")
11104 (copy "copy" "Copying")
11105 (crosspost "crosspost" "Crossposting")))
11106 (copy-buf (save-excursion
11107 (nnheader-set-temp-buffer " *copy article*")))
11108 art-group to-method new-xref article)
11109 (unless (assq action names)
11110 (error "Unknown action %s" action))
11111 ;; Read the newsgroup name.
11112 (when (and (not to-newsgroup)
11113 (not select-method))
11115 (gnus-read-move-group-name
11116 (cadr (assq action names))
11117 gnus-current-move-group articles prefix))
11118 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
11119 (setq to-method (if select-method (list select-method "")
11120 (gnus-find-method-for-group to-newsgroup)))
11121 ;;(when (equal to-newsgroup gnus-newsgroup-name)
11122 ;;(error "Can't %s to the same group you're already in" action))
11123 ;; Check the method we are to move this article to...
11124 (or (gnus-check-backend-function 'request-accept-article (car to-method))
11125 (error "%s does not support article copying" (car to-method)))
11126 (or (gnus-check-server to-method)
11127 (error "Can't open server %s" (car to-method)))
11128 (gnus-message 6 "%s to %s: %s..."
11129 (caddr (assq action names))
11130 (or select-method to-newsgroup) articles)
11132 (setq article (pop articles))
11136 ;; Move the article.
11138 (gnus-request-move-article
11139 article ; Article to move
11140 gnus-newsgroup-name ; From newsgrouo
11141 (nth 1 (gnus-find-method-for-group
11142 gnus-newsgroup-name)) ; Server
11143 (list 'gnus-request-accept-article
11145 (list 'quote select-method)
11147 (not articles)) ; Accept form
11148 (not articles))) ; Only save nov last time
11149 ;; Copy the article.
11152 (set-buffer copy-buf)
11153 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11154 (gnus-request-accept-article
11155 (if select-method select-method to-newsgroup)
11157 ;; Crosspost the article.
11158 ((eq action 'crosspost)
11159 (let ((xref (mail-header-xref (gnus-summary-article-header article))))
11160 (setq new-xref (concat gnus-newsgroup-name ":" article))
11161 (if (and xref (not (string= xref "")))
11163 (when (string-match "^Xref: " xref)
11164 (setq xref (substring xref (match-end 0))))
11165 (setq new-xref (concat xref " " new-xref)))
11166 (setq new-xref (concat (system-name) " " new-xref)))
11168 (set-buffer copy-buf)
11169 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11170 (nnheader-replace-header "xref" new-xref)
11171 (gnus-request-accept-article
11172 (if select-method select-method to-newsgroup)
11173 (not articles)))))))
11174 (if (not art-group)
11175 (gnus-message 1 "Couldn't %s article %s"
11176 (cadr (assq action names)) article)
11179 (gnus-gethash (car art-group) gnus-newsrc-hashtb)
11181 (gnus-group-prefixed-name
11183 (if select-method (list select-method "")
11184 (gnus-find-method-for-group to-newsgroup)))
11185 gnus-newsrc-hashtb)))
11186 (info (nth 2 entry)))
11187 ;; Update the group that has been moved to.
11189 (memq action '(move copy)))
11190 (unless (memq article gnus-newsgroup-unreads)
11191 (gnus-info-set-read
11192 info (gnus-add-to-range (gnus-info-read info)
11193 (list (cdr art-group)))))
11195 ;; Copy any marks over to the new group.
11196 (let ((marks gnus-article-mark-lists)
11197 (to-article (cdr art-group)))
11199 ;; See whether the article is to be put in the cache.
11200 (when gnus-use-cache
11201 (gnus-cache-possibly-enter-article
11202 (gnus-info-group info) to-article
11203 (let ((header (copy-sequence
11204 (gnus-summary-article-header article))))
11205 (mail-header-set-number header to-article)
11207 (memq article gnus-newsgroup-marked)
11208 (memq article gnus-newsgroup-dormant)
11209 (memq article gnus-newsgroup-unreads)))
11212 (when (memq article (symbol-value
11213 (intern (format "gnus-newsgroup-%s"
11215 (gnus-add-marked-articles
11216 (gnus-info-group info) (cdar marks)
11217 (list to-article) info))
11218 (setq marks (cdr marks)))))
11220 ;; Update the Xref header in this article to point to
11221 ;; the new crossposted article we have just created.
11222 (when (eq action 'crosspost)
11224 (set-buffer copy-buf)
11225 (gnus-request-article-this-buffer article gnus-newsgroup-name)
11226 (nnheader-replace-header
11227 "xref" (concat new-xref " " (gnus-group-prefixed-name
11228 (car art-group) to-method)
11229 ":" (cdr art-group)))
11230 (gnus-request-replace-article
11231 article gnus-newsgroup-name (current-buffer)))))
11233 (gnus-summary-goto-subject article)
11234 (when (eq action 'move)
11235 (gnus-summary-mark-article article gnus-canceled-mark)))
11236 (gnus-summary-remove-process-mark article))
11237 (gnus-kill-buffer copy-buf)
11238 (gnus-summary-position-point)
11239 (gnus-set-mode-line 'summary)))
11241 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
11242 "Move the current article to a different newsgroup.
11243 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
11244 If SELECT-METHOD is symbol, do not move to a specific newsgroup, but
11245 re-spool using this method."
11247 (gnus-summary-move-article n nil select-method 'copy))
11249 (defun gnus-summary-crosspost-article (&optional n)
11250 "Crosspost the current article to some other group."
11252 (gnus-summary-move-article n nil nil 'crosspost))
11254 (defun gnus-summary-respool-article (&optional n respool-method)
11255 "Respool the current article.
11256 The article will be squeezed through the mail spooling process again,
11257 which means that it will be put in some mail newsgroup or other
11258 depending on `nnmail-split-methods'.
11259 If N is a positive number, respool the N next articles.
11260 If N is a negative number, respool the N previous articles.
11261 If N is nil and any articles have been marked with the process mark,
11262 respool those articles instead.
11264 Respooling can be done both from mail groups and \"real\" newsgroups.
11265 In the former case, the articles in question will be moved from the
11266 current group into whatever groups they are destined to. In the
11267 latter case, they will be copied into the relevant groups."
11269 (gnus-set-global-variables)
11270 (let ((respool-methods (gnus-methods-using 'respool))
11272 (symbol-name (car (gnus-find-method-for-group gnus-newsgroup-name)))))
11274 (setq respool-method
11276 "What method do you want to use when respooling? "
11277 respool-methods nil t methname)))
11278 (or (string= respool-method "")
11279 (if (assoc (symbol-name
11280 (car (gnus-find-method-for-group gnus-newsgroup-name)))
11282 (gnus-summary-move-article n nil (intern respool-method))
11283 (gnus-summary-copy-article n nil (intern respool-method))))))
11285 (defun gnus-summary-import-article (file)
11286 "Import a random file into a mail newsgroup."
11287 (interactive "fImport file: ")
11288 (gnus-set-global-variables)
11289 (let ((group gnus-newsgroup-name)
11290 (now (current-time))
11292 (or (gnus-check-backend-function 'request-accept-article group)
11293 (error "%s does not support article importing" group))
11294 (or (file-readable-p file)
11295 (not (file-regular-p file))
11296 (error "Can't read %s" file))
11298 (set-buffer (get-buffer-create " *import file*"))
11299 (buffer-disable-undo (current-buffer))
11301 (insert-file-contents file)
11302 (goto-char (point-min))
11303 (unless (nnheader-article-p)
11304 ;; This doesn't look like an article, so we fudge some headers.
11305 (setq atts (file-attributes file)
11306 lines (count-lines (point-min) (point-max)))
11307 (insert "From: " (read-string "From: ") "\n"
11308 "Subject: " (read-string "Subject: ") "\n"
11309 "Date: " (timezone-make-date-arpa-standard
11310 (current-time-string (nth 5 atts))
11311 (current-time-zone now)
11312 (current-time-zone now)) "\n"
11313 "Message-ID: " (gnus-inews-message-id) "\n"
11314 "Lines: " (int-to-string lines) "\n"
11315 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
11316 (gnus-request-accept-article group t)
11317 (kill-buffer (current-buffer)))))
11319 (defun gnus-summary-expire-articles ()
11320 "Expire all articles that are marked as expirable in the current group."
11322 (gnus-set-global-variables)
11323 (when (gnus-check-backend-function
11324 'request-expire-articles gnus-newsgroup-name)
11325 ;; This backend supports expiry.
11326 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
11327 (expirable (if total
11328 (gnus-list-of-read-articles gnus-newsgroup-name)
11329 (setq gnus-newsgroup-expirable
11330 (sort gnus-newsgroup-expirable '<))))
11331 (expiry-wait (gnus-group-get-parameter
11332 gnus-newsgroup-name 'expiry-wait))
11335 ;; There are expirable articles in this group, so we run them
11336 ;; through the expiry process.
11337 (gnus-message 6 "Expiring articles...")
11338 ;; The list of articles that weren't expired is returned.
11340 (let ((nnmail-expiry-wait-function nil)
11341 (nnmail-expiry-wait expiry-wait))
11342 (setq es (gnus-request-expire-articles
11343 expirable gnus-newsgroup-name)))
11344 (setq es (gnus-request-expire-articles
11345 expirable gnus-newsgroup-name)))
11346 (or total (setq gnus-newsgroup-expirable es))
11347 ;; We go through the old list of expirable, and mark all
11348 ;; really expired articles as nonexistent.
11349 (unless (eq es expirable) ;If nothing was expired, we don't mark.
11350 (let ((gnus-use-cache nil))
11352 (unless (memq (car expirable) es)
11353 (when (gnus-data-find (car expirable))
11354 (gnus-summary-mark-article
11355 (car expirable) gnus-canceled-mark)))
11356 (setq expirable (cdr expirable)))))
11357 (gnus-message 6 "Expiring articles...done")))))
11359 (defun gnus-summary-expire-articles-now ()
11360 "Expunge all expirable articles in the current group.
11361 This means that *all* articles that are marked as expirable will be
11362 deleted forever, right now."
11364 (gnus-set-global-variables)
11365 (or gnus-expert-user
11367 "Are you really, really, really sure you want to expunge? ")
11369 (let ((nnmail-expiry-wait 'immediate)
11370 (nnmail-expiry-wait-function nil))
11371 (gnus-summary-expire-articles)))
11373 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
11374 (defun gnus-summary-delete-article (&optional n)
11375 "Delete the N next (mail) articles.
11376 This command actually deletes articles. This is not a marking
11377 command. The article will disappear forever from your life, never to
11379 If N is negative, delete backwards.
11380 If N is nil and articles have been marked with the process mark,
11381 delete these instead."
11383 (gnus-set-global-variables)
11384 (or (gnus-check-backend-function 'request-expire-articles
11385 gnus-newsgroup-name)
11386 (error "The current newsgroup does not support article deletion."))
11387 ;; Compute the list of articles to delete.
11388 (let ((articles (gnus-summary-work-articles n))
11390 (if (and gnus-novice-user
11391 (not (gnus-y-or-n-p
11392 (format "Do you really want to delete %s forever? "
11393 (if (> (length articles) 1) "these articles"
11394 "this article")))))
11396 ;; Delete the articles.
11397 (setq not-deleted (gnus-request-expire-articles
11398 articles gnus-newsgroup-name 'force))
11400 (gnus-summary-remove-process-mark (car articles))
11401 ;; The backend might not have been able to delete the article
11403 (or (memq (car articles) not-deleted)
11404 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
11405 (setq articles (cdr articles))))
11406 (gnus-summary-position-point)
11407 (gnus-set-mode-line 'summary)
11410 (defun gnus-summary-edit-article (&optional force)
11411 "Enter into a buffer and edit the current article.
11412 This will have permanent effect only in mail groups.
11413 If FORCE is non-nil, allow editing of articles even in read-only
11417 (set-buffer gnus-summary-buffer)
11418 (gnus-set-global-variables)
11419 (when (and (not force)
11420 (gnus-group-read-only-p))
11421 (error "The current newsgroup does not support article editing."))
11422 (gnus-summary-select-article t nil t)
11423 (gnus-configure-windows 'article)
11424 (select-window (get-buffer-window gnus-article-buffer))
11425 (gnus-message 6 "C-c C-c to end edits")
11426 (setq buffer-read-only nil)
11428 (use-local-map (copy-keymap (current-local-map)))
11429 (local-set-key "\C-c\C-c" 'gnus-summary-edit-article-done)
11430 (buffer-enable-undo)
11432 (goto-char (point-min))
11433 (search-forward "\n\n" nil t)))
11435 (defun gnus-summary-edit-article-done ()
11436 "Make edits to the current article permanent."
11438 (if (gnus-group-read-only-p)
11440 (gnus-summary-edit-article-postpone)
11442 1 "The current newsgroup does not support article editing.")
11444 (let ((buf (format "%s" (buffer-string))))
11447 (if (not (gnus-request-replace-article
11448 (cdr gnus-article-current) (car gnus-article-current)
11450 (error "Couldn't replace article.")
11451 (gnus-article-mode)
11452 (use-local-map gnus-article-mode-map)
11453 (setq buffer-read-only t)
11454 (buffer-disable-undo (current-buffer))
11455 (gnus-configure-windows 'summary)
11456 (gnus-summary-update-article (cdr gnus-article-current))
11457 (when gnus-use-cache
11458 (gnus-cache-update-article
11459 (cdr gnus-article-current) (car gnus-article-current))))
11460 (run-hooks 'gnus-article-display-hook)
11461 (and (gnus-visual-p 'summary-highlight 'highlight)
11462 (run-hooks 'gnus-visual-mark-article-hook)))))
11464 (defun gnus-summary-edit-article-postpone ()
11465 "Postpone changes to the current article."
11467 (gnus-article-mode)
11468 (use-local-map gnus-article-mode-map)
11469 (setq buffer-read-only t)
11470 (buffer-disable-undo (current-buffer))
11471 (gnus-configure-windows 'summary)
11472 (and (gnus-visual-p 'summary-highlight 'highlight)
11473 (run-hooks 'gnus-visual-mark-article-hook)))
11475 (defun gnus-summary-respool-query ()
11476 "Query where the respool algorithm would put this article."
11478 (gnus-set-global-variables)
11479 (gnus-summary-select-article)
11481 (set-buffer gnus-article-buffer)
11483 (goto-char (point-min))
11484 (search-forward "\n\n")
11485 (narrow-to-region (point-min) (point))
11486 (pp-eval-expression
11487 (list 'quote (mapcar 'car (nnmail-article-group 'identity)))))))
11489 ;; Summary score commands.
11491 ;; Suggested by boubaker@cenatls.cena.dgac.fr.
11493 (defun gnus-summary-raise-score (n)
11494 "Raise the score of the current article by N."
11496 (gnus-set-global-variables)
11497 (gnus-summary-set-score (+ (gnus-summary-article-score) n)))
11499 (defun gnus-summary-set-score (n)
11500 "Set the score of the current article to N."
11502 (gnus-set-global-variables)
11504 (gnus-summary-show-thread)
11505 (let ((buffer-read-only nil))
11507 (gnus-summary-update-mark
11508 (if (= n (or gnus-summary-default-score 0)) ?
11509 (if (< n (or gnus-summary-default-score 0))
11510 gnus-score-below-mark gnus-score-over-mark)) 'score))
11511 (let* ((article (gnus-summary-article-number))
11512 (score (assq article gnus-newsgroup-scored)))
11513 (if score (setcdr score n)
11514 (setq gnus-newsgroup-scored
11515 (cons (cons article n) gnus-newsgroup-scored))))
11516 (gnus-summary-update-line)))
11518 (defun gnus-summary-current-score ()
11519 "Return the score of the current article."
11521 (gnus-set-global-variables)
11522 (message "%s" (gnus-summary-article-score)))
11524 ;; Summary marking commands.
11526 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
11527 "Mark articles which has the same subject as read, and then select the next.
11528 If UNMARK is positive, remove any kind of mark.
11529 If UNMARK is negative, tick articles."
11531 (gnus-set-global-variables)
11533 (setq unmark (prefix-numeric-value unmark)))
11535 (gnus-summary-mark-same-subject
11536 (gnus-summary-article-subject) unmark)))
11537 ;; Select next unread article. If auto-select-same mode, should
11538 ;; select the first unread article.
11539 (gnus-summary-next-article t (and gnus-auto-select-same
11540 (gnus-summary-article-subject)))
11541 (gnus-message 7 "%d article%s marked as %s"
11542 count (if (= count 1) " is" "s are")
11543 (if unmark "unread" "read"))))
11545 (defun gnus-summary-kill-same-subject (&optional unmark)
11546 "Mark articles which has the same subject as read.
11547 If UNMARK is positive, remove any kind of mark.
11548 If UNMARK is negative, tick articles."
11550 (gnus-set-global-variables)
11552 (setq unmark (prefix-numeric-value unmark)))
11554 (gnus-summary-mark-same-subject
11555 (gnus-summary-article-subject) unmark)))
11556 ;; If marked as read, go to next unread subject.
11558 ;; Go to next unread subject.
11559 (gnus-summary-next-subject 1 t))
11560 (gnus-message 7 "%d articles are marked as %s"
11561 count (if unmark "unread" "read"))))
11563 (defun gnus-summary-mark-same-subject (subject &optional unmark)
11564 "Mark articles with same SUBJECT as read, and return marked number.
11565 If optional argument UNMARK is positive, remove any kinds of marks.
11566 If optional argument UNMARK is negative, mark articles as unread instead."
11570 ((null unmark) ; Mark as read.
11573 (gnus-summary-mark-article-as-read gnus-killed-mark)
11574 (gnus-summary-show-thread) t)
11575 (gnus-summary-find-subject subject))
11576 (setq count (1+ count))))
11577 ((> unmark 0) ; Tick.
11580 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
11581 (gnus-summary-show-thread) t)
11582 (gnus-summary-find-subject subject))
11583 (setq count (1+ count))))
11584 (t ; Mark as unread.
11587 (gnus-summary-mark-article-as-unread gnus-unread-mark)
11588 (gnus-summary-show-thread) t)
11589 (gnus-summary-find-subject subject))
11590 (setq count (1+ count)))))
11591 (gnus-set-mode-line 'summary)
11592 ;; Return the number of marked articles.
11595 (defun gnus-summary-mark-as-processable (n &optional unmark)
11596 "Set the process mark on the next N articles.
11597 If N is negative, mark backward instead. If UNMARK is non-nil, remove
11598 the process mark instead. The difference between N and the actual
11599 number of articles marked is returned."
11601 (gnus-set-global-variables)
11602 (let ((backward (< n 0))
11607 (gnus-summary-remove-process-mark
11608 (gnus-summary-article-number))
11609 (gnus-summary-set-process-mark (gnus-summary-article-number)))
11610 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
11612 (if (/= 0 n) (gnus-message 7 "No more articles"))
11613 (gnus-summary-recenter)
11614 (gnus-summary-position-point)
11617 (defun gnus-summary-unmark-as-processable (n)
11618 "Remove the process mark from the next N articles.
11619 If N is negative, mark backward instead. The difference between N and
11620 the actual number of articles marked is returned."
11622 (gnus-set-global-variables)
11623 (gnus-summary-mark-as-processable n t))
11625 (defun gnus-summary-unmark-all-processable ()
11626 "Remove the process mark from all articles."
11628 (gnus-set-global-variables)
11630 (while gnus-newsgroup-processable
11631 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
11632 (gnus-summary-position-point))
11634 (defun gnus-summary-mark-as-expirable (n)
11635 "Mark N articles forward as expirable.
11636 If N is negative, mark backward instead. The difference between N and
11637 the actual number of articles marked is returned."
11639 (gnus-set-global-variables)
11640 (gnus-summary-mark-forward n gnus-expirable-mark))
11642 (defun gnus-summary-mark-article-as-replied (article)
11643 "Mark ARTICLE replied and update the summary line."
11644 (setq gnus-newsgroup-replied (cons article gnus-newsgroup-replied))
11645 (let ((buffer-read-only nil))
11646 (when (gnus-summary-goto-subject article)
11647 (gnus-summary-update-secondary-mark article))))
11649 (defun gnus-summary-set-bookmark (article)
11650 "Set a bookmark in current article."
11651 (interactive (list (gnus-summary-article-number)))
11652 (gnus-set-global-variables)
11653 (if (or (not (get-buffer gnus-article-buffer))
11654 (not gnus-current-article)
11655 (not gnus-article-current)
11656 (not (equal gnus-newsgroup-name (car gnus-article-current))))
11657 (error "No current article selected"))
11658 ;; Remove old bookmark, if one exists.
11659 (let ((old (assq article gnus-newsgroup-bookmarks)))
11660 (if old (setq gnus-newsgroup-bookmarks
11661 (delq old gnus-newsgroup-bookmarks))))
11662 ;; Set the new bookmark, which is on the form
11663 ;; (article-number . line-number-in-body).
11664 (setq gnus-newsgroup-bookmarks
11668 (set-buffer gnus-article-buffer)
11672 (goto-char (point-min))
11673 (search-forward "\n\n" nil t)
11676 gnus-newsgroup-bookmarks))
11677 (gnus-message 6 "A bookmark has been added to the current article."))
11679 (defun gnus-summary-remove-bookmark (article)
11680 "Remove the bookmark from the current article."
11681 (interactive (list (gnus-summary-article-number)))
11682 (gnus-set-global-variables)
11683 ;; Remove old bookmark, if one exists.
11684 (let ((old (assq article gnus-newsgroup-bookmarks)))
11687 (setq gnus-newsgroup-bookmarks
11688 (delq old gnus-newsgroup-bookmarks))
11689 (gnus-message 6 "Removed bookmark."))
11690 (gnus-message 6 "No bookmark in current article."))))
11692 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11693 (defun gnus-summary-mark-as-dormant (n)
11694 "Mark N articles forward as dormant.
11695 If N is negative, mark backward instead. The difference between N and
11696 the actual number of articles marked is returned."
11698 (gnus-set-global-variables)
11699 (gnus-summary-mark-forward n gnus-dormant-mark))
11701 (defun gnus-summary-set-process-mark (article)
11702 "Set the process mark on ARTICLE and update the summary line."
11703 (setq gnus-newsgroup-processable
11705 (delq article gnus-newsgroup-processable)))
11706 (when (gnus-summary-goto-subject article)
11707 (gnus-summary-show-thread)
11708 (gnus-summary-update-secondary-mark article)))
11710 (defun gnus-summary-remove-process-mark (article)
11711 "Remove the process mark from ARTICLE and update the summary line."
11712 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
11713 (when (gnus-summary-goto-subject article)
11714 (gnus-summary-show-thread)
11715 (gnus-summary-update-secondary-mark article)))
11717 (defun gnus-summary-set-saved-mark (article)
11718 "Set the process mark on ARTICLE and update the summary line."
11719 (push article gnus-newsgroup-saved)
11720 (when (gnus-summary-goto-subject article)
11721 (gnus-summary-update-secondary-mark article)))
11723 (defun gnus-summary-mark-forward (n &optional mark no-expire)
11724 "Mark N articles as read forwards.
11725 If N is negative, mark backwards instead.
11726 Mark with MARK. If MARK is ? , ?! or ??, articles will be
11728 The difference between N and the actual number of articles marked is
11731 (gnus-set-global-variables)
11732 (let ((backward (< n 0))
11733 (gnus-summary-goto-unread
11734 (and gnus-summary-goto-unread
11735 (not (eq gnus-summary-goto-unread 'never))
11736 (not (memq mark (list gnus-unread-mark
11737 gnus-ticked-mark gnus-dormant-mark)))))
11739 (mark (or mark gnus-del-mark)))
11740 (while (and (> n 0)
11741 (gnus-summary-mark-article nil mark no-expire)
11742 (zerop (gnus-summary-next-subject
11744 (and gnus-summary-goto-unread
11745 (not (eq gnus-summary-goto-unread 'never)))
11748 (if (/= 0 n) (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11749 (gnus-summary-recenter)
11750 (gnus-summary-position-point)
11751 (gnus-set-mode-line 'summary)
11754 (defun gnus-summary-mark-article-as-read (mark)
11755 "Mark the current article quickly as read with MARK."
11756 (let ((article (gnus-summary-article-number)))
11757 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11758 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11759 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11760 (setq gnus-newsgroup-reads
11761 (cons (cons article mark) gnus-newsgroup-reads))
11762 ;; Possibly remove from cache, if that is used.
11763 (and gnus-use-cache (gnus-cache-enter-remove-article article))
11764 ;; Allow the backend to change the mark.
11765 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11766 ;; Check for auto-expiry.
11767 (when (and gnus-newsgroup-auto-expire
11768 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11769 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11770 (= mark gnus-ancient-mark)
11771 (= mark gnus-read-mark) (= mark gnus-souped-mark)))
11772 (setq mark gnus-expirable-mark)
11773 (push article gnus-newsgroup-expirable))
11774 ;; Set the mark in the buffer.
11775 (gnus-summary-update-mark mark 'unread)
11778 (defun gnus-summary-mark-article-as-unread (mark)
11779 "Mark the current article quickly as unread with MARK."
11780 (let ((article (gnus-summary-article-number)))
11781 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11782 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11783 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11784 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11785 (cond ((= mark gnus-ticked-mark)
11786 (push article gnus-newsgroup-marked))
11787 ((= mark gnus-dormant-mark)
11788 (push article gnus-newsgroup-dormant))
11790 (push article gnus-newsgroup-unreads)))
11791 (setq gnus-newsgroup-reads
11792 (delq (assq article gnus-newsgroup-reads)
11793 gnus-newsgroup-reads))
11795 ;; See whether the article is to be put in the cache.
11796 (and gnus-use-cache
11797 (vectorp (gnus-summary-article-header article))
11799 (gnus-cache-possibly-enter-article
11800 gnus-newsgroup-name article
11801 (gnus-summary-article-header article)
11802 (= mark gnus-ticked-mark)
11803 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11806 (gnus-summary-update-mark mark 'unread)
11809 (defun gnus-summary-mark-article (&optional article mark no-expire)
11810 "Mark ARTICLE with MARK. MARK can be any character.
11811 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11812 `??' (dormant) and `?E' (expirable).
11813 If MARK is nil, then the default character `?D' is used.
11814 If ARTICLE is nil, then the article on the current line will be
11816 ;; The mark might be a string.
11817 (and (stringp mark)
11818 (setq mark (aref mark 0)))
11819 ;; If no mark is given, then we check auto-expiring.
11820 (and (not no-expire)
11821 gnus-newsgroup-auto-expire
11823 (and (numberp mark)
11824 (or (= mark gnus-killed-mark) (= mark gnus-del-mark)
11825 (= mark gnus-catchup-mark) (= mark gnus-low-score-mark)
11826 (= mark gnus-read-mark) (= mark gnus-souped-mark))))
11827 (setq mark gnus-expirable-mark))
11828 (let* ((mark (or mark gnus-del-mark))
11829 (article (or article (gnus-summary-article-number))))
11830 (or article (error "No article on current line"))
11831 (if (or (= mark gnus-unread-mark)
11832 (= mark gnus-ticked-mark)
11833 (= mark gnus-dormant-mark))
11834 (gnus-mark-article-as-unread article mark)
11835 (gnus-mark-article-as-read article mark))
11837 ;; See whether the article is to be put in the cache.
11838 (and gnus-use-cache
11839 (not (= mark gnus-canceled-mark))
11840 (vectorp (gnus-summary-article-header article))
11842 (gnus-cache-possibly-enter-article
11843 gnus-newsgroup-name article
11844 (gnus-summary-article-header article)
11845 (= mark gnus-ticked-mark)
11846 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11848 (if (gnus-summary-goto-subject article nil t)
11849 (let ((buffer-read-only nil))
11850 (gnus-summary-show-thread)
11852 (gnus-summary-update-mark mark 'unread)
11855 (defun gnus-summary-update-secondary-mark (article)
11856 "Update the secondary (read, process, cache) mark."
11857 (gnus-summary-update-mark
11858 (cond ((memq article gnus-newsgroup-processable)
11860 ((memq article gnus-newsgroup-cached)
11862 ((memq article gnus-newsgroup-replied)
11864 ((memq article gnus-newsgroup-saved)
11866 (t gnus-unread-mark))
11868 (when (gnus-visual-p 'summary-highlight 'highlight)
11869 (run-hooks 'gnus-summary-update-hook))
11872 (defun gnus-summary-update-mark (mark type)
11873 (beginning-of-line)
11874 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11875 (buffer-read-only nil))
11877 ;; Go to the right position on the line.
11878 (forward-char forward)
11879 ;; Replace the old mark with the new mark.
11880 (subst-char-in-region (point) (1+ (point)) (following-char) mark)
11881 ;; Optionally update the marks by some user rule.
11882 (when (eq type 'unread)
11883 (gnus-data-set-mark
11884 (gnus-data-find (gnus-summary-article-number)) mark)
11885 (gnus-summary-update-line (eq mark gnus-unread-mark))))))
11887 (defun gnus-mark-article-as-read (article &optional mark)
11888 "Enter ARTICLE in the pertinent lists and remove it from others."
11889 ;; Make the article expirable.
11890 (let ((mark (or mark gnus-del-mark)))
11891 (if (= mark gnus-expirable-mark)
11892 (setq gnus-newsgroup-expirable (cons article gnus-newsgroup-expirable))
11893 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
11894 ;; Remove from unread and marked lists.
11895 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11896 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11897 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11898 (push (cons article mark) gnus-newsgroup-reads)
11899 ;; Possibly remove from cache, if that is used.
11900 (when gnus-use-cache
11901 (gnus-cache-enter-remove-article article))))
11903 (defun gnus-mark-article-as-unread (article &optional mark)
11904 "Enter ARTICLE in the pertinent lists and remove it from others."
11905 (let ((mark (or mark gnus-ticked-mark)))
11906 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11907 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11908 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11909 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11910 (cond ((= mark gnus-ticked-mark)
11911 (push article gnus-newsgroup-marked))
11912 ((= mark gnus-dormant-mark)
11913 (push article gnus-newsgroup-dormant))
11915 (push article gnus-newsgroup-unreads)))
11916 (setq gnus-newsgroup-reads
11917 (delq (assq article gnus-newsgroup-reads)
11918 gnus-newsgroup-reads))))
11920 (defalias 'gnus-summary-mark-as-unread-forward
11921 'gnus-summary-tick-article-forward)
11922 (make-obsolete 'gnus-summary-mark-as-unread-forward
11923 'gnus-summary-tick-article-forward)
11924 (defun gnus-summary-tick-article-forward (n)
11925 "Tick N articles forwards.
11926 If N is negative, tick backwards instead.
11927 The difference between N and the number of articles ticked is returned."
11929 (gnus-summary-mark-forward n gnus-ticked-mark))
11931 (defalias 'gnus-summary-mark-as-unread-backward
11932 'gnus-summary-tick-article-backward)
11933 (make-obsolete 'gnus-summary-mark-as-unread-backward
11934 'gnus-summary-tick-article-backward)
11935 (defun gnus-summary-tick-article-backward (n)
11936 "Tick N articles backwards.
11937 The difference between N and the number of articles ticked is returned."
11939 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11941 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
11942 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
11943 (defun gnus-summary-tick-article (&optional article clear-mark)
11944 "Mark current article as unread.
11945 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11946 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11948 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11949 gnus-ticked-mark)))
11951 (defun gnus-summary-mark-as-read-forward (n)
11952 "Mark N articles as read forwards.
11953 If N is negative, mark backwards instead.
11954 The difference between N and the actual number of articles marked is
11957 (gnus-summary-mark-forward n gnus-del-mark t))
11959 (defun gnus-summary-mark-as-read-backward (n)
11960 "Mark the N articles as read backwards.
11961 The difference between N and the actual number of articles marked is
11964 (gnus-summary-mark-forward (- n) gnus-del-mark t))
11966 (defun gnus-summary-mark-as-read (&optional article mark)
11967 "Mark current article as read.
11968 ARTICLE specifies the article to be marked as read.
11969 MARK specifies a string to be inserted at the beginning of the line."
11970 (gnus-summary-mark-article article mark))
11972 (defun gnus-summary-clear-mark-forward (n)
11973 "Clear marks from N articles forward.
11974 If N is negative, clear backward instead.
11975 The difference between N and the number of marks cleared is returned."
11977 (gnus-summary-mark-forward n gnus-unread-mark))
11979 (defun gnus-summary-clear-mark-backward (n)
11980 "Clear marks from N articles backward.
11981 The difference between N and the number of marks cleared is returned."
11983 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11985 (defun gnus-summary-mark-unread-as-read ()
11986 "Intended to be used by `gnus-summary-mark-article-hook'."
11987 (when (memq gnus-current-article gnus-newsgroup-unreads)
11988 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11990 (defun gnus-summary-mark-read-and-unread-as-read ()
11991 "Intended to be used by `gnus-summary-mark-article-hook'."
11992 (let ((mark (gnus-summary-article-mark)))
11993 (when (or (gnus-unread-mark-p mark)
11994 (gnus-read-mark-p mark))
11995 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
11997 (defun gnus-summary-mark-region-as-read (point mark all)
11998 "Mark all unread articles between point and mark as read.
11999 If given a prefix, mark all articles between point and mark as read,
12000 even ticked and dormant ones."
12001 (interactive "r\nP")
12005 (beginning-of-line)
12010 (memq (setq article (gnus-summary-article-number))
12011 gnus-newsgroup-unreads))
12012 (gnus-summary-mark-article article gnus-del-mark))
12014 (gnus-summary-find-next))))))
12016 (defun gnus-summary-mark-below (score mark)
12017 "Mark articles with score less than SCORE with MARK."
12018 (interactive "P\ncMark: ")
12019 (gnus-set-global-variables)
12020 (setq score (if score
12021 (prefix-numeric-value score)
12022 (or gnus-summary-default-score 0)))
12024 (set-buffer gnus-summary-buffer)
12025 (goto-char (point-min))
12028 (and (< (gnus-summary-article-score) score)
12029 (gnus-summary-mark-article nil mark))
12030 (gnus-summary-find-next)))))
12032 (defun gnus-summary-kill-below (&optional score)
12033 "Mark articles with score below SCORE as read."
12035 (gnus-set-global-variables)
12036 (gnus-summary-mark-below score gnus-killed-mark))
12038 (defun gnus-summary-clear-above (&optional score)
12039 "Clear all marks from articles with score above SCORE."
12041 (gnus-set-global-variables)
12042 (gnus-summary-mark-above score gnus-unread-mark))
12044 (defun gnus-summary-tick-above (&optional score)
12045 "Tick all articles with score above SCORE."
12047 (gnus-set-global-variables)
12048 (gnus-summary-mark-above score gnus-ticked-mark))
12050 (defun gnus-summary-mark-above (score mark)
12051 "Mark articles with score over SCORE with MARK."
12052 (interactive "P\ncMark: ")
12053 (gnus-set-global-variables)
12054 (setq score (if score
12055 (prefix-numeric-value score)
12056 (or gnus-summary-default-score 0)))
12058 (set-buffer gnus-summary-buffer)
12059 (goto-char (point-min))
12061 (if (> (gnus-summary-article-score) score)
12062 (gnus-summary-mark-article nil mark))
12064 (gnus-summary-find-next)))))
12066 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
12067 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
12068 (defun gnus-summary-limit-include-expunged ()
12069 "Display all the hidden articles that were expunged for low scores."
12071 (gnus-set-global-variables)
12072 (let ((buffer-read-only nil))
12073 (let ((scored gnus-newsgroup-scored)
12076 (or (gnus-summary-goto-subject (caar scored))
12077 (and (setq h (gnus-summary-article-header (caar scored)))
12078 (< (cdar scored) gnus-summary-expunge-below)
12079 (setq headers (cons h headers))))
12080 (setq scored (cdr scored)))
12081 (or headers (error "No expunged articles hidden."))
12082 (goto-char (point-min))
12083 (gnus-summary-prepare-unthreaded (nreverse headers)))
12084 (goto-char (point-min))
12085 (gnus-summary-position-point)))
12087 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
12088 "Mark all articles not marked as unread in this newsgroup as read.
12089 If prefix argument ALL is non-nil, all articles are marked as read.
12090 If QUIETLY is non-nil, no questions will be asked.
12091 If TO-HERE is non-nil, it should be a point in the buffer. All
12092 articles before this point will be marked as read.
12093 The number of articles marked as read is returned."
12095 (gnus-set-global-variables)
12098 (not gnus-interactive-catchup) ;Without confirmation?
12102 "Mark absolutely all articles as read? "
12103 "Mark all unread articles as read? ")))
12105 (not gnus-newsgroup-adaptive)
12106 (not gnus-newsgroup-auto-expire))
12109 (setq gnus-newsgroup-marked nil
12110 gnus-newsgroup-dormant nil))
12111 (setq gnus-newsgroup-unreads nil))
12112 ;; We actually mark all articles as canceled, which we
12113 ;; have to do when using auto-expiry or adaptive scoring.
12114 (gnus-summary-show-all-threads)
12115 (if (gnus-summary-first-subject (not all))
12117 (if to-here (< (point) to-here) t)
12118 (gnus-summary-mark-article-as-read gnus-catchup-mark)
12119 (gnus-summary-find-next (not all)))))
12121 (setq gnus-newsgroup-unreads nil))
12122 (gnus-set-mode-line 'summary)))
12123 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
12124 (if (and (not to-here) (eq 'nnvirtual (car method)))
12125 (nnvirtual-catchup-group
12126 (gnus-group-real-name gnus-newsgroup-name) (nth 1 method) all)))
12127 (gnus-summary-position-point)))
12129 (defun gnus-summary-catchup-to-here (&optional all)
12130 "Mark all unticked articles before the current one as read.
12131 If ALL is non-nil, also mark ticked and dormant articles as read."
12133 (gnus-set-global-variables)
12135 (let ((beg (point)))
12136 ;; We check that there are unread articles.
12137 (when (or all (gnus-summary-find-prev))
12138 (gnus-summary-catchup all t beg))))
12139 (gnus-summary-position-point))
12141 (defun gnus-summary-catchup-all (&optional quietly)
12142 "Mark all articles in this newsgroup as read."
12144 (gnus-set-global-variables)
12145 (gnus-summary-catchup t quietly))
12147 (defun gnus-summary-catchup-and-exit (&optional all quietly)
12148 "Mark all articles not marked as unread in this newsgroup as read, then exit.
12149 If prefix argument ALL is non-nil, all articles are marked as read."
12151 (gnus-set-global-variables)
12152 (gnus-summary-catchup all quietly nil 'fast)
12153 ;; Select next newsgroup or exit.
12154 (if (eq gnus-auto-select-next 'quietly)
12155 (gnus-summary-next-group nil)
12156 (gnus-summary-exit)))
12158 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
12159 "Mark all articles in this newsgroup as read, and then exit."
12161 (gnus-set-global-variables)
12162 (gnus-summary-catchup-and-exit t quietly))
12164 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
12165 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
12166 "Mark all articles in this group as read and select the next group.
12167 If given a prefix, mark all articles, unread as well as ticked, as
12170 (gnus-set-global-variables)
12172 (gnus-summary-catchup all))
12173 (gnus-summary-next-article t nil nil t))
12175 ;; Thread-based commands.
12177 (defun gnus-summary-articles-in-thread (&optional article)
12178 "Return a list of all articles in the current thread.
12179 If ARTICLE is non-nil, return all articles in the thread that starts
12180 with that article."
12181 (let* ((article (or article (gnus-summary-article-number)))
12182 (data (gnus-data-find-list article))
12183 (top-level (gnus-data-level (car data)))
12185 (cond ((null gnus-thread-operation-ignore-subject)
12186 (gnus-simplify-subject-re
12187 (mail-header-subject (gnus-data-header (car data)))))
12188 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
12189 (gnus-simplify-subject-fuzzy
12190 (mail-header-subject (gnus-data-header (car data)))))
12194 () ; This article doesn't exist.
12196 (and (or (not top-subject)
12197 (string= top-subject
12198 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
12199 (gnus-simplify-subject-fuzzy
12200 (mail-header-subject
12201 (gnus-data-header (car data))))
12202 (gnus-simplify-subject-re
12203 (mail-header-subject
12204 (gnus-data-header (car data)))))))
12205 (setq articles (cons (gnus-data-number (car data)) articles)))
12206 (if (and (setq data (cdr data))
12207 (> (gnus-data-level (car data)) top-level))
12210 ;; Return the list of articles.
12211 (nreverse articles))))
12213 (defun gnus-summary-rethread-current ()
12214 "Rethread the thread the current article is part of."
12216 (gnus-set-global-variables)
12217 (let* ((gnus-show-threads t)
12218 (article (gnus-summary-article-number))
12219 (id (mail-header-id (gnus-summary-article-header)))
12220 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
12222 (error "No article on the current line"))
12223 (gnus-rebuild-thread id)
12224 (gnus-summary-goto-subject article)))
12226 (defun gnus-summary-reparent-thread ()
12227 "Make current article child of the marked (or previous) article.
12229 Note that the re-threading will only work if `gnus-thread-ignore-subject'
12230 is non-nil or the Subject: of both articles are the same."
12232 (or (not (gnus-group-read-only-p))
12233 (error "The current newsgroup does not support article editing."))
12234 (or (<= (length gnus-newsgroup-processable) 1)
12235 (error "No more than one article may be marked."))
12236 (save-window-excursion
12237 (let ((gnus-article-buffer " *reparent*")
12238 (current-article (gnus-summary-article-number))
12239 ; first grab the marked article, otherwise one line up.
12240 (parent-article (if (not (null gnus-newsgroup-processable))
12241 (car gnus-newsgroup-processable)
12243 (if (eq (forward-line -1) 0)
12244 (gnus-summary-article-number)
12245 (error "Beginning of summary buffer."))))))
12246 (or (not (eq current-article parent-article))
12247 (error "An article may not be self-referential."))
12248 (let ((message-id (mail-header-id
12249 (gnus-summary-article-header parent-article))))
12250 (or (and message-id (not (equal message-id "")))
12251 (error "No message-id in desired parent."))
12252 (gnus-summary-select-article t t nil current-article)
12253 (set-buffer gnus-article-buffer)
12254 (setq buffer-read-only nil)
12255 (let ((buf (format "%s" (buffer-string))))
12258 (goto-char (point-min))
12259 (if (search-forward-regexp "^References: " nil t)
12260 (insert message-id " " )
12261 (insert "References: " message-id "\n"))
12262 (or (gnus-request-replace-article current-article
12263 (car gnus-article-current)
12264 gnus-article-buffer)
12265 (error "Couldn't replace article."))
12266 (set-buffer gnus-summary-buffer)
12267 (gnus-summary-unmark-all-processable)
12268 (gnus-summary-rethread-current)
12269 (message "Article %d is now the child of article %d."
12270 current-article parent-article)))))
12272 (defun gnus-summary-toggle-threads (&optional arg)
12273 "Toggle showing conversation threads.
12274 If ARG is positive number, turn showing conversation threads on."
12276 (gnus-set-global-variables)
12277 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
12278 (setq gnus-show-threads
12279 (if (null arg) (not gnus-show-threads)
12280 (> (prefix-numeric-value arg) 0)))
12281 (gnus-summary-prepare)
12282 (gnus-summary-goto-subject current)
12283 (gnus-summary-position-point)))
12285 (defun gnus-summary-show-all-threads ()
12286 "Show all threads."
12288 (gnus-set-global-variables)
12290 (let ((buffer-read-only nil))
12291 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
12292 (gnus-summary-position-point))
12294 (defun gnus-summary-show-thread ()
12295 "Show thread subtrees.
12296 Returns nil if no thread was there to be shown."
12298 (gnus-set-global-variables)
12299 (let ((buffer-read-only nil)
12301 ;; first goto end then to beg, to have point at beg after let
12302 (end (progn (end-of-line) (point)))
12303 (beg (progn (beginning-of-line) (point))))
12305 ;; Any hidden lines here?
12306 (search-forward "\r" end t)
12307 (subst-char-in-region beg end ?\^M ?\n t)
12309 (gnus-summary-position-point))))
12311 (defun gnus-summary-hide-all-threads ()
12312 "Hide all thread subtrees."
12314 (gnus-set-global-variables)
12316 (goto-char (point-min))
12317 (gnus-summary-hide-thread)
12318 (while (zerop (gnus-summary-next-thread 1 t))
12319 (gnus-summary-hide-thread)))
12320 (gnus-summary-position-point))
12322 (defun gnus-summary-hide-thread ()
12323 "Hide thread subtrees.
12324 Returns nil if no threads were there to be hidden."
12326 (gnus-set-global-variables)
12327 (let ((buffer-read-only nil)
12329 (article (gnus-summary-article-number))
12332 ;; Go forward until either the buffer ends or the subthread
12334 (when (and (not (eobp))
12335 (or (zerop (gnus-summary-next-thread 1 t))
12336 (goto-char (point-max))))
12339 (if (and (> (point) start)
12340 (search-backward "\n" start t))
12342 (subst-char-in-region start (point) ?\n ?\^M)
12343 (gnus-summary-goto-subject article))
12346 ;;(gnus-summary-position-point)
12349 (defun gnus-summary-go-to-next-thread (&optional previous)
12350 "Go to the same level (or less) next thread.
12351 If PREVIOUS is non-nil, go to previous thread instead.
12352 Return the article number moved to, or nil if moving was impossible."
12353 (if (and (eq gnus-summary-make-false-root 'dummy)
12354 (gnus-summary-article-intangible-p))
12355 (let ((beg (point)))
12356 (while (and (zerop (forward-line 1))
12357 (not (gnus-summary-article-intangible-p))))
12363 (let* ((level (gnus-summary-thread-level))
12364 (article (gnus-summary-article-number))
12365 (data (cdr (gnus-data-find-list article (gnus-data-list previous))))
12368 (if (<= (gnus-data-level (car data)) level)
12369 (setq oart (gnus-data-number (car data))
12371 (setq data (cdr data))))
12373 (gnus-summary-goto-subject oart)))))
12375 (defun gnus-summary-next-thread (n &optional silent)
12376 "Go to the same level next N'th thread.
12377 If N is negative, search backward instead.
12378 Returns the difference between N and the number of skips actually
12381 If SILENT, don't output messages."
12383 (gnus-set-global-variables)
12384 (let ((backward (< n 0))
12387 (while (and (> n 0)
12388 (setq old (save-excursion
12390 (setq int (gnus-summary-article-intangible-p))
12393 (gnus-summary-go-to-next-thread backward)))
12394 (when (and (eq gnus-summary-make-false-root 'dummy)
12395 (setq dum (text-property-not-all
12396 old (point) 'gnus-intangible nil)))
12400 (gnus-summary-position-point))
12401 (when (and (not silent) (/= 0 n))
12402 (gnus-message 7 "No more threads"))
12405 (defun gnus-summary-prev-thread (n)
12406 "Go to the same level previous N'th thread.
12407 Returns the difference between N and the number of skips actually
12410 (gnus-set-global-variables)
12411 (gnus-summary-next-thread (- n)))
12413 (defun gnus-summary-go-down-thread ()
12414 "Go down one level in the current thread."
12415 (let ((children (gnus-summary-article-children)))
12417 (gnus-summary-goto-subject (car children)))))
12419 (defun gnus-summary-go-up-thread ()
12420 "Go up one level in the current thread."
12421 (let ((parent (gnus-summary-article-parent)))
12423 (gnus-summary-goto-subject parent))))
12425 (defun gnus-summary-down-thread (n)
12426 "Go down thread N steps.
12427 If N is negative, go up instead.
12428 Returns the difference between N and how many steps down that were
12431 (gnus-set-global-variables)
12434 (while (and (> n 0)
12435 (if up (gnus-summary-go-up-thread)
12436 (gnus-summary-go-down-thread)))
12438 (gnus-summary-position-point)
12439 (if (/= 0 n) (gnus-message 7 "Can't go further"))
12442 (defun gnus-summary-up-thread (n)
12443 "Go up thread N steps.
12444 If N is negative, go up instead.
12445 Returns the difference between N and how many steps down that were
12448 (gnus-set-global-variables)
12449 (gnus-summary-down-thread (- n)))
12451 (defun gnus-summary-top-thread ()
12452 "Go to the top of the thread."
12454 (gnus-set-global-variables)
12455 (while (gnus-summary-go-up-thread))
12456 (gnus-summary-article-number))
12458 (defun gnus-summary-kill-thread (&optional unmark)
12459 "Mark articles under current thread as read.
12460 If the prefix argument is positive, remove any kinds of marks.
12461 If the prefix argument is negative, tick articles instead."
12463 (gnus-set-global-variables)
12465 (setq unmark (prefix-numeric-value unmark)))
12466 (let ((articles (gnus-summary-articles-in-thread)))
12468 ;; Expand the thread.
12469 (gnus-summary-show-thread)
12470 ;; Mark all the articles.
12472 (gnus-summary-goto-subject (car articles))
12473 (cond ((null unmark)
12474 (gnus-summary-mark-article-as-read gnus-killed-mark))
12476 (gnus-summary-mark-article-as-unread gnus-unread-mark))
12478 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
12479 (setq articles (cdr articles))))
12480 ;; Hide killed subtrees.
12482 gnus-thread-hide-killed
12483 (gnus-summary-hide-thread))
12484 ;; If marked as read, go to next unread subject.
12486 ;; Go to next unread subject.
12487 (gnus-summary-next-subject 1 t)))
12488 (gnus-set-mode-line 'summary))
12490 ;; Summary sorting commands
12492 (defun gnus-summary-sort-by-number (&optional reverse)
12493 "Sort summary buffer by article number.
12494 Argument REVERSE means reverse order."
12496 (gnus-summary-sort 'number reverse))
12498 (defun gnus-summary-sort-by-author (&optional reverse)
12499 "Sort summary buffer by author name alphabetically.
12500 If case-fold-search is non-nil, case of letters is ignored.
12501 Argument REVERSE means reverse order."
12503 (gnus-summary-sort 'author reverse))
12505 (defun gnus-summary-sort-by-subject (&optional reverse)
12506 "Sort summary buffer by subject alphabetically. `Re:'s are ignored.
12507 If case-fold-search is non-nil, case of letters is ignored.
12508 Argument REVERSE means reverse order."
12510 (gnus-summary-sort 'subject reverse))
12512 (defun gnus-summary-sort-by-date (&optional reverse)
12513 "Sort summary buffer by date.
12514 Argument REVERSE means reverse order."
12516 (gnus-summary-sort 'date reverse))
12518 (defun gnus-summary-sort-by-score (&optional reverse)
12519 "Sort summary buffer by score.
12520 Argument REVERSE means reverse order."
12522 (gnus-summary-sort 'score reverse))
12524 (defun gnus-summary-sort (predicate reverse)
12525 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12526 (gnus-set-global-variables)
12527 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12528 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12529 (gnus-thread-sort-functions
12534 (,thread t2 t1)))))
12535 (gnus-article-sort-functions
12540 (,article t2 t1)))))
12542 (gnus-summary-prepare-hook nil))
12543 ;; We do the sorting by regenerating the threads.
12544 (gnus-summary-prepare)
12545 ;; Hide subthreads if needed.
12546 (when (and gnus-show-threads gnus-thread-hide-subtree)
12547 (gnus-summary-hide-all-threads)))
12548 ;; If in async mode, we send some info to the backend.
12549 (when gnus-newsgroup-async
12550 (gnus-request-asynchronous
12551 gnus-newsgroup-name gnus-newsgroup-data)))
12553 (defun gnus-sortable-date (date)
12554 "Make sortable string by string-lessp from DATE.
12555 Timezone package is used."
12556 (let* ((date (timezone-fix-time date nil nil)) ;[Y M D H M S]
12557 (year (aref date 0))
12558 (month (aref date 1))
12559 (day (aref date 2)))
12560 (timezone-make-sortable-date
12562 (timezone-make-time-string
12563 (aref date 3) (aref date 4) (aref date 5)))))
12565 ;; Summary saving commands.
12567 (defun gnus-summary-save-article (&optional n not-saved)
12568 "Save the current article using the default saver function.
12569 If N is a positive number, save the N next articles.
12570 If N is a negative number, save the N previous articles.
12571 If N is nil and any articles have been marked with the process mark,
12572 save those articles instead.
12573 The variable `gnus-default-article-saver' specifies the saver function."
12575 (gnus-set-global-variables)
12576 (let ((articles (gnus-summary-work-articles n))
12577 file header article)
12579 (setq header (gnus-summary-article-header
12580 (setq article (pop articles))))
12581 (if (not (vectorp header))
12582 ;; This is a pseudo-article.
12583 (if (assq 'name header)
12584 (gnus-copy-file (cdr (assq 'name header)))
12585 (gnus-message 1 "Article %d is unsaveable" article))
12586 ;; This is a real article.
12587 (save-window-excursion
12588 (gnus-summary-select-article t nil nil article))
12589 (unless gnus-save-all-headers
12590 ;; Remove headers accoring to `gnus-saved-headers'.
12591 (let ((gnus-visible-headers
12592 (or gnus-saved-headers gnus-visible-headers)))
12593 (gnus-article-hide-headers nil t)))
12594 ;; Remove any X-Gnus lines.
12596 (set-buffer gnus-article-buffer)
12598 (let ((buffer-read-only nil))
12599 (nnheader-narrow-to-headers)
12600 (while (re-search-forward "^X-Gnus" nil t)
12601 (gnus-delete-line)))))
12602 (save-window-excursion
12603 (if (not gnus-default-article-saver)
12604 (error "No default saver is defined.")
12605 (setq file (funcall
12606 gnus-default-article-saver
12608 ((not gnus-prompt-before-saving)
12610 ((eq gnus-prompt-before-saving 'always)
12613 (gnus-summary-remove-process-mark article)
12615 (gnus-summary-set-saved-mark article))))
12616 (gnus-summary-position-point)
12619 (defun gnus-summary-pipe-output (&optional arg)
12620 "Pipe the current article to a subprocess.
12621 If N is a positive number, pipe the N next articles.
12622 If N is a negative number, pipe the N previous articles.
12623 If N is nil and any articles have been marked with the process mark,
12624 pipe those articles instead."
12626 (gnus-set-global-variables)
12627 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
12628 (gnus-summary-save-article arg t))
12629 (gnus-configure-windows 'pipe))
12631 (defun gnus-summary-save-article-mail (&optional arg)
12632 "Append the current article to an mail file.
12633 If N is a positive number, save the N next articles.
12634 If N is a negative number, save the N previous articles.
12635 If N is nil and any articles have been marked with the process mark,
12636 save those articles instead."
12638 (gnus-set-global-variables)
12639 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12640 (gnus-summary-save-article arg)))
12642 (defun gnus-summary-save-article-rmail (&optional arg)
12643 "Append the current article to an rmail file.
12644 If N is a positive number, save the N next articles.
12645 If N is a negative number, save the N previous articles.
12646 If N is nil and any articles have been marked with the process mark,
12647 save those articles instead."
12649 (gnus-set-global-variables)
12650 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12651 (gnus-summary-save-article arg)))
12653 (defun gnus-summary-save-article-file (&optional arg)
12654 "Append the current article to a file.
12655 If N is a positive number, save the N next articles.
12656 If N is a negative number, save the N previous articles.
12657 If N is nil and any articles have been marked with the process mark,
12658 save those articles instead."
12660 (gnus-set-global-variables)
12661 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12662 (gnus-summary-save-article arg)))
12664 (defun gnus-summary-save-article-body-file (&optional arg)
12665 "Append the current article body to a file.
12666 If N is a positive number, save the N next articles.
12667 If N is a negative number, save the N previous articles.
12668 If N is nil and any articles have been marked with the process mark,
12669 save those articles instead."
12671 (gnus-set-global-variables)
12672 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12673 (gnus-summary-save-article arg)))
12675 (defun gnus-get-split-value (methods)
12676 "Return a value based on the split METHODS."
12677 (let (split-name method result match)
12680 (set-buffer gnus-original-article-buffer)
12682 (nnheader-narrow-to-headers)
12684 (goto-char (point-min))
12685 (setq method (pop methods))
12686 (setq match (car method))
12689 ;; Regular expression.
12691 (re-search-forward match nil t)
12693 ((gnus-functionp match)
12697 (setq result (funcall match gnus-newsgroup-name))))
12702 (setq result (eval match)))))
12703 (setq split-name (append (cdr method) split-name))
12704 (cond ((stringp result)
12705 (push result split-name))
12707 (setq split-name (append result split-name)))))))))
12710 (defun gnus-read-move-group-name (prompt default articles prefix)
12711 "Read a group name."
12712 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12714 (format "Where do you want to %s %s? "
12716 (if (> (length articles) 1)
12717 (format "these %d articles" (length articles))
12725 (format "(default %s) " default)
12727 gnus-active-hashtb nil nil prefix))
12728 ((= 1 (length split-name))
12729 (completing-read prom gnus-active-hashtb
12730 nil nil (cons (car split-name) 0)))
12733 prom (mapcar (lambda (el) (list el)) (nreverse split-name)))))))
12736 (if (or (string= to-newsgroup "")
12737 (string= to-newsgroup prefix))
12738 (setq to-newsgroup (or default "")))
12739 (or (gnus-active to-newsgroup)
12740 (gnus-activate-group to-newsgroup)
12741 (error "No such group: %s" to-newsgroup)))
12744 (defun gnus-read-save-file-name (prompt default-name)
12745 (let* ((split-name (gnus-get-split-value gnus-split-methods))
12747 ;; Let the split methods have their say.
12749 ;; No split name was found.
12752 (concat prompt " (default "
12753 (file-name-nondirectory default-name) ") ")
12754 (file-name-directory default-name)
12756 ;; A single split name was found
12757 ((= 1 (length split-name))
12759 (concat prompt " (default " (car split-name) ") ")
12760 gnus-article-save-directory
12761 (concat gnus-article-save-directory (car split-name))))
12762 ;; A list of splits was found.
12764 (setq split-name (mapcar (lambda (el) (list el))
12765 (nreverse split-name)))
12766 (let ((result (completing-read
12767 (concat prompt " ") split-name nil nil)))
12768 (concat gnus-article-save-directory
12769 (if (string= result "")
12772 ;; If we have read a directory, we append the default file name.
12773 (when (file-directory-p file)
12774 (setq file (concat (file-name-as-directory file)
12775 (file-name-nondirectory default-name))))
12776 ;; Possibly translate some charaters.
12777 (nnheader-translate-file-chars file)))
12779 (defun gnus-article-archive-name (group)
12780 "Return the first instance of an \"Archive-name\" in the current buffer."
12781 (let ((case-fold-search t))
12782 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
12783 (match-string 1))))
12785 (defun gnus-summary-save-in-rmail (&optional filename)
12786 "Append this article to Rmail file.
12787 Optional argument FILENAME specifies file name.
12788 Directory to save to is default to `gnus-article-save-directory' which
12789 is initialized from the SAVEDIR environment variable."
12791 (gnus-set-global-variables)
12792 (let ((default-name
12793 (funcall gnus-rmail-save-name gnus-newsgroup-name
12794 gnus-current-headers gnus-newsgroup-last-rmail)))
12796 (cond ((eq filename 'default)
12798 (filename filename)
12799 (t (gnus-read-save-file-name
12800 "Save in rmail file:" default-name))))
12801 (gnus-make-directory (file-name-directory filename))
12802 (gnus-eval-in-buffer-window
12803 gnus-original-article-buffer
12807 (gnus-output-to-rmail filename))))
12808 ;; Remember the directory name to save articles
12809 (setq gnus-newsgroup-last-rmail filename)))
12811 (defun gnus-summary-save-in-mail (&optional filename)
12812 "Append this article to Unix mail file.
12813 Optional argument FILENAME specifies file name.
12814 Directory to save to is default to `gnus-article-save-directory' which
12815 is initialized from the SAVEDIR environment variable."
12817 (gnus-set-global-variables)
12818 (let ((default-name
12819 (funcall gnus-mail-save-name gnus-newsgroup-name
12820 gnus-current-headers gnus-newsgroup-last-mail)))
12822 (cond ((eq filename 'default)
12824 (filename filename)
12825 (t (gnus-read-save-file-name
12826 "Save in Unix mail file:" default-name))))
12828 (expand-file-name filename
12830 (file-name-directory default-name))))
12831 (gnus-make-directory (file-name-directory filename))
12832 (gnus-eval-in-buffer-window
12833 gnus-original-article-buffer
12837 (if (and (file-readable-p filename) (mail-file-babyl-p filename))
12838 (gnus-output-to-rmail filename)
12839 (let ((mail-use-rfc822 t))
12840 (rmail-output filename 1 t t))))))
12841 ;; Remember the directory name to save articles.
12842 (setq gnus-newsgroup-last-mail filename)))
12844 (defun gnus-summary-save-in-file (&optional filename)
12845 "Append this article to file.
12846 Optional argument FILENAME specifies file name.
12847 Directory to save to is default to `gnus-article-save-directory' which
12848 is initialized from the SAVEDIR environment variable."
12850 (gnus-set-global-variables)
12851 (let ((default-name
12852 (funcall gnus-file-save-name gnus-newsgroup-name
12853 gnus-current-headers gnus-newsgroup-last-file)))
12855 (cond ((eq filename 'default)
12857 (filename filename)
12858 (t (gnus-read-save-file-name
12859 "Save in file:" default-name))))
12860 (gnus-make-directory (file-name-directory filename))
12861 (gnus-eval-in-buffer-window
12862 gnus-original-article-buffer
12866 (gnus-output-to-file filename))))
12867 ;; Remember the directory name to save articles.
12868 (setq gnus-newsgroup-last-file filename)))
12870 (defun gnus-summary-save-body-in-file (&optional filename)
12871 "Append this article body to a file.
12872 Optional argument FILENAME specifies file name.
12873 The directory to save in defaults to `gnus-article-save-directory' which
12874 is initialized from the SAVEDIR environment variable."
12876 (gnus-set-global-variables)
12877 (let ((default-name
12878 (funcall gnus-file-save-name gnus-newsgroup-name
12879 gnus-current-headers gnus-newsgroup-last-file)))
12881 (cond ((eq filename 'default)
12883 (filename filename)
12884 (t (gnus-read-save-file-name
12885 "Save body in file:" default-name))))
12886 (gnus-make-directory (file-name-directory filename))
12887 (gnus-eval-in-buffer-window
12888 gnus-article-buffer
12892 (goto-char (point-min))
12893 (and (search-forward "\n\n" nil t)
12894 (narrow-to-region (point) (point-max)))
12895 (gnus-output-to-file filename))))
12896 ;; Remember the directory name to save articles.
12897 (setq gnus-newsgroup-last-file filename)))
12899 (defun gnus-summary-save-in-pipe (&optional command)
12900 "Pipe this article to subprocess."
12902 (gnus-set-global-variables)
12904 (cond ((eq command 'default)
12905 gnus-last-shell-command)
12907 (t (read-string "Shell command on article: "
12908 gnus-last-shell-command))))
12909 (if (string-equal command "")
12910 (setq command gnus-last-shell-command))
12911 (gnus-eval-in-buffer-window
12912 gnus-article-buffer
12915 (shell-command-on-region (point-min) (point-max) command nil)))
12916 (setq gnus-last-shell-command command))
12918 ;; Summary extract commands
12920 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12921 (let ((buffer-read-only nil)
12922 (article (gnus-summary-article-number))
12924 (or (gnus-summary-goto-subject article)
12925 (error (format "No such article: %d" article)))
12926 (gnus-summary-position-point)
12927 ;; If all commands are to be bunched up on one line, we collect
12929 (if gnus-view-pseudos-separately
12931 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12934 (setq action (cdr (assq 'action (car ps))))
12935 (setq files (list (cdr (assq 'name (car ps)))))
12936 (while (and ps (cdr ps)
12937 (string= (or action "1")
12938 (or (cdr (assq 'action (cadr ps))) "2")))
12939 (setq files (cons (cdr (assq 'name (cadr ps))) files))
12940 (setcdr ps (cddr ps)))
12943 (if (not (string-match "%s" action))
12944 (setq files (cons " " files)))
12945 (setq files (cons " " files))
12946 (and (assq 'execute (car ps))
12947 (setcdr (assq 'execute (car ps))
12948 (funcall (if (string-match "%s" action)
12951 (mapconcat (lambda (f) f) files " ")))))
12952 (setq ps (cdr ps)))))
12953 (if (and gnus-view-pseudos (not not-view))
12955 (and (assq 'execute (car pslist))
12956 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12957 (eq gnus-view-pseudos 'not-confirm)))
12958 (setq pslist (cdr pslist)))
12961 (setq after-article (or (cdr (assq 'article (car pslist)))
12962 (gnus-summary-article-number)))
12963 (gnus-summary-goto-subject after-article)
12966 (insert " " (file-name-nondirectory
12967 (cdr (assq 'name (car pslist))))
12968 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12970 (forward-line -1) ; back to `b'
12971 (add-text-properties
12972 b e (list 'gnus-number gnus-reffed-article-number
12973 gnus-mouse-face-prop gnus-mouse-face))
12975 after-article gnus-reffed-article-number
12976 gnus-unread-mark b (car pslist) 0 (- e b))
12977 (push gnus-reffed-article-number gnus-newsgroup-unreads)
12978 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12979 (setq pslist (cdr pslist)))))))
12981 (defun gnus-pseudos< (p1 p2)
12982 (let ((c1 (cdr (assq 'action p1)))
12983 (c2 (cdr (assq 'action p2))))
12984 (and c1 c2 (string< c1 c2))))
12986 (defun gnus-request-pseudo-article (props)
12987 (cond ((assq 'execute props)
12988 (gnus-execute-command (cdr (assq 'execute props)))))
12989 (let ((gnus-current-article (gnus-summary-article-number)))
12990 (run-hooks 'gnus-mark-article-hook)))
12992 (defun gnus-execute-command (command &optional automatic)
12994 (gnus-article-setup-buffer)
12995 (set-buffer gnus-article-buffer)
12996 (let ((command (if automatic command (read-string "Command: " command)))
12997 (buffer-read-only nil))
12999 (insert "$ " command "\n\n")
13000 (if gnus-view-pseudo-asynchronously
13001 (start-process "gnus-execute" nil "sh" "-c" command)
13002 (call-process "sh" nil t nil "-c" command)))))
13004 (defun gnus-copy-file (file &optional to)
13007 (list (read-file-name "Copy file: " default-directory)
13008 (read-file-name "Copy file to: " default-directory)))
13009 (gnus-set-global-variables)
13010 (or to (setq to (read-file-name "Copy file to: " default-directory)))
13011 (and (file-directory-p to)
13012 (setq to (concat (file-name-as-directory to)
13013 (file-name-nondirectory file))))
13014 (copy-file file to))
13016 ;; Summary kill commands.
13018 (defun gnus-summary-edit-global-kill (article)
13019 "Edit the \"global\" kill file."
13020 (interactive (list (gnus-summary-article-number)))
13021 (gnus-set-global-variables)
13022 (gnus-group-edit-global-kill article))
13024 (defun gnus-summary-edit-local-kill ()
13025 "Edit a local kill file applied to the current newsgroup."
13027 (gnus-set-global-variables)
13028 (setq gnus-current-headers (gnus-summary-article-header))
13029 (gnus-set-global-variables)
13030 (gnus-group-edit-local-kill
13031 (gnus-summary-article-number) gnus-newsgroup-name))
13035 ;;; Gnus article mode
13038 (put 'gnus-article-mode 'mode-class 'special)
13040 (if gnus-article-mode-map
13042 (setq gnus-article-mode-map (make-keymap))
13043 (suppress-keymap gnus-article-mode-map)
13045 (gnus-define-keys gnus-article-mode-map
13046 " " gnus-article-goto-next-page
13047 "\177" gnus-article-goto-prev-page
13048 [delete] gnus-article-goto-prev-page
13049 "\C-c^" gnus-article-refer-article
13050 "h" gnus-article-show-summary
13051 "s" gnus-article-show-summary
13052 "\C-c\C-m" gnus-article-mail
13053 "?" gnus-article-describe-briefly
13054 gnus-mouse-2 gnus-article-push-button
13055 "\r" gnus-article-press-button
13056 "\t" gnus-article-next-button
13057 "\M-\t" gnus-article-prev-button
13058 "\C-c\C-b" gnus-bug)
13060 (substitute-key-definition
13061 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map))
13063 (defun gnus-article-mode ()
13064 "Major mode for displaying an article.
13066 All normal editing commands are switched off.
13068 The following commands are available:
13070 \\<gnus-article-mode-map>
13071 \\[gnus-article-next-page]\t Scroll the article one page forwards
13072 \\[gnus-article-prev-page]\t Scroll the article one page backwards
13073 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
13074 \\[gnus-article-show-summary]\t Display the summary buffer
13075 \\[gnus-article-mail]\t Send a reply to the address near point
13076 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
13077 \\[gnus-info-find-node]\t Go to the Gnus info node"
13079 (when (and menu-bar-mode
13080 (gnus-visual-p 'article-menu 'menu))
13081 (gnus-article-make-menu-bar))
13082 (kill-all-local-variables)
13083 (gnus-simplify-mode-line)
13084 (setq mode-name "Article")
13085 (setq major-mode 'gnus-article-mode)
13086 (make-local-variable 'minor-mode-alist)
13087 (or (assq 'gnus-show-mime minor-mode-alist)
13088 (setq minor-mode-alist
13089 (cons (list 'gnus-show-mime " MIME") minor-mode-alist)))
13090 (use-local-map gnus-article-mode-map)
13091 (make-local-variable 'page-delimiter)
13092 (setq page-delimiter gnus-page-delimiter)
13093 (buffer-disable-undo (current-buffer))
13094 (setq buffer-read-only t) ;Disable modification
13095 (run-hooks 'gnus-article-mode-hook))
13097 (defun gnus-article-setup-buffer ()
13098 "Initialize the article buffer."
13099 (let* ((name (if gnus-single-article-buffer "*Article*"
13100 (concat "*Article " gnus-newsgroup-name "*")))
13102 (progn (string-match "\\*Article" name)
13103 (concat " *Original Article"
13104 (substring name (match-end 0))))))
13105 (setq gnus-article-buffer name)
13106 (setq gnus-original-article-buffer original)
13107 ;; This might be a variable local to the summary buffer.
13108 (unless gnus-single-article-buffer
13110 (set-buffer gnus-summary-buffer)
13111 (setq gnus-article-buffer name)
13112 (setq gnus-original-article-buffer original)
13113 (gnus-set-global-variables))
13114 (make-local-variable 'gnus-summary-buffer))
13115 (if (get-buffer name)
13118 (buffer-disable-undo (current-buffer))
13119 (setq buffer-read-only t)
13120 (gnus-add-current-to-buffer-list)
13121 (or (eq major-mode 'gnus-article-mode)
13122 (gnus-article-mode))
13125 (set-buffer (get-buffer-create name))
13126 (gnus-add-current-to-buffer-list)
13127 (gnus-article-mode)
13128 (current-buffer)))))
13130 ;; Set article window start at LINE, where LINE is the number of lines
13131 ;; from the head of the article.
13132 (defun gnus-article-set-window-start (&optional line)
13134 (get-buffer-window gnus-article-buffer)
13136 (set-buffer gnus-article-buffer)
13137 (goto-char (point-min))
13140 (gnus-message 6 "Moved to bookmark")
13141 (search-forward "\n\n" nil t)
13142 (forward-line line)
13145 (defun gnus-kill-all-overlays ()
13146 "Delete all overlays in the current buffer."
13147 (when (fboundp 'overlay-lists)
13148 (let* ((overlayss (overlay-lists))
13149 (buffer-read-only nil)
13150 (overlays (nconc (car overlayss) (cdr overlayss))))
13152 (delete-overlay (pop overlays))))))
13154 (defun gnus-request-article-this-buffer (article group)
13155 "Get an article and insert it into this buffer."
13159 (gnus-kill-all-overlays)
13160 (setq group (or group gnus-newsgroup-name))
13162 ;; Open server if it has closed.
13163 (gnus-check-server (gnus-find-method-for-group group))
13165 ;; Using `gnus-request-article' directly will insert the article into
13166 ;; `nntp-server-buffer' - so we'll save some time by not having to
13167 ;; copy it from the server buffer into the article buffer.
13169 ;; We only request an article by message-id when we do not have the
13170 ;; headers for it, so we'll have to get those.
13171 (when (stringp article)
13172 (let ((gnus-override-method gnus-refer-article-method))
13173 (gnus-read-header article)))
13175 ;; If the article number is negative, that means that this article
13176 ;; doesn't belong in this newsgroup (possibly), so we find its
13177 ;; message-id and request it by id instead of number.
13178 (when (and (numberp article)
13179 gnus-summary-buffer
13180 (buffer-name gnus-summary-buffer))
13182 (set-buffer gnus-summary-buffer)
13183 (let ((header (gnus-summary-article-header article)))
13186 ((memq article gnus-newsgroup-sparse)
13187 ;; This is a sparse gap article.
13188 (setq article (mail-header-id header)))
13190 ;; It's a real article.
13191 (setq article (mail-header-id header)))
13193 ;; It is an extracted pseudo-article.
13194 (setq article 'pseudo)
13195 (gnus-request-pseudo-article header))))
13197 (let ((method (gnus-find-method-for-group
13198 gnus-newsgroup-name)))
13199 (if (not (eq (car method) 'nneething))
13201 (let ((dir (concat (file-name-as-directory (nth 1 method))
13202 (mail-header-subject header))))
13203 (if (file-directory-p dir)
13205 (setq article 'nneething)
13206 (gnus-group-enter-directory dir)))))))))
13209 ;; We first check `gnus-original-article-buffer'.
13210 ((and (equal (car gnus-original-article) group)
13211 (eq (cdr gnus-original-article) article)
13212 (get-buffer gnus-original-article-buffer))
13213 (insert-buffer-substring gnus-original-article-buffer)
13215 ;; Check the backlog.
13216 ((and gnus-keep-backlog
13217 (gnus-backlog-request-article group article (current-buffer)))
13219 ;; Check the cache.
13220 ((and gnus-use-cache
13222 (gnus-cache-request-article article group))
13224 ;; Get the article and put into the article buffer.
13225 ((or (stringp article) (numberp article))
13226 (let ((gnus-override-method
13227 (and (stringp article) gnus-refer-article-method))
13228 (buffer-read-only nil))
13230 (gnus-kill-all-overlays)
13231 (if (gnus-request-article article group (current-buffer))
13233 (and gnus-keep-backlog
13234 (gnus-backlog-enter-article
13235 group article (current-buffer)))
13237 ;; It was a pseudo.
13240 ;; Take the article from the original article buffer
13241 ;; and place it in the buffer it's supposed to be in.
13242 (setq gnus-original-article (cons group article))
13243 (when (and (get-buffer gnus-article-buffer)
13244 (equal (buffer-name (current-buffer))
13245 (buffer-name (get-buffer gnus-article-buffer))))
13247 (if (get-buffer gnus-original-article-buffer)
13248 (set-buffer (get-buffer gnus-original-article-buffer))
13249 (set-buffer (get-buffer-create gnus-original-article-buffer))
13250 (buffer-disable-undo (current-buffer))
13251 (setq major-mode 'gnus-original-article-mode)
13252 (setq buffer-read-only t)
13253 (gnus-add-current-to-buffer-list))
13254 (let (buffer-read-only)
13256 (insert-buffer-substring gnus-article-buffer))))
13258 ;; Update sparse articles.
13259 (when (memq article gnus-newsgroup-sparse)
13260 (gnus-summary-update-article article))))
13262 (defun gnus-read-header (id)
13263 "Read the headers of article ID and enter them into the Gnus system."
13264 (let ((group gnus-newsgroup-name)
13265 (headers gnus-newsgroup-headers)
13267 ;; First we check to see whether the header in question is already
13270 ;; This is a Message-ID.
13271 (setq header (gnus-id-to-header id))
13272 ;; This is an article number.
13273 (setq header (gnus-summary-article-header id)))
13275 ;; We have found the header.
13277 ;; We have to really fetch the header to this article.
13279 (if (gnus-check-backend-function 'request-head group)
13280 (gnus-request-head id group)
13281 (gnus-request-article id group)))
13283 (set-buffer nntp-server-buffer)
13284 (and (search-forward "\n\n" nil t)
13285 (delete-region (1- (point)) (point-max)))
13286 (goto-char (point-max))
13288 (goto-char (point-min))
13297 gnus-reffed-article-number)))
13298 " Article retrieved.\n"))
13299 (if (not (setq header (car (gnus-get-newsgroup-headers))))
13300 () ; Malformed head.
13301 (if (and (stringp id)
13302 (not (string= (gnus-group-real-name group)
13304 ;; If we fetched by Message-ID and the article came
13305 ;; from a different group, we fudge some bogus article
13306 ;; numbers for this article.
13307 (mail-header-set-number header gnus-reffed-article-number))
13308 (decf gnus-reffed-article-number)
13309 (push header gnus-newsgroup-headers)
13310 (setq gnus-current-headers header)
13311 (push (mail-header-number header) gnus-newsgroup-limit)
13314 (defun gnus-article-prepare (article &optional all-headers header)
13315 "Prepare ARTICLE in article mode buffer.
13316 ARTICLE should either be an article number or a Message-ID.
13317 If ARTICLE is an id, HEADER should be the article headers.
13318 If ALL-HEADERS is non-nil, no headers are hidden."
13320 ;; Make sure we start in a summary buffer.
13321 (unless (eq major-mode 'gnus-summary-mode)
13322 (set-buffer gnus-summary-buffer))
13323 (setq gnus-summary-buffer (current-buffer))
13324 ;; Make sure the connection to the server is alive.
13325 (unless (gnus-server-opened
13326 (gnus-find-method-for-group gnus-newsgroup-name))
13327 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
13328 (gnus-request-group gnus-newsgroup-name t))
13329 (let* ((article (if header (mail-header-number header) article))
13330 (summary-buffer (current-buffer))
13331 (internal-hook gnus-article-internal-prepare-hook)
13332 (group gnus-newsgroup-name)
13335 (gnus-article-setup-buffer)
13336 (set-buffer gnus-article-buffer)
13337 ;; Deactivate active regions.
13338 (when (and (boundp 'transient-mark-mode)
13339 transient-mark-mode)
13340 (setq mark-active nil))
13341 (if (not (setq result (let ((buffer-read-only nil))
13342 (gnus-request-article-this-buffer
13344 ;; There is no such article.
13346 (when (and (numberp article)
13347 (not (memq article gnus-newsgroup-sparse)))
13348 (setq gnus-article-current
13349 (cons gnus-newsgroup-name article))
13350 (set-buffer gnus-summary-buffer)
13351 (setq gnus-current-article article)
13352 (gnus-summary-mark-article article gnus-canceled-mark))
13353 (unless (memq article gnus-newsgroup-sparse)
13355 1 "No such article (may have expired or been canceled)")
13358 (if (or (eq result 'pseudo) (eq result 'nneething))
13361 (set-buffer summary-buffer)
13362 (setq gnus-last-article gnus-current-article
13363 gnus-newsgroup-history (cons gnus-current-article
13364 gnus-newsgroup-history)
13365 gnus-current-article 0
13366 gnus-current-headers nil
13367 gnus-article-current nil)
13368 (if (eq result 'nneething)
13369 (gnus-configure-windows 'summary)
13370 (gnus-configure-windows 'article))
13371 (gnus-set-global-variables))
13372 (gnus-set-mode-line 'article))
13373 ;; The result from the `request' was an actual article -
13374 ;; or at least some text that is now displayed in the
13376 (if (and (numberp article)
13377 (not (eq article gnus-current-article)))
13378 ;; Seems like a new article has been selected.
13379 ;; `gnus-current-article' must be an article number.
13381 (set-buffer summary-buffer)
13382 (setq gnus-last-article gnus-current-article
13383 gnus-newsgroup-history (cons gnus-current-article
13384 gnus-newsgroup-history)
13385 gnus-current-article article
13386 gnus-current-headers
13387 (gnus-summary-article-header gnus-current-article)
13388 gnus-article-current
13389 (cons gnus-newsgroup-name gnus-current-article))
13390 (unless (vectorp gnus-current-headers)
13391 (setq gnus-current-headers nil))
13392 (gnus-summary-show-thread)
13393 (run-hooks 'gnus-mark-article-hook)
13394 (gnus-set-mode-line 'summary)
13395 (and (gnus-visual-p 'article-highlight 'highlight)
13396 (run-hooks 'gnus-visual-mark-article-hook))
13397 ;; Set the global newsgroup variables here.
13398 ;; Suggested by Jim Sisolak
13399 ;; <sisolak@trans4.neep.wisc.edu>.
13400 (gnus-set-global-variables)
13401 (setq gnus-have-all-headers
13402 (or all-headers gnus-show-all-headers))
13403 (and gnus-use-cache
13404 (vectorp (gnus-summary-article-header article))
13405 (gnus-cache-possibly-enter-article
13407 (gnus-summary-article-header article)
13408 (memq article gnus-newsgroup-marked)
13409 (memq article gnus-newsgroup-dormant)
13410 (memq article gnus-newsgroup-unreads)))))
13411 ;; Hooks for getting information from the article.
13412 ;; This hook must be called before being narrowed.
13413 (let (buffer-read-only)
13414 (run-hooks 'internal-hook)
13415 (run-hooks 'gnus-article-prepare-hook)
13416 ;; Decode MIME message.
13418 (if (or (not gnus-strict-mime)
13419 (gnus-fetch-field "Mime-Version"))
13420 (funcall gnus-show-mime-method)
13421 (funcall gnus-decode-encoded-word-method)))
13422 ;; Perform the article display hooks.
13423 (run-hooks 'gnus-article-display-hook))
13425 (goto-char (point-min))
13426 (and gnus-break-pages (gnus-narrow-to-page))
13427 (gnus-set-mode-line 'article)
13428 (gnus-configure-windows 'article)
13429 (goto-char (point-min))
13432 (defun gnus-article-show-all-headers ()
13433 "Show all article headers in article mode buffer."
13435 (gnus-article-setup-buffer)
13436 (set-buffer gnus-article-buffer)
13437 (let ((buffer-read-only nil))
13438 (remove-text-properties (point-min) (point-max)
13439 gnus-hidden-properties))))
13441 (defun gnus-article-hide-headers-if-wanted ()
13442 "Hide unwanted headers if `gnus-have-all-headers' is nil.
13443 Provided for backwards compatibility."
13444 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
13445 gnus-inhibit-hiding
13446 (gnus-article-hide-headers)))
13448 (defun gnus-article-hide-headers (&optional arg delete)
13449 "Toggle whether to hide unwanted headers and possibly sort them as well.
13450 If given a negative prefix, always show; if given a positive prefix,
13453 (unless (gnus-article-check-hidden-text 'headers arg)
13454 ;; This function might be inhibited.
13455 (unless gnus-inhibit-hiding
13457 (set-buffer gnus-article-buffer)
13459 (let ((buffer-read-only nil)
13460 (ignored (when (not (stringp gnus-visible-headers))
13461 (cond ((stringp gnus-ignored-headers)
13462 gnus-ignored-headers)
13463 ((listp gnus-ignored-headers)
13464 (mapconcat 'identity gnus-ignored-headers
13467 (cond ((stringp gnus-visible-headers)
13468 gnus-visible-headers)
13469 ((and gnus-visible-headers
13470 (listp gnus-visible-headers))
13471 (mapconcat 'identity gnus-visible-headers "\\|"))))
13472 want-list beg want-l)
13473 ;; First we narrow to just the headers.
13475 (goto-char (point-min))
13476 ;; Hide any "From " lines at the beginning of (mail) articles.
13477 (while (looking-at "From ")
13480 (add-text-properties
13481 (point-min) (point)
13482 (nconc (list 'gnus-type 'headers) gnus-hidden-properties)))
13483 ;; Then treat the rest of the header lines.
13486 (progn (search-forward "\n\n" nil t) (forward-line -1) (point)))
13487 ;; Then we use the two regular expressions
13488 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
13489 ;; select which header lines is to remain visible in the
13491 (goto-char (point-min))
13492 (while (re-search-forward "^[^ \t]*:" nil t)
13493 (beginning-of-line)
13494 ;; We add the headers we want to keep to a list and delete
13495 ;; them from the buffer.
13496 (if (or (and visible (looking-at visible))
13497 (and ignored (not (looking-at ignored))))
13499 (push (buffer-substring
13503 ;; Be sure to get multi-line headers...
13504 (re-search-forward "^[^ \t]*:" nil t)
13505 (beginning-of-line)
13508 (delete-region beg (point)))
13510 ;; Sort the headers that we want to display.
13511 (setq want-list (sort want-list 'gnus-article-header-less))
13512 (goto-char (point-min))
13514 (insert (pop want-list)))
13515 ;; We make the unwanted headers invisible.
13517 (delete-region (point-min) (point-max))
13518 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
13519 (add-text-properties
13520 (point) (point-max)
13521 (nconc (list 'gnus-type 'headers)
13522 gnus-hidden-properties)))))))))
13524 (defsubst gnus-article-header-rank (header)
13525 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
13526 (let ((list gnus-sorted-header-list)
13529 (when (string-match (car list) header)
13531 (setq list (cdr list))
13535 (defun gnus-article-header-less (h1 h2)
13536 "Say whether string H1 is \"less\" than string H2."
13537 (< (gnus-article-header-rank h1)
13538 (gnus-article-header-rank h2)))
13540 (defun gnus-article-hide-boring-headers (&optional arg)
13541 "Toggle hiding of headers that aren't very interesting.
13542 If given a negative prefix, always show; if given a positive prefix,
13545 (unless (gnus-article-check-hidden-text 'boring-headers arg)
13547 (set-buffer gnus-article-buffer)
13549 (let ((buffer-read-only nil)
13550 (list gnus-boring-article-headers)
13551 (inhibit-point-motion-hooks t)
13553 (nnheader-narrow-to-headers)
13555 (setq elem (pop list))
13556 (goto-char (point-min))
13558 ;; Hide empty headers.
13560 (while (re-search-forward "^[^:]+:[ \t]\n[^ \t]" nil t)
13562 (add-text-properties
13563 (progn (beginning-of-line) (point))
13566 (if (re-search-forward "^[^ \t]" nil t)
13567 (match-beginning 0)
13569 (nconc (list 'gnus-type 'boring-headers)
13570 gnus-hidden-properties))))
13571 ;; Hide boring Newsgroups header.
13572 ((eq elem 'newsgroups)
13573 (when (equal (mail-fetch-field "newsgroups")
13574 (gnus-group-real-name gnus-newsgroup-name))
13575 (gnus-article-hide-header "newsgroups")))
13576 ((eq elem 'followup-to)
13577 (when (equal (mail-fetch-field "followup-to")
13578 (mail-fetch-field "newsgroups"))
13579 (gnus-article-hide-header "followup-to")))
13580 ((eq elem 'reply-to)
13581 (let ((from (mail-fetch-field "from"))
13582 (reply-to (mail-fetch-field "reply-to")))
13586 (nth 1 (mail-extract-address-components from))
13587 (nth 1 (mail-extract-address-components reply-to))))
13588 (gnus-article-hide-header "reply-to"))))
13590 (let ((date (mail-fetch-field "date")))
13592 (< (gnus-days-between date (current-time-string))
13594 (gnus-article-hide-header "date")))))))))))
13596 (defun gnus-article-hide-header (header)
13598 (goto-char (point-min))
13599 (when (re-search-forward (concat "^" header ":") nil t)
13600 (add-text-properties
13601 (progn (beginning-of-line) (point))
13604 (if (re-search-forward "^[^ \t]" nil t)
13605 (match-beginning 0)
13607 (nconc (list 'gnus-type 'boring-headers)
13608 gnus-hidden-properties)))))
13610 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>.
13611 (defun gnus-article-treat-overstrike ()
13612 "Translate overstrikes into bold text."
13615 (set-buffer gnus-article-buffer)
13616 (let ((buffer-read-only nil))
13617 (while (search-forward "\b" nil t)
13618 (let ((next (following-char))
13619 (previous (char-after (- (point) 2))))
13620 (cond ((eq next previous)
13621 (put-text-property (- (point) 2) (point) 'invisible t)
13622 (put-text-property (point) (1+ (point)) 'face 'bold))
13624 (put-text-property (1- (point)) (1+ (point)) 'invisible t)
13626 (- (point) 2) (1- (point)) 'face 'underline))
13628 (put-text-property (- (point) 2) (point) 'invisible t)
13630 (point) (1+ (point)) 'face 'underline))))))))
13632 (defun gnus-article-word-wrap ()
13633 "Format too long lines."
13636 (set-buffer gnus-article-buffer)
13637 (let ((buffer-read-only nil)
13640 (goto-char (point-min))
13641 (search-forward "\n\n" nil t)
13643 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
13644 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
13645 (adaptive-fill-mode t))
13646 (while (not (eobp))
13647 (and (>= (current-column) (min fill-column (window-width)))
13648 (/= (preceding-char) ?:)
13649 (fill-paragraph nil))
13650 (end-of-line 2))))))
13652 (defun gnus-article-remove-cr ()
13653 "Remove carriage returns from an article."
13656 (set-buffer gnus-article-buffer)
13657 (let ((buffer-read-only nil))
13658 (goto-char (point-min))
13659 (while (search-forward "\r" nil t)
13660 (replace-match "" t t)))))
13662 (defun gnus-article-remove-trailing-blank-lines ()
13663 "Remove all trailing blank lines from the article."
13666 (set-buffer gnus-article-buffer)
13667 (let ((buffer-read-only nil))
13668 (goto-char (point-max))
13672 (while (looking-at "^[ \t]*$")
13677 (defun gnus-article-display-x-face (&optional force)
13678 "Look for an X-Face header and display it if present."
13679 (interactive (list 'force))
13681 (set-buffer gnus-article-buffer)
13682 ;; Delete the old process, if any.
13683 (when (process-status "gnus-x-face")
13684 (delete-process "gnus-x-face"))
13685 (let ((inhibit-point-motion-hooks t)
13686 (case-fold-search nil)
13689 (nnheader-narrow-to-headers)
13690 (setq from (mail-fetch-field "from"))
13691 (goto-char (point-min))
13692 (when (and gnus-article-x-face-command
13694 ;; Check whether this face is censored.
13695 (not gnus-article-x-face-too-ugly)
13696 (and gnus-article-x-face-too-ugly from
13697 (not (string-match gnus-article-x-face-too-ugly
13699 ;; Has to be present.
13700 (re-search-forward "^X-Face: " nil t))
13701 ;; We now have the area of the buffer where the X-Face is stored.
13702 (let ((beg (point))
13703 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
13704 ;; We display the face.
13705 (if (symbolp gnus-article-x-face-command)
13706 ;; The command is a lisp function, so we call it.
13707 (if (gnus-functionp gnus-article-x-face-command)
13708 (funcall gnus-article-x-face-command beg end)
13709 (error "%s is not a function" gnus-article-x-face-command))
13710 ;; The command is a string, so we interpret the command
13711 ;; as a, well, command, and fork it off.
13712 (let ((process-connection-type nil))
13713 (process-kill-without-query
13715 "gnus-x-face" nil "sh" "-c" gnus-article-x-face-command))
13716 (process-send-region "gnus-x-face" beg end)
13717 (process-send-eof "gnus-x-face")))))))))
13719 (defun gnus-headers-decode-quoted-printable ()
13720 "Hack to remove QP encoding from headers."
13721 (let ((case-fold-search t)
13722 (inhibit-point-motion-hooks t)
13724 (goto-char (point-min))
13725 (while (re-search-forward "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t)
13726 (setq string (match-string 1))
13727 (narrow-to-region (match-beginning 0) (match-end 0))
13728 (delete-region (point-min) (point-max))
13730 (gnus-mime-decode-quoted-printable (goto-char (point-min)) (point-max))
13731 (subst-char-in-region (point-min) (point-max) ?_ ? )
13733 (goto-char (point-min)))))
13735 (defun gnus-article-de-quoted-unreadable (&optional force)
13736 "Do a naive translation of a quoted-printable-encoded article.
13737 This is in no way, shape or form meant as a replacement for real MIME
13738 processing, but is simply a stop-gap measure until MIME support is
13740 If FORCE, decode the article whether it is marked as quoted-printable
13742 (interactive (list 'force))
13744 (set-buffer gnus-article-buffer)
13745 (let ((case-fold-search t)
13746 (buffer-read-only nil)
13747 (type (gnus-fetch-field "content-transfer-encoding")))
13749 (and type (string-match "quoted-printable" type)))
13750 (gnus-headers-decode-quoted-printable)
13751 (goto-char (point-min))
13752 (search-forward "\n\n" nil 'move)
13753 (gnus-mime-decode-quoted-printable (point) (point-max))))))
13755 (defun gnus-mime-decode-quoted-printable (from to)
13756 "Decode Quoted-Printable in the region between FROM and TO."
13758 (while (search-forward "=" to t)
13759 (cond ((eq (following-char) ?\n)
13762 ((looking-at "[0-9A-F][0-9A-F]")
13764 (insert (hexl-hex-string-to-integer
13765 (buffer-substring (point) (+ 2 (point)))))
13769 ((gnus-message 3 "Malformed MIME quoted-printable message")))))
13771 (defun gnus-article-hide-pgp (&optional arg)
13772 "Toggle hiding of any PGP headers and signatures in the current article.
13773 If given a negative prefix, always show; if given a positive prefix,
13776 (unless (gnus-article-check-hidden-text 'pgp arg)
13778 (set-buffer gnus-article-buffer)
13779 (let ((props (nconc (list 'gnus-type 'pgp) gnus-hidden-properties))
13780 buffer-read-only beg end)
13782 (goto-char (point-min))
13783 ;; Hide the "header".
13784 (and (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
13785 (add-text-properties (match-beginning 0) (match-end 0) props))
13787 ;; Hide the actual signature.
13788 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
13789 (setq end (match-beginning 0))
13790 (add-text-properties
13791 (match-beginning 0)
13792 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
13794 ;; Perhaps we shouldn't hide to the end of the buffer
13795 ;; if there is no end to the signature?
13798 ;; Hide "- " PGP quotation markers.
13799 (when (and beg end)
13800 (narrow-to-region beg end)
13801 (goto-char (point-min))
13802 (while (re-search-forward "^- " nil t)
13803 (add-text-properties (match-beginning 0) (match-end 0) props))
13806 (defun gnus-article-hide-signature (&optional arg)
13807 "Hide the signature in the current article.
13808 If given a negative prefix, always show; if given a positive prefix,
13811 (unless (gnus-article-check-hidden-text 'signature arg)
13813 (set-buffer gnus-article-buffer)
13815 (let ((buffer-read-only nil))
13816 (when (gnus-narrow-to-signature)
13817 (add-text-properties
13818 (point-min) (point-max)
13819 (nconc (list 'gnus-type 'signature)
13820 gnus-hidden-properties))))))))
13822 (defun gnus-narrow-to-signature ()
13823 "Narrow to the signature."
13825 (goto-char (point-max))
13826 (when (re-search-backward gnus-signature-separator nil t)
13828 (when (or (null gnus-signature-limit)
13829 (and (numberp gnus-signature-limit)
13830 (< (- (point-max) (point)) gnus-signature-limit))
13831 (and (gnus-functionp gnus-signature-limit)
13832 (funcall gnus-signature-limit))
13833 (and (stringp gnus-signature-limit)
13834 (not (re-search-forward gnus-signature-limit nil t))))
13835 (narrow-to-region (point) (point-max))
13838 (defun gnus-article-check-hidden-text (type arg)
13839 "Return nil if hiding is necessary."
13841 (set-buffer gnus-article-buffer)
13842 (let ((hide (gnus-article-hidden-text-p type)))
13843 (cond ((or (and (null arg) (eq hide 'hidden))
13844 (and arg (< 0 (prefix-numeric-value arg))))
13845 (gnus-article-show-hidden-text type))
13847 (gnus-article-show-hidden-text type t))
13850 (defun gnus-article-hidden-text-p (type)
13851 "Say whether the current buffer contains hidden text of type TYPE."
13852 (let ((pos (text-property-any (point-min) (point-max) 'gnus-type type))
13855 (if (get-text-property pos 'invisible)
13859 (defun gnus-article-hide (&optional arg force)
13860 "Hide all the gruft in the current article.
13861 This means that PGP stuff, signatures, cited text and (some)
13862 headers will be hidden.
13863 If given a prefix, show the hidden text instead."
13864 (interactive (list current-prefix-arg 'force))
13865 (gnus-article-hide-headers arg)
13866 (gnus-article-hide-pgp arg)
13867 (gnus-article-hide-citation-maybe arg force)
13868 (gnus-article-hide-signature arg))
13870 (defun gnus-article-show-hidden-text (type &optional hide)
13871 "Show all hidden text of type TYPE.
13872 If HIDE, hide the text instead."
13874 (set-buffer gnus-article-buffer)
13875 (let ((buffer-read-only nil)
13876 (inhibit-point-motion-hooks t)
13878 (while (gnus-goto-char (text-property-any
13879 beg (point-max) 'gnus-type type))
13883 (add-text-properties beg (point) gnus-hidden-properties)
13884 (remove-text-properties beg (point) gnus-hidden-properties))
13885 (setq beg (point)))
13888 (defvar gnus-article-time-units
13889 `((year . ,(* 365.25 24 60 60))
13890 (week . ,(* 7 24 60 60))
13891 (day . ,(* 24 60 60))
13892 (hour . ,(* 60 60))
13895 "Mapping from time units to seconds.")
13897 (defun gnus-article-date-ut (&optional type highlight)
13898 "Convert DATE date to universal time in the current article.
13899 If TYPE is `local', convert to local time; if it is `lapsed', output
13900 how much time has lapsed since DATE."
13901 (interactive (list 'ut t))
13902 (let* ((header (or gnus-current-headers
13903 (gnus-summary-article-header) ""))
13904 (date (and (vectorp header) (mail-header-date header)))
13905 (date-regexp "^Date: \\|^X-Sent: ")
13906 (now (current-time))
13907 (inhibit-point-motion-hooks t))
13908 (when (and date (not (string= date "")))
13910 (set-buffer gnus-article-buffer)
13912 (nnheader-narrow-to-headers)
13913 (let ((buffer-read-only nil))
13914 ;; Delete any old Date headers.
13915 (if (zerop (nnheader-remove-header date-regexp t))
13916 (beginning-of-line)
13917 (goto-char (point-max)))
13920 ;; Convert to the local timezone. We have to slap a
13921 ;; `condition-case' round the calls to the timezone
13922 ;; functions since they aren't particularly resistant to
13925 (concat "Date: " (condition-case ()
13926 (timezone-make-date-arpa-standard date)
13929 ;; Convert to Universal Time.
13933 (timezone-make-date-arpa-standard date nil "UT")
13936 ;; Get the original date from the article.
13937 ((eq type 'original)
13938 (concat "Date: " date "\n"))
13939 ;; Do an X-Sent lapsed format.
13941 ;; If the date is seriously mangled, the timezone
13942 ;; functions are liable to bug out, so we condition-case
13943 ;; the entire thing.
13948 (timezone-make-date-arpa-standard
13949 (current-time-string now)
13950 (current-time-zone now) "UT"))
13952 (timezone-make-date-arpa-standard
13955 (real-sec (+ (* (float (car real-time)) 65536)
13957 (sec (abs real-sec))
13963 ;; This is a bit convoluted, but basically we go
13964 ;; through the time units for years, weeks, etc,
13965 ;; and divide things to see whether that results
13966 ;; in positive answers.
13969 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
13970 ;; The (remaining) seconds are too few to
13971 ;; be divided into this time unit.
13973 ;; It's big enough, so we output it.
13974 (setq sec (- sec (* num (cdr unit))))
13976 (concat (if prev ", " "") (int-to-string
13978 " " (symbol-name (car unit))
13979 (if (> num 1) "s" ""))
13981 gnus-article-time-units "")
13982 ;; If dates are odd, then it might appear like the
13983 ;; article was sent in the future.
13986 " in the future\n")))))
13988 (error "Unknown conversion type: %s" type)))))
13989 ;; Do highlighting.
13990 (when (and highlight (gnus-visual-p 'article-highlight 'highlight))
13991 (gnus-article-highlight-headers)))))))
13993 (defun gnus-article-date-local (&optional highlight)
13994 "Convert the current article date to the local timezone."
13995 (interactive (list t))
13996 (gnus-article-date-ut 'local highlight))
13998 (defun gnus-article-date-original (&optional highlight)
13999 "Convert the current article date to what it was originally.
14000 This is only useful if you have used some other date conversion
14001 function and want to see what the date was before converting."
14002 (interactive (list t))
14003 (gnus-article-date-ut 'original highlight))
14005 (defun gnus-article-date-lapsed (&optional highlight)
14006 "Convert the current article date to time lapsed since it was sent."
14007 (interactive (list t))
14008 (gnus-article-date-ut 'lapsed highlight))
14010 (defun gnus-article-maybe-highlight ()
14011 "Do some article highlighting if `gnus-visual' is non-nil."
14012 (if (gnus-visual-p 'article-highlight 'highlight)
14013 (gnus-article-highlight-some)))
14017 (defun gnus-output-to-rmail (file-name)
14018 "Append the current article to an Rmail file named FILE-NAME."
14020 ;; Most of these codes are borrowed from rmailout.el.
14021 (setq file-name (expand-file-name file-name))
14022 (setq rmail-default-rmail-file file-name)
14023 (let ((artbuf (current-buffer))
14024 (tmpbuf (get-buffer-create " *Gnus-output*")))
14026 (or (get-file-buffer file-name)
14027 (file-exists-p file-name)
14028 (if (gnus-yes-or-no-p
14029 (concat "\"" file-name "\" does not exist, create it? "))
14030 (let ((file-buffer (create-file-buffer file-name)))
14032 (set-buffer file-buffer)
14033 (rmail-insert-rmail-file-header)
14034 (let ((require-final-newline nil))
14035 (write-region (point-min) (point-max) file-name t 1)))
14036 (kill-buffer file-buffer))
14037 (error "Output file does not exist")))
14038 (set-buffer tmpbuf)
14039 (buffer-disable-undo (current-buffer))
14041 (insert-buffer-substring artbuf)
14042 (gnus-convert-article-to-rmail)
14043 ;; Decide whether to append to a file or to an Emacs buffer.
14044 (let ((outbuf (get-file-buffer file-name)))
14046 (append-to-file (point-min) (point-max) file-name)
14047 ;; File has been visited, in buffer OUTBUF.
14048 (set-buffer outbuf)
14049 (let ((buffer-read-only nil)
14050 (msg (and (boundp 'rmail-current-message)
14051 (symbol-value 'rmail-current-message))))
14052 ;; If MSG is non-nil, buffer is in RMAIL mode.
14055 (narrow-to-region (point-max) (point-max))))
14056 (insert-buffer-substring tmpbuf)
14059 (goto-char (point-min))
14061 (search-backward "\^_")
14062 (narrow-to-region (point) (point-max))
14063 (goto-char (1+ (point-min)))
14064 (rmail-count-new-messages t)
14065 (rmail-show-message msg)))))))
14066 (kill-buffer tmpbuf)))
14068 (defun gnus-output-to-file (file-name)
14069 "Append the current article to a file named FILE-NAME."
14070 (setq file-name (expand-file-name file-name))
14071 (let ((artbuf (current-buffer))
14072 (tmpbuf (get-buffer-create " *Gnus-output*")))
14074 (set-buffer tmpbuf)
14075 (buffer-disable-undo (current-buffer))
14077 (insert-buffer-substring artbuf)
14078 ;; Append newline at end of the buffer as separator, and then
14079 ;; save it to file.
14080 (goto-char (point-max))
14082 (append-to-file (point-min) (point-max) file-name))
14083 (kill-buffer tmpbuf)))
14085 (defun gnus-convert-article-to-rmail ()
14086 "Convert article in current buffer to Rmail message format."
14087 (let ((buffer-read-only nil))
14088 ;; Convert article directly into Babyl format.
14089 ;; Suggested by Rob Austein <sra@lcs.mit.edu>
14090 (goto-char (point-min))
14091 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
14092 (while (search-forward "\n\^_" nil t) ;single char
14093 (replace-match "\n^_" t t)) ;2 chars: "^" and "_"
14094 (goto-char (point-max))
14097 (defun gnus-narrow-to-page (&optional arg)
14098 "Narrow the article buffer to a page.
14099 If given a numerical ARG, move forward ARG pages."
14101 (setq arg (if arg (prefix-numeric-value arg) 0))
14103 (set-buffer gnus-article-buffer)
14104 (goto-char (point-min))
14106 (when (gnus-visual-p 'page-marker)
14107 (let ((buffer-read-only nil))
14108 (gnus-remove-text-with-property 'gnus-prev)
14109 (gnus-remove-text-with-property 'gnus-next)))
14112 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
14114 (re-search-forward page-delimiter nil 'move arg)))
14115 (goto-char (match-end 0)))
14118 (if (re-search-forward page-delimiter nil 'move)
14119 (match-beginning 0)
14121 (when (and (gnus-visual-p 'page-marker)
14122 (not (= (point-min) 1)))
14124 (goto-char (point-min))
14125 (gnus-insert-prev-page-button)))
14126 (when (and (gnus-visual-p 'page-marker)
14127 (not (= (1- (point-max)) (buffer-size))))
14129 (goto-char (point-max))
14130 (gnus-insert-next-page-button)))))
14132 ;; Article mode commands
14134 (defun gnus-article-goto-next-page ()
14135 "Show the next page of the article."
14137 (when (gnus-article-next-page)
14138 (gnus-article-read-summary-keys nil ?n)))
14140 (defun gnus-article-goto-prev-page ()
14141 "Show the next page of the article."
14143 (if (bobp) (gnus-article-read-summary-keys nil ?n)
14144 (gnus-article-prev-page nil)))
14146 (defun gnus-article-next-page (&optional lines)
14147 "Show the next page of the current article.
14148 If end of article, return non-nil. Otherwise return nil.
14149 Argument LINES specifies lines to be scrolled up."
14151 (move-to-window-line -1)
14152 ;; Fixed by enami@ptgd.sony.co.jp (enami tsugutomo)
14153 (if (save-excursion
14155 (and (pos-visible-in-window-p) ;Not continuation line.
14157 ;; Nothing in this page.
14158 (if (or (not gnus-break-pages)
14161 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
14163 (gnus-narrow-to-page 1) ;Go to next page.
14165 ;; More in this page.
14169 ;; Long lines may cause an end-of-buffer error.
14170 (goto-char (point-max))))
14171 (move-to-window-line 0)
14174 (defun gnus-article-prev-page (&optional lines)
14175 "Show previous page of current article.
14176 Argument LINES specifies lines to be scrolled down."
14178 (move-to-window-line 0)
14179 (if (and gnus-break-pages
14181 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
14183 (gnus-narrow-to-page -1) ;Go to previous page.
14184 (goto-char (point-max))
14188 (scroll-down lines)
14190 (move-to-window-line 0))))
14192 (defun gnus-article-refer-article ()
14193 "Read article specified by message-id around point."
14195 (let ((point (point)))
14196 (search-forward ">" nil t) ;Move point to end of "<....>".
14197 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
14198 (let ((message-id (match-string 1)))
14200 (set-buffer gnus-summary-buffer)
14201 (gnus-summary-refer-article message-id))
14202 (goto-char (point))
14203 (error "No references around point"))))
14205 (defun gnus-article-show-summary ()
14206 "Reconfigure windows to show summary buffer."
14208 (gnus-configure-windows 'article)
14209 (gnus-summary-goto-subject gnus-current-article))
14211 (defun gnus-article-describe-briefly ()
14212 "Describe article mode commands briefly."
14215 (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")))
14217 (defun gnus-article-summary-command ()
14218 "Execute the last keystroke in the summary buffer."
14220 (let ((obuf (current-buffer))
14221 (owin (current-window-configuration))
14223 (switch-to-buffer gnus-summary-buffer 'norecord)
14224 (setq func (lookup-key (current-local-map) (this-command-keys)))
14225 (call-interactively func)
14227 (set-window-configuration owin)
14228 (set-window-point (get-buffer-window (current-buffer)) (point))))
14230 (defun gnus-article-summary-command-nosave ()
14231 "Execute the last keystroke in the summary buffer."
14234 (pop-to-buffer gnus-summary-buffer 'norecord)
14235 (setq func (lookup-key (current-local-map) (this-command-keys)))
14236 (call-interactively func)))
14238 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
14239 "Read a summary buffer key sequence and execute it from the article buffer."
14242 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
14243 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
14247 (set-buffer gnus-summary-buffer)
14248 (push (or key last-command-event) unread-command-events)
14249 (setq keys (read-key-sequence nil)))
14252 (if (member keys nosaves)
14254 (pop-to-buffer gnus-summary-buffer 'norecord)
14255 (if (setq func (lookup-key (current-local-map) keys))
14256 (call-interactively func)
14258 (let ((obuf (current-buffer))
14259 (owin (current-window-configuration))
14262 (if not-restore-window
14263 (pop-to-buffer gnus-summary-buffer 'norecord)
14264 (switch-to-buffer gnus-summary-buffer 'norecord))
14265 (setq in-buffer (current-buffer))
14266 (if (setq func (lookup-key (current-local-map) keys))
14267 (call-interactively func)
14269 (when (eq in-buffer (current-buffer))
14271 (unless not-restore-window
14272 (set-window-configuration owin))
14273 (set-window-point (get-buffer-window (current-buffer)) opoint))))))
14277 ;;; Kill file handling.
14281 (defalias 'gnus-batch-kill 'gnus-batch-score)
14283 (defun gnus-batch-score ()
14284 "Run batched scoring.
14285 Usage: emacs -batch -l gnus -f gnus-batch-score <newsgroups> ...
14286 Newsgroups is a list of strings in Bnews format. If you want to score
14287 the comp hierarchy, you'd say \"comp.all\". If you would not like to
14288 score the alt hierarchy, you'd say \"!alt.all\"."
14291 (gnus-newsrc-parse-options
14292 (apply (function concat)
14293 (mapcar (lambda (g) (concat g " "))
14294 command-line-args-left))))
14295 (gnus-expert-user t)
14296 (nnmail-spool-file nil)
14297 (gnus-use-dribble-file nil)
14298 (yes (car yes-and-no))
14299 (no (cdr yes-and-no))
14301 ;; Disable verbose message.
14302 gnus-novice-user gnus-large-newsgroup)
14303 ;; Eat all arguments.
14304 (setq command-line-args-left nil)
14307 ;; Apply kills to specified newsgroups in command line arguments.
14308 (setq newsrc (cdr gnus-newsrc-alist))
14310 (setq group (caar newsrc))
14311 (setq entry (gnus-gethash group gnus-newsrc-hashtb))
14312 (if (and (<= (nth 1 (car newsrc)) gnus-level-subscribed)
14314 (or (eq (car entry) t)
14315 (not (zerop (car entry)))))
14316 (if yes (string-match yes group) t)
14317 (or (null no) (not (string-match no group))))
14319 (gnus-summary-read-group group nil t nil t)
14320 (and (eq (current-buffer) (get-buffer gnus-summary-buffer))
14321 (gnus-summary-exit))))
14322 (setq newsrc (cdr newsrc)))
14324 (switch-to-buffer gnus-group-buffer)
14325 (gnus-group-save-newsrc)))
14327 (defun gnus-apply-kill-file ()
14328 "Apply a kill file to the current newsgroup.
14329 Returns the number of articles marked as read."
14330 (if (or (file-exists-p (gnus-newsgroup-kill-file nil))
14331 (file-exists-p (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14332 (gnus-apply-kill-file-internal)
14335 (defun gnus-kill-save-kill-buffer ()
14336 (let ((file (gnus-newsgroup-kill-file gnus-newsgroup-name)))
14337 (when (get-file-buffer file)
14339 (set-buffer (get-file-buffer file))
14340 (and (buffer-modified-p) (save-buffer))
14341 (kill-buffer (current-buffer))))))
14343 (defvar gnus-kill-file-name "KILL"
14344 "Suffix of the kill files.")
14346 (defun gnus-newsgroup-kill-file (newsgroup)
14347 "Return the name of a kill file name for NEWSGROUP.
14348 If NEWSGROUP is nil, return the global kill file name instead."
14350 ;; The global KILL file is placed at top of the directory.
14351 ((or (null newsgroup)
14352 (string-equal newsgroup ""))
14353 (expand-file-name gnus-kill-file-name
14354 (or gnus-kill-files-directory "~/News")))
14355 ;; Append ".KILL" to newsgroup name.
14356 ((gnus-use-long-file-name 'not-kill)
14357 (expand-file-name (concat (gnus-newsgroup-savable-name newsgroup)
14358 "." gnus-kill-file-name)
14359 (or gnus-kill-files-directory "~/News")))
14360 ;; Place "KILL" under the hierarchical directory.
14362 (expand-file-name (concat (gnus-newsgroup-directory-form newsgroup)
14363 "/" gnus-kill-file-name)
14364 (or gnus-kill-files-directory "~/News")))))
14371 (defvar gnus-dribble-ignore nil)
14372 (defvar gnus-dribble-eval-file nil)
14374 (defun gnus-dribble-file-name ()
14375 "Return the dribble file for the current .newsrc."
14377 (if gnus-dribble-directory
14378 (concat (file-name-as-directory gnus-dribble-directory)
14379 (file-name-nondirectory gnus-current-startup-file))
14380 gnus-current-startup-file)
14383 (defun gnus-dribble-enter (string)
14384 "Enter STRING into the dribble buffer."
14385 (if (and (not gnus-dribble-ignore)
14386 gnus-dribble-buffer
14387 (buffer-name gnus-dribble-buffer))
14388 (let ((obuf (current-buffer)))
14389 (set-buffer gnus-dribble-buffer)
14390 (insert string "\n")
14391 (set-window-point (get-buffer-window (current-buffer)) (point-max))
14392 (set-buffer obuf))))
14394 (defun gnus-dribble-read-file ()
14395 "Read the dribble file from disk."
14396 (let ((dribble-file (gnus-dribble-file-name)))
14398 (set-buffer (setq gnus-dribble-buffer
14400 (file-name-nondirectory dribble-file))))
14401 (gnus-add-current-to-buffer-list)
14403 (setq buffer-file-name dribble-file)
14405 (buffer-disable-undo (current-buffer))
14406 (bury-buffer (current-buffer))
14407 (set-buffer-modified-p nil)
14408 (let ((auto (make-auto-save-file-name))
14409 (gnus-dribble-ignore t))
14410 (when (or (file-exists-p auto) (file-exists-p dribble-file))
14411 ;; Load whichever file is newest -- the auto save file
14412 ;; or the "real" file.
14413 (if (file-newer-than-file-p auto dribble-file)
14414 (insert-file-contents auto)
14415 (insert-file-contents dribble-file))
14416 (unless (zerop (buffer-size))
14417 (set-buffer-modified-p t))
14418 ;; Set the file modes to reflect the .newsrc file modes.
14420 (when (file-exists-p gnus-current-startup-file)
14421 (set-file-modes dribble-file
14422 (file-modes gnus-current-startup-file)))
14423 ;; Possibly eval the file later.
14424 (when (gnus-y-or-n-p
14425 "Auto-save file exists. Do you want to read it? ")
14426 (setq gnus-dribble-eval-file t)))))))
14428 (defun gnus-dribble-eval-file ()
14429 (if (not gnus-dribble-eval-file)
14431 (setq gnus-dribble-eval-file nil)
14433 (let ((gnus-dribble-ignore t))
14434 (set-buffer gnus-dribble-buffer)
14435 (eval-buffer (current-buffer))))))
14437 (defun gnus-dribble-delete-file ()
14438 (if (file-exists-p (gnus-dribble-file-name))
14439 (delete-file (gnus-dribble-file-name)))
14440 (if gnus-dribble-buffer
14442 (set-buffer gnus-dribble-buffer)
14443 (let ((auto (make-auto-save-file-name)))
14444 (if (file-exists-p auto)
14445 (delete-file auto))
14447 (set-buffer-modified-p nil)))))
14449 (defun gnus-dribble-save ()
14450 (if (and gnus-dribble-buffer
14451 (buffer-name gnus-dribble-buffer))
14453 (set-buffer gnus-dribble-buffer)
14456 (defun gnus-dribble-clear ()
14458 (if (gnus-buffer-exists-p gnus-dribble-buffer)
14460 (set-buffer gnus-dribble-buffer)
14462 (set-buffer-modified-p nil)
14463 (setq buffer-saved-size (buffer-size))))))
14467 ;;; Server Communication
14470 (defun gnus-start-news-server (&optional confirm)
14471 "Open a method for getting news.
14472 If CONFIRM is non-nil, the user will be asked for an NNTP server."
14474 (if gnus-current-select-method
14475 ;; Stream is already opened.
14477 ;; Open NNTP server.
14478 (if (null gnus-nntp-service) (setq gnus-nntp-server nil))
14481 ;; Read server name with completion.
14482 (setq gnus-nntp-server
14483 (completing-read "NNTP server: "
14484 (mapcar (lambda (server) (list server))
14485 (cons (list gnus-nntp-server)
14486 gnus-secondary-servers))
14487 nil nil gnus-nntp-server))))
14489 (if (and gnus-nntp-server
14490 (stringp gnus-nntp-server)
14491 (not (string= gnus-nntp-server "")))
14492 (setq gnus-select-method
14493 (cond ((or (string= gnus-nntp-server "")
14494 (string= gnus-nntp-server "::"))
14495 (list 'nnspool (system-name)))
14496 ((string-match "^:" gnus-nntp-server)
14497 (list 'nnmh gnus-nntp-server
14498 (list 'nnmh-directory
14499 (file-name-as-directory
14501 (concat "~/" (substring
14502 gnus-nntp-server 1)))))
14503 (list 'nnmh-get-new-mail nil)))
14505 (list 'nntp gnus-nntp-server)))))
14507 (setq how (car gnus-select-method))
14508 (cond ((eq how 'nnspool)
14510 (gnus-message 5 "Looking up local news spool..."))
14513 (gnus-message 5 "Looking up mh spool..."))
14516 (setq gnus-current-select-method gnus-select-method)
14517 (run-hooks 'gnus-open-server-hook)
14519 ;; gnus-open-server-hook might have opened it
14520 (gnus-server-opened gnus-select-method)
14521 (gnus-open-server gnus-select-method)
14524 "%s (%s) open error: '%s'. Continue? "
14525 (car gnus-select-method) (cadr gnus-select-method)
14526 (gnus-status-message gnus-select-method)))
14528 (gnus-message 1 "Couldn't open server on %s"
14529 (nth 1 gnus-select-method))
14533 (defun gnus-check-group (group)
14534 "Try to make sure that the server where GROUP exists is alive."
14535 (let ((method (gnus-find-method-for-group group)))
14536 (or (gnus-server-opened method)
14537 (gnus-open-server method))))
14539 (defun gnus-check-server (&optional method silent)
14540 "Check whether the connection to METHOD is down.
14541 If METHOD is nil, use `gnus-select-method'.
14542 If it is down, start it up (again)."
14543 (let ((method (or method gnus-select-method)))
14544 ;; Transform virtual server names into select methods.
14545 (when (stringp method)
14546 (setq method (gnus-server-to-method method)))
14547 (if (gnus-server-opened method)
14548 ;; The stream is already opened.
14550 ;; Open the server.
14552 (gnus-message 5 "Opening %s server%s..." (car method)
14553 (if (equal (nth 1 method) "") ""
14554 (format " on %s" (nth 1 method)))))
14555 (run-hooks 'gnus-open-server-hook)
14557 (gnus-open-server method)
14561 (defun gnus-get-function (method function)
14562 "Return a function symbol based on METHOD and FUNCTION."
14563 ;; Translate server names into methods.
14565 (error "Attempted use of a nil select method"))
14566 (when (stringp method)
14567 (setq method (gnus-server-to-method method)))
14568 (let ((func (intern (format "%s-%s" (car method) function))))
14569 ;; If the functions isn't bound, we require the backend in
14571 (unless (fboundp func)
14572 (require (car method))
14573 (unless (fboundp func)
14574 ;; This backend doesn't implement this function.
14575 (error "No such function: %s" func)))
14580 ;;; Interface functions to the backends.
14583 (defun gnus-open-server (method)
14584 "Open a connection to METHOD."
14585 (let ((elem (assoc method gnus-opened-servers)))
14586 ;; If this method was previously denied, we just return nil.
14587 (if (eq (nth 1 elem) 'denied)
14589 (gnus-message 1 "Denied server")
14591 ;; Open the server.
14593 (funcall (gnus-get-function method 'open-server)
14594 (nth 1 method) (nthcdr 2 method))))
14595 ;; If this hasn't been opened before, we add it to the list.
14597 (setq elem (list method nil)
14598 gnus-opened-servers (cons elem gnus-opened-servers)))
14599 ;; Set the status of this server.
14600 (setcar (cdr elem) (if result 'ok 'denied))
14601 ;; Return the result from the "open" call.
14604 (defun gnus-close-server (method)
14605 "Close the connection to METHOD."
14606 (funcall (gnus-get-function method 'close-server) (nth 1 method)))
14608 (defun gnus-request-list (method)
14609 "Request the active file from METHOD."
14610 (funcall (gnus-get-function method 'request-list) (nth 1 method)))
14612 (defun gnus-request-list-newsgroups (method)
14613 "Request the newsgroups file from METHOD."
14614 (funcall (gnus-get-function method 'request-list-newsgroups) (nth 1 method)))
14616 (defun gnus-request-newgroups (date method)
14617 "Request all new groups since DATE from METHOD."
14618 (funcall (gnus-get-function method 'request-newgroups)
14619 date (nth 1 method)))
14621 (defun gnus-server-opened (method)
14622 "Check whether a connection to METHOD has been opened."
14623 (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
14625 (defun gnus-status-message (method)
14626 "Return the status message from METHOD.
14627 If METHOD is a string, it is interpreted as a group name. The method
14628 this group uses will be queried."
14629 (let ((method (if (stringp method) (gnus-find-method-for-group method)
14631 (funcall (gnus-get-function method 'status-message) (nth 1 method))))
14633 (defun gnus-request-group (group &optional dont-check method)
14634 "Request GROUP. If DONT-CHECK, no information is required."
14635 (let ((method (or method (gnus-find-method-for-group group))))
14636 (funcall (gnus-get-function method 'request-group)
14637 (gnus-group-real-name group) (nth 1 method) dont-check)))
14639 (defun gnus-request-asynchronous (group &optional articles)
14640 "Request that GROUP behave asynchronously.
14641 ARTICLES is the `data' of the group."
14642 (let ((method (gnus-find-method-for-group group)))
14643 (funcall (gnus-get-function method 'request-asynchronous)
14644 (gnus-group-real-name group) (nth 1 method) articles)))
14646 (defun gnus-list-active-group (group)
14647 "Request active information on GROUP."
14648 (let ((method (gnus-find-method-for-group group))
14649 (func 'list-active-group))
14650 (when (gnus-check-backend-function func group)
14651 (funcall (gnus-get-function method func)
14652 (gnus-group-real-name group) (nth 1 method)))))
14654 (defun gnus-request-group-description (group)
14655 "Request a description of GROUP."
14656 (let ((method (gnus-find-method-for-group group))
14657 (func 'request-group-description))
14658 (when (gnus-check-backend-function func group)
14659 (funcall (gnus-get-function method func)
14660 (gnus-group-real-name group) (nth 1 method)))))
14662 (defun gnus-close-group (group)
14663 "Request the GROUP be closed."
14664 (let ((method (gnus-find-method-for-group group)))
14665 (funcall (gnus-get-function method 'close-group)
14666 (gnus-group-real-name group) (nth 1 method))))
14668 (defun gnus-retrieve-headers (articles group &optional fetch-old)
14669 "Request headers for ARTICLES in GROUP.
14670 If FETCH-OLD, retrieve all headers (or some subset thereof) in the group."
14671 (let ((method (gnus-find-method-for-group group)))
14672 (if (and gnus-use-cache (numberp (car articles)))
14673 (gnus-cache-retrieve-headers articles group fetch-old)
14674 (funcall (gnus-get-function method 'retrieve-headers)
14675 articles (gnus-group-real-name group) (nth 1 method)
14678 (defun gnus-retrieve-groups (groups method)
14679 "Request active information on GROUPS from METHOD."
14680 (funcall (gnus-get-function method 'retrieve-groups) groups (nth 1 method)))
14682 (defun gnus-request-type (group &optional article)
14683 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14684 (let ((method (gnus-find-method-for-group group)))
14685 (if (not (gnus-check-backend-function 'request-type (car method)))
14687 (funcall (gnus-get-function method 'request-type)
14688 (gnus-group-real-name group) article))))
14690 (defun gnus-request-update-mark (group article mark)
14691 "Return the type (`post' or `mail') of GROUP (and ARTICLE)."
14692 (let ((method (gnus-find-method-for-group group)))
14693 (if (not (gnus-check-backend-function 'request-update-mark (car method)))
14695 (funcall (gnus-get-function method 'request-update-mark)
14696 (gnus-group-real-name group) article mark))))
14698 (defun gnus-request-article (article group &optional buffer)
14699 "Request the ARTICLE in GROUP.
14700 ARTICLE can either be an article number or an article Message-ID.
14701 If BUFFER, insert the article in that group."
14702 (let ((method (gnus-find-method-for-group group)))
14703 (funcall (gnus-get-function method 'request-article)
14704 article (gnus-group-real-name group) (nth 1 method) buffer)))
14706 (defun gnus-request-head (article group)
14707 "Request the head of ARTICLE in GROUP."
14708 (let ((method (gnus-find-method-for-group group)))
14709 (funcall (gnus-get-function method 'request-head)
14710 article (gnus-group-real-name group) (nth 1 method))))
14712 (defun gnus-request-body (article group)
14713 "Request the body of ARTICLE in GROUP."
14714 (let ((method (gnus-find-method-for-group group)))
14715 (funcall (gnus-get-function method 'request-body)
14716 article (gnus-group-real-name group) (nth 1 method))))
14718 (defun gnus-request-post (method)
14719 "Post the current buffer using METHOD."
14720 (funcall (gnus-get-function method 'request-post) (nth 1 method)))
14722 (defun gnus-request-scan (group method)
14723 "Request a SCAN being performed in GROUP from METHOD.
14724 If GROUP is nil, all groups on METHOD are scanned."
14725 (let ((method (if group (gnus-find-method-for-group group) method)))
14726 (funcall (gnus-get-function method 'request-scan)
14727 (and group (gnus-group-real-name group)) (nth 1 method))))
14729 (defsubst gnus-request-update-info (info method)
14730 "Request that METHOD update INFO."
14731 (when (gnus-check-backend-function 'request-update-info (car method))
14732 (funcall (gnus-get-function method 'request-update-info)
14733 (gnus-group-real-name (gnus-info-group info))
14734 info (nth 1 method))))
14736 (defun gnus-request-expire-articles (articles group &optional force)
14737 (let ((method (gnus-find-method-for-group group)))
14738 (funcall (gnus-get-function method 'request-expire-articles)
14739 articles (gnus-group-real-name group) (nth 1 method)
14742 (defun gnus-request-move-article
14743 (article group server accept-function &optional last)
14744 (let ((method (gnus-find-method-for-group group)))
14745 (funcall (gnus-get-function method 'request-move-article)
14746 article (gnus-group-real-name group)
14747 (nth 1 method) accept-function last)))
14749 (defun gnus-request-accept-article (group &optional last method)
14750 ;; Make sure there's a newline at the end of the article.
14751 (goto-char (point-max))
14754 (let ((func (if (symbolp group) group
14755 (car (or method (gnus-find-method-for-group group))))))
14756 (funcall (intern (format "%s-request-accept-article" func))
14757 (if (stringp group) (gnus-group-real-name group) group)
14760 (defun gnus-request-replace-article (article group buffer)
14761 (let ((func (car (gnus-find-method-for-group group))))
14762 (funcall (intern (format "%s-request-replace-article" func))
14763 article (gnus-group-real-name group) buffer)))
14765 (defun gnus-request-associate-buffer (group)
14766 (let ((method (gnus-find-method-for-group group)))
14767 (funcall (gnus-get-function method 'request-associate-buffer)
14768 (gnus-group-real-name group))))
14770 (defun gnus-request-restore-buffer (article group)
14771 "Request a new buffer restored to the state of ARTICLE."
14772 (let ((method (gnus-find-method-for-group group)))
14773 (funcall (gnus-get-function method 'request-restore-buffer)
14774 article (gnus-group-real-name group) (nth 1 method))))
14776 (defun gnus-request-create-group (group &optional method)
14777 (let ((method (or method (gnus-find-method-for-group group))))
14778 (funcall (gnus-get-function method 'request-create-group)
14779 (gnus-group-real-name group) (nth 1 method))))
14781 (defun gnus-request-delete-group (group &optional force)
14782 (let ((method (gnus-find-method-for-group group)))
14783 (funcall (gnus-get-function method 'request-delete-group)
14784 (gnus-group-real-name group) force (nth 1 method))))
14786 (defun gnus-request-rename-group (group new-name)
14787 (let ((method (gnus-find-method-for-group group)))
14788 (funcall (gnus-get-function method 'request-rename-group)
14789 (gnus-group-real-name group)
14790 (gnus-group-real-name new-name) (nth 1 method))))
14792 (defun gnus-member-of-valid (symbol group)
14793 "Find out if GROUP has SYMBOL as part of its \"valid\" spec."
14794 (memq symbol (assoc
14795 (symbol-name (car (gnus-find-method-for-group group)))
14796 gnus-valid-select-methods)))
14798 (defun gnus-method-option-p (method option)
14799 "Return non-nil if select METHOD has OPTION as a parameter."
14800 (memq option (assoc (format "%s" (car method))
14801 gnus-valid-select-methods)))
14803 (defun gnus-server-extend-method (group method)
14804 ;; This function "extends" a virtual server. If the server is
14805 ;; "hello", and the select method is ("hello" (my-var "something"))
14806 ;; in the group "alt.alt", this will result in a new virtual server
14807 ;; called "hello+alt.alt".
14809 (gnus-copy-sequence
14810 (if (equal (car method) "native") gnus-select-method
14811 (cdr (assoc (car method) gnus-server-alist))))))
14812 (setcar (cdr entry) (concat (nth 1 entry) "+" group))
14813 (nconc entry (cdr method))))
14815 (defun gnus-find-method-for-group (group &optional info)
14816 "Find the select method that GROUP uses."
14817 (or gnus-override-method
14819 gnus-select-method)
14820 (let ((info (or info (gnus-get-info group)))
14823 (not (setq method (gnus-info-method info)))
14824 (equal method "native"))
14827 (cond ((stringp method)
14828 (gnus-server-to-method method))
14829 ((stringp (car method))
14830 (gnus-server-extend-method group method))
14833 (if (equal (cadr method) "")
14835 (gnus-server-add-address method))))))
14837 (defun gnus-check-backend-function (func group)
14838 "Check whether GROUP supports function FUNC."
14839 (let ((method (if (stringp group) (car (gnus-find-method-for-group group))
14841 (fboundp (intern (format "%s-%s" method func)))))
14843 (defun gnus-methods-using (feature)
14844 "Find all methods that have FEATURE."
14845 (let ((valids gnus-valid-select-methods)
14848 (if (memq feature (car valids))
14849 (setq outs (cons (car valids) outs)))
14850 (setq valids (cdr valids)))
14855 ;;; Active & Newsrc File Handling
14858 (defun gnus-setup-news (&optional rawfile level dont-connect)
14859 "Setup news information.
14860 If RAWFILE is non-nil, the .newsrc file will also be read.
14861 If LEVEL is non-nil, the news will be set up at level LEVEL."
14862 (let ((init (not (and gnus-newsrc-alist gnus-active-hashtb (not rawfile)))))
14865 ;; Clear some variables to re-initialize news information.
14866 (setq gnus-newsrc-alist nil
14867 gnus-active-hashtb nil)
14868 ;; Read the newsrc file and create `gnus-newsrc-hashtb'.
14869 (gnus-read-newsrc-file rawfile))
14871 (when (and (not (assoc "archive" gnus-server-alist))
14872 gnus-message-archive-method)
14873 (push (cons "archive" gnus-message-archive-method)
14874 gnus-server-alist))
14876 ;; If we don't read the complete active file, we fill in the
14878 (if (or (null gnus-read-active-file)
14879 (eq gnus-read-active-file 'some))
14880 (gnus-update-active-hashtb-from-killed))
14882 ;; Read the active file and create `gnus-active-hashtb'.
14883 ;; If `gnus-read-active-file' is nil, then we just create an empty
14884 ;; hash table. The partial filling out of the hash table will be
14885 ;; done in `gnus-get-unread-articles'.
14886 (and gnus-read-active-file
14888 (gnus-read-active-file))
14890 (or gnus-active-hashtb
14891 (setq gnus-active-hashtb (make-vector 4095 0)))
14893 ;; Initialize the cache.
14894 (when gnus-use-cache
14897 ;; Possibly eval the dribble file.
14898 (and init (or gnus-use-dribble-file gnus-slave) (gnus-dribble-eval-file))
14900 (gnus-update-format-specifications)
14902 ;; See whether we need to read the description file.
14903 (if (and (string-match "%[-,0-9]*D" gnus-group-line-format)
14904 (not gnus-description-hashtb)
14906 gnus-read-active-file)
14907 (gnus-read-all-descriptions-files))
14909 ;; Find new newsgroups and treat them.
14910 (if (and init gnus-check-new-newsgroups (not level)
14911 (gnus-check-server gnus-select-method))
14912 (gnus-find-new-newsgroups))
14914 ;; Find the number of unread articles in each non-dead group.
14915 (let ((gnus-read-active-file (and (not level) gnus-read-active-file)))
14916 (gnus-get-unread-articles level))
14918 (if (and init gnus-check-bogus-newsgroups
14919 gnus-read-active-file (not level)
14920 (gnus-server-opened gnus-select-method))
14921 (gnus-check-bogus-newsgroups))))
14923 (defun gnus-find-new-newsgroups (&optional arg)
14924 "Search for new newsgroups and add them.
14925 Each new newsgroup will be treated with `gnus-subscribe-newsgroup-method.'
14926 The `-n' option line from .newsrc is respected.
14927 If ARG (the prefix), use the `ask-server' method to query
14928 the server for new groups."
14930 (let ((check (if (or (and arg (not (listp gnus-check-new-newsgroups)))
14931 (null gnus-read-active-file)
14932 (eq gnus-read-active-file 'some))
14933 'ask-server gnus-check-new-newsgroups)))
14934 (unless (gnus-check-first-time-used)
14935 (if (or (consp check)
14936 (eq check 'ask-server))
14937 ;; Ask the server for new groups.
14938 (gnus-ask-server-for-new-groups)
14939 ;; Go through the active hashtb and look for new groups.
14941 group new-newsgroups)
14942 (gnus-message 5 "Looking for new newsgroups...")
14943 (unless gnus-have-read-active-file
14944 (gnus-read-active-file))
14945 (setq gnus-newsrc-last-checked-date (current-time-string))
14946 (unless gnus-killed-hashtb
14947 (gnus-make-hashtable-from-killed))
14948 ;; Go though every newsgroup in `gnus-active-hashtb' and compare
14949 ;; with `gnus-newsrc-hashtb' and `gnus-killed-hashtb'.
14952 (if (or (null (setq group (symbol-name sym)))
14954 (null (symbol-value sym))
14955 (gnus-gethash group gnus-killed-hashtb)
14956 (gnus-gethash group gnus-newsrc-hashtb))
14958 (let ((do-sub (gnus-matches-options-n group)))
14960 ((eq do-sub 'subscribe)
14961 (setq groups (1+ groups))
14962 (gnus-sethash group group gnus-killed-hashtb)
14963 (funcall gnus-subscribe-options-newsgroup-method group))
14964 ((eq do-sub 'ignore)
14967 (setq groups (1+ groups))
14968 (gnus-sethash group group gnus-killed-hashtb)
14969 (if gnus-subscribe-hierarchical-interactive
14970 (setq new-newsgroups (cons group new-newsgroups))
14971 (funcall gnus-subscribe-newsgroup-method group)))))))
14972 gnus-active-hashtb)
14973 (when new-newsgroups
14974 (gnus-subscribe-hierarchical-interactive new-newsgroups))
14975 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
14977 (gnus-message 6 "%d new newsgroup%s arrived."
14978 groups (if (> groups 1) "s have" " has"))
14979 (gnus-message 6 "No new newsgroups.")))))))
14981 (defun gnus-matches-options-n (group)
14982 ;; Returns `subscribe' if the group is to be unconditionally
14983 ;; subscribed, `ignore' if it is to be ignored, and nil if there is
14984 ;; no match for the group.
14986 ;; First we check the two user variables.
14988 ((and gnus-options-subscribe
14989 (string-match gnus-options-subscribe group))
14991 ((and gnus-auto-subscribed-groups
14992 (string-match gnus-auto-subscribed-groups group))
14994 ((and gnus-options-not-subscribe
14995 (string-match gnus-options-not-subscribe group))
14997 ;; Then we go through the list that was retrieved from the .newsrc
14998 ;; file. This list has elements on the form
14999 ;; `(REGEXP . {ignore,subscribe})'. The first match found (the list
15000 ;; is in the reverse order of the options line) is returned.
15002 (let ((regs gnus-newsrc-options-n))
15004 (not (string-match (caar regs) group)))
15005 (setq regs (cdr regs)))
15006 (and regs (cdar regs))))))
15008 (defun gnus-ask-server-for-new-groups ()
15009 (let* ((date (or gnus-newsrc-last-checked-date (current-time-string)))
15010 (methods (cons gnus-select-method
15012 (when gnus-message-archive-method
15015 (and (consp gnus-check-new-newsgroups)
15016 gnus-check-new-newsgroups)
15017 gnus-secondary-select-methods))))
15019 (new-date (current-time-string))
15020 group new-newsgroups got-new method hashtb
15021 gnus-override-subscribe-method)
15022 ;; Go through both primary and secondary select methods and
15023 ;; request new newsgroups.
15024 (while (setq method (gnus-server-get-method nil (pop methods)))
15025 (setq new-newsgroups nil)
15026 (setq gnus-override-subscribe-method method)
15027 (when (and (gnus-check-server method)
15028 (gnus-request-newgroups date method))
15031 (setq hashtb (gnus-make-hashtable 100))
15032 (set-buffer nntp-server-buffer)
15033 ;; Enter all the new groups into a hashtable.
15034 (gnus-active-to-gnus-format method hashtb 'ignore)))
15035 ;; Now all new groups from `method' are in `hashtb'.
15037 (lambda (group-sym)
15038 (if (or (null (setq group (symbol-name group-sym)))
15039 (null (symbol-value group-sym))
15040 (gnus-gethash group gnus-newsrc-hashtb)
15041 (member group gnus-zombie-list)
15042 (member group gnus-killed-list))
15043 ;; The group is already known.
15045 ;; Make this group active.
15046 (when (symbol-value group-sym)
15047 (gnus-set-active group (symbol-value group-sym)))
15048 ;; Check whether we want it or not.
15049 (let ((do-sub (gnus-matches-options-n group)))
15051 ((eq do-sub 'subscribe)
15053 (gnus-sethash group group gnus-killed-hashtb)
15054 (funcall gnus-subscribe-options-newsgroup-method group))
15055 ((eq do-sub 'ignore)
15059 (gnus-sethash group group gnus-killed-hashtb)
15060 (if gnus-subscribe-hierarchical-interactive
15061 (push group new-newsgroups)
15062 (funcall gnus-subscribe-newsgroup-method group)))))))
15064 (when new-newsgroups
15065 (gnus-subscribe-hierarchical-interactive new-newsgroups)))
15066 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
15068 (gnus-message 6 "%d new newsgroup%s arrived."
15069 groups (if (> groups 1) "s have" " has")))
15070 (and got-new (setq gnus-newsrc-last-checked-date new-date))
15073 (defun gnus-check-first-time-used ()
15074 (if (or (> (length gnus-newsrc-alist) 1)
15075 (file-exists-p gnus-startup-file)
15076 (file-exists-p (concat gnus-startup-file ".el"))
15077 (file-exists-p (concat gnus-startup-file ".eld")))
15079 (gnus-message 6 "First time user; subscribing you to default groups")
15080 (unless gnus-have-read-active-file
15081 (gnus-read-active-file))
15082 (setq gnus-newsrc-last-checked-date (current-time-string))
15083 (let ((groups gnus-default-subscribed-newsgroups)
15087 (setq groups (or groups gnus-backup-default-subscribed-newsgroups))
15090 (if (null (setq group (symbol-name sym)))
15092 (let ((do-sub (gnus-matches-options-n group)))
15094 ((eq do-sub 'subscribe)
15095 (gnus-sethash group group gnus-killed-hashtb)
15096 (funcall gnus-subscribe-options-newsgroup-method group))
15097 ((eq do-sub 'ignore)
15100 (setq gnus-killed-list (cons group gnus-killed-list)))))))
15101 gnus-active-hashtb)
15103 (if (gnus-active (car groups))
15104 (gnus-group-change-level
15105 (car groups) gnus-level-default-subscribed gnus-level-killed))
15106 (setq groups (cdr groups)))
15107 (gnus-group-make-help-group)
15108 (and gnus-novice-user
15109 (gnus-message 7 "`A k' to list killed groups"))))))
15111 (defun gnus-subscribe-group (group previous &optional method)
15112 (gnus-group-change-level
15114 (list t group gnus-level-default-subscribed nil nil method)
15116 gnus-level-default-subscribed gnus-level-killed previous t))
15118 ;; `gnus-group-change-level' is the fundamental function for changing
15119 ;; subscription levels of newsgroups. This might mean just changing
15120 ;; from level 1 to 2, which is pretty trivial, from 2 to 6 or back
15121 ;; again, which subscribes/unsubscribes a group, which is equally
15122 ;; trivial. Changing from 1-7 to 8-9 means that you kill a group, and
15123 ;; from 8-9 to 1-7 means that you remove the group from the list of
15124 ;; killed (or zombie) groups and add them to the (kinda) subscribed
15125 ;; groups. And last but not least, moving from 8 to 9 and 9 to 8,
15126 ;; which is trivial.
15127 ;; ENTRY can either be a string (newsgroup name) or a list (if
15128 ;; FROMKILLED is t, it's a list on the format (NUM INFO-LIST),
15129 ;; otherwise it's a list in the format of the `gnus-newsrc-hashtb'
15131 ;; LEVEL is the new level of the group, OLDLEVEL is the old level and
15132 ;; PREVIOUS is the group (in hashtb entry format) to insert this group
15134 (defun gnus-group-change-level (entry level &optional oldlevel
15135 previous fromkilled)
15136 (let (group info active num)
15137 ;; Glean what info we can from the arguments
15139 (if fromkilled (setq group (nth 1 entry))
15140 (setq group (car (nth 2 entry))))
15141 (setq group entry))
15142 (if (and (stringp entry)
15144 (< oldlevel gnus-level-zombie))
15145 (setq entry (gnus-gethash entry gnus-newsrc-hashtb)))
15146 (if (and (not oldlevel)
15148 (setq oldlevel (gnus-info-level (nth 2 entry)))
15149 (setq oldlevel (or oldlevel 9)))
15150 (if (stringp previous)
15151 (setq previous (gnus-gethash previous gnus-newsrc-hashtb)))
15153 (if (and (>= oldlevel gnus-level-zombie)
15154 (gnus-gethash group gnus-newsrc-hashtb))
15155 ;; We are trying to subscribe a group that is already
15159 (or (gnus-ephemeral-group-p group)
15160 (gnus-dribble-enter
15161 (format "(gnus-group-change-level %S %S %S %S %S)"
15162 group level oldlevel (car (nth 2 previous)) fromkilled)))
15164 ;; Then we remove the newgroup from any old structures, if needed.
15165 ;; If the group was killed, we remove it from the killed or zombie
15166 ;; list. If not, and it is in fact going to be killed, we remove
15167 ;; it from the newsrc hash table and assoc.
15169 ((>= oldlevel gnus-level-zombie)
15170 (if (= oldlevel gnus-level-zombie)
15171 (setq gnus-zombie-list (delete group gnus-zombie-list))
15172 (setq gnus-killed-list (delete group gnus-killed-list))))
15174 (if (and (>= level gnus-level-zombie)
15177 (gnus-sethash (car (nth 2 entry)) nil gnus-newsrc-hashtb)
15179 (setcdr (gnus-gethash (car (nth 3 entry))
15180 gnus-newsrc-hashtb)
15182 (setcdr (cdr entry) (cdddr entry))))))
15184 ;; Finally we enter (if needed) the list where it is supposed to
15185 ;; go, and change the subscription level. If it is to be killed,
15186 ;; we enter it into the killed or zombie list.
15188 ((>= level gnus-level-zombie)
15189 ;; Remove from the hash table.
15190 (gnus-sethash group nil gnus-newsrc-hashtb)
15191 ;; We do not enter foreign groups into the list of dead
15193 (unless (gnus-group-foreign-p group)
15194 (if (= level gnus-level-zombie)
15195 (setq gnus-zombie-list (cons group gnus-zombie-list))
15196 (setq gnus-killed-list (cons group gnus-killed-list)))))
15198 ;; If the list is to be entered into the newsrc assoc, and
15199 ;; it was killed, we have to create an entry in the newsrc
15200 ;; hashtb format and fix the pointers in the newsrc assoc.
15201 (if (< oldlevel gnus-level-zombie)
15202 ;; It was alive, and it is going to stay alive, so we
15203 ;; just change the level and don't change any pointers or
15204 ;; hash table entries.
15205 (setcar (cdaddr entry) level)
15207 (setq info (cdr entry)
15209 (setq active (gnus-active group))
15211 (if active (- (1+ (cdr active)) (car active)) t))
15212 ;; Check whether the group is foreign. If so, the
15213 ;; foreign select method has to be entered into the
15215 (let ((method (or gnus-override-subscribe-method
15216 (gnus-group-method group))))
15217 (if (eq method gnus-select-method)
15218 (setq info (list group level nil))
15219 (setq info (list group level nil nil method)))))
15222 (let ((p gnus-newsrc-alist))
15226 (setq entry (cons info (cddr previous)))
15229 (setcdr (cdr previous) entry)
15230 (gnus-sethash group (cons num (cdr previous))
15231 gnus-newsrc-hashtb))
15232 (setcdr previous entry)
15233 (gnus-sethash group (cons num previous)
15234 gnus-newsrc-hashtb))
15236 (setcdr (gnus-gethash (caadr entry) gnus-newsrc-hashtb) entry)))))
15237 (when gnus-group-change-level-function
15238 (funcall gnus-group-change-level-function group level oldlevel)))))
15240 (defun gnus-kill-newsgroup (newsgroup)
15241 "Obsolete function. Kills a newsgroup."
15242 (gnus-group-change-level
15243 (gnus-gethash newsgroup gnus-newsrc-hashtb) gnus-level-killed))
15245 (defun gnus-check-bogus-newsgroups (&optional confirm)
15246 "Remove bogus newsgroups.
15247 If CONFIRM is non-nil, the user has to confirm the deletion of every
15249 (let ((newsrc (cdr gnus-newsrc-alist))
15250 bogus group entry info)
15251 (gnus-message 5 "Checking bogus newsgroups...")
15252 (unless gnus-have-read-active-file
15253 (gnus-read-active-file))
15254 (when (member gnus-select-method gnus-have-read-active-file)
15255 ;; Find all bogus newsgroup that are subscribed.
15257 (setq info (pop newsrc)
15258 group (gnus-info-group info))
15259 (unless (or (gnus-active group) ; Active
15260 (gnus-info-method info) ; Foreign
15262 (not (gnus-y-or-n-p
15263 (format "Remove bogus newsgroup: %s " group)))))
15264 ;; Found a bogus newsgroup.
15265 (push group bogus)))
15266 ;; Remove all bogus subscribed groups by first killing them, and
15267 ;; then removing them from the list of killed groups.
15269 (when (setq entry (gnus-gethash (setq group (pop bogus))
15270 gnus-newsrc-hashtb))
15271 (gnus-group-change-level entry gnus-level-killed)
15272 (setq gnus-killed-list (delete group gnus-killed-list))))
15273 ;; Then we remove all bogus groups from the list of killed and
15274 ;; zombie groups. They are are removed without confirmation.
15275 (let ((dead-lists '(gnus-killed-list gnus-zombie-list))
15278 (setq killed (symbol-value (car dead-lists)))
15280 (unless (gnus-active (setq group (pop killed)))
15281 ;; The group is bogus.
15282 ;; !!!Slow as hell.
15283 (set (car dead-lists)
15284 (delete group (symbol-value (car dead-lists))))))
15285 (setq dead-lists (cdr dead-lists))))
15286 (gnus-message 5 "Checking bogus newsgroups...done"))))
15288 (defun gnus-check-duplicate-killed-groups ()
15289 "Remove duplicates from the list of killed groups."
15291 (let ((killed gnus-killed-list))
15293 (gnus-message 9 "%d" (length killed))
15294 (setcdr killed (delete (car killed) (cdr killed)))
15295 (setq killed (cdr killed)))))
15297 ;; Go though `gnus-newsrc-alist' and compare with `gnus-active-hashtb'
15298 ;; and compute how many unread articles there are in each group.
15299 (defun gnus-get-unread-articles (&optional level)
15300 (let* ((newsrc (cdr gnus-newsrc-alist))
15301 (level (or level gnus-activate-level (1+ gnus-level-subscribed)))
15304 (cond ((and gnus-activate-foreign-newsgroups
15305 (not (numberp gnus-activate-foreign-newsgroups)))
15306 (1+ gnus-level-subscribed))
15307 ((numberp gnus-activate-foreign-newsgroups)
15308 gnus-activate-foreign-newsgroups)
15311 info group active method)
15312 (gnus-message 5 "Checking new news...")
15315 (setq active (gnus-active (setq group (gnus-info-group
15316 (setq info (pop newsrc))))))
15318 ;; Check newsgroups. If the user doesn't want to check them, or
15319 ;; they can't be checked (for instance, if the news server can't
15320 ;; be reached) we just set the number of unread articles in this
15321 ;; newsgroup to t. This means that Gnus thinks that there are
15322 ;; unread articles, but it has no idea how many.
15323 (if (and (setq method (gnus-info-method info))
15324 (not (gnus-server-equal
15326 (gnus-server-get-method nil method)))
15327 (not (gnus-secondary-method-p method)))
15328 ;; These groups are foreign. Check the level.
15329 (when (<= (gnus-info-level info) foreign-level)
15330 (setq active (gnus-activate-group group 'scan))
15331 (gnus-close-group group))
15333 ;; These groups are native or secondary.
15334 (when (and (<= (gnus-info-level info) level)
15335 (not gnus-read-active-file))
15336 (setq active (gnus-activate-group group 'scan))
15337 (gnus-close-group group)))
15340 (gnus-get-unread-articles-in-group info active t)
15341 ;; The group couldn't be reached, so we nix out the number of
15342 ;; unread articles and stuff.
15343 (gnus-set-active group nil)
15344 (setcar (gnus-gethash group gnus-newsrc-hashtb) t)))
15346 (gnus-message 5 "Checking new news...done")))
15348 ;; Create a hash table out of the newsrc alist. The `car's of the
15349 ;; alist elements are used as keys.
15350 (defun gnus-make-hashtable-from-newsrc-alist ()
15351 (let ((alist gnus-newsrc-alist)
15352 (ohashtb gnus-newsrc-hashtb)
15354 (setq gnus-newsrc-hashtb (gnus-make-hashtable (length alist)))
15356 (setq prev (setq gnus-newsrc-alist
15357 (if (equal (caar gnus-newsrc-alist)
15360 (cons (list "dummy.group" 0 nil) alist)))))
15364 (cons (and ohashtb (car (gnus-gethash (caar alist) ohashtb)))
15366 gnus-newsrc-hashtb)
15368 alist (cdr alist)))))
15370 (defun gnus-make-hashtable-from-killed ()
15371 "Create a hash table from the killed and zombie lists."
15372 (let ((lists '(gnus-killed-list gnus-zombie-list))
15374 (setq gnus-killed-hashtb
15375 (gnus-make-hashtable
15376 (+ (length gnus-killed-list) (length gnus-zombie-list))))
15378 (setq list (symbol-value (car lists)))
15379 (setq lists (cdr lists))
15381 (gnus-sethash (car list) (car list) gnus-killed-hashtb)
15382 (setq list (cdr list))))))
15384 (defun gnus-get-unread-articles-in-group (info active &optional update)
15386 ;; Allow the backend to update the info in the group.
15388 (gnus-request-update-info
15389 info (gnus-find-method-for-group (gnus-info-group info))))
15390 (gnus-activate-group (gnus-info-group info)))
15391 (let* ((range (gnus-info-read info))
15393 (marked (gnus-info-marks info)))
15394 ;; If a cache is present, we may have to alter the active info.
15395 (when (and gnus-use-cache info)
15396 (gnus-cache-possibly-alter-active (gnus-info-group info) active))
15397 ;; Modify the list of read articles according to what articles
15398 ;; are available; then tally the unread articles and add the
15399 ;; number to the group hash table entry.
15401 ((zerop (cdr active))
15404 (setq num (- (1+ (cdr active)) (car active))))
15405 ((not (listp (cdr range)))
15406 ;; Fix a single (num . num) range according to the
15407 ;; active hash table.
15408 ;; Fix by Carsten Bormann <cabo@Informatik.Uni-Bremen.DE>.
15409 (and (< (cdr range) (car active)) (setcdr range (1- (car active))))
15410 (and (> (cdr range) (cdr active)) (setcdr range (cdr active)))
15411 ;; Compute number of unread articles.
15412 (setq num (max 0 (- (cdr active) (- (1+ (cdr range)) (car range))))))
15414 ;; The read list is a list of ranges. Fix them according to
15415 ;; the active hash table.
15416 ;; First peel off any elements that are below the lower
15418 (while (and (cdr range)
15420 (or (and (atom (cadr range)) (cadr range))
15422 (if (numberp (car range))
15425 (or (and (numberp (cadr range))
15428 (setcdr (car range)
15429 (or (and (numberp (nth 1 range)) (nth 1 range))
15431 (setcdr range (cddr range)))
15432 ;; Adjust the first element to be the same as the lower limit.
15433 (if (and (not (atom (car range)))
15434 (< (cdar range) (car active)))
15435 (setcdr (car range) (1- (car active))))
15436 ;; Then we want to peel off any elements that are higher
15437 ;; than the upper active limit.
15438 (let ((srange range))
15439 ;; Go past all legal elements.
15440 (while (and (cdr srange)
15441 (<= (or (and (atom (cadr srange))
15443 (caadr srange)) (cdr active)))
15444 (setq srange (cdr srange)))
15446 ;; Nuke all remaining illegal elements.
15447 (setcdr srange nil))
15449 ;; Adjust the final element.
15450 (if (and (not (atom (car srange)))
15451 (> (cdar srange) (cdr active)))
15452 (setcdr (car srange) (cdr active))))
15453 ;; Compute the number of unread articles.
15455 (setq num (+ num (- (1+ (or (and (atom (car range)) (car range))
15457 (or (and (atom (car range)) (car range))
15459 (setq range (cdr range)))
15460 (setq num (max 0 (- (cdr active) num)))))
15461 ;; Set the number of unread articles.
15463 (setcar (gnus-gethash (gnus-info-group info) gnus-newsrc-hashtb) num))
15466 (defun gnus-activate-group (group &optional scan)
15467 ;; Check whether a group has been activated or not.
15468 ;; If SCAN, request a scan of that group as well.
15469 (let ((method (gnus-find-method-for-group group))
15471 (and (gnus-check-server method)
15472 ;; We escape all bugs and quit here to make it possible to
15473 ;; continue if a group is so out-there that it reports bugs
15477 (gnus-check-backend-function 'request-scan (car method))
15478 (gnus-request-scan group method))
15481 (gnus-request-group group)
15485 (set-buffer nntp-server-buffer)
15486 (goto-char (point-min))
15487 ;; Parse the result we got from `gnus-request-group'.
15488 (and (looking-at "[0-9]+ [0-9]+ \\([0-9]+\\) [0-9]+")
15490 (goto-char (match-beginning 1))
15492 group (setq active (cons (read (current-buffer))
15493 (read (current-buffer)))))
15494 ;; Return the new active info.
15497 (defun gnus-update-read-articles (group unread)
15498 "Update the list of read and ticked articles in GROUP using the
15499 UNREAD and TICKED lists.
15500 Note: UNSELECTED has to be sorted over `<'.
15501 Returns whether the updating was successful."
15502 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
15503 (entry (gnus-gethash group gnus-newsrc-hashtb))
15504 (info (nth 2 entry))
15505 (marked (gnus-info-marks info))
15507 (unread (sort (copy-sequence unread) '<))
15509 (if (or (not info) (not active))
15510 ;; There is no info on this group if it was, in fact,
15511 ;; killed. Gnus stores no information on killed groups, so
15512 ;; there's nothing to be done.
15513 ;; One could store the information somewhere temporarily,
15514 ;; perhaps... Hmmm...
15516 ;; Remove any negative articles numbers.
15517 (while (and unread (< (car unread) 0))
15518 (setq unread (cdr unread)))
15519 ;; Remove any expired article numbers
15520 (while (and unread (< (car unread) (car active)))
15521 (setq unread (cdr unread)))
15522 ;; Compute the ranges of read articles by looking at the list of
15523 ;; unread articles.
15525 (if (/= (car unread) prev)
15526 (setq read (cons (if (= prev (1- (car unread))) prev
15527 (cons prev (1- (car unread)))) read)))
15528 (setq prev (1+ (car unread)))
15529 (setq unread (cdr unread)))
15530 (when (<= prev (cdr active))
15531 (setq read (cons (cons prev (cdr active)) read)))
15532 ;; Enter this list into the group info.
15533 (gnus-info-set-read
15534 info (if (> (length read) 1) (nreverse read) read))
15535 ;; Set the number of unread articles in gnus-newsrc-hashtb.
15536 (gnus-get-unread-articles-in-group info (gnus-active group))
15539 (defun gnus-make-articles-unread (group articles)
15540 "Mark ARTICLES in GROUP as unread."
15541 (let* ((info (nth 2 (or (gnus-gethash group gnus-newsrc-hashtb)
15542 (gnus-gethash (gnus-group-real-name group)
15543 gnus-newsrc-hashtb))))
15544 (ranges (gnus-info-read info))
15547 (when (gnus-member-of-range
15548 (setq article (pop articles)) ranges)
15549 (setq news (cons article news))))
15551 (gnus-info-set-read
15552 info (gnus-remove-from-range (gnus-info-read info) (nreverse news)))
15553 (gnus-group-update-group group t))))
15555 ;; Enter all dead groups into the hashtb.
15556 (defun gnus-update-active-hashtb-from-killed ()
15557 (let ((hashtb (setq gnus-active-hashtb (make-vector 4095 0)))
15558 (lists (list gnus-killed-list gnus-zombie-list))
15561 (setq killed (car lists))
15563 (gnus-sethash (car killed) nil hashtb)
15564 (setq killed (cdr killed)))
15565 (setq lists (cdr lists)))))
15567 ;; Get the active file(s) from the backend(s).
15568 (defun gnus-read-active-file ()
15569 (gnus-group-set-mode-line)
15572 (if (gnus-check-server gnus-select-method)
15573 ;; The native server is available.
15574 (cons gnus-select-method gnus-secondary-select-methods)
15575 ;; The native server is down, so we just do the
15577 gnus-secondary-select-methods)
15578 ;; Also read from the archive server.
15579 (when gnus-message-archive-method
15580 (list "archive"))))
15582 (setq gnus-have-read-active-file nil)
15584 (set-buffer nntp-server-buffer)
15586 (let* ((method (if (stringp (car methods))
15587 (gnus-server-get-method nil (car methods))
15589 (where (nth 1 method))
15590 (mesg (format "Reading active file%s via %s..."
15591 (if (and where (not (zerop (length where))))
15592 (concat " from " where) "")
15594 (gnus-message 5 mesg)
15595 (when (gnus-check-server method)
15596 ;; Request that the backend scan its incoming messages.
15597 (and (gnus-check-backend-function 'request-scan (car method))
15598 (gnus-request-scan nil method))
15600 ((and (eq gnus-read-active-file 'some)
15601 (gnus-check-backend-function 'retrieve-groups (car method)))
15602 (let ((newsrc (cdr gnus-newsrc-alist))
15603 (gmethod (if (stringp method)
15604 (gnus-server-get-method nil method)
15607 (while (setq info (pop newsrc))
15608 (when (gnus-server-equal
15609 (gnus-find-method-for-group
15610 (gnus-info-group info) info)
15612 (push (gnus-group-real-name (gnus-info-group info))
15615 (gnus-check-server method)
15616 (setq list-type (gnus-retrieve-groups groups method))
15620 1 "Cannot read partial active file from %s server."
15624 ((eq list-type 'active)
15625 (gnus-active-to-gnus-format method gnus-active-hashtb))
15627 (gnus-groups-to-gnus-format method gnus-active-hashtb))))))
15629 (if (not (gnus-request-list method))
15631 (unless (equal method gnus-message-archive-method)
15632 (gnus-message 1 "Cannot read active file from %s server."
15635 (gnus-active-to-gnus-format method)
15636 ;; We mark this active file as read.
15637 (push method gnus-have-read-active-file)
15638 (gnus-message 5 "%sdone" mesg))))))
15639 (setq methods (cdr methods))))))
15641 ;; Read an active file and place the results in `gnus-active-hashtb'.
15642 (defun gnus-active-to-gnus-format (&optional method hashtb ignore-errors)
15644 (setq method gnus-select-method))
15645 (let ((cur (current-buffer))
15647 (if (and gnus-active-hashtb
15648 (not (equal method gnus-select-method)))
15650 (setq gnus-active-hashtb
15651 (if (equal method gnus-select-method)
15652 (gnus-make-hashtable
15653 (count-lines (point-min) (point-max)))
15654 (gnus-make-hashtable 4096))))))
15655 (flag-hashtb (gnus-make-hashtable 60)))
15656 ;; Delete unnecessary lines.
15657 (goto-char (point-min))
15658 (while (search-forward "\nto." nil t)
15659 (delete-region (1+ (match-beginning 0))
15660 (progn (forward-line 1) (point))))
15661 (or (string= gnus-ignored-newsgroups "")
15663 (goto-char (point-min))
15664 (delete-matching-lines gnus-ignored-newsgroups)))
15665 ;; Make the group names readable as a lisp expression even if they
15666 ;; contain special characters.
15667 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
15668 (goto-char (point-max))
15669 (while (re-search-backward "[][';?()#]" nil t)
15671 ;; If these are groups from a foreign select method, we insert the
15672 ;; group prefix in front of the group names.
15673 (and method (not (gnus-server-equal
15674 (gnus-server-get-method nil method)
15675 (gnus-server-get-method nil gnus-select-method)))
15676 (let ((prefix (gnus-group-prefixed-name "" method)))
15677 (goto-char (point-min))
15678 (while (and (not (eobp))
15679 (progn (insert prefix)
15680 (zerop (forward-line 1)))))))
15681 ;; Store the active file in a hash table.
15682 (goto-char (point-min))
15683 (if (string-match "%[oO]" gnus-group-line-format)
15684 ;; Suggested by Brian Edmonds <edmonds@cs.ubc.ca>.
15685 ;; If we want information on moderated groups, we use this
15687 (let* ((mod-hashtb (make-vector 7 0))
15688 (m (intern "m" mod-hashtb))
15690 (while (not (eobp))
15691 (condition-case nil
15693 (narrow-to-region (point) (gnus-point-at-eol))
15694 (setq group (let ((obarray hashtb)) (read cur)))
15695 (if (and (numberp (setq max (read cur)))
15696 (numberp (setq min (read cur)))
15698 (skip-chars-forward " \t")
15700 (or (= (following-char) ?=)
15701 (= (following-char) ?x)
15702 (= (following-char) ?j)))))
15703 (set group (cons min max))
15705 ;; Enter moderated groups into a list.
15706 (if (eq (let ((obarray mod-hashtb)) (read cur)) m)
15707 (setq gnus-moderated-list
15708 (cons (symbol-name group) gnus-moderated-list))))
15715 ;; And if we do not care about moderation, we use this loop,
15716 ;; which is faster.
15717 (let (group max min)
15718 (while (not (eobp))
15721 (narrow-to-region (point) (gnus-point-at-eol))
15722 ;; group gets set to a symbol interned in the hash table
15723 ;; (what a hack!!) - jwz
15724 (setq group (let ((obarray hashtb)) (read cur)))
15725 (if (and (numberp (setq max (read cur)))
15726 (numberp (setq min (read cur)))
15728 (skip-chars-forward " \t")
15730 (or (= (following-char) ?=)
15731 (= (following-char) ?x)
15732 (= (following-char) ?j)))))
15733 (set group (cons min max))
15741 (gnus-message 3 "Warning - illegal active: %s"
15743 (gnus-point-at-bol) (gnus-point-at-eol)))))))
15745 (forward-line 1))))))
15747 (defun gnus-groups-to-gnus-format (method &optional hashtb)
15748 ;; Parse a "groups" active file.
15749 (let ((cur (current-buffer))
15751 (if (and method gnus-active-hashtb)
15753 (setq gnus-active-hashtb
15754 (gnus-make-hashtable
15755 (count-lines (point-min) (point-max)))))))
15756 (prefix (and method
15757 (not (gnus-server-equal
15758 (gnus-server-get-method nil method)
15759 (gnus-server-get-method nil gnus-select-method)))
15760 (gnus-group-prefixed-name "" method))))
15762 (goto-char (point-min))
15763 ;; We split this into to separate loops, one with the prefix
15764 ;; and one without to speed the reading up somewhat.
15766 (let (min max opoint group)
15767 (while (not (eobp))
15770 (read cur) (read cur)
15771 (setq min (read cur)
15774 (skip-chars-forward " \t")
15777 (set (let ((obarray hashtb)) (read cur))
15779 (error (and group (symbolp group) (set group nil))))
15781 (let (min max group)
15782 (while (not (eobp))
15784 (if (= (following-char) ?2)
15786 (read cur) (read cur)
15787 (setq min (read cur)
15789 (set (setq group (let ((obarray hashtb)) (read cur)))
15791 (error (and group (symbolp group) (set group nil))))
15792 (forward-line 1))))))
15794 (defun gnus-read-newsrc-file (&optional force)
15795 "Read startup file.
15796 If FORCE is non-nil, the .newsrc file is read."
15797 ;; Reset variables that might be defined in the .newsrc.eld file.
15798 (let ((variables gnus-variable-list))
15800 (set (car variables) nil)
15801 (setq variables (cdr variables))))
15802 (let* ((newsrc-file gnus-current-startup-file)
15803 (quick-file (concat newsrc-file ".el")))
15805 ;; We always load the .newsrc.eld file. If always contains
15806 ;; much information that can not be gotten from the .newsrc
15807 ;; file (ticked articles, killed groups, foreign methods, etc.)
15808 (gnus-read-newsrc-el-file quick-file)
15810 (if (and (file-exists-p gnus-current-startup-file)
15812 (and (file-newer-than-file-p newsrc-file quick-file)
15813 (file-newer-than-file-p newsrc-file
15814 (concat quick-file "d")))
15815 (not gnus-newsrc-alist)))
15816 ;; We read the .newsrc file. Note that if there if a
15817 ;; .newsrc.eld file exists, it has already been read, and
15818 ;; the `gnus-newsrc-hashtb' has been created. While reading
15819 ;; the .newsrc file, Gnus will only use the information it
15820 ;; can find there for changing the data already read -
15821 ;; ie. reading the .newsrc file will not trash the data
15822 ;; already read (except for read articles).
15824 (gnus-message 5 "Reading %s..." newsrc-file)
15825 (set-buffer (find-file-noselect newsrc-file))
15826 (buffer-disable-undo (current-buffer))
15827 (gnus-newsrc-to-gnus-format)
15828 (kill-buffer (current-buffer))
15829 (gnus-message 5 "Reading %s...done" newsrc-file)))
15831 ;; Read any slave files.
15833 (gnus-master-read-slave-newsrc)))))
15835 (defun gnus-read-newsrc-el-file (file)
15836 (let ((ding-file (concat file "d")))
15837 ;; We always, always read the .eld file.
15838 (gnus-message 5 "Reading %s..." ding-file)
15839 (let (gnus-newsrc-assoc)
15840 (condition-case nil
15841 (load ding-file t t t)
15843 (gnus-message 1 "Error in %s" ding-file)
15845 (when gnus-newsrc-assoc
15846 (setq gnus-newsrc-alist gnus-newsrc-assoc)))
15847 (gnus-make-hashtable-from-newsrc-alist)
15848 (when (file-newer-than-file-p file ding-file)
15849 ;; Old format quick file
15850 (gnus-message 5 "Reading %s..." file)
15851 ;; The .el file is newer than the .eld file, so we read that one
15853 (gnus-read-old-newsrc-el-file file))))
15855 ;; Parse the old-style quick startup file
15856 (defun gnus-read-old-newsrc-el-file (file)
15857 (let (newsrc killed marked group m info)
15859 (let ((gnus-killed-assoc nil)
15860 gnus-marked-assoc gnus-newsrc-alist gnus-newsrc-assoc)
15862 (condition-case nil
15865 (setq newsrc gnus-newsrc-assoc
15866 killed gnus-killed-assoc
15867 marked gnus-marked-assoc)))
15868 (setq gnus-newsrc-alist nil)
15869 (while (setq info (gnus-get-info (setq group (pop newsrc))))
15872 (gnus-info-set-read info (cddr group))
15873 (gnus-info-set-level
15874 info (if (nth 1 group) gnus-level-default-subscribed
15875 gnus-level-default-unsubscribed))
15876 (setq gnus-newsrc-alist (cons info gnus-newsrc-alist)))
15879 (if (nth 1 group) gnus-level-default-subscribed
15880 gnus-level-default-unsubscribed)
15882 gnus-newsrc-alist))
15883 ;; Copy marks into info.
15884 (when (setq m (assoc (car group) marked))
15885 (unless (nthcdr 3 info)
15886 (nconc info (list nil)))
15887 (gnus-info-set-marks
15888 info (list (cons 'tick (gnus-compress-sequence
15889 (sort (cdr m) '<) t))))))
15890 (setq newsrc killed)
15892 (setcar newsrc (caar newsrc))
15893 (setq newsrc (cdr newsrc)))
15894 (setq gnus-killed-list killed))
15895 ;; The .el file version of this variable does not begin with
15896 ;; "options", while the .eld version does, so we just add it if it
15899 gnus-newsrc-options
15901 (and (not (string-match "^ *options" gnus-newsrc-options))
15902 (setq gnus-newsrc-options (concat "options " gnus-newsrc-options)))
15903 (and (not (string-match "\n$" gnus-newsrc-options))
15904 (setq gnus-newsrc-options (concat gnus-newsrc-options "\n")))
15905 ;; Finally, if we read some options lines, we parse them.
15906 (or (string= gnus-newsrc-options "")
15907 (gnus-newsrc-parse-options gnus-newsrc-options))))
15909 (setq gnus-newsrc-alist (nreverse gnus-newsrc-alist))
15910 (gnus-make-hashtable-from-newsrc-alist)))
15912 (defun gnus-make-newsrc-file (file)
15913 "Make server dependent file name by catenating FILE and server host name."
15914 (let* ((file (expand-file-name file nil))
15915 (real-file (concat file "-" (nth 1 gnus-select-method))))
15916 (if (or (file-exists-p real-file)
15917 (file-exists-p (concat real-file ".el"))
15918 (file-exists-p (concat real-file ".eld")))
15921 (defun gnus-newsrc-to-gnus-format ()
15922 (setq gnus-newsrc-options "")
15923 (setq gnus-newsrc-options-n nil)
15925 (or gnus-active-hashtb
15926 (setq gnus-active-hashtb (make-vector 4095 0)))
15927 (let ((buf (current-buffer))
15928 (already-read (> (length gnus-newsrc-alist) 1))
15929 group subscribed options-symbol newsrc Options-symbol
15931 (goto-char (point-min))
15932 ;; We intern the symbol `options' in the active hashtb so that we
15933 ;; can `eq' against it later.
15934 (set (setq options-symbol (intern "options" gnus-active-hashtb)) nil)
15935 (set (setq Options-symbol (intern "Options" gnus-active-hashtb)) nil)
15937 (while (not (eobp))
15938 ;; We first read the first word on the line by narrowing and
15939 ;; then reading into `gnus-active-hashtb'. Most groups will
15940 ;; already exist in that hashtb, so this will save some string
15944 (progn (skip-chars-forward "^ \t!:\n") (point)))
15945 (goto-char (point-min))
15947 (and (/= (point-min) (point-max))
15948 (let ((obarray gnus-active-hashtb)) (read buf))))
15950 ;; Now, the symbol we have read is either `options' or a group
15951 ;; name. If it is an options line, we just add it to a string.
15953 ((or (eq symbol options-symbol)
15954 (eq symbol Options-symbol))
15955 (setq gnus-newsrc-options
15956 ;; This concating is quite inefficient, but since our
15957 ;; thorough studies show that approx 99.37% of all
15958 ;; .newsrc files only contain a single options line, we
15959 ;; don't give a damn, frankly, my dear.
15960 (concat gnus-newsrc-options
15962 (gnus-point-at-bol)
15963 ;; Options may continue on the next line.
15964 (or (and (re-search-forward "^[^ \t]" nil 'move)
15965 (progn (beginning-of-line) (point)))
15969 ;; Group names can be just numbers.
15970 (when (numberp symbol)
15971 (setq symbol (intern (int-to-string symbol) gnus-active-hashtb)))
15972 (or (boundp symbol) (set symbol nil))
15973 ;; It was a group name.
15974 (setq subscribed (= (following-char) ?:)
15975 group (symbol-name symbol)
15978 ;; If the line ends here, this is clearly a buggy line, so
15979 ;; we put point a the beginning of line and let the cond
15980 ;; below do the error handling.
15981 (beginning-of-line)
15982 ;; We skip to the beginning of the ranges.
15983 (skip-chars-forward "!: \t"))
15984 ;; We are now at the beginning of the list of read articles.
15985 ;; We read them range by range.
15988 ((looking-at "[0-9]+")
15989 ;; We narrow and read a number instead of buffer-substring/
15990 ;; string-to-int because it's faster. narrow/widen is
15991 ;; faster than save-restriction/narrow, and save-restriction
15992 ;; produces a garbage object.
15994 (narrow-to-region (match-beginning 0) (match-end 0))
15997 ;; If the next character is a dash, then this is a range.
15998 (if (= (following-char) ?-)
16000 ;; We read the upper bound of the range.
16002 (if (not (looking-at "[0-9]+"))
16003 ;; This is a buggy line, by we pretend that
16004 ;; it's kinda OK. Perhaps the user should be
16006 (setq reads (cons num1 reads))
16011 (narrow-to-region (match-beginning 0)
16016 ;; It was just a simple number, so we add it to the
16018 (setq reads (cons num1 reads)))
16019 ;; If the next char in ?\n, then we have reached the end
16020 ;; of the line and return nil.
16021 (/= (following-char) ?\n))
16022 ((= (following-char) ?\n)
16023 ;; End of line, so we end.
16026 ;; Not numbers and not eol, so this might be a buggy
16029 ;; If it was eob instead of ?\n, we allow it.
16031 ;; The line was buggy.
16033 (gnus-message 3 "Mangled line: %s"
16034 (buffer-substring (gnus-point-at-bol)
16035 (gnus-point-at-eol)))
16039 ;; Skip past ", ". Spaces are illegal in these ranges, but
16040 ;; we allow them, because it's a common mistake to put a
16041 ;; space after the comma.
16042 (skip-chars-forward ", "))
16044 ;; We have already read .newsrc.eld, so we gently update the
16045 ;; data in the hash table with the information we have just
16048 (let ((info (gnus-get-info group))
16051 ;; There is an entry for this file in the alist.
16053 (gnus-info-set-read info (nreverse reads))
16054 ;; We update the level very gently. In fact, we
16055 ;; only change it if there's been a status change
16056 ;; from subscribed to unsubscribed, or vice versa.
16057 (setq level (gnus-info-level info))
16058 (cond ((and (<= level gnus-level-subscribed)
16060 (setq level (if reads
16061 gnus-level-default-unsubscribed
16062 (1+ gnus-level-default-unsubscribed))))
16063 ((and (> level gnus-level-subscribed) subscribed)
16064 (setq level gnus-level-default-subscribed)))
16065 (gnus-info-set-level info level))
16066 ;; This is a new group.
16067 (setq info (list group
16069 gnus-level-default-subscribed
16071 (1+ gnus-level-subscribed)
16072 gnus-level-default-unsubscribed))
16073 (nreverse reads))))
16074 (setq newsrc (cons info newsrc))))))
16077 (setq newsrc (nreverse newsrc))
16079 (if (not already-read)
16081 ;; We now have two newsrc lists - `newsrc', which is what we
16082 ;; have read from .newsrc, and `gnus-newsrc-alist', which is
16083 ;; what we've read from .newsrc.eld. We have to merge these
16084 ;; lists. We do this by "attaching" any (foreign) groups in the
16085 ;; gnus-newsrc-alist to the (native) group that precedes them.
16086 (let ((rc (cdr gnus-newsrc-alist))
16087 (prev gnus-newsrc-alist)
16090 (or (null (nth 4 (car rc))) ; It's a native group.
16091 (assoc (caar rc) newsrc) ; It's already in the alist.
16092 (if (setq entry (assoc (caar prev) newsrc))
16093 (setcdr (setq mentry (memq entry newsrc))
16094 (cons (car rc) (cdr mentry)))
16095 (setq newsrc (cons (car rc) newsrc))))
16099 (setq gnus-newsrc-alist newsrc)
16100 ;; We make the newsrc hashtb.
16101 (gnus-make-hashtable-from-newsrc-alist)
16103 ;; Finally, if we read some options lines, we parse them.
16104 (or (string= gnus-newsrc-options "")
16105 (gnus-newsrc-parse-options gnus-newsrc-options))))
16107 ;; Parse options lines to find "options -n !all rec.all" and stuff.
16108 ;; The return value will be a list on the form
16109 ;; ((regexp1 . ignore)
16110 ;; (regexp2 . subscribe)...)
16111 ;; When handling new newsgroups, groups that match a `ignore' regexp
16112 ;; will be ignored, and groups that match a `subscribe' regexp will be
16113 ;; subscribed. A line like
16114 ;; options -n !all rec.all
16115 ;; will lead to a list that looks like
16116 ;; (("^rec\\..+" . subscribe)
16117 ;; ("^.+" . ignore))
16118 ;; So all "rec.*" groups will be subscribed, while all the other
16119 ;; groups will be ignored. Note that "options -n !all rec.all" is very
16120 ;; different from "options -n rec.all !all".
16121 (defun gnus-newsrc-parse-options (options)
16124 (gnus-set-work-buffer)
16125 (insert (regexp-quote options))
16126 ;; First we treat all continuation lines.
16127 (goto-char (point-min))
16128 (while (re-search-forward "\n[ \t]+" nil t)
16129 (replace-match " " t t))
16130 ;; Then we transform all "all"s into ".+"s.
16131 (goto-char (point-min))
16132 (while (re-search-forward "\\ball\\b" nil t)
16133 (replace-match ".+" t t))
16134 (goto-char (point-min))
16135 ;; We remove all other options than the "-n" ones.
16136 (while (re-search-forward "[ \t]-[^n][^-]*" nil t)
16137 (replace-match " ")
16139 (goto-char (point-min))
16141 ;; We are only interested in "options -n" lines - we
16142 ;; ignore the other option lines.
16143 (while (re-search-forward "[ \t]-n" nil t)
16145 (or (save-excursion
16146 (and (re-search-forward "[ \t]-n" (gnus-point-at-eol) t)
16148 (gnus-point-at-eol)))
16149 ;; Search for all "words"...
16150 (while (re-search-forward "[^ \t,\n]+" eol t)
16151 (if (= (char-after (match-beginning 0)) ?!)
16152 ;; If the word begins with a bang (!), this is a "not"
16153 ;; spec. We put this spec (minus the bang) and the
16154 ;; symbol `ignore' into the list.
16155 (setq out (cons (cons (concat
16156 "^" (buffer-substring
16157 (1+ (match-beginning 0))
16160 ;; There was no bang, so this is a "yes" spec.
16161 (setq out (cons (cons (concat "^" (match-string 0))
16162 'subscribe) out)))))
16164 (setq gnus-newsrc-options-n out))))
16166 (defun gnus-save-newsrc-file (&optional force)
16167 "Save .newsrc file."
16168 ;; Note: We cannot save .newsrc file if all newsgroups are removed
16169 ;; from the variable gnus-newsrc-alist.
16170 (when (and (or gnus-newsrc-alist gnus-killed-list)
16171 gnus-current-startup-file)
16173 (if (and (or gnus-use-dribble-file gnus-slave)
16175 (or (not gnus-dribble-buffer)
16176 (not (buffer-name gnus-dribble-buffer))
16177 (zerop (save-excursion
16178 (set-buffer gnus-dribble-buffer)
16180 (gnus-message 4 "(No changes need to be saved)")
16181 (run-hooks 'gnus-save-newsrc-hook)
16183 (gnus-slave-save-newsrc)
16185 (when gnus-save-newsrc-file
16186 (gnus-message 5 "Saving %s..." gnus-current-startup-file)
16187 (gnus-gnus-to-newsrc-format)
16188 (gnus-message 5 "Saving %s...done" gnus-current-startup-file))
16189 ;; Save .newsrc.eld.
16190 (set-buffer (get-buffer-create " *Gnus-newsrc*"))
16191 (make-local-variable 'version-control)
16192 (setq version-control 'never)
16193 (setq buffer-file-name
16194 (concat gnus-current-startup-file ".eld"))
16195 (gnus-add-current-to-buffer-list)
16196 (buffer-disable-undo (current-buffer))
16198 (gnus-message 5 "Saving %s.eld..." gnus-current-startup-file)
16199 (gnus-gnus-to-quick-newsrc-format)
16200 (run-hooks 'gnus-save-quick-newsrc-hook)
16202 (kill-buffer (current-buffer))
16204 5 "Saving %s.eld...done" gnus-current-startup-file))
16205 (gnus-dribble-delete-file)))))
16207 (defun gnus-gnus-to-quick-newsrc-format ()
16208 "Insert Gnus variables such as gnus-newsrc-alist in lisp format."
16209 (insert ";; Gnus startup file.\n")
16210 (insert ";; Never delete this file - touch .newsrc instead to force Gnus\n")
16211 (insert ";; to read .newsrc.\n")
16212 (insert "(setq gnus-newsrc-file-version "
16213 (prin1-to-string gnus-version) ")\n")
16215 (if gnus-save-killed-list gnus-variable-list
16216 ;; Remove the `gnus-killed-list' from the list of variables
16217 ;; to be saved, if required.
16218 (delq 'gnus-killed-list (copy-sequence gnus-variable-list))))
16219 ;; Peel off the "dummy" group.
16220 (gnus-newsrc-alist (cdr gnus-newsrc-alist))
16222 ;; Insert the variables into the file.
16224 (when (and (boundp (setq variable (pop variables)))
16225 (symbol-value variable))
16226 (insert "(setq " (symbol-name variable) " '"
16227 (prin1-to-string (symbol-value variable)) ")\n")))))
16229 (defun gnus-gnus-to-newsrc-format ()
16230 ;; Generate and save the .newsrc file.
16231 (let ((newsrc (cdr gnus-newsrc-alist))
16234 (set-buffer (create-file-buffer gnus-current-startup-file))
16235 (setq buffer-file-name gnus-current-startup-file)
16236 (buffer-disable-undo (current-buffer))
16239 (if gnus-newsrc-options (insert gnus-newsrc-options))
16240 ;; Write subscribed and unsubscribed.
16241 (while (setq info (pop newsrc))
16242 ;; Don't write foreign groups to .newsrc.
16243 (when (gnus-server-equal (gnus-info-method info) gnus-select-method)
16244 (insert (gnus-info-group info)
16245 (if (> (gnus-info-level info) gnus-level-subscribed)
16247 (when (setq ranges (gnus-info-read info))
16249 (if (not (listp (cdr ranges)))
16250 (if (= (car ranges) (cdr ranges))
16251 (insert (int-to-string (car ranges)))
16252 (insert (int-to-string (car ranges)) "-"
16253 (int-to-string (cdr ranges))))
16255 (setq range (car ranges)
16256 ranges (cdr ranges))
16257 (if (or (atom range) (= (car range) (cdr range)))
16258 (insert (int-to-string
16259 (or (and (atom range) range)
16261 (insert (int-to-string (car range)) "-"
16262 (int-to-string (cdr range))))
16263 (if ranges (insert ",")))))
16265 (make-local-variable 'version-control)
16266 (setq version-control 'never)
16267 ;; It has been reported that sometime the modtime on the .newsrc
16268 ;; file seems to be off. We really do want to overwrite it, so
16269 ;; we clear the modtime here before saving. It's a bit odd,
16271 ;; sometimes the modtime clear isn't sufficient. most brute force:
16272 ;; delete the silly thing entirely first. but this fails to provide
16273 ;; such niceties as .newsrc~ creation.
16274 (if gnus-modtime-botch
16275 (delete-file gnus-startup-file)
16276 (clear-visited-file-modtime))
16277 (run-hooks 'gnus-save-standard-newsrc-hook)
16279 (kill-buffer (current-buffer)))))
16283 ;;; Slave functions.
16286 (defun gnus-slave-save-newsrc ()
16288 (set-buffer gnus-dribble-buffer)
16290 (make-temp-name (concat gnus-current-startup-file "-slave-"))))
16291 (write-region (point-min) (point-max) slave-name nil 'nomesg))))
16293 (defun gnus-master-read-slave-newsrc ()
16296 (file-name-directory gnus-current-startup-file)
16300 (file-name-nondirectory gnus-current-startup-file)
16304 (if (not slave-files)
16305 () ; There are no slave files to read.
16306 (gnus-message 7 "Reading slave newsrcs...")
16308 (set-buffer (get-buffer-create " *gnus slave*"))
16309 (buffer-disable-undo (current-buffer))
16311 (sort (mapcar (lambda (file)
16312 (list (nth 5 (file-attributes file)) file))
16315 (or (< (caar f1) (caar f2))
16316 (< (nth 1 (car f1)) (nth 1 (car f2)))))))
16319 (setq file (nth 1 (car slave-files)))
16320 (insert-file-contents file)
16321 (if (condition-case ()
16323 (eval-buffer (current-buffer))
16326 (gnus-message 3 "Possible error in %s" file)
16330 (or gnus-slave ; Slaves shouldn't delete these files.
16334 (setq slave-files (cdr slave-files))))
16335 (gnus-message 7 "Reading slave newsrcs...done"))))
16339 ;;; Group description.
16342 (defun gnus-read-all-descriptions-files ()
16343 (let ((methods (cons gnus-select-method
16345 (when gnus-message-archive-method
16347 gnus-secondary-select-methods))))
16349 (gnus-read-descriptions-file (car methods))
16350 (setq methods (cdr methods)))
16353 (defun gnus-read-descriptions-file (&optional method)
16354 (let ((method (or method gnus-select-method)))
16355 (when (stringp method)
16356 (setq method (gnus-server-to-method method)))
16357 ;; We create the hashtable whether we manage to read the desc file
16358 ;; to avoid trying to re-read after a failed read.
16359 (or gnus-description-hashtb
16360 (setq gnus-description-hashtb
16361 (gnus-make-hashtable (length gnus-active-hashtb))))
16362 ;; Mark this method's desc file as read.
16363 (gnus-sethash (gnus-group-prefixed-name "" method) "Has read"
16364 gnus-description-hashtb)
16366 (gnus-message 5 "Reading descriptions file via %s..." (car method))
16368 ((not (gnus-check-server method))
16369 (gnus-message 1 "Couldn't open server")
16371 ((not (gnus-request-list-newsgroups method))
16372 (gnus-message 1 "Couldn't read newsgroups descriptions")
16378 (set-buffer nntp-server-buffer)
16379 (goto-char (point-min))
16380 (if (or (search-forward "\n.\n" nil t)
16381 (goto-char (point-max)))
16383 (beginning-of-line)
16384 (narrow-to-region (point-min) (point))))
16385 (goto-char (point-min))
16386 (while (not (eobp))
16387 ;; If we get an error, we set group to 0, which is not a
16391 (let ((obarray gnus-description-hashtb))
16392 ;; Group is set to a symbol interned in this
16394 (read nntp-server-buffer))
16396 (skip-chars-forward " \t")
16397 ;; ... which leads to this line being effectively ignored.
16398 (and (symbolp group)
16399 (set group (buffer-substring
16400 (point) (progn (end-of-line) (point)))))
16401 (forward-line 1))))
16402 (gnus-message 5 "Reading descriptions file...done")
16405 (defun gnus-group-get-description (group)
16406 "Get the description of a group by sending XGTITLE to the server."
16407 (when (gnus-request-group-description group)
16409 (set-buffer nntp-server-buffer)
16410 (goto-char (point-min))
16411 (when (looking-at "[^ \t]+[ \t]+\\(.*\\)")
16412 (match-string 1)))))
16416 ;;; Buffering of read articles.
16419 (defvar gnus-backlog-buffer " *Gnus Backlog*")
16420 (defvar gnus-backlog-articles nil)
16421 (defvar gnus-backlog-hashtb nil)
16423 (defun gnus-backlog-buffer ()
16424 "Return the backlog buffer."
16425 (or (get-buffer gnus-backlog-buffer)
16427 (set-buffer (get-buffer-create gnus-backlog-buffer))
16428 (buffer-disable-undo (current-buffer))
16429 (setq buffer-read-only t)
16430 (gnus-add-current-to-buffer-list)
16431 (get-buffer gnus-backlog-buffer))))
16433 (defun gnus-backlog-setup ()
16434 "Initialize backlog variables."
16435 (unless gnus-backlog-hashtb
16436 (setq gnus-backlog-hashtb (make-vector 1023 0))))
16438 (defun gnus-backlog-shutdown ()
16439 "Clear all backlog variables and buffers."
16440 (when (get-buffer gnus-backlog-buffer)
16441 (kill-buffer gnus-backlog-buffer))
16442 (setq gnus-backlog-hashtb nil
16443 gnus-backlog-articles nil))
16445 (defun gnus-backlog-enter-article (group number buffer)
16446 (gnus-backlog-setup)
16447 (let ((ident (intern (concat group ":" (int-to-string number))
16448 gnus-backlog-hashtb))
16450 (if (memq ident gnus-backlog-articles)
16451 () ; It's already kept.
16452 ;; Remove the oldest article, if necessary.
16453 (and (numberp gnus-keep-backlog)
16454 (>= (length gnus-backlog-articles) gnus-keep-backlog)
16455 (gnus-backlog-remove-oldest-article))
16456 (setq gnus-backlog-articles (cons ident gnus-backlog-articles))
16457 ;; Insert the new article.
16459 (set-buffer (gnus-backlog-buffer))
16460 (let (buffer-read-only)
16461 (goto-char (point-max))
16462 (or (bolp) (insert "\n"))
16464 (insert-buffer-substring buffer)
16465 ;; Tag the beginning of the article with the ident.
16466 (put-text-property b (1+ b) 'gnus-backlog ident))))))
16468 (defun gnus-backlog-remove-oldest-article ()
16470 (set-buffer (gnus-backlog-buffer))
16471 (goto-char (point-min))
16472 (if (zerop (buffer-size))
16473 () ; The buffer is empty.
16474 (let ((ident (get-text-property (point) 'gnus-backlog))
16476 ;; Remove the ident from the list of articles.
16478 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16479 ;; Delete the article itself.
16481 (point) (next-single-property-change
16482 (1+ (point)) 'gnus-backlog nil (point-max)))))))
16484 (defun gnus-backlog-request-article (group number buffer)
16485 (when (numberp number)
16486 (gnus-backlog-setup)
16487 (let ((ident (intern (concat group ":" (int-to-string number))
16488 gnus-backlog-hashtb))
16490 (when (memq ident gnus-backlog-articles)
16491 ;; It was in the backlog.
16493 (set-buffer (gnus-backlog-buffer))
16494 (if (not (setq beg (text-property-any
16495 (point-min) (point-max) 'gnus-backlog
16497 ;; It wasn't in the backlog after all.
16499 (setq gnus-backlog-articles (delq ident gnus-backlog-articles)))
16500 ;; Find the end (i. e., the beginning of the next article).
16502 (next-single-property-change
16503 (1+ beg) 'gnus-backlog (current-buffer) (point-max)))))
16504 (let ((buffer-read-only nil))
16506 (insert-buffer-substring gnus-backlog-buffer beg end)
16509 ;; Allow redefinition of Gnus functions.
16511 (gnus-ems-redefine)
16515 ;;; gnus.el ends here